[gnome-panel/wip/gnome-3.10+] update panel-test-applets



commit a2e69a763d0aa6baf9007d4d2a8c3daa69bcd7d3
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Aug 21 14:43:16 2014 +0300

    update panel-test-applets
    
    1) Update for new libpanel-applet version.
    2) Set default size for applet window.
    3) Open applet window on top of 'Test applet utility' window.

 gnome-panel/panel-test-applets.c  |   82 +++++++++--------------------------
 gnome-panel/panel-test-applets.ui |   86 ++++---------------------------------
 2 files changed, 29 insertions(+), 139 deletions(-)
---
diff --git a/gnome-panel/panel-test-applets.c b/gnome-panel/panel-test-applets.c
index 795b138..de1c2bf 100644
--- a/gnome-panel/panel-test-applets.c
+++ b/gnome-panel/panel-test-applets.c
@@ -22,19 +22,13 @@ G_GNUC_UNUSED void on_execute_button_clicked (GtkButton *button, gpointer dummy)
 
 static GtkWidget *win = NULL;
 static GtkWidget *applet_combo = NULL;
-static GtkWidget *prefs_dir_entry = NULL;
 static GtkWidget *orient_combo = NULL;
-static GtkWidget *size_combo = NULL;
 
 static char *cli_iid = NULL;
