[totem] grilo: Make TotemMainToolbar a GtkHeaderBar



commit 540764363581c5b4126e4f7e4b7257260c145dfa
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Jan 24 16:25:43 2014 +0100

    grilo: Make TotemMainToolbar a GtkHeaderBar
    
    So that we can get the right styling when using it as a
    headerbar.

 src/plugins/grilo/totem-main-toolbar.c |   58 ++++----------------------------
 src/plugins/grilo/totem-main-toolbar.h |    4 +-
 src/plugins/grilo/totemmaintoolbar.ui  |   12 ------
 3 files changed, 9 insertions(+), 65 deletions(-)
---
diff --git a/src/plugins/grilo/totem-main-toolbar.c b/src/plugins/grilo/totem-main-toolbar.c
index 3b64d32..40eb921 100644
--- a/src/plugins/grilo/totem-main-toolbar.c
+++ b/src/plugins/grilo/totem-main-toolbar.c
@@ -44,11 +44,8 @@
  * Since: 3.10
  */
 
-static void totem_main_toolbar_buildable_init (GtkBuildableIface *iface);
-
 struct _TotemMainToolbarPrivate {
   /* Template widgets */
-  GtkWidget   *headerbar;
   GtkWidget   *search_button;
   GtkWidget   *select_button;
   GtkWidget   *done_button;
@@ -82,10 +79,8 @@ struct _TotemMainToolbarPrivate {
   GtkWidget   *selection_menu_button;
 };
 
-G_DEFINE_TYPE_WITH_CODE (TotemMainToolbar, totem_main_toolbar, GTK_TYPE_BOX,
-                         G_ADD_PRIVATE (TotemMainToolbar)
-                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
-                                                totem_main_toolbar_buildable_init));
+G_DEFINE_TYPE_WITH_CODE (TotemMainToolbar, totem_main_toolbar, GTK_TYPE_HEADER_BAR,
+                         G_ADD_PRIVATE (TotemMainToolbar));
 
 enum {
   PROP_0,
@@ -148,7 +143,7 @@ update_toolbar_state (TotemMainToolbar *bar)
           g_free (label);
         }
 
-      change_class (GTK_WIDGET (priv->headerbar), "selection-mode", TRUE);
+      change_class (GTK_WIDGET (bar), "selection-mode", TRUE);
     }
   else if (priv->search_mode)
     {
@@ -167,7 +162,7 @@ update_toolbar_state (TotemMainToolbar *bar)
         gtk_widget_show (priv->select_button);
       gtk_widget_hide (priv->done_button);
 
-      change_class (GTK_WIDGET (priv->headerbar), "selection-mode", FALSE);
+      change_class (GTK_WIDGET (bar), "selection-mode", FALSE);
     }
   else
     {
@@ -182,7 +177,7 @@ update_toolbar_state (TotemMainToolbar *bar)
       if (priv->show_search_button)
         gtk_widget_show (priv->search_button);
 
-      change_class (GTK_WIDGET (priv->headerbar), "selection-mode", FALSE);
+      change_class (GTK_WIDGET (bar), "selection-mode", FALSE);
     }
 }
 
@@ -337,40 +332,6 @@ totem_main_toolbar_finalize (GObject *object)
 }
 
 static void
