diff options
Diffstat (limited to 'widgets/shortcut-bar')
-rw-r--r-- | widgets/shortcut-bar/ChangeLog | 14 | ||||
-rw-r--r-- | widgets/shortcut-bar/e-group-bar.c | 20 | ||||
-rw-r--r-- | widgets/shortcut-bar/e-icon-bar-bg-item.c | 22 | ||||
-rw-r--r-- | widgets/shortcut-bar/e-shortcut-bar.c | 2 | ||||
-rw-r--r-- | widgets/shortcut-bar/test-shortcut-bar.c | 54 |
5 files changed, 98 insertions, 14 deletions
diff --git a/widgets/shortcut-bar/ChangeLog b/widgets/shortcut-bar/ChangeLog index 58b315d2a8..088eed7ea3 100644 --- a/widgets/shortcut-bar/ChangeLog +++ b/widgets/shortcut-bar/ChangeLog @@ -1,3 +1,17 @@ +2000-09-30 Damon Chaplin <damon@helixcode.com> + + * test-shortcut-bar.c: updated to use new EShortcutBar signals for DnD. + + * e-group-bar.c (e_group_bar_add_group): show the new windows if the + EGroupBar is realized, handle the position argument properly, and + fixed the window z-order code. + + * e-shortcut-bar.c (e_shortcut_bar_add_group): pass group_num to the + e_group_bar_add_group() function. + + * e-icon-bar-bg-item.c (e_icon_bar_bg_item_draw): fixed SEGV when + trying to drag into a group with no items. + 2000-09-28 Ettore Perazzoli <ettore@helixcode.com> * e-shortcut-bar.c (e_shortcut_bar_destroy): Disconnect the model diff --git a/widgets/shortcut-bar/e-group-bar.c b/widgets/shortcut-bar/e-group-bar.c index dd78fe6243..b5aa471d0e 100644 --- a/widgets/shortcut-bar/e-group-bar.c +++ b/widgets/shortcut-bar/e-group-bar.c @@ -914,8 +914,11 @@ e_group_bar_add_group (EGroupBar *group_bar, /* Append an empty group to the children array and get a pointer to it, so we can use it like a normal group. */ - group_num = group_bar->children->len; - g_array_append_val (group_bar->children, empty_group); + if (position == -1) + group_num = group_bar->children->len; + else + group_num = position; + g_array_insert_val (group_bar->children, group_num, empty_group); group = &g_array_index (group_bar->children, EGroupBarChild, group_num); @@ -929,26 +932,32 @@ e_group_bar_add_group (EGroupBar *group_bar, group->button_window_target_y = 0; group->child_window_target_y = 0; - /* If we don't have a current group, set it to the first one. */ + /* If we don't have a current group, set it to the first one. + Move the currently shown group index forward if necessary. */ if (group_bar->current_group_num == -1) group_bar->current_group_num = 0; + else if (group_bar->current_group_num >= group_num) + group_bar->current_group_num++; /* If the EGroupBar widget is realize, we need to create the child windows to put the button & child in. */ if (GTK_WIDGET_REALIZED (group_bar)) { e_group_bar_create_group_button_window (group_bar, group_num); + gdk_window_show (group->button_window); + e_group_bar_create_group_child_window (group_bar, group_num); + gdk_window_show (group->child_window); /* We need to lower all the child windows of the previous groups, in reverse order, to keep the stacking order correct. */ - for (tmp_group_num = group_num - 1; + for (tmp_group_num = group_num; tmp_group_num >= 0; tmp_group_num--) { tmp_group = &g_array_index (group_bar->children, EGroupBarChild, tmp_group_num); - gdk_window_lower (group->child_window); + gdk_window_lower (tmp_group->child_window); } } @@ -1136,6 +1145,7 @@ e_group_bar_set_current_group_num (EGroupBar *group_bar, /* The positions will be sorted out when the widget's size is allocated. */ group_bar->current_group_num = group_num; + gtk_widget_queue_resize (GTK_WIDGET (group_bar)); } } diff --git a/widgets/shortcut-bar/e-icon-bar-bg-item.c b/widgets/shortcut-bar/e-icon-bar-bg-item.c index 5154a38267..26da038a6e 100644 --- a/widgets/shortcut-bar/e-icon-bar-bg-item.c +++ b/widgets/shortcut-bar/e-icon-bar-bg-item.c @@ -234,15 +234,23 @@ e_icon_bar_bg_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable, bar_y = 0; } else { /* We need to draw the bar after the last item. */ - item = &g_array_index (icon_bar->items, EIconBarItem, - icon_bar->items->len - 1); - bar_y = item->item_height + icon_bar->spacing; + if (icon_bar->items->len != 0) { + item = &g_array_index (icon_bar->items, + EIconBarItem, + icon_bar->items->len - 1); + bar_y = item->item_height + icon_bar->spacing; + } else { + item = NULL; + bar_y = icon_bar->spacing; + } } - if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) { - bar_y += item->icon_y; - } else { - bar_y += MIN (item->icon_y, item->text_y); + if (item) { + if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) { + bar_y += item->icon_y; + } else { + bar_y += MIN (item->icon_y, item->text_y); + } } bar_y -= y + icon_bar->spacing / 2; diff --git a/widgets/shortcut-bar/e-shortcut-bar.c b/widgets/shortcut-bar/e-shortcut-bar.c index 2c15d499d2..0e577c9207 100644 --- a/widgets/shortcut-bar/e-shortcut-bar.c +++ b/widgets/shortcut-bar/e-shortcut-bar.c @@ -452,7 +452,7 @@ e_shortcut_bar_add_group (EShortcutBar *shortcut_bar, GDK_ACTION_COPY | GDK_ACTION_MOVE); e_group_bar_add_group (E_GROUP_BAR (shortcut_bar), - group->vscrolled_bar, button, -1); + group->vscrolled_bar, button, group_num); gtk_widget_pop_visual (); gtk_widget_pop_colormap (); diff --git a/widgets/shortcut-bar/test-shortcut-bar.c b/widgets/shortcut-bar/test-shortcut-bar.c index aafb54ccb0..4eb5e4c199 100644 --- a/widgets/shortcut-bar/test-shortcut-bar.c +++ b/widgets/shortcut-bar/test-shortcut-bar.c @@ -73,6 +73,8 @@ static void set_large_icons (GtkWidget *menuitem, EShortcutBar *shortcut_bar); static void set_small_icons (GtkWidget *menuitem, EShortcutBar *shortcut_bar); +static void add_group (GtkWidget *menuitem, + EShortcutBar *shortcut_bar); static void remove_group (GtkWidget *menuitem, EShortcutBar *shortcut_bar); @@ -94,6 +96,14 @@ static void on_group_added (EShortcutModel *shortcut_model, gint group_num); static void on_group_removed (EShortcutModel *shortcut_model, gint group_num); +static void on_shortcut_dragged (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num); +static void on_shortcut_dropped (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num, + gchar *url, + gchar *name); int main (int argc, char *argv[]) @@ -139,6 +149,11 @@ main (int argc, char *argv[]) gtk_signal_connect (GTK_OBJECT (shortcut_model), "group_removed", GTK_SIGNAL_FUNC (on_group_removed), NULL); + gtk_signal_connect (GTK_OBJECT (shortcut_bar), "shortcut_dragged", + GTK_SIGNAL_FUNC (on_shortcut_dragged), NULL); + gtk_signal_connect (GTK_OBJECT (shortcut_bar), "shortcut_dropped", + GTK_SIGNAL_FUNC (on_shortcut_dropped), NULL); + #if 0 gtk_container_set_border_width (GTK_CONTAINER (shortcut_bar), 4); #endif @@ -339,9 +354,10 @@ show_standard_popup (EShortcutBar *shortcut_bar, gtk_menu_append (GTK_MENU (menu), menuitem); menuitem = gtk_menu_item_new_with_label ("Add New Group"); - gtk_widget_set_sensitive (menuitem, FALSE); gtk_widget_show (menuitem); gtk_menu_append (GTK_MENU (menu), menuitem); + gtk_signal_connect (GTK_OBJECT (menuitem), "activate", + GTK_SIGNAL_FUNC (add_group), shortcut_bar); menuitem = gtk_menu_item_new_with_label ("Remove Group"); gtk_widget_show (menuitem); @@ -421,6 +437,14 @@ set_small_icons (GtkWidget *menuitem, static void +add_group (GtkWidget *menuitem, + EShortcutBar *shortcut_bar) +{ + e_shortcut_model_add_group (shortcut_bar->model, 3, "New Group"); +} + + +static void remove_group (GtkWidget *menuitem, EShortcutBar *shortcut_bar) { @@ -604,3 +628,31 @@ on_group_removed (EShortcutModel *shortcut_model, { g_print ("In on_group_removed Group:%i\n", group_num); } + + +static void +on_shortcut_dragged (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num) +{ + g_print ("In on_shortcut_dragged Group:%i Item:%i\n", group_num, + item_num); + + e_shortcut_model_remove_item (shortcut_bar->model, group_num, + item_num); +} + + +static void +on_shortcut_dropped (EShortcutBar *shortcut_bar, + gint group_num, + gint item_num, + gchar *url, + gchar *name) +{ + g_print ("In on_shortcut_dropped Group:%i Item:%i\n", group_num, + item_num); + + e_shortcut_model_add_item (shortcut_bar->model, + group_num, item_num, url, name); +} |