[gedit/wip/redesign2: 9/35] Integrate sidebar insto titlebar



commit 4983980d1abb07ad23ab3ae46786a72e0dc3865b
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Wed Nov 6 09:10:42 2013 +0100

    Integrate sidebar insto titlebar

 gedit/gedit-panel.c          |  162 ------------------------------------------
 gedit/gedit-window-private.h |    2 +
 gedit/gedit-window.c         |   13 ++++
 gedit/gedit-window.ui        |  155 +++++++++++++++++++++-------------------
 4 files changed, 98 insertions(+), 234 deletions(-)
---
diff --git a/gedit/gedit-panel.c b/gedit/gedit-panel.c
index 0ac28d5..eb750df 100644
--- a/gedit/gedit-panel.c
+++ b/gedit/gedit-panel.c
@@ -51,10 +51,6 @@ struct _GeditPanelPrivate
 
        GtkWidget *main_box;
 
-       /* Title bar (vertical panel only) */
-       GtkWidget *title_image;
-       GtkWidget *title_label;
-
        /* Notebook */
        GtkWidget *notebook;
 };
@@ -320,98 +316,6 @@ gedit_panel_class_init (GeditPanelClass *klass)
                                      0);
 }
 
-/* This is ugly, since it supports only known
- * storage types of GtkImage, otherwise fall back
- * to the empty icon.
- * See http://bugzilla.gnome.org/show_bug.cgi?id=317520.
- */
-static void
-set_gtk_image_from_gtk_image (GtkImage *image,
-                             GtkImage *source)
-{
-       switch (gtk_image_get_storage_type (source))
-       {
-               case GTK_IMAGE_EMPTY:
-                       gtk_image_clear (image);
-                       break;
-               case GTK_IMAGE_PIXBUF:
-                       {
-                               GdkPixbuf *pb;
-
-                               pb = gtk_image_get_pixbuf (source);
-                               gtk_image_set_from_pixbuf (image, pb);
-                       }
-                       break;
-               G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-               case GTK_IMAGE_STOCK:
-                       {
-                               gchar *s_id;
-                               GtkIconSize s;
-
-                               gtk_image_get_stock (source, &s_id, &s);
-                               gtk_image_set_from_stock (image, s_id, s);
-                       }
-                       break;
-               case GTK_IMAGE_ICON_SET:
-                       {
-                               GtkIconSet *is;
-                               GtkIconSize s;
-
-                               gtk_image_get_icon_set (source, &is, &s);
-                               gtk_image_set_from_icon_set (image, is, s);
-                       }
-                       break;
-               G_GNUC_END_IGNORE_DEPRECATIONS;
-               case GTK_IMAGE_ANIMATION:
-                       {
-                               GdkPixbufAnimation *a;
-
-                               a = gtk_image_get_animation (source);
-                               gtk_image_set_from_animation (image, a);
-                       }
-                       break;
-               case GTK_IMAGE_ICON_NAME:
-                       {
-                               const gchar *n;
-                               GtkIconSize s;
-
-                               gtk_image_get_icon_name (source, &n, &s);
-                               gtk_image_set_from_icon_name (image, n, s);
-                       }
-                       break;
-               default:
-                       gtk_image_set_from_icon_name (image,
-                                                     "text-x-generic",
-                                                     GTK_ICON_SIZE_MENU);
-       }
-}
-
-static void
-sync_title (GeditPanel     *panel,
-           GeditPanelItem *item)
-{
-       if (panel->priv->orientation != GTK_ORIENTATION_VERTICAL)
-               return;
-
-       if (item != NULL)
-       {
-               gtk_label_set_text (GTK_LABEL (panel->priv->title_label),
-                                   item->display_name);
-
-               set_gtk_image_from_gtk_image (GTK_IMAGE (panel->priv->title_image),
-                                             GTK_IMAGE (item->icon));
-       }
-       else
-       {
-               gtk_label_set_text (GTK_LABEL (panel->priv->title_label),
-                                   _("Empty"));
-
-               gtk_image_set_from_icon_name (GTK_IMAGE (panel->priv->title_image),
-                                             "text-x-generic",
-                                             GTK_ICON_SIZE_MENU);
-       }
-}
-
 static void
 notebook_page_changed (GtkNotebook *notebook,
                        GtkWidget   *page,
@@ -427,8 +331,6 @@ notebook_page_changed (GtkNotebook *notebook,
        data = (GeditPanelItem *)g_object_get_data (G_OBJECT (item),
                                                    PANEL_ITEM_KEY);
        g_return_if_fail (data != NULL);
-
-       sync_title (panel, data);
 }
 
 static void
@@ -547,66 +449,6 @@ build_horizontal_panel (GeditPanel *panel)
 static void
 build_vertical_panel (GeditPanel *panel)
 {
-       GtkStyleContext *context;
-       GtkWidget *title_frame;
-       GtkWidget *title_hbox;
-       GtkWidget *icon_name_hbox;
-       GtkWidget *dummy_label;
-       GtkWidget *close_button;
-
-       /* Create title */
-       title_frame = gtk_frame_new (NULL);
-       context = gtk_widget_get_style_context (GTK_WIDGET (title_frame));
-       gtk_style_context_add_class (context, "title");
-       gtk_box_pack_start (GTK_BOX (panel->priv->main_box), title_frame,
-                                    FALSE, FALSE, 0);
-
-       title_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-       gtk_container_add (GTK_CONTAINER (title_frame), title_hbox);
-
-       icon_name_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-       gtk_box_pack_start (GTK_BOX (title_hbox),
-                           icon_name_hbox,
-                           TRUE,
-                           TRUE,
-                           0);
-
-       panel->priv->title_image = gtk_image_new_from_icon_name ("text-x-generic",
-                                                                GTK_ICON_SIZE_MENU);
-       gtk_box_pack_start (GTK_BOX (icon_name_hbox),
-                           panel->priv->title_image,
-                           FALSE,
-                           TRUE,
-                           0);
-
-       dummy_label = gtk_label_new (" ");
-
-       gtk_box_pack_start (GTK_BOX (icon_name_hbox),
-                           dummy_label,
-                           FALSE,
-                           FALSE,
-                           0);
-
-       panel->priv->title_label = gtk_label_new (_("Empty"));
-       gtk_widget_set_halign (panel->priv->title_label, GTK_ALIGN_START);
-       gtk_label_set_ellipsize(GTK_LABEL (panel->priv->title_label), PANGO_ELLIPSIZE_END);
-
-       gtk_box_pack_start (GTK_BOX (icon_name_hbox),
-                           panel->priv->title_label,
-                           TRUE,
-                           TRUE,
-                           0);
-
-       close_button = create_close_button (panel);
-
-       gtk_box_pack_start (GTK_BOX (title_hbox),
-                           close_button,
-                           FALSE,
-                           FALSE,
-                           0);
-
-       gtk_widget_show_all (title_frame);
-
        gtk_box_pack_start (GTK_BOX (panel->priv->main_box),
                            panel->priv->notebook,
                            TRUE,
@@ -886,10 +728,6 @@ gedit_panel_remove_item (GeditPanel *panel,
        gtk_notebook_remove_page (GTK_NOTEBOOK (panel->priv->notebook),
                                  page_num);
 
-       /* if we removed all the pages, reset the title */
-       if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (panel->priv->notebook)) == 0)
-               sync_title (panel, NULL);
-
        g_signal_emit (G_OBJECT (panel), signals[ITEM_REMOVED], 0, item);
 
        g_object_unref (G_OBJECT (item));
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index 1cb32b5..e61974b 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -87,6 +87,8 @@ struct _GeditWindowPrivate
        GtkActionGroup *documents_list_action_group;
        guint           documents_list_menu_ui_id;
 
+       GtkWidget      *titlebar_paned;
+       GtkWidget      *side_headerbar;
        GtkWidget      *headerbar;
        GtkWidget      *open_button;
        GtkWidget      *open_menu;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index fbb05ab..176572f 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -428,6 +428,8 @@ gedit_window_class_init (GeditWindowClass *klass)
        /* Bind class to template */
        gtk_widget_class_set_template_from_resource (widget_class,
                                                     "/org/gnome/gedit/ui/gedit-window.ui");
+       gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, titlebar_paned);
+       gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, side_headerbar);
        gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, headerbar);
        gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, open_menu);
        gtk_widget_class_bind_template_child_private (widget_class, GeditWindow, hpaned);
