[gupnp-tools] universal-cp: Remove deprecated GTK+ widget/property use



commit 80798bd591001aa2b935d731fb5af7b217f06010
Author: Jussi Kukkonen <jku goto fi>
Date:   Thu Jul 17 16:05:17 2014 +0300

    universal-cp: Remove deprecated GTK+ widget/property use
    
    Don't use Box, VBox, Hbox or Table: use Grid instead. Don't use
    HPaned or VPaned, use Paned instead. Don't use properties in Misc,
    but those in Widget.
    
    Stop using stock items.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=733594

 data/gupnp-universal-cp.ui       |  372 ++++++++++++++++----------------------
 src/universal-cp/action-dialog.c |  161 ++++++-----------
 2 files changed, 215 insertions(+), 318 deletions(-)
---
diff --git a/data/gupnp-universal-cp.ui b/data/gupnp-universal-cp.ui
index 26579e9..4760b32 100644
--- a/data/gupnp-universal-cp.ui
+++ b/data/gupnp-universal-cp.ui
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
 <interface>
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.0"/>
   <object class="GtkAboutDialog" id="about-dialog">
     <property name="can_focus">False</property>
     <property name="type_hint">normal</property>
@@ -12,9 +13,9 @@ Inspired by Intel Tools for UPnP.</property>
     <property name="authors">Zeeshan Ali (Khattak) &lt;zeeshanak gnome org&gt;</property>
     <property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with 
your names, one name per line.">translator-credits</property>
     <property name="artists">Lapo Calamandrei &lt;calamandrei gmail com&gt;</property>
+    <property name="logo_icon_name">image-missing</property>
     <property name="license_type">gpl-2-0</property>
-    <signal name="delete-event" handler="gtk_widget_hide" object="about-dialog" swapped="yes"/>
-    <signal name="response" handler="gtk_widget_hide" object="about-dialog" swapped="yes"/>
+    <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
@@ -55,11 +56,10 @@ Inspired by Intel Tools for UPnP.</property>
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="action-invocation-dialog-close-button">
-                <property name="label">gtk-close</property>
+                <property name="label">Close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
                 <signal name="clicked" handler="gtk_dialog_response" object="action-invocation-dialog" 
swapped="yes"/>
               </object>
               <packing>
@@ -77,205 +77,163 @@ Inspired by Intel Tools for UPnP.</property>
           </packing>
         </child>
         <child>
-          <object class="GtkHBox" id="action-invocaion-hbox">
+          <object class="GtkGrid" id="action-invocation-grid">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="border_width">4</property>
-            <property name="spacing">4</property>
+            <property name="row_spacing">4</property>
+            <property name="column_spacing">4</property>
+            <property name="row_homogeneous">True</property>
             <child>
-              <object class="GtkAlignment" id="action-invocation-table-alignment">
+              <object class="GtkButton" id="action-invocation-button">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <signal name="clicked" handler="on_action_invocation" swapped="no"/>
                 <child>
-                  <object class="GtkTable" id="action-invocation-table">
+                  <object class="GtkGrid" id="grid1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="n_rows">3</property>
-                    <property name="n_columns">2</property>
-                    <property name="column_spacing">4</property>
-                    <property name="row_spacing">4</property>
-                    <child>
-                      <object class="GtkLabel" id="action-label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">action</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
-                        <property name="x_options"/>
-                        <property name="y_options"/>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="service-label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">service</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options"/>
-                        <property name="y_options"/>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="device-label">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">device</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="x_options"/>
-                        <property name="y_options"/>
-                      </packing>
-                    </child>
+                    <property name="margin_start">12</property>
+                    <property name="margin_end">12</property>
                     <child>
-                      <object class="GtkImage" id="action-image">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="stock">gtk-missing-image</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
-                        <property name="x_options"/>
-                        <property name="y_options"/>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkImage" id="service-image">
+                      <object class="GtkLabel" id="label1">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="stock">gtk-missing-image</property>
+                        <property name="halign">end</property>
+                        <property name="valign">start</property>
+                        <property name="vexpand">True</property>
+                        <property name="label" translatable="yes">_Invoke</property>
+                        <property name="use_underline">True</property>
                       </object>
                       <packing>
