[gnome-control-center/extensible-shell] shell: add an object to represent the shell



commit 4e70e91f7f0d70d5bab6fe91d48c50a61dcb0f81
Author: Thomas Wood <thomas wood intel com>
Date:   Thu Feb 25 11:08:19 2010 +0000

    shell: add an object to represent the shell
    
    The CcShell object represents the control center shell. This will allow
    panels to access certain aspects of the shell, such as switching to
    different panels.

 shell/Makefile.am      |    2 +
 shell/cc-shell.c       |  126 ++++++++++++++++++++++++++++++++++++++++++++++++
 shell/cc-shell.h       |   73 ++++++++++++++++++++++++++++
 shell/control-center.c |   15 ++----
 4 files changed, 207 insertions(+), 9 deletions(-)
---
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 7dbeeac..c47d3e4 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -11,6 +11,8 @@ bin_PROGRAMS = gnome-control-center
 
 gnome_control_center_SOURCES =			\
 	control-center.c			\
+	cc-shell.c				\
+	cc-shell.h				\
 	shell-search-renderer.c			\
 	shell-search-renderer.h			\
 	$(NULL)
diff --git a/shell/cc-shell.c b/shell/cc-shell.c
new file mode 100644
index 0000000..6a735d6
--- /dev/null
+++ b/shell/cc-shell.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2010 Intel, Inc.
+ *
+ * The Control Center 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.
+ *
+ * The Control Center 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 the Control Center; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Thomas Wood <thos gnome org>
+ */
+
+#include "cc-shell.h"
+
+G_DEFINE_TYPE (CcShell, cc_shell, GTK_TYPE_BUILDER)
+
+#define SHELL_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_SHELL, CcShellPrivate))
+
+struct _CcShellPrivate
+{
+  gpointer *dummy;
+};
+
+
+static void
+cc_shell_get_property (GObject    *object,
+                       guint       property_id,
+                       GValue     *value,
+                       GParamSpec *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+cc_shell_set_property (GObject      *object,
+                       guint         property_id,
+                       const GValue *value,
+                       GParamSpec   *pspec)
+{
+  switch (property_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
+static void
+cc_shell_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (cc_shell_parent_class)->dispose (object);
+}
+
+static void
+cc_shell_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (cc_shell_parent_class)->finalize (object);
+}
+
+static GObject*
+cc_shell_constructor (GType                  type,
+                      guint                  n_construct_properties,
+                      GObjectConstructParam *construct_properties)
+{
+  GError *err = NULL;
+  GObject *object;
+
+  object =
+    G_OBJECT_CLASS (cc_shell_parent_class)->constructor (type,
+                                                         n_construct_properties,
+                                                         construct_properties);
+
+  gtk_builder_add_from_file (GTK_BUILDER (object),
+                             UIDIR "/shell.ui",
+                             &err);
+
+  if (err)
+    {
+      g_warning ("Could not load UI file: %s", err->message);
+
+      g_error_free (err);
+      g_object_unref (object);
+
+      return NULL;
+    }
+
+  return object;
+}
+
+static void
+cc_shell_class_init (CcShellClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (CcShellPrivate));
+
+  object_class->get_property = cc_shell_get_property;
+  object_class->set_property = cc_shell_set_property;
+  object_class->dispose = cc_shell_dispose;
+  object_class->finalize = cc_shell_finalize;
+  object_class->constructor = cc_shell_constructor;
+}
+
+static void
+cc_shell_init (CcShell *self)
+{
+  self->priv = SHELL_PRIVATE (self);
+}
+
+CcShell *
+cc_shell_new (void)
+{
+  return g_object_new (CC_TYPE_SHELL, NULL);
+}
diff --git a/shell/cc-shell.h b/shell/cc-shell.h
new file mode 100644
index 0000000..68db6c9
--- /dev/null
+++ b/shell/cc-shell.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2010 Intel, Inc.
+ *
+ * The Control Center 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.
+ *
+ * The Control Center 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 the Control Center; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Thomas Wood <thos gnome org>
+ */
+
+#ifndef _CC_SHELL_H
+#define _CC_SHELL_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_SHELL cc_shell_get_type()
+
+#define CC_SHELL(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+  CC_TYPE_SHELL, CcShell))
+
+#define CC_SHELL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), \
+  CC_TYPE_SHELL, CcShellClass))
+
+#define CC_IS_SHELL(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+  CC_TYPE_SHELL))
+
+#define CC_IS_SHELL_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+  CC_TYPE_SHELL))
+
+#define CC_SHELL_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+  CC_TYPE_SHELL, CcShellClass))
+
+typedef struct _CcShell CcShell;
+typedef struct _CcShellClass CcShellClass;
+typedef struct _CcShellPrivate CcShellPrivate;
+
+struct _CcShell
+{
+  GtkBuilder parent;
+
+  CcShellPrivate *priv;
+};
+
+struct _CcShellClass
+{
+  GtkBuilderClass parent_class;
+};
+
+GType cc_shell_get_type (void) G_GNUC_CONST;
+
+CcShell *cc_shell_new (void);
+
+G_END_DECLS
+
+#endif /* _CC_SHELL_H */
diff --git a/shell/control-center.c b/shell/control-center.c
index 7776ce5..bf33e42 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -30,6 +30,7 @@
 #include <gmenu-tree.h>
 
 #include "cc-panel.h"
+#include "cc-shell.h"
 #include "shell-search-renderer.h"
 
 #define W(b,x) GTK_WIDGET (gtk_builder_get_object (b, x))
@@ -600,7 +601,6 @@ int
 main (int argc, char **argv)
 {
   ShellData *data;
-  guint ret;
   GtkWidget *widget;
 
   g_thread_init (NULL);
@@ -608,18 +608,15 @@ main (int argc, char **argv)
 
   data = g_new0 (ShellData, 1);
 
-  data->builder = gtk_builder_new ();
+  data->builder = (GtkBuilder*) cc_shell_new ();
 
-  ret = gtk_builder_add_from_file (data->builder, UIDIR "/shell.ui", NULL);
-  if (ret == 0)
+  if (!data->builder)
     {
-#ifdef RUN_IN_SOURCE_TREE
-      ret = gtk_builder_add_from_file (data->builder, "shell.ui", NULL);
-      if (ret == 0)
-#endif
-        g_error ("Unable to load UI");
+      g_critical ("Could not build interface");
+      return 1;
     }
 
+
   data->window = W (data->builder, "main-window");
   g_signal_connect (data->window, "delete-event", G_CALLBACK (gtk_main_quit),
                     NULL);



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