[bijiben] mainToolbar : fix regressions on selection mode
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] mainToolbar : fix regressions on selection mode
- Date: Wed, 24 Apr 2013 22:04:40 +0000 (UTC)
commit 5ec5bb0c42a81424c07b781f1a3294d5dbb0e52a
Author: Pierre-Yves Luyten <py luyten fr>
Date: Thu Apr 25 00:03:21 2013 +0200
mainToolbar : fix regressions on selection mode
Things have changed and toolbar was ignoring selection changing
src/bjb-main-toolbar.c | 36 +++++++++++++++++++++++++++++++++---
src/bjb-main-view.c | 42 +++++++++++-------------------------------
2 files changed, 44 insertions(+), 34 deletions(-)
---
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 8e53521..9611b29 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -58,6 +58,7 @@ struct _BjbMainToolbarPrivate
gulong update_selection;
gulong search_handler;
gulong display_notes;
+ gulong view_selection_changed;
/* When note view */
BijiNoteObj *note;
@@ -262,6 +263,13 @@ populate_bar_for_selection (BjbMainToolbar *self)
g_signal_connect (priv->select, "clicked",
G_CALLBACK (on_selection_mode_clicked), self);
+ if (priv->view_selection_changed == 0)
+ {
+ priv->view_selection_changed = g_signal_connect_swapped (
+ self->priv->parent, "view-selection-changed",
+ G_CALLBACK (on_view_selection_changed_cb), self);
+ }
+
update_selection_label (self);
}
@@ -288,6 +296,19 @@ update_label_for_standard (BjbMainToolbar *self)
}
static void
+connect_main_view_handlers (BjbMainToolbar *self)
+{
+ BjbMainToolbarPrivate *priv = self->priv;
+
+ if (priv->view_selection_changed == 0)
+ {
+ priv->view_selection_changed = g_signal_connect_swapped (
+ self->priv->parent, "view-selection-changed",
+ G_CALLBACK (on_view_selection_changed_cb), self);
+ }
+}
+
+static void
populate_bar_for_standard(BjbMainToolbar *self)
{
BjbMainToolbarPrivate *priv = self->priv;
@@ -324,6 +345,9 @@ populate_bar_for_standard(BjbMainToolbar *self)
g_signal_connect (priv->select,"clicked",
G_CALLBACK(on_selection_mode_clicked),self);
+
+ /* Watch for main view changing */
+ connect_main_view_handlers (self);
}
static void
@@ -715,6 +739,12 @@ populate_main_toolbar(BjbMainToolbar *self)
priv->display_notes = 0;
}
+ if (priv->view_selection_changed != 0)
+ {
+ g_signal_handler_disconnect (priv->parent, priv->view_selection_changed);
+ priv->view_selection_changed = 0;
+ }
+
populate_bar_switch (self);
}
}
@@ -727,9 +757,6 @@ bjb_main_toolbar_constructed (GObject *obj)
g_signal_connect_swapped (self->priv->window, "view-changed",
G_CALLBACK (populate_main_toolbar), self);
- g_signal_connect_swapped (self->priv->parent, "view-selection-changed",
- G_CALLBACK (on_view_selection_changed_cb), self);
-
G_OBJECT_CLASS(bjb_main_toolbar_parent_class)->constructed(obj);
}
@@ -746,6 +773,7 @@ bjb_main_toolbar_init (BjbMainToolbar *self)
priv->search = NULL;
priv->search_handler = 0;
priv->display_notes = 0;
+ priv->view_selection_changed = 0;
priv->accel = NULL;
priv->note = NULL;
@@ -767,6 +795,8 @@ bjb_main_toolbar_finalize (GObject *object)
priv->search_handler = 0;
}
+ disconnect_note_handlers (priv);
+
/* chain up */
G_OBJECT_CLASS (bjb_main_toolbar_parent_class)->finalize (object);
}
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index de932a5..7a08ef5 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -74,7 +74,6 @@ struct _BjbMainViewPriv {
/* Signals */
gulong key;
- gulong button;
gulong activated;
gulong data;
gulong view_selection_changed;
@@ -89,7 +88,6 @@ bjb_main_view_init (BjbMainView *object)
G_TYPE_INSTANCE_GET_PRIVATE(object,BJB_TYPE_MAIN_VIEW,BjbMainViewPriv);
object->priv->key = 0;
- object->priv->button = 0;
object->priv->activated = 0;
object->priv->data = 0;
object->priv->view_selection_changed =0;
@@ -107,13 +105,11 @@ bjb_main_view_disconnect_handlers (BjbMainView *self)
BjbMainViewPriv *priv = self->priv;
g_signal_handler_disconnect (priv->window, priv->key);
- g_signal_handler_disconnect (priv->view, priv->button);
g_signal_handler_disconnect (priv->view, priv->activated);
g_signal_handler_disconnect (priv->view, priv->data);
g_signal_handler_disconnect (priv->view, priv->view_selection_changed);
priv->key = 0;
- priv->button = 0;
priv->activated = 0;
priv->data = 0;
priv->view_selection_changed =0;
@@ -338,10 +334,20 @@ action_delete_selected_notes(GtkWidget *w,BjbMainView *view)
g_list_free (notes);
}
-/* Just tell */
static void
on_selection_mode_changed_cb (BjbMainView *self)
{
+ GList *select;
+
+ /* Workaround if items are selected
+ * but selection mode not really active (?) */
+ if (gd_main_view_get_selection (self->priv->view))
+ {
+ g_list_free (select);
+ gd_main_view_set_selection_mode (self->priv->view, TRUE);
+ }
+
+ /* Any case, tell */
g_signal_emit (G_OBJECT (self),
bjb_main_view_signals[VIEW_SELECTION_CHANGED],0);
}
@@ -380,28 +386,6 @@ on_key_press_event_cb (GtkWidget *widget,
return FALSE;
}
-/* Go to selection mode with right-click */
-static gboolean
-on_button_press_event_cb (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
-{
- BjbMainView *self = BJB_MAIN_VIEW (user_data);
- BjbMainViewPriv *priv = self->priv;
-
- switch (event->button.button)
- {
- /* Right click */
- case 3:
- if (!gd_main_view_get_selection_mode (priv->view))
- gd_main_view_set_selection_mode (priv->view, TRUE);
- return TRUE;
-
- default:
- return FALSE;
- }
-}
-
static gboolean
on_item_activated(GdMainView * gd,
const gchar * id,
@@ -487,10 +471,6 @@ bjb_main_view_connect_signals (BjbMainView *self)
priv->key = g_signal_connect (priv->window, "key-press-event",
G_CALLBACK (on_key_press_event_cb), self);
- if (priv->button == 0)
- priv->button = g_signal_connect (priv->view, "button-press-event",
- G_CALLBACK (on_button_press_event_cb), self);
-
if (priv->activated == 0)
priv->activated = g_signal_connect(priv->view,"item-activated",
G_CALLBACK(on_item_activated),self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]