[gnome-panel] modules: add builtin library



commit 02d900dcebf7e8064fe2f24db01842a53bfc362d
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Dec 2 15:46:12 2016 +0200

    modules: add builtin library

 configure.ac                                       |    5 +++
 gnome-panel/libpanel-applet-private/Makefile.am    |    1 +
 .../libpanel-applet-private/gp-applet-manager.c    |   28 +++++++++++++++-
 modules/Makefile.am                                |    1 +
 modules/builtin/Makefile.am                        |   34 ++++++++++++++++++++
 modules/builtin/gp-builtin.c                       |   25 ++++++++++++++
 modules/builtin/gp-builtin.h                       |   29 +++++++++++++++++
 7 files changed, 121 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9fb1967..ecae31e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,6 +151,10 @@ PKG_CHECK_MODULES([LIBPANEL_APPLET], [
   x11
 ])
 
+PKG_CHECK_MODULES([BUILTIN], [
+  gio-2.0 >= $GLIB_REQUIRED
+])
+
 PKG_CHECK_MODULES(FISH, gtk+-3.0 >= $GTK_REQUIRED cairo >= $CAIRO_REQUIRED)
 AC_SUBST(FISH_CFLAGS)
 AC_SUBST(FISH_LIBS)
@@ -275,6 +279,7 @@ AC_CONFIG_FILES([
   man/Makefile
 
   modules/Makefile
+  modules/builtin/Makefile
   modules/external/Makefile
   modules/external/clock/Makefile
   modules/external/clock/pixmaps/Makefile
diff --git a/gnome-panel/libpanel-applet-private/Makefile.am b/gnome-panel/libpanel-applet-private/Makefile.am
index af39f36..0e94745 100644
--- a/gnome-panel/libpanel-applet-private/Makefile.am
+++ b/gnome-panel/libpanel-applet-private/Makefile.am
@@ -36,6 +36,7 @@ libpanel_applet_private_la_SOURCES =  \
 
 libpanel_applet_private_la_LIBADD = \
        $(top_builddir)/libgnome-panel/libgnome-panel.la \
+       $(top_builddir)/modules/builtin/libbuiltin.la \
        $(NULL)
 
 libpanel_applet_private_la_LDFLAGS = \
diff --git a/gnome-panel/libpanel-applet-private/gp-applet-manager.c 
b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
index d992e18..c9d7259 100644
--- a/gnome-panel/libpanel-applet-private/gp-applet-manager.c
+++ b/gnome-panel/libpanel-applet-private/gp-applet-manager.c
@@ -23,6 +23,7 @@
 #include "gp-applet-manager.h"
 #include "gp-module-private.h"
 #include "libgnome-panel/gp-applet-info-private.h"
+#include "modules/builtin/gp-builtin.h"
 
 struct _GpAppletManager
 {
@@ -73,7 +74,29 @@ get_applet_infos (GpAppletManager *manager,
 }
 
 static void
-load_modules (GpAppletManager *manager)
+load_builtin_modules (GpAppletManager *manager)
+{
+  guint i;
+
+  for (i = 0; builtin[i] != NULL; i++)
+    {
+      GpModule *module;
+      const gchar *id;
+
+      module = gp_module_new_from_vtable (builtin[i]);
+
+      if (module == NULL)
+        continue;
+
+      id = gp_module_get_id (module);
+
+      g_hash_table_insert (manager->modules, g_strdup (id), module);
+      get_applet_infos (manager, id, module);
+    }
+}
+
+static void
+load_external_modules (GpAppletManager *manager)
 {
   GDir *dir;
   const gchar *name;
@@ -339,5 +362,6 @@ gp_applet_manager_init (GpAppletManager *manager)
   manager->infos = g_hash_table_new_full (g_str_hash, g_str_equal,
                                           g_free, applet_info_free);
 
-  load_modules (manager);
+  load_builtin_modules (manager);
+  load_external_modules (manager);
 }
diff --git a/modules/Makefile.am b/modules/Makefile.am
index c8349e0..8a311df 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -1,6 +1,7 @@
 NULL =
 
 SUBDIRS = \
+       builtin \
        external \
        $(NULL)
 
diff --git a/modules/builtin/Makefile.am b/modules/builtin/Makefile.am
new file mode 100644
index 0000000..d90562b
--- /dev/null
+++ b/modules/builtin/Makefile.am
@@ -0,0 +1,34 @@
+NULL =
+
+noinst_LTLIBRARIES = libbuiltin.la
+
+libbuiltin_la_SOURCES = \
+       gp-builtin.c \
+       gp-builtin.h \
+       $(NULL)
+
+libbuiltin_la_CPPFLAGS = \
+       -DG_LOG_DOMAIN=\"libbuiltin\" \
+       -DG_LOG_USE_STRUCTURED=1 \
+       -I$(top_srcdir) \
+       $(AM_CPPFLAGS) \
+       $(NULL)
+
+libbuiltin_la_CFLAGS = \
+       $(LIBGNOME_PANEL_CFLAGS) \
+       $(BUILTIN_CFLAGS) \
+       $(AM_CFLAGS) \
+       $(NULL)
+
+libbuiltin_la_LDFLAGS = \
+       $(WARN_LDFLAGS) \
+       $(AM_LDFLAGS) \
+       $(NULL)
+
+libbuiltin_la_LIBADD = \
+       $(top_builddir)/libgnome-panel/libgnome-panel.la \
+       $(LIBGNOME_PANEL_LIBS) \
+       $(BUILTIN_LIBS) \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/modules/builtin/gp-builtin.c b/modules/builtin/gp-builtin.c
new file mode 100644
index 0000000..e239903
--- /dev/null
+++ b/modules/builtin/gp-builtin.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2016 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 "gp-builtin.h"
+
+const GpModuleVTable *builtin[] =
+{
+  NULL
+};
diff --git a/modules/builtin/gp-builtin.h b/modules/builtin/gp-builtin.h
new file mode 100644
index 0000000..4796d86
--- /dev/null
+++ b/modules/builtin/gp-builtin.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2016 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 GP_BUILTIN_H
+#define GP_BUILTIN_H
+
+#include <libgnome-panel/gp-module.h>
+
+G_BEGIN_DECLS
+
+extern const GpModuleVTable *builtin[];
+
+G_END_DECLS
+
+#endif


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