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



commit d48f94b68dd0519ef79933e20affdc3982b106d7
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 72b531c14..40db8543a 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 2f8eeb63f..7ca35ca0b 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         *page);
 
diff --git a/libgnome-panel/gp-module-private.h b/libgnome-panel/gp-module-private.h
index c0c423d90..16f4f6efa 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 db4f1026c..03748fcb1 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]