[gnome-control-center/libgnome-control-center] shell: add a new shell
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/libgnome-control-center] shell: add a new shell
- Date: Tue, 18 May 2010 17:22:01 +0000 (UTC)
commit 8ecbd0f40181258c264d5a53206a2bde3795f01d
Author: Thomas Wood <thomas wood intel com>
Date: Tue May 18 18:21:49 2010 +0100
shell: add a new shell
configure.ac | 4 +-
shell/Makefile.am | 79 ++++--
shell/cc-shell-category-view.c | 246 ++++++++++++++++
shell/cc-shell-category-view.h | 76 +++++
shell/cc-shell-item-view.c | 194 +++++++++++++
shell/cc-shell-item-view.h | 72 +++++
shell/cc-shell-marshal.list | 1 +
shell/cc-shell-model.c | 101 +++++++
shell/cc-shell-model.h | 88 ++++++
shell/control-center.c | 288 ++++++++------------
shell/control-center.h | 21 ++
...op.in.in => gnome-control-center.desktop.in.in} | 0
shell/shell-search-renderer.c | 299 ++++++++++++++++++++
shell/shell-search-renderer.h | 74 +++++
shell/shell.ui | 169 +++++++++++
15 files changed, 1514 insertions(+), 198 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3f609ed..96390eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,7 +125,7 @@ COMMON_MODULES="gtk+-2.0 >= 2.20.0 dnl
gnome-desktop-2.0 >= 2.29.4"
PKG_CHECK_MODULES(CAPPLET, $COMMON_MODULES)
PKG_CHECK_MODULES(GNOMECC, $COMMON_MODULES libgnome-menu >= 2.10.1)
-PKG_CHECK_MODULES(GNOMECC_SHELL, $COMMON_MODULES libgnome-menu unique-1.0)
+PKG_CHECK_MODULES(GNOMECC_SHELL, $COMMON_MODULES libgnome-menu unique-1.0 gio-unix-2.0)
PKG_CHECK_MODULES(DBUS, dbus-1 dbus-glib-1)
PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-2.0)
PKG_CHECK_MODULES(DEFAULT_APPLICATIONS_CAPPLET, libxml-2.0)
@@ -368,7 +368,7 @@ libwindow-settings/gnome-window-settings-2.0.pc
po/Makefile.in
libslab/Makefile
shell/Makefile
-shell/gnomecc.desktop.in
+shell/gnome-control-center.desktop.in
typing-break/Makefile
])
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 915d75a..795c6ba 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -1,30 +1,61 @@
-if HAVE_LIBSLAB_DEPS
-REAL_LIBSLAB_CFLAGS = -I$(top_srcdir)/libslab
-REAL_LIBSLAB_LIBS = $(top_builddir)/libslab/libslab.la
-else
-REAL_LIBSLAB_CFLAGS = $(EXTERNAL_LIBSLAB_CFLAGS)
-REAL_LIBSLAB_LIBS = $(EXTERNAL_LIBSLAB_LIBS)
-endif
+NULL =
INCLUDES = \
-I$(top_srcdir) \
- $(REAL_LIBSLAB_CFLAGS) \
- $(GNOMECC_SHELL_CFLAGS)
+ -I$(top_srcdir)/libgnome-control-center \
+ $(GIO_CFLAGS) \
+ $(GNOMECC_SHELL_CFLAGS) \
+ $(NULL)
+
+bin_PROGRAMS = gnome-control-center
+
+MARSHAL_FILES = cc-shell-marshal.c cc-shell-marshal.h
+BUILT_SOURCES = $(MARSHAL_FILES)
-bin_PROGRAMS = gnome-control-center
+cc-shell-marshal.h: cc-shell-marshal.list
+ @GLIB_GENMARSHAL@ --prefix=cc_shell_marshal $< --header > $@
-gnome_control_center_SOURCES = \
- control-center.c
+cc-shell-marshal.c: cc-shell-marshal.list
+ @GLIB_GENMARSHAL@ --prefix=cc_shell_marshal $< --body --header > $@
-gnome_control_center_LDADD = \
- $(GNOMECC_SHELL_LIBS) \
- $(REAL_LIBSLAB_LIBS)
+gnome_control_center_SOURCES = \
+ control-center.c \
+ control-center.h \
+ gnome-control-center.c \
+ gnome-control-center.h \
+ shell-search-renderer.c \
+ shell-search-renderer.h \
+ cc-shell-category-view.c \
+ cc-shell-category-view.h \
+ cc-shell-item-view.c \
+ cc-shell-item-view.h \
+ cc-shell-model.c \
+ cc-shell-model.h \
+ $(MARSHAL_FILES) \
+ $(NULL)
+
+gnome_control_center_LDADD = \
+ $(top_builddir)/libgnome-control-center/libgnome-control-center.la \
+ $(GNOMECC_SHELL_LIBS) \
+ $(GIO_LIBS) \
+ $(NULL)
+
+gnome_control_center_LDFLAGS = -export-dynamic
AM_CPPFLAGS = \
- -DGNOMELOCALEDIR="\"$(datadir)/locale\""
+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
+ -DUIDIR="\"$(uidir)\"" \
+ -DMENUDIR="\"$(menudir)\"" \
+ $(NULL)
+
+menudir = $(sysconfdir)/xdg/menus
+menu_DATA = gnomecc.menu
+
+uidir = $(pkgdatadir)/ui
+ui_DATA = shell.ui
sysdir = $(datadir)/applications
-sys_in_files = gnomecc.desktop.in
+sys_in_files = gnome-control-center.desktop.in
sys_DATA = $(sys_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
@@ -46,11 +77,15 @@ if GCONF_SCHEMAS_INSTALL
fi
endif
-menudir = $(sysconfdir)/xdg/menus
-menu_DATA = gnomecc.menu
-
-EXTRA_DIST = gnomecc.desktop.in.in gnomecc.directory.in gnomecc.menu $(schemas_DATA).in
+EXTRA_DIST = \
+ $(ui_DATA) \
+ gnome-control-center.desktop.in.in \
+ gnomecc.directory.in \
+ gnomecc.menu \
+ cc-shell-marshal.list \
+ $(schemas_DATA).in \
+ $(NULL)
-DISTCLEANFILES = gnomecc.desktop gnomecc.desktop.in gnomecc.directory $(schemas_DATA)
+DISTCLEANFILES = gnome-control-center.desktop gnome-control-center.desktop.in gnomecc.directory $(schemas_DATA)
-include $(top_srcdir)/git.mk
diff --git a/shell/cc-shell-category-view.c b/shell/cc-shell-category-view.c
new file mode 100644
index 0000000..9593f38
--- /dev/null
+++ b/shell/cc-shell-category-view.c
@@ -0,0 +1,246 @@
+/*
+ * 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-category-view.h"
+#include "cc-shell-item-view.h"
+#include "cc-shell.h"
+#include "control-center.h"
+#include "cc-shell-model.h"
+
+G_DEFINE_TYPE (CcShellCategoryView, cc_shell_category_view, GTK_TYPE_FRAME)
+
+#define SHELL_CATEGORY_VIEW_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_SHELL_CATEGORY_VIEW, CcShellCategoryViewPrivate))
+
+enum
+{
+ PROP_NAME = 1,
+ PROP_MODEL
+};
+
+struct _CcShellCategoryViewPrivate
+{
+ gchar *name;
+ GtkTreeModel *model;
+
+ GtkWidget *header;
+ GtkWidget *iconview;
+};
+
+static void
+cc_shell_category_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (object)->priv;
+
+ switch (property_id)
+ {
+ case PROP_NAME:
+ g_value_set_string (value, priv->name);
+ break;
+
+ case PROP_MODEL:
+ g_value_set_object (value, priv->model);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cc_shell_category_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (object)->priv;
+
+ switch (property_id)
+ {
+ case PROP_NAME:
+ priv->name = g_value_dup_string (value);
+ break;
+
+ case PROP_MODEL:
+ priv->model = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+cc_shell_category_view_dispose (GObject *object)
+{
+ CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (object)->priv;
+
+ if (priv->model)
+ {
+ g_object_unref (priv->model);
+ priv->model = NULL;
+ }
+
+ G_OBJECT_CLASS (cc_shell_category_view_parent_class)->dispose (object);
+}
+
+static void
+cc_shell_category_view_finalize (GObject *object)
+{
+ CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (object)->priv;
+
+ if (priv->name)
+ {
+ g_free (priv->name);
+ priv->name = NULL;
+ }
+
+ G_OBJECT_CLASS (cc_shell_category_view_parent_class)->finalize (object);
+}
+
+static void
+cc_shell_category_view_constructed (GObject *object)
+{
+ CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (object)->priv;
+ gchar *header_name;
+ GtkWidget *iconview, *vbox, *header, *self;
+
+ self = GTK_WIDGET (object);
+
+ iconview = cc_shell_item_view_new ();
+ gtk_icon_view_set_model (GTK_ICON_VIEW (iconview), priv->model);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+
+ gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (iconview), COL_PIXBUF);
+ gtk_icon_view_set_text_column (GTK_ICON_VIEW (iconview), COL_NAME);
+ gtk_icon_view_set_item_width (GTK_ICON_VIEW (iconview), 120);
+
+ /* create the header if required */
+ if (priv->name)
+ {
+ header_name = g_strdup_printf ("<b>%s</b>", priv->name);
+
+ header = g_object_new (GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_name,
+ "wrap", TRUE,
+ "xalign", 0.0,
+ "xpad", 6,
+ NULL);
+
+ g_free (header_name);
+ gtk_box_pack_start (GTK_BOX (vbox), header, FALSE, TRUE, 3);
+
+ priv->header = header;
+ }
+
+ /* add the iconview to the vbox */
+ gtk_box_pack_start (GTK_BOX (vbox), iconview, FALSE, TRUE, 0);
+
+ /* add the main vbox to the view */
+ gtk_container_add (GTK_CONTAINER (object), vbox);
+ gtk_widget_show_all (vbox);
+
+ priv->iconview = iconview;
+}
+
+static void
+cc_shell_category_view_style_set (GtkWidget *widget,
+ GtkStyle *old_style)
+{
+ CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (widget)->priv;
+
+ if (priv->header)
+ {
+ gtk_widget_modify_bg (priv->header, GTK_STATE_NORMAL,
+ &widget->style->base[GTK_STATE_NORMAL]);
+ gtk_widget_modify_fg (priv->header, GTK_STATE_NORMAL,
+ &widget->style->text[GTK_STATE_NORMAL]);
+ }
+
+ if (priv->iconview)
+ {
+ gtk_widget_modify_bg (priv->iconview, GTK_STATE_NORMAL,
+ &widget->style->base[GTK_STATE_NORMAL]);
+ gtk_widget_modify_fg (priv->iconview, GTK_STATE_NORMAL,
+ &widget->style->text[GTK_STATE_NORMAL]);
+ }
+}
+
+static void
+cc_shell_category_view_class_init (CcShellCategoryViewClass *klass)
+{
+ GParamSpec *pspec;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CcShellCategoryViewPrivate));
+
+ object_class->get_property = cc_shell_category_view_get_property;
+ object_class->set_property = cc_shell_category_view_set_property;
+ object_class->dispose = cc_shell_category_view_dispose;
+ object_class->finalize = cc_shell_category_view_finalize;
+ object_class->constructed = cc_shell_category_view_constructed;
+
+ widget_class->style_set = cc_shell_category_view_style_set;
+
+ pspec = g_param_spec_string ("name",
+ "Name",
+ "Name of the category",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_NAME, pspec);
+
+ pspec = g_param_spec_object ("model",
+ "Model",
+ "Model of the category",
+ GTK_TYPE_TREE_MODEL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
+ | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_MODEL, pspec);
+
+}
+
+static void
+cc_shell_category_view_init (CcShellCategoryView *self)
+{
+ self->priv = SHELL_CATEGORY_VIEW_PRIVATE (self);
+
+ gtk_frame_set_shadow_type (GTK_FRAME (self), GTK_SHADOW_NONE);
+}
+
+GtkWidget *
+cc_shell_category_view_new (const gchar *name,
+ GtkTreeModel *model)
+{
+ return g_object_new (CC_TYPE_SHELL_CATEGORY_VIEW,
+ "name", name,
+ "model", model, NULL);
+}
+
+CcShellItemView*
+cc_shell_category_view_get_item_view (CcShellCategoryView *self)
+{
+ return (CcShellItemView*) self->priv->iconview;
+}
diff --git a/shell/cc-shell-category-view.h b/shell/cc-shell-category-view.h
new file mode 100644
index 0000000..d434501
--- /dev/null
+++ b/shell/cc-shell-category-view.h
@@ -0,0 +1,76 @@
+/*
+ * 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_CATEGORY_VIEW_H
+#define _CC_SHELL_CATEGORY_VIEW_H
+
+#include <gtk/gtk.h>
+#include "cc-shell-item-view.h"
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_SHELL_CATEGORY_VIEW cc_shell_category_view_get_type()
+
+#define CC_SHELL_CATEGORY_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ CC_TYPE_SHELL_CATEGORY_VIEW, CcShellCategoryView))
+
+#define CC_SHELL_CATEGORY_VIEW_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ CC_TYPE_SHELL_CATEGORY_VIEW, CcShellCategoryViewClass))
+
+#define CC_IS_SHELL_CATEGORY_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ CC_TYPE_SHELL_CATEGORY_VIEW))
+
+#define CC_IS_SHELL_CATEGORY_VIEW_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ CC_TYPE_SHELL_CATEGORY_VIEW))
+
+#define CC_SHELL_CATEGORY_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ CC_TYPE_SHELL_CATEGORY_VIEW, CcShellCategoryViewClass))
+
+typedef struct _CcShellCategoryView CcShellCategoryView;
+typedef struct _CcShellCategoryViewClass CcShellCategoryViewClass;
+typedef struct _CcShellCategoryViewPrivate CcShellCategoryViewPrivate;
+
+struct _CcShellCategoryView
+{
+ GtkFrame parent;
+
+ CcShellCategoryViewPrivate *priv;
+};
+
+struct _CcShellCategoryViewClass
+{
+ GtkFrameClass parent_class;
+};
+
+GType cc_shell_category_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget *cc_shell_category_view_new (const gchar *name,
+ GtkTreeModel *model);
+CcShellItemView* cc_shell_category_view_get_item_view (CcShellCategoryView *self);
+
+G_END_DECLS
+
+#endif /* _CC_SHELL_CATEGORY_VIEW_H */
diff --git a/shell/cc-shell-item-view.c b/shell/cc-shell-item-view.c
new file mode 100644
index 0000000..a1cd9d7
--- /dev/null
+++ b/shell/cc-shell-item-view.c
@@ -0,0 +1,194 @@
+/*
+ * 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-item-view.h"
+#include "cc-shell-model.h"
+#include "cc-shell-marshal.h"
+
+G_DEFINE_TYPE (CcShellItemView, cc_shell_item_view, GTK_TYPE_ICON_VIEW)
+
+#define SHELL_ITEM_VIEW_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_SHELL_ITEM_VIEW, CcShellItemViewPrivate))
+
+struct _CcShellItemViewPrivate
+{
+ gboolean ignore_release;
+};
+
+
+enum
+{
+ DESKTOP_ITEM_ACTIVATED,
+
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = {0,};
+
+static void
+cc_shell_item_view_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_item_view_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_item_view_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (cc_shell_item_view_parent_class)->dispose (object);
+}
+
+static void
+cc_shell_item_view_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (cc_shell_item_view_parent_class)->finalize (object);
+}
+
+static gboolean
+iconview_button_press_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ CcShellItemView *cc_view)
+{
+ /* be sure to ignore double and triple clicks */
+ cc_view->priv->ignore_release = (event->type != GDK_BUTTON_PRESS);
+
+ return FALSE;
+}
+
+static gboolean
+iconview_button_release_event_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ CcShellItemView *cc_view)
+{
+ CcShellItemViewPrivate *priv = cc_view->priv;
+
+ if (event->button == 1 && !priv->ignore_release)
+ {
+ GList *selection;
+
+ selection =
+ gtk_icon_view_get_selected_items (GTK_ICON_VIEW (cc_view));
+
+ if (!selection)
+ return TRUE;
+
+ gtk_icon_view_item_activated (GTK_ICON_VIEW (cc_view),
+ (GtkTreePath*) selection->data);
+
+ g_list_free (selection);
+ }
+
+ return TRUE;
+}
+
+static void
+iconview_item_activated_cb (GtkIconView *icon_view,
+ GtkTreePath *path,
+ CcShellItemView *cc_view)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gchar *name, *desktop_file, *id;
+
+ model = gtk_icon_view_get_model (icon_view);
+
+ gtk_icon_view_unselect_all (icon_view);
+
+ /* get the iter and ensure it is valid */
+ if (!gtk_tree_model_get_iter (model, &iter, path))
+ return;
+
+ gtk_tree_model_get (model, &iter,
+ COL_NAME, &name,
+ COL_DESKTOP_FILE, &desktop_file,
+ COL_ID, &id,
+ -1);
+
+ g_signal_emit (cc_view, signals[DESKTOP_ITEM_ACTIVATED], 0,
+ name, id, desktop_file);
+
+ g_free (desktop_file);
+ g_free (name);
+ g_free (id);
+}
+
+static void
+cc_shell_item_view_class_init (CcShellItemViewClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (CcShellItemViewPrivate));
+
+ object_class->get_property = cc_shell_item_view_get_property;
+ object_class->set_property = cc_shell_item_view_set_property;
+ object_class->dispose = cc_shell_item_view_dispose;
+ object_class->finalize = cc_shell_item_view_finalize;
+
+ signals[DESKTOP_ITEM_ACTIVATED] = g_signal_new ("desktop-item-activated",
+ CC_TYPE_SHELL_ITEM_VIEW,
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL,
+ NULL,
+ cc_shell_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE,
+ 3,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+}
+
+static void
+cc_shell_item_view_init (CcShellItemView *self)
+{
+ self->priv = SHELL_ITEM_VIEW_PRIVATE (self);
+
+ g_signal_connect (self, "item-activated",
+ G_CALLBACK (iconview_item_activated_cb), self);
+ g_signal_connect (self, "button-press-event",
+ G_CALLBACK (iconview_button_press_event_cb), self);
+ g_signal_connect (self, "button-release-event",
+ G_CALLBACK (iconview_button_release_event_cb), self);
+}
+
+GtkWidget *
+cc_shell_item_view_new (void)
+{
+ return g_object_new (CC_TYPE_SHELL_ITEM_VIEW, NULL);
+}
diff --git a/shell/cc-shell-item-view.h b/shell/cc-shell-item-view.h
new file mode 100644
index 0000000..ec27f14
--- /dev/null
+++ b/shell/cc-shell-item-view.h
@@ -0,0 +1,72 @@
+/*
+ * 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_ITEM_VIEW_H
+#define _CC_SHELL_ITEM_VIEW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_SHELL_ITEM_VIEW cc_shell_item_view_get_type()
+
+#define CC_SHELL_ITEM_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ CC_TYPE_SHELL_ITEM_VIEW, CcShellItemView))
+
+#define CC_SHELL_ITEM_VIEW_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ CC_TYPE_SHELL_ITEM_VIEW, CcShellItemViewClass))
+
+#define CC_IS_SHELL_ITEM_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ CC_TYPE_SHELL_ITEM_VIEW))
+
+#define CC_IS_SHELL_ITEM_VIEW_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ CC_TYPE_SHELL_ITEM_VIEW))
+
+#define CC_SHELL_ITEM_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ CC_TYPE_SHELL_ITEM_VIEW, CcShellItemViewClass))
+
+typedef struct _CcShellItemView CcShellItemView;
+typedef struct _CcShellItemViewClass CcShellItemViewClass;
+typedef struct _CcShellItemViewPrivate CcShellItemViewPrivate;
+
+struct _CcShellItemView
+{
+ GtkIconView parent;
+
+ CcShellItemViewPrivate *priv;
+};
+
+struct _CcShellItemViewClass
+{
+ GtkIconViewClass parent_class;
+};
+
+GType cc_shell_item_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget *cc_shell_item_view_new (void);
+
+G_END_DECLS
+
+#endif /* _CC_SHELL_ITEM_VIEW_H */
diff --git a/shell/cc-shell-marshal.list b/shell/cc-shell-marshal.list
new file mode 100644
index 0000000..41e4027
--- /dev/null
+++ b/shell/cc-shell-marshal.list
@@ -0,0 +1 @@
+VOID:STRING,STRING,STRING
diff --git a/shell/cc-shell-model.c b/shell/cc-shell-model.c
new file mode 100644
index 0000000..3bd4d31
--- /dev/null
+++ b/shell/cc-shell-model.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2009, 2010 Intel, Inc.
+ * Copyright (c) 2010 Red Hat, 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-model.h"
+#include <string.h>
+
+G_DEFINE_TYPE (CcShellModel, cc_shell_model, GTK_TYPE_LIST_STORE)
+
+static void
+cc_shell_model_class_init (CcShellModelClass *klass)
+{
+
+}
+
+static void
+cc_shell_model_init (CcShellModel *self)
+{
+ GType types[] = {G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING};
+
+ gtk_list_store_set_column_types (GTK_LIST_STORE (self),
+ N_COLS, types);
+}
+
+CcShellModel *
+cc_shell_model_new (void)
+{
+ return g_object_new (CC_TYPE_SHELL_MODEL, NULL);
+}
+
+void
+cc_shell_model_add_item (CcShellModel *model,
+ const gchar *category_name,
+ GMenuTreeEntry *item)
+{
+ const gchar *icon = gmenu_tree_entry_get_icon (item);
+ const gchar *name = gmenu_tree_entry_get_name (item);
+ const gchar *id = gmenu_tree_entry_get_desktop_file_id (item);
+ const gchar *desktop = gmenu_tree_entry_get_desktop_file_path (item);
+ const gchar *comment = gmenu_tree_entry_get_comment (item);
+ GdkPixbuf *pixbuf = NULL;
+ gchar *icon2 = NULL;
+ GError *err = NULL;
+ gchar *search_target;
+
+ if (icon != NULL && *icon == '/')
+ {
+ pixbuf = gdk_pixbuf_new_from_file_at_scale (icon, 32, 32, TRUE, &err);
+ }
+ else
+ {
+ if (icon2 == NULL && icon != NULL && g_str_has_suffix (icon, ".png"))
+ icon2 = g_strndup (icon, strlen (icon) - strlen (".png"));
+
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ icon2 ? icon2 : icon, 32,
+ GTK_ICON_LOOKUP_FORCE_SIZE,
+ &err);
+ }
+
+ if (err)
+ {
+ g_warning ("Could not load icon '%s': %s", icon2 ? icon2 : icon,
+ err->message);
+ g_error_free (err);
+ }
+
+ g_free (icon2);
+
+ search_target = g_strconcat (name, " - ", comment, NULL);
+
+ gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, 0,
+ COL_NAME, name,
+ COL_DESKTOP_FILE, desktop,
+ COL_ID, id,
+ COL_PIXBUF, pixbuf,
+ COL_CATEGORY, category_name,
+ COL_SEARCH_TARGET, search_target,
+ -1);
+
+ g_free (search_target);
+
+}
diff --git a/shell/cc-shell-model.h b/shell/cc-shell-model.h
new file mode 100644
index 0000000..851b7d2
--- /dev/null
+++ b/shell/cc-shell-model.h
@@ -0,0 +1,88 @@
+/*
+ * 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_MODEL_H
+#define _CC_SHELL_MODEL_H
+
+#include <gtk/gtk.h>
+#define GMENU_I_KNOW_THIS_IS_UNSTABLE
+#include <gmenu-tree.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_SHELL_MODEL cc_shell_model_get_type()
+
+#define CC_SHELL_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ CC_TYPE_SHELL_MODEL, CcShellModel))
+
+#define CC_SHELL_MODEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ CC_TYPE_SHELL_MODEL, CcShellModelClass))
+
+#define CC_IS_SHELL_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ CC_TYPE_SHELL_MODEL))
+
+#define CC_IS_SHELL_MODEL_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ CC_TYPE_SHELL_MODEL))
+
+#define CC_SHELL_MODEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ CC_TYPE_SHELL_MODEL, CcShellModelClass))
+
+typedef struct _CcShellModel CcShellModel;
+typedef struct _CcShellModelClass CcShellModelClass;
+
+enum
+{
+ COL_NAME,
+ COL_DESKTOP_FILE,
+ COL_ID,
+ COL_PIXBUF,
+ COL_CATEGORY,
+ COL_SEARCH_TARGET,
+
+ N_COLS
+};
+
+struct _CcShellModel
+{
+ GtkListStore parent;
+};
+
+struct _CcShellModelClass
+{
+ GtkListStoreClass parent_class;
+};
+
+GType cc_shell_model_get_type (void) G_GNUC_CONST;
+
+CcShellModel *cc_shell_model_new (void);
+
+void cc_shell_model_add_item (CcShellModel *model,
+ const gchar *category_name,
+ GMenuTreeEntry *item);
+
+G_END_DECLS
+
+#endif /* _CC_SHELL_MODEL_H */
diff --git a/shell/control-center.c b/shell/control-center.c
index c9b6657..029c577 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -1,197 +1,137 @@
/*
- * This file is part of the Control Center.
+ * Copyright (c) 2009, 2010 Intel, Inc.
+ * Copyright (c) 2010 Red Hat, Inc.
*
- * Copyright (c) 2006 Novell, 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 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.
*
- * 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
*
- * 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 "config.h"
-#include <glib/gi18n.h>
+#include "gnome-control-center.h"
+
#include <gtk/gtk.h>
-#include <libgnome/gnome-desktop-item.h>
-#include <unique/unique.h>
+#include <string.h>
-#include <libslab/slab.h>
-void handle_static_action_clicked (Tile * tile, TileEvent * event, gpointer data);
-static GSList *get_actions_list ();
+#include <unique/unique.h>
-#define CONTROL_CENTER_PREFIX "/apps/control-center/cc_"
-#define CONTROL_CENTER_ACTIONS_LIST_KEY (CONTROL_CENTER_PREFIX "actions_list")
-#define CONTROL_CENTER_ACTIONS_SEPARATOR ";"
-#define EXIT_SHELL_ON_STATIC_ACTION "exit_shell_on_static_action"
-static GSList *
-get_actions_list (void)
+enum
{
- GSList *l;
- GSList *key_list;
- GSList *actions_list = NULL;
- AppAction *action;
-
- key_list = get_slab_gconf_slist (CONTROL_CENTER_ACTIONS_LIST_KEY);
- if (!key_list)
- {
- g_warning (_("key not found [%s]\n"), CONTROL_CENTER_ACTIONS_LIST_KEY);
- return NULL;
- }
-
- for (l = key_list; l != NULL; l = l->next)
- {
- gchar *entry = (gchar *) l->data;
- gchar **temp;
-
- action = g_new (AppAction, 1);
- temp = g_strsplit (entry, CONTROL_CENTER_ACTIONS_SEPARATOR, 2);
- action->name = g_strdup (temp[0]);
- if ((action->item = load_desktop_item_from_unknown (temp[1])) == NULL)
- {
- g_warning ("get_actions_list() - PROBLEM - Can't load %s\n", temp[1]);
- }
- else
- {
- actions_list = g_slist_prepend (actions_list, action);
- }
- g_strfreev (temp);
- g_free (entry);
- }
-
- g_slist_free (key_list);
-
- return g_slist_reverse (actions_list);
-}
+ CC_SHELL_RAISE_COMMAND = 1
+};
+
-void
-handle_static_action_clicked (Tile * tile, TileEvent * event, gpointer data)
-{
- gchar *temp;
- AppShellData *app_data = (AppShellData *) data;
- GnomeDesktopItem *item =
- (GnomeDesktopItem *) g_object_get_data (G_OBJECT (tile), APP_ACTION_KEY);
-
- if (event->type == TILE_EVENT_ACTIVATED_DOUBLE_CLICK)
- return;
- open_desktop_item_exec (item);
-
- temp = g_strdup_printf("%s%s", app_data->gconf_prefix, EXIT_SHELL_ON_STATIC_ACTION);
- if (get_slab_gconf_bool(temp))
- {
- if (app_data->exit_on_close)
- gtk_main_quit ();
- else
- hide_shell (app_data);
- }
- g_free (temp);
-}
static UniqueResponse
-message_received_cb (UniqueApp *app,
- UniqueCommand command,
- UniqueMessageData *message,
- guint time,
- gpointer user_data)
+message_received (UniqueApp *app,
+ gint command,
+ UniqueMessageData *message_data,
+ guint time_,
+ GnomeControlCenter *shell)
{
- UniqueResponse res;
- AppShellData *app_data = user_data;
-
- switch (command) {
- case UNIQUE_ACTIVATE:
- /* move the main window to the screen that sent us the command */
- gtk_window_set_screen (GTK_WINDOW (app_data->main_app),
- unique_message_data_get_screen (message));
- if (!app_data->main_app_window_shown_once)
- show_shell (app_data);
-
- gtk_window_present_with_time (GTK_WINDOW (app_data->main_app),
- time);
-
- gtk_widget_grab_focus (SLAB_SECTION (app_data->filter_section)->contents);
-
- res = UNIQUE_RESPONSE_OK;
- break;
- default:
- res = UNIQUE_RESPONSE_PASSTHROUGH;
- break;
- }
-
- return res;
+ const gchar *id;
+ gsize len;
+
+ gnome_control_center_present (shell);
+
+ id = (gchar*) unique_message_data_get (message_data, &len);
+
+ if (id)
+ {
+ GError *err = NULL;
+
+ if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, &err))
+ {
+ if (err)
+ {
+ g_warning ("Could not load setting panel \"%s\": %s", id,
+ err->message);
+ g_error_free (err);
+ err = NULL;
+ }
+ }
+ }
+
+ return GTK_RESPONSE_OK;
}
int
-main (int argc, char *argv[])
+main (int argc, char **argv)
{
- gboolean hidden = FALSE;
- UniqueApp *unique_app;
- AppShellData *app_data;
- GSList *actions;
- GError *error;
- GOptionEntry options[] = {
- { "hide", 0, 0, G_OPTION_ARG_NONE, &hidden, N_("Hide on start (useful to preload the shell)"), NULL },
- { NULL }
- };
-
-#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- textdomain (GETTEXT_PACKAGE);
-#endif
-
- error = NULL;
- if (!gtk_init_with_args (&argc, &argv,
- NULL, options, GETTEXT_PACKAGE, &error)) {
- g_printerr ("%s\n", error->message);
- g_error_free (error);
- return 1;
- }
-
- unique_app = unique_app_new ("org.gnome.gnome-control-center.shell", NULL);
- if (unique_app_is_running (unique_app)) {
- int retval = 0;
-
- if (!hidden) {
- UniqueResponse response;
- response = unique_app_send_message (unique_app,
- UNIQUE_ACTIVATE,
- NULL);
- retval = (response != UNIQUE_RESPONSE_OK);
- }
-
- g_object_unref (unique_app);
- return retval;
- }
-
- app_data = appshelldata_new ("gnomecc.menu", NULL, CONTROL_CENTER_PREFIX,
- GTK_ICON_SIZE_DND, FALSE, TRUE);
- generate_categories (app_data);
-
- actions = get_actions_list ();
- layout_shell (app_data, _("Filter"), _("Groups"), _("Common Tasks"), actions,
- handle_static_action_clicked);
-
- create_main_window (app_data, "MyControlCenter", _("Control Center"),
- "gnome-control-center", 975, 600, hidden);
-
- unique_app_watch_window (unique_app, GTK_WINDOW (app_data->main_app));
- g_signal_connect (unique_app, "message-received",
- G_CALLBACK (message_received_cb), app_data);
-
- gtk_main ();
-
- g_object_unref (unique_app);
-
- return 0;
-};
+ GnomeControlCenter *shell;
+ UniqueApp *unique;
+
+ g_thread_init (NULL);
+ gtk_init (&argc, &argv);
+
+ /* use Unique to enforce single instance of this application */
+ unique = unique_app_new_with_commands ("org.gnome.ControlCenter",
+ NULL,
+ "raise",
+ CC_SHELL_RAISE_COMMAND,
+ NULL);
+
+ /* check if the application is already running */
+ if (unique_app_is_running (unique))
+ {
+ UniqueMessageData *data;
+
+ if (argc == 2)
+ {
+ data = unique_message_data_new ();
+ unique_message_data_set (data, (guchar*) argv[1],
+ strlen(argv[1]) + 1);
+ }
+ else
+ data = NULL;
+
+ unique_app_send_message (unique, 1, data);
+
+ gdk_notify_startup_complete ();
+ return 0;
+ }
+
+
+ shell = gnome_control_center_new ();
+
+ g_signal_connect (unique, "message-received", G_CALLBACK (message_received),
+ shell);
+
+ if (argc == 2)
+ {
+ gchar *start_id;
+ GError *err = NULL;
+
+ start_id = argv[1];
+
+ if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, &err))
+ {
+ g_warning ("Could not load setting panel \"%s\": %s", start_id,
+ (err) ? err->message : "Unknown error");
+ if (err)
+ {
+ g_error_free (err);
+ err = NULL;
+ }
+ }
+ }
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/shell/control-center.h b/shell/control-center.h
new file mode 100644
index 0000000..6054f9d
--- /dev/null
+++ b/shell/control-center.h
@@ -0,0 +1,21 @@
+/*
+ * 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>
+ */
+
+
diff --git a/shell/gnomecc.desktop.in.in b/shell/gnome-control-center.desktop.in.in
similarity index 100%
rename from shell/gnomecc.desktop.in.in
rename to shell/gnome-control-center.desktop.in.in
diff --git a/shell/shell-search-renderer.c b/shell/shell-search-renderer.c
new file mode 100644
index 0000000..08cada5
--- /dev/null
+++ b/shell/shell-search-renderer.c
@@ -0,0 +1,299 @@
+/*
+ * 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 "shell-search-renderer.h"
+#include <string.h>
+
+G_DEFINE_TYPE (ShellSearchRenderer, shell_search_renderer, GTK_TYPE_CELL_RENDERER)
+
+#define SEARCH_RENDERER_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), SHELL_TYPE_SEARCH_RENDERER, ShellSearchRendererPrivate))
+
+struct _ShellSearchRendererPrivate
+{
+ gchar *title;
+ gchar *search_target;
+ gchar *search_string;
+
+ PangoLayout *layout;
+};
+
+enum
+{
+ PROP_TITLE = 1,
+ PROP_SEARCH_TARGET,
+ PROP_SEARCH_STRING
+};
+
+
+static void
+shell_search_renderer_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ case PROP_TITLE:
+ case PROP_SEARCH_TARGET:
+ case PROP_SEARCH_STRING:
+ break;
+
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+shell_search_renderer_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (object)->priv;
+
+ switch (property_id)
+ {
+ case PROP_TITLE:
+ g_free (priv->title);
+ priv->title = g_value_dup_string (value);
+ break;
+
+ case PROP_SEARCH_TARGET:
+ g_free (priv->search_target);
+ priv->search_target = g_value_dup_string (value);
+ break;
+
+ case PROP_SEARCH_STRING:
+ g_free (priv->search_string);
+ priv->search_string = g_value_dup_string (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+shell_search_renderer_dispose (GObject *object)
+{
+ ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (object)->priv;
+
+ if (priv->layout)
+ {
+ g_object_unref (priv->layout);
+ priv->layout = NULL;
+ }
+
+ G_OBJECT_CLASS (shell_search_renderer_parent_class)->dispose (object);
+}
+
+static void
+shell_search_renderer_finalize (GObject *object)
+{
+ ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (object)->priv;
+
+ if (priv->title)
+ {
+ g_free (priv->title);
+ priv->title = NULL;
+ }
+
+ if (priv->search_target)
+ {
+ g_free (priv->search_target);
+ priv->search_target = NULL;
+ }
+
+ if (priv->search_string)
+ {
+ g_free (priv->search_string);
+ priv->search_string = NULL;
+ }
+
+ G_OBJECT_CLASS (shell_search_renderer_parent_class)->finalize (object);
+}
+
+static void
+shell_search_renderer_set_layout (ShellSearchRenderer *cell, GtkWidget *widget)
+{
+ gchar *display_string;
+ ShellSearchRendererPrivate *priv = cell->priv;
+ gchar *needle, *haystack;
+ gchar *full_string;
+
+ if (!priv->layout)
+ {
+ priv->layout = pango_layout_new (gtk_widget_get_pango_context (widget));
+ pango_layout_set_ellipsize (priv->layout, PANGO_ELLIPSIZE_END);
+ }
+
+ full_string = priv->search_target;
+
+ needle = g_utf8_casefold (priv->search_string, -1);
+ haystack = g_utf8_casefold (full_string, -1);
+
+ /* clear any previous attributes */
+ pango_layout_set_attributes (priv->layout, NULL);
+
+ if (priv->search_string && priv->title
+ && (strstr (haystack, needle)))
+ {
+ gchar *start;
+ gchar *lead, *trail, *leaddot;
+ gint count;
+#define CONTEXT 10
+
+ count = strlen (needle);
+ start = strstr (haystack, needle);
+
+ lead = MAX (start - CONTEXT, haystack);
+ trail = start + count;
+
+ if (lead == haystack)
+ leaddot = "";
+ else
+ leaddot = "...";
+
+ lead = g_strndup (lead, start - lead);
+
+ display_string = g_markup_printf_escaped ("%s\n"
+ "<small>%s%s<b>%s</b>%s</small>",
+ priv->title, leaddot, lead,
+ needle, trail);
+
+ g_free (lead);
+ }
+ else
+ display_string = g_markup_escape_text (priv->title, -1);
+
+
+ pango_layout_set_markup (priv->layout, display_string, -1);
+ g_free (display_string);
+ g_free (needle);
+ g_free (haystack);
+}
+
+static void
+shell_search_renderer_get_size (GtkCellRenderer *cell,
+ GtkWidget *widget,
+ GdkRectangle *cell_area,
+ gint *x_offset,
+ gint *y_offset,
+ gint *width,
+ gint *height)
+{
+ ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (cell)->priv;
+ PangoRectangle rect;
+
+ shell_search_renderer_set_layout (SHELL_SEARCH_RENDERER (cell), widget);
+
+ pango_layout_set_width (priv->layout, PANGO_SCALE * 180);
+ pango_layout_get_pixel_extents (priv->layout, NULL, &rect);
+
+ if (width) *width = rect.width;
+ if (height) *height = rect.height;
+
+ if (x_offset) *x_offset = 0;
+ if (y_offset) *y_offset = 0;
+
+}
+
+static void
+shell_search_renderer_render (GtkCellRenderer *cell,
+ GdkDrawable *window,
+ GtkWidget *widget,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GdkRectangle *expose_area,
+ GtkCellRendererState flags)
+{
+ ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (cell)->priv;
+ cairo_t *cr;
+ PangoRectangle rect;
+
+ shell_search_renderer_set_layout (SHELL_SEARCH_RENDERER (cell), widget);
+
+ cr = gdk_cairo_create (window);
+
+ pango_layout_get_pixel_extents (priv->layout, NULL, &rect);
+
+ cairo_move_to (cr, cell_area->x, cell_area->y);
+
+ /* FIXME: get the correct colour from the theme */
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ if (priv->layout)
+ pango_cairo_layout_path (cr, priv->layout);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+}
+
+static void
+shell_search_renderer_class_init (ShellSearchRendererClass *klass)
+{
+ GParamSpec *pspec;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkCellRendererClass *cell_renderer = GTK_CELL_RENDERER_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (ShellSearchRendererPrivate));
+
+ object_class->get_property = shell_search_renderer_get_property;
+ object_class->set_property = shell_search_renderer_set_property;
+ object_class->dispose = shell_search_renderer_dispose;
+ object_class->finalize = shell_search_renderer_finalize;
+
+ cell_renderer->get_size = shell_search_renderer_get_size;
+ cell_renderer->render = shell_search_renderer_render;
+
+ pspec = g_param_spec_string ("title",
+ "Title",
+ "Item title",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_TITLE, pspec);
+
+ pspec = g_param_spec_string ("search-target",
+ "Search Target",
+ "The string that will be searched",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SEARCH_TARGET, pspec);
+
+ pspec = g_param_spec_string ("search-string",
+ "Search String",
+ "Current search string",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SEARCH_STRING, pspec);
+}
+
+static void
+shell_search_renderer_init (ShellSearchRenderer *self)
+{
+ self->priv = SEARCH_RENDERER_PRIVATE (self);
+}
+
+ShellSearchRenderer *
+shell_search_renderer_new (void)
+{
+ return g_object_new (SHELL_TYPE_SEARCH_RENDERER, NULL);
+}
diff --git a/shell/shell-search-renderer.h b/shell/shell-search-renderer.h
new file mode 100644
index 0000000..d0dfd82
--- /dev/null
+++ b/shell/shell-search-renderer.h
@@ -0,0 +1,74 @@
+/*
+ * 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 _SHELL_SEARCH_RENDERER_H
+#define _SHELL_SEARCH_RENDERER_H
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define SHELL_TYPE_SEARCH_RENDERER shell_search_renderer_get_type()
+
+#define SHELL_SEARCH_RENDERER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ SHELL_TYPE_SEARCH_RENDERER, ShellSearchRenderer))
+
+#define SHELL_SEARCH_RENDERER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ SHELL_TYPE_SEARCH_RENDERER, ShellSearchRendererClass))
+
+#define SHELL_IS_SEARCH_RENDERER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ SHELL_TYPE_SEARCH_RENDERER))
+
+#define SHELL_IS_SEARCH_RENDERER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ SHELL_TYPE_SEARCH_RENDERER))
+
+#define SHELL_SEARCH_RENDERER_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ SHELL_TYPE_SEARCH_RENDERER, ShellSearchRendererClass))
+
+typedef struct _ShellSearchRenderer ShellSearchRenderer;
+typedef struct _ShellSearchRendererClass ShellSearchRendererClass;
+typedef struct _ShellSearchRendererPrivate ShellSearchRendererPrivate;
+
+struct _ShellSearchRenderer
+{
+ GtkCellRenderer parent;
+
+ ShellSearchRendererPrivate *priv;
+};
+
+struct _ShellSearchRendererClass
+{
+ GtkCellRendererClass parent_class;
+};
+
+GType shell_search_renderer_get_type (void) G_GNUC_CONST;
+
+ShellSearchRenderer *shell_search_renderer_new (void);
+
+G_END_DECLS
+
+#endif /* _SHELL_SEARCH_RENDERER_H */
diff --git a/shell/shell.ui b/shell/shell.ui
new file mode 100644
index 0000000..57ce5f9
--- /dev/null
+++ b/shell/shell.ui
@@ -0,0 +1,169 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkWindow" id="main-window">
+ <property name="title" translatable="yes">System Settings</property>
+ <property name="default_width">800</property>
+ <property name="default_height">500</property>
+ <property name="icon_name">gnome-control-center</property>
+ <child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkToolbar" id="toolbar1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkToolItem" id="toolbutton1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <child>
+ <object class="GtkButton" id="home-button">
+ <property name="label">_All Settings</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="no_show_all">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="entry-alignment">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="xscale">0</property>
+ <child>
+ <object class="GtkEntry" id="search-entry">
+ <property name="width_request">210</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="primary_icon_stock">gtk-find</property>
+ <property name="secondary_icon_stock">gtk-clear</property>
+ <property name="secondary_icon_activatable">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="title-alignment">
+ <property name="no_show_all">True</property>
+ <property name="top_padding">12</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkLabel" id="label-title">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_tabs">False</property>
+ <property name="show_border">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <object class="GtkViewport" id="viewport1">
+ <property name="visible">True</property>
+ <property name="resize_mode">queue</property>
+ <child>
+ <object class="GtkVBox" id="main-vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="search-scrolled-window">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <object class="GtkListStore" id="liststore">
+ <columns>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name exec -->
+ <column type="gchararray"/>
+ <!-- column-name icon -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkSizeGroup" id="sizegroup">
+ <property name="mode">vertical</property>
+ <widgets>
+ <widget name="home-button"/>
+ <widget name="entry-alignment"/>
+ </widgets>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]