[gnome-control-center/wip/libgnome-control-center] Add an example implementation of a settings panel
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/libgnome-control-center] Add an example implementation of a settings panel
- Date: Wed, 19 May 2010 16:28:15 +0000 (UTC)
commit 7d1e6028a3cf136e5e69f17c981da8e4025583e1
Author: Thomas Wood <thomas wood intel com>
Date: Wed May 19 17:27:43 2010 +0100
Add an example implementation of a settings panel
The example panel implements CcPanel and registers itself as extending the
panel extension point. It provides a simple "Hello World" message.
Makefile.am | 2 +-
configure.ac | 2 +
examples/Makefile.am | 27 ++++++++++
examples/cc-example-panel.c | 111 +++++++++++++++++++++++++++++++++++++++++++
examples/cc-example-panel.h | 74 ++++++++++++++++++++++++++++
examples/example-module.c | 41 ++++++++++++++++
6 files changed, 256 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4ecf918..d465573 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
SUBDIRS = po libwindow-settings libgnome-control-center shell capplets \
- font-viewer help docs
+ font-viewer help docs examples
DIST_SUBDIRS = po libwindow-settings capplets font-viewer help shell typing-break
if HAVE_TYPING_BREAK
diff --git a/configure.ac b/configure.ac
index d729411..8fa7da3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -351,6 +351,8 @@ docs/Makefile
docs/reference/Makefile
docs/reference/libgnome-control-center/Makefile
docs/reference/libgnome-control-center/version.xml
+examples/Makefile
+examples/gnome-example-panel.desktop.in
font-viewer/Makefile
font-viewer/gnome-font-viewer.desktop.in
help/Makefile
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644
index 0000000..7fc18ab
--- /dev/null
+++ b/examples/Makefile.am
@@ -0,0 +1,27 @@
+INCLUDES = \
+ $(PANEL_CFLAGS) \
+ $(GNOMECC_CAPPLETS_CFLAGS) \
+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
+ -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
+ $(NULL)
+
+ccpanelsdir = $(PANELS_DIR)
+ccpanels_LTLIBRARIES = libexample.la
+
+libexample_la_SOURCES = \
+ example-module.c \
+ cc-example-panel.c \
+ cc-example-panel.h
+
+libexample_la_LIBADD = $(PANEL_LIBS)
+libexample_la_LDFLAGS = $(PANEL_LDFLAGS)
+
+ INTLTOOL_DESKTOP_RULE@
+
+desktopdir = $(datadir)/applications
+desktop_in_files = gnome-example-panel.desktop.in
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+
+CLEANFILES = $(desktop_in_files) $(desktop_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/examples/cc-example-panel.c b/examples/cc-example-panel.c
new file mode 100644
index 0000000..64727f7
--- /dev/null
+++ b/examples/cc-example-panel.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+#include "cc-example-panel.h"
+
+G_DEFINE_DYNAMIC_TYPE (CcExamplePanel, cc_example_panel, CC_TYPE_PANEL)
+
+#define EXAMPLE_PANEL_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_EXAMPLE_PANEL, CcExamplePanelPrivate))
+
+struct _CcExamplePanelPrivate
+{
+ gpointer dummy;
+};
+
+
+static void
+cc_example_panel_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_example_panel_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_example_panel_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (cc_example_panel_parent_class)->dispose (object);
+}
+
+static void
+cc_example_panel_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (cc_example_panel_parent_class)->finalize (object);
+}
+
+static void
+cc_example_panel_class_init (CcExamplePanelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CcExamplePanelPrivate));
+
+ object_class->get_property = cc_example_panel_get_property;
+ object_class->set_property = cc_example_panel_set_property;
+ object_class->dispose = cc_example_panel_dispose;
+ object_class->finalize = cc_example_panel_finalize;
+}
+
+static void
+cc_example_panel_class_finalize (CcExamplePanelClass *klass)
+{
+}
+
+static void
+cc_example_panel_init (CcExamplePanel *self)
+{
+ GtkWidget *label;
+
+ self->priv = EXAMPLE_PANEL_PRIVATE (self);
+
+ label = gtk_label_new ("Hello World");
+
+ gtk_container_add (GTK_CONTAINER (self), label);
+}
+
+void
+cc_example_panel_register (GIOModule *module)
+{
+ cc_example_panel_register_type (G_TYPE_MODULE (module));
+ g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
+ CC_TYPE_EXAMPLE_PANEL,
+ "gnome-example-panel.desktop", 0);
+}
+
diff --git a/examples/cc-example-panel.h b/examples/cc-example-panel.h
new file mode 100644
index 0000000..fe6a079
--- /dev/null
+++ b/examples/cc-example-panel.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+
+#ifndef _CC_EXAMPLE_PANEL_H
+#define _CC_EXAMPLE_PANEL_H
+
+#include <libgnome-control-center/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_EXAMPLE_PANEL cc_example_panel_get_type()
+
+#define CC_EXAMPLE_PANEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ CC_TYPE_EXAMPLE_PANEL, CcExamplePanel))
+
+#define CC_EXAMPLE_PANEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ CC_TYPE_EXAMPLE_PANEL, CcExamplePanelClass))
+
+#define CC_IS_EXAMPLE_PANEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ CC_TYPE_EXAMPLE_PANEL))
+
+#define CC_IS_EXAMPLE_PANEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ CC_TYPE_EXAMPLE_PANEL))
+
+#define CC_EXAMPLE_PANEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ CC_TYPE_EXAMPLE_PANEL, CcExamplePanelClass))
+
+typedef struct _CcExamplePanel CcExamplePanel;
+typedef struct _CcExamplePanelClass CcExamplePanelClass;
+typedef struct _CcExamplePanelPrivate CcExamplePanelPrivate;
+
+struct _CcExamplePanel
+{
+ CcPanel parent;
+
+ CcExamplePanelPrivate *priv;
+};
+
+struct _CcExamplePanelClass
+{
+ CcPanelClass parent_class;
+};
+
+GType cc_example_panel_get_type (void) G_GNUC_CONST;
+
+void cc_example_panel_register (GIOModule *module);
+
+G_END_DECLS
+
+#endif /* _CC_EXAMPLE_PANEL_H */
diff --git a/examples/example-module.c b/examples/example-module.c
new file mode 100644
index 0000000..a66e4fa
--- /dev/null
+++ b/examples/example-module.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Intel, Inc
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Thomas Wood <thomas wood intel com>
+ *
+ */
+
+#include <config.h>
+
+#include "cc-example-panel.h"
+
+#include <glib/gi18n.h>
+
+void
+g_io_module_load (GIOModule *module)
+{
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ /* register the panel */
+ cc_example_panel_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]