[gnome-flashback/wip/flashback: 4/4] libosd: initial version



commit b4c867aac17984c8d0680f033784b9cdf9defa60
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Dec 14 01:24:21 2014 +0200

    libosd: initial version
    
    Currenlty ShowOSD is not implemented!

 configure.ac                                     |    5 +
 data/org.gnome.gnome-flashback.gschema.xml.in.in |    5 +
 gnome-flashback/Makefile.am                      |    2 +
 gnome-flashback/flashback-application.c          |   14 ++
 gnome-flashback/libosd/Makefile.am               |   34 ++++++
 gnome-flashback/libosd/flashback-osd.c           |  139 ++++++++++++++++++++++
 gnome-flashback/libosd/flashback-osd.h           |   64 ++++++++++
 gnome-flashback/libosd/org.gnome.Shell.OSD.xml   |    8 ++
 8 files changed, 271 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7170b3b..6c77456 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,6 +61,10 @@ PKG_CHECK_MODULES(KEY_GRABBER, gtk+-3.0 >= $GTK_REQUIRED x11)
 AC_SUBST(KEY_GRABBER_CFLAGS)
 AC_SUBST(KEY_GRABBER_LIBS)
 
+PKG_CHECK_MODULES(OSD, gtk+-3.0 >= $GTK_REQUIRED)
+AC_SUBST(OSD_CFLAGS)
+AC_SUBST(OSD_LIBS)
+
 PKG_CHECK_MODULES(GVC, gobject-2.0 libpulse libpulse-mainloop-glib)
 AM_CONDITIONAL(HAVE_INTROSPECTION, false)
 
@@ -78,6 +82,7 @@ gnome-flashback/libdisplay-config/Makefile
 gnome-flashback/libend-session-dialog/Makefile
 gnome-flashback/libidle-monitor/Makefile
 gnome-flashback/libkey-grabber/Makefile
+gnome-flashback/libosd/Makefile
 gnome-flashback/libsound-applet/Makefile
 gnome-flashback/libsound-applet/gvc/Makefile
 po/Makefile.in
diff --git a/data/org.gnome.gnome-flashback.gschema.xml.in.in 
b/data/org.gnome.gnome-flashback.gschema.xml.in.in
index 9e91388..42030ff 100644
--- a/data/org.gnome.gnome-flashback.gschema.xml.in.in
+++ b/data/org.gnome.gnome-flashback.gschema.xml.in.in
@@ -30,6 +30,11 @@
                        <_summary>Key grabber</_summary>
                        <_description>If set to true, then GNOME Flashback application will be used for key 
grabbing.</_description>
                </key>
+               <key name="osd" type="b">
+                       <default>false</default>
+                       <_summary>OSD</_summary>
+                       <_description>If set to true, then GNOME Flashback application will be used to show 
OSD.</_description>
+               </key>
                <key name="sound-applet" type="b">
                        <default>true</default>
                        <_summary>Sound applet</_summary>
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index b250193..9042f0f 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -5,6 +5,7 @@ SUBDIRS = \
        libend-session-dialog \
        libidle-monitor \
        libkey-grabber \
+       libosd \
        libsound-applet
 
 bin_PROGRAMS = \
@@ -30,6 +31,7 @@ gnome_flashback_LDADD = \
        $(top_builddir)/gnome-flashback/libend-session-dialog/libend-session-dialog.la \
        $(top_builddir)/gnome-flashback/libidle-monitor/libidle-monitor.la \
        $(top_builddir)/gnome-flashback/libkey-grabber/libkey-grabber.la \
+       $(top_builddir)/gnome-flashback/libosd/libosd.la \
        $(top_builddir)/gnome-flashback/libsound-applet/libsound-applet.la
 
 -include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index bcba7f1..02695e8 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -25,6 +25,7 @@
 #include "libend-session-dialog/flashback-end-session-dialog.h"
 #include "libidle-monitor/meta-idle-monitor-dbus.h"
 #include "libkey-grabber/flashback-key-grabber.h"
+#include "libosd/flashback-osd.h"
 #include "libsound-applet/gvc-applet.h"
 
 #define FLASHBACK_SCHEMA       "org.gnome.gnome-flashback"
@@ -33,6 +34,7 @@
 #define KEY_DISPLAY_CONFIG     "display-config"
 #define KEY_END_SESSION_DIALOG "end-session-dialog"
 #define KEY_KEY_GRABBER        "key-grabber"
