[gnome-panel] menu: add empty menu bar to applets



commit 1bbc88e6f81c198341dcc38d98e2f5199393a60a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Jan 22 17:08:24 2018 +0200

    menu: add empty menu bar to applets

 modules/menu/gp-menu-bar-applet.c  |   46 ++++++++++++++++++++++++++++++++----
 modules/menu/gp-menu-bar-applet.h  |   10 ++++----
 modules/menu/gp-menu-module.c      |    4 +-
 modules/menu/gp-user-menu-applet.c |   46 ++++++++++++++++++++++++++++++++----
 modules/menu/gp-user-menu-applet.h |   10 ++++----
 5 files changed, 94 insertions(+), 22 deletions(-)
---
diff --git a/modules/menu/gp-menu-bar-applet.c b/modules/menu/gp-menu-bar-applet.c
index 2e084d8..774e6cd 100644
--- a/modules/menu/gp-menu-bar-applet.c
+++ b/modules/menu/gp-menu-bar-applet.c
@@ -17,20 +17,56 @@
 
 #include "config.h"
 #include "gp-menu-bar-applet.h"
+#include "gp-menu-bar.h"
 
-struct _MenuBarApplet
+struct _GpMenuBarApplet
 {
-  GpApplet parent;
+  GpApplet   parent;
+
+  GtkWidget *menu_bar;
 };
 