@@ -3219,6 +3221,17 @@ gedit_window_init (GeditWindow *window)
        // FIXME: kill this, right now it is just not added to the window
        create_menu_bar_and_toolbar (window);
 
+       g_object_bind_property (window->priv->side_panel,
+                               "visible",
+                               window->priv->side_headerbar,
+                               "visible",
+                               G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+       g_object_bind_property (window->priv->titlebar_paned,
+                               "position",
+                               window->priv->hpaned,
+                               "position",
+                               G_BINDING_DEFAULT | G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
        setup_headerbar_open_button (window);
 
        /* Setup status bar */
diff --git a/gedit/gedit-window.ui b/gedit/gedit-window.ui
index c01858e..d6daaf9 100644
--- a/gedit/gedit-window.ui
+++ b/gedit/gedit-window.ui
@@ -68,103 +68,114 @@
     <property name="has_focus">False</property>
     <property name="is_focus">False</property>
     <child type="titlebar">
-      <object class="GtkHeaderBar" id="headerbar">
+      <object class="GtkPaned" id="titlebar_paned">
         <property name="visible">True</property>
-        <property name="show_close_button">True</property>
         <child>
-          <object class="GtkBox" id="open_box">
+          <object class="GtkHeaderBar" id="side_headerbar">
             <property name="visible">True</property>
-            <property name="orientation">horizontal</property>
-            <property name="valign">center</property>
-            <style>
-              <class name="linked"/>
-            </style>
+            <property name="title">Documents</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkHeaderBar" id="headerbar">
+            <property name="visible">True</property>
+            <property name="show_close_button">True</property>
             <child>
-              <object class="GtkButton" id="open_button">
+              <object class="GtkBox" id="open_box">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Open</property>
-                <property name="tooltip_text" translatable="yes">Open a file</property>
-                <property name="action_name">win.open</property>
+                <property name="orientation">horizontal</property>
+                <property name="valign">center</property>
                 <style>
-                  <class name="text-button"/>
+                  <class name="linked"/>
                 </style>
+                <child>
+                  <object class="GtkButton" id="open_button">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Open</property>
+                    <property name="tooltip_text" translatable="yes">Open a file</property>
+                    <property name="action_name">win.open</property>
+                    <style>
+                      <class name="text-button"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GeditOpenMenuButton" id="open_menu">
+                    <property name="visible">True</property>
+                    <property name="tooltip_text" translatable="yes">Open a recently used file</property>
+                    <style>
+                      <class name="image-button"/>
+                    </style>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">start</property>
+              </packing>
             </child>
             <child>
-              <object class="GeditOpenMenuButton" id="open_menu">
+              <object class="GtkButton" id="new_tab_button">
                 <property name="visible">True</property>
-                <property name="tooltip_text" translatable="yes">Open a recently used file</property>
+                <property name="valign">center</property>
+                <property name="tooltip_text" translatable="yes">Create a new document</property>
+                <property name="action_name">win.new_tab</property>
                 <style>
                   <class name="image-button"/>
                 </style>
+                <child>
+                  <object class="GtkImage" id="new_tab_image">
+                    <property name="visible">True</property>
+                    <property name="icon_size">1</property>
+                    <property name="icon_name">tab-new-symbolic</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">start</property>
+              </packing>
             </child>
-          </object>
-          <packing>
-            <property name="pack_type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="new_tab_button">
-            <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="tooltip_text" translatable="yes">Create a new document</property>
-            <property name="action_name">win.new_tab</property>
-            <style>
-              <class name="image-button"/>
-            </style>
             <child>
-              <object class="GtkImage" id="new_tab_image">
+              <object class="GtkButton" id="save_button">
                 <property name="visible">True</property>
-                <property name="icon_size">1</property>
-                <property name="icon_name">tab-new-symbolic</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="pack_type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="save_button">
-            <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="tooltip_text" translatable="yes">Save the current file</property>
-            <property name="action_name">win.save</property>
-            <style>
-              <class name="image-button"/>
-            </style>
-            <child>
-              <object class="GtkImage" id="save_image">
-                <property name="visible">True</property>
-                <property name="icon_size">1</property>
-                <property name="icon_name">document-save-symbolic</property>
+                <property name="valign">center</property>
+                <property name="tooltip_text" translatable="yes">Save the current file</property>
+                <property name="action_name">win.save</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child>
+                  <object class="GtkImage" id="save_image">
+                    <property name="visible">True</property>
+                    <property name="icon_size">1</property>
+                    <property name="icon_name">document-save-symbolic</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">start</property>
+              </packing>
             </child>
-          </object>
-          <packing>
-            <property name="pack_type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkMenuButton" id="gear_button">
-            <property name="visible">True</property>
-            <property name="valign">center</property>
-            <property name="menu_model">gear-menu</property>
-            <style>
-              <class name="image-button"/>
-            </style>
             <child>
-              <object class="GtkImage" id="gear_image">
+              <object class="GtkMenuButton" id="gear_button">
                 <property name="visible">True</property>
-                <property name="icon_size">1</property>
-                <property name="icon_name">emblem-system-symbolic</property>
+                <property name="valign">center</property>
+                <property name="menu_model">gear-menu</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child>
+                  <object class="GtkImage" id="gear_image">
+                    <property name="visible">True</property>
+                    <property name="icon_size">1</property>
+                    <property name="icon_name">emblem-system-symbolic</property>
+                  </object>
+                </child>
               </object>
+              <packing>
+                <property name="pack_type">end</property>
+              </packing>
             </child>
           </object>
-          <packing>
-            <property name="pack_type">end</property>
-          </packing>
         </child>
       </object>
     </child>


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