+#define KEY_OSD                "osd"
 #define KEY_IDLE_MONITOR       "idle-monitor"
 #define KEY_SOUND_APPLET       "sound-applet"
 
@@ -43,6 +45,7 @@ struct _FlashbackApplicationPrivate {
        FlashbackDisplayConfig     *config;
        FlashbackEndSessionDialog  *dialog;
        FlashbackKeyGrabber        *grabber;
+       FlashbackOSD               *osd;
        MetaIdleMonitorDBus        *idle_monitor;
        GvcApplet                  *applet;
 };
@@ -116,6 +119,16 @@ flashback_application_settings_changed (GSettings   *settings,
                }
        }
 
+       if (key == NULL || g_strcmp0 (key, KEY_OSD) == 0) {
+               if (g_settings_get_boolean (settings, KEY_OSD)) {
+                       if (app->priv->osd == NULL) {
+                               app->priv->osd = flashback_osd_new ();
+                       }
+               } else {
+                       g_clear_object (&app->priv->osd);
+               }
+       }
+
        if (key == NULL || g_strcmp0 (key, KEY_SOUND_APPLET) == 0) {
                if (g_settings_get_boolean (settings, KEY_SOUND_APPLET)) {
                        if (app->priv->applet == NULL) {
@@ -138,6 +151,7 @@ flashback_application_finalize (GObject *object)
        g_clear_object (&app->priv->dialog);
        g_clear_object (&app->priv->idle_monitor);
        g_clear_object (&app->priv->grabber);
+       g_clear_object (&app->priv->osd);
        g_clear_object (&app->priv->applet);
        g_clear_object (&app->priv->settings);
 
diff --git a/gnome-flashback/libosd/Makefile.am b/gnome-flashback/libosd/Makefile.am
new file mode 100644
index 0000000..b8ec299
--- /dev/null
+++ b/gnome-flashback/libosd/Makefile.am
@@ -0,0 +1,34 @@
+noinst_LTLIBRARIES = \
+       libosd.la
+
+AM_CPPFLAGS = \
+       $(OSD_CFLAGS) \
+       -I$(top_builddir)/gnome-flashback/libosd \
+       -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+
+libosd_la_SOURCES = \
+       $(BUILT_SOURCES) \
+       flashback-osd.c \
+       flashback-osd.h
+
+libosd_la_LIBADD = \
+       $(OSD_LIBS)
+
+shell-osd.c: shell-osd.h
+shell-osd.h: Makefile.am org.gnome.Shell.OSD.xml
+       gdbus-codegen --interface-prefix org.gnome.Shell \
+                     --generate-c-code shell-osd \
+                     --c-namespace Shell \
+                     $(srcdir)/org.gnome.Shell.OSD.xml
+
+BUILT_SOURCES = \
+       shell-osd.c \
+       shell-osd.h
+
+EXTRA_DIST = \
+       org.gnome.Shell.OSD.xml
+
+CLEANFILES = \
+       $(BUILT_SOURCES)
+
+-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libosd/flashback-osd.c b/gnome-flashback/libosd/flashback-osd.c
new file mode 100644
index 0000000..68d3fab
--- /dev/null
+++ b/gnome-flashback/libosd/flashback-osd.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2014 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 3 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/>.
+ *
+ * Authors:
+ *    Alberts Muktupāvels <alberts muktupavels gmail com>
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+
+#include "flashback-osd.h"
+#include "shell-osd.h"
+
+#define SHELL_OSD_DBUS_NAME "org.gnome.Shell.OSD"
+#define SHELL_OSD_DBUS_PATH "/org/gnome/Shell/OSD"
+
+struct _FlashbackOSDPrivate
+{
+       gint                    bus_name;
+       GDBusInterfaceSkeleton *iface;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (FlashbackOSD,
+                            flashback_osd,
+                            G_TYPE_OBJECT);
+
+static void
+handle_show_osd (ShellOSD              *object,
+                 GDBusMethodInvocation *invocation,
+                 GVariant              *params,
+                 gpointer               user_data)
+{
+       g_warning ("ShowOSD is not implemented!");
+}
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+                 const gchar     *name,
+                 gpointer         user_data)
+{
+       FlashbackOSD *osd;
+       GError       *error;
+
+       osd = FLASHBACK_OSD (user_data);
+       error = NULL;
+
+       osd->priv->iface = G_DBUS_INTERFACE_SKELETON (shell_osd_skeleton_new ());
+
+       g_signal_connect (osd->priv->iface, "handle-show-osd", G_CALLBACK (handle_show_osd), osd);
+
+       if (!g_dbus_interface_skeleton_export (osd->priv->iface,
+                                              connection,
+                                              SHELL_OSD_DBUS_PATH,
+                                              &error)) {
+               g_warning ("Failed to export interface: %s", error->message);
+               g_error_free (error);
+               return;
+       }
+}
+
+static void
+on_name_acquired (GDBusConnection *connection,
+                  const char      *name,
+                  gpointer         user_data)
+{
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+              const char      *name,
+              gpointer         user_data)
+{
+}
+
+static void
+flashback_osd_finalize (GObject *object)
+{
+       FlashbackOSD *osd;
+
+       osd = FLASHBACK_OSD (object);
+
+       if (osd->priv->iface) {
+               g_dbus_interface_skeleton_unexport (osd->priv->iface);
+
+               g_object_unref (osd->priv->iface);
+               osd->priv->iface = NULL;
+       }
+
+       if (osd->priv->bus_name != 0) {
+               g_bus_unown_name (osd->priv->bus_name);
+               osd->priv->bus_name = 0;
+       }
+
+       G_OBJECT_CLASS (flashback_osd_parent_class)->finalize (object);
+}
+
+static void
+flashback_osd_init (FlashbackOSD *osd)
+{
+       osd->priv = flashback_osd_get_instance_private (osd);
+
+       osd->priv->bus_name = g_bus_own_name (G_BUS_TYPE_SESSION,
+                                             SHELL_OSD_DBUS_NAME,
+                                             G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+                                             G_BUS_NAME_OWNER_FLAGS_REPLACE,
+                                             on_bus_acquired,
+                                             on_name_acquired,
+                                             on_name_lost,
+                                             osd,
+                                             NULL);
+}
+
+static void
+flashback_osd_class_init (FlashbackOSDClass *class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+       object_class->finalize = flashback_osd_finalize;
+}
+
+FlashbackOSD *
+flashback_osd_new (void)
+{
+       return g_object_new (FLASHBACK_TYPE_OSD,
+                            NULL);
+}
diff --git a/gnome-flashback/libosd/flashback-osd.h b/gnome-flashback/libosd/flashback-osd.h
new file mode 100644
index 0000000..4b8f7f6
--- /dev/null
+++ b/gnome-flashback/libosd/flashback-osd.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2014 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 3 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/>.
+ *
+ * Authors:
+ *    Alberts Muktupāvels <alberts muktupavels gmail com>
+ */
+
+#ifndef FLASHBACK_OSD_H
+#define FLASHBACK_OSD_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define FLASHBACK_TYPE_OSD         (flashback_osd_get_type ())
+#define FLASHBACK_OSD(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), \
+                                    FLASHBACK_TYPE_OSD,              \
+                                    FlashbackOSD))
+#define FLASHBACK_OSD_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c),    \
+                                    FLASHBACK_TYPE_OSD,              \
+                                    FlashbackOSDClass))
+#define FLASHBACK_IS_OSD(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
+                                    FLASHBACK_TYPE_OSD))
+#define FLASHBACK_IS_OSD_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((c),    \
+                                    FLASHBACK_TYPE_OSD))
+#define FLASHBACK_OSD_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o),   \
+                                    FLASHBACK_TYPE_OSD,              \
+                                    FlashbackOSDClass))
+
+typedef struct _FlashbackOSD        FlashbackOSD;
+typedef struct _FlashbackOSDClass   FlashbackOSDClass;
+typedef struct _FlashbackOSDPrivate FlashbackOSDPrivate;
+
+struct _FlashbackOSD
+{
+       GObject              parent;
+       FlashbackOSDPrivate *priv;
+};
+
+struct _FlashbackOSDClass
+{
+    GObjectClass parent_class;
+};
+
+GType         flashback_osd_get_type (void);
+
+FlashbackOSD *flashback_osd_new      (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libosd/org.gnome.Shell.OSD.xml b/gnome-flashback/libosd/org.gnome.Shell.OSD.xml
new file mode 100644
index 0000000..6628414
--- /dev/null
+++ b/gnome-flashback/libosd/org.gnome.Shell.OSD.xml
@@ -0,0 +1,8 @@
+<node>
+  <interface name="org.gnome.Shell.OSD">
+    <annotation name="org.gtk.GDBus.C.Name" value="OSD"/>
+    <method name="ShowOSD">
+      <arg type="a{sv}" direction="in" name="params"/>
+    </method>
+  </interface>
+</node>


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