[eog] EogSidebar: Center and reformat page selector



commit 5b9f6f5e8e4b14c39b35dbd4b31712ffd0a2bf04
Author: Felix Riemann <friemann gnome org>
Date:   Fri Jan 16 22:20:13 2015 +0100

    EogSidebar: Center and reformat page selector

 data/eog.css      |    4 ++++
 src/eog-sidebar.c |   23 ++++++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/data/eog.css b/data/eog.css
index 7cef526..d8ea878 100644
--- a/data/eog.css
+++ b/data/eog.css
@@ -5,3 +5,7 @@ GtkScrollbar#eog-image-gallery-scrollbar {
        -GtkScrollbar-has-secondary-forward-stepper: false;
        -GtkScrollbar-min-slider-length: 60;
 }
+
+GtkLabel#eog-sidebar-title {
+       font-weight: bold;
+}
diff --git a/src/eog-sidebar.c b/src/eog-sidebar.c
index 4965c3d..0e7575f 100644
--- a/src/eog-sidebar.c
+++ b/src/eog-sidebar.c
@@ -60,6 +60,7 @@ struct _EogSidebarPrivate {
        GtkWidget *menu;
        GtkWidget *hbox;
        GtkWidget *label;
+       GtkWidget *arrow;
 
        GtkTreeModel *page_model;
 };
@@ -357,6 +358,16 @@ eog_sidebar_menu_item_activate_cb (GtkWidget *widget,
 }
 
 static void
+eog_sidebar_update_arrow_visibility (EogSidebar *sidebar)
+{
+       EogSidebarPrivate *priv = sidebar->priv;
+       const gint n_pages = eog_sidebar_get_n_pages (sidebar);
+
+       gtk_widget_set_visible (GTK_WIDGET (priv->arrow),
+                               n_pages > 1);
+}
+
+static void
 eog_sidebar_init (EogSidebar *eog_sidebar)
 {
        GtkWidget *hbox;
@@ -393,9 +404,10 @@ eog_sidebar_init (EogSidebar *eog_sidebar)
                          G_CALLBACK (eog_sidebar_select_button_key_press_cb),
                          eog_sidebar);
 
-       select_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+       select_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
 
        eog_sidebar->priv->label = gtk_label_new ("");
+       gtk_widget_set_name (eog_sidebar->priv->label, "eog-sidebar-title");
 
        gtk_box_pack_start (GTK_BOX (select_hbox),
                            eog_sidebar->priv->label,
@@ -405,12 +417,13 @@ eog_sidebar_init (EogSidebar *eog_sidebar)
 
        arrow = gtk_image_new_from_icon_name ("pan-down-symbolic", GTK_ICON_SIZE_BUTTON);
        gtk_box_pack_end (GTK_BOX (select_hbox), arrow, FALSE, FALSE, 0);
-       gtk_widget_show (arrow);
+       eog_sidebar->priv->arrow = arrow;
+       gtk_widget_set_visible (arrow, FALSE);
 
        gtk_container_add (GTK_CONTAINER (eog_sidebar->priv->select_button), select_hbox);
        gtk_widget_show (select_hbox);
 
-       gtk_box_pack_start (GTK_BOX (hbox), eog_sidebar->priv->select_button, TRUE, TRUE, 0);
+       gtk_box_set_center_widget (GTK_BOX (hbox), eog_sidebar->priv->select_button);
        gtk_widget_show (eog_sidebar->priv->select_button);
 
        close_button = gtk_button_new ();
@@ -521,6 +534,8 @@ eog_sidebar_add_page (EogSidebar   *eog_sidebar,
 
        g_free (label_title);
 
+       eog_sidebar_update_arrow_visibility (eog_sidebar);
+
        g_signal_emit (G_OBJECT (eog_sidebar),
                       signals[SIGNAL_PAGE_ADDED], 0, main_widget);
 }
@@ -565,6 +580,8 @@ eog_sidebar_remove_page (EogSidebar *eog_sidebar, GtkWidget *main_widget)
                gtk_list_store_remove (GTK_LIST_STORE (eog_sidebar->priv->page_model),
                                       &iter);
 
+               eog_sidebar_update_arrow_visibility (eog_sidebar);
+
                g_signal_emit (G_OBJECT (eog_sidebar),
                               signals[SIGNAL_PAGE_REMOVED], 0, main_widget);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]