[gnome-panel] panel-separator: convert to builtin module



commit 67c3fa4b2e63206224856f70d0cf44718c4b95ae
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Fri Dec 2 17:11:41 2016 +0200

    panel-separator: convert to builtin module

 configure.ac                                 |    5 +
 gnome-panel/Makefile.am                      |    2 -
 gnome-panel/applet.c                         |    3 -
 gnome-panel/panel-addto-dialog.c             |   16 --
 gnome-panel/panel-enums.h                    |    1 -
 gnome-panel/panel-icon-names.h               |    1 -
 gnome-panel/panel-object-loader.c            |    7 -
 gnome-panel/panel-separator.c                |  295 --------------------------
 gnome-panel/panel-separator.h                |   64 ------
 gnome-panel/panel.c                          |   14 --
 modules/builtin/Makefile.am                  |    5 +
 modules/builtin/gp-builtin.c                 |    2 +
 modules/builtin/separator/Makefile.am        |   38 ++++
 modules/builtin/separator/separator-applet.c |   79 +++++++
 modules/builtin/separator/separator-applet.h |   31 +++
 modules/builtin/separator/separator-module.c |   71 ++++++
 modules/builtin/separator/separator-module.h |   29 +++
 po/POTFILES.in                               |    2 +-
 18 files changed, 261 insertions(+), 404 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ecae31e..270dd4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,6 +164,10 @@ PKG_CHECK_MODULES([NOTIFICATION_AREA], [
   x11
 ])
 
+PKG_CHECK_MODULES([SEPARATOR], [
+  gtk+-3.0 >= $GTK_REQUIRED
+])
+
 PKG_CHECK_MODULES([STATUS_NOTIFIER], [
   gtk+-3.0 >= $GTK_REQUIRED
 ])
