[gnome-flashback] desktop: add GfDesktopWindow



commit 86bdbdac4852b4fccd608ef47a2d34eb51c1679e
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Oct 26 12:30:28 2019 +0300

    desktop: add GfDesktopWindow

 gnome-flashback/libdesktop/Makefile.am         |   2 +
 gnome-flashback/libdesktop/gf-desktop-window.c | 168 +++++++++++++++++++++++++
 gnome-flashback/libdesktop/gf-desktop-window.h |  34 +++++
 gnome-flashback/libdesktop/gf-desktop.c        |  21 ++++
 4 files changed, 225 insertions(+)
---
diff --git a/gnome-flashback/libdesktop/Makefile.am b/gnome-flashback/libdesktop/Makefile.am
index 619ab94..7171692 100644
--- a/gnome-flashback/libdesktop/Makefile.am
+++ b/gnome-flashback/libdesktop/Makefile.am
@@ -15,6 +15,8 @@ libdesktop_la_CFLAGS = \
        $(NULL)
 
 libdesktop_la_SOURCES = \
+       gf-desktop-window.c \
+       gf-desktop-window.h \
        gf-desktop.c \
        gf-desktop.h \
        $(NULL)
diff --git a/gnome-flashback/libdesktop/gf-desktop-window.c b/gnome-flashback/libdesktop/gf-desktop-window.c
new file mode 100644
index 0000000..70b5f26
--- /dev/null
+++ b/gnome-flashback/libdesktop/gf-desktop-window.c
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2019 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 "config.h"
+#include "gf-desktop-window.h"
+
+struct _GfDesktopWindow
+{
+  GtkWindow parent;
+
+  gboolean  draw_background;
+  gboolean  show_icons;
+};
+
+enum
+{
+  PROP_0,
+
+  PROP_DRAW_BACKGROUND,
+  PROP_SHOW_ICONS,
+
+  LAST_PROP
+};
+
+static GParamSpec *window_properties[LAST_PROP] = { NULL };
+
+G_DEFINE_TYPE (GfDesktopWindow, gf_desktop_window, GTK_TYPE_WINDOW)
+
+static void
+draw_background_changed (GfDesktopWindow *self)
+{
+}
+
+static void
+show_icons_changed (GfDesktopWindow *self)
+{
+}
+
+static void
+set_draw_background (GfDesktopWindow *self,
+                     gboolean         draw_background)
+{
+  if (self->draw_background == draw_background)
+    return;
+
+  self->draw_background = draw_background;
+  draw_background_changed (self);
+}
+
+static void
+set_show_icons (GfDesktopWindow *self,
+                gboolean         show_icons)
+{
+  if (self->show_icons == show_icons)
+    return;
+
+  self->show_icons = show_icons;
+  show_icons_changed (self);
+}
+
+static void
+gf_desktop_window_constructed (GObject *object)
+{
+  GfDesktopWindow *self;
+
+  self = GF_DESKTOP_WINDOW (object);
+
+  G_OBJECT_CLASS (gf_desktop_window_parent_class)->constructed (object);
+
+  draw_background_changed (self);
+  show_icons_changed (self);
+}
+
+static void
+gf_desktop_window_set_property (GObject      *object,
+                                guint         property_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  GfDesktopWindow *self;
+
+  self = GF_DESKTOP_WINDOW (object);
+
+  switch (property_id)
+    {
+      case PROP_DRAW_BACKGROUND:
+        set_draw_background (self, g_value_get_boolean (value));
+        break;
+
+      case PROP_SHOW_ICONS:
+        set_show_icons (self, g_value_get_boolean (value));
+        break;
+
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+install_properties (GObjectClass *object_class)
+{
+  window_properties[PROP_DRAW_BACKGROUND] =
+    g_param_spec_boolean ("draw-background",
+                          "draw-background",
+                          "draw-background",
+                          TRUE,
+                          G_PARAM_CONSTRUCT | G_PARAM_WRITABLE |
+                          G_PARAM_EXPLICIT_NOTIFY |
+                          G_PARAM_STATIC_STRINGS);
+
+  window_properties[PROP_SHOW_ICONS] =
+    g_param_spec_boolean ("show-icons",
+                          "show-icons",
+                          "show-icons",
+                          TRUE,
+                          G_PARAM_CONSTRUCT | G_PARAM_WRITABLE |
+                          G_PARAM_EXPLICIT_NOTIFY |
+                          G_PARAM_STATIC_STRINGS);
+
+  g_object_class_install_properties (object_class, LAST_PROP, window_properties);
+}
+
+static void
+gf_desktop_window_class_init (GfDesktopWindowClass *self_class)
+{
+  GObjectClass *object_class;
+
+  object_class = G_OBJECT_CLASS (self_class);
+
+  object_class->constructed = gf_desktop_window_constructed;
+  object_class->set_property = gf_desktop_window_set_property;
+
+  install_properties (object_class);
+}
+
+static void
+gf_desktop_window_init (GfDesktopWindow *self)
+{
+  self->draw_background = TRUE;
+  self->show_icons = TRUE;
+}
+
+GtkWidget *
+gf_desktop_window_new (gboolean draw_background,
+                       gboolean show_icons)
+{
+  return g_object_new (GF_TYPE_DESKTOP_WINDOW,
+                       "type", GTK_WINDOW_TOPLEVEL,
+                       "type-hint", GDK_WINDOW_TYPE_HINT_DESKTOP,
+                       "draw-background", draw_background,
+                       "show-icons", show_icons,
+                       NULL);
+}
diff --git a/gnome-flashback/libdesktop/gf-desktop-window.h b/gnome-flashback/libdesktop/gf-desktop-window.h
new file mode 100644
index 0000000..d302152
--- /dev/null
+++ b/gnome-flashback/libdesktop/gf-desktop-window.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2019 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 GF_DESKTOP_WINDOW_H
+#define GF_DESKTOP_WINDOW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GF_TYPE_DESKTOP_WINDOW (gf_desktop_window_get_type ())
+G_DECLARE_FINAL_TYPE (GfDesktopWindow, gf_desktop_window,
+                      GF, DESKTOP_WINDOW, GtkWindow)
+
+GtkWidget *gf_desktop_window_new (gboolean draw_background,
+                                  gboolean show_icons);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libdesktop/gf-desktop.c b/gnome-flashback/libdesktop/gf-desktop.c
index dddbeb3..03b9ae1 100644
--- a/gnome-flashback/libdesktop/gf-desktop.c
+++ b/gnome-flashback/libdesktop/gf-desktop.c
@@ -20,11 +20,15 @@
 
 #include <gio/gio.h>
 
+#include "gf-desktop-window.h"
+
 struct _GfDesktop
 {
   GObject    parent;
 
   GSettings *settings;
+
+  GtkWidget *window;
 };
 
 G_DEFINE_TYPE (GfDesktop, gf_desktop, G_TYPE_OBJECT)
@@ -37,6 +41,7 @@ gf_desktop_dispose (GObject *object)
   self = GF_DESKTOP (object);
 
   g_clear_object (&self->settings);
+  g_clear_pointer (&self->window, gtk_widget_destroy);
 
   G_OBJECT_CLASS (gf_desktop_parent_class)->dispose (object);
 }
@@ -54,7 +59,23 @@ gf_desktop_class_init (GfDesktopClass *self_class)
 static void
 gf_desktop_init (GfDesktop *self)
 {
+  gboolean draw_background;
+  gboolean show_icons;
+
   self->settings = g_settings_new ("org.gnome.gnome-flashback.desktop");
+
+  draw_background = g_settings_get_boolean (self->settings, "draw-background");
+  show_icons = g_settings_get_boolean (self->settings, "show-icons");
+
+  self->window = gf_desktop_window_new (draw_background, show_icons);
+
+  g_settings_bind (self->settings, "draw-background",
+                   self->window, "draw-background",
+                   G_SETTINGS_BIND_GET);
+
+  g_settings_bind (self->settings, "show-icons",
+                   self->window, "show-icons",
+                   G_SETTINGS_BIND_GET);
 }
 
 GfDesktop *


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