[gupnp-tools] av-cp: Move Renderer Combobox into glade



commit 5c347e2bd0e7712661f4231db9df3ef00b2a3c2d
Author: Jens Georg <mail jensge org>
Date:   Sun Jun 5 19:06:48 2016 +0200

    av-cp: Move Renderer Combobox into glade
    
    Move model and cellrenderer creation into glade file
    
    Signed-off-by: Jens Georg <mail jensge org>

 data/gupnp-av-cp.ui.in     |   41 +++++++++++++++++++++++
 src/av-cp/renderer-combo.c |   77 ++------------------------------------------
 2 files changed, 44 insertions(+), 74 deletions(-)
---
diff --git a/data/gupnp-av-cp.ui.in b/data/gupnp-av-cp.ui.in
index bdd15a4..b2e1f73 100644
--- a/data/gupnp-av-cp.ui.in
+++ b/data/gupnp-av-cp.ui.in
@@ -54,6 +54,28 @@
       <column type="gint"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="renderer-list-store">
+    <columns>
+      <!-- column-name icon -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name renderer-proxy -->
+      <column type="GObject"/>
+      <!-- column-name avtransport-proxy -->
+      <column type="GObject"/>
+      <!-- column-name renderingcontrol-proxy -->
+      <column type="GObject"/>
+      <!-- column-name sink-protocol-info -->
+      <column type="gchararray"/>
+      <!-- column-name avtransport-state -->
+      <column type="guint"/>
+      <!-- column-name volume -->
+      <column type="guint"/>
+      <!-- column-name duration -->
+      <column type="guint"/>
+    </columns>
+  </object>
   <object class="GtkWindow" id="main-window">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">GUPnP AV Control Point</property>
@@ -490,6 +512,25 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="hexpand">True</property>
+                    <property name="model">renderer-list-store</property>
+                    <signal name="changed" handler="on_renderer_combo_changed" swapped="no"/>
+                    <child>
+                      <object class="GtkCellRendererPixbuf">
+                        <property name="xalign">0</property>
+                      </object>
+                      <attributes>
+                        <attribute name="pixbuf">0</attribute>
+                      </attributes>
+                    </child>
+                    <child>
+                      <object class="GtkCellRendererText">
+                        <property name="xpad">6</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <attributes>
+                        <attribute name="text">1</attribute>
+                      </attributes>
+                    </child>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>
diff --git a/src/av-cp/renderer-combo.c b/src/av-cp/renderer-combo.c
index 114a8ed..381a701 100644
--- a/src/av-cp/renderer-combo.c
+++ b/src/av-cp/renderer-combo.c
@@ -798,62 +798,8 @@ remove_media_renderer (GUPnPDeviceProxy *proxy)
         }
 }
 
-static GtkTreeModel *
-create_renderer_treemodel (void)
-{
-        GtkListStore *store;
-
-        store = gtk_list_store_new (9,
-                                    GDK_TYPE_PIXBUF, /* Icon              */
-                                    G_TYPE_STRING,   /* Name              */
-                                    G_TYPE_OBJECT,   /* renderer proxy    */
-                                    G_TYPE_OBJECT,   /* AVTranport proxy  */
-                                    G_TYPE_OBJECT,   /* Rendering Control */
-                                                     /* proxy             */
-                                    G_TYPE_STRING,   /* SinkProtocolInfo  */
-                                    G_TYPE_UINT,     /* AVTranport state  */
-                                    G_TYPE_UINT,     /* Volume            */
-                                    G_TYPE_UINT);    /* Duration          */
-
-        return GTK_TREE_MODEL (store);
-}
-
-static void
-setup_renderer_combo_text_cell (GtkWidget *widget)
-{
-        GtkCellRenderer *renderer;
-
-        renderer = gtk_cell_renderer_text_new ();
-
-        g_object_set (renderer,
-                      "xalign", 0.0,
-                      "xpad", 6,
-                      NULL);
-        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (renderer_combo),
-                                    renderer,
-                                    TRUE);
-        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (renderer_combo),
-                                       renderer,
-                                       "text", 1);
-}
-
-static void
-setup_renderer_combo_pixbuf_cell (GtkWidget *widget)
-{
-        GtkCellRenderer *renderer;
-
-        renderer = gtk_cell_renderer_pixbuf_new ();
-        g_object_set (renderer, "xalign", 0.0, NULL);
-
-        gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (renderer_combo),
-                                    renderer,
-                                    FALSE);
-        gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (renderer_combo),
-                                       renderer,
-                                       "pixbuf", 0);
-}
-
-static void
+G_MODULE_EXPORT
+void
 on_renderer_combo_changed (GtkComboBox *widget,
                            gpointer     user_data)
 {
@@ -863,7 +809,7 @@ on_renderer_combo_changed (GtkComboBox *widget,
         PlaybackState state;
         guint         volume;
 
-        combo = GTK_COMBO_BOX (renderer_combo);
+        combo = GTK_COMBO_BOX (widget);
         model = gtk_combo_box_get_model (combo);
         g_assert (model != NULL);
 
@@ -883,26 +829,9 @@ on_renderer_combo_changed (GtkComboBox *widget,
 void
 setup_renderer_combo (GtkBuilder *builder)
 {
-        GtkTreeModel *model;
-
         lc_parser = gupnp_last_change_parser_new ();
         renderer_combo = GTK_WIDGET (gtk_builder_get_object (
                                                 builder,
                                                 "renderer-combobox"));
-        g_assert (renderer_combo != NULL);
-
-        model = create_renderer_treemodel ();
-        g_assert (model != NULL);
-
-        gtk_combo_box_set_model (GTK_COMBO_BOX (renderer_combo), model);
-        g_object_unref (model);
-
-        setup_renderer_combo_pixbuf_cell (renderer_combo);
-        setup_renderer_combo_text_cell (renderer_combo);
-
-        g_signal_connect (renderer_combo,
-                          "changed",
-                          G_CALLBACK (on_renderer_combo_changed),
-                          NULL);
 }
 


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