diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/shortcut-bar/ChangeLog | 9 | ||||
-rw-r--r-- | widgets/shortcut-bar/e-shortcut-bar.c | 70 | ||||
-rw-r--r-- | widgets/shortcut-bar/e-shortcut-bar.h | 16 | ||||
-rw-r--r-- | widgets/shortcut-bar/test-shortcut-bar.c | 54 |
4 files changed, 145 insertions, 4 deletions
diff --git a/widgets/shortcut-bar/ChangeLog b/widgets/shortcut-bar/ChangeLog index 9b6be0117d..c49b12ca72 100644 --- a/widgets/shortcut-bar/ChangeLog +++ b/widgets/shortcut-bar/ChangeLog @@ -1,3 +1,12 @@ +2000-05-18 Damon Chaplin <damon@helixcode.com> + + * e-shortcut-bar.[hc]: new signals "added_item", "removed_item", + "added_group", "removed_group". Note that the removed signals are + emitted just before the item/group is actually removed. + + * test-shortcut-bar.c: updated to test the new signals, and ref'ed + the pixbufs in the icon callback. + 2000-05-16 Ettore Perazzoli <ettore@helixcode.com> * e-clipped-label.c: Moved to $(top_srcdir)/widgets/misc. diff --git a/widgets/shortcut-bar/e-shortcut-bar.c b/widgets/shortcut-bar/e-shortcut-bar.c index 63b511ed82..bca9d5c61a 100644 --- a/widgets/shortcut-bar/e-shortcut-bar.c +++ b/widgets/shortcut-bar/e-shortcut-bar.c @@ -91,6 +91,10 @@ static GdkPixbuf* e_shortcut_bar_load_image (const gchar *filename); enum { ITEM_SELECTED, + ITEM_ADDED, + ITEM_REMOVED, + GROUP_ADDED, + GROUP_REMOVED, LAST_SIGNAL }; @@ -144,6 +148,44 @@ e_shortcut_bar_class_init (EShortcutBarClass *class) GTK_TYPE_NONE, 3, GTK_TYPE_GDK_EVENT, GTK_TYPE_INT, GTK_TYPE_INT); + e_shortcut_bar_signals[ITEM_ADDED] = + gtk_signal_new ("item_added", + GTK_RUN_LAST | GTK_RUN_ACTION, + object_class->type, + GTK_SIGNAL_OFFSET (EShortcutBarClass, + added_item), + gtk_marshal_NONE__INT_INT, + GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); + + /* This is emitted just before the item is actually removed. */ + e_shortcut_bar_signals[ITEM_REMOVED] = + gtk_signal_new ("item_removed", + GTK_RUN_LAST | GTK_RUN_ACTION, + object_class->type, + GTK_SIGNAL_OFFSET (EShortcutBarClass, + removed_item), + gtk_marshal_NONE__INT_INT, + GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); + + e_shortcut_bar_signals[GROUP_ADDED] = + gtk_signal_new ("group_added", + GTK_RUN_LAST | GTK_RUN_ACTION, + object_class->type, + GTK_SIGNAL_OFFSET (EShortcutBarClass, + added_group), + gtk_marshal_NONE__INT, + GTK_TYPE_NONE, 1, GTK_TYPE_INT); + + /* This is emitted just before the group is actually removed. */ + e_shortcut_bar_signals[GROUP_REMOVED] = + gtk_signal_new ("group_removed", + GTK_RUN_LAST | GTK_RUN_ACTION, + object_class->type, + GTK_SIGNAL_OFFSET (EShortcutBarClass, + removed_group), + gtk_marshal_NONE__INT, + GTK_TYPE_NONE, 1, GTK_TYPE_INT); + gtk_object_class_add_signals (object_class, e_shortcut_bar_signals, LAST_SIGNAL); @@ -265,6 +307,10 @@ e_shortcut_bar_add_group (EShortcutBar *shortcut_bar, const gchar *group_name) gtk_widget_pop_visual (); gtk_widget_pop_colormap (); + gtk_signal_emit (GTK_OBJECT (shortcut_bar), + e_shortcut_bar_signals[GROUP_ADDED], + group_num); + return group_num; } @@ -273,6 +319,10 @@ void e_shortcut_bar_remove_group (EShortcutBar *shortcut_bar, gint group_num) { + gtk_signal_emit (GTK_OBJECT (shortcut_bar), + e_shortcut_bar_signals[GROUP_REMOVED], + group_num); + e_group_bar_remove_group (E_GROUP_BAR (shortcut_bar), group_num); g_array_remove_index (shortcut_bar->groups, group_num); } @@ -301,6 +351,11 @@ e_shortcut_bar_add_item (EShortcutBar *shortcut_bar, gint group_num, gdk_pixbuf_unref (image); e_icon_bar_set_item_data_full (E_ICON_BAR (group->icon_bar), item_num, g_strdup (item_url), g_free); + + gtk_signal_emit (GTK_OBJECT (shortcut_bar), + e_shortcut_bar_signals[ITEM_ADDED], + group_num, item_num); + return item_num; } @@ -319,6 +374,10 @@ e_shortcut_bar_remove_item (EShortcutBar *shortcut_bar, group = &g_array_index (shortcut_bar->groups, EShortcutBarGroup, group_num); + gtk_signal_emit (GTK_OBJECT (shortcut_bar), + e_shortcut_bar_signals[ITEM_REMOVED], + group_num, item_num); + e_icon_bar_remove_item (E_ICON_BAR (group->icon_bar), item_num); } @@ -462,6 +521,10 @@ e_shortcut_bar_on_drag_data_received (GtkWidget *widget, item_num, g_strdup (item_url), g_free); + gtk_signal_emit (GTK_OBJECT (shortcut_bar), + e_shortcut_bar_signals[ITEM_ADDED], + group_num, item_num); + gtk_drag_finish (context, TRUE, TRUE, time); return; } @@ -476,10 +539,15 @@ e_shortcut_bar_on_drag_data_delete (GtkWidget *widget, EShortcutBar *shortcut_bar) { EIconBar *icon_bar; + gint group_num; icon_bar = E_ICON_BAR (widget); - e_icon_bar_remove_item (icon_bar, icon_bar->dragged_item_num); + group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar), + widget->parent); + + e_shortcut_bar_remove_item (shortcut_bar, group_num, + icon_bar->dragged_item_num); } diff --git a/widgets/shortcut-bar/e-shortcut-bar.h b/widgets/shortcut-bar/e-shortcut-bar.h index 2482399428..b02626fdef 100644 --- a/widgets/shortcut-bar/e-shortcut-bar.h +++ b/widgets/shortcut-bar/e-shortcut-bar.h @@ -90,6 +90,16 @@ struct _EShortcutBarClass GdkEvent *event, gint group_num, gint item_num); + void (*added_item) (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num); + void (*removed_item) (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num); + void (*added_group) (EShortcutBar *shortcut_bar, + gint group_num); + void (*removed_group) (EShortcutBar *shortcut_bar, + gint group_num); }; @@ -123,9 +133,9 @@ void e_shortcut_bar_remove_item (EShortcutBar *shortcut_bar, /* Sets the callback which is called to return the icon to use for a particular URL. This callback must be set before any items are added. If the callback returns NULL the default icon is used. */ -void e_shortcut_bar_set_icon_callback (EShortcutBar *shortcut_bar, - EShortcutBarIconCallback cb, - gpointer data); +void e_shortcut_bar_set_icon_callback (EShortcutBar *shortcut_bar, + EShortcutBarIconCallback cb, + gpointer data); #ifdef __cplusplus } diff --git a/widgets/shortcut-bar/test-shortcut-bar.c b/widgets/shortcut-bar/test-shortcut-bar.c index abdccddeb1..5d9ae700f3 100644 --- a/widgets/shortcut-bar/test-shortcut-bar.c +++ b/widgets/shortcut-bar/test-shortcut-bar.c @@ -84,6 +84,16 @@ static void on_set_group_button_clicked (GtkWidget *button, EShortcutBar *shortcut_bar); static void on_set_group_button_no_animation_clicked (GtkWidget *button, EShortcutBar *shortcut_bar); +static void on_item_added (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num); +static void on_item_removed (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num); +static void on_group_added (EShortcutBar *shortcut_bar, + gint group_num); +static void on_group_removed (EShortcutBar *shortcut_bar, + gint group_num); int main (int argc, char *argv[]) @@ -115,6 +125,15 @@ main (int argc, char *argv[]) icon_callback, NULL); + gtk_signal_connect (GTK_OBJECT (shortcut_bar), "item_added", + GTK_SIGNAL_FUNC (on_item_added), NULL); + gtk_signal_connect (GTK_OBJECT (shortcut_bar), "item_removed", + GTK_SIGNAL_FUNC (on_item_removed), NULL); + gtk_signal_connect (GTK_OBJECT (shortcut_bar), "group_added", + GTK_SIGNAL_FUNC (on_group_added), NULL); + gtk_signal_connect (GTK_OBJECT (shortcut_bar), "group_removed", + GTK_SIGNAL_FUNC (on_group_removed), NULL); + #if 0 gtk_container_set_border_width (GTK_CONTAINER (shortcut_bar), 4); #endif @@ -190,6 +209,7 @@ icon_callback (EShortcutBar *shortcut_bar, for (i = 0; i < NUM_SHORTCUT_TYPES; i++) { if (!strncmp (url, shortcut_types[i], strlen (shortcut_types[i]))) { + gdk_pixbuf_ref (icon_pixbufs[i]); return icon_pixbufs[i]; } } @@ -559,3 +579,37 @@ on_move_button_clicked (GtkWidget *button, e_group_bar_reorder_group (E_GROUP_BAR (shortcut_bar), 0, 3); } + + +static void +on_item_added (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num) +{ + g_print ("In on_item_added Group:%i Item:%i\n", group_num, item_num); +} + + +static void +on_item_removed (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num) +{ + g_print ("In on_item_removed Group:%i Item:%i\n", group_num, item_num); +} + + +static void +on_group_added (EShortcutBar *shortcut_bar, + gint group_num) +{ + g_print ("In on_group_added Group:%i\n", group_num); +} + + +static void +on_group_removed (EShortcutBar *shortcut_bar, + gint group_num) +{ + g_print ("In on_group_removed Group:%i\n", group_num); +} |