[yast-commit] r65066 - in /trunk/control-center-gnome: ./ etc/ src/ src/cut-n-paste/ src/cut-n-paste/libgnome-control-center/ src/cut-n-paste/shell/ src/patch/
Author: vuntz Date: Thu Jul 28 12:34:32 2011 New Revision: 65066 URL: http://svn.opensuse.org/viewcvs/yast?rev=65066&view=rev Log: 2011-07-28 Vincent Untz <vuntz@gnome.org> Release 2.21.1 Use an internal copy of the libgnome-control-center code since it is going private upstream. * VERSION: bump version. * src/cut-n-paste/libgnome-control-center/: internal copy of the libgnome-control-center code. * src/cut-n-paste/shell/: copy of the unpatched shell code fro gnome-control-center. We build a static library without the code we're going to patch. This will make it easier to update to new upstream code later on since we'll simply copy the new code there. * src/{*.[ch],shell.ui}: simply keep the code we patch here. * src/patch/: move gnome-control-center.patch patch there, and add a update-patch.sh script to easily update the patch file. Added: trunk/control-center-gnome/src/cut-n-paste/ (with props) trunk/control-center-gnome/src/cut-n-paste/Makefile.am trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/ (with props) trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/Makefile.am trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.c trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.h trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.c trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.h trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.c trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.h trunk/control-center-gnome/src/cut-n-paste/shell/ (with props) trunk/control-center-gnome/src/cut-n-paste/shell/Makefile.am trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.c trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.h trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.c trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.h trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.c trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.h trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-marshal.list trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.c trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.h trunk/control-center-gnome/src/cut-n-paste/shell/control-center.c trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.c trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.h trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.c trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.h trunk/control-center-gnome/src/cut-n-paste/shell/shell.ui trunk/control-center-gnome/src/patch/ trunk/control-center-gnome/src/patch/gnome-control-center.patch - copied, changed from r64979, trunk/control-center-gnome/gnome-control-center.patch trunk/control-center-gnome/src/patch/update-patch.sh (with props) Removed: trunk/control-center-gnome/gnome-control-center.patch trunk/control-center-gnome/src/cc-shell-category-view.c trunk/control-center-gnome/src/cc-shell-category-view.h trunk/control-center-gnome/src/cc-shell-item-view.c trunk/control-center-gnome/src/cc-shell-item-view.h trunk/control-center-gnome/src/cc-shell-log.c trunk/control-center-gnome/src/cc-shell-log.h trunk/control-center-gnome/src/cc-shell-marshal.list trunk/control-center-gnome/src/cc-shell-model.c trunk/control-center-gnome/src/cc-shell-model.h trunk/control-center-gnome/src/gnome-control-center.h trunk/control-center-gnome/src/shell-search-renderer.c trunk/control-center-gnome/src/shell-search-renderer.h Modified: trunk/control-center-gnome/ (props changed) trunk/control-center-gnome/ChangeLog trunk/control-center-gnome/VERSION trunk/control-center-gnome/configure.in.in trunk/control-center-gnome/etc/ (props changed) trunk/control-center-gnome/src/ (props changed) trunk/control-center-gnome/src/Makefile.am trunk/control-center-gnome/src/gnome-control-center.c Modified: trunk/control-center-gnome/ChangeLog URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/ChangeLog?rev=65066&r1=65065&r2=65066&view=diff ============================================================================== --- trunk/control-center-gnome/ChangeLog (original) +++ trunk/control-center-gnome/ChangeLog Thu Jul 28 12:34:32 2011 @@ -1,3 +1,21 @@ +2011-07-28 Vincent Untz <vuntz@gnome.org> + + Release 2.21.1 + + Use an internal copy of the libgnome-control-center code since it is + going private upstream. + + * VERSION: bump version. + * src/cut-n-paste/libgnome-control-center/: internal copy of the + libgnome-control-center code. + * src/cut-n-paste/shell/: copy of the unpatched shell code fro + gnome-control-center. We build a static library without the code we're + going to patch. This will make it easier to update to new upstream code + later on since we'll simply copy the new code there. + * src/{*.[ch],shell.ui}: simply keep the code we patch here. + * src/patch/: move gnome-control-center.patch patch there, and add a + update-patch.sh script to easily update the patch file. + 2011-07-25 Vincent Untz <vuntz@gnome.org> Release 2.21.0 Modified: trunk/control-center-gnome/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/VERSION?rev=65066&r1=65065&r2=65066&view=diff ============================================================================== --- trunk/control-center-gnome/VERSION (original) +++ trunk/control-center-gnome/VERSION Thu Jul 28 12:34:32 2011 @@ -1 +1 @@ -2.21.0 +2.21.1 Modified: trunk/control-center-gnome/configure.in.in URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/configure.in.in?rev=65066&r1=65065&r2=65066&view=diff ============================================================================== --- trunk/control-center-gnome/configure.in.in (original) +++ trunk/control-center-gnome/configure.in.in Thu Jul 28 12:34:32 2011 @@ -19,7 +19,7 @@ AC_SUBST(GLIB_GENMARSHAL) -PKG_CHECK_MODULES(CONTROL, gtk+-3.0 libgnome-menu gio-unix-2.0 libgnome-control-center > 3.0) +PKG_CHECK_MODULES(CONTROL, gtk+-3.0 libgnome-menu gio-unix-2.0) AC_SUBST(CONTROL_CFLAGS) AC_SUBST(CONTROL_LIBS) Modified: trunk/control-center-gnome/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/Makefile.am?rev=65066&r1=65065&r2=65066&view=diff ============================================================================== --- trunk/control-center-gnome/src/Makefile.am (original) +++ trunk/control-center-gnome/src/Makefile.am Thu Jul 28 12:34:32 2011 @@ -1,4 +1,11 @@ -INCLUDES = $(CONTROL_CFLAGS) +SUBDIRS = cut-n-paste + +INCLUDES = \ + $(CONTROL_CFLAGS) \ + -I$(srcdir)/cut-n-paste \ + -I$(srcdir)/cut-n-paste/libgnome-control-center \ + -I$(srcdir)/cut-n-paste/shell \ + -I$(top_builddir)/src/cut-n-paste/shell AM_CPPFLAGS = \ -DGETTEXT_PACKAGE="\"gnome-control-center-2.0\"" \ @@ -9,36 +16,17 @@ ybin_PROGRAMS = y2controlcenter-gnome -MARSHAL_FILES = cc-shell-marshal.c cc-shell-marshal.h -BUILT_SOURCES = $(MARSHAL_FILES) - -cc-shell-marshal.h: cc-shell-marshal.list - $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=cc_shell_marshal $< --header > $@ - -cc-shell-marshal.c: cc-shell-marshal.list - $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=cc_shell_marshal $< --body --header > $@ - -y2controlcenter_gnome_SOURCES = \ - control-center.c \ - cc-shell-log.c \ - cc-shell-log.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) - -y2controlcenter_gnome_LDADD = $(CONTROL_LIBS) +y2controlcenter_gnome_SOURCES = \ + control-center.c \ + gnome-control-center.c + +y2controlcenter_gnome_LDADD = \ + $(top_builddir)/src/cut-n-paste/libgnome-control-center/libgnome-control-center.la \ + $(top_builddir)/src/cut-n-paste/shell/libshell-unpatched.la \ + $(CONTROL_LIBS) uidir = $(pkgdatadir)/ui ui_DATA = shell.ui EXTRA_DIST = \ - $(ui_DATA) \ - cc-shell-marshal.list + $(ui_DATA) Added: trunk/control-center-gnome/src/cut-n-paste/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/Makefile.am?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/Makefile.am (added) +++ trunk/control-center-gnome/src/cut-n-paste/Makefile.am Thu Jul 28 12:34:32 2011 @@ -0,0 +1 @@ +SUBDIRS = libgnome-control-center shell Added: trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/Makefile.am?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/Makefile.am (added) +++ trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/Makefile.am Thu Jul 28 12:34:32 2011 @@ -0,0 +1,14 @@ +NULL = + +noinst_LTLIBRARIES = libgnome-control-center.la + +AM_CPPFLAGS = $(CONTROL_CFLAGS) + +libgnome_control_center_la_SOURCES = \ + cc-panel.c \ + cc-panel.h \ + cc-shell.c \ + cc-shell.h \ + cc-editable-entry.c \ + cc-editable-entry.h \ + $(NULL) Added: trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,546 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright 2009-2010 Red Hat, 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 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Written by: Matthias Clasen <mclasen@redhat.com> + */ + +#include <gdk/gdkkeysyms.h> +#include "cc-editable-entry.h" + +#define EMPTY_TEXT "\xe2\x80\x94" + +struct _CcEditableEntryPrivate { + GtkNotebook *notebook; + GtkLabel *label; + GtkButton *button; + GtkEntry *entry; + + gchar *text; + gboolean editable; + gboolean selectable; + gint weight; + gboolean weight_set; + gdouble scale; + gboolean scale_set; + + gboolean in_stop_editing; +}; + +#define CC_EDITABLE_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TYPE_EDITABLE_ENTRY, CcEditableEntryPrivate)) + +enum { + PROP_0, + PROP_TEXT, + PROP_EDITABLE, + PROP_SELECTABLE, + PROP_SCALE, + PROP_SCALE_SET, + PROP_WEIGHT, + PROP_WEIGHT_SET +}; + +enum { + EDITING_DONE, + LAST_SIGNAL +}; + +enum { + PAGE_LABEL, + PAGE_BUTTON, + PAGE_ENTRY +}; + +static guint signals [LAST_SIGNAL] = { 0, }; + +G_DEFINE_TYPE (CcEditableEntry, cc_editable_entry, GTK_TYPE_ALIGNMENT); + +void +cc_editable_entry_set_text (CcEditableEntry *e, + const gchar *text) +{ + CcEditableEntryPrivate *priv; + gchar *tmp; + GtkWidget *label; + + priv = e->priv; + + tmp = g_strdup (text); + g_free (priv->text); + priv->text = tmp; + + gtk_entry_set_text (priv->entry, tmp); + + if (tmp == NULL || tmp[0] == '\0') + tmp = EMPTY_TEXT; + + gtk_label_set_text (priv->label, tmp); + label = gtk_bin_get_child (GTK_BIN (priv->button)); + gtk_label_set_text (GTK_LABEL (label), tmp); + + g_object_notify (G_OBJECT (e), "text"); +} + +const gchar * +cc_editable_entry_get_text (CcEditableEntry *e) +{ + return e->priv->text; +} + +void +cc_editable_entry_set_editable (CcEditableEntry *e, + gboolean editable) +{ + CcEditableEntryPrivate *priv; + + priv = e->priv; + + if (priv->editable != editable) { + priv->editable = editable; + + gtk_notebook_set_current_page (priv->notebook, editable ? PAGE_BUTTON : PAGE_LABEL); + + g_object_notify (G_OBJECT (e), "editable"); + } +} + +gboolean +cc_editable_entry_get_editable (CcEditableEntry *e) +{ + return e->priv->editable; +} + +void +cc_editable_entry_set_selectable (CcEditableEntry *e, + gboolean selectable) +{ + CcEditableEntryPrivate *priv; + + priv = e->priv; + + if (priv->selectable != selectable) { + priv->selectable = selectable; + + gtk_label_set_selectable (priv->label, selectable); + + g_object_notify (G_OBJECT (e), "selectable"); + } +} + +gboolean +cc_editable_entry_get_selectable (CcEditableEntry *e) +{ + return e->priv->selectable; +} + +static void +update_entry_font (GtkWidget *widget, + CcEditableEntry *e) +{ + CcEditableEntryPrivate *priv = e->priv; + PangoFontDescription *desc; + GtkStyleContext *style; + gint size; + + if (!priv->weight_set && !priv->scale_set) + return; + + g_signal_handlers_block_by_func (widget, update_entry_font, e); + + gtk_widget_override_font (widget, NULL); + + style = gtk_widget_get_style_context (widget); + desc = pango_font_description_copy + (gtk_style_context_get_font (style, gtk_widget_get_state_flags (widget))); + + if (priv->weight_set) + pango_font_description_set_weight (desc, priv->weight); + if (priv->scale_set) { + size = pango_font_description_get_size (desc); + pango_font_description_set_size (desc, priv->scale * size); + } + gtk_widget_override_font (widget, desc); + + pango_font_description_free (desc); + + g_signal_handlers_unblock_by_func (widget, update_entry_font, e); +} + +static void +update_fonts (CcEditableEntry *e) +{ + PangoAttrList *attrs; + PangoAttribute *attr; + GtkWidget *label; + + CcEditableEntryPrivate *priv = e->priv; + + attrs = pango_attr_list_new (); + if (priv->scale_set) { + attr = pango_attr_scale_new (priv->scale); + pango_attr_list_insert (attrs, attr); + } + if (priv->weight_set) { + attr = pango_attr_weight_new (priv->weight); + pango_attr_list_insert (attrs, attr); + } + + gtk_label_set_attributes (priv->label, attrs); + + label = gtk_bin_get_child (GTK_BIN (priv->button)); + gtk_label_set_attributes (GTK_LABEL (label), attrs); + + pango_attr_list_unref (attrs); + + update_entry_font ((GtkWidget *)priv->entry, e); +} + +void +cc_editable_entry_set_weight (CcEditableEntry *e, + gint weight) +{ + CcEditableEntryPrivate *priv = e->priv; + + if (priv->weight == weight && priv->weight_set) + return; + + priv->weight = weight; + priv->weight_set = TRUE; + + update_fonts (e); + + g_object_notify (G_OBJECT (e), "weight"); + g_object_notify (G_OBJECT (e), "weight-set"); +} + +gint +cc_editable_entry_get_weight (CcEditableEntry *e) +{ + return e->priv->weight; +} + +void +cc_editable_entry_set_scale (CcEditableEntry *e, + gdouble scale) +{ + CcEditableEntryPrivate *priv = e->priv; + + if (priv->scale == scale && priv->scale_set) + return; + + priv->scale = scale; + priv->scale_set = TRUE; + + update_fonts (e); + + g_object_notify (G_OBJECT (e), "scale"); + g_object_notify (G_OBJECT (e), "scale-set"); +} + +gdouble +cc_editable_entry_get_scale (CcEditableEntry *e) +{ + return e->priv->scale; +} + +static void +cc_editable_entry_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + CcEditableEntry *e = CC_EDITABLE_ENTRY (object); + + switch (prop_id) { + case PROP_TEXT: + cc_editable_entry_set_text (e, g_value_get_string (value)); + break; + case PROP_EDITABLE: + cc_editable_entry_set_editable (e, g_value_get_boolean (value)); + break; + case PROP_SELECTABLE: + cc_editable_entry_set_selectable (e, g_value_get_boolean (value)); + break; + case PROP_WEIGHT: + cc_editable_entry_set_weight (e, g_value_get_int (value)); + break; + case PROP_WEIGHT_SET: + e->priv->weight_set = g_value_get_boolean (value); + break; + case PROP_SCALE: + cc_editable_entry_set_scale (e, g_value_get_double (value)); + break; + case PROP_SCALE_SET: + e->priv->scale_set = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +cc_editable_entry_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + CcEditableEntry *e = CC_EDITABLE_ENTRY (object); + + switch (prop_id) { + case PROP_TEXT: + g_value_set_string (value, + cc_editable_entry_get_text (e)); + break; + case PROP_EDITABLE: + g_value_set_boolean (value, + cc_editable_entry_get_editable (e)); + break; + case PROP_SELECTABLE: + g_value_set_boolean (value, + cc_editable_entry_get_selectable (e)); + break; + case PROP_WEIGHT: + g_value_set_int (value, + cc_editable_entry_get_weight (e)); + break; + case PROP_WEIGHT_SET: + g_value_set_boolean (value, e->priv->weight_set); + break; + case PROP_SCALE: + g_value_set_double (value, + cc_editable_entry_get_scale (e)); + break; + case PROP_SCALE_SET: + g_value_set_boolean (value, e->priv->scale_set); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +cc_editable_entry_finalize (GObject *object) +{ + CcEditableEntry *e = (CcEditableEntry*)object; + + g_free (e->priv->text); + + G_OBJECT_CLASS (cc_editable_entry_parent_class)->finalize (object); +} + +static void +cc_editable_entry_class_init (CcEditableEntryClass *class) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (class); + + object_class->set_property = cc_editable_entry_set_property; + object_class->get_property = cc_editable_entry_get_property; + object_class->finalize = cc_editable_entry_finalize; + + signals[EDITING_DONE] = + g_signal_new ("editing-done", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CcEditableEntryClass, editing_done), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + g_object_class_install_property (object_class, PROP_TEXT, + g_param_spec_string ("text", + "Text", "The text of the button", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_EDITABLE, + g_param_spec_boolean ("editable", + "Editable", "Whether the text can be edited", + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_SELECTABLE, + g_param_spec_boolean ("selectable", + "Selectable", "Whether the text can be selected by mouse", + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_WEIGHT, + g_param_spec_int ("weight", + "Font Weight", "The font weight to use", + 0, G_MAXINT, PANGO_WEIGHT_NORMAL, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_WEIGHT_SET, + g_param_spec_boolean ("weight-set", + "Font Weight Set", "Whether a font weight is set", + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_SCALE, + g_param_spec_double ("scale", + "Font Scale", "The font scale to use", + 0.0, G_MAXDOUBLE, 1.0, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_SCALE_SET, + g_param_spec_boolean ("scale-set", + "Font Scale Set", "Whether a font scale is set", + FALSE, + G_PARAM_READWRITE)); + + g_type_class_add_private (class, sizeof (CcEditableEntryPrivate)); +} + +static void +start_editing (CcEditableEntry *e) +{ + gtk_notebook_set_current_page (e->priv->notebook, PAGE_ENTRY); +} + +static void +stop_editing (CcEditableEntry *e) +{ + /* Avoid launching another "editing-done" signal + * caused by the notebook page change */ + if (e->priv->in_stop_editing) + return; + + e->priv->in_stop_editing = TRUE; + gtk_notebook_set_current_page (e->priv->notebook, PAGE_BUTTON); + cc_editable_entry_set_text (e, gtk_entry_get_text (e->priv->entry)); + g_signal_emit (e, signals[EDITING_DONE], 0); + e->priv->in_stop_editing = FALSE; +} + +static void +cancel_editing (CcEditableEntry *e) +{ + gtk_entry_set_text (e->priv->entry, cc_editable_entry_get_text (e)); + gtk_notebook_set_current_page (e->priv->notebook, PAGE_BUTTON); +} + +static void +button_clicked (GtkWidget *widget, + CcEditableEntry *e) +{ + start_editing (e); +} + +static void +entry_activated (GtkWidget *widget, + CcEditableEntry *e) +{ + stop_editing (e); +} + +static gboolean +entry_focus_out (GtkWidget *widget, + GdkEventFocus *event, + CcEditableEntry *e) +{ + stop_editing (e); + return FALSE; +} + +static gboolean +entry_key_press (GtkWidget *widget, + GdkEventKey *event, + CcEditableEntry *e) +{ + if (event->keyval == GDK_KEY_Escape) { + cancel_editing (e); + } + return FALSE; +} + +static void +update_button_padding (GtkWidget *widget, + GtkAllocation *allocation, + CcEditableEntry *e) +{ + CcEditableEntryPrivate *priv = e->priv; + GtkAllocation alloc; + gint offset; + gint pad; + + gtk_widget_get_allocation (gtk_widget_get_parent (widget), &alloc); + + offset = allocation->x - alloc.x; + + gtk_misc_get_padding (GTK_MISC (priv->label), &pad, NULL); + if (offset != pad) + gtk_misc_set_padding (GTK_MISC (priv->label), offset, 0); +} + +static void +cc_editable_entry_init (CcEditableEntry *e) +{ + CcEditableEntryPrivate *priv; + + priv = e->priv = CC_EDITABLE_ENTRY_GET_PRIVATE (e); + + priv->weight = PANGO_WEIGHT_NORMAL; + priv->weight_set = FALSE; + priv->scale = 1.0; + priv->scale_set = FALSE; + + priv->notebook = (GtkNotebook*)gtk_notebook_new (); + gtk_notebook_set_show_tabs (priv->notebook, FALSE); + gtk_notebook_set_show_border (priv->notebook, FALSE); + + /* Label */ + priv->label = (GtkLabel*)gtk_label_new (EMPTY_TEXT); + gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); + gtk_notebook_append_page (priv->notebook, (GtkWidget*)priv->label, NULL); + + /* Button */ + priv->button = (GtkButton*)gtk_button_new_with_label (EMPTY_TEXT); + gtk_widget_set_receives_default ((GtkWidget*)priv->button, TRUE); + gtk_button_set_relief (priv->button, GTK_RELIEF_NONE); + gtk_button_set_alignment (priv->button, 0.0, 0.5); + gtk_notebook_append_page (priv->notebook, (GtkWidget*)priv->button, NULL); + g_signal_connect (priv->button, "clicked", G_CALLBACK (button_clicked), e); + + /* Entry */ + priv->entry = (GtkEntry*)gtk_entry_new (); + gtk_notebook_append_page (priv->notebook, (GtkWidget*)priv->entry, NULL); + + g_signal_connect (priv->entry, "activate", G_CALLBACK (entry_activated), e); + g_signal_connect (priv->entry, "focus-out-event", G_CALLBACK (entry_focus_out), e); + g_signal_connect (priv->entry, "key-press-event", G_CALLBACK (entry_key_press), e); + g_signal_connect (priv->entry, "style-updated", G_CALLBACK (update_entry_font), e); + g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->button)), "size-allocate", G_CALLBACK (update_button_padding), e); + + gtk_container_add (GTK_CONTAINER (e), (GtkWidget*)priv->notebook); + + gtk_widget_show ((GtkWidget*)priv->notebook); + gtk_widget_show ((GtkWidget*)priv->label); + gtk_widget_show ((GtkWidget*)priv->button); + gtk_widget_show ((GtkWidget*)priv->entry); + + gtk_notebook_set_current_page (priv->notebook, PAGE_LABEL); +} + +GtkWidget * +cc_editable_entry_new (void) +{ + return (GtkWidget *) g_object_new (CC_TYPE_EDITABLE_ENTRY, NULL); +} Added: trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-editable-entry.h Thu Jul 28 12:34:32 2011 @@ -0,0 +1,75 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright 2009-2010 Red Hat, 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 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Written by: Matthias Clasen <mclasen@redhat.com> + */ + +#ifndef _CC_EDITABLE_ENTRY_H_ +#define _CC_EDITABLE_ENTRY_H_ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define CC_TYPE_EDITABLE_ENTRY cc_editable_entry_get_type() + +#define CC_EDITABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_EDITABLE_ENTRY, CcEditableEntry)) +#define CC_EDITABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_EDITABLE_ENTRY, CcEditableEntryClass)) +#define CC_IS_EDITABLE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_EDITABLE_ENTRY)) +#define CC_IS_EDITABLE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_EDITABLE_ENTRY)) +#define CC_EDITABLE_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_EDITABLE_ENTRY, CcEditableEntryClass)) + +typedef struct _CcEditableEntry CcEditableEntry; +typedef struct _CcEditableEntryClass CcEditableEntryClass; +typedef struct _CcEditableEntryPrivate CcEditableEntryPrivate; + +struct _CcEditableEntry +{ + GtkAlignment parent; + + CcEditableEntryPrivate *priv; +}; + +struct _CcEditableEntryClass +{ + GtkAlignmentClass parent_class; + + void (* editing_done) (CcEditableEntry *entry); +}; + +GType cc_editable_entry_get_type (void) G_GNUC_CONST; +GtkWidget *cc_editable_entry_new (void); +void cc_editable_entry_set_text (CcEditableEntry *entry, + const gchar *text); +const gchar *cc_editable_entry_get_text (CcEditableEntry *entry); +void cc_editable_entry_set_editable (CcEditableEntry *entry, + gboolean editable); +gboolean cc_editable_entry_get_editable (CcEditableEntry *entry); +void cc_editable_entry_set_selectable (CcEditableEntry *entry, + gboolean selectable); +gboolean cc_editable_entry_get_selectable (CcEditableEntry *entry); +void cc_editable_entry_set_weight (CcEditableEntry *entry, + gint weight); +gint cc_editable_entry_get_weight (CcEditableEntry *entry); +void cc_editable_entry_set_scale (CcEditableEntry *entry, + gdouble scale); +gdouble cc_editable_entry_get_scale (CcEditableEntry *entry); + +G_END_DECLS + +#endif /* _CC_EDITABLE_ENTRY_H_ */ Added: trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,233 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2010 Red Hat, Inc. + * 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. + * + * Authors: William Jon McCann <jmccann@redhat.com> + * Thomas Wood <thomas.wood@intel.com> + * + */ + +/** + * SECTION:cc-panel + * @short_description: An abstract class for Control Center panels + * + * CcPanel is an abstract class used to implement panels for the shell. A + * panel contains a collection of related settings that are displayed within + * the shell window. + */ + +#include "config.h" + +#include "cc-panel.h" + +#include <stdlib.h> +#include <stdio.h> + +#include <gtk/gtk.h> +#include <gio/gio.h> + +#define CC_PANEL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_PANEL, CcPanelPrivate)) + +struct CcPanelPrivate +{ + gchar *id; + gchar *display_name; + gchar *category; + gchar *current_location; + + gboolean is_active; + CcShell *shell; +}; + +enum +{ + PROP_0, + PROP_SHELL, +}; + +G_DEFINE_ABSTRACT_TYPE (CcPanel, cc_panel, GTK_TYPE_BIN) + +static void +cc_panel_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + CcPanel *panel; + + panel = CC_PANEL (object); + + switch (prop_id) + { + case PROP_SHELL: + /* construct only property */ + panel->priv->shell = g_value_get_object (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +cc_panel_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + CcPanel *panel; + + panel = CC_PANEL (object); + + switch (prop_id) + { + case PROP_SHELL: + g_value_set_object (value, panel->priv->shell); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +cc_panel_finalize (GObject *object) +{ + CcPanel *panel; + + g_return_if_fail (object != NULL); + g_return_if_fail (CC_IS_PANEL (object)); + + panel = CC_PANEL (object); + + g_free (panel->priv->id); + g_free (panel->priv->display_name); + + G_OBJECT_CLASS (cc_panel_parent_class)->finalize (object); +} + +static void +cc_panel_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + GtkBin *bin = GTK_BIN (widget); + GtkWidget *child; + + if (minimum != NULL) + *minimum = 0; + + if (natural != NULL) + *natural = 0; + + if ((child = gtk_bin_get_child (bin))) + gtk_widget_get_preferred_width (child, minimum, natural); +} + +static void +cc_panel_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + GtkBin *bin = GTK_BIN (widget); + GtkWidget *child; + + if (minimum != NULL) + *minimum = 0; + + if (natural != NULL) + *natural = 0; + + if ((child = gtk_bin_get_child (bin))) + gtk_widget_get_preferred_height (child, minimum, natural); +} + +static void +cc_panel_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkAllocation child_allocation; + + gtk_widget_set_allocation (widget, allocation); + + child_allocation = *allocation; + + gtk_widget_size_allocate (gtk_bin_get_child (GTK_BIN (widget)), + &child_allocation); +} + +static void +cc_panel_class_init (CcPanelClass *klass) +{ + GParamSpec *pspec; + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + object_class->get_property = cc_panel_get_property; + object_class->set_property = cc_panel_set_property; + object_class->finalize = cc_panel_finalize; + + widget_class->get_preferred_width = cc_panel_get_preferred_width; + widget_class->get_preferred_height = cc_panel_get_preferred_height; + widget_class->size_allocate = cc_panel_size_allocate; + + gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (klass)); + + g_type_class_add_private (klass, sizeof (CcPanelPrivate)); + + pspec = g_param_spec_object ("shell", + "Shell", + "Shell the Panel resides in", + CC_TYPE_SHELL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS + | G_PARAM_CONSTRUCT_ONLY); + g_object_class_install_property (object_class, PROP_SHELL, pspec); +} + +static void +cc_panel_init (CcPanel *panel) +{ + panel->priv = CC_PANEL_GET_PRIVATE (panel); +} + +/** + * cc_panel_get_shell: + * @panel: A #CcPanel + * + * Get the shell that the panel resides in + * + * Returns: a #CcShell + */ +CcShell * +cc_panel_get_shell (CcPanel *panel) +{ + return panel->priv->shell; +} + +GPermission * +cc_panel_get_permission (CcPanel *panel) +{ + CcPanelClass *class = CC_PANEL_GET_CLASS (panel); + + if (class->get_permission) + return class->get_permission (panel); + + return NULL; +} Added: trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-panel.h Thu Jul 28 12:34:32 2011 @@ -0,0 +1,81 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2010 Red Hat, Inc. + * 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. + * + * Authors: William Jon McCann <jmccann@redhat.com> + * Thomas Wood <thomas.wood@intel.com> + */ + + +#ifndef __CC_PANEL_H +#define __CC_PANEL_H + +#include <glib-object.h> +#include <gtk/gtk.h> + + +G_BEGIN_DECLS + +#define CC_TYPE_PANEL (cc_panel_get_type ()) +#define CC_PANEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_PANEL, CcPanel)) +#define CC_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_PANEL, CcPanelClass)) +#define CC_IS_PANEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_PANEL)) +#define CC_IS_PANEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_PANEL)) +#define CC_PANEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_PANEL, CcPanelClass)) + +typedef struct CcPanelPrivate CcPanelPrivate; + +typedef struct _CcPanel CcPanel; +typedef struct _CcPanelClass CcPanelClass; + +/* cc-shell.h requires CcPanel, so make sure it is defined first */ +#include "cc-shell.h" + +/** + * CcPanel: + * + * The contents of this struct are private and should not be accessed directly. + */ +struct _CcPanel +{ + /*< private >*/ + GtkBin parent; + CcPanelPrivate *priv; +}; +/** + * CcPanelClass: + * + * The contents of this struct are private and should not be accessed directly. + */ +struct _CcPanelClass +{ + /*< private >*/ + GtkBinClass parent_class; + + GPermission * (* get_permission) (CcPanel *panel); +}; + +GType cc_panel_get_type (void); + +CcShell* cc_panel_get_shell (CcPanel *panel); + +GPermission *cc_panel_get_permission (CcPanel *panel); + +G_END_DECLS + +#endif /* __CC_PANEL_H */ Added: trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,237 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * 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> + */ + +/** + * SECTION:cc-shell + * @short_description: Abstract class representing the Control Center shell + * + * CcShell is an abstract class that represents an instance of a control + * center shell. It provides access to some of the properties of the shell + * that panels will need to read or change. When a panel is created it has an + * instance of CcShell available that represents the current shell. + */ + + +#include "cc-shell.h" +#include "cc-panel.h" + +G_DEFINE_ABSTRACT_TYPE (CcShell, cc_shell, G_TYPE_OBJECT) + +#define SHELL_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_SHELL, CcShellPrivate)) + +struct _CcShellPrivate +{ + CcPanel *active_panel; +}; + +enum +{ + PROP_ACTIVE_PANEL = 1 +}; + + +static void +cc_shell_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + CcShell *shell = CC_SHELL (object); + + switch (property_id) + { + case PROP_ACTIVE_PANEL: + g_value_set_object (value, shell->priv->active_panel); + break; + + 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) +{ + CcShell *shell = CC_SHELL (object); + + switch (property_id) + { + case PROP_ACTIVE_PANEL: + cc_shell_set_active_panel (shell, g_value_get_object (value)); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +cc_shell_dispose (GObject *object) +{ + /* remove and unref the active shell */ + cc_shell_set_active_panel (CC_SHELL (object), NULL); + + G_OBJECT_CLASS (cc_shell_parent_class)->dispose (object); +} + +static void +cc_shell_class_init (CcShellClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GParamSpec *pspec; + + 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; + + pspec = g_param_spec_object ("active-panel", + "active panel", + "The currently active Panel", + CC_TYPE_PANEL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_ACTIVE_PANEL, pspec); +} + +static void +cc_shell_init (CcShell *self) +{ + self->priv = SHELL_PRIVATE (self); +} + +/** + * cc_shell_get_active_panel: + * @shell: A #CcShell + * + * Get the current active panel + * + * Returns: a #CcPanel or NULL if no panel is active + */ +CcPanel* +cc_shell_get_active_panel (CcShell *shell) +{ + g_return_val_if_fail (CC_IS_SHELL (shell), NULL); + + return shell->priv->active_panel; +} + +/** + * cc_shell_set_active_panel: + * @shell: A #CcShell + * @panel: A #CcPanel + * + * Set the current active panel. If @panel is NULL, then the shell is returned + * to a state where no panel is being displayed (for example, the list of panels + * may be shown instead). + * + */ +void +cc_shell_set_active_panel (CcShell *shell, + CcPanel *panel) +{ + g_return_if_fail (CC_IS_SHELL (shell)); + g_return_if_fail (panel == NULL || CC_IS_PANEL (panel)); + + if (panel != shell->priv->active_panel) + { + /* remove the old panel */ + g_object_unref (shell->priv->active_panel); + shell->priv->active_panel = NULL; + + /* set the new panel */ + if (panel) + { + shell->priv->active_panel = g_object_ref (panel); + g_object_set (G_OBJECT (panel), "shell", shell, NULL); + } + g_object_notify (G_OBJECT (shell), "active-panel"); + } +} + +/** + * cc_shell_set_active_panel_from_id: + * @shell: A #CcShell + * @id: the ID of the panel to set as active + * @error: A #GError + * + * Find a panel corresponding to the specified id and set it as active. + * + * Returns: #TRUE if the panel was found and set as the active panel + */ +gboolean +cc_shell_set_active_panel_from_id (CcShell *shell, + const gchar *id, + GError **error) +{ + CcShellClass *class; + + g_return_val_if_fail (CC_IS_SHELL (shell), FALSE); + + + class = (CcShellClass *) G_OBJECT_GET_CLASS (shell); + + if (!class->set_active_panel_from_id) + { + g_warning ("Object of type \"%s\" does not implement required virtual" + " function \"set_active_panel_from_id\",", + G_OBJECT_TYPE_NAME (shell)); + return FALSE; + } + else + { + return class->set_active_panel_from_id (shell, id, error); + } +} + +/** + * cc_shell_get_toplevel: + * @shell: A #CcShell + * + * Gets the toplevel window of the shell. + * + * Returns: The #GtkWidget of the shell window, or #NULL on error. + */ +GtkWidget * +cc_shell_get_toplevel (CcShell *shell) +{ + CcShellClass *klass; + + g_return_val_if_fail (CC_IS_SHELL (shell), NULL); + + klass = CC_SHELL_GET_CLASS (shell); + + if (klass->get_toplevel) + { + return klass->get_toplevel (shell); + } + + g_warning ("Object of type \"%s\" does not implement required virtual" + " function \"get_toplevel\",", + G_OBJECT_TYPE_NAME (shell)); + + return NULL; +} + Added: trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/libgnome-control-center/cc-shell.h Thu Jul 28 12:34:32 2011 @@ -0,0 +1,105 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * 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 <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)) + + +#define CC_SHELL_PANEL_EXTENSION_POINT "control-center-1" + +typedef struct _CcShell CcShell; +typedef struct _CcShellClass CcShellClass; +typedef struct _CcShellPrivate CcShellPrivate; + +/* cc-panel.h requires CcShell, so make sure they are defined first */ +#include "cc-panel.h" + +/** + * CcShell: + * + * The contents of this struct are private should not be accessed directly. + */ +struct _CcShell +{ + /*< private >*/ + GObject parent; + + CcShellPrivate *priv; +}; + +/** + * CcShellClass: + * @set_active_panel_from_id: virtual function to set the active panel from an + * id string + * + */ +struct _CcShellClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< public >*/ + /* vfuncs */ + gboolean (*set_active_panel_from_id) (CcShell *shell, + const gchar *id, + GError **error); + GtkWidget * (*get_toplevel) (CcShell *shell); +}; + +GType cc_shell_get_type (void) G_GNUC_CONST; + +CcPanel* cc_shell_get_active_panel (CcShell *shell); +void cc_shell_set_active_panel (CcShell *shell, + CcPanel *panel); +gboolean cc_shell_set_active_panel_from_id (CcShell *shell, + const gchar *id, + GError **error); +GtkWidget * cc_shell_get_toplevel (CcShell *shell); + +G_END_DECLS + +#endif /* _CC_SHELL_H */ Added: trunk/control-center-gnome/src/cut-n-paste/shell/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/Makefile.am?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/Makefile.am (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/Makefile.am Thu Jul 28 12:34:32 2011 @@ -0,0 +1,32 @@ +noinst_LTLIBRARIES = libshell-unpatched.la + +INCLUDES = \ + $(CONTROL_CFLAGS) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/cut-n-paste/libgnome-control-center + +MARSHAL_FILES = cc-shell-marshal.c cc-shell-marshal.h +BUILT_SOURCES = $(MARSHAL_FILES) + +cc-shell-marshal.h: cc-shell-marshal.list + $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=cc_shell_marshal $< --header > $@ + +cc-shell-marshal.c: cc-shell-marshal.list + $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=cc_shell_marshal $< --body --header > $@ + +libshell_unpatched_la_SOURCES = \ + cc-shell-log.c \ + cc-shell-log.h \ + 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) + +EXTRA_DIST = \ + cc-shell-marshal.list Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,261 @@ +/* + * 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 "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 *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 +label_style_set_cb (GtkWidget *widget, + GtkStyle *old_style, + gpointer user_data) +{ + GtkStyle *style; + + /* "base" colours are used for the background inside CcShellCategoryView, + * so set the labels to use the "text" colors */ + + g_signal_handlers_block_by_func (widget, label_style_set_cb, NULL); + + style = gtk_widget_get_style (widget); + + gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, + &style->text[GTK_STATE_NORMAL]); + + g_signal_handlers_unblock_by_func (widget, label_style_set_cb, NULL); +} + + + +static void +cc_shell_category_view_constructed (GObject *object) +{ + CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (object)->priv; + GtkWidget *iconview, *vbox; + + 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), 100); + cc_shell_item_view_update_cells (CC_SHELL_ITEM_VIEW (iconview)); + + /* create the header if required */ + if (priv->name) + { + GtkWidget *label; + PangoAttrList *attrs; + + label = gtk_label_new (priv->name); + attrs = pango_attr_list_new (); + pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); + gtk_label_set_attributes (GTK_LABEL (label), attrs); + pango_attr_list_unref (attrs); + gtk_frame_set_label_widget (GTK_FRAME (object), label); + + g_signal_connect (label, "style-set", G_CALLBACK (label_style_set_cb), + NULL); + } + + /* 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 gboolean +cc_shell_category_view_draw (GtkWidget *widget, + cairo_t *cr) +{ + GtkStyle *style; + GtkStateType state; + GtkAllocation allocation; + + style = gtk_widget_get_style (widget); + state = gtk_widget_get_state (widget); + gtk_widget_get_allocation (widget, &allocation); + + + cairo_rectangle (cr, 0, 0, allocation.width, allocation.height); + gdk_cairo_set_source_color (cr, &style->base[state]); + + cairo_fill (cr); + + GTK_WIDGET_CLASS (cc_shell_category_view_parent_class)->draw (widget, cr); + + return FALSE; +} + +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->draw = cc_shell_category_view_draw; + + 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; +} Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-category-view.h Thu Jul 28 12:34:32 2011 @@ -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 */ Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,215 @@ +/* + * 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); +} + +void +cc_shell_item_view_update_cells (CcShellItemView *view) +{ + GList *cells, *l; + + cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (view)); + for (l = cells ; l != NULL; l = l->next) + { + GtkCellRenderer *cell = l->data; + + if (GTK_IS_CELL_RENDERER_TEXT (cell)) { + g_object_set (G_OBJECT (cell), + "wrap-mode", PANGO_WRAP_WORD, + NULL); + /* We only have one text cell */ + break; + } + } +} + +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_object_set (self, "margin", 0, NULL); + 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); +} Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-item-view.h Thu Jul 28 12:34:32 2011 @@ -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 _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); + +void cc_shell_item_view_update_cells (CcShellItemView *view); + +G_END_DECLS + +#endif /* _CC_SHELL_ITEM_VIEW_H */ Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2009 Red Hat, 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. + * + */ + + +#include "config.h" + +#include <glib.h> +#include <glib/gstdio.h> + +#include "cc-shell-log.h" + +static int log_levels = G_LOG_LEVEL_CRITICAL | + G_LOG_LEVEL_ERROR | + G_LOG_LEVEL_WARNING | + G_LOG_LEVEL_MESSAGE | + G_LOG_LEVEL_INFO | + G_LOG_LEVEL_DEBUG; + +static void +cc_shell_log_default_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data) +{ + if ((log_level & log_levels) == 0) + return; + + g_log_default_handler (log_domain, log_level, message, unused_data); +} + +void +cc_shell_log_init (void) +{ + g_log_set_default_handler (cc_shell_log_default_handler, NULL); +} + +void +cc_shell_log_set_debug (gboolean debug) +{ + if (debug) { + log_levels |= (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO); + g_debug ("Enabling debugging"); + } else { + log_levels &= ~ (G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_INFO); + } +} Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-log.h Thu Jul 28 12:34:32 2011 @@ -0,0 +1,33 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2009 Red Hat, 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. + * + */ + +#ifndef __CC_SHELL_LOG_H +#define __CC_SHELL_LOG_H + +#include <glib.h> + +G_BEGIN_DECLS + +void cc_shell_log_init (void); +void cc_shell_log_set_debug (gboolean debug); + +G_END_DECLS + +#endif /* __CC_SHELL_LOG_H */ Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-marshal.list URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-marshal.list?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-marshal.list (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-marshal.list Thu Jul 28 12:34:32 2011 @@ -0,0 +1 @@ +VOID:STRING,STRING,STRING Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,223 @@ +/* + * 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> + +#define GNOME_SETTINGS_PANEL_ID_KEY "X-GNOME-Settings-Panel" +#define GNOME_SETTINGS_PANEL_CATEGORY GNOME_SETTINGS_PANEL_ID_KEY +#define GNOME_SETTINGS_PANEL_ID_KEYWORDS "X-GNOME-Keywords" + + +G_DEFINE_TYPE (CcShellModel, cc_shell_model, GTK_TYPE_LIST_STORE) + +static GdkPixbuf * +load_pixbuf_for_string (const char *icon) +{ + GtkIconTheme *theme; + GdkPixbuf *pixbuf; + GError *err = NULL; + char *icon2 = NULL; + + if (icon == NULL) + return NULL; + + theme = gtk_icon_theme_get_default (); + + /* find the icon */ + if (*icon == '/') + { + pixbuf = gdk_pixbuf_new_from_file_at_scale (icon, 32, 32, TRUE, &err); + } + else + { + if (g_str_has_suffix (icon, ".png")) + icon2 = g_strndup (icon, strlen (icon) - strlen (".png")); + + pixbuf = gtk_icon_theme_load_icon (theme, + 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); + + return pixbuf; +} + +static void +icon_theme_changed (GtkIconTheme *theme, + CcShellModel *self) +{ + GtkTreeIter iter; + GtkTreeModel *model; + gboolean cont; + + model = GTK_TREE_MODEL (self); + cont = gtk_tree_model_get_iter_first (model, &iter); + while (cont) + { + GdkPixbuf *pixbuf; + char *icon; + + gtk_tree_model_get (model, &iter, + COL_ICON_NAME, &icon, + -1); + pixbuf = load_pixbuf_for_string (icon); + g_free (icon); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + COL_PIXBUF, pixbuf, + -1); + + cont = gtk_tree_model_iter_next (model, &iter); + } +} + +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, G_TYPE_STRING, G_TYPE_STRV}; + + gtk_list_store_set_column_types (GTK_LIST_STORE (self), + N_COLS, types); + + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self), COL_NAME, + GTK_SORT_ASCENDING); + + g_signal_connect (G_OBJECT (gtk_icon_theme_get_default ()), "changed", + G_CALLBACK (icon_theme_changed), self); +} + +CcShellModel * +cc_shell_model_new (void) +{ + return g_object_new (CC_TYPE_SHELL_MODEL, NULL); +} + +static gboolean +desktop_entry_has_panel_category (GKeyFile *key_file) +{ + char **strv; + gsize len; + int i; + + strv = g_key_file_get_string_list (key_file, + "Desktop Entry", + "Categories", + &len, + NULL); + if (!strv) + return FALSE; + + for (i = 0; strv[i]; i++) + { + if (g_str_equal (strv[i], GNOME_SETTINGS_PANEL_CATEGORY)) + { + g_strfreev (strv); + return TRUE; + } + } + + g_strfreev (strv); + + return FALSE; + +} + +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 *desktop = gmenu_tree_entry_get_desktop_file_path (item); + const gchar *comment = gmenu_tree_entry_get_comment (item); + gchar *id; + GdkPixbuf *pixbuf = NULL; + gchar *search_target; + GKeyFile *key_file; + gchar **keywords; + + /* load the .desktop file since gnome-menus doesn't have a way to read + * custom properties from desktop files */ + + key_file = g_key_file_new (); + g_key_file_load_from_file (key_file, desktop, 0, NULL); + + id = g_key_file_get_string (key_file, "Desktop Entry", + GNOME_SETTINGS_PANEL_ID_KEY, NULL); + + if (!id) + { + /* Refuse to load desktop files without a panel ID, but + * with the X-GNOME-Settings-Panel category */ + if (desktop_entry_has_panel_category (key_file)) + { + g_warning ("Not loading desktop file '%s' because it uses the " + GNOME_SETTINGS_PANEL_CATEGORY + " category but isn't a panel.", + desktop); + g_key_file_free (key_file); + return; + } + id = g_strdup (gmenu_tree_entry_get_desktop_file_id (item)); + } + + keywords = g_key_file_get_locale_string_list (key_file, "Desktop Entry", + GNOME_SETTINGS_PANEL_ID_KEYWORDS, + NULL, NULL, NULL); + + g_key_file_free (key_file); + key_file = NULL; + + pixbuf = load_pixbuf_for_string (icon); + + 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, + COL_ICON_NAME, icon, + COL_KEYWORDS, keywords, + -1); + + g_free (id); + g_free (search_target); + g_strfreev (keywords); +} Added: trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/cc-shell-model.h Thu Jul 28 12:34:32 2011 @@ -0,0 +1,90 @@ +/* + * 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, + COL_ICON_NAME, + COL_KEYWORDS, + + 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 */ Added: trunk/control-center-gnome/src/cut-n-paste/shell/control-center.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/control-center.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/control-center.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/control-center.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,198 @@ +/* + * 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 "config.h" + +#include <glib/gi18n.h> +#include <stdlib.h> + +#include "gnome-control-center.h" + +#include <gtk/gtk.h> +#include <string.h> + +#include "cc-shell-log.h" + +G_GNUC_NORETURN static gboolean +option_version_cb (const gchar *option_name, + const gchar *value, + gpointer data, + GError **error) +{ + g_print ("%s %s\n", PACKAGE, VERSION); + exit (0); +} + +static char **start_panels = NULL; +static gboolean show_overview = FALSE; +static gboolean verbose = FALSE; +static gboolean show_help = FALSE; +static gboolean show_help_gtk = FALSE; +static gboolean show_help_all = FALSE; + +const GOptionEntry all_options[] = { + { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL }, + { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Enable verbose mode"), NULL }, + { "overview", 'o', 0, G_OPTION_ARG_NONE, &show_overview, N_("Show the overview"), NULL }, + { "help", 'h', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help, N_("Show help options"), NULL }, + { "help-all", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help_all, N_("Show help options"), NULL }, + { "help-gtk", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &show_help_gtk, N_("Show help options"), NULL }, + { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &start_panels, N_("Panel to display"), NULL }, + { NULL } /* end the list */ +}; + +static int +application_command_line_cb (GApplication *application, + GApplicationCommandLine *command_line, + GnomeControlCenter *shell) +{ + int argc; + char **argv; + int retval = 0; + GOptionContext *context; + GError *error = NULL; + + verbose = FALSE; + show_overview = FALSE; + show_help = FALSE; + start_panels = NULL; + + argv = g_application_command_line_get_arguments (command_line, &argc); + + context = g_option_context_new (N_("- System Settings")); + g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE); + g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); + g_option_context_add_group (context, gtk_get_option_group (TRUE)); + g_option_context_set_help_enabled (context, FALSE); + + if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) + { + g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), + error->message, argv[0]); + g_error_free (error); + g_option_context_free (context); + return 1; + } + + if (show_help || show_help_all || show_help_gtk) + { + gchar *help; + GOptionGroup *group; + + if (show_help || show_help_all) + group = NULL; + else + group = gtk_get_option_group (FALSE); + + help = g_option_context_get_help (context, FALSE, group); + g_print ("%s", help); + g_free (help); + g_option_context_free (context); + return 0; + } + + g_option_context_free (context); + + cc_shell_log_set_debug (verbose); + + gnome_control_center_show (shell, GTK_APPLICATION (application)); + + if (show_overview) + { + gnome_control_center_set_overview_page (shell); + } + else if (start_panels != NULL && start_panels[0] != NULL) + { + const char *start_id; + GError *err = NULL; + + start_id = start_panels[0]; + + 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"); + retval = 1; + if (err) + { + g_error_free (err); + err = NULL; + } + } + } + + gnome_control_center_present (shell); + gdk_notify_startup_complete (); + + g_strfreev (argv); + if (start_panels != NULL) + { + g_strfreev (start_panels); + start_panels = NULL; + } + show_overview = FALSE; + + return retval; +} + +static void +application_startup_cb (GApplication *application, + GnomeControlCenter *shell) +{ + /* nothing to do here, we don't want to show a window before + * we've looked at the commandline + */ +} + +int +main (int argc, char **argv) +{ + GnomeControlCenter *shell; + GtkApplication *application; + int status; + + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + + g_thread_init (NULL); + gtk_init (&argc, &argv); + cc_shell_log_init (); + + /* register a symbolic icon size for use in sidebar lists */ + gtk_icon_size_register ("cc-sidebar-list", 24, 24); + + shell = gnome_control_center_new (); + + /* enforce single instance of this application */ + application = gtk_application_new ("org.gnome.ControlCenter", G_APPLICATION_HANDLES_COMMAND_LINE); + g_signal_connect (application, "startup", + G_CALLBACK (application_startup_cb), shell); + g_signal_connect (application, "command-line", + G_CALLBACK (application_command_line_cb), shell); + + status = g_application_run (G_APPLICATION (application), argc, argv); + + g_object_unref (application); + + return status; +} Added: trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,1124 @@ +/* + * 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 "gnome-control-center.h" + +#include <glib/gi18n.h> +#include <gio/gio.h> +#include <gio/gdesktopappinfo.h> +#include <gtk/gtk.h> +#include <gdk/gdkkeysyms.h> +#include <string.h> +#define GMENU_I_KNOW_THIS_IS_UNSTABLE +#include <gmenu-tree.h> + +#include "cc-panel.h" +#include "cc-shell.h" +#include "shell-search-renderer.h" +#include "cc-shell-category-view.h" +#include "cc-shell-model.h" + +G_DEFINE_TYPE (GnomeControlCenter, gnome_control_center, CC_TYPE_SHELL) + +#define CONTROL_CENTER_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNOME_TYPE_CONTROL_CENTER, GnomeControlCenterPrivate)) + +#define W(b,x) GTK_WIDGET (gtk_builder_get_object (b, x)) + +enum +{ + OVERVIEW_PAGE, + SEARCH_PAGE, + CAPPLET_PAGE +}; + + +struct _GnomeControlCenterPrivate +{ + GtkBuilder *builder; + GtkWidget *notebook; + GtkWidget *main_vbox; + GtkWidget *scrolled_window; + GtkWidget *window; + GtkWidget *search_entry; + GtkWidget *lock_button; + + GMenuTree *menu_tree; + GtkListStore *store; + GHashTable *category_views; + + GtkTreeModel *search_filter; + GtkWidget *search_view; + GtkCellRenderer *search_renderer; + gchar *filter_string; + + guint32 last_time; + + GIOExtensionPoint *extension_point; + + gchar *default_window_title; + gchar *default_window_icon; +}; + +/* Use a fixed width for the shell, since resizing horizontally is more awkward + * for the user than resizing vertically */ +#define FIXED_WIDTH 675 + + +static void +activate_panel (GnomeControlCenter *shell, + const gchar *id, + const gchar *desktop_file, + const gchar *name, + const gchar *icon_name) +{ + GnomeControlCenterPrivate *priv = shell->priv; + GType panel_type = G_TYPE_INVALID; + GList *panels, *l; + + /* check if there is an plugin that implements this panel */ + panels = g_io_extension_point_get_extensions (priv->extension_point); + + if (!desktop_file) + return; + + if (id) + { + + for (l = panels; l != NULL; l = l->next) + { + GIOExtension *extension; + const gchar *name; + + extension = l->data; + + name = g_io_extension_get_name (extension); + + if (!g_strcmp0 (name, id)) + { + panel_type = g_io_extension_get_type (extension); + break; + } + } + + if (panel_type != G_TYPE_INVALID) + { + GtkWidget *panel; + GtkWidget *box; + gint i; + int nat_height; + + /* create the panel plugin */ + panel = g_object_new (panel_type, "shell", shell, NULL); + + gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button), + cc_panel_get_permission (CC_PANEL (panel))); + + box = gtk_alignment_new (0, 0, 1, 1); + gtk_alignment_set_padding (GTK_ALIGNMENT (box), 6, 6, 6, 6); + + gtk_container_add (GTK_CONTAINER (box), panel); + + i = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), box, + NULL); + + /* switch to the new panel */ + gtk_widget_show (box); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i); + + /* set the title of the window */ + gtk_window_set_title (GTK_WINDOW (priv->window), name); + gtk_window_set_default_icon_name (icon_name); + gtk_window_set_icon_name (GTK_WINDOW (priv->window), icon_name); + + gtk_widget_show (panel); + + /* set the scrolled window small so that it doesn't force + the window to be larger than this panel */ + gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (priv->scrolled_window), 50); + + /* resize to the preferred size of the panel */ + gtk_widget_set_size_request (priv->window, FIXED_WIDTH, -1); + gtk_widget_get_preferred_height (GTK_WIDGET (priv->window), + NULL, &nat_height); + gtk_window_resize (GTK_WINDOW (priv->window), + FIXED_WIDTH, + nat_height); + return; + } + else + { + g_warning ("Could not find the loadable module for panel '%s'", id); + } + } +} + +static void +shell_show_overview_page (GnomeControlCenterPrivate *priv) +{ + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), OVERVIEW_PAGE); + + gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), CAPPLET_PAGE); + + /* clear the search text */ + g_free (priv->filter_string); + priv->filter_string = g_strdup (""); + gtk_entry_set_text (GTK_ENTRY (priv->search_entry), ""); + + gtk_lock_button_set_permission (GTK_LOCK_BUTTON (priv->lock_button), NULL); + + /* reset window title and icon */ + gtk_window_set_title (GTK_WINDOW (priv->window), priv->default_window_title); + gtk_window_set_default_icon_name (priv->default_window_icon); + gtk_window_set_icon_name (GTK_WINDOW (priv->window), + priv->default_window_icon); +} + +void +gnome_control_center_set_overview_page (GnomeControlCenter *center) +{ + shell_show_overview_page (center->priv); +} + +static void +item_activated_cb (CcShellCategoryView *view, + gchar *name, + gchar *id, + gchar *desktop_file, + GnomeControlCenter *shell) +{ + GError *err = NULL; + + if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, &err)) + { + /* TODO: show message to user */ + if (err) + { + g_warning ("Could not active panel \"%s\": %s", id, err->message); + g_error_free (err); + } + } +} + +static gboolean +category_focus_out (GtkWidget *view, + GdkEventFocus *event, + GnomeControlCenter *shell) +{ + gtk_icon_view_unselect_all (GTK_ICON_VIEW (view)); + + return FALSE; +} + +static gboolean +category_focus_in (GtkWidget *view, + GdkEventFocus *event, + GnomeControlCenter *shell) +{ + GtkTreePath *path; + + if (!gtk_icon_view_get_cursor (GTK_ICON_VIEW (view), &path, NULL)) + { + path = gtk_tree_path_new_from_indices (0, -1); + gtk_icon_view_set_cursor (GTK_ICON_VIEW (view), path, NULL, FALSE); + } + + gtk_icon_view_select_path (GTK_ICON_VIEW (view), path); + gtk_tree_path_free (path); + + return FALSE; +} + +static GList * +get_item_views (GnomeControlCenter *shell) +{ + GList *list, *l; + GList *res; + + list = gtk_container_get_children (GTK_CONTAINER (shell->priv->main_vbox)); + res = NULL; + for (l = list; l; l = l->next) + { + res = g_list_append (res, cc_shell_category_view_get_item_view (CC_SHELL_CATEGORY_VIEW (l->data))); + } + + g_list_free (list); + + return res; +} + +static gboolean +keynav_failed (GtkIconView *current_view, + GtkDirectionType direction, + GnomeControlCenter *shell) +{ + GList *views, *v; + GtkIconView *new_view; + GtkTreePath *path; + GtkTreeModel *model; + GtkTreeIter iter; + gint col, c, dist, d; + GtkTreePath *sel; + gboolean res; + + res = FALSE; + + views = get_item_views (shell); + + for (v = views; v; v = v->next) + { + if (v->data == current_view) + break; + } + + if (direction == GTK_DIR_DOWN && v != NULL && v->next != NULL) + { + new_view = v->next->data; + + if (gtk_icon_view_get_cursor (current_view, &path, NULL)) + { + col = gtk_icon_view_get_item_column (current_view, path); + gtk_tree_path_free (path); + + sel = NULL; + dist = 1000; + model = gtk_icon_view_get_model (new_view); + gtk_tree_model_get_iter_first (model, &iter); + do { + path = gtk_tree_model_get_path (model, &iter); + c = gtk_icon_view_get_item_column (new_view, path); + d = ABS (c - col); + if (d < dist) + { + if (sel) + gtk_tree_path_free (sel); + sel = path; + dist = d; + } + else + gtk_tree_path_free (path); + } while (gtk_tree_model_iter_next (model, &iter)); + + gtk_icon_view_set_cursor (new_view, sel, NULL, FALSE); + gtk_tree_path_free (sel); + } + + gtk_widget_grab_focus (GTK_WIDGET (new_view)); + + res = TRUE; + } + + if (direction == GTK_DIR_UP && v != NULL && v->prev != NULL) + { + new_view = v->prev->data; + + if (gtk_icon_view_get_cursor (current_view, &path, NULL)) + { + col = gtk_icon_view_get_item_column (current_view, path); + gtk_tree_path_free (path); + + sel = NULL; + dist = 1000; + model = gtk_icon_view_get_model (new_view); + gtk_tree_model_get_iter_first (model, &iter); + do { + path = gtk_tree_model_get_path (model, &iter); + c = gtk_icon_view_get_item_column (new_view, path); + d = ABS (c - col); + if (d <= dist) + { + if (sel) + gtk_tree_path_free (sel); + sel = path; + dist = d; + } + else + gtk_tree_path_free (path); + } while (gtk_tree_model_iter_next (model, &iter)); + + gtk_icon_view_set_cursor (new_view, sel, NULL, FALSE); + gtk_tree_path_free (sel); + } + + gtk_widget_grab_focus (GTK_WIDGET (new_view)); + + res = TRUE; + } + + g_list_free (views); + + return res; +} + +static gboolean +model_filter_func (GtkTreeModel *model, + GtkTreeIter *iter, + GnomeControlCenterPrivate *priv) +{ + gchar *name, *target; + gchar *needle, *haystack; + gboolean result; + gchar **keywords; + + gtk_tree_model_get (model, iter, COL_NAME, &name, + COL_SEARCH_TARGET, &target, + COL_KEYWORDS, &keywords, + -1); + + if (!priv->filter_string || !name || !target) + { + g_free (name); + g_free (target); + g_strfreev (keywords); + return FALSE; + } + + needle = g_utf8_casefold (priv->filter_string, -1); + haystack = g_utf8_casefold (target, -1); + + result = (strstr (haystack, needle) != NULL); + + if (!result && keywords) + { + gint i; + gchar *keyword; + + for (i = 0; !result && keywords[i]; i++) + { + keyword = g_utf8_casefold (keywords[i], -1); + result = strstr (keyword, needle) == keyword; + g_free (keyword); + } + } + + g_free (name); + g_free (target); + g_free (haystack); + g_free (needle); + g_strfreev (keywords); + + return result; +} + +static gboolean +category_filter_func (GtkTreeModel *model, + GtkTreeIter *iter, + gchar *filter) +{ + gchar *category; + gboolean result; + + gtk_tree_model_get (model, iter, COL_CATEGORY, &category, -1); + + result = (g_strcmp0 (category, filter) == 0); + + g_free (category); + + return result; +} + +static void +search_entry_changed_cb (GtkEntry *entry, + GnomeControlCenterPrivate *priv) +{ + char *str; + + /* if the entry text was set manually (not by the user) */ + if (!g_strcmp0 (priv->filter_string, gtk_entry_get_text (entry))) + return; + + /* Don't re-filter for added trailing or leading spaces */ + str = g_strdup (gtk_entry_get_text (entry)); + g_strstrip (str); + if (!g_strcmp0 (str, priv->filter_string)) + { + g_free (str); + return; + } + + g_free (priv->filter_string); + priv->filter_string = str; + + g_object_set (priv->search_renderer, + "search-string", priv->filter_string, + NULL); + + if (!g_strcmp0 (priv->filter_string, "")) + { + shell_show_overview_page (priv); + g_object_set (G_OBJECT (entry), + "secondary-icon-name", "edit-find-symbolic", + "secondary-icon-activatable", FALSE, + "secondary-icon-sensitive", FALSE, + NULL); + } + else + { + gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->search_filter)); + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), + SEARCH_PAGE); + g_object_set (G_OBJECT (entry), + "secondary-icon-name", "edit-clear-symbolic", + "secondary-icon-activatable", TRUE, + "secondary-icon-sensitive", TRUE, + NULL); + } +} + +static gboolean +search_entry_key_press_event_cb (GtkEntry *entry, + GdkEventKey *event, + GnomeControlCenterPrivate *priv) +{ + if (event->keyval == GDK_KEY_Return) + { + GtkTreePath *path; + + path = gtk_tree_path_new_first (); + + priv->last_time = event->time; + + gtk_icon_view_item_activated (GTK_ICON_VIEW (priv->search_view), path); + + gtk_tree_path_free (path); + return TRUE; + } + + if (event->keyval == GDK_KEY_Escape) + { + gtk_entry_set_text (entry, ""); + return TRUE; + } + + return FALSE; +} + +static void +search_entry_clear_cb (GtkEntry *entry) +{ + gtk_entry_set_text (entry, ""); +} + + +static void +setup_search (GnomeControlCenter *shell) +{ + GtkWidget *search_scrolled, *search_view, *widget; + GnomeControlCenterPrivate *priv = shell->priv; + + g_return_if_fail (priv->store != NULL); + + /* create the search filter */ + priv->search_filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->store), + NULL); + + gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (priv->search_filter), + (GtkTreeModelFilterVisibleFunc) + model_filter_func, + priv, NULL); + + /* set up the search view */ + priv->search_view = search_view = cc_shell_item_view_new (); + gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (search_view), + GTK_ORIENTATION_HORIZONTAL); + gtk_icon_view_set_spacing (GTK_ICON_VIEW (search_view), 6); + gtk_icon_view_set_model (GTK_ICON_VIEW (search_view), + GTK_TREE_MODEL (priv->search_filter)); + gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (search_view), COL_PIXBUF); + + search_scrolled = W (priv->builder, "search-scrolled-window"); + gtk_container_add (GTK_CONTAINER (search_scrolled), search_view); + + /* add the custom renderer */ + priv->search_renderer = (GtkCellRenderer*) shell_search_renderer_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (search_view), + priv->search_renderer, TRUE); + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (search_view), + priv->search_renderer, + "title", COL_NAME); + gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (search_view), + priv->search_renderer, + "search-target", COL_SEARCH_TARGET); + + /* connect the activated signal */ + g_signal_connect (search_view, "desktop-item-activated", + G_CALLBACK (item_activated_cb), shell); + + /* setup the search entry widget */ + widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "search-entry"); + priv->search_entry = widget; + priv->filter_string = g_strdup (""); + + g_signal_connect (widget, "changed", G_CALLBACK (search_entry_changed_cb), + priv); + g_signal_connect (widget, "key-press-event", + G_CALLBACK (search_entry_key_press_event_cb), priv); + + g_signal_connect (widget, "icon-release", G_CALLBACK (search_entry_clear_cb), + priv); +} + +static void +setup_lock (GnomeControlCenter *shell) +{ + GnomeControlCenterPrivate *priv = shell->priv; + + priv->lock_button = W (priv->builder, "lock-button"); +} + +static void +maybe_add_category_view (GnomeControlCenter *shell, + const char *name) +{ + GtkTreeModel *filter; + GtkWidget *categoryview; + + if (g_hash_table_lookup (shell->priv->category_views, name) != NULL) + return; + + /* create new category view for this category */ + filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (shell->priv->store), + NULL); + gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter), + (GtkTreeModelFilterVisibleFunc) category_filter_func, + g_strdup (name), g_free); + + categoryview = cc_shell_category_view_new (name, filter); + gtk_box_pack_start (GTK_BOX (shell->priv->main_vbox), categoryview, FALSE, TRUE, 0); + + g_signal_connect (cc_shell_category_view_get_item_view (CC_SHELL_CATEGORY_VIEW (categoryview)), + "desktop-item-activated", + G_CALLBACK (item_activated_cb), shell); + + gtk_widget_show (categoryview); + + g_signal_connect (cc_shell_category_view_get_item_view (CC_SHELL_CATEGORY_VIEW (categoryview)), + "focus-in-event", + G_CALLBACK (category_focus_in), shell); + g_signal_connect (cc_shell_category_view_get_item_view (CC_SHELL_CATEGORY_VIEW (categoryview)), + "focus-out-event", + G_CALLBACK (category_focus_out), shell); + g_signal_connect (cc_shell_category_view_get_item_view (CC_SHELL_CATEGORY_VIEW (categoryview)), + "keynav-failed", + G_CALLBACK (keynav_failed), shell); + + g_hash_table_insert (shell->priv->category_views, g_strdup (name), categoryview); +} + +static void +reload_menu (GnomeControlCenter *shell) +{ + GSList *list, *l; + GMenuTreeDirectory *d; + + d = gmenu_tree_get_root_directory (shell->priv->menu_tree); + list = gmenu_tree_directory_get_contents (d); + + for (l = list; l; l = l->next) + { + GMenuTreeItemType type; + type = gmenu_tree_item_get_type (l->data); + + if (type == GMENU_TREE_ITEM_DIRECTORY) + { + GSList *contents, *f; + const gchar *dir_name; + + contents = gmenu_tree_directory_get_contents (l->data); + dir_name = gmenu_tree_directory_get_name (l->data); + + maybe_add_category_view (shell, dir_name); + + /* add the items from this category to the model */ + for (f = contents; f; f = f->next) + { + if (gmenu_tree_item_get_type (f->data) == GMENU_TREE_ITEM_ENTRY) + { + cc_shell_model_add_item (CC_SHELL_MODEL (shell->priv->store), + dir_name, + f->data); + } + } + + g_slist_free (contents); + } + } + + g_slist_free (list); +} + +static void +on_menu_changed (GMenuTree *monitor, + GnomeControlCenter *shell) +{ + gtk_list_store_clear (shell->priv->store); + reload_menu (shell); +} + +static void +setup_model (GnomeControlCenter *shell) +{ + GnomeControlCenterPrivate *priv = shell->priv; + + gtk_container_set_border_width (GTK_CONTAINER (shell->priv->main_vbox), 10); + gtk_container_set_focus_vadjustment (GTK_CONTAINER (shell->priv->main_vbox), + gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (shell->priv->scrolled_window))); + + priv->store = (GtkListStore *) cc_shell_model_new (); + priv->category_views = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + priv->menu_tree = gmenu_tree_lookup (MENUDIR "/gnomecc.menu", 0); + + if (priv->menu_tree == NULL) + { + g_warning ("Could not find control center menu"); + return; + } + + reload_menu (shell); + + gmenu_tree_add_monitor (priv->menu_tree, (GMenuTreeChangedFunc)on_menu_changed, shell); +} + +static void +load_panel_plugins (GnomeControlCenter *shell) +{ + GList *modules; + + /* only allow this function to be run once to prevent modules being loaded + * twice + */ + if (shell->priv->extension_point) + return; + + /* make sure the base type is registered */ + g_type_from_name ("CcPanel"); + + shell->priv->extension_point + = g_io_extension_point_register (CC_SHELL_PANEL_EXTENSION_POINT); + + /* load all the plugins in the panels directory */ + modules = g_io_modules_load_all_in_directory (PANELS_DIR); + g_list_free (modules); + +} + + +static void +home_button_clicked_cb (GtkButton *button, + GnomeControlCenter *shell) +{ + shell_show_overview_page (shell->priv); +} + +static void +notebook_switch_page_cb (GtkNotebook *book, + GtkWidget *child, + gint page_num, + GnomeControlCenterPrivate *priv) +{ + /* make sure the home button is shown on all pages except the overview page */ + + if (page_num == OVERVIEW_PAGE || page_num == SEARCH_PAGE) + { + gtk_widget_hide (W (priv->builder, "home-button")); + gtk_widget_show (W (priv->builder, "search-entry")); + gtk_widget_hide (W (priv->builder, "lock-button")); + } + else + { + gtk_widget_show (W (priv->builder, "home-button")); + gtk_widget_hide (W (priv->builder, "search-entry")); + } +} + +/* CcShell implementation */ +static gboolean +_shell_set_active_panel_from_id (CcShell *shell, + const gchar *start_id, + GError **err) +{ + GtkTreeIter iter; + gboolean iter_valid; + gchar *name = NULL; + gchar *desktop, *icon_name; + GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (shell)->priv; + + + iter_valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), + &iter); + + /* find the details for this item */ + while (iter_valid) + { + gchar *id; + + gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, + COL_NAME, &name, + COL_DESKTOP_FILE, &desktop, + COL_ICON_NAME, &icon_name, + COL_ID, &id, + -1); + + if (id && !strcmp (id, start_id)) + { + g_free (id); + break; + } + else + { + g_free (id); + g_free (name); + g_free (desktop); + g_free (icon_name); + + name = NULL; + id = NULL; + } + + iter_valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), + &iter); + } + + if (!name) + { + g_warning ("Could not find settings panel \"%s\"", start_id); + return FALSE; + } + else + { + gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), CAPPLET_PAGE); + + activate_panel (GNOME_CONTROL_CENTER (shell), start_id, desktop, name, + icon_name); + + g_free (name); + g_free (desktop); + g_free (icon_name); + + return TRUE; + } +} + +static GtkWidget * +_shell_get_toplevel (CcShell *shell) +{ + return GNOME_CONTROL_CENTER (shell)->priv->window; +} + +/* GObject Implementation */ +static void +gnome_control_center_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 +gnome_control_center_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 +gnome_control_center_dispose (GObject *object) +{ + GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (object)->priv; + + if (priv->window) + { + gtk_widget_destroy (priv->window); + priv->window = NULL; + + /* destroying the window will destroy its children */ + priv->notebook = NULL; + priv->search_entry = NULL; + priv->search_view = NULL; + priv->search_renderer = NULL; + } + + if (priv->builder) + { + g_object_unref (priv->builder); + priv->builder = NULL; + } + + if (priv->store) + { + g_object_unref (priv->store); + priv->store = NULL; + } + + if (priv->search_filter) + { + g_object_unref (priv->search_filter); + priv->search_filter = NULL; + } + + + G_OBJECT_CLASS (gnome_control_center_parent_class)->dispose (object); +} + +static void +gnome_control_center_finalize (GObject *object) +{ + GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (object)->priv; + + if (priv->filter_string) + { + g_free (priv->filter_string); + priv->filter_string = NULL; + } + + if (priv->default_window_title) + { + g_free (priv->default_window_title); + priv->default_window_title = NULL; + } + + if (priv->default_window_icon) + { + g_free (priv->default_window_icon); + priv->default_window_icon = NULL; + } + + if (priv->menu_tree) + { + gmenu_tree_remove_monitor (priv->menu_tree, (GMenuTreeChangedFunc)on_menu_changed, object); + gmenu_tree_unref (priv->menu_tree); + } + + if (priv->category_views) + { + g_hash_table_destroy (priv->category_views); + } + + G_OBJECT_CLASS (gnome_control_center_parent_class)->finalize (object); +} + +static void +gnome_control_center_class_init (GnomeControlCenterClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + CcShellClass *shell_class = CC_SHELL_CLASS (klass); + + g_type_class_add_private (klass, sizeof (GnomeControlCenterPrivate)); + + object_class->get_property = gnome_control_center_get_property; + object_class->set_property = gnome_control_center_set_property; + object_class->dispose = gnome_control_center_dispose; + object_class->finalize = gnome_control_center_finalize; + + shell_class->set_active_panel_from_id = _shell_set_active_panel_from_id; + shell_class->get_toplevel = _shell_get_toplevel; +} + +static gboolean +queue_resize (gpointer data) +{ + GtkWidget *widget = data; + + gtk_widget_queue_resize (widget); + + return FALSE; +} + +static void +on_window_size_allocate (GtkWidget *widget, + GtkAllocation *allocation, + GnomeControlCenter *self) +{ + int height; + + if (gtk_notebook_get_current_page (GTK_NOTEBOOK (self->priv->notebook)) == OVERVIEW_PAGE) + { + gtk_widget_get_preferred_height_for_width (GTK_WIDGET (self->priv->main_vbox), + FIXED_WIDTH, + NULL, + &height); + if (gtk_widget_get_realized (widget)) + { + int monitor; + GdkScreen *screen; + GdkRectangle rect; + GdkWindow *window; + + window = gtk_widget_get_window (widget); + screen = gtk_widget_get_screen (widget); + monitor = gdk_screen_get_monitor_at_window (screen, window); + gdk_screen_get_monitor_geometry (screen, monitor, &rect); + height = MIN (height + 10, rect.height - 120); + } + } + else + { + height = 50; + } + + if (gtk_scrolled_window_get_min_content_height (GTK_SCROLLED_WINDOW (self->priv->scrolled_window)) != height) + { + gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (self->priv->scrolled_window), height); + /* + * Queueing a resize out of size-allocate is ignored, + * so we have to defer to an idle. + */ + g_idle_add (queue_resize, self->priv->scrolled_window); + } +} + +static void +viewport_style_set_cb (GtkWidget *widget, + GtkStyle *old_style, + gpointer user_data) +{ + GtkStyle *style; + + /* use "base" colours inside the viewport */ + + g_signal_handlers_block_by_func (widget, viewport_style_set_cb, NULL); + + style = gtk_widget_get_style (widget); + + gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, + &style->base[GTK_STATE_NORMAL]); + + g_signal_handlers_unblock_by_func (widget, viewport_style_set_cb, NULL); +} + +static gboolean +window_key_press_event (GtkWidget *win, + GdkEventKey *event, + GnomeControlCenter *self) +{ + gboolean retval; + + retval = FALSE; + + if (!gtk_widget_get_visible (self->priv->search_entry)) + return retval; + + if (event->state != 0 && + (event->state & GDK_CONTROL_MASK)) + { + switch (event->keyval) + { + case GDK_KEY_s: + case GDK_KEY_S: + case GDK_KEY_f: + case GDK_KEY_F: + gtk_widget_grab_focus (self->priv->search_entry); + retval = TRUE; + break; + } + } + return retval; +} + +static void +gnome_control_center_init (GnomeControlCenter *self) +{ + GtkWidget *widget; + GError *err = NULL; + GnomeControlCenterPrivate *priv; + + priv = self->priv = CONTROL_CENTER_PRIVATE (self); + + /* load the user interface */ + priv->builder = gtk_builder_new (); + + if (!gtk_builder_add_from_file (priv->builder, UIDIR "/shell.ui", &err)) + { + g_critical ("Could not build interface: %s", err->message); + g_error_free (err); + + return; + } + + /* connect various signals */ + priv->window = W (priv->builder, "main-window"); + g_signal_connect_swapped (priv->window, "delete-event", G_CALLBACK (g_object_unref), self); + g_signal_connect (priv->window, "key_press_event", + G_CALLBACK (window_key_press_event), self); + + priv->notebook = W (priv->builder, "notebook"); + priv->scrolled_window = W (priv->builder, "scrolledwindow1"); + + widget = W (priv->builder, "viewport"); + g_signal_connect (widget, "style-set", G_CALLBACK (viewport_style_set_cb), + NULL); + + gtk_widget_set_size_request (priv->scrolled_window, FIXED_WIDTH, -1); + priv->main_vbox = W (priv->builder, "main-vbox"); + g_signal_connect (priv->scrolled_window, "size-allocate", G_CALLBACK (on_window_size_allocate), self); + g_signal_connect (priv->notebook, "switch-page", + G_CALLBACK (notebook_switch_page_cb), priv); + + g_signal_connect (gtk_builder_get_object (priv->builder, "home-button"), + "clicked", G_CALLBACK (home_button_clicked_cb), self); + + /* load the available settings panels */ + setup_model (self); + + /* load the panels that are implemented as plugins */ + load_panel_plugins (self); + + /* setup search functionality */ + setup_search (self); + + setup_lock (self); + + /* store default window title and name */ + priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window))); + priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window))); +} + +GnomeControlCenter * +gnome_control_center_new (void) +{ + return g_object_new (GNOME_TYPE_CONTROL_CENTER, NULL); +} + +void +gnome_control_center_present (GnomeControlCenter *center) +{ + gtk_window_present (GTK_WINDOW (center->priv->window)); +} + +void +gnome_control_center_show (GnomeControlCenter *center, + GtkApplication *app) +{ + gtk_window_set_application (GTK_WINDOW (center->priv->window), app); + gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (center->priv->window))); +} Added: trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/gnome-control-center.h Thu Jul 28 12:34:32 2011 @@ -0,0 +1,79 @@ +/* + * 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 _GNOME_CONTROL_CENTER_H +#define _GNOME_CONTROL_CENTER_H + +#include <glib-object.h> +#include <libgnome-control-center/cc-shell.h> + +G_BEGIN_DECLS + +#define GNOME_TYPE_CONTROL_CENTER gnome_control_center_get_type() + +#define GNOME_CONTROL_CENTER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + GNOME_TYPE_CONTROL_CENTER, GnomeControlCenter)) + +#define GNOME_CONTROL_CENTER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + GNOME_TYPE_CONTROL_CENTER, GnomeControlCenterClass)) + +#define GNOME_IS_CONTROL_CENTER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + GNOME_TYPE_CONTROL_CENTER)) + +#define GNOME_IS_CONTROL_CENTER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + GNOME_TYPE_CONTROL_CENTER)) + +#define GNOME_CONTROL_CENTER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + GNOME_TYPE_CONTROL_CENTER, GnomeControlCenterClass)) + +typedef struct _GnomeControlCenter GnomeControlCenter; +typedef struct _GnomeControlCenterClass GnomeControlCenterClass; +typedef struct _GnomeControlCenterPrivate GnomeControlCenterPrivate; + +struct _GnomeControlCenter +{ + CcShell parent; + + GnomeControlCenterPrivate *priv; +}; + +struct _GnomeControlCenterClass +{ + CcShellClass parent_class; +}; + +GType gnome_control_center_get_type (void) G_GNUC_CONST; + +GnomeControlCenter *gnome_control_center_new (void); + +void gnome_control_center_present (GnomeControlCenter *center); + +void gnome_control_center_show (GnomeControlCenter *center, GtkApplication *app); + +void gnome_control_center_set_overview_page (GnomeControlCenter *center); + +G_END_DECLS + +#endif /* _GNOME_CONTROL_CENTER_H */ Added: trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.c?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.c (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.c Thu Jul 28 12:34:32 2011 @@ -0,0 +1,351 @@ +/* + * 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_TEXT) + +#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); + /* set GtkCellRendererText::text for a11y */ + g_object_set (object, "text", priv->title, NULL); + 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; + + if (priv->search_string != NULL) + needle = g_utf8_casefold (priv->search_string, -1); + else + needle = NULL; + 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; + gchar *match; + gint count; + +#define CONTEXT 10 + + count = strlen (needle); + start = full_string + (strstr (haystack, needle) - haystack); + + lead = MAX (start - CONTEXT, full_string); + trail = start + count; + + if (lead == full_string) + leaddot = ""; + else + leaddot = "â¦"; + + match = g_strndup (start, count); + 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, + match, trail); + + g_free (match); + 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 +get_size (GtkCellRenderer *cell, + GtkWidget *widget, + 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; +} + +static void +shell_search_renderer_get_preferred_width (GtkCellRenderer *cell, + GtkWidget *widget, + gint *minimum_size, + gint *natural_size) +{ + gint width; + + get_size (cell, widget, &width, NULL); + if (minimum_size) *minimum_size = width; + if (natural_size) *natural_size = width; +} + +static void +shell_search_renderer_get_preferred_height (GtkCellRenderer *cell, + GtkWidget *widget, + gint *minimum_size, + gint *natural_size) +{ + gint height; + + get_size (cell, widget, NULL, &height); + if (minimum_size) *minimum_size = height; + if (natural_size) *natural_size = height; +} + +static void +shell_search_renderer_get_preferred_height_for_width (GtkCellRenderer *cell, + GtkWidget *widget, + gint width, + gint *minimum_height, + gint *natural_height) +{ + shell_search_renderer_get_preferred_height (cell, widget, minimum_height, natural_height); +} + +static void +shell_search_renderer_get_aligned_area (GtkCellRenderer *cell, + GtkWidget *widget, + GtkCellRendererState flags, + const GdkRectangle *cell_area, + GdkRectangle *aligned_area) +{ + get_size (cell, widget, &aligned_area->width, &aligned_area->height); + aligned_area->x = cell_area->x; + aligned_area->y = cell_area->y; +} + +static void +shell_search_renderer_render (GtkCellRenderer *cell, + cairo_t *cr, + GtkWidget *widget, + const GdkRectangle *background_area, + const GdkRectangle *cell_area, + GtkCellRendererState flags) +{ + ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (cell)->priv; + PangoRectangle rect; + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + + shell_search_renderer_set_layout (SHELL_SEARCH_RENDERER (cell), widget); + + pango_layout_get_pixel_extents (priv->layout, NULL, &rect); + + cairo_save (cr); + + gtk_render_layout (context, cr, + cell_area->x, + cell_area->y, + priv->layout); + + cairo_restore (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_preferred_width = shell_search_renderer_get_preferred_width; + cell_renderer->get_preferred_height = shell_search_renderer_get_preferred_height; + cell_renderer->get_preferred_height_for_width = shell_search_renderer_get_preferred_height_for_width; + cell_renderer->get_aligned_area = shell_search_renderer_get_aligned_area; + + 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); +} Added: trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.h?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.h (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/shell-search-renderer.h Thu Jul 28 12:34:32 2011 @@ -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 +{ + GtkCellRendererText parent; + + ShellSearchRendererPrivate *priv; +}; + +struct _ShellSearchRendererClass +{ + GtkCellRendererTextClass 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 */ Added: trunk/control-center-gnome/src/cut-n-paste/shell/shell.ui URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/cut-n-paste/shell/shell.ui?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/cut-n-paste/shell/shell.ui (added) +++ trunk/control-center-gnome/src/cut-n-paste/shell/shell.ui Thu Jul 28 12:34:32 2011 @@ -0,0 +1,173 @@ +<?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="resizable">False</property> + <property name="icon_name">preferences-desktop</property> + <property name="window_position">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> + <style> + <class name="primary-toolbar"/> + </style> + <child> + <object class="GtkToolItem" id="toolbutton1"> + <property name="visible">True</property> + <style> + <class name="raised"/> + </style> + <child> + <object class="GtkAlignment" id="alignment1"> + <property name="visible">True</property> + <property name="top_padding">5</property> + <property name="bottom_padding">5</property> + <property name="left_padding">10</property> + <property name="right_padding">5</property> + <child> + <object class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <child> + <object class="GtkButton" id="home-button"> + <property name="label" translatable="yes">_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="GtkBox" id="topright"> + <property name="visible">True</property> + <property name="orientation">horizontal</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="secondary-icon-name">edit-find-symbolic</property> + <property name="secondary-icon-activatable">False</property> + <property name="secondary-icon-sensitive">False</property> + </object> + </child> + <child> + <object class="GtkLockButton" id="lock-button"> + <property name="visible">False</property> + <property name="no_show_all">True</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + </object> + </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="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="viewport"> + <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">1</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> Modified: trunk/control-center-gnome/src/gnome-control-center.c URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/gnome-control-center.c?rev=65066&r1=65065&r2=65066&view=diff ============================================================================== --- trunk/control-center-gnome/src/gnome-control-center.c (original) +++ trunk/control-center-gnome/src/gnome-control-center.c Thu Jul 28 12:34:32 2011 @@ -31,8 +31,8 @@ #define GMENU_I_KNOW_THIS_IS_UNSTABLE #include <gmenu-tree.h> -#include <libgnome-control-center/cc-panel.h> -#include <libgnome-control-center/cc-shell.h> +#include "cc-panel.h" +#include "cc-shell.h" #include "shell-search-renderer.h" #include "cc-shell-category-view.h" #include "cc-shell-model.h" Copied: trunk/control-center-gnome/src/patch/gnome-control-center.patch (from r64979, trunk/control-center-gnome/gnome-control-center.patch) URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/patch/gnome-control-center.patch?p2=trunk/control-center-gnome/src/patch/gnome-control-center.patch&p1=trunk/control-center-gnome/gnome-control-center.patch&r1=64979&r2=65066&rev=65066&view=diff ============================================================================== --- trunk/control-center-gnome/gnome-control-center.patch (original) +++ trunk/control-center-gnome/src/patch/gnome-control-center.patch Thu Jul 28 12:34:32 2011 @@ -1,27 +1,6 @@ -commit 9515576b680d86c78f5c5e100b22c0e71e71b738 -Author: Vincent Untz <vuntz@gnome.org> -Date: Mon Jul 25 11:38:26 2011 +0200 - - shell: change to YaST shell - -diff --git a/shell/cc-shell-category-view.c b/shell/cc-shell-category-view.c -index b2a5ee4..57ad8d4 100644 ---- a/shell/cc-shell-category-view.c -+++ b/shell/cc-shell-category-view.c -@@ -20,7 +20,7 @@ - - #include "cc-shell-category-view.h" - #include "cc-shell-item-view.h" --#include "cc-shell.h" -+#include <libgnome-control-center/cc-shell.h> - #include "cc-shell-model.h" - - G_DEFINE_TYPE (CcShellCategoryView, cc_shell_category_view, GTK_TYPE_FRAME) -diff --git a/shell/control-center.c b/shell/control-center.c -index 2ba41fd..09aec0f 100644 ---- a/shell/control-center.c -+++ b/shell/control-center.c -@@ -41,8 +41,10 @@ option_version_cb (const gchar *option_name, +--- ./patch/../cut-n-paste/shell/control-center.c 2011-07-25 12:13:00.915871481 +0200 ++++ ./patch/../control-center.c 2011-07-25 11:36:40.873059970 +0200 +@@ -41,8 +41,10 @@ exit (0); } @@ -32,7 +11,7 @@ static gboolean verbose = FALSE; static gboolean show_help = FALSE; static gboolean show_help_gtk = FALSE; -@@ -51,11 +53,15 @@ static gboolean show_help_all = FALSE; +@@ -51,11 +53,15 @@ const GOptionEntry all_options[] = { { "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL }, { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Enable verbose mode"), NULL }, @@ -48,7 +27,7 @@ { NULL } /* end the list */ }; -@@ -71,13 +77,17 @@ application_command_line_cb (GApplication *application, +@@ -71,13 +77,17 @@ GError *error = NULL; verbose = FALSE; @@ -67,7 +46,7 @@ g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); -@@ -115,6 +125,7 @@ application_command_line_cb (GApplication *application, +@@ -115,6 +125,7 @@ gnome_control_center_show (shell, GTK_APPLICATION (application)); @@ -75,7 +54,7 @@ if (show_overview) { gnome_control_center_set_overview_page (shell); -@@ -138,17 +149,20 @@ application_command_line_cb (GApplication *application, +@@ -138,17 +149,20 @@ } } } @@ -96,7 +75,7 @@ return retval; } -@@ -169,6 +183,8 @@ main (int argc, char **argv) +@@ -169,6 +183,8 @@ GtkApplication *application; int status; @@ -105,7 +84,7 @@ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); -@@ -178,13 +194,17 @@ main (int argc, char **argv) +@@ -178,13 +194,17 @@ gtk_init (&argc, &argv); cc_shell_log_init (); @@ -124,22 +103,9 @@ g_signal_connect (application, "startup", G_CALLBACK (application_startup_cb), shell); g_signal_connect (application, "command-line", -diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c -index a771282..652300b 100644 ---- a/shell/gnome-control-center.c -+++ b/shell/gnome-control-center.c -@@ -31,8 +31,8 @@ - #define GMENU_I_KNOW_THIS_IS_UNSTABLE - #include <gmenu-tree.h> - --#include "cc-panel.h" --#include "cc-shell.h" -+#include <libgnome-control-center/cc-panel.h> -+#include <libgnome-control-center/cc-shell.h> - #include "shell-search-renderer.h" - #include "cc-shell-category-view.h" - #include "cc-shell-model.h" -@@ -91,6 +91,33 @@ activate_panel (GnomeControlCenter *shell, +--- ./patch/../cut-n-paste/shell/gnome-control-center.c 2011-07-28 11:50:46.369276534 +0200 ++++ ./patch/../gnome-control-center.c 2011-07-28 12:07:12.977644709 +0200 +@@ -91,6 +91,33 @@ const gchar *name, const gchar *icon_name) { @@ -173,7 +139,7 @@ GnomeControlCenterPrivate *priv = shell->priv; GType panel_type = G_TYPE_INVALID; GList *panels, *l; -@@ -170,6 +197,7 @@ activate_panel (GnomeControlCenter *shell, +@@ -170,6 +197,7 @@ g_warning ("Could not find the loadable module for panel '%s'", id); } } @@ -181,7 +147,7 @@ } static void -@@ -685,7 +713,7 @@ setup_model (GnomeControlCenter *shell) +@@ -685,7 +713,7 @@ priv->store = (GtkListStore *) cc_shell_model_new (); priv->category_views = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -190,7 +156,7 @@ if (priv->menu_tree == NULL) { -@@ -701,6 +729,7 @@ setup_model (GnomeControlCenter *shell) +@@ -701,6 +729,7 @@ static void load_panel_plugins (GnomeControlCenter *shell) { @@ -198,7 +164,7 @@ GList *modules; /* only allow this function to be run once to prevent modules being loaded -@@ -719,6 +748,7 @@ load_panel_plugins (GnomeControlCenter *shell) +@@ -719,6 +748,7 @@ modules = g_io_modules_load_all_in_directory (PANELS_DIR); g_list_free (modules); @@ -206,7 +172,7 @@ } -@@ -978,7 +1008,16 @@ on_window_size_allocate (GtkWidget *widget, +@@ -978,7 +1008,16 @@ screen = gtk_widget_get_screen (widget); monitor = gdk_screen_get_monitor_at_window (screen, window); gdk_screen_get_monitor_geometry (screen, monitor, &rect); @@ -224,10 +190,8 @@ } } else -diff --git a/shell/shell.ui b/shell/shell.ui -index e63f19f..f8e0d7e 100644 ---- a/shell/shell.ui -+++ b/shell/shell.ui +--- ./patch/../cut-n-paste/shell/shell.ui 2011-07-25 12:13:00.915871481 +0200 ++++ ./patch/../shell.ui 2011-07-25 10:04:29.790594605 +0200 @@ -3,9 +3,9 @@ <requires lib="gtk+" version="2.16"/> <!-- interface-naming-policy project-wide --> Added: trunk/control-center-gnome/src/patch/update-patch.sh URL: http://svn.opensuse.org/viewcvs/yast/trunk/control-center-gnome/src/patch/update-patch.sh?rev=65066&view=auto ============================================================================== --- trunk/control-center-gnome/src/patch/update-patch.sh (added) +++ trunk/control-center-gnome/src/patch/update-patch.sh Thu Jul 28 12:34:32 2011 @@ -0,0 +1,7 @@ +#!/bin/sh +DIRNAME=`dirname $0` +( +for file in control-center.c gnome-control-center.c shell.ui; do + diff -u "${DIRNAME}/../cut-n-paste/shell/$file" "${DIRNAME}/../$file" +done +) > "${DIRNAME}/gnome-control-center.patch" -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
vuntz@svn2.opensuse.org