+                        <property name="left_attach">0</property>
                         <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options"/>
-                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkImage" id="device-image">
+                      <object class="GtkImage" id="image1">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="stock">gtk-missing-image</property>
+                        <property name="valign">end</property>
+                        <property name="vexpand">True</property>
+                        <property name="icon_name">system-run</property>
+                        <property name="icon_size">3</property>
                       </object>
                       <packing>
-                        <property name="x_options"/>
-                        <property name="y_options"/>
+                        <property name="left_attach">0</property>
+                        <property name="top_attach">0</property>
                       </packing>
                     </child>
                   </object>
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
+                <property name="left_attach">2</property>
+                <property name="top_attach">0</property>
+                <property name="height">3</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="action-invocation-button">
+              <object class="GtkImage" id="device-image">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <signal name="clicked" handler="on_action_invocation" swapped="no"/>
-                <child>
-                  <object class="GtkHBox" id="hbox1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="border_width">12</property>
-                    <property name="spacing">12</property>
-                    <child>
-                      <object class="GtkImage" id="image1">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="stock">gtk-execute</property>
-                        <property name="icon-size">3</property>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label1">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="label" translatable="yes">_Invoke</property>
-                        <property name="use_underline">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
+                <property name="can_focus">False</property>
+                <property name="icon_name">image-missing</property>
               </object>
               <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkImage" id="service-image">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="icon_name">image-missing</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkImage" id="action-image">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="icon_name">image-missing</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="device-label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="hexpand">True</property>
+                <property name="label" translatable="yes">device</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="service-label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="hexpand">True</property>
+                <property name="label" translatable="yes">service</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="action-label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="hexpand">True</property>
+                <property name="label" translatable="yes">action</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="top_attach">2</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox3">
+          <object class="GtkGrid" id="action-arguments-grid">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="spacing">2</property>
+            <property name="hexpand">True</property>
+            <property name="row_spacing">4</property>
+            <property name="column_spacing">4</property>
             <child>
               <object class="GtkExpander" id="in-action-arguments-expander">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
                 <property name="expanded">True</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment1">
+                  <object class="GtkGrid" id="in-action-arguments-grid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
+                    <property name="margin_start">20</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkTable" id="in-action-arguments-table">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="border_width">4</property>
-                        <property name="n_columns">2</property>
-                        <property name="column_spacing">4</property>
-                        <property name="row_spacing">2</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
+                      <placeholder/>
                     </child>
                   </object>
                 </child>
@@ -283,48 +241,32 @@ Inspired by Intel Tools for UPnP.</property>
                   <object class="GtkLabel" id="label2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">&lt;b&gt;'in' arguments&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
+                    <property name="label" translatable="yes">'in' arguments</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
                   </object>
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
               </packing>
             </child>
             <child>
               <object class="GtkExpander" id="out-action-arguments-expander">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment3">
+                  <object class="GtkGrid" id="out-action-arguments-grid">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="left_padding">12</property>
+                    <property name="margin_start">20</property>
+                    <property name="row_spacing">6</property>
+                    <property name="column_spacing">6</property>
                     <child>
-                      <object class="GtkTable" id="out-action-arguments-table">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="border_width">4</property>
-                        <property name="n_columns">2</property>
-                        <property name="column_spacing">4</property>
-                        <property name="row_spacing">4</property>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
+                      <placeholder/>
                     </child>
                   </object>
                 </child>
@@ -332,25 +274,28 @@ Inspired by Intel Tools for UPnP.</property>
                   <object class="GtkLabel" id="label3">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">&lt;b&gt;'out' arguments&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
+                    <property name="label" translatable="yes">'out' arguments</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
                   </object>
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
               </packing>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="padding">2</property>