-static char *cli_prefs_dir = NULL;
-static char *cli_size = NULL;
 static char *cli_orient = NULL;
 
 static const GOptionEntry options [] = {
        { "iid", 0, 0, G_OPTION_ARG_STRING, &cli_iid, N_("Specify an applet IID to load"), NULL},
-       { "prefs-dir", 0, 0, G_OPTION_ARG_STRING, &cli_prefs_dir, N_("Specify a gconf location in which the 
applet preferences should be stored"), NULL},
-       { "size", 0, 0, G_OPTION_ARG_STRING, &cli_size, N_("Specify the initial size of the applet (xx-small, 
medium, large etc.)"), NULL},
        { "orient", 0, 0, G_OPTION_ARG_STRING, &cli_orient, N_("Specify the initial orientation of the applet 
(top, bottom, left or right)"), NULL},
        { NULL}
 };
@@ -57,17 +51,6 @@ static ComboItem orient_items [] = {
        { NC_("Orientation", "Right"),  PANEL_ORIENTATION_RIGHT  }
 };
 
-
-static ComboItem size_items [] = {
-       { NC_("Size", "XX Small"), 12  },
-       { NC_("Size", "X Small"),  24  },
-       { NC_("Size", "Small"),    36  },
-       { NC_("Size", "Medium"),   48  },
-       { NC_("Size", "Large"),    64  },
-       { NC_("Size", "X Large"),  80  },
-       { NC_("Size", "XX Large"), 128 }
-};
-
 static guint
 get_combo_value (GtkWidget *combo_box)
 {
@@ -135,20 +118,27 @@ applet_activated_cb (GObject      *source_object,
 
 static void
 load_applet_into_window (const char *title,
-                        const char *prefs_key,
-                        guint       size,
                         guint       orientation)
 {
+       GtkWidget       *box;
        GtkWidget       *container;
        GtkWidget       *applet_window;
        GVariantBuilder  builder;
 
-       container = panel_applet_container_new ();
-
        applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        //FIXME: we could set the window icon with the applet icon
        gtk_window_set_title (GTK_WINDOW (applet_window), title);
-       gtk_container_add (GTK_CONTAINER (applet_window), container);
+       gtk_window_set_transient_for (GTK_WINDOW (applet_window), GTK_WINDOW (win));
+       gtk_window_set_default_size (GTK_WINDOW (applet_window),
+                                    orientation & PANEL_HORIZONTAL_MASK ? 200 : 24,
+                                    orientation & PANEL_HORIZONTAL_MASK ? 24 : 200);
+
+       box = gtk_box_new (orientation & PANEL_HORIZONTAL_MASK ? GTK_ORIENTATION_HORIZONTAL : 
GTK_ORIENTATION_VERTICAL, 0);
+       gtk_container_add (GTK_CONTAINER (applet_window), box);
+       gtk_widget_show (box);
+
+       container = panel_applet_container_new ();
+       gtk_box_set_center_widget (GTK_BOX (box), container);
        gtk_widget_show (container);
 
        g_signal_connect (container, "applet-broken",
@@ -157,10 +147,6 @@ load_applet_into_window (const char *title,
 
        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
        g_variant_builder_add (&builder, "{sv}",
-                              "prefs-key", g_variant_new_string (prefs_key));
-       g_variant_builder_add (&builder, "{sv}",
-                              "size", g_variant_new_uint32 (size));
-       g_variant_builder_add (&builder, "{sv}",
                               "orient", g_variant_new_uint32 (orientation));
        panel_applet_container_add (PANEL_APPLET_CONTAINER (container),
                                    gtk_widget_get_screen (applet_window),
@@ -173,34 +159,23 @@ load_applet_into_window (const char *title,
 static void
 load_applet_from_command_line (void)
 {
-       guint size = 24, orient = PANEL_ORIENTATION_TOP;
+       guint orient = PANEL_ORIENTATION_TOP;
        gint i;
 
        g_assert (cli_iid != NULL);
 
-       if (cli_size || cli_orient) {
-               if (cli_size) {
-                       for (i = 0; i < G_N_ELEMENTS (size_items); i++) {
-                               if (strcmp (g_dpgettext2 (NULL, "Size", size_items[i].name), cli_size) == 0) {
-                                       size = size_items[i].value;
-                                       break;
-                               }
-                       }
-               }
-
-               if (cli_orient) {
-                       for (i = 0; i < G_N_ELEMENTS (orient_items); i++) {
-                               if (strcmp (g_dpgettext2 (NULL, "Orientation", orient_items[i].name), 
cli_orient) == 0) {
-                                       orient = orient_items[i].value;
-                                       break;
-                               }
+       if (cli_orient) {
+               for (i = 0; i < G_N_ELEMENTS (orient_items); i++) {
+                       if (strcmp (g_dpgettext2 (NULL, "Orientation", orient_items[i].name), cli_orient) == 
0) {
+                               orient = orient_items[i].value;
+                               break;
                        }
                }
        }
 
        g_print ("Loading %s\n", cli_iid);
 
-       load_applet_into_window (cli_iid, cli_prefs_dir, size, orient);
+       load_applet_into_window (cli_iid, orient);
 }
 
 G_GNUC_UNUSED void
@@ -211,10 +186,7 @@ on_execute_button_clicked (GtkButton *button,
 
        title = get_combo_applet_id (applet_combo);
 
-       load_applet_into_window (title,
-                                gtk_entry_get_text (GTK_ENTRY (prefs_dir_entry)),
-                                get_combo_value (size_combo),
-                                get_combo_value (orient_combo));
+       load_applet_into_window (title, get_combo_value (orient_combo));
        g_free (title);
 }
 
@@ -260,8 +232,6 @@ setup_options (void)
        PanelAppletsManager *manager;
        GList               *applet_list, *l;
        int                  i;
-       char                *prefs_dir;
-       char                *unique_key;
        GtkListStore        *model;
        GtkTreeIter          iter;
        GtkCellRenderer     *renderer;
@@ -295,16 +265,8 @@ setup_options (void)
 
        gtk_combo_box_set_active (GTK_COMBO_BOX (applet_combo), 0);
 
-       setup_combo (size_combo, size_items, "Size",
-                    G_N_ELEMENTS (size_items));
        setup_combo (orient_combo, orient_items, "Orientation",
                     G_N_ELEMENTS (orient_items));
-
-       unique_key = g_strdup ("unused");
-       prefs_dir = g_strdup_printf ("/tmp/%s", unique_key);
-       g_free (unique_key);
-       gtk_entry_set_text (GTK_ENTRY (prefs_dir_entry), prefs_dir);
-       g_free (prefs_dir);
 }
 
 int
@@ -357,12 +319,8 @@ main (int argc, char **argv)
                                                              "toplevel"));
        applet_combo    = GTK_WIDGET (gtk_builder_get_object (builder,
                                                              "applet-combo"));
-       prefs_dir_entry = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                             "prefs-dir-entry"));
        orient_combo    = GTK_WIDGET (gtk_builder_get_object (builder,
                                                              "orient-combo"));
-       size_combo      = GTK_WIDGET (gtk_builder_get_object (builder,
-                                                             "size-combo"));
        g_object_unref (builder);
 
        setup_options ();
diff --git a/gnome-panel/panel-test-applets.ui b/gnome-panel/panel-test-applets.ui
index e0d06fa..b31cc7b 100644
--- a/gnome-panel/panel-test-applets.ui
+++ b/gnome-panel/panel-test-applets.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.18.3 -->
 <interface>
-  <requires lib="gtk+" version="3.0"/>
+  <requires lib="gtk+" version="3.10"/>
   <object class="GtkDialog" id="toplevel">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -22,12 +22,11 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="ok-button">
-                <property name="label">gtk-execute</property>
+                <property name="label">Execute</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
                 <signal name="clicked" handler="on_execute_button_clicked" swapped="no"/>
               </object>
               <packing>
@@ -38,12 +37,11 @@
             </child>
             <child>
               <object class="GtkButton" id="button1">
-                <property name="label">gtk-close</property>
+                <property name="label" translatable="yes">Close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
                 <signal name="clicked" handler="gtk_main_quit" swapped="no"/>
               </object>
               <packing>
@@ -70,23 +68,6 @@
             <property name="row_spacing">4</property>
             <property name="column_spacing">8</property>
             <child>
-              <object class="GtkLabel" id="size-label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">_Size:</property>
-                <property name="use_underline">True</property>
-                <property name="justify">center</property>
-                <property name="mnemonic_widget">size-combo</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">4</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkLabel" id="applet-label">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -99,56 +80,17 @@
               <packing>
                 <property name="left_attach">0</property>
                 <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="prefs-dir-entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
               <object class="GtkComboBox" id="applet-combo">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
               </object>
               <packing>
                 <property name="left_attach">1</property>
                 <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="orient-combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="size-combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">4</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -160,7 +102,6 @@
                 <property name="left_attach">0</property>
                 <property name="top_attach">1</property>
                 <property name="width">2</property>
-                <property name="height">1</property>
               </packing>
             </child>
             <child>
@@ -171,30 +112,21 @@
                 <property name="label" translatable="yes">_Orientation:</property>
                 <property name="use_underline">True</property>
                 <property name="justify">center</property>
-                <property name="mnemonic_widget">orient-combo</property>
               </object>
               <packing>
                 <property name="left_attach">0</property>
-                <property name="top_attach">3</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="top_attach">2</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="prefs-label">
+              <object class="GtkComboBox" id="orient-combo">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">1</property>
-                <property name="label" translatable="yes">_Prefs Dir:</property>
-                <property name="use_underline">True</property>
-                <property name="justify">center</property>
-                <property name="mnemonic_widget">prefs-dir-entry</property>
+                <property name="hexpand">True</property>
               </object>
               <packing>
-                <property name="left_attach">0</property>
+                <property name="left_attach">1</property>
                 <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
               </packing>
             </child>
           </object>


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