[gnome-notes] controller: Add display-notebooks-changed signal
- From: Isaque Galdino de Araujo <igaldino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-notes] controller: Add display-notebooks-changed signal
- Date: Tue, 4 May 2021 13:10:21 +0000 (UTC)
commit c52110d872908d9780f3458974fcab7277bbe81f
Author: Jonathan Kang <jonathankang gnome org>
Date: Tue Feb 2 17:39:17 2021 +0800
controller: Add display-notebooks-changed signal
Previously, signal dispaly-items-changed is used to notify that notes
or notebooks has changed in the controller.
Now we need to show notes and notebooks separately in different lists,
it'sĀ better to add a new signal named display-notebooks-changed
indicating that notebooks has changed. signal display-items-changed is
renamed as display-notes-changed to indicates notes has changed.
src/bjb-controller.c | 45 ++++++++++++++++++++++++++++++++++++++-------
src/bjb-list-view.c | 2 +-
2 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/src/bjb-controller.c b/src/bjb-controller.c
index b89d53b..6a9e2e1 100644
--- a/src/bjb-controller.c
+++ b/src/bjb-controller.c
@@ -76,6 +76,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
enum {
SEARCH_CHANGED,
DISPLAY_NOTES_CHANGED, // either search or manager change
+ DISPLAY_NOTEBOOKS_CHANGED,
BJB_CONTROLLER_SIGNALS
};
@@ -382,9 +383,8 @@ bjb_controller_update_view (BjbController *self)
}
}
-
static void
-notify_displayed_items_changed (BjbController *self)
+notify_displayed_notes_changed (BjbController *self)
{
g_signal_emit (G_OBJECT (self),
bjb_controller_signals[DISPLAY_NOTES_CHANGED],
@@ -393,6 +393,16 @@ notify_displayed_items_changed (BjbController *self)
self->remaining_items);
}
+static void
+notify_displayed_notebooks_changed (BjbController *self)
+{
+ g_signal_emit (G_OBJECT (self),
+ bjb_controller_signals[DISPLAY_NOTEBOOKS_CHANGED],
+ 0,
+ (self->items_to_show != NULL),
+ self->remaining_items);
+}
+
static void
update (BjbController *self)
{
@@ -412,7 +422,7 @@ update (BjbController *self)
bjb_controller_update_view (self);
- notify_displayed_items_changed (self);
+ notify_displayed_notes_changed (self);
}
@@ -596,7 +606,11 @@ on_manager_changed (BijiManager *manager,
bjb_controller_add_item_if_needed (self, item, TRUE, p_iter);
self->n_items_to_show++;
self->items_to_show = g_list_prepend (self->items_to_show, item);
- notify_displayed_items_changed (self);
+
+ if (BIJI_IS_NOTE_OBJ (item))
+ notify_displayed_notes_changed (self);
+ else if (BIJI_IS_NOTEBOOK (item))
+ notify_displayed_notebooks_changed (self);
break;
/* Same comment, prepend but notebook before note */
@@ -631,7 +645,12 @@ on_manager_changed (BijiManager *manager,
bjb_window_base_switch_to (self->window, BJB_WINDOW_BASE_NO_RESULT);
}
else
- notify_displayed_items_changed (self);
+ {
+ if (BIJI_IS_NOTE_OBJ (item))
+ notify_displayed_notes_changed (self);
+ else if (BIJI_IS_NOTEBOOK (item))
+ notify_displayed_notebooks_changed (self);
+ }
break;
@@ -700,7 +719,7 @@ bjb_controller_class_init (BjbControllerClass *klass)
G_TYPE_NONE,
0);
- bjb_controller_signals[DISPLAY_NOTES_CHANGED] = g_signal_new ( "display-items-changed" ,
+ bjb_controller_signals[DISPLAY_NOTES_CHANGED] = g_signal_new ( "display-notes-changed" ,
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
0,
@@ -712,6 +731,18 @@ bjb_controller_class_init (BjbControllerClass *klass)
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
+ bjb_controller_signals[DISPLAY_NOTEBOOKS_CHANGED] = g_signal_new ("display-notebooks-changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ _biji_marshal_VOID__BOOLEAN_BOOLEAN,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN);
+
properties[PROP_BOOK] = g_param_spec_object ("manager",
"Book",
"The BijiManager",
@@ -962,7 +993,7 @@ bjb_controller_set_all_selection (BjbController *self,
bjb_controller_set_selection_foreach,
GINT_TO_POINTER (selection));
- notify_displayed_items_changed (self);
+ notify_displayed_notes_changed (self);
}
void
diff --git a/src/bjb-list-view.c b/src/bjb-list-view.c
index d4064fb..a522b8a 100644
--- a/src/bjb-list-view.c
+++ b/src/bjb-list-view.c
@@ -109,7 +109,7 @@ bjb_list_view_setup (BjbListView *self,
self->controller = controller;
self->display_items_changed = g_signal_connect (self->controller,
- "display-items-changed",
+ "display-notes-changed",
G_CALLBACK (bjb_list_view_on_display_items_changed),
self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]