+            <property name="expand">True</property>
+            <property name="fill">False</property>
             <property name="position">2</property>
           </packing>
         </child>
+        <child>
+          <placeholder/>
+        </child>
       </object>
     </child>
     <action-widgets>
@@ -464,7 +409,7 @@ Inspired by Intel Tools for UPnP.</property>
     <property name="title" translatable="yes">GUPnP Universal Control Point</property>
     <signal name="delete-event" handler="on_delete_event" swapped="no"/>
     <child>
-      <object class="GtkVBox" id="vbox2">
+      <object class="GtkGrid" id="main-window-grid">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
@@ -481,12 +426,10 @@ Inspired by Intel Tools for UPnP.</property>
                   <object class="GtkMenu" id="file_menuitem_menu">
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkImageMenuItem" id="clear_event_log">
-                        <property name="label" translatable="yes">_Clear event log</property>
+                      <object class="GtkMenuItem" id="clear_event_log">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="use_stock">True</property>
+                        <property name="label" translatable="yes">Clear event log</property>
                         <signal name="activate" handler="on_clear_event_log_activate" swapped="no"/>
                       </object>
                     </child>
@@ -497,12 +440,10 @@ Inspired by Intel Tools for UPnP.</property>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkImageMenuItem" id="quit">
-                        <property name="label">gtk-quit</property>
+                      <object class="GtkMenuItem" id="quit">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="use_stock">True</property>
+                        <property name="label" translatable="yes">Quit</property>
                         <signal name="activate" handler="application_exit" swapped="no"/>
                       </object>
                     </child>
@@ -567,12 +508,10 @@ Inspired by Intel Tools for UPnP.</property>
                   <object class="GtkMenu" id="help_menuitem_menu">
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkImageMenuItem" id="about">
-                        <property name="label">gtk-about</property>
+                      <object class="GtkMenuItem" id="about">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="use_underline">True</property>
-                        <property name="use_stock">True</property>
+                        <property name="label" translatable="yes">About</property>
                         <signal name="activate" handler="gtk_widget_show" object="about-dialog" 
swapped="yes"/>
                       </object>
                     </child>
@@ -582,15 +521,16 @@ Inspired by Intel Tools for UPnP.</property>
             </child>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
           </packing>
         </child>
         <child>
-          <object class="GtkHPaned" id="main-window-hpaned">
+          <object class="GtkPaned" id="main-window-hpaned">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
             <child>
               <object class="GtkScrolledWindow" id="scrolledwindow1">
                 <property name="visible">True</property>
@@ -602,10 +542,10 @@ Inspired by Intel Tools for UPnP.</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="headers_visible">False</property>
-                    <signal name="row-activated" handler="on_device_treeview_row_activate" swapped="no"/>
                     <signal name="button-release-event" handler="on_device_treeview_button_release" 
swapped="no"/>
+                    <signal name="row-activated" handler="on_device_treeview_row_activate" swapped="no"/>
                     <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection1"/>
+                      <object class="GtkTreeSelection" id="treeview-selection"/>
                     </child>
                   </object>
                 </child>
@@ -616,22 +556,24 @@ Inspired by Intel Tools for UPnP.</property>
               </packing>
             </child>
             <child>
-              <object class="GtkVPaned" id="main-window-vpaned">
+              <object class="GtkPaned" id="main-window-vpaned">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="orientation">vertical</property>
                 <child>
                   <object class="GtkScrolledWindow" id="details-scrolledwindow">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="vexpand">True</property>
                     <property name="shadow_type">in</property>
                     <child>
                       <object class="GtkTreeView" id="details-treeview">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <signal name="row-activated" handler="on_details_treeview_row_activate" 
swapped="no"/>
                         <signal name="button-release-event" handler="on_details_treeview_button_release" 
swapped="no"/>
+                        <signal name="row-activated" handler="on_details_treeview_row_activate" 
swapped="no"/>
                         <child internal-child="selection">
-                          <object class="GtkTreeSelection" id="treeview-selection2"/>
+                          <object class="GtkTreeSelection" id="treeview-selection1"/>
                         </child>
                       </object>
                     </child>
