diff options
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | examples/Makefile.am | 27 | ||||
-rw-r--r-- | examples/cc-example-panel.c | 111 | ||||
-rw-r--r-- | examples/cc-example-panel.h | 74 | ||||
-rw-r--r-- | examples/example-module.c | 41 | ||||
-rw-r--r-- | examples/gnome-example-panel.desktop.in.in | 11 |
7 files changed, 284 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 4ecf918ba..7bb045f09 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,15 @@ SUBDIRS = po libwindow-settings libgnome-control-center shell capplets \ font-viewer help docs -DIST_SUBDIRS = po libwindow-settings capplets font-viewer help shell typing-break +DIST_SUBDIRS = po libwindow-settings capplets font-viewer help shell typing-break examples if HAVE_TYPING_BREAK SUBDIRS += typing-break endif +if BUILD_EXAMPLES +SUBDIRS += examples +endif + schemasdir = @GCONF_SCHEMA_FILE_DIR@ schemas_in_files = gnome-control-center.schemas.in schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) diff --git a/configure.ac b/configure.ac index d729411e5..fab6a3ae3 100644 --- a/configure.ac +++ b/configure.ac @@ -295,6 +295,19 @@ AC_SUBST(PANEL_LIBS) PANEL_LDFLAGS="-export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_io_module_(load|unload)'" AC_SUBST(PANEL_LDFLAGS) +dnl ============================================== +dnl Example Panel +dnl ============================================== + +AC_MSG_CHECKING([whether to build the example panel]) +AC_ARG_ENABLE([examples], + AC_HELP_STRING([--enable-examples], + [enable the examples]),, + [enable_examples=no]) +AC_MSG_RESULT([$enable_examples]) + +AM_CONDITIONAL(BUILD_EXAMPLES, test "x$enable_examples" = "xyes") + dnl ======================================= dnl Update Mime Database @@ -351,6 +364,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 000000000..7fc18ab7e --- /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 000000000..64727f771 --- /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 000000000..fe6a079f5 --- /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 000000000..a66e4faad --- /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) +{ +} diff --git a/examples/gnome-example-panel.desktop.in.in b/examples/gnome-example-panel.desktop.in.in new file mode 100644 index 000000000..66b9648be --- /dev/null +++ b/examples/gnome-example-panel.desktop.in.in @@ -0,0 +1,11 @@ +[Desktop Entry] +_Name=Example Panel +_Comment=Example preferences panel +Exec=gnome-example-properties +Icon=application-x-executable +Terminal=false +Type=Application +StartupNotify=true +Categories=GNOME;GTK;Settings;DesktopSettings; +OnlyShowIn=GNOME; + |