[bijiben] SearchToolbar: now owned by window
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] SearchToolbar: now owned by window
- Date: Tue, 30 Apr 2013 22:35:57 +0000 (UTC)
commit cd3a26813437139d5310141f1afce82344294d71
Author: Pierre-Yves Luyten <py luyten fr>
Date: Tue Apr 30 23:52:35 2013 +0200
SearchToolbar: now owned by window
mainview : clean up some code, window and window-controller have more control.
main view is now rather a simple widget.
src/bjb-main-toolbar.c | 14 +----
src/bjb-main-view.c | 29 +---------
src/bjb-main-view.h | 4 --
src/bjb-search-toolbar.c | 12 +----
src/bjb-window-base.c | 132 +++++++++++++++++++++++++++++----------------
src/bjb-window-base.h | 5 ++
6 files changed, 97 insertions(+), 99 deletions(-)
---
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 233c5f0..5ba9e72 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -202,18 +202,10 @@ on_button_press (GtkWidget* widget,
static void
on_search_button_clicked (BjbMainToolbarPrivate *priv)
{
- BjbSearchToolbar *bar;
+ gboolean show_bar;
- bar = bjb_main_view_get_search_toolbar (priv->parent);
-
- if (bar == NULL)
- return;
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search)))
- bjb_search_toolbar_fade_in (bar);
-
- else
- bjb_search_toolbar_fade_out (bar);
+ show_bar = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search));
+ bjb_window_base_set_show_search_bar (BJB_WINDOW_BASE (priv->window), show_bar);
}
static void
diff --git a/src/bjb-main-view.c b/src/bjb-main-view.c
index 4441dd3..fc2b37d 100644
--- a/src/bjb-main-view.c
+++ b/src/bjb-main-view.c
@@ -65,9 +65,6 @@ struct _BjbMainViewPriv {
/* Selection Mode */
BjbSelectionToolbar *select_bar;
- /* Search Entry */
- BjbSearchToolbar *search_bar;
-
/* View Notes , model */
GdMainView *view ;
BjbController *controller ;
@@ -182,7 +179,6 @@ biji_main_view_constructor (GType gtype,
void
switch_to_note_view (BjbMainView *self, BijiNoteObj *note)
{
- bjb_search_toolbar_disconnect (self->priv->search_bar);
bjb_main_view_disconnect_handlers (self);
bjb_window_base_switch_to_note (BJB_WINDOW_BASE (self->priv->window), note);
}
@@ -474,7 +470,6 @@ bjb_main_view_connect_signals (BjbMainView *self)
BjbMainViewPriv *priv = self->priv;
bjb_controller_connect (priv->controller);
- bjb_search_toolbar_connect (priv->search_bar);
if (priv->view_selection_changed == 0)
priv->view_selection_changed = g_signal_connect_swapped
@@ -503,7 +498,6 @@ bjb_main_view_constructed(GObject *o)
GtkBox *vbox; //self, too
BjbMainViewPriv *priv;
GtkOverlay *overlay;
- GdRevealer *revealer;
G_OBJECT_CLASS (bjb_main_view_parent_class)->constructed(G_OBJECT(o));
@@ -517,11 +511,6 @@ bjb_main_view_constructed(GObject *o)
priv->view = gd_main_view_new (DEFAULT_VIEW);
- /* Search entry toolbar */
- priv->search_bar = bjb_search_toolbar_new (priv->window, priv->controller);
- revealer = bjb_search_toolbar_get_revealer (priv->search_bar);
- gtk_box_pack_start (vbox, GTK_WIDGET (revealer), FALSE, FALSE, 0);
-
/* Main view */
overlay = GTK_OVERLAY (gtk_overlay_new ());
@@ -611,23 +600,9 @@ bjb_main_view_update_model (BjbMainView *self)
gd_main_view_set_model (priv->view, bjb_controller_get_model (priv->controller));
}
-BjbSearchToolbar *
-bjb_main_view_get_search_toolbar (BjbMainView *view)
-{
- g_return_val_if_fail (BJB_IS_MAIN_VIEW (view), NULL);
-
- return view->priv->search_bar;
-}
-
-gpointer
-bjb_main_view_get_main_toolbar (BjbMainView *view)
-{
- g_return_val_if_fail (BJB_IS_MAIN_VIEW (view), NULL);
-
- return (gpointer) view->priv->main_toolbar;
-}
+/* interface for notes view (GdMainView)
+ * TODO - BjbMainView should rather be a GdMainView */
-/* interface for notes view (GdMainView) */
gboolean
bjb_main_view_get_selection_mode (BjbMainView *self)
{
diff --git a/src/bjb-main-view.h b/src/bjb-main-view.h
index d3155b8..51aea63 100644
--- a/src/bjb-main-view.h
+++ b/src/bjb-main-view.h
@@ -82,10 +82,6 @@ void switch_to_note_view(BjbMainView *view,BijiNoteObj *note) ;
void bjb_main_view_update_model (BjbMainView *view);
-BjbSearchToolbar *bjb_main_view_get_search_toolbar (BjbMainView *view);
-
-gpointer bjb_main_view_get_main_toolbar (BjbMainView *view);
-
/* bridge for notes view (GdMainView)
* TODO : get rid of this it's a bit idiot */
diff --git a/src/bjb-search-toolbar.c b/src/bjb-search-toolbar.c
index 2d8355e..9651f4a 100644
--- a/src/bjb-search-toolbar.c
+++ b/src/bjb-search-toolbar.c
@@ -72,16 +72,8 @@ static void
bjb_search_toolbar_toggle_search_button (BjbSearchToolbar *self,
gboolean state)
{
- BjbMainView *view;
- BjbMainToolbar *bar;
-
- view = bjb_window_base_get_main_view (BJB_WINDOW_BASE (self->priv->window));
- if (view)
- {
- bar = bjb_main_view_get_main_toolbar (view);
- if (bar)
- bjb_main_toolbar_set_search_toggle_state (bar, state);
- }
+ bjb_window_base_toggle_search_button (BJB_WINDOW_BASE (self->priv->window),
+ state);
}
void
diff --git a/src/bjb-window-base.c b/src/bjb-window-base.c
index 32169a8..64a6269 100644
--- a/src/bjb-window-base.c
+++ b/src/bjb-window-base.c
@@ -26,33 +26,32 @@ enum {
static guint bjb_win_base_signals [BJB_WIN_BASE_SIGNALS] = { 0 };
-/* As the main window remains, it owns the data */
+
struct _BjbWindowBasePriv
{
- /* To register new windows and access the data */
GtkApplication *app ;
BjbController *controller;
+ gchar *entry; // FIXME, remove this
+
- /* UI
- * The Notebook always has a main view.
- * When editing a note, it _also_ has a note view */
GtkWidget *vbox;
- GdStack *stack;
- GtkWidget *spinner; // this spinner takes the whole place
- // and only shows on startup
- GtkWidget *no_note;
+ BjbMainToolbar *main_toolbar;
+ BjbSearchToolbar *search_bar;
+
+ GdStack *stack;
BjbWindowViewType current_view;
BjbMainView *view;
- BjbMainToolbar *main_toolbar;
- gchar *entry;
+ BjbNoteView *note_view;
+ GtkWidget *spinner;
+ GtkWidget *no_note;
+
/* when a note is opened */
BijiNoteObj *note;
- BjbNoteView *note_view;
GtkWidget *note_overlay;
- /* To avoid loiding several times */
+
PangoFontDescription *font ;
};
@@ -185,8 +184,9 @@ bjb_window_base_class_init (BjbWindowBaseClass *klass)
GtkWindow *
bjb_window_base_new(void)
{
- BjbWindowBase *retval;
- BjbWindowBasePriv *priv;
+ BjbWindowBase *retval;
+ BjbWindowBasePriv *priv;
+ GdRevealer *revealer;
retval = g_object_new(BJB_TYPE_WINDOW_BASE,
"application", g_application_get_default(),
@@ -207,6 +207,11 @@ bjb_window_base_new(void)
priv->main_toolbar = bjb_main_toolbar_new (priv->view, priv->controller);
gtk_box_pack_start (GTK_BOX (priv->vbox), GTK_WIDGET (priv->main_toolbar), FALSE, FALSE, 0);
+ /* Search entry toolbar */
+ priv->search_bar = bjb_search_toolbar_new (GTK_WIDGET (retval), priv->controller);
+ revealer = bjb_search_toolbar_get_revealer (priv->search_bar);
+ gtk_box_pack_start (GTK_BOX (priv->vbox), GTK_WIDGET (revealer), FALSE, FALSE, 0);
+
/* UI : stack for different views */
priv->stack = GD_STACK (gd_stack_new ());
gtk_box_pack_start (GTK_BOX (priv->vbox), GTK_WIDGET (priv->stack), TRUE, TRUE, 0);
@@ -262,44 +267,54 @@ bjb_window_base_switch_to (BjbWindowBase *bwb, BjbWindowViewType type)
BjbWindowBasePriv *priv = bwb->priv;
priv->current_view = type;
- /* Precise the window does not display any specific note
- * Refresh the model
- * Ensure the main view receives the proper signals */
- if (type == BJB_WINDOW_BASE_MAIN_VIEW)
+ switch (type)
{
- priv->note = NULL;
- bjb_main_view_connect_signals (priv->view);
- gd_stack_set_visible_child_name (priv->stack, "main-view");
- destroy_note_if_needed (bwb);
- }
+ /* Precise the window does not display any specific note
+ * Refresh the model
+ * Ensure the main view receives the proper signals */
- else if (type == BJB_WINDOW_BASE_SPINNER_VIEW)
- {
- priv->note = NULL;
- gd_stack_set_visible_child_name (priv->stack, "spinner");
- }
+ case BJB_WINDOW_BASE_MAIN_VIEW:
+ priv->note = NULL;
+ bjb_search_toolbar_connect (priv->search_bar);
+ bjb_main_view_connect_signals (priv->view);
+ gd_stack_set_visible_child_name (priv->stack, "main-view");
+ destroy_note_if_needed (bwb);
+ break;
- else if (type == BJB_WINDOW_BASE_NO_NOTE)
- {
- bjb_empty_results_box_set_type (BJB_EMPTY_RESULTS_BOX (priv->no_note),
- BJB_EMPTY_RESULTS_NO_NOTE);
- gtk_widget_show (priv->no_note);
- gd_stack_set_visible_child_name (priv->stack, "empty");
- }
- else if (type == BJB_WINDOW_BASE_NO_RESULT)
- {
- bjb_empty_results_box_set_type (BJB_EMPTY_RESULTS_BOX (priv->no_note),
- BJB_EMPTY_RESULTS_NO_RESULTS);
- gtk_widget_show (priv->no_note);
- gd_stack_set_visible_child_name (priv->stack, "empty");
- }
+ case BJB_WINDOW_BASE_SPINNER_VIEW:
+ priv->note = NULL;
+ gd_stack_set_visible_child_name (priv->stack, "spinner");
+ break;
- else
- {
- gtk_widget_show_all (GTK_WIDGET (priv->note_overlay));
- gd_stack_set_visible_child_name (priv->stack, "note-view");
+
+ case BJB_WINDOW_BASE_NO_NOTE:
+ bjb_empty_results_box_set_type (BJB_EMPTY_RESULTS_BOX (priv->no_note),
+ BJB_EMPTY_RESULTS_NO_NOTE);
+ gtk_widget_show (priv->no_note);
+ gd_stack_set_visible_child_name (priv->stack, "empty");
+ break;
+
+
+ case BJB_WINDOW_BASE_NO_RESULT:
+ bjb_empty_results_box_set_type (BJB_EMPTY_RESULTS_BOX (priv->no_note),
+ BJB_EMPTY_RESULTS_NO_RESULTS);
+ gtk_widget_show (priv->no_note);
+ gd_stack_set_visible_child_name (priv->stack, "empty");
+ break;
+
+
+ case BJB_WINDOW_BASE_NOTE_VIEW:
+ bjb_search_toolbar_fade_out (priv->search_bar);
+ bjb_search_toolbar_disconnect (priv->search_bar);
+ gtk_widget_show_all (GTK_WIDGET (priv->note_overlay));
+ gd_stack_set_visible_child_name (priv->stack, "note-view");
+ break;
+
+
+ default:
+ return;
}
g_signal_emit (G_OBJECT (bwb), bjb_win_base_signals[BJB_WIN_BASE_VIEW_CHANGED],0);
@@ -362,3 +377,26 @@ bjb_window_base_get_main_view (BjbWindowBase *self)
{
return (gpointer) self->priv->view;
}
+
+gboolean
+bjb_window_base_set_show_search_bar (BjbWindowBase *self,
+ gboolean show)
+{
+ if (show)
+ bjb_search_toolbar_fade_in (self->priv->search_bar);
+
+ else
+ bjb_search_toolbar_fade_out (self->priv->search_bar);
+
+ return TRUE;
+}
+
+gboolean
+bjb_window_base_toggle_search_button (BjbWindowBase *self,
+ gboolean active)
+{
+ bjb_main_toolbar_set_search_toggle_state (self->priv->main_toolbar,
+ active);
+
+ return TRUE;
+}
diff --git a/src/bjb-window-base.h b/src/bjb-window-base.h
index 45ba393..c263ba6 100644
--- a/src/bjb-window-base.h
+++ b/src/bjb-window-base.h
@@ -69,4 +69,9 @@ BijiNoteObj * bjb_window_base_get_note (BjbWindowBase *self);
gboolean switch_window_fullscreen();
+gboolean bjb_window_base_set_show_search_bar (BjbWindowBase *self, gboolean show);
+
+gboolean bjb_window_base_toggle_search_button (BjbWindowBase *self,
+ gboolean active);
+
#endif /* _BJB_WINDOW_BASE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]