[bijiben] EmptyBin: move button to header bar
- From: Pierre-Yves Luyten <pyluyten src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bijiben] EmptyBin: move button to header bar
- Date: Sun, 9 Feb 2014 00:13:18 +0000 (UTC)
commit 5538534923b6635b99aa6ef641d5c10f4282a50b
Author: Pierre-Yves Luyten <py luyten fr>
Date: Sat Feb 8 23:13:09 2014 +0100
EmptyBin: move button to header bar
bug 723844
src/bjb-main-toolbar.c | 180 ++++++++++++++++++++++++++---------------------
src/bjb-trash-bar.c | 43 ------------
src/bjb-window-base.h | 2 +-
3 files changed, 101 insertions(+), 124 deletions(-)
---
diff --git a/src/bjb-main-toolbar.c b/src/bjb-main-toolbar.c
index 07e0524..cbc0b98 100644
--- a/src/bjb-main-toolbar.c
+++ b/src/bjb-main-toolbar.c
@@ -58,6 +58,7 @@ struct _BjbMainToolbarPrivate
GtkWidget *grid;
GtkWidget *select;
GtkWidget *search;
+ GtkWidget *empty_bin;
gulong finish_sig;
gulong update_selection;
gulong search_handler;
@@ -93,15 +94,16 @@ G_DEFINE_TYPE (BjbMainToolbar, bjb_main_toolbar, GTK_TYPE_HEADER_BAR);
static void
bjb_main_toolbar_clear (BjbMainToolbar *self)
{
- g_clear_pointer (&self->priv->back ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->color ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->grid ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->list ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->menu ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->new ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->search ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->select ,gtk_widget_destroy);
- g_clear_pointer (&self->priv->share ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->back ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->color ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->grid ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->list ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->menu ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->new ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->search ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->select ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->share ,gtk_widget_destroy);
+ g_clear_pointer (&self->priv->empty_bin ,gtk_widget_destroy);
}
/* Callbacks */
@@ -389,6 +391,15 @@ on_back_button_clicked (BjbMainToolbar *self)
bjb_controller_set_notebook (self->priv->controller, NULL);
}
+
+
+static void
+on_empty_clicked_callback (BjbMainToolbar *self)
+{
+ biji_manager_empty_bin (bjb_window_base_get_manager (GTK_WIDGET (self->priv->window)));
+}
+
+
static void
populate_bar_for_standard(BjbMainToolbar *self)
{
@@ -459,6 +470,52 @@ populate_bar_for_standard(BjbMainToolbar *self)
}
+static void
+add_list_button (BjbMainToolbar *self)
+{
+ BjbMainToolbarPrivate *priv;
+ GtkWidget *list_image;
+
+ priv = self->priv;
+ priv->grid = NULL;
+ priv->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 (priv->list), list_image);
+ gtk_widget_set_valign (priv->list, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->list),
+ "image-button");
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (self), priv->list);
+ gtk_widget_set_tooltip_text (priv->list,
+ _("View notes and notebooks in a list"));
+ g_signal_connect (priv->list, "clicked",
+ G_CALLBACK(on_view_mode_clicked),self);
+}
+
+
+
+static void
+add_grid_button (BjbMainToolbar *self)
+{
+ BjbMainToolbarPrivate *priv;
+ GtkWidget *grid_image;
+
+
+ priv = self->priv;
+ priv->list = NULL;
+ priv->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 (priv->grid), grid_image);
+ gtk_widget_set_valign (priv->grid, GTK_ALIGN_CENTER);
+ gtk_style_context_add_class (gtk_widget_get_style_context (priv->grid),
+ "image-button");
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (self), priv->grid);
+ gtk_widget_set_tooltip_text (priv->grid,
+ _("View notes and notebooks in a grid"));
+
+ g_signal_connect (priv->grid, "clicked",
+ G_CALLBACK(on_view_mode_clicked),self);
+}
+
static void
populate_bar_for_trash (BjbMainToolbar *self)
@@ -467,6 +524,7 @@ populate_bar_for_trash (BjbMainToolbar *self)
gboolean rtl;
GtkWidget *select_image;
GtkSizeGroup *size;
+ GtkStyleContext *context;
priv = self->priv;
@@ -496,9 +554,34 @@ populate_bar_for_trash (BjbMainToolbar *self)
g_signal_connect (priv->select,"clicked",
G_CALLBACK(on_selection_mode_clicked),self);
+
+
+ /* Add Search ? */
+
+ /* Grid / List */
+ if (priv->type == BJB_TOOLBAR_TRASH_ICON)
+ add_list_button (self);
+
+ if (priv->type == BJB_TOOLBAR_TRASH_LIST)
+ add_grid_button (self);
+
+ /* Add Empty-Bin */
+ priv->empty_bin = gtk_button_new_with_label(_("Empty"));
+ context = gtk_widget_get_style_context (priv->empty_bin);
+ gtk_style_context_add_class (context, "destructive-action");
+ gtk_widget_set_valign (priv->empty_bin, GTK_ALIGN_CENTER);
+ gtk_header_bar_pack_end (GTK_HEADER_BAR (self), priv->empty_bin);
+ g_signal_connect_swapped (priv->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), priv->select);
+ gtk_size_group_add_widget (GTK_SIZE_GROUP (size), priv->empty_bin);
gtk_size_group_add_widget (GTK_SIZE_GROUP (size), priv->back);
g_object_unref (size);
@@ -511,51 +594,6 @@ populate_bar_for_trash (BjbMainToolbar *self)
-static void
-add_list_button (BjbMainToolbar *self)
-{
- BjbMainToolbarPrivate *priv;
- GtkWidget *list_image;
-
- priv = self->priv;
- priv->grid = NULL;
- priv->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 (priv->list), list_image);
- gtk_widget_set_valign (priv->list, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->list),
- "image-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), priv->list);
- gtk_widget_set_tooltip_text (priv->list,
- _("View notes and notebooks in a list"));
- g_signal_connect (priv->list, "clicked",
- G_CALLBACK(on_view_mode_clicked),self);
-}
-
-
-
-static void
-add_grid_button (BjbMainToolbar *self)
-{
- BjbMainToolbarPrivate *priv;
- GtkWidget *grid_image;
-
-
- priv = self->priv;
- priv->list = NULL;
- priv->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 (priv->grid), grid_image);
- gtk_widget_set_valign (priv->grid, GTK_ALIGN_CENTER);
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->grid),
- "image-button");
- gtk_header_bar_pack_end (GTK_HEADER_BAR (self), priv->grid);
- gtk_widget_set_tooltip_text (priv->grid,
- _("View notes and notebooks in a grid"));
-
- g_signal_connect (priv->grid, "clicked",
- G_CALLBACK(on_view_mode_clicked),self);
-}
static void
@@ -574,22 +612,6 @@ populate_bar_for_list_view(BjbMainToolbar *self)
static void
-populate_bar_for_trash_icon_view (BjbMainToolbar *self)
-{
- populate_bar_for_trash (self);
- add_list_button (self);
-}
-
-
-static void
-populate_bar_for_trash_list_view (BjbMainToolbar *self)
-{
- populate_bar_for_trash (self);
- add_grid_button (self);
-}
-
-
-static void
disconnect_note_handlers (BjbMainToolbarPrivate *priv)
{
if (priv->note_renamed != 0)
@@ -947,15 +969,11 @@ populate_bar_switch (BjbMainToolbar *self)
case BJB_TOOLBAR_TRASH_ICON:
- //add_search_button (self); TODO (handle callback)
- populate_bar_for_trash_icon_view (self);
- break;
-
case BJB_TOOLBAR_TRASH_LIST:
- //add_search_button (self); TODO (handle callback)
- populate_bar_for_trash_list_view (self);
+ populate_bar_for_trash (self);
break;
+
case BJB_TOOLBAR_NOTE_VIEW:
populate_bar_for_note_view (self);
break;
@@ -1022,6 +1040,7 @@ populate_main_toolbar(BjbMainToolbar *self)
to_be = BJB_TOOLBAR_0;
}
+
/* Simply clear then populate */
if (to_be != priv->type)
{
@@ -1080,16 +1099,17 @@ bjb_main_toolbar_init (BjbMainToolbar *self)
priv->grid = NULL;
priv->list = NULL;
priv->search = NULL;
- priv->search_handler = 0;
- priv->display_notes = 0;
- priv->view_selection_changed = 0;
-
+ priv->empty_bin = NULL;
priv->accel = NULL;
priv->note = NULL;
priv->back = NULL;
priv->color = NULL;
priv->menu = NULL;
priv->share = NULL;
+
+ priv->search_handler = 0;
+ priv->display_notes = 0;
+ priv->view_selection_changed = 0;
priv->note_renamed = 0;
priv->note_color_changed = 0;
diff --git a/src/bjb-trash-bar.c b/src/bjb-trash-bar.c
index 42f84fd..48c6b10 100644
--- a/src/bjb-trash-bar.c
+++ b/src/bjb-trash-bar.c
@@ -50,7 +50,6 @@ struct BjbTrashBarPrivate_
GdMainView *selection;
GtkWidget *normal_box;
- GtkWidget *empty_bin;
GtkWidget *selection_box;
GtkWidget *restore;
@@ -64,14 +63,6 @@ G_DEFINE_TYPE (BjbTrashBar, bjb_trash_bar, GTK_TYPE_BOX)
-static void
-on_empty_clicked_callback (BjbTrashBar *self)
-{
-
- biji_manager_empty_bin (
- bjb_window_base_get_manager (
- gtk_widget_get_toplevel (GTK_WIDGET (self))));
-}
static void
@@ -109,30 +100,16 @@ bjb_trash_bar_set_visibility (BjbTrashBar *self)
priv = self->priv;
- gtk_widget_hide (priv->normal_box);
gtk_widget_hide (priv->selection_box);
items = gd_main_view_get_selection (priv->selection);
if (items != NULL)
gtk_widget_show (priv->selection_box);
- else
- gtk_widget_show (priv->normal_box);
-
g_list_free (items);
}
-void
-bjb_trash_bar_fade_in (BjbTrashBar *self)
-{
-}
-
-
-void
-bjb_trash_bar_fade_out (BjbTrashBar *self)
-{
-}
static void
bjb_trash_bar_dispose (GObject *obj)
@@ -206,26 +183,6 @@ bjb_trash_bar_constructed (GObject *obj)
super_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (self), super_box);
- /* No selection : just offer to empty bin */
- priv->normal_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
- gtk_widget_set_hexpand (priv->normal_box, TRUE);
- priv->empty_bin = gtk_button_new_with_label(_("Empty"));
- gtk_widget_set_halign (priv->empty_bin, GTK_ALIGN_CENTER);
- gtk_widget_set_size_request (priv->empty_bin, 90, -1);
- context = gtk_widget_get_style_context (priv->empty_bin);
- gtk_style_context_add_class (context, "destructive-action");
- gtk_box_pack_start (GTK_BOX (priv->normal_box),
- priv->empty_bin,
- TRUE,
- FALSE,
- 0);
- gtk_container_add (GTK_CONTAINER (super_box), priv->normal_box);
- g_signal_connect_swapped (priv->empty_bin,
- "clicked",
- G_CALLBACK (on_empty_clicked_callback),
- self);
-
-
/* Selection : delete or restore selected items */
priv->selection_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
gtk_widget_set_hexpand (priv->selection_box, TRUE);
diff --git a/src/bjb-window-base.h b/src/bjb-window-base.h
index 004937d..b06eff3 100644
--- a/src/bjb-window-base.h
+++ b/src/bjb-window-base.h
@@ -31,8 +31,8 @@ struct _BjbWindowBase
};
typedef enum {
- BJB_WINDOW_BASE_ARCHIVE_VIEW,
BJB_WINDOW_BASE_MAIN_VIEW,
+ BJB_WINDOW_BASE_ARCHIVE_VIEW,
BJB_WINDOW_BASE_SPINNER_VIEW,
BJB_WINDOW_BASE_NOTE_VIEW,
BJB_WINDOW_BASE_NO_NOTE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]