-G_DEFINE_TYPE (MenuBarApplet, menu_bar_applet, GP_TYPE_APPLET)
+G_DEFINE_TYPE (GpMenuBarApplet, gp_menu_bar_applet, GP_TYPE_APPLET)
+
+static void
+gp_menu_bar_applet_setup (GpMenuBarApplet *menu_bar)
+{
+  menu_bar->menu_bar = gp_menu_bar_new ();
+  gtk_container_add (GTK_CONTAINER (menu_bar), menu_bar->menu_bar);
+  gtk_widget_show (menu_bar->menu_bar);
+
+  g_object_bind_property (menu_bar, "enable-tooltips",
+                          menu_bar->menu_bar, "enable-tooltips",
+                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+
+  g_object_bind_property (menu_bar, "position",
+                          menu_bar->menu_bar, "position",
+                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+}
 
 static void
-menu_bar_applet_class_init (MenuBarAppletClass *menu_bar_class)
+gp_menu_bar_applet_constructed (GObject *object)
 {
+  G_OBJECT_CLASS (gp_menu_bar_applet_parent_class)->constructed (object);
+  gp_menu_bar_applet_setup (GP_MENU_BAR_APPLET (object));
 }
 
 static void
-menu_bar_applet_init (MenuBarApplet *menu_bar)
+gp_menu_bar_applet_class_init (GpMenuBarAppletClass *menu_bar_class)
 {
+  GObjectClass *object_class;
+
+  object_class = G_OBJECT_CLASS (menu_bar_class);
+
+  object_class->constructed = gp_menu_bar_applet_constructed;
+}
+
+static void
+gp_menu_bar_applet_init (GpMenuBarApplet *menu_bar)
+{
+  GpApplet *applet;
+
+  applet = GP_APPLET (menu_bar);
+
+  gp_applet_set_flags (applet, GP_APPLET_FLAGS_EXPAND_MINOR);
 }
diff --git a/modules/menu/gp-menu-bar-applet.h b/modules/menu/gp-menu-bar-applet.h
index 1ea1946..6b2ae26 100644
--- a/modules/menu/gp-menu-bar-applet.h
+++ b/modules/menu/gp-menu-bar-applet.h
@@ -15,16 +15,16 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef MENU_BAR_APPLET_H
-#define MENU_BAR_APPLET_H
+#ifndef GP_MENU_BAR_APPLET_H
+#define GP_MENU_BAR_APPLET_H
 
 #include <libgnome-panel/gp-applet.h>
 
 G_BEGIN_DECLS
 
-#define MENU_BAR_TYPE_APPLET (menu_bar_applet_get_type ())
-G_DECLARE_FINAL_TYPE (MenuBarApplet, menu_bar_applet,
-                      MENU_BAR, APPLET, GpApplet)
+#define GP_MENU_BAR_TYPE_APPLET (gp_menu_bar_applet_get_type ())
+G_DECLARE_FINAL_TYPE (GpMenuBarApplet, gp_menu_bar_applet,
+                      GP, MENU_BAR_APPLET, GpApplet)
 
 G_END_DECLS
 
diff --git a/modules/menu/gp-menu-module.c b/modules/menu/gp-menu-module.c
index 3fab0d7..ebf46b7 100644
--- a/modules/menu/gp-menu-module.c
+++ b/modules/menu/gp-menu-module.c
@@ -42,14 +42,14 @@ menu_get_applet_info (const gchar *id)
     }
   else if (g_strcmp0 (id, "menu-bar") == 0)
     {
-      type_func = menu_bar_applet_get_type;
+      type_func = gp_menu_bar_applet_get_type;
       name = _("Menu Bar");
       description = _("A custom menu bar");
       icon = "start-here";
     }
   else if (g_strcmp0 (id, "user-menu") == 0)
     {
-      type_func = user_menu_applet_get_type;
+      type_func = gp_user_menu_applet_get_type;
       name = _("User menu");
       description = _("Menu to change your settings and log out");
       icon = "computer";
diff --git a/modules/menu/gp-user-menu-applet.c b/modules/menu/gp-user-menu-applet.c
index ceb85ed..2f6babc 100644
--- a/modules/menu/gp-user-menu-applet.c
+++ b/modules/menu/gp-user-menu-applet.c
@@ -16,21 +16,57 @@
  */
 
 #include "config.h"
+#include "gp-menu-bar.h"
 #include "gp-user-menu-applet.h"
 
-struct _UserMenuApplet
+struct _GpUserMenuApplet
 {
-  GpApplet parent;
+  GpApplet   parent;
+
+  GtkWidget *menu_bar;
 };
 
-G_DEFINE_TYPE (UserMenuApplet, user_menu_applet, GP_TYPE_APPLET)
+G_DEFINE_TYPE (GpUserMenuApplet, gp_user_menu_applet, GP_TYPE_APPLET)
+
+static void
+gp_user_menu_applet_setup (GpUserMenuApplet *user_menu)
+{
+  user_menu->menu_bar = gp_menu_bar_new ();
+  gtk_container_add (GTK_CONTAINER (user_menu), user_menu->menu_bar);
+  gtk_widget_show (user_menu->menu_bar);
+
+  g_object_bind_property (user_menu, "enable-tooltips",
+                          user_menu->menu_bar, "enable-tooltips",
+                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+
+  g_object_bind_property (user_menu, "position",
+                          user_menu->menu_bar, "position",
+                          G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
+}
 
 static void
-user_menu_applet_class_init (UserMenuAppletClass *user_menu_class)
+gp_user_menu_applet_constructed (GObject *object)
 {
+  G_OBJECT_CLASS (gp_user_menu_applet_parent_class)->constructed (object);
+  gp_user_menu_applet_setup (GP_USER_MENU_APPLET (object));
 }
 
 static void
-user_menu_applet_init (UserMenuApplet *user_menu)
+gp_user_menu_applet_class_init (GpUserMenuAppletClass *user_menu_class)
 {
+  GObjectClass *object_class;
+
+  object_class = G_OBJECT_CLASS (user_menu_class);
+
+  object_class->constructed = gp_user_menu_applet_constructed;
+}
+
+static void
+gp_user_menu_applet_init (GpUserMenuApplet *user_menu)
+{
+  GpApplet *applet;
+
+  applet = GP_APPLET (user_menu);
+
+  gp_applet_set_flags (applet, GP_APPLET_FLAGS_EXPAND_MINOR);
 }
diff --git a/modules/menu/gp-user-menu-applet.h b/modules/menu/gp-user-menu-applet.h
index 639b419..d86786c 100644
--- a/modules/menu/gp-user-menu-applet.h
+++ b/modules/menu/gp-user-menu-applet.h
@@ -15,16 +15,16 @@
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef USER_MENU_APPLET_H
-#define USER_MENU_APPLET_H
+#ifndef GP_USER_MENU_APPLET_H
+#define GP_USER_MENU_APPLET_H
 
 #include <libgnome-panel/gp-applet.h>
 
 G_BEGIN_DECLS
 
-#define USER_MENU_TYPE_APPLET (user_menu_applet_get_type ())
-G_DECLARE_FINAL_TYPE (UserMenuApplet, user_menu_applet,
-                      USER_MENU, APPLET, GpApplet)
+#define GP_USER_MENU_TYPE_APPLET (gp_user_menu_applet_get_type ())
+G_DECLARE_FINAL_TYPE (GpUserMenuApplet, gp_user_menu_applet,
+                      GP, USER_MENU_APPLET, GpApplet)
 
 G_END_DECLS
 


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