GtkWidget*
gnome_appbar_new (gboolean has_progress,
gboolean has_status,
GnomePreferencesType interactivity)
{
GnomeAppBar * ab = gtk_type_new (gnome_appbar_get_type ());
gnome_appbar_construct(ab, has_progress, has_status, interactivity);
return GTK_WIDGET(ab);
}
void
gnome_appbar_construct(GnomeAppBar * ab,
gboolean has_progress,
gboolean has_status,
GnomePreferencesType interactivity)
{
GtkBox *box;
g_return_if_fail( ((has_status == FALSE) &&
(interactivity == GNOME_PREFERENCES_NEVER)) ||
(has_status == TRUE));
box = GTK_BOX (ab);
box->spacing = GNOME_PAD_SMALL;
box->homogeneous = FALSE;
if (has_progress)
ab->progress = gtk_progress_bar_new();
else
ab->progress = NULL;
/*
* If the progress meter goes on the right then we place it after we
* create the status line.
*/
if (has_progress && !gnome_preferences_get_statusbar_meter_on_right ())
gtk_box_pack_start (box, ab->progress, FALSE, FALSE, 0);
if ( has_status ) {
if ( (interactivity == GNOME_PREFERENCES_ALWAYS) ||
( (interactivity == GNOME_PREFERENCES_USER) &&
gnome_preferences_get_statusbar_interactive()) ) {
ab->interactive = TRUE;
ab->status = gtk_entry_new();
gtk_signal_connect (GTK_OBJECT(ab->status), "delete_text",
GTK_SIGNAL_FUNC(entry_delete_text_cb),
ab);
gtk_signal_connect (GTK_OBJECT(ab->status), "insert_text",
GTK_SIGNAL_FUNC(entry_insert_text_cb),
ab);
gtk_signal_connect_after(GTK_OBJECT(ab->status), "key_press_event",
GTK_SIGNAL_FUNC(entry_key_press_cb),
ab);
gtk_signal_connect(GTK_OBJECT(ab->status), "activate",
GTK_SIGNAL_FUNC(entry_activate_cb),
ab);
/* no prompt now */
gtk_entry_set_editable(GTK_ENTRY(ab->status), FALSE);
gtk_box_pack_start (box, ab->status, TRUE, TRUE, 0);
}
else {
GtkWidget * frame;
ab->interactive = FALSE;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
ab->status = gtk_label_new ("");
gtk_misc_set_alignment (GTK_MISC (ab->status), 0.0, 0.0);
gtk_box_pack_start (box, frame, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER(frame), ab->status);
gtk_widget_show (frame);
}
}
else {
ab->status = NULL;
ab->interactive = FALSE;
}
if (has_progress && gnome_preferences_get_statusbar_meter_on_right ())
gtk_box_pack_start (box, ab->progress, FALSE, FALSE, 0);
if (ab->status) gtk_widget_show (ab->status);
if (ab->progress) gtk_widget_show(ab->progress);
}
|