-totem_main_toolbar_add (GtkContainer *container,
-                        GtkWidget    *child)
-{
-  TotemMainToolbar *bar = TOTEM_MAIN_TOOLBAR (container);
-
-  if (bar->priv->headerbar == NULL)
-    GTK_CONTAINER_CLASS (totem_main_toolbar_parent_class)->add (container, child);
-  else
-    gtk_container_add (GTK_CONTAINER (bar->priv->headerbar), child);
-}
-
-static void
-totem_main_toolbar_buildable_add_child (GtkBuildable *buildable,
-                                        GtkBuilder   *builder,
-                                        GObject      *child,
-                                        const gchar  *type)
-{
-  TotemMainToolbar *bar = TOTEM_MAIN_TOOLBAR (buildable);
-
-  if (type && strcmp (type, "title") == 0)
-    totem_main_toolbar_set_custom_title (bar, GTK_WIDGET (child));
-  else if (!type)
-    gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
-  else
-    GTK_BUILDER_WARN_INVALID_CHILD_TYPE (GTK_HEADER_BAR (buildable), type);
-}
-
-static void
-totem_main_toolbar_buildable_init (GtkBuildableIface *iface)
-{
-  iface->add_child = totem_main_toolbar_buildable_add_child;
-}
-
-static void
 totem_main_toolbar_class_init (TotemMainToolbarClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -381,8 +342,6 @@ totem_main_toolbar_class_init (TotemMainToolbarClass *klass)
   object_class->set_property = totem_main_toolbar_set_property;
   object_class->get_property = totem_main_toolbar_get_property;
 
-  container_class->add = totem_main_toolbar_add;
-
   g_object_class_install_property (object_class,
                                    PROP_TITLE,
                                    g_param_spec_string ("title",
@@ -490,7 +449,6 @@ totem_main_toolbar_class_init (TotemMainToolbarClass *klass)
                 G_TYPE_NONE, 0, G_TYPE_NONE);
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/totem/grilo/totemmaintoolbar.ui");
-  gtk_widget_class_bind_template_child_private (widget_class, TotemMainToolbar, headerbar);
   gtk_widget_class_bind_template_child_private (widget_class, TotemMainToolbar, search_button);
   gtk_widget_class_bind_template_child_private (widget_class, TotemMainToolbar, select_button);
   gtk_widget_class_bind_template_child_private (widget_class, TotemMainToolbar, selection_menu_button);
@@ -577,8 +535,6 @@ totem_main_toolbar_init (TotemMainToolbar *bar)
                             bar, "search-mode", 0);
   g_object_bind_property (bar->priv->select_button, "active",
                             bar, "select-mode", 0);
-
-  gtk_widget_show_all (bar->priv->headerbar);
 };
 
 /**
@@ -759,7 +715,7 @@ totem_main_toolbar_pack_start (TotemMainToolbar *bar,
 {
   g_return_if_fail (TOTEM_IS_MAIN_TOOLBAR (bar));
 
-  gtk_header_bar_pack_start (GTK_HEADER_BAR (bar->priv->headerbar), child);
+  gtk_header_bar_pack_start (GTK_HEADER_BAR (bar), child);
 }
 
 void
@@ -768,7 +724,7 @@ totem_main_toolbar_pack_end (TotemMainToolbar *bar,
 {
   g_return_if_fail (TOTEM_IS_MAIN_TOOLBAR (bar));
 
-  gtk_header_bar_pack_end (GTK_HEADER_BAR (bar->priv->headerbar), child);
+  gtk_header_bar_pack_end (GTK_HEADER_BAR (bar), child);
 }
 
 void
diff --git a/src/plugins/grilo/totem-main-toolbar.h b/src/plugins/grilo/totem-main-toolbar.h
index 2aed9f1..6b04d23 100644
--- a/src/plugins/grilo/totem-main-toolbar.h
+++ b/src/plugins/grilo/totem-main-toolbar.h
@@ -46,14 +46,14 @@ typedef struct _TotemMainToolbarClass   TotemMainToolbarClass;
 struct _TotemMainToolbar
 {
   /*< private >*/
-  GtkBox parent;
+  GtkHeaderBar parent;
 
   TotemMainToolbarPrivate *priv;
 };
 
 struct _TotemMainToolbarClass
 {
-  GtkBoxClass parent_class;
+  GtkHeaderBarClass parent_class;
 };
 
 GType           totem_main_toolbar_get_type              (void) G_GNUC_CONST;
diff --git a/src/plugins/grilo/totemmaintoolbar.ui b/src/plugins/grilo/totemmaintoolbar.ui
index efff50a..82ffef9 100644
--- a/src/plugins/grilo/totemmaintoolbar.ui
+++ b/src/plugins/grilo/totemmaintoolbar.ui
@@ -2,10 +2,6 @@
 <interface domain="totem">
   <!-- interface-requires gtk+ 3.10 -->
   <template class="TotemMainToolbar" parent="GtkBox">
-    <property name="app_paintable">True</property>
-    <property name="can_focus">False</property>
-    <child>
-      <object class="GtkHeaderBar" id="headerbar">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
@@ -134,13 +130,5 @@
             </child>
           </object>
         </child>
-      </object>
-      <packing>
-        <property name="expand">True</property>
-        <property name="fill">True</property>
-        <property name="pack_type">end</property>
-        <property name="position">0</property>
-      </packing>
-    </child>
   </template>
 </interface>


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