[bijiben/wip/sadiq/modernize: 2/2] main-toolbar: wip
- From: Mohammed Sadiq <pksadiq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben/wip/sadiq/modernize: 2/2] main-toolbar: wip
- Date: Fri, 29 Dec 2017 00:52:09 +0000 (UTC)
commit 28a2396d5f5b22cd2f7f9cdfdccee840f6808010
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date: Thu Dec 28 20:00:45 2017 +0530
main-toolbar: wip
data/bjb.gresource.xml | 1 +
data/resources/main-toolbar.ui | 259 +++++++++++++
src/bjb-main-toolbar.c | 830 +++++++++++++++++++++++----------------
3 files changed, 749 insertions(+), 341 deletions(-)
---
diff --git a/data/bjb.gresource.xml b/data/bjb.gresource.xml
index 76718a7..ad9bfeb 100644
--- a/data/bjb.gresource.xml
+++ b/data/bjb.gresource.xml
@@ -16,6 +16,7 @@
</gresource>
<gresource prefix="/org/gnome/bijiben/ui">
+ <file alias="main-toolbar.ui" preprocess="xml-stripblanks">resources/main-toolbar.ui</file>
<file alias="organize-dialog.ui" preprocess="xml-stripblanks">resources/organize-dialog.ui</file>
<file alias="settings-dialog.ui">resources/settings-dialog.ui</file>
<file alias="empty-results-box.ui">resources/empty-results-box.ui</file>
diff --git a/data/resources/main-toolbar.ui b/data/resources/main-toolbar.ui
new file mode 100644
index 0000000..b8b1380
--- /dev/null
+++ b/data/resources/main-toolbar.ui
@@ -0,0 +1,259 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="BjbMainToolbar" parent="GtkHeaderBar">
+ <property name="visible">1</property>
+ <property name="show-close-button">1</property>
+
+ <child>
+ <object class="GtkStack" id="button_stack">
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkButton" id="new_button">
+ <property name="visible">1</property>
+ <property name="label" translatable="yes">_New</property>
+ <property name="use-underline">1</property>
+ <signal name="clicked" handler="on_new_note_clicked" swapped="yes"/>
+ </object>
+ <packing>
+ <property name="name">new-note</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="back_button">
+ <property name="visible">1</property>
+ <signal name="clicked" handler="on_back_button_clicked" swapped="yes"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">back</property>
+ </packing>
+ </child> <!-- /GtkToggleButton back_button -->
+ </object>
+ </child> <!-- /GtkStack button_stack -->
+
+ <child>
+ <object class="BjbColorButton" id="color_button">
+ <property name="visible">1</property>
+ <property name="tooltip-text" translatable="yes">Note color</property>
+ <signal name="color-set" handler="on_color_button_clicked" swapped="yes"/>
+ </object>
+ <packing>
+ <property name="position">4</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="empty_button">
+ <property name="visible">1</property>
+ <property name="label" translatable="yes">_Empty</property>
+ <property name="use-underline">1</property>
+ <!-- <property name="sensitive" bind-source="select_button" bind-property="sensitive"
bind-flags="default"/> -->
+ <signal name="clicked" handler="on_empty_clicked_callback" swapped="yes"/>
+ <style>
+ <class name="destructive-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="position">3</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="cancel_button">
+ <property name="visible">1</property>
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="use-underline">1</property>
+ <property name="tooltip-text" translatable="yes">Exit selection mode</property>
+ <signal name="clicked" handler="on_selection_mode_clicked" swapped="yes"/>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkToggleButton" id="search_button">
+ <property name="visible">1</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</property>
+ <property name="icon-name">edit-find-symbolic</property>
+ <property name="icon-size">1</property>
+ <property name="tooltip-text" translatable="yes">Search note titles, content and
notebooks</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkStack" id="style_buttons">
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkButton" id="grid_button">
+ <property name="visible">1</property>
+ <signal name="clicked" handler="on_view_mode_clicked" swapped="yes"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</property>
+ <property name="icon-name">view-grid-symbolic</property>
+ <property name="icon-size">1</property>
+ <property name="tooltip-text" translatable="yes">View notes and notebooks in a
grid</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkButton" id="list_button">
+ <!-- <property name="visible">1</property> -->
+ <property name="visible" bind-source="grid_button" bind-property="visible"
bind-flags="default|bidirectional|invert-boolean"/>
+ <signal name="clicked" handler="on_view_mode_clicked" swapped="yes"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</property>
+ <property name="icon-name">view-list-symbolic</property>
+ <property name="icon-size">1</property>
+ <property name="tooltip-text" translatable="yes">View notes and notebooks in a
list</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child> <!-- /GtkStack style_buttons -->
+
+ <child>
+ <object class="GtkButton" id="select_button">
+ <property name="visible">1</property>
+ <signal name="clicked" handler="on_selection_mode_clicked" swapped="yes"/>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</property>
+ <property name="icon-name">object-select-symbolic</property>
+ <property name="icon-size">1</property>
+ <property name="tooltip-text" translatable="yes">Selection mode</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkMenuButton" id="menu_button">
+ <property name="visible">1</property>
+ <property name="direction">none</property>
+ <property name="tooltip-text" translatable="yes">More options…</property>
+ <property name="popup">menu</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <!-- <child>
+ <object class="GtkImage">
+ <property name="visible">1</property>
+ <property name="icon-name">object-select-symbolic</property>
+ <property name="icon-size">1</property>
+ <property name="tooltip-text" translatable="yes">Selection mode</property>
+ </object>
+ </child> -->
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+
+ </template>
+ <object class="GtkMenu" id="menu">
+ <property name="visible">1</property>
+
+ <child>
+ <object class="GtkMenuItem" id="new_window_item">
+ <property name="visible">1</property>
+ <property name="label">Open in New Window</property>
+ <signal name="activate" handler="on_detached_clicked_cb" swapped="yes"/>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkSeparatorMenuItem">
+ <property name="visible">true</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkMenuItem" id="undo_item">
+ <property name="visible">1</property>
+ <property name="label">Undo</property>
+ <signal name="activate" handler="on_undo_or_redo_cb" swapped="yes"/>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkMenuItem" id="redo_item">
+ <property name="visible">1</property>
+ <property name="label">Redo</property>
+ <signal name="activate" handler="on_undo_or_redo_cb" swapped="yes"/>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkMenuItem" id="notebook_item">
+ <property name="visible">1</property>
+ <property name="label">Notebooks</property>
+ <signal name="activate" handler="action_view_tags_callback" swapped="yes"/>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkMenuItem" id="email_item">
+ <property name="visible">1</property>
+ <property name="label">Email this Note</property>
+ <signal name="activate" handler="on_email_note_callback" swapped="yes"/>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkMenuItem" id="trash_item">
+ <property name="visible">1</property>
+ <property name="label">Move to Trash</property>
+ <signal name="activate" handler="trash_item_callback" swapped="yes"/>
+ </object>
+ </child>
+
+ </object>
+</interface>
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 2c877c4..83cbf88 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -52,15 +52,35 @@ struct _BjbMainToolbar
BjbMainView *parent;
BjbController *controller;
GtkWindow *window;
- GtkWidget *back;
+ /* GtkWidget *back; */
/* Main View */
- GtkWidget *new;
- GtkWidget *list;
- GtkWidget *grid;
- GtkWidget *select;
- GtkWidget *search;
- GtkWidget *empty_bin;
+ GtkWidget *new_button;
+ GtkWidget *back_button;
+ GtkWidget *list_button;
+ GtkWidget *grid_button;
+ GtkWidget *select_button;
+ GtkWidget *cancel_button;
+ GtkWidget *search_button;
+ GtkWidget *style_buttons;
+ GtkWidget *empty_button;
+ GtkWidget *color_button;
+ GtkWidget *button_stack;
+ GtkWidget *menu_button;
+
+ /* Menu items */
+ GtkWidget *new_window_item;
+ GtkWidget *undo_item;
+ GtkWidget *redo_item;
+ GtkWidget *notebook_item;
+ GtkWidget *email_item;
+ GtkWidget *trash_item;
+ /* GtkWidget *new; */
+ /* GtkWidget *list; */
+ /* GtkWidget *grid; */
+ /* GtkWidget *select; */
+ /* GtkWidget *search; */
+ /* GtkWidget *empty_bin; */
gulong finish_sig;
gulong update_selection;
gulong search_handler;
@@ -71,7 +91,7 @@ struct _BjbMainToolbar
BijiNoteObj *note;
GtkWidget *color;
GtkWidget *share;
- GtkWidget *menu;
+ /* GtkWidget *menu; */
gulong note_renamed;
gulong note_color_changed;
GtkAccelGroup *accel;
@@ -91,38 +111,40 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
G_DEFINE_TYPE (BjbMainToolbar, bjb_main_toolbar, GTK_TYPE_HEADER_BAR)
-static void
-bjb_main_toolbar_clear (BjbMainToolbar *self)
-{
- g_clear_pointer (&self->back ,gtk_widget_destroy);
- g_clear_pointer (&self->color ,gtk_widget_destroy);
- g_clear_pointer (&self->grid ,gtk_widget_destroy);
- g_clear_pointer (&self->list ,gtk_widget_destroy);
- g_clear_pointer (&self->menu ,gtk_widget_destroy);
- g_clear_pointer (&self->new ,gtk_widget_destroy);
- g_clear_pointer (&self->search ,gtk_widget_destroy);
- g_clear_pointer (&self->select ,gtk_widget_destroy);
- g_clear_pointer (&self->empty_bin ,gtk_widget_destroy);
-}
+/* static void */
+/* bjb_main_toolbar_clear (BjbMainToolbar *self) */
+/* { */
+ /* g_clear_pointer (&self->back ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->color ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->grid ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->list ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->menu ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->new ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->search ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->select ,gtk_widget_destroy); */
+ /* g_clear_pointer (&self->empty_bin ,gtk_widget_destroy); */
+/* } */
/* Callbacks */
static void
-on_new_note_clicked (GtkWidget *but, BjbMainView *view)
+on_new_note_clicked (BjbMainToolbar *self)
{
BijiNoteObj *result;
BijiManager *manager;
BjbSettings *settings;
+ g_assert (BJB_IS_MAIN_TOOLBAR (self));
+
/* append note to notebook */
- manager = bjb_window_base_get_manager (bjb_main_view_get_window (view));
+ manager = bjb_window_base_get_manager (bjb_main_view_get_window (self->parent));
settings = bjb_app_get_settings (g_application_get_default ());
result = biji_manager_note_new (manager,
NULL,
bjb_settings_get_default_location (settings));
/* Go to that note */
- switch_to_note_view(view,result);
+ switch_to_note_view (self->parent, result);
}
static void populate_main_toolbar (BjbMainToolbar *self);
@@ -162,7 +184,6 @@ on_view_selection_changed_cb (BjbMainToolbar *self)
if (!bjb_main_view_get_selection_mode (self->parent))
gtk_style_context_remove_class (context, "selection-mode");
-
else
gtk_style_context_add_class (context, "selection-mode");
@@ -174,13 +195,17 @@ on_view_selection_changed_cb (BjbMainToolbar *self)
if (self->type == BJB_TOOLBAR_SELECT)
update_selection_label (self);
- return;
+ /* return; */
}
static void
-on_selection_mode_clicked (GtkWidget *button, BjbMainToolbar *self)
+on_selection_mode_clicked (BjbMainToolbar *self,
+ GtkWidget *button)
{
- if (bjb_main_view_get_selection_mode (self->parent))
+ g_assert (BJB_IS_MAIN_TOOLBAR (self));
+ g_assert (GTK_IS_BUTTON (button));
+
+ if (button == self->cancel_button)
{
bjb_main_view_set_selection_mode (self->parent, FALSE);
}
@@ -195,9 +220,15 @@ on_selection_mode_clicked (GtkWidget *button, BjbMainToolbar *self)
}
static gboolean
-on_view_mode_clicked (GtkWidget *button, BjbMainToolbar *self)
+on_view_mode_clicked (BjbMainToolbar *self,
+ GtkWidget *button)
{
- GdMainViewType current = bjb_main_view_get_view_type (self->parent);
+ GdMainViewType current;
+
+ g_assert (BJB_IS_MAIN_TOOLBAR (self));
+ g_assert (GTK_IS_BUTTON (button));
+
+ current = bjb_main_view_get_view_type (self->parent);
switch ( current )
{
@@ -212,32 +243,32 @@ on_view_mode_clicked (GtkWidget *button, BjbMainToolbar *self)
}
bjb_main_view_update_model (self->parent);
- populate_main_toolbar (self);
-
+ /* populate_main_toolbar (self); */
+ gtk_widget_hide (button);
return TRUE;
}
-static void
-add_search_button (BjbMainToolbar *self)
-{
- GtkWidget *search_image;
-
- self->search = gtk_toggle_button_new ();
- search_image = gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (self->search), search_image);
- gtk_widget_set_valign (self->search, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->search),
- "image-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->search);
- gtk_widget_set_tooltip_text (self->search,
- _("Search note titles, content and notebooks"));
-
- g_object_bind_property (self->search,
- "active",
- bjb_window_base_get_search_bar (BJB_WINDOW_BASE (self->window)),
- "search-mode-enabled",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-}
+/* static void */
+/* add_search_button (BjbMainToolbar *self) */
+/* { */
+ /* GtkWidget *search_image; */
+
+ /* self->search = gtk_toggle_button_new (); */
+ /* search_image = gtk_image_new_from_icon_name ("edit-find-symbolic", GTK_ICON_SIZE_MENU); */
+ /* gtk_button_set_image (GTK_BUTTON (self->search), search_image); */
+ /* gtk_widget_set_valign (self->search, GTK_ALIGN_CENTER); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->search), */
+ /* "image-button"); */
+ /* gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->search); */
+ /* gtk_widget_set_tooltip_text (self->search, */
+ /* _("Search note titles, content and notebooks")); */
+
+ /* g_object_bind_property (self->search, */
+ /* "active", */
+ /* bjb_window_base_get_search_bar (BJB_WINDOW_BASE (self->window)), */
+ /* "search-mode-enabled", */
+ /* G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); */
+/* } */
static void
update_selection_buttons (BjbController *controller,
@@ -245,56 +276,65 @@ update_selection_buttons (BjbController *controller,
gboolean remaining,
BjbMainToolbar *self)
{
- if (self->grid)
- gtk_widget_set_sensitive (self->grid, some_item_is_visible);
-
- if (self->list)
- gtk_widget_set_sensitive (self->list, some_item_is_visible);
-
- if (self->empty_bin)
- gtk_widget_set_sensitive (self->empty_bin, some_item_is_visible);
-
- gtk_widget_set_sensitive (self->select, some_item_is_visible);
+ gtk_widget_set_sensitive (self->grid_button, some_item_is_visible);
+ gtk_widget_set_sensitive (self->list_button, some_item_is_visible);
+ gtk_widget_set_sensitive (self->empty_button, some_item_is_visible);
+ gtk_widget_set_sensitive (self->search_button, some_item_is_visible);
+ gtk_widget_set_sensitive (self->select_button, some_item_is_visible);
}
+static void
+connect_main_view_handlers (BjbMainToolbar *self)
+{
+ if (self->view_selection_changed == 0)
+ {
+ self->view_selection_changed =
+ g_signal_connect_swapped (self->parent, "view-selection-changed",
+ G_CALLBACK (on_view_selection_changed_cb), self);
+ }
+}
static void
populate_bar_for_selection (BjbMainToolbar *self)
{
- GtkSizeGroup *size;
+ /* GtkSizeGroup *size; */
/* Hide close button */
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), FALSE);
-
- size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+ gtk_widget_hide (self->select_button);
+ gtk_widget_hide (self->button_stack);
+ gtk_widget_hide (self->style_buttons);
+ gtk_widget_show (self->cancel_button);
+ /* size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); */
/* Select */
- self->select = gtk_button_new_with_mnemonic (_("Cancel"));
- gtk_widget_set_valign (self->select, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->select),
- "text-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->select);
+ /* self->select = gtk_button_new_with_mnemonic (_("Cancel")); */
+ /* gtk_widget_set_valign (self->select, GTK_ALIGN_CENTER); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->select), */
+ /* "text-button"); */
+ /* gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->select); */
/* Search button */
- add_search_button (self);
+ /* add_search_button (self); */
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->search);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->select);
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->search); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->select); */
- g_object_unref (size);
+ /* g_object_unref (size); */
- gtk_widget_set_tooltip_text (self->select, _("Exit selection mode"));
- gtk_widget_reset_style (self->select);
+ /* gtk_widget_set_tooltip_text (self->select, _("Exit selection mode")); */
+ /* gtk_widget_reset_style (self->select); */
- g_signal_connect (self->select, "clicked",
- G_CALLBACK (on_selection_mode_clicked), self);
+ /* g_signal_connect (self->select, "clicked", */
+ /* G_CALLBACK (on_selection_mode_clicked), self); */
- if (self->view_selection_changed == 0)
- {
- self->view_selection_changed = g_signal_connect_swapped (
- self->parent, "view-selection-changed",
- G_CALLBACK (on_view_selection_changed_cb), self);
- }
+ connect_main_view_handlers (self);
+ /* if (self->view_selection_changed == 0) */
+ /* { */
+ /* self->view_selection_changed = g_signal_connect_swapped ( */
+ /* self->parent, "view-selection-changed", */
+ /* G_CALLBACK (on_view_selection_changed_cb), self); */
+ /* } */
update_selection_label (self);
}
@@ -322,21 +362,28 @@ update_label_for_standard (BjbMainToolbar *self)
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (self), NULL);
g_free (label);
- self->display_notes = g_signal_connect (self->controller,
- "display-items-changed",
- G_CALLBACK (update_selection_buttons),
- self);
+ /* self->display_notes = g_signal_connect (self->controller, */
+ /* "display-items-changed", */
+ /* G_CALLBACK (update_selection_buttons), */
+ /* self); */
}
static void
-connect_main_view_handlers (BjbMainToolbar *self)
+disconnect_note_handlers (BjbMainToolbar *self)
{
- if (self->view_selection_changed == 0)
- {
- self->view_selection_changed = g_signal_connect_swapped (
- self->parent, "view-selection-changed",
- G_CALLBACK (on_view_selection_changed_cb), self);
- }
+ if (self->note_renamed != 0)
+ {
+ g_signal_handler_disconnect (self->note, self->note_renamed);
+ self->note_renamed = 0;
+ }
+
+ if (self->note_color_changed != 0)
+ {
+ g_signal_handler_disconnect (self->note, self->note_color_changed);
+ self->note_color_changed = 0;
+ }
+
+ self->note = NULL;
}
static void
@@ -344,6 +391,14 @@ on_back_button_clicked (BjbMainToolbar *self)
{
BijiItemsGroup group;
+ if (self->note)
+ {
+ disconnect_note_handlers (self);
+ bjb_window_base_switch_to (BJB_WINDOW_BASE (self->window),
+ BJB_WINDOW_BASE_MAIN_VIEW);
+ return;
+ }
+
group = bjb_controller_get_group (self->controller);
/* Back to main view from trash bin */
@@ -373,7 +428,7 @@ populate_bar_for_standard(BjbMainToolbar *self)
gboolean rtl;
GtkSizeGroup *size;
- rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL);
+ /* rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL); */
/* Label */
update_label_for_standard (self);
@@ -381,103 +436,103 @@ populate_bar_for_standard(BjbMainToolbar *self)
"search-changed", G_CALLBACK(update_label_for_standard), self);
/* Go back to all notes */
- coll = bjb_controller_get_notebook (self->controller);
+ /* coll = bjb_controller_get_notebook (self->controller); */
- if (coll != NULL)
- {
- self->back = gtk_button_new_from_icon_name (rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic",
- GTK_ICON_SIZE_MENU);
- gtk_widget_set_valign (self->back, GTK_ALIGN_CENTER);
- gtk_header_bar_pack_start (GTK_HEADER_BAR (self), self->back);
+ /* if (coll != NULL) */
+ /* { */
+ /* self->back = gtk_button_new_from_icon_name (rtl ? "go-previous-rtl-symbolic" :
"go-previous-symbolic", */
+ /* GTK_ICON_SIZE_MENU); */
+ /* gtk_widget_set_valign (self->back, GTK_ALIGN_CENTER); */
+ /* gtk_header_bar_pack_start (GTK_HEADER_BAR (self), self->back); */
- g_signal_connect_swapped (self->back, "clicked",
- G_CALLBACK (on_back_button_clicked), self);
- }
+ /* g_signal_connect_swapped (self->back, "clicked", */
+ /* G_CALLBACK (on_back_button_clicked), self); */
+ /* } */
- else
- {
+ /* else */
+ /* { */
/*
* Translators : <_New> refers to new note creation.
* User clicks new, which opens a new blank note.
*/
- self->new = gtk_button_new_with_mnemonic (_("_New"));
- gtk_widget_set_valign (self->new, GTK_ALIGN_CENTER);
-
- gtk_header_bar_pack_start (GTK_HEADER_BAR (self), self->new);
- gtk_widget_set_size_request (self->new, 70, -1);
- gtk_widget_add_accelerator (self->new, "clicked", self->accel, GDK_KEY_n,
- GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- g_signal_connect(self->new,"clicked",
- G_CALLBACK(on_new_note_clicked),self->parent);
- }
+ /* self->new = gtk_button_new_with_mnemonic (_("_New")); */
+ /* gtk_widget_set_valign (self->new, GTK_ALIGN_CENTER); */
+
+ /* gtk_header_bar_pack_start (GTK_HEADER_BAR (self), self->new); */
+ /* gtk_widget_set_size_request (self->new, 70, -1); */
+ /* gtk_widget_add_accelerator (self->new, "clicked", self->accel, GDK_KEY_n, */
+ /* GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); */
+ /* g_signal_connect(self->new,"clicked", */
+ /* G_CALLBACK(on_new_note_clicked),self->parent); */
+ /* } */
/* Go to selection mode */
- self->select = gtk_button_new ();
- select_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (self->select), select_image);
- gtk_widget_set_valign (self->select, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->select),
- "image-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->select);
- gtk_widget_set_tooltip_text (self->select, _("Selection mode"));
-
- g_signal_connect (self->select,"clicked",
- G_CALLBACK(on_selection_mode_clicked),self);
+ /* self->select = gtk_button_new (); */
+ /* select_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU); */
+ /* gtk_button_set_image (GTK_BUTTON (self->select), select_image); */
+ /* gtk_widget_set_valign (self->select, GTK_ALIGN_CENTER); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->select), */
+ /* "image-button"); */
+ /* gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->select); */
+ /* gtk_widget_set_tooltip_text (self->select, _("Selection mode")); */
+
+ /* g_signal_connect (self->select,"clicked", */
+ /* G_CALLBACK(on_selection_mode_clicked),self); */
/* Align buttons */
- size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->select);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->new);
- g_object_unref (size);
+ /* size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->select); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->new); */
+ /* g_object_unref (size); */
/* Show close button */
- gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);
+ /* gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE); */
/* Watch for main view changing */
connect_main_view_handlers (self);
}
-static void
-add_list_button (BjbMainToolbar *self)
-{
- GtkWidget *list_image;
-
- self->grid = NULL;
- self->list = gtk_button_new ();
- list_image = gtk_image_new_from_icon_name ("view-list-symbolic", GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (self->list), list_image);
- gtk_widget_set_valign (self->list, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->list),
- "image-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->list);
- gtk_widget_set_tooltip_text (self->list,
- _("View notes and notebooks in a list"));
- g_signal_connect (self->list, "clicked",
- G_CALLBACK(on_view_mode_clicked),self);
-}
-
-
-
-static void
-add_grid_button (BjbMainToolbar *self)
-{
- GtkWidget *grid_image;
-
- self->list = NULL;
- self->grid = gtk_button_new ();
- grid_image = gtk_image_new_from_icon_name ("view-grid-symbolic", GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (self->grid), grid_image);
- gtk_widget_set_valign (self->grid, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->grid),
- "image-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->grid);
- gtk_widget_set_tooltip_text (self->grid,
- _("View notes and notebooks in a grid"));
-
- g_signal_connect (self->grid, "clicked",
- G_CALLBACK(on_view_mode_clicked),self);
-}
+/* static void */
+/* add_list_button (BjbMainToolbar *self) */
+/* { */
+ /* GtkWidget *list_image; */
+
+ /* self->grid = NULL; */
+ /* self->list = gtk_button_new (); */
+ /* list_image = gtk_image_new_from_icon_name ("view-list-symbolic", GTK_ICON_SIZE_MENU); */
+ /* gtk_button_set_image (GTK_BUTTON (self->list), list_image); */
+ /* gtk_widget_set_valign (self->list, GTK_ALIGN_CENTER); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->list), */
+ /* "image-button"); */
+ /* gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->list); */
+ /* gtk_widget_set_tooltip_text (self->list, */
+ /* _("View notes and notebooks in a list")); */
+ /* g_signal_connect (self->list, "clicked", */
+ /* G_CALLBACK(on_view_mode_clicked),self); */
+/* } */
+
+
+
+/* static void */
+/* add_grid_button (BjbMainToolbar *self) */
+/* { */
+ /* GtkWidget *grid_image; */
+
+ /* self->list = NULL; */
+ /* self->grid = gtk_button_new (); */
+ /* grid_image = gtk_image_new_from_icon_name ("view-grid-symbolic", GTK_ICON_SIZE_MENU); */
+ /* gtk_button_set_image (GTK_BUTTON (self->grid), grid_image); */
+ /* gtk_widget_set_valign (self->grid, GTK_ALIGN_CENTER); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->grid), */
+ /* "image-button"); */
+ /* gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->grid); */
+ /* gtk_widget_set_tooltip_text (self->grid, */
+ /* _("View notes and notebooks in a grid")); */
+
+ /* g_signal_connect (self->grid, "clicked", */
+ /* G_CALLBACK(on_view_mode_clicked),self); */
+/* } */
static void
@@ -488,67 +543,71 @@ populate_bar_for_trash (BjbMainToolbar *self)
GtkSizeGroup *size;
GtkStyleContext *context;
- rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL);
+ /* rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL); */
gtk_header_bar_set_title (GTK_HEADER_BAR (self), _("Trash"));
gtk_header_bar_set_subtitle (GTK_HEADER_BAR (self), NULL);
+ gtk_widget_hide (self->new_button);
+ gtk_widget_hide (self->search_button);
+ gtk_widget_show (self->empty_button);
+ gtk_widget_show (self->back_button);
- self->back = gtk_button_new_from_icon_name (rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic",
- GTK_ICON_SIZE_MENU);
- gtk_widget_set_valign (self->back, GTK_ALIGN_CENTER);
- gtk_header_bar_pack_start (GTK_HEADER_BAR (self), self->back);
+ /* self->back = gtk_button_new_from_icon_name (rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic",
*/
+ /* GTK_ICON_SIZE_MENU); */
+ /* gtk_widget_set_valign (self->back, GTK_ALIGN_CENTER); */
+ /* gtk_header_bar_pack_start (GTK_HEADER_BAR (self), self->back); */
- g_signal_connect_swapped (self->back, "clicked",
- G_CALLBACK (on_back_button_clicked), self);
+ /* g_signal_connect_swapped (self->back, "clicked", */
+ /* G_CALLBACK (on_back_button_clicked), self); */
/* Go to selection mode */
- self->select = gtk_button_new ();
- select_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (self->select), select_image);
- gtk_widget_set_valign (self->select, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->select),
- "image-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->select);
- gtk_widget_set_tooltip_text (self->select, _("Selection mode"));
+ /* self->select = gtk_button_new (); */
+ /* select_image = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU); */
+ /* gtk_button_set_image (GTK_BUTTON (self->select), select_image); */
+ /* gtk_widget_set_valign (self->select, GTK_ALIGN_CENTER); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->select), */
+ /* "image-button"); */
+ /* gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->select); */
+ /* gtk_widget_set_tooltip_text (self->select, _("Selection mode")); */
- g_signal_connect (self->select,"clicked",
- G_CALLBACK(on_selection_mode_clicked),self);
+ /* g_signal_connect (self->select,"clicked", */
+ /* G_CALLBACK(on_selection_mode_clicked),self); */
/* Add Search ? */
/* Grid / List */
- if (self->type == BJB_TOOLBAR_TRASH_ICON)
- add_list_button (self);
+ /* if (self->type == BJB_TOOLBAR_TRASH_ICON) */
+ /* add_list_button (self); */
- if (self->type == BJB_TOOLBAR_TRASH_LIST)
- add_grid_button (self);
+ /* if (self->type == BJB_TOOLBAR_TRASH_LIST) */
+ /* add_grid_button (self); */
/* Add Empty-Bin
* translators : Empty is the verb.
* This action permanently deletes notes */
- self->empty_bin = gtk_button_new_with_label(_("Empty"));
- context = gtk_widget_get_style_context (self->empty_bin);
- gtk_style_context_add_class (context, "destructive-action");
- gtk_widget_set_valign (self->empty_bin, GTK_ALIGN_CENTER);
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->empty_bin);
- g_signal_connect_swapped (self->empty_bin,
- "clicked",
- G_CALLBACK (on_empty_clicked_callback),
- self);
+ /* self->empty_bin = gtk_button_new_with_label(_("Empty")); */
+ /* context = gtk_widget_get_style_context (self->empty_bin); */
+ /* gtk_style_context_add_class (context, "destructive-action"); */
+ /* gtk_widget_set_valign (self->empty_bin, GTK_ALIGN_CENTER); */
+ /* gtk_header_bar_pack_end (GTK_HEADER_BAR (self), self->empty_bin); */
+ /* g_signal_connect_swapped (self->empty_bin, */
+ /* "clicked", */
+ /* G_CALLBACK (on_empty_clicked_callback), */
+ /* self); */
/* Align buttons */
- size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->select);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->empty_bin);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->back);
- g_object_unref (size);
+ /* size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->select); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->empty_bin); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->back); */
+ /* g_object_unref (size); */
/* Show close button */
- gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);
+ /* gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE); */
/* Watch for main view changing */
update_selection_buttons (
@@ -561,38 +620,20 @@ populate_bar_for_trash (BjbMainToolbar *self)
-static void
-populate_bar_for_icon_view(BjbMainToolbar *self)
-{
- populate_bar_for_standard(self);
- add_list_button (self);
-}
-
-static void
-populate_bar_for_list_view(BjbMainToolbar *self)
-{
- populate_bar_for_standard(self);
- add_grid_button (self);
-}
-
-
-static void
-disconnect_note_handlers (BjbMainToolbar *self)
-{
- if (self->note_renamed != 0)
- {
- g_signal_handler_disconnect (self->note, self->note_renamed);
- self->note_renamed = 0;
- }
+/* static void */
+/* populate_bar_for_icon_view(BjbMainToolbar *self) */
+/* { */
+/* populate_bar_for_standard(self); */
+/* /\* add_list_button (self); *\/ */
+/* } */
- if (self->note_color_changed != 0)
- {
- g_signal_handler_disconnect (self->note, self->note_color_changed);
- self->note_color_changed = 0;
- }
+/* static void */
+/* populate_bar_for_list_view(BjbMainToolbar *self) */
+/* { */
+/* populate_bar_for_standard(self); */
+/* /\* add_grid_button (self); *\/ */
+/* } */
- self->note = NULL;
-}
static void
just_switch_to_main_view (BjbMainToolbar *self)
@@ -640,20 +681,20 @@ on_note_color_changed (BijiNoteObj *note, GtkColorButton *button)
-static void
-on_note_content_changed (BjbMainToolbar *self)
-{
- const gchar *str = NULL;
- gboolean sensitive = TRUE;
+/* static void */
+/* on_note_content_changed (BjbMainToolbar *self) */
+/* { */
+/* const gchar *str = NULL; */
+/* gboolean sensitive = TRUE; */
- if (self->note)
- str = biji_note_obj_get_raw_text (self->note);
+/* if (self->note) */
+/* str = biji_note_obj_get_raw_text (self->note); */
- if (!str || g_strcmp0 (str, "") == 0 || g_strcmp0 (str, "\n") == 0)
- sensitive = FALSE;
+/* if (!str || g_strcmp0 (str, "") == 0 || g_strcmp0 (str, "\n") == 0) */
+/* sensitive = FALSE; */
- gtk_widget_set_sensitive (self->share, sensitive);
-}
+/* gtk_widget_set_sensitive (self->share, sensitive); */
+/* } */
static void
@@ -677,6 +718,26 @@ trash_item_callback (GtkWidget *item, gpointer user_data)
biji_item_trash (BIJI_ITEM (self->note));
}
+static void
+on_undo_or_redo_cb (BjbMainToolbar *self,
+ GtkMenuItem *menu_item)
+{
+ BijiNoteObj *note;
+ BijiWebkitEditor *editor;
+
+ g_assert (BJB_IS_MAIN_TOOLBAR (self));
+ g_assert (GTK_IS_MENU_ITEM (menu_item));
+
+ if (!self->note)
+ return;
+
+ editor = BIJI_WEBKIT_EDITOR (biji_note_obj_get_editor (self->note));
+
+ if (menu_item == self->undo_item)
+ biji_webkit_editor_undo (editor);
+ else
+ biji_webkit_editor_redo (editor);
+}
static void
on_detached_clicked_cb (BjbMainToolbar *self)
@@ -697,39 +758,39 @@ bjb_note_menu_new (BjbMainToolbar *self)
BijiWebkitEditor *editor;
gboolean detached;
- result = gtk_menu_new();
- editor = BIJI_WEBKIT_EDITOR (biji_note_obj_get_editor (self->note));
+ /* result = gtk_menu_new(); */
+ /* editor = BIJI_WEBKIT_EDITOR (biji_note_obj_get_editor (self->note)); */
- detached = bjb_window_base_is_detached (BJB_WINDOW_BASE (self->window));
- if (detached == FALSE)
- {
+ /* detached = bjb_window_base_is_detached (BJB_WINDOW_BASE (self->window)); */
+ /* if (detached == FALSE) */
+ /* { */
/*
* Open the current note in a new window
* in order to be able to see it and others at the same time
*/
- item = gtk_menu_item_new_with_label (_("Open in New Window"));
- gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
- g_signal_connect_swapped (item, "activate",
- G_CALLBACK (on_detached_clicked_cb), self);
+ /* item = gtk_menu_item_new_with_label (_("Open in New Window")); */
+ /* gtk_menu_shell_append (GTK_MENU_SHELL (result), item); */
+ /* g_signal_connect_swapped (item, "activate", */
+ /* G_CALLBACK (on_detached_clicked_cb), self); */
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
- }
+ /* } */
/* Undo Redo separator */
- item = gtk_menu_item_new_with_label (_("Undo"));
- gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
- g_signal_connect_swapped (item, "activate",
- G_CALLBACK (biji_webkit_editor_undo), editor);
+ /* item = gtk_menu_item_new_with_label (_("Undo")); */
+ /* gtk_menu_shell_append (GTK_MENU_SHELL (result), item); */
+ /* g_signal_connect_swapped (item, "activate", */
+ /* G_CALLBACK (biji_webkit_editor_undo), editor); */
gtk_widget_add_accelerator (item, "activate", self->accel, GDK_KEY_z,
GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
- item = gtk_menu_item_new_with_label (_("Redo"));
- gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
- g_signal_connect_swapped (item, "activate",
- G_CALLBACK (biji_webkit_editor_redo), editor);
+ /* item = gtk_menu_item_new_with_label (_("Redo")); */
+ /* gtk_menu_shell_append (GTK_MENU_SHELL (result), item); */
+ /* g_signal_connect_swapped (item, "activate", */
+ /* G_CALLBACK (biji_webkit_editor_redo), editor); */
gtk_widget_add_accelerator (item, "activate", self->accel, GDK_KEY_z,
GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
@@ -739,39 +800,39 @@ bjb_note_menu_new (BjbMainToolbar *self)
/* Notebooks */
- if (biji_item_is_collectable (BIJI_ITEM (self->note)))
- {
- item = gtk_menu_item_new_with_label(_("Notebooks"));
- gtk_menu_shell_append(GTK_MENU_SHELL(result),item);
- g_signal_connect(item,"activate",
- G_CALLBACK(action_view_tags_callback),self);
+ /* if (biji_item_is_collectable (BIJI_ITEM (self->note))) */
+ /* { */
+ /* item = gtk_menu_item_new_with_label(_("Notebooks")); */
+ /* gtk_menu_shell_append(GTK_MENU_SHELL(result),item); */
+ /* g_signal_connect(item,"activate", */
+ /* G_CALLBACK(action_view_tags_callback),self); */
- }
+ /* } */
/*Share */
- self->share = gtk_menu_item_new_with_label (_("Email this Note"));
- gtk_menu_shell_append (GTK_MENU_SHELL (result), self->share);
- g_signal_connect (self->share, "activate",
- G_CALLBACK (on_email_note_callback), self->note);
+ /* self->share = gtk_menu_item_new_with_label (_("Email this Note")); */
+ /* gtk_menu_shell_append (GTK_MENU_SHELL (result), self->share); */
+ /* g_signal_connect (self->share, "activate", */
+ /* G_CALLBACK (on_email_note_callback), self->note); */
- g_signal_connect_swapped (biji_note_obj_get_editor (self->note),
- "content-changed",
- G_CALLBACK (on_note_content_changed),
- self);
+ /* g_signal_connect_swapped (biji_note_obj_get_editor (self->note), */
+ /* "content-changed", */
+ /* G_CALLBACK (on_note_content_changed), */
+ /* self); */
- on_note_content_changed (self);
+ /* on_note_content_changed (self); */
/* Delete Note */
- item = gtk_menu_item_new_with_label(_("Move to Trash"));
- gtk_menu_shell_append(GTK_MENU_SHELL(result),item);
+ /* item = gtk_menu_item_new_with_label(_("Move to Trash")); */
+ /* gtk_menu_shell_append(GTK_MENU_SHELL(result),item); */
gtk_widget_add_accelerator (item, "activate", self->accel,
GDK_KEY_Delete, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
- g_signal_connect(item,"activate",
- G_CALLBACK(trash_item_callback),self);
+ /* g_signal_connect(item,"activate", */
+ /* G_CALLBACK(trash_item_callback),self); */
- gtk_widget_show_all (result);
- return result;
+ /* gtk_widget_show_all (result); */
+ /* return result; */
}
static void
@@ -786,8 +847,8 @@ populate_bar_for_note_view (BjbMainToolbar *self)
self->note = bjb_window_base_get_note (BJB_WINDOW_BASE (self->window));
item = BIJI_ITEM (self->note);
- size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
- rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL);
+ /* size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); */
+ /* rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL); */
detached = bjb_window_base_is_detached (BJB_WINDOW_BASE (self->window));
if (!self->note) /* no reason this would happen */
@@ -795,18 +856,26 @@ populate_bar_for_note_view (BjbMainToolbar *self)
settings = bjb_app_get_settings (g_application_get_default());
+ gtk_widget_hide (self->new_button);
+ gtk_widget_hide (self->style_buttons);
+ gtk_widget_hide (self->search_button);
+ gtk_widget_hide (self->select_button);
+
+ gtk_widget_show (self->back_button);
+ gtk_widget_show (self->menu_button);
/* Go to main view basically means closing note */
- if (!detached)
+ if (detached)
{
- self->back = gtk_button_new_from_icon_name (rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic",
- GTK_ICON_SIZE_MENU);
- gtk_header_bar_pack_start (bar, self->back);
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->back);
-
- g_signal_connect_swapped (self->back, "clicked",
- G_CALLBACK (just_switch_to_main_view), self);
- gtk_widget_add_accelerator (self->back, "activate", self->accel,
- GDK_KEY_w, GDK_CONTROL_MASK, GTK_ACCEL_MASK);
+ /* self->back = gtk_button_new_from_icon_name (rtl ? "go-previous-rtl-symbolic" :
"go-previous-symbolic", */
+ /* GTK_ICON_SIZE_MENU); */
+ /* gtk_header_bar_pack_start (bar, self->back); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->back); */
+
+ gtk_widget_hide (self->new_window_item);
+ /* g_signal_connect_swapped (self->back, "clicked", */
+ /* G_CALLBACK (just_switch_to_main_view), self); */
+ /* gtk_widget_add_accelerator (self->back, "activate", self->accel, */
+ /* GDK_KEY_w, GDK_CONTROL_MASK, GTK_ACCEL_MASK); */
}
/* Note Title */
@@ -816,19 +885,19 @@ populate_bar_for_note_view (BjbMainToolbar *self)
/* Menu */
- self->menu = gtk_menu_button_new ();
- gtk_menu_button_set_direction (GTK_MENU_BUTTON (self->menu), GTK_ARROW_NONE);
- gtk_style_context_add_class (gtk_widget_get_style_context (self->menu),
- "image-button");
- gtk_header_bar_pack_end (bar, self->menu);
- gtk_widget_set_tooltip_text (self->menu, _("More options…"));
- gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->menu);
+ /* self->menu = gtk_menu_button_new (); */
+ /* gtk_menu_button_set_direction (GTK_MENU_BUTTON (self->menu), GTK_ARROW_NONE); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->menu), */
+ /* "image-button"); */
+ /* gtk_header_bar_pack_end (bar, self->menu); */
+ /* gtk_widget_set_tooltip_text (self->menu, _("More options…")); */
+ /* gtk_size_group_add_widget (GTK_SIZE_GROUP (size), self->menu); */
/* Show close button */
- gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);
+ /* gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE); */
- gtk_menu_button_set_popup (GTK_MENU_BUTTON (self->menu),
- bjb_note_menu_new (self));
+ /* gtk_menu_button_set_popup (GTK_MENU_BUTTON (self->menu), */
+ /* bjb_note_menu_new (self)); */
/* Note Color */
@@ -843,32 +912,54 @@ populate_bar_for_note_view (BjbMainToolbar *self)
g_free (default_color);
}
- self->color = bjb_color_button_new ();
- gtk_widget_set_tooltip_text (self->color, _("Note color"));
- gtk_style_context_add_class (gtk_widget_get_style_context (self->color),
- "button");
- gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->color), &color);
+ /* self->color = bjb_color_button_new (); */
+ /* gtk_widget_set_tooltip_text (self->color, _("Note color")); */
+ /* gtk_style_context_add_class (gtk_widget_get_style_context (self->color), */
+ /* "button"); */
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->color_button), &color);
+ gtk_widget_show (self->color_button);
+ /* gtk_header_bar_pack_end (bar, self->color); */
+ /* gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (self->color)), */
+ /* COLOR_SIZE, COLOR_SIZE); */
+ /* gtk_widget_show (self->color); */
+ /* gtk_size_group_add_widget (size, self->color); */
- gtk_header_bar_pack_end (bar, self->color);
- gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (self->color)),
- COLOR_SIZE, COLOR_SIZE);
- gtk_widget_show (self->color);
- gtk_size_group_add_widget (size, self->color);
-
- g_signal_connect (self->color, "color-set",
- G_CALLBACK (on_color_button_clicked), self);
+ /* g_signal_connect (self->color, "color-set", */
+ /* G_CALLBACK (on_color_button_clicked), self); */
self->note_color_changed = g_signal_connect (self->note, "color-changed",
- G_CALLBACK (on_note_color_changed), self->color);
+ G_CALLBACK (on_note_color_changed), self->color_button);
}
- g_object_unref (size);
+ /* g_object_unref (size); */
+}
+
+static void
+bjb_main_toolbar_reset (BjbMainToolbar *self)
+{
+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);
+
+ gtk_widget_show (self->button_stack);
+ gtk_widget_show (self->style_buttons);
+ gtk_widget_show (self->select_button);
+ gtk_widget_show (self->search_button);
+ gtk_widget_show (self->new_button);
+
+ gtk_widget_hide (self->back_button);
+ gtk_widget_hide (self->color_button);
+ gtk_widget_hide (self->empty_button);
+ gtk_widget_hide (self->cancel_button);
+ gtk_widget_hide (self->menu_button);
}
static void
populate_bar_switch (BjbMainToolbar *self)
{
+ bjb_main_toolbar_reset (self);
+ g_print ("here\n");
+
+ g_assert (GTK_IS_BUTTON (self->color_button));
switch (self->type)
{
case BJB_TOOLBAR_SELECT:
@@ -877,21 +968,29 @@ populate_bar_switch (BjbMainToolbar *self)
break;
case BJB_TOOLBAR_STD_ICON:
- populate_bar_for_icon_view(self);
+ populate_bar_for_standard(self);
+ gtk_widget_show (self->list_button);
+ /* gtk_widget_set_sensitive (self->select_button, */
+ /* !bjb_controller_shows_item (self->controller)); */
+ /* populate_bar_for_icon_view (self); */
update_selection_buttons (self->controller,
bjb_controller_shows_item (self->controller),
TRUE,
self);
- add_search_button (self);
+ /* add_search_button (self); */
break;
case BJB_TOOLBAR_STD_LIST:
- populate_bar_for_list_view(self);
+ populate_bar_for_standard(self);
+ gtk_widget_show (self->grid_button);
+ /* gtk_widget_set_sensitive (self->select_button, */
+ /* bjb_controller_shows_item (self->controller)); */
+ /* populate_bar_for_list_view (self); */
update_selection_buttons (self->controller,
bjb_controller_shows_item (self->controller),
TRUE,
self);
- add_search_button (self);
+ /* add_search_button (self); */
break;
@@ -908,11 +1007,11 @@ populate_bar_switch (BjbMainToolbar *self)
/* Spinner, Empty Results */
case BJB_TOOLBAR_0:
default:
- gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);
+ /* gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE); */
break;
}
- gtk_widget_show_all (GTK_WIDGET (self));
+ /* gtk_widget_show_all (GTK_WIDGET (self)); */
}
static void
@@ -979,7 +1078,7 @@ populate_main_toolbar(BjbMainToolbar *self)
disconnect_note_handlers (self);
self->type = to_be;
- bjb_main_toolbar_clear (self);
+ /* bjb_main_toolbar_clear (self); */
if (self->search_handler != 0)
@@ -988,11 +1087,11 @@ populate_main_toolbar(BjbMainToolbar *self)
self->search_handler = 0;
}
- if (self->display_notes != 0)
- {
- g_signal_handler_disconnect (self->controller, self->display_notes);
- self->display_notes = 0;
- }
+ /* if (self->display_notes != 0) */
+ /* { */
+ /* g_signal_handler_disconnect (self->controller, self->display_notes); */
+ /* self->display_notes = 0; */
+ /* } */
if (self->view_selection_changed != 0)
{
@@ -1014,6 +1113,17 @@ bjb_main_toolbar_constructed (GObject *obj)
g_signal_connect_swapped (self->window, "view-changed",
G_CALLBACK (populate_main_toolbar), self);
+ g_object_bind_property (self->search_button,
+ "active",
+ bjb_window_base_get_search_bar (BJB_WINDOW_BASE (self->window)),
+ "search-mode-enabled",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+ g_assert (GTK_IS_BUTTON (self->new_button));
+
+ gtk_widget_add_accelerator (self->new_button, "clicked", self->accel, GDK_KEY_n,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
G_OBJECT_CLASS(bjb_main_toolbar_parent_class)->constructed(obj);
}
@@ -1021,6 +1131,7 @@ static void
bjb_main_toolbar_init (BjbMainToolbar *self)
{
self->type = BJB_TOOLBAR_0;
+ gtk_widget_init_template (GTK_WIDGET (self));
}
static void
@@ -1088,6 +1199,7 @@ static void
bjb_main_toolbar_class_init (BjbMainToolbarClass *klass)
{
GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->get_property = bjb_main_toolbar_get_property;
object_class->set_property = bjb_main_toolbar_set_property;
@@ -1111,6 +1223,38 @@ bjb_main_toolbar_class_init (BjbMainToolbarClass *klass)
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
+
+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/bijiben/ui/main-toolbar.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, button_stack);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, new_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, back_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, list_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, grid_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, search_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, empty_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, style_buttons);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, cancel_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, select_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, color_button);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, menu_button);
+
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, new_window_item);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, undo_item);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, redo_item);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, notebook_item);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, email_item);
+ gtk_widget_class_bind_template_child (widget_class, BjbMainToolbar, trash_item);
+
+ gtk_widget_class_bind_template_callback (widget_class, on_new_note_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, on_selection_mode_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, on_back_button_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, on_view_mode_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, on_empty_clicked_callback);
+ gtk_widget_class_bind_template_callback (widget_class, on_color_button_clicked);
+
+ gtk_widget_class_bind_template_callback (widget_class, on_detached_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_undo_or_redo_cb);
}
BjbMainToolbar *
@@ -1124,6 +1268,10 @@ bjb_main_toolbar_new (BjbMainView *parent,
"parent", parent,
NULL));
+ self->display_notes = g_signal_connect (self->controller,
+ "display-items-changed",
+ G_CALLBACK (update_selection_buttons),
+ self);
populate_main_toolbar(self);
return self;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]