[gnome-panel] menu: new module for menu applets



commit 6a10ec124d801fb0f918abc5a3fc1fe92fc3ba2f
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Jan 6 20:41:35 2018 +0200

    menu: new module for menu applets

 configure.ac                    |    6 +++
 modules/Makefile.am             |    1 +
 modules/menu/Makefile.am        |   43 ++++++++++++++++++++
 modules/menu/main-menu-applet.c |   36 +++++++++++++++++
 modules/menu/main-menu-applet.h |   31 ++++++++++++++
 modules/menu/menu-bar-applet.c  |   36 +++++++++++++++++
 modules/menu/menu-bar-applet.h  |   31 ++++++++++++++
 modules/menu/menu-module.c      |   83 +++++++++++++++++++++++++++++++++++++++
 modules/menu/user-menu-applet.c |   36 +++++++++++++++++
 modules/menu/user-menu-applet.h |   31 ++++++++++++++
 po/POTFILES.in                  |    1 +
 11 files changed, 335 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b59a6b9..c3e66d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,6 +155,11 @@ PKG_CHECK_MODULES(FISH, gtk+-3.0 >= $GTK_REQUIRED cairo >= $CAIRO_REQUIRED)
 AC_SUBST(FISH_CFLAGS)
 AC_SUBST(FISH_LIBS)
 
