[gnome-panel/wip-geiger-dialog: 51/54] properties-dialog: show list of applets



commit 015eb1edf633996cdfeef35daf98670334554798
Author: Sebastian Geiger <sbastig gmx net>
Date:   Mon Apr 13 21:02:40 2020 +0200

    properties-dialog: show list of applets

 gnome-panel/applet.c                |  2 +-
 gnome-panel/applet.h                |  2 ++
 gnome-panel/gp-properties-dialog.c  | 36 ++++++++++++++++++++++++++++++++++++
 gnome-panel/gp-properties-dialog.ui | 23 ++++++++++++++++++++---
 4 files changed, 59 insertions(+), 4 deletions(-)
---
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index 6c30930de..0e86df1b2 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -75,7 +75,7 @@ panel_applet_destroy (GtkWidget  *widget,
        g_free (info);
 }
 
-static const char *
+const char *
 panel_applet_get_toplevel_id (AppletInfo *applet)
 {
        PanelWidget *panel_widget;
diff --git a/gnome-panel/applet.h b/gnome-panel/applet.h
index 3237cbb4b..d0dd12e14 100644
--- a/gnome-panel/applet.h
+++ b/gnome-panel/applet.h
@@ -27,6 +27,8 @@ AppletInfo *panel_applet_register    (GtkWidget       *applet,
 
 const char *panel_applet_get_id           (AppletInfo      *info);
 
+const char *panel_applet_get_toplevel_id    (AppletInfo      *info);
+
 gboolean    panel_applet_activate_main_menu (guint32 activate_time);
 
 GSList     *panel_applet_list_applets (void);
diff --git a/gnome-panel/gp-properties-dialog.c b/gnome-panel/gp-properties-dialog.c
index d0f11ba50..0b0d203c1 100644
--- a/gnome-panel/gp-properties-dialog.c
+++ b/gnome-panel/gp-properties-dialog.c
@@ -20,6 +20,8 @@
 #include <glib/gi18n.h>
 
 #include "gp-properties-dialog.h"
+#include "panel-schemas.h"
+#include "applet.h"
 
 struct _GpPropertiesDialog
 {
@@ -55,6 +57,8 @@ struct _GpPropertiesDialog
   GtkWidget *custom_fg_color;
   GtkWidget *fg_color_box;
   GtkWidget *fg_color;
+
+  GtkWidget *applet_box;
 };
 
 enum
@@ -305,6 +309,35 @@ setup_theme_bindings (GpPropertiesDialog *dialog)
   bg_image_changed_cb (dialog->theme, "bg-image", dialog);
 }
 
+static void
+setup_applet_box (GpPropertiesDialog  *dialog)
+{
+  GSList * applets;
+  GSList * item;
+
+  applets = panel_applet_list_applets ();
+
+  for (item = applets; item; item = item->next)
+    {
+      AppletInfo *info = item->data;
+      const char * applet_toplevel_id;
+      GtkWidget *label;
+
+      applet_toplevel_id = panel_applet_get_toplevel_id (info);
+
+      if (g_strcmp0 (applet_toplevel_id, dialog->toplevel_id) != 0)
+        {
+          continue;
+        }
+
+      label = gtk_label_new (g_strdup_printf ("Applet Id: %s", info->id));
+
+      gtk_container_add (GTK_CONTAINER (dialog->applet_box), label);
+    }
+
+  gtk_widget_show_all(dialog->applet_box);
+}
+
 static gboolean
 all_keys_writable (GSettings    *settings,
                    const gchar **keys)
@@ -399,6 +432,7 @@ gp_properties_dialog_constructed (GObject *object)
 
   setup_writability (dialog);
   setup_bindings (dialog);
+  setup_applet_box (dialog);
 }
 
 static void
@@ -497,6 +531,8 @@ bind_template (GtkWidgetClass *widget_class)
   gtk_widget_class_bind_template_callback (widget_class, custom_fg_color_toggled_cb);
   gtk_widget_class_bind_template_child (widget_class, GpPropertiesDialog, fg_color_box);
   gtk_widget_class_bind_template_child (widget_class, GpPropertiesDialog, fg_color);
+
+  gtk_widget_class_bind_template_child (widget_class, GpPropertiesDialog, applet_box);
 }
 
 static void
diff --git a/gnome-panel/gp-properties-dialog.ui b/gnome-panel/gp-properties-dialog.ui
index e387787aa..53200c220 100644
--- a/gnome-panel/gp-properties-dialog.ui
+++ b/gnome-panel/gp-properties-dialog.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.22.2 -->
 <interface>
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkAdjustment" id="size">
@@ -17,6 +17,9 @@
     <property name="window_position">center</property>
     <property name="default_width">340</property>
     <property name="type_hint">dialog</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
     <child>
       <object class="GtkNotebook">
         <property name="visible">True</property>
@@ -612,10 +615,24 @@
           </packing>
         </child>
         <child>
-          <placeholder/>
+          <object class="GtkListBox" id="applet_box">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
         </child>
         <child type="tab">
-          <placeholder/>
+          <object class="GtkLabel">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Applets</property>
+          </object>
+          <packing>
+            <property name="position">2</property>
+            <property name="tab_fill">False</property>
+          </packing>
         </child>
       </object>
     </child>


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