[gnome-panel/wip/muktupavels/help-about: 5/5] libgnome-panel: add gp_applet_show_about



commit 4c7bc6b66585c95bff1ffdcf351ece26d0f1110c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Mar 31 20:18:46 2020 +0300

    libgnome-panel: add gp_applet_show_about

 libgnome-panel/gp-applet.c         | 18 ++++++++++++++++++
 libgnome-panel/gp-applet.h         |  2 ++
 libgnome-panel/gp-module-private.h |  4 ++++
 libgnome-panel/gp-module.c         | 20 ++++++++++++++++++++
 4 files changed, 44 insertions(+)
---
diff --git a/libgnome-panel/gp-applet.c b/libgnome-panel/gp-applet.c
index a992c4b1d..e0b8d11b0 100644
--- a/libgnome-panel/gp-applet.c
+++ b/libgnome-panel/gp-applet.c
@@ -1381,6 +1381,24 @@ gp_applet_get_menu_icon_size (GpApplet *applet)
   return priv->menu_icon_size;
 }
 
+/**
+ * gp_applet_show_about:
+ * @applet: a #GpApplet
+ *
+ * Show about dialog. #GpAboutDialogFunc must be set with
+ * gp_applet_info_set_about_dialog().
+ */
+void
+gp_applet_show_about (GpApplet *applet)
+{
+  GpAppletPrivate *priv;
+
+  g_return_if_fail (GP_IS_APPLET (applet));
+  priv = gp_applet_get_instance_private (applet);
+
+  gp_module_show_about (priv->module, NULL, priv->id);
+}
+
 /**
  * gp_applet_show_help:
  * @applet: a #GpApplet
diff --git a/libgnome-panel/gp-applet.h b/libgnome-panel/gp-applet.h
index 8b4513c05..5cd084b1d 100644
--- a/libgnome-panel/gp-applet.h
+++ b/libgnome-panel/gp-applet.h
@@ -121,6 +121,8 @@ guint            gp_applet_get_panel_icon_size       (GpApplet           *applet
 
 guint            gp_applet_get_menu_icon_size        (GpApplet           *applet);
 
+void             gp_applet_show_about                (GpApplet           *applet);
+
 void             gp_applet_show_help                 (GpApplet           *applet,
                                                       const char         *section);
 
diff --git a/libgnome-panel/gp-module-private.h b/libgnome-panel/gp-module-private.h
index ba8f47360..af1543354 100644
--- a/libgnome-panel/gp-module-private.h
+++ b/libgnome-panel/gp-module-private.h
@@ -59,6 +59,10 @@ GpApplet            *gp_module_applet_new             (GpModule     *module,
                                                        GVariant     *initial_settings,
                                                        GError      **error);
 
+void                gp_module_show_about              (GpModule     *module,
+                                                       GtkWindow    *parent,
+                                                       const char   *applet);
+
 void                gp_module_show_help               (GpModule     *module,
                                                        GtkWindow    *parent,
                                                        const char   *applet,
diff --git a/libgnome-panel/gp-module.c b/libgnome-panel/gp-module.c
index 64f21ab79..9b48c6e51 100644
--- a/libgnome-panel/gp-module.c
+++ b/libgnome-panel/gp-module.c
@@ -652,6 +652,26 @@ gp_module_applet_new (GpModule     *module,
                        NULL);
 }
 
+void
+gp_module_show_about (GpModule   *module,
+                      GtkWindow  *parent,
+                      const char *applet)
+{
+  GpAppletInfo *info;
+  GtkWidget *dialog;
+
+  info = get_applet_info (module, applet, NULL);
+  g_assert (info != NULL);
+
+  if (info->about_dialog_func == NULL)
+    return;
+
+  dialog = gtk_about_dialog_new ();
+
+  info->about_dialog_func (GTK_ABOUT_DIALOG (dialog));
+  gtk_window_present (GTK_WINDOW (dialog));
+}
+
 void
 gp_module_show_help (GpModule   *module,
                      GtkWindow  *parent,


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