+PKG_CHECK_MODULES([MENU], [
+  gtk+-3.0 >= $GTK_REQUIRED
+  libgnome-menu-3.0 >= $LIBGNOME_MENU_REQUIRED
+])
+
 PKG_CHECK_MODULES([NOTIFICATION_AREA], [
   gtk+-3.0 >= $GTK_REQUIRED
   x11
@@ -282,6 +287,7 @@ AC_CONFIG_FILES([
   modules/clock/Makefile
   modules/clock/pixmaps/Makefile
   modules/fish/Makefile
+  modules/menu/Makefile
   modules/notification-area/Makefile
   modules/separator/Makefile
   modules/status-notifier/Makefile
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 0b9b43d..586caca 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -3,6 +3,7 @@ NULL =
 SUBDIRS = \
        clock \
        fish \
+       menu \
        notification-area \
        separator \
        status-notifier \
diff --git a/modules/menu/Makefile.am b/modules/menu/Makefile.am
new file mode 100644
index 0000000..b2a7942
--- /dev/null
+++ b/modules/menu/Makefile.am
@@ -0,0 +1,43 @@
+NULL =
+
+menu_libdir = $(libdir)/gnome-panel/modules
+menu_lib_LTLIBRARIES = menu.la
+
+menu_la_CPPFLAGS = \
+       -DLOCALEDIR=\""$(localedir)"\" \
+       -DG_LOG_DOMAIN=\""menu"\" \
+       -DG_LOG_USE_STRUCTURED=1 \
+       -I$(top_srcdir) \
+       $(AM_CPPFLAGS) \
+       $(NULL)
+
+menu_la_CFLAGS = \
+       $(LIBGNOME_PANEL_CFLAGS) \
+       $(MENU_CFLAGS) \
+       $(WARN_CFLAGS) \
+       $(AM_CFLAGS) \
+       $(NULL)
+
+menu_la_SOURCES = \
+       main-menu-applet.c \
+       main-menu-applet.h \
+       menu-bar-applet.c \
+       menu-bar-applet.h \
+       menu-module.c \
+       user-menu-applet.c \
+       user-menu-applet.h \
+       $(NULL)
+
+menu_la_LIBADD = \
+       $(top_builddir)/libgnome-panel/libgnome-panel.la \
+       $(LIBGNOME_PANEL_LIBS) \
+       $(MENU_LIBS) \
+       $(NULL)
+
+menu_la_LDFLAGS = \
+       -module -avoid-version \
+       $(WARN_LDFLAGS) \
+       $(AM_LDFLAGS) \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/modules/menu/main-menu-applet.c b/modules/menu/main-menu-applet.c
new file mode 100644
index 0000000..b6330f1
--- /dev/null
+++ b/modules/menu/main-menu-applet.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "main-menu-applet.h"
+
+struct _MainMenuApplet
+{
+  GpApplet parent;
+};
+
+G_DEFINE_TYPE (MainMenuApplet, main_menu_applet, GP_TYPE_APPLET)
+
+static void
+main_menu_applet_class_init (MainMenuAppletClass *main_menu_class)
+{
+}
+
+static void
+main_menu_applet_init (MainMenuApplet *main_menu)
+{
+}
diff --git a/modules/menu/main-menu-applet.h b/modules/menu/main-menu-applet.h
new file mode 100644
index 0000000..1d38743
--- /dev/null
+++ b/modules/menu/main-menu-applet.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAIN_MENU_APPLET_H
+#define MAIN_MENU_APPLET_H
+
+#include <libgnome-panel/gp-applet.h>
+
+G_BEGIN_DECLS
+
+#define MAIN_MENU_TYPE_APPLET (main_menu_applet_get_type ())
+G_DECLARE_FINAL_TYPE (MainMenuApplet, main_menu_applet,
+                      MAIN_MENU, APPLET, GpApplet)
+
+G_END_DECLS
+
+#endif
diff --git a/modules/menu/menu-bar-applet.c b/modules/menu/menu-bar-applet.c
new file mode 100644
index 0000000..99ebd87
--- /dev/null
+++ b/modules/menu/menu-bar-applet.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "menu-bar-applet.h"
+
+struct _MenuBarApplet
+{
+  GpApplet parent;
+};
+
+G_DEFINE_TYPE (MenuBarApplet, menu_bar_applet, GP_TYPE_APPLET)
+
+static void
+menu_bar_applet_class_init (MenuBarAppletClass *menu_bar_class)
+{
+}
+
+static void
+menu_bar_applet_init (MenuBarApplet *menu_bar)
+{
+}
diff --git a/modules/menu/menu-bar-applet.h b/modules/menu/menu-bar-applet.h
new file mode 100644
index 0000000..1ea1946
--- /dev/null
+++ b/modules/menu/menu-bar-applet.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MENU_BAR_APPLET_H
+#define 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)
+
+G_END_DECLS
+
+#endif
diff --git a/modules/menu/menu-module.c b/modules/menu/menu-module.c
new file mode 100644
index 0000000..05ae16e
--- /dev/null
+++ b/modules/menu/menu-module.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <libgnome-panel/gp-module.h>
+
+#include "main-menu-applet.h"
+#include "menu-bar-applet.h"
+#include "user-menu-applet.h"
+
+static GpAppletInfo *
+menu_get_applet_info (const gchar *id)
+{
+  GpGetAppletTypeFunc type_func;
+  const gchar *name;
+  const gchar *description;
+  const gchar *icon;
+  GpAppletInfo *info;
+
+  if (g_strcmp0 (id, "main-menu") == 0)
+    {
+      type_func = main_menu_applet_get_type;
+      name = _("Main Menu");
+      description = _("The main GNOME menu");
+      icon = "start-here";
+    }
+  else if (g_strcmp0 (id, "menu-bar") == 0)
+    {
+      type_func = 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;
+      name = _("User menu");
+      description = _("Menu to change your settings and log out");
+      icon = "computer";
+    }
+  else
+    {
+      g_assert_not_reached ();
+      return NULL;
+    }
+
+  info = gp_applet_info_new (type_func, name, description, icon);
+
+  return info;
+}
+
+void
+gp_module_load (GpModule *module)
+{
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  gp_module_set_gettext_domain (module, GETTEXT_PACKAGE);
+
+  gp_module_set_abi_version (module, GP_MODULE_ABI_VERSION);
+
+  gp_module_set_id (module, "org.gnome.gnome-panel.menu");
+  gp_module_set_version (module, PACKAGE_VERSION);
+
+  gp_module_set_applet_ids (module, "main-menu", "menu-bar", "user-menu", NULL);
+
+  gp_module_set_get_applet_info (module, menu_get_applet_info);
+}
diff --git a/modules/menu/user-menu-applet.c b/modules/menu/user-menu-applet.c
new file mode 100644
index 0000000..dff2490
--- /dev/null
+++ b/modules/menu/user-menu-applet.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "user-menu-applet.h"
+
+struct _UserMenuApplet
+{
+  GpApplet parent;
+};
+
+G_DEFINE_TYPE (UserMenuApplet, user_menu_applet, GP_TYPE_APPLET)
+
+static void
+user_menu_applet_class_init (UserMenuAppletClass *user_menu_class)
+{
+}
+
+static void
+user_menu_applet_init (UserMenuApplet *user_menu)
+{
+}
diff --git a/modules/menu/user-menu-applet.h b/modules/menu/user-menu-applet.h
new file mode 100644
index 0000000..639b419
--- /dev/null
+++ b/modules/menu/user-menu-applet.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef USER_MENU_APPLET_H
+#define 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)
+
+G_END_DECLS
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f081920..6dee977 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -59,6 +59,7 @@ modules/fish/fish-applet.c
 modules/fish/fish-module.c
 modules/fish/fish-menu.ui
 modules/fish/fish.ui
+modules/menu/menu-module.c
 modules/notification-area/na-applet.c
 modules/notification-area/na-module.c
 modules/notification-area/na-tray-manager.c


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