[bijiben/wip/sadiq/modernize] main-toolbar: wip
- From: Mohammed Sadiq <pksadiq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben/wip/sadiq/modernize] main-toolbar: wip
- Date: Fri, 29 Dec 2017 08:05:55 +0000 (UTC)
commit cb774bb045ce99e813767b3125a65887f37a4964
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 | 252 +++++++++++++
src/bjb-main-toolbar.c | 806 ++++++++++++++-------------------------
3 files changed, 542 insertions(+), 517 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..f378f8b
--- /dev/null
+++ b/data/resources/main-toolbar.ui
@@ -0,0 +1,252 @@
+<?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>
+ </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>
+ </child>
+
+ </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" 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>
+ </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" bind-source="new_window_item" bind-property="visible" bind-flags="default"/>
+ </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="GtkSeparatorMenuItem">
+ <property name="visible">1</property>
+ </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_cb" 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..fe1d7d4 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -1,5 +1,6 @@
/* Bijiben
* Copyright (C) Pierre-Yves Luyten 2012, 2013 <py luyten fr>
+ * Copyright 2017 Mohammed Sadiq <sadiq sadiqpk org>
*
* bijiben is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -45,36 +46,46 @@ typedef enum
struct _BjbMainToolbar
{
- GtkHeaderBar parent_instance;
+ GtkHeaderBar parent_instance;
/* Controllers */
- BjbToolbarType type;
- BjbMainView *parent;
- BjbController *controller;
- GtkWindow *window;
- GtkWidget *back;
+ BjbToolbarType type;
+ BjbMainView *parent;
+ BjbController *controller;
+ GtkWindow *window;
/* Main View */
- GtkWidget *new;
- GtkWidget *list;
- GtkWidget *grid;
- GtkWidget *select;
- GtkWidget *search;
- GtkWidget *empty_bin;
- gulong finish_sig;
- gulong update_selection;
- gulong search_handler;
- gulong display_notes;
- gulong view_selection_changed;
+ 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;
+
+ /* Signals */
+ gulong search_handler;
+ gulong display_notes;
+ gulong view_selection_changed;
/* When note view */
- BijiNoteObj *note;
- GtkWidget *color;
- GtkWidget *share;
- GtkWidget *menu;
- gulong note_renamed;
- gulong note_color_changed;
- GtkAccelGroup *accel;
+ BijiNoteObj *note;
+ gulong note_renamed;
+ gulong note_color_changed;
+ GtkAccelGroup *accel;
};
/* GObject properties */
@@ -90,39 +101,24 @@ 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);
-}
-
-/* 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 +158,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");
@@ -173,14 +168,16 @@ on_view_selection_changed_cb (BjbMainToolbar *self)
* the bar is not totaly refreshed. just udpate label */
if (self->type == BJB_TOOLBAR_SELECT)
update_selection_label (self);
-
- 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 +192,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,89 +215,50 @@ 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
update_selection_buttons (BjbController *controller,
gboolean some_item_is_visible,
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;
-
- /* Hide close button */
gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), FALSE);
-
- 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);
-
- /* Search button */
- 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);
-
- g_object_unref (size);
-
- 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);
-
- 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);
- }
+ gtk_widget_hide (self->select_button);
+ gtk_widget_hide (self->button_stack);
+ gtk_widget_hide (self->style_buttons);
+ gtk_widget_show (self->cancel_button);
+ 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 +286,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 +315,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 */
@@ -368,187 +347,30 @@ on_empty_clicked_callback (BjbMainToolbar *self)
static void
populate_bar_for_standard(BjbMainToolbar *self)
{
- BijiNotebook *coll;
- GtkWidget *select_image;
- gboolean rtl;
- GtkSizeGroup *size;
-
- rtl = (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL);
+ /* Check for Notebook view */
+ if (bjb_controller_get_notebook (self->controller))
+ {
+ gtk_widget_hide (self->new_button);
+ gtk_widget_show (self->back_button);
+ }
/* Label */
update_label_for_standard (self);
self->search_handler = g_signal_connect_swapped (self->controller,
"search-changed", G_CALLBACK(update_label_for_standard), self);
-
- /* Go back to all notes */
- 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);
-
- g_signal_connect_swapped (self->back, "clicked",
- G_CALLBACK (on_back_button_clicked), self);
- }
-
- 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);
- }
-
- /* 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);
-
- /* 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);
-
- /* Show close button */
- 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
populate_bar_for_trash (BjbMainToolbar *self)
{
- gboolean rtl;
- GtkWidget *select_image;
- GtkSizeGroup *size;
- GtkStyleContext *context;
-
- 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);
-
- 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);
-
- /* 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);
-
-
-
- /* Add Search ? */
-
- /* Grid / List */
- if (self->type == BJB_TOOLBAR_TRASH_ICON)
- add_list_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);
-
-
-
- /* 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);
-
- /* Show close button */
- gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE);
+ gtk_widget_hide (self->new_button);
+ gtk_widget_hide (self->search_button);
+ gtk_widget_show (self->empty_button);
+ gtk_widget_show (self->back_button);
/* Watch for main view changing */
update_selection_buttons (
@@ -557,51 +379,6 @@ populate_bar_for_trash (BjbMainToolbar *self)
connect_main_view_handlers (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;
- }
-
- 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
-just_switch_to_main_view (BjbMainToolbar *self)
-{
- disconnect_note_handlers (self);
- bjb_window_base_switch_to (BJB_WINDOW_BASE (self->window),
- BJB_WINDOW_BASE_MAIN_VIEW);
-}
-
static void
on_note_renamed (BijiItem *note,
BjbMainToolbar *self)
@@ -617,20 +394,21 @@ on_note_renamed (BijiItem *note,
}
static void
-on_color_button_clicked (GtkColorButton *button,
- BjbMainToolbar *bar)
+on_color_button_clicked (BjbMainToolbar *self,
+ GtkColorButton *button)
{
GdkRGBA color;
- if (!bar->note)
+ if (!self->note)
return;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &color);
- biji_note_obj_set_rgba (bar->note, &color);
+ biji_note_obj_set_rgba (self->note, &color);
}
static void
-on_note_color_changed (BijiNoteObj *note, GtkColorButton *button)
+on_note_color_changed (BijiNoteObj *note,
+ GtkColorButton *button)
{
GdkRGBA color;
@@ -640,154 +418,97 @@ 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
-action_view_tags_callback (GtkWidget *item, gpointer user_data)
+action_view_tags_callback (BjbMainToolbar *self)
{
- BjbMainToolbar *self = BJB_MAIN_TOOLBAR (user_data);
GList *list = NULL;
+ g_assert (BJB_IS_MAIN_TOOLBAR (self));
+
list = g_list_append (list, self->note);
bjb_organize_dialog_new (self->window, list);
g_list_free (list);
}
static void
-trash_item_callback (GtkWidget *item, gpointer user_data)
+trash_item_callback (BjbMainToolbar *self)
{
- BjbMainToolbar *self = BJB_MAIN_TOOLBAR (user_data);
+ g_assert (BJB_IS_MAIN_TOOLBAR (self));
+
+ if (!self->note)
+ return;
/* Delete the note from notebook
* The deleted note will emit a signal. */
biji_item_trash (BIJI_ITEM (self->note));
}
+static void
+on_undo_or_redo_cb (BjbMainToolbar *self,
+ GtkWidget *menu_item)
+{
+ 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)
{
BijiNoteObj *note;
+ g_assert (BJB_IS_MAIN_TOOLBAR (self));
+
note = bjb_window_base_get_note (BJB_WINDOW_BASE (self->window));
bjb_window_base_switch_to (BJB_WINDOW_BASE (self->window),
BJB_WINDOW_BASE_MAIN_VIEW);
bijiben_new_window_for_note (g_application_get_default (), note);
}
-
-static GtkWidget *
-bjb_note_menu_new (BjbMainToolbar *self)
+static void
+on_email_cb (BjbMainToolbar *self,
+ GtkWidget *menu_item)
{
- GtkWidget *result, *item;
- BijiWebkitEditor *editor;
- gboolean detached;
-
- 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)
- {
- /*
- * 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_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);
- 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);
- gtk_widget_add_accelerator (item, "activate", self->accel, GDK_KEY_z,
- GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
-
- item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append (GTK_MENU_SHELL (result), item);
-
-
- /* Notebooks */
+ g_return_if_fail (self->note);
- 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);
-
- 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);
-
- /* Delete Note */
- 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);
-
- gtk_widget_show_all (result);
- return result;
+ on_email_note_callback (menu_item, self->note);
}
static void
populate_bar_for_note_view (BjbMainToolbar *self)
{
- GtkHeaderBar *bar = GTK_HEADER_BAR (self);
- BjbSettings *settings;
- GdkRGBA color;
- GtkSizeGroup *size;
- BijiItem *item;
- gboolean rtl, detached;
+ BjbSettings *settings;
+ GdkRGBA color;
+ gboolean detached;
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);
detached = bjb_window_base_is_detached (BJB_WINDOW_BASE (self->window));
if (!self->note) /* no reason this would happen */
@@ -795,42 +516,25 @@ populate_bar_for_note_view (BjbMainToolbar *self)
settings = bjb_app_get_settings (g_application_get_default());
- /* Go to main view basically means closing note */
- 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);
- }
+ 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);
+
+ if (detached)
+ {
+ gtk_widget_hide (self->new_window_item);
+ gtk_widget_hide (self->button_stack);
+ }
/* Note Title */
- on_note_renamed (item, self);
+ on_note_renamed (BIJI_ITEM (self->note), self);
self->note_renamed = g_signal_connect (self->note,"renamed",
G_CALLBACK (on_note_renamed), 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_menu_button_set_popup (GTK_MENU_BUTTON (self->menu),
- bjb_note_menu_new (self));
-
-
/* Note Color */
if (biji_item_has_color (BIJI_ITEM (self->note)))
{
@@ -843,32 +547,37 @@ 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);
-
-
- 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);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (self->color_button), &color);
+ gtk_widget_show (self->color_button);
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);
+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_assert (GTK_IS_BUTTON (self->color_button));
switch (self->type)
{
case BJB_TOOLBAR_SELECT:
@@ -877,21 +586,21 @@ 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);
update_selection_buttons (self->controller,
bjb_controller_shows_item (self->controller),
TRUE,
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);
update_selection_buttons (self->controller,
bjb_controller_shows_item (self->controller),
TRUE,
self);
- add_search_button (self);
break;
@@ -908,11 +617,8 @@ 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);
break;
}
-
- gtk_widget_show_all (GTK_WIDGET (self));
}
static void
@@ -979,7 +685,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,12 +694,6 @@ 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->view_selection_changed != 0)
{
g_signal_handler_disconnect (self->parent, self->view_selection_changed);
@@ -1005,15 +705,43 @@ populate_main_toolbar(BjbMainToolbar *self)
}
static void
+bjb_main_toolbar_setup_menu (BjbMainToolbar *self)
+{
+ gtk_widget_add_accelerator (self->undo_item, "activate", self->accel, GDK_KEY_z,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator (self->redo_item, "activate", self->accel, GDK_KEY_z,
+ GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);
+ /* 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); */
+ gtk_widget_add_accelerator (self->trash_item, "activate", self->accel,
+ GDK_KEY_Delete, GDK_CONTROL_MASK,
+ GTK_ACCEL_VISIBLE);
+}
+
+static void
bjb_main_toolbar_constructed (GObject *obj)
{
BjbMainToolbar *self = BJB_MAIN_TOOLBAR (obj);
self->accel = gtk_accel_group_new ();
gtk_window_add_accel_group (self->window, self->accel);
+ gtk_widget_add_accelerator (self->new_button, "clicked", self->accel, GDK_KEY_n,
+ GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
+
+ bjb_main_toolbar_setup_menu (self);
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_OBJECT_CLASS(bjb_main_toolbar_parent_class)->constructed(obj);
}
@@ -1021,6 +749,7 @@ static void
bjb_main_toolbar_init (BjbMainToolbar *self)
{
self->type = BJB_TOOLBAR_0;
+ gtk_widget_init_template (GTK_WIDGET (self));
}
static void
@@ -1029,10 +758,13 @@ bjb_main_toolbar_finalize (GObject *object)
BjbMainToolbar *self = BJB_MAIN_TOOLBAR(object);
if (self->search_handler != 0)
- {
g_signal_handler_disconnect (self->controller, self->search_handler);
- self->search_handler = 0;
- }
+
+ if (self->view_selection_changed != 0)
+ g_signal_handler_disconnect (self->parent, self->view_selection_changed);
+
+ if (self->display_notes != 0)
+ g_signal_handler_disconnect (self->controller, self->display_notes);
gtk_window_remove_accel_group (self->window, self->accel);
disconnect_note_handlers (self);
@@ -1088,6 +820,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 +844,41 @@ 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);
+ gtk_widget_class_bind_template_callback (widget_class, action_view_tags_callback);
+ gtk_widget_class_bind_template_callback (widget_class, trash_item_callback);
+ gtk_widget_class_bind_template_callback (widget_class, on_email_cb);
}
BjbMainToolbar *
@@ -1124,6 +892,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]