From: <kr_...@us...> - 2003-11-16 13:26:00
|
Update of /cvsroot/htoolkit/port/src/cbits/GTK In directory sc8-pr-cvs1:/tmp/cvs-serv14422/src/cbits/GTK Modified Files: StatusBar.c Log Message: Added support for status bar indicators. (Linux only) Index: StatusBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/GTK/StatusBar.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StatusBar.c 16 Nov 2003 09:01:59 -0000 1.3 --- StatusBar.c 16 Nov 2003 13:25:20 -0000 1.4 *************** *** 1,4 **** --- 1,5 ---- #include "StatusBar.h" #include "Internals.h" + #include "Handlers_stub.h" void osSetStatusBarVisible(BOOL visible) *************** *** 34,36 **** --- 35,115 ---- { gnome_appbar_set_status(GNOME_APPBAR(GNOME_APP(gFrameWidget)->statusbar), title); + } + + static void calc_pack_end_count(GtkWidget *child, gpointer data) + { + gboolean expand; + gboolean fill; + guint padding; + GtkPackType pack_type; + + gtk_box_query_child_packing(GTK_BOX(gtk_widget_get_parent(child)), child, + &expand, &fill, &padding, &pack_type); + + if (pack_type == GTK_PACK_END) + (*((int *) data))++; + } + + static gboolean indicator_button_press_handler(GtkWidget *widget, GdkEventButton *event, gpointer user_data) + { + if (event->type == GDK_2BUTTON_PRESS && event->button == 1) + handleIndicatorCommand((IndicatorHandle) user_data); + + return TRUE; + } + + + IndicatorHandle osCreateIndicator(int index) + { + GtkWidget *label, *frame, *ebox; + + if (index >= 0) + { + int count = 0; + gtk_container_foreach(GTK_CONTAINER(GNOME_APP(gFrameWidget)->statusbar), calc_pack_end_count, &count); + index = count-index; + } + else + index = 0; + + // create the frame for the indicator + frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN); + gtk_signal_connect (GTK_OBJECT(frame), "destroy", + GTK_SIGNAL_FUNC(handleIndicatorDestroy), + NULL); + + // create the event box inside the frame + ebox = gtk_event_box_new(); + gtk_widget_set_events (ebox, GDK_BUTTON2_MOTION_MASK); + gtk_signal_connect (GTK_OBJECT(ebox), "button-press-event", + GTK_SIGNAL_FUNC(indicator_button_press_handler), + frame); + gtk_container_add (GTK_CONTAINER(frame), ebox); + + // create the label inside the event box + label = gtk_label_new(""); + gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.0); + gtk_container_add (GTK_CONTAINER(ebox), label); + + gtk_box_pack_end(GTK_BOX(GNOME_APP(gFrameWidget)->statusbar), frame, FALSE, TRUE, 0); + gtk_box_reorder_child(GTK_BOX(GNOME_APP(gFrameWidget)->statusbar), frame, index); + gtk_widget_show_all(frame); + + return frame; + } + + void osDestroyIndicator(IndicatorHandle indicator) + { + gtk_widget_destroy(indicator); + } + + char *osGetIndicatorTitle(IndicatorHandle indicator) + { + return strdup(gtk_label_get_text(GTK_LABEL(GTK_BIN(GTK_BIN(indicator)->child)->child))); + } + + void osSetIndicatorTitle(IndicatorHandle indicator, char *title) + { + gtk_label_set_text(GTK_LABEL(GTK_BIN(GTK_BIN(indicator)->child)->child), title); } |