@@ -645,13 +587,14 @@ Inspired by Intel Tools for UPnP.</property>
                   <object class="GtkScrolledWindow" id="event-scrolledwindow">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="vexpand">True</property>
                     <property name="shadow_type">in</property>
                     <child>
                       <object class="GtkTreeView" id="event-treeview">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <signal name="row-activated" handler="on_event_treeview_row_activate" swapped="no"/>
                         <signal name="button-release-event" handler="on_event_treeview_button_release" 
swapped="no"/>
+                        <signal name="row-activated" handler="on_event_treeview_row_activate" swapped="no"/>
                         <child internal-child="selection">
                           <object class="GtkTreeSelection" id="treeview-selection3"/>
                         </child>
@@ -671,9 +614,8 @@ Inspired by Intel Tools for UPnP.</property>
             </child>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
           </packing>
         </child>
       </object>
diff --git a/src/universal-cp/action-dialog.c b/src/universal-cp/action-dialog.c
index 74c22f0..cfef832 100644
--- a/src/universal-cp/action-dialog.c
+++ b/src/universal-cp/action-dialog.c
@@ -35,16 +35,14 @@
 #define DEFAULT_TEXTVIEW_HEIGHT 55
 
 static GtkWidget *dialog;
-static GtkWidget *in_args_table;
-static GtkWidget *out_args_table;
+static GtkWidget *in_args_grid;
+static GtkWidget *out_args_grid;
 static GtkWidget *device_label;
 static GtkWidget *service_label;
 static GtkWidget *action_label;
 static GtkWidget *in_args_expander;
 static GtkWidget *out_args_expander;
