[gnome-flashback] add FlashbackDisplayConfig
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] add FlashbackDisplayConfig
- Date: Sun, 24 Aug 2014 00:22:38 +0000 (UTC)
commit fe76809ce6789abd9a12f893ed1fc5f60520290f
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Aug 24 01:33:34 2014 +0300
add FlashbackDisplayConfig
data/org.gnome.gnome-flashback.gschema.xml.in.in | 5 +
gnome-flashback/Makefile.am | 2 +
gnome-flashback/flashback-application.c | 20 +++++
gnome-flashback/flashback-display-config.c | 96 ++++++++++++++++++++++
gnome-flashback/flashback-display-config.h | 46 ++++++++++
gnome-flashback/flashback-gsettings.h | 1 +
6 files changed, 170 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.gnome-flashback.gschema.xml.in.in
b/data/org.gnome.gnome-flashback.gschema.xml.in.in
index d08d340..a28adbf 100644
--- a/data/org.gnome.gnome-flashback.gschema.xml.in.in
+++ b/data/org.gnome.gnome-flashback.gschema.xml.in.in
@@ -5,6 +5,11 @@
<_summary>Desktop background</_summary>
<_description>If set to true, then GNOME Flashback application will be used to draw
desktop background.</_description>
</key>
+ <key name="display-config" type="b">
+ <default>true</default>
+ <_summary>Display config</_summary>
+ <_description>If set to true, then GNOME Flashback application will be used to
provide display configuration.</_description>
+ </key>
<key name="end-session-dialog" type="b">
<default>true</default>
<_summary>End session dialog</_summary>
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index d271d7f..93080fa 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -18,6 +18,8 @@ gnome_flashback_SOURCES = \
flashback-application.h \
flashback-desktop-background.c \
flashback-desktop-background.h \
+ flashback-display-config.c \
+ flashback-display-config.h \
flashback-end-session-dialog.c \
flashback-end-session-dialog.h \
flashback-gsettings.h \
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index a1b66fc..556aa67 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -20,6 +20,7 @@
#include "config.h"
#include "flashback-application.h"
#include "flashback-desktop-background.h"
+#include "flashback-display-config.h"
#include "flashback-end-session-dialog.h"
#include "flashback-gsettings.h"
@@ -27,6 +28,7 @@ struct _FlashbackApplicationPrivate {
GSettings *settings;
FlashbackDesktopBackground *background;
+ FlashbackDisplayConfig *config;
FlashbackEndSessionDialog *dialog;
};
@@ -51,6 +53,19 @@ flashback_application_settings_changed (GSettings *settings,
}
}
}
+
+ if (key == NULL || g_strcmp0 (key, KEY_DISPLAY_CONFIG) == 0) {
+ if (g_settings_get_boolean (settings, KEY_DISPLAY_CONFIG)) {
+ if (app->priv->config == NULL) {
+ app->priv->config = flashback_display_config_new ();
+ }
+ } else {
+ if (app->priv->config) {
+ g_object_unref (app->priv->config);
+ app->priv->config = NULL;
+ }
+ }
+ }
if (key == NULL || g_strcmp0 (key, KEY_END_SESSION_DIALOG) == 0) {
if (g_settings_get_boolean (settings, KEY_END_SESSION_DIALOG)) {
@@ -100,6 +115,11 @@ flashback_application_shutdown (GApplication *application)
g_object_unref (app->priv->background);
app->priv->background = NULL;
}
+
+ if (app->priv->config) {
+ g_object_unref (app->priv->config);
+ app->priv->config = NULL;
+ }
if (app->priv->dialog) {
g_object_unref (app->priv->dialog);
diff --git a/gnome-flashback/flashback-display-config.c b/gnome-flashback/flashback-display-config.c
new file mode 100644
index 0000000..a8a3778
--- /dev/null
+++ b/gnome-flashback/flashback-display-config.c
@@ -0,0 +1,96 @@
+/*
+ * 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/>.
+ */
+
+#include <gtk/gtk.h>
+#include "config.h"
+#include "dbus-display-config.h"
+#include "flashback-display-config.h"
+
+struct _FlashbackDisplayConfigPrivate {
+ gint bus_name;
+};
+
+G_DEFINE_TYPE (FlashbackDisplayConfig, flashback_display_config, G_TYPE_OBJECT);
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+}
+
+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_display_config_finalize (GObject *object)
+{
+ FlashbackDisplayConfig *config = FLASHBACK_DISPLAY_CONFIG (object);
+
+ if (config->priv->bus_name) {
+ g_bus_unown_name (config->priv->bus_name);
+ config->priv->bus_name = 0;
+ }
+
+ G_OBJECT_CLASS (flashback_display_config_parent_class)->finalize (object);
+}
+
+static void
+flashback_display_config_init (FlashbackDisplayConfig *config)
+{
+ config->priv = G_TYPE_INSTANCE_GET_PRIVATE (config,
+ FLASHBACK_TYPE_DISPLAY_CONFIG,
+ FlashbackDisplayConfigPrivate);
+
+ config->priv->bus_name = g_bus_own_name (G_BUS_TYPE_SESSION,
+ "org.gnome.Mutter.DisplayConfig",
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+ G_BUS_NAME_OWNER_FLAGS_REPLACE,
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ config,
+ NULL);
+}
+
+static void
+flashback_display_config_class_init (FlashbackDisplayConfigClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = flashback_display_config_finalize;
+
+ g_type_class_add_private (class, sizeof (FlashbackDisplayConfigPrivate));
+}
+
+FlashbackDisplayConfig *
+flashback_display_config_new (void)
+{
+ return g_object_new (FLASHBACK_TYPE_DISPLAY_CONFIG,
+ NULL);
+}
diff --git a/gnome-flashback/flashback-display-config.h b/gnome-flashback/flashback-display-config.h
new file mode 100644
index 0000000..d9bb37f
--- /dev/null
+++ b/gnome-flashback/flashback-display-config.h
@@ -0,0 +1,46 @@
+/*
+ * 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/>.
+ */
+
+#ifndef FLASHBACK_DISPLAY_CONFIG_H
+#define FLASHBACK_DISPLAY_CONFIG_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define FLASHBACK_TYPE_DISPLAY_CONFIG (flashback_display_config_get_type ())
+#define FLASHBACK_DISPLAY_CONFIG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), FLASHBACK_TYPE_DISPLAY_CONFIG,
FlashbackDisplayConfig))
+
+typedef struct _FlashbackDisplayConfig FlashbackDisplayConfig;
+typedef struct _FlashbackDisplayConfigClass FlashbackDisplayConfigClass;
+typedef struct _FlashbackDisplayConfigPrivate FlashbackDisplayConfigPrivate;
+
+struct _FlashbackDisplayConfig {
+ GObject parent;
+ FlashbackDisplayConfigPrivate *priv;
+};
+
+struct _FlashbackDisplayConfigClass {
+ GObjectClass parent_class;
+};
+
+GType flashback_display_config_get_type (void);
+FlashbackDisplayConfig *flashback_display_config_new (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/flashback-gsettings.h b/gnome-flashback/flashback-gsettings.h
index 73e53fb..97121da 100644
--- a/gnome-flashback/flashback-gsettings.h
+++ b/gnome-flashback/flashback-gsettings.h
@@ -20,6 +20,7 @@
#define FLASHBACK_SCHEMA "org.gnome.gnome-flashback"
#define KEY_DESKTOP_BACKGROUND "desktop-background"
+#define KEY_DISPLAY_CONFIG "display-config"
#define KEY_END_SESSION_DIALOG "end-session-dialog"
/*#define FLASHBACK_BACKGROUND_SCHEMA "org.gnome.gnome-flashback.background"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]