@@ -280,6 +284,7 @@ AC_CONFIG_FILES([
 
   modules/Makefile
   modules/builtin/Makefile
+  modules/builtin/separator/Makefile
   modules/external/Makefile
   modules/external/clock/Makefile
   modules/external/clock/pixmaps/Makefile
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 6cc10d2..0c195d1 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -39,7 +39,6 @@ panel_sources =                       \
        panel-menu-bar-object.c \
        panel-menu-button.c     \
        panel-menu-items.c      \
-       panel-separator.c       \
        panel-recent.c          \
        panel-action-protocol.c \
        panel-toplevel.c        \
@@ -81,7 +80,6 @@ panel_headers =                       \
        panel-menu-bar-object.h \
        panel-menu-button.h     \
        panel-menu-items.h      \
-       panel-separator.h       \
        panel-recent.h          \
        panel-action-protocol.h \
        panel-toplevel.h        \
diff --git a/gnome-panel/applet.c b/gnome-panel/applet.c
index b29f20c..171550a 100644
--- a/gnome-panel/applet.c
+++ b/gnome-panel/applet.c
@@ -24,7 +24,6 @@
 #include "panel-applet-frame.h"
 #include "panel-action-button.h"
 #include "panel-menu-bar.h"
-#include "panel-separator.h"
 #include "panel-toplevel.h"
 #include "panel-util.h"
 #include "panel-menu-button.h"
@@ -66,7 +65,6 @@ panel_applet_set_dnd_enabled (AppletInfo *info,
                                                     dnd_enabled);
                break;
        case PANEL_OBJECT_MENU_BAR:
-       case PANEL_OBJECT_SEPARATOR:
        case PANEL_OBJECT_USER_MENU:
                break;
        default:
@@ -192,7 +190,6 @@ applet_callback_callback (GtkWidget      *widget,
                 * Applet's menu's are handled differently
                 */
                break;
-       case PANEL_OBJECT_SEPARATOR:
        case PANEL_OBJECT_USER_MENU:
                break;
        default:
diff --git a/gnome-panel/panel-addto-dialog.c b/gnome-panel/panel-addto-dialog.c
index 733deed..e6b103d 100644
--- a/gnome-panel/panel-addto-dialog.c
+++ b/gnome-panel/panel-addto-dialog.c
@@ -36,7 +36,6 @@
 #include "panel-applet-frame.h"
 #include "panel-action-button.h"
 #include "panel-menu-bar.h"
-#include "panel-separator.h"
 #include "panel-toplevel.h"
 #include "panel-menu-button.h"
 #include "panel-globals.h"
@@ -90,7 +89,6 @@ typedef enum {
        PANEL_ADDTO_LAUNCHER_NEW,
        PANEL_ADDTO_MENU,
        PANEL_ADDTO_MENUBAR,
-       PANEL_ADDTO_SEPARATOR,
        PANEL_ADDTO_USER_MENU
 } PanelAddtoItemType;
 
@@ -156,15 +154,6 @@ prepend_internal_applets (GSList *list)
        list = g_slist_prepend (list, internal);
 
        internal = g_new0 (PanelAddtoItemInfo, 1);
-       internal->type = PANEL_ADDTO_SEPARATOR;
-       internal->name = g_strdup (_("Separator"));
-       internal->description = g_strdup (_("A separator to organize the panel items"));
-       internal->icon = g_themed_icon_new (PANEL_ICON_SEPARATOR);
-       internal->action_type = PANEL_ACTION_NONE;
-       internal->iid = g_strdup ("SEPARATOR:NEW");
-       list = g_slist_prepend (list, internal);
-
-       internal = g_new0 (PanelAddtoItemInfo, 1);
        internal->type = PANEL_ADDTO_USER_MENU;
        internal->name = g_strdup (_("User menu"));
        internal->description = g_strdup (_("Menu to change your settings and log out"));
@@ -768,11 +757,6 @@ panel_addto_add_item (PanelAddtoDialog   *dialog,
                                       dialog->insert_pack_type,
                                       pack_index);
                break;
-       case PANEL_ADDTO_SEPARATOR:
-               panel_separator_create (dialog->panel_widget->toplevel,
-                                       dialog->insert_pack_type,
-                                       pack_index);
-               break;
        case PANEL_ADDTO_USER_MENU:
                panel_user_menu_create (dialog->panel_widget->toplevel,
                                        dialog->insert_pack_type,
diff --git a/gnome-panel/panel-enums.h b/gnome-panel/panel-enums.h
index 768239d..39a0b03 100644
--- a/gnome-panel/panel-enums.h
+++ b/gnome-panel/panel-enums.h
@@ -46,7 +46,6 @@ typedef enum {
        PANEL_OBJECT_APPLET,
        PANEL_OBJECT_ACTION,
        PANEL_OBJECT_MENU_BAR,
-       PANEL_OBJECT_SEPARATOR,
        PANEL_OBJECT_USER_MENU
 } PanelObjectType;
 
diff --git a/gnome-panel/panel-icon-names.h b/gnome-panel/panel-icon-names.h
index f77411c..a07a180 100644
--- a/gnome-panel/panel-icon-names.h
+++ b/gnome-panel/panel-icon-names.h
@@ -30,7 +30,6 @@
 #define PANEL_ICON_REMOTE              "applications-internet"
 #define PANEL_ICON_REMOVABLE_MEDIA     "drive-removable-media"
 #define PANEL_ICON_RUN                 "system-run"
-#define PANEL_ICON_SEPARATOR           "gnome-panel-separator"
 #define PANEL_ICON_SAVED_SEARCH                "folder-saved-search"
 #define PANEL_ICON_SEARCHTOOL          "system-search"
 #define PANEL_ICON_SHUTDOWN            "system-shutdown"
diff --git a/gnome-panel/panel-object-loader.c b/gnome-panel/panel-object-loader.c
index c085806..eda33ca 100644
--- a/gnome-panel/panel-object-loader.c
+++ b/gnome-panel/panel-object-loader.c
@@ -41,7 +41,6 @@
 #include "panel-applet-frame.h"
 #include "panel-menu-bar.h"
 #include "panel-menu-button.h"
-#include "panel-separator.h"
 #include "panel-user-menu.h"
 
 #include "panel-object-loader.h"
@@ -225,11 +224,6 @@ panel_object_loader_idle_handler (gpointer dummy)
                                      object->id,
                                      object->settings);
                 break;
-        case PANEL_OBJECT_SEPARATOR:
-                panel_separator_load (panel_widget,
-                                      object->id,
-                                      object->settings);
-                break;
         case PANEL_OBJECT_USER_MENU:
                 panel_user_menu_load (panel_widget,
                                       object->id,
@@ -373,7 +367,6 @@ static struct {
         { PANEL_OBJECT_MENU_BAR,  "MenuBar"      , FALSE },
         { PANEL_OBJECT_MENU,      "MenuButton"   , FALSE },
         { PANEL_OBJECT_LAUNCHER,  "Launcher"     , FALSE },
-        { PANEL_OBJECT_SEPARATOR, "Separator"    , FALSE },
         { PANEL_OBJECT_USER_MENU, "UserMenu"     , FALSE }
 };
 
diff --git a/gnome-panel/panel.c b/gnome-panel/panel.c
index ec436b4..075516c 100644
--- a/gnome-panel/panel.c
+++ b/gnome-panel/panel.c
@@ -33,7 +33,6 @@
 #include "panel-applet-frame.h"
 #include "panel-action-button.h"
 #include "panel-menu-bar.h"
-#include "panel-separator.h"
 #include "panel-multiscreen.h"
 #include "panel-toplevel.h"
 #include "panel-menu-button.h"
@@ -81,10 +80,6 @@ orientation_change (AppletInfo  *info,
        case PANEL_OBJECT_USER_MENU:
                panel_menu_bar_object_set_orientation (PANEL_MENU_BAR_OBJECT (info->widget), orientation);
                break;
-       case PANEL_OBJECT_SEPARATOR:
-               panel_separator_set_orientation (PANEL_SEPARATOR (info->widget),
-                                                orientation);
-               break;
        default:
                break;
        }
@@ -868,15 +863,6 @@ drop_internal_applet (PanelWidget         *panel,
                        success = FALSE;
                }
 
-       } else if (!strcmp(applet_type,"SEPARATOR:NEW")) {
-               if (panel_layout_is_writable ()) {
-                       panel_separator_create (panel->toplevel,
-                                               pack_type, pack_index);
-                       success = TRUE;
-               } else {
-                       success = FALSE;
-               }
-
        } else if (!strcmp (applet_type, "USERMENU:NEW")) {
                if (panel_layout_is_writable ()) {
                        panel_user_menu_create (panel->toplevel,
diff --git a/modules/builtin/Makefile.am b/modules/builtin/Makefile.am
index d90562b..edfa45d 100644
--- a/modules/builtin/Makefile.am
+++ b/modules/builtin/Makefile.am
@@ -1,5 +1,9 @@
 NULL =
 
+SUBDIRS = \
+       separator \
+       $(NULL)
+
 noinst_LTLIBRARIES = libbuiltin.la
 
 libbuiltin_la_SOURCES = \
@@ -27,6 +31,7 @@ libbuiltin_la_LDFLAGS = \
 
 libbuiltin_la_LIBADD = \
        $(top_builddir)/libgnome-panel/libgnome-panel.la \
+       $(top_builddir)/modules/builtin/separator/libseparator.la \
        $(LIBGNOME_PANEL_LIBS) \
        $(BUILTIN_LIBS) \
        $(NULL)
diff --git a/modules/builtin/gp-builtin.c b/modules/builtin/gp-builtin.c
index e239903..97af82e 100644
--- a/modules/builtin/gp-builtin.c
+++ b/modules/builtin/gp-builtin.c
@@ -18,8 +18,10 @@
 #include "config.h"
 
 #include "gp-builtin.h"
+#include "separator/separator-module.h"
 
 const GpModuleVTable *builtin[] =
 {
+  &separator_vtable,
   NULL
 };
diff --git a/modules/builtin/separator/Makefile.am b/modules/builtin/separator/Makefile.am
new file mode 100644
index 0000000..fd9c8ba
--- /dev/null
+++ b/modules/builtin/separator/Makefile.am
@@ -0,0 +1,38 @@
+NULL =
+
+noinst_LTLIBRARIES = libseparator.la
+
+libseparator_la_CPPFLAGS = \
+       -DLOCALEDIR=\""$(localedir)"\" \
+       -DG_LOG_DOMAIN=\""separator"\" \
+       -DG_LOG_USE_STRUCTURED=1 \
+       -I$(top_srcdir) \
+       $(AM_CPPFLAGS) \
+       $(NULL)
+
+libseparator_la_CFLAGS = \
+       $(LIBGNOME_PANEL_CFLAGS) \
+       $(SEPARATOR_CFLAGS) \
+       $(WARN_CFLAGS) \
+       $(AM_CFLAGS) \
+       $(NULL)
+
+libseparator_la_SOURCES = \
+       separator-applet.c \
+       separator-applet.h \
+       separator-module.c \
+       separator-module.h \
+       $(NULL)
+
+libseparator_la_LIBADD = \
+       $(top_builddir)/libgnome-panel/libgnome-panel.la \
+       $(LIBGNOME_PANEL_LIBS) \
+       $(SEPARATOR_LIBS) \
+       $(NULL)
+
+libseparator_la_LDFLAGS = \
+       $(WARN_LDFLAGS) \
+       $(AM_LDFLAGS) \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/modules/builtin/separator/separator-applet.c b/modules/builtin/separator/separator-applet.c
new file mode 100644
index 0000000..b22d2ed
--- /dev/null
+++ b/modules/builtin/separator/separator-applet.c
@@ -0,0 +1,79 @@
+/*
+ * 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 "separator-applet.h"
+
+struct _SeparatorApplet
+{
+  GpApplet   parent;
+
+  GtkWidget *separator;
+};
+
+G_DEFINE_TYPE (SeparatorApplet, separator_applet, GP_TYPE_APPLET)
+
+static void
+separator_applet_placement_changed (GpApplet        *applet,
+                                    GtkOrientation   orientation,
+                                    GtkPositionType  position)
+{
+  SeparatorApplet *separator;
+  GtkOrientable *orientable;
+
+  separator = SEPARATOR_APPLET (applet);
+  orientable = GTK_ORIENTABLE (separator->separator);
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    gtk_orientable_set_orientation (orientable, GTK_ORIENTATION_VERTICAL);
+  else
+    gtk_orientable_set_orientation (orientable, GTK_ORIENTATION_HORIZONTAL);
+}
+
+static void
+separator_applet_class_init (SeparatorAppletClass *separator_class)
+{
+  GpAppletClass *applet_class;
+
+  applet_class = GP_APPLET_CLASS (separator_class);
+
+  applet_class->placement_changed = separator_applet_placement_changed;
+}
+
+static void
+separator_applet_init (SeparatorApplet *separator)
+{
+  GpApplet *applet;
+  GpAppletFlags flags;
+  GtkOrientation orientation;
+
+  applet = GP_APPLET (separator);
+
+  flags = GP_APPLET_FLAGS_EXPAND_MINOR;
+  orientation = gp_applet_get_orientation (applet);
+
+  gp_applet_set_flags (applet, flags);
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    separator->separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
+  else
+    separator->separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+
+  gtk_container_add (GTK_CONTAINER (separator), separator->separator);
+  gtk_widget_show (separator->separator);
+}
diff --git a/modules/builtin/separator/separator-applet.h b/modules/builtin/separator/separator-applet.h
new file mode 100644
index 0000000..9b6f2df
--- /dev/null
+++ b/modules/builtin/separator/separator-applet.h
@@ -0,0 +1,31 @@
+/*
+ * 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 SEPARATOR_APPLET_H
+#define SEPARATOR_APPLET_H
+
+#include <libgnome-panel/gp-applet.h>
+
+G_BEGIN_DECLS
+
+#define SEPARATOR_TYPE_APPLET separator_applet_get_type ()
+G_DECLARE_FINAL_TYPE (SeparatorApplet, separator_applet,
+                      SEPARATOR, APPLET, GpApplet)
+
+G_END_DECLS
+
+#endif
diff --git a/modules/builtin/separator/separator-module.c b/modules/builtin/separator/separator-module.c
new file mode 100644
index 0000000..80433e2
--- /dev/null
+++ b/modules/builtin/separator/separator-module.c
@@ -0,0 +1,71 @@
+/*
+ * 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 <glib/gi18n-lib.h>
+#include <libgnome-panel/gp-module.h>
+
+#include "separator-applet.h"
+
+static GpModuleInfo *
+separator_get_module_info (void)
+{
+  GpModuleInfo *info;
+
+  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+  info = gp_module_info_new ("separator", PACKAGE_VERSION);
+
+  gp_module_info_set_applets (info, "separator", NULL);
+  gp_module_info_set_translation_domain (info, GETTEXT_PACKAGE);
+
+  return info;
+}
+
+static GpAppletInfo *
+separator_get_applet_info (const gchar *applet)
+{
+  return gp_applet_info_new (_("Separator"),
+                             _("A separator to organize the panel items"),
+                             "gnome-panel-separator");
+}
+
+static GType
+separator_get_applet_type (const gchar *applet)
+{
+  return SEPARATOR_TYPE_APPLET;
+}
+
+static const gchar *
+separator_get_applet_from_iid (const gchar *iid)
+{
+  if (g_strcmp0 (iid, "PanelInternalFactory::Separator") == 0)
+    return "separator";
+
+  return NULL;
+}
+
+const GpModuleVTable separator_vtable =
+{
+  separator_get_module_info,
+  separator_get_applet_info,
+  separator_get_applet_type,
+  separator_get_applet_from_iid,
+  NULL
+};
diff --git a/modules/builtin/separator/separator-module.h b/modules/builtin/separator/separator-module.h
new file mode 100644
index 0000000..42dac96
--- /dev/null
+++ b/modules/builtin/separator/separator-module.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 SEPARATOR_MODULE_H
+#define SEPARATOR_MODULE_H
+
+#include <libgnome-panel/gp-module.h>
+
+G_BEGIN_DECLS
+
+extern const GpModuleVTable separator_vtable;
+
+G_END_DECLS
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0d15093..1c7110c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -41,11 +41,11 @@ gnome-panel/panel-image-menu-item.c
 gnome-panel/panel-recent.c
 gnome-panel/panel-run-dialog.c
 gnome-panel/panel-run-dialog.ui
-gnome-panel/panel-separator.c
 gnome-panel/panel-stock-icons.c
 gnome-panel/panel-toplevel.c
 gnome-panel/panel-util.c
 libpanel-applet/panel-applet.c
+modules/builtin/separator/separator-module.c
 modules/external/clock/calendar-client.c
 modules/external/clock/calendar-window.c
 modules/external/clock/clock-applet.c


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