-static GtkSizeGroup *static_labels_group;
-static GtkSizeGroup *arguments_label_group;
-static GtkSizeGroup *arguments_widget_group;
+static GtkSizeGroup *label_group;
 
 static void
 on_expander_clicked (GObject    *expander,
@@ -57,58 +55,33 @@ on_expander_clicked (GObject    *expander,
 
 /*
  * 1. Gets rid of all the existing arguments
- * 2. resizes the table according to the number of new arguments
- * 3. Only show the label if there are any arguments
+ * 2. Only show the label if there are any arguments
  */
 static void
-prepare_action_arguments_table (GtkContainer                  *table,
-                                GUPnPServiceActionArgDirection direction,
-                                GList                         *arguments)
+prepare_action_arguments_grid (GtkContainer                  *grid,
+                               GUPnPServiceActionArgDirection direction,
+                               GList                         *arguments)
 {
-        GList     *child_node;
-        GtkWidget *label;
+        GList     *child_node, *children;
 
         /* reset expander state */
         gtk_expander_set_expanded (GTK_EXPANDER (in_args_expander),  TRUE);
         gtk_expander_set_expanded (GTK_EXPANDER (out_args_expander), FALSE);
 
-        for (child_node = gtk_container_get_children (table);
+        children = gtk_container_get_children (grid);
+        for (child_node = children;
              child_node;
              child_node = child_node->next) {
-                GtkWidget *widget;
-                gchar     *name;
-
-                widget = GTK_WIDGET (child_node->data);
-                name = g_object_get_data (G_OBJECT (widget),
-                                   "argument-name");
-                if (name)
-                        g_free (name);
-
-                if (GTK_IS_LABEL (widget)) {
-                        gtk_size_group_remove_widget (arguments_label_group,
-                                                      widget);
-                } else {
-                        gtk_size_group_remove_widget (arguments_widget_group,
-                                                      widget);
-                }
-
-                gtk_container_remove (table, widget);
+                gtk_widget_destroy (GTK_WIDGET (child_node->data));
         }
+        g_list_free (children);
 
         if (direction == GUPNP_SERVICE_ACTION_ARG_DIRECTION_IN) {
-                label = in_args_expander;
+                gtk_widget_set_visible (in_args_expander,
+                                        arguments != NULL);
         } else {
-                label = out_args_expander;
-        }
-
-        if (arguments) {
-                gtk_table_resize (GTK_TABLE (table),
-                                  g_list_length (arguments),
-                                  2);
-                gtk_widget_show (label);
-        } else {
-                /* No need to resize the table if it's not visible */
-                gtk_widget_hide (label);
+                gtk_widget_set_visible (out_args_expander,
+                                        arguments != NULL);
         }
 }
 
@@ -238,30 +211,30 @@ create_widget_for_argument (GUPnPServiceActionArgInfo *arg_info,
                 g_value_unset (&default_value);
         }
 
-        g_object_set_data (G_OBJECT (widget),
-                           "argument-name",
-                           g_strdup (arg_info->name));
+        g_object_set_data_full (G_OBJECT (widget),
+                                "argument-name",
+                                g_strdup (arg_info->name),
+                                g_free);
         return widget;
 }
 
 static void
-populate_action_arguments_table (GtkWidget                     *table,
-                                 GList                         *arguments,
-                                 GUPnPServiceActionArgDirection direction,
-                                 GUPnPServiceIntrospection     *introspection)
+populate_action_arguments_grid (GtkWidget                     *grid,
+                                GList                         *arguments,
+                                GUPnPServiceActionArgDirection direction,
+                                GUPnPServiceIntrospection     *introspection)
 {
         GList *arg_node;
-        guint row;
+        GtkWidget *last_label = NULL;
 
         g_assert (introspection != NULL);
 
-        prepare_action_arguments_table (GTK_CONTAINER (table),
-                                        direction,
-                                        arguments);
+        prepare_action_arguments_grid (GTK_CONTAINER (grid),
+                                       direction,
+                                       arguments);
 
         gtk_widget_set_size_request (dialog, 0, 0);
 
-        row = 0;
         for (arg_node = arguments;
              arg_node;
              arg_node = arg_node->next) {
@@ -273,39 +246,27 @@ populate_action_arguments_table (GtkWidget                     *table,
 
                 /* First add the name */
                 label = gtk_label_new (arg_info->name);
-                gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-                gtk_size_group_add_widget (arguments_label_group,
-                                           label);
-                gtk_table_attach (GTK_TABLE (table),
-                                  label,
-                                  0,
-                                  1,
-                                  row,
-                                  row + 1,
-                                  GTK_SHRINK,
-                                  GTK_EXPAND | GTK_FILL,
-                                  2,
-                                  2);
+                gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+                gtk_widget_set_halign (label, GTK_ALIGN_START);
+                gtk_grid_attach_next_to (GTK_GRID (grid),
+                                         label,
+                                         last_label,
+                                         GTK_POS_BOTTOM,
+                                         1, 1);
+                gtk_size_group_add_widget (label_group, label);
                 gtk_widget_show (label);
+                last_label = label;
 
                 /* Then the input widget */
                 input_widget = create_widget_for_argument (arg_info,
                                                            introspection);
-                gtk_size_group_add_widget (arguments_widget_group,
-                                           input_widget);
-                gtk_table_attach (GTK_TABLE (table),
-                                  input_widget,
-                                  1,
-                                  2,
-                                  row,
-                                  row + 1,
-                                  GTK_EXPAND | GTK_FILL,
-                                  GTK_EXPAND | GTK_FILL,
-                                  2,
-                                  2);
+                gtk_widget_set_hexpand (input_widget, TRUE);
+                gtk_grid_attach_next_to (GTK_GRID (grid),
+                                         input_widget,
+                                         label,
+                                         GTK_POS_RIGHT,
+                                         1,1);
                 gtk_widget_show_all (input_widget);
-
-                row += 1;
         }
 }
 
@@ -363,8 +324,8 @@ run_action_dialog (GUPnPServiceActionInfo    *action_info,
         in_arguments = find_arguments_by_direction (
                         action_info->arguments,
                         GUPNP_SERVICE_ACTION_ARG_DIRECTION_IN);
-        populate_action_arguments_table (
-                        in_args_table,
+        populate_action_arguments_grid (
+                        in_args_grid,
                         in_arguments,
                         GUPNP_SERVICE_ACTION_ARG_DIRECTION_IN,
                         introspection);
@@ -372,8 +333,8 @@ run_action_dialog (GUPnPServiceActionInfo    *action_info,
         out_arguments = find_arguments_by_direction (
                         action_info->arguments,
                         GUPNP_SERVICE_ACTION_ARG_DIRECTION_OUT);
-        populate_action_arguments_table (
-                        out_args_table,
+        populate_action_arguments_grid (
+                        out_args_grid,
                         out_arguments,
                         GUPNP_SERVICE_ACTION_ARG_DIRECTION_OUT,
                         introspection);
@@ -581,7 +542,7 @@ retrieve_in_action_arguments (GUPnPServiceIntrospection *introspection,
 {
         GList      *arg_node;
 
-        arg_node = gtk_container_get_children (GTK_CONTAINER (in_args_table));
+        arg_node = gtk_container_get_children (GTK_CONTAINER (in_args_grid));
 
         for (; arg_node; arg_node = arg_node->next) {
                 GtkWidget *arg_widget;
@@ -652,7 +613,7 @@ display_action_out_arguments (GHashTable *out_args)
         if (action_info == NULL)
                 return;
 
-        arg_node = gtk_container_get_children (GTK_CONTAINER (out_args_table));
+        arg_node = gtk_container_get_children (GTK_CONTAINER (out_args_grid));
 
         for (; arg_node; arg_node = arg_node->next) {
                 GtkWidget *arg_widget;
@@ -761,26 +722,22 @@ init_action_dialog (GtkBuilder *builder)
 {
         GtkWidget *image;
 
-        arguments_label_group =
-                gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-        arguments_widget_group =
-                gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-        static_labels_group =
+        label_group =
                 gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
-        /* Dialog box and tables */
+        /* Dialog box and grids */
         dialog = GTK_WIDGET (gtk_builder_get_object (
                                         builder,
                                         "action-invocation-dialog"));
         g_assert (dialog != NULL);
-        in_args_table = GTK_WIDGET (gtk_builder_get_object (
+        in_args_grid = GTK_WIDGET (gtk_builder_get_object (
                                         builder,
-                                        "in-action-arguments-table"));
-        g_assert (in_args_table != NULL);
-        out_args_table = GTK_WIDGET (gtk_builder_get_object (
+                                        "in-action-arguments-grid"));
+        g_assert (in_args_grid != NULL);
+        out_args_grid = GTK_WIDGET (gtk_builder_get_object (
                                         builder,
-                                        "out-action-arguments-table"));
-        g_assert (out_args_table != NULL);
+                                        "out-action-arguments-grid"));
+        g_assert (out_args_grid != NULL);
 
         /* All the labels */
         in_args_expander = GTK_WIDGET (gtk_builder_get_object (
@@ -794,15 +751,12 @@ init_action_dialog (GtkBuilder *builder)
         device_label = GTK_WIDGET (gtk_builder_get_object (builder,
                                                            "device-label"));
         g_assert (device_label != NULL);
-        gtk_size_group_add_widget (static_labels_group, device_label);
         service_label = GTK_WIDGET (gtk_builder_get_object (builder,
                                                             "service-label"));
         g_assert (service_label != NULL);
-        gtk_size_group_add_widget (static_labels_group, service_label);
         action_label = GTK_WIDGET (gtk_builder_get_object (builder,
                                                            "action-label"));
         g_assert (action_label != NULL);
-        gtk_size_group_add_widget (static_labels_group, action_label);
 
         /* the images */
         image = GTK_WIDGET (gtk_builder_get_object (builder, "device-image"));
@@ -834,6 +788,7 @@ init_action_dialog (GtkBuilder *builder)
 void
 deinit_action_dialog (void)
 {
+        g_object_unref (label_group);
         gtk_widget_destroy (dialog);
 }
 



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