Hello community, here is the log from the commit of package yast2-control-center-gnome for openSUSE:Factory checked in at Tue Sep 13 12:34:45 CEST 2011.
-------- --- yast2-control-center-gnome/yast2-control-center-gnome.changes 2011-07-28 12:35:29.000000000 +0200 +++ /mounts/work_src_done/STABLE/yast2-control-center-gnome/yast2-control-center-gnome.changes 2011-09-02 16:37:37.000000000 +0200 @@ -1,0 +2,12 @@ +Fri Sep 2 14:22:30 UTC 2011 - vu...@opensuse.org + +- Update to version 2.21.2: + + Update gnome-control-center code; this includes: + - port to the new gnome-menus library + - do not display item title twice when searching + - add Ctrl+Q as a way to exit the shell + + Specify layout in YaST-gnome.menu to avoid alphabetical order. +- Change pkgconfig(libgnome-menu) BuildRequires to + pkgconfig(libgnome-menu-3.0) to use the new gnome-menus library. + +------------------------------------------------------------------- calling whatdependson for head-i586 Old: ---- yast2-control-center-gnome-2.21.1.tar.bz2 New: ---- yast2-control-center-gnome-2.21.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-control-center-gnome.spec ++++++ --- /var/tmp/diff_new_pack.rbn5ko/_old 2011-09-13 12:34:40.000000000 +0200 +++ /var/tmp/diff_new_pack.rbn5ko/_new 2011-09-13 12:34:40.000000000 +0200 @@ -18,7 +18,7 @@ Name: yast2-control-center-gnome -Version: 2.21.1 +Version: 2.21.2 Release: 1 License: GPL v2 or later Summary: YaST2 - Control Center (GNOME version) @@ -31,7 +31,7 @@ BuildRequires: yast2-devtools BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(gtk+-3.0) -BuildRequires: pkgconfig(libgnome-menu) +BuildRequires: pkgconfig(libgnome-menu-3.0) Requires: yast2-control-center Supplements: gnome-main-menu Provides: yast2-control-center-binary ++++++ yast2-control-center-gnome-2.21.1.tar.bz2 -> yast2-control-center-gnome-2.21.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/ChangeLog new/yast2-control-center-gnome-2.21.2/ChangeLog --- old/yast2-control-center-gnome-2.21.1/ChangeLog 2011-07-28 12:29:30.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/ChangeLog 2011-09-02 16:33:51.000000000 +0200 @@ -1,3 +1,20 @@ +2011-09-02 Vincent Untz <vu...@gnome.org> + + Release 2.21.2 + + Update to gnome-control-center code as of today. This includes a port + to new gnome-menus API. + + * VERSION: bump version. + * configure.in.in: look for libgnome-menu-3.0 instead of libgnome-menu. + * etc/YaST-gnome.menu: add Layout node to force the layout we want, + instead of relying on alphabetical order. + * src/cut-n-paste/: update code from gnome-control-center. + * src/{control-center.c,gnome-control-center.c}: rebase on updated code. + * src/shell-search-renderer.c: tweak this source file to avoid a crash + caused by the fact that yast .desktop files have no Comment key. + * src/patch/: update patch to current changes. + 2011-07-28 Vincent Untz <vu...@gnome.org> Release 2.21.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/VERSION new/yast2-control-center-gnome-2.21.2/VERSION --- old/yast2-control-center-gnome-2.21.1/VERSION 2011-07-28 12:22:34.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/VERSION 2011-09-02 16:17:20.000000000 +0200 @@ -1 +1 @@ -2.21.1 +2.21.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/configure new/yast2-control-center-gnome-2.21.2/configure --- old/yast2-control-center-gnome-2.21.1/configure 2011-07-28 12:09:15.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/configure 2011-09-02 16:22:11.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for yast2-control-center-gnome 2.21.0. +# Generated by GNU Autoconf 2.65 for yast2-control-center-gnome 2.21.2. # # Report bugs to <http://bugs.opensuse.org/>. # @@ -701,8 +701,8 @@ # Identity of this package. PACKAGE_NAME='yast2-control-center-gnome' PACKAGE_TARNAME='yast2-control-center-gnome' -PACKAGE_VERSION='2.21.0' -PACKAGE_STRING='yast2-control-center-gnome 2.21.0' +PACKAGE_VERSION='2.21.2' +PACKAGE_STRING='yast2-control-center-gnome 2.21.2' PACKAGE_BUGREPORT='http://bugs.opensuse.org/' PACKAGE_URL='' @@ -1483,7 +1483,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures yast2-control-center-gnome 2.21.0 to adapt to many kinds of systems. +\`configure' configures yast2-control-center-gnome 2.21.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1555,7 +1555,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of yast2-control-center-gnome 2.21.0:";; + short | recursive ) echo "Configuration of yast2-control-center-gnome 2.21.2:";; esac cat <<\_ACEOF @@ -1673,7 +1673,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -yast2-control-center-gnome configure 2.21.0 +yast2-control-center-gnome configure 2.21.2 generated by GNU Autoconf 2.65 Copyright (C) 2009 Free Software Foundation, Inc. @@ -2072,7 +2072,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by yast2-control-center-gnome $as_me 2.21.0, which was +It was created by yast2-control-center-gnome $as_me 2.21.2, which was generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -2995,7 +2995,7 @@ # Define the identity of the package. PACKAGE='yast2-control-center-gnome' - VERSION='2.21.0' + VERSION='2.21.2' cat >>confdefs.h <<_ACEOF @@ -3117,7 +3117,7 @@ -VERSION="2.21.0" +VERSION="2.21.2" RPMNAME="yast2-control-center-gnome" MAINTAINER="Scott Reeves <sree...@novell.com>" @@ -15263,12 +15263,12 @@ pkg_cv_CONTROL_CFLAGS="$CONTROL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 libgnome-menu gio-unix-2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "gtk+-3.0 libgnome-menu gio-unix-2.0") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_CONTROL_CFLAGS=`$PKG_CONFIG --cflags "gtk+-3.0 libgnome-menu gio-unix-2.0" 2>/dev/null` + pkg_cv_CONTROL_CFLAGS=`$PKG_CONFIG --cflags "gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0" 2>/dev/null` else pkg_failed=yes fi @@ -15279,12 +15279,12 @@ pkg_cv_CONTROL_LIBS="$CONTROL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 libgnome-menu gio-unix-2.0\""; } >&5 - ($PKG_CONFIG --exists --print-errors "gtk+-3.0 libgnome-menu gio-unix-2.0") 2>&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_CONTROL_LIBS=`$PKG_CONFIG --libs "gtk+-3.0 libgnome-menu gio-unix-2.0" 2>/dev/null` + pkg_cv_CONTROL_LIBS=`$PKG_CONFIG --libs "gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0" 2>/dev/null` else pkg_failed=yes fi @@ -15304,14 +15304,14 @@ _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - CONTROL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gtk+-3.0 libgnome-menu gio-unix-2.0" 2>&1` + CONTROL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0" 2>&1` else - CONTROL_PKG_ERRORS=`$PKG_CONFIG --print-errors "gtk+-3.0 libgnome-menu gio-unix-2.0" 2>&1` + CONTROL_PKG_ERRORS=`$PKG_CONFIG --print-errors "gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$CONTROL_PKG_ERRORS" >&5 - as_fn_error "Package requirements (gtk+-3.0 libgnome-menu gio-unix-2.0) were not met: + as_fn_error "Package requirements (gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0) were not met: $CONTROL_PKG_ERRORS @@ -15885,7 +15885,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by yast2-control-center-gnome $as_me 2.21.0, which was +This file was extended by yast2-control-center-gnome $as_me 2.21.2, which was generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15951,7 +15951,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -yast2-control-center-gnome config.status 2.21.0 +yast2-control-center-gnome config.status 2.21.2 configured by $0, generated by GNU Autoconf 2.65, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/configure.in new/yast2-control-center-gnome-2.21.2/configure.in --- old/yast2-control-center-gnome-2.21.1/configure.in 2011-07-28 12:09:06.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/configure.in 2011-09-02 16:22:02.000000000 +0200 @@ -3,7 +3,7 @@ dnl -- This file is generated by y2autoconf 2.18.11 - DO NOT EDIT! -- dnl (edit configure.in.in instead) -AC_INIT(yast2-control-center-gnome, 2.21.0, http://bugs.opensuse.org/, yast2-control-center-gnome) +AC_INIT(yast2-control-center-gnome, 2.21.2, http://bugs.opensuse.org/, yast2-control-center-gnome) dnl Check for presence of file 'RPMNAME' AC_CONFIG_SRCDIR([RPMNAME]) @@ -18,7 +18,7 @@ AM_INIT_AUTOMAKE(tar-ustar -Wno-portability) dnl Important YaST2 variables -VERSION="2.21.0" +VERSION="2.21.2" RPMNAME="yast2-control-center-gnome" MAINTAINER="Scott Reeves <sree...@novell.com>" @@ -180,7 +180,7 @@ AC_SUBST(GLIB_GENMARSHAL) -PKG_CHECK_MODULES(CONTROL, gtk+-3.0 libgnome-menu gio-unix-2.0) +PKG_CHECK_MODULES(CONTROL, gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0) AC_SUBST(CONTROL_CFLAGS) AC_SUBST(CONTROL_LIBS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/configure.in.in new/yast2-control-center-gnome-2.21.2/configure.in.in --- old/yast2-control-center-gnome-2.21.1/configure.in.in 2011-07-28 11:22:28.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/configure.in.in 2011-09-02 15:59:12.000000000 +0200 @@ -19,7 +19,7 @@ AC_SUBST(GLIB_GENMARSHAL) -PKG_CHECK_MODULES(CONTROL, gtk+-3.0 libgnome-menu gio-unix-2.0) +PKG_CHECK_MODULES(CONTROL, gtk+-3.0 libgnome-menu-3.0 gio-unix-2.0) AC_SUBST(CONTROL_CFLAGS) AC_SUBST(CONTROL_LIBS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/etc/YaST-gnome.menu new/yast2-control-center-gnome-2.21.2/etc/YaST-gnome.menu --- old/yast2-control-center-gnome-2.21.1/etc/YaST-gnome.menu 2011-07-25 11:04:59.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/etc/YaST-gnome.menu 2011-09-02 16:33:09.000000000 +0200 @@ -84,4 +84,18 @@ </Include> </Menu> <DefaultMergeDirs/> + + <Layout> + <Menuname>Software</Menuname> + <Menuname>Hardware</Menuname> + <Menuname>System</Menuname> + <Menuname>Network Devices</Menuname> + <Menuname>Network Services</Menuname> + <Menuname>AppArmor</Menuname> + <Menuname>Security</Menuname> + <Menuname>Virtualization</Menuname> + <Menuname>High Availability</Menuname> + <Menuname>Misc</Menuname> + <Merge type="all" /> + </Layout> </Menu> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/Makefile.am new/yast2-control-center-gnome-2.21.2/src/Makefile.am --- old/yast2-control-center-gnome-2.21.1/src/Makefile.am 2011-07-28 12:09:02.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/Makefile.am 2011-09-02 16:15:23.000000000 +0200 @@ -18,7 +18,8 @@ y2controlcenter_gnome_SOURCES = \ control-center.c \ - gnome-control-center.c + gnome-control-center.c \ + shell-search-renderer.c y2controlcenter_gnome_LDADD = \ $(top_builddir)/src/cut-n-paste/libgnome-control-center/libgnome-control-center.la \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/Makefile.in new/yast2-control-center-gnome-2.21.2/src/Makefile.in --- old/yast2-control-center-gnome-2.21.1/src/Makefile.in 2011-07-28 12:09:17.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/Makefile.in 2011-09-02 16:22:13.000000000 +0200 @@ -53,7 +53,7 @@ am__installdirs = "$(DESTDIR)$(ybindir)" "$(DESTDIR)$(uidir)" PROGRAMS = $(ybin_PROGRAMS) am_y2controlcenter_gnome_OBJECTS = control-center.$(OBJEXT) \ - gnome-control-center.$(OBJEXT) + gnome-control-center.$(OBJEXT) shell-search-renderer.$(OBJEXT) y2controlcenter_gnome_OBJECTS = $(am_y2controlcenter_gnome_OBJECTS) am__DEPENDENCIES_1 = y2controlcenter_gnome_DEPENDENCIES = $(top_builddir)/src/cut-n-paste/libgnome-control-center/libgnome-control-center.la \ @@ -330,7 +330,8 @@ y2controlcenter_gnome_SOURCES = \ control-center.c \ - gnome-control-center.c + gnome-control-center.c \ + shell-search-renderer.c y2controlcenter_gnome_LDADD = \ $(top_builddir)/src/cut-n-paste/libgnome-control-center/libgnome-control-center.la \ @@ -431,6 +432,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/control-center.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gnome-control-center.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell-search-renderer.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/control-center.c new/yast2-control-center-gnome-2.21.2/src/control-center.c --- old/yast2-control-center-gnome-2.21.1/src/control-center.c 2011-07-25 11:36:40.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/control-center.c 2011-09-02 15:37:53.000000000 +0200 @@ -28,6 +28,9 @@ #include <gtk/gtk.h> #include <string.h> +#if 0 +#include <libnotify/notify.h> +#endif #include "cc-shell-log.h" @@ -201,6 +204,10 @@ /* register a symbolic icon size for use in sidebar lists */ gtk_icon_size_register ("cc-sidebar-list", 24, 24); +#if 0 + notify_init ("gnome-control-center"); +#endif + shell = gnome_control_center_new (); /* enforce single instance of this application */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/Makefile.am new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/Makefile.am --- old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/Makefile.am 2011-07-28 12:08:06.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/Makefile.am 2011-09-02 16:14:20.000000000 +0200 @@ -18,7 +18,6 @@ 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 \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/Makefile.in new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/Makefile.in --- old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/Makefile.in 2011-07-28 12:09:17.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/Makefile.in 2011-09-02 16:22:13.000000000 +0200 @@ -52,8 +52,8 @@ libshell_unpatched_la_LIBADD = am__objects_1 = cc-shell-marshal.lo am_libshell_unpatched_la_OBJECTS = cc-shell-log.lo \ - shell-search-renderer.lo cc-shell-category-view.lo \ - cc-shell-item-view.lo cc-shell-model.lo $(am__objects_1) + cc-shell-category-view.lo cc-shell-item-view.lo \ + cc-shell-model.lo $(am__objects_1) libshell_unpatched_la_OBJECTS = $(am_libshell_unpatched_la_OBJECTS) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) @@ -261,7 +261,6 @@ 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 \ @@ -332,7 +331,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cc-shell-log.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cc-shell-marshal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cc-shell-model.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell-search-renderer.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/cc-shell-model.c new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/cc-shell-model.c --- old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/cc-shell-model.c 2011-07-28 11:50:46.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/cc-shell-model.c 2011-09-02 16:12:42.000000000 +0200 @@ -30,43 +30,37 @@ G_DEFINE_TYPE (CcShellModel, cc_shell_model, GTK_TYPE_LIST_STORE) static GdkPixbuf * -load_pixbuf_for_string (const char *icon) +load_pixbuf_for_gicon (GIcon *icon) { GtkIconTheme *theme; + GtkIconInfo *icon_info; GdkPixbuf *pixbuf; GError *err = NULL; - char *icon2 = NULL; if (icon == NULL) return NULL; theme = gtk_icon_theme_get_default (); - /* find the icon */ - if (*icon == '/') + icon_info = gtk_icon_theme_lookup_by_gicon (theme, icon, + 32, GTK_ICON_LOOKUP_FORCE_SIZE); + if (icon_info) { - 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_info_load_icon (icon_info, &err); + if (err) + { + g_warning ("Could not load icon '%s': %s", + gtk_icon_info_get_filename (icon_info), err->message); + g_error_free (err); + } - pixbuf = gtk_icon_theme_load_icon (theme, - icon2 ? icon2 : icon, 32, - GTK_ICON_LOOKUP_FORCE_SIZE, - &err); + gtk_icon_info_free (icon_info); } - - if (err) + else { - g_warning ("Could not load icon '%s': %s", icon2 ? icon2 : icon, - err->message); - g_error_free (err); + g_warning ("Could not find icon"); } - g_free (icon2); - return pixbuf; } @@ -83,13 +77,13 @@ while (cont) { GdkPixbuf *pixbuf; - char *icon; + GIcon *icon; gtk_tree_model_get (model, &iter, - COL_ICON_NAME, &icon, + COL_GICON, &icon, -1); - pixbuf = load_pixbuf_for_string (icon); - g_free (icon); + pixbuf = load_pixbuf_for_gicon (icon); + g_object_unref (icon); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_PIXBUF, pixbuf, -1); @@ -107,7 +101,7 @@ 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}; + GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ICON, G_TYPE_STRV}; gtk_list_store_set_column_types (GTK_LIST_STORE (self), N_COLS, types); @@ -160,13 +154,13 @@ const gchar *category_name, GMenuTreeEntry *item) { - const gchar *icon = gmenu_tree_entry_get_icon (item); - const gchar *name = gmenu_tree_entry_get_name (item); + GAppInfo *appinfo = G_APP_INFO (gmenu_tree_entry_get_app_info (item)); + GIcon *icon = g_app_info_get_icon (appinfo); + const gchar *name = g_app_info_get_name (appinfo); const gchar *desktop = gmenu_tree_entry_get_desktop_file_path (item); - const gchar *comment = gmenu_tree_entry_get_comment (item); + const gchar *comment = g_app_info_get_description (appinfo); gchar *id; GdkPixbuf *pixbuf = NULL; - gchar *search_target; GKeyFile *key_file; gchar **keywords; @@ -202,9 +196,7 @@ g_key_file_free (key_file); key_file = NULL; - pixbuf = load_pixbuf_for_string (icon); - - search_target = g_strconcat (name, " - ", comment, NULL); + pixbuf = load_pixbuf_for_gicon (icon); gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, 0, COL_NAME, name, @@ -212,12 +204,11 @@ COL_ID, id, COL_PIXBUF, pixbuf, COL_CATEGORY, category_name, - COL_SEARCH_TARGET, search_target, - COL_ICON_NAME, icon, + COL_DESCRIPTION, comment, + COL_GICON, icon, COL_KEYWORDS, keywords, -1); g_free (id); - g_free (search_target); g_strfreev (keywords); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/cc-shell-model.h new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/cc-shell-model.h --- old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/cc-shell-model.h 2011-07-28 11:50:46.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/cc-shell-model.h 2011-09-02 15:36:53.000000000 +0200 @@ -60,8 +60,8 @@ COL_ID, COL_PIXBUF, COL_CATEGORY, - COL_SEARCH_TARGET, - COL_ICON_NAME, + COL_DESCRIPTION, + COL_GICON, COL_KEYWORDS, N_COLS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/shell-search-renderer.c new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/shell-search-renderer.c --- old/yast2-control-center-gnome-2.21.1/src/cut-n-paste/shell/shell-search-renderer.c 2011-07-04 16:54:48.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/cut-n-paste/shell/shell-search-renderer.c 1970-01-01 01:00:00.000000000 +0100 @@ -1,351 +0,0 @@ -/* - * 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 <t...@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); -} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/gnome-control-center.c new/yast2-control-center-gnome-2.21.2/src/gnome-control-center.c --- old/yast2-control-center-gnome-2.21.1/src/gnome-control-center.c 2011-07-28 12:07:12.000000000 +0200 +++ new/yast2-control-center-gnome-2.21.2/src/gnome-control-center.c 2011-09-02 16:02:55.000000000 +0200 @@ -84,12 +84,36 @@ #define FIXED_WIDTH 675 +#if 0 +static const gchar * +get_icon_name_from_g_icon (GIcon *gicon) +{ + const gchar * const *names; + GtkIconTheme *icon_theme; + int i; + + if (!G_IS_THEMED_ICON (gicon)) + return NULL; + + names = g_themed_icon_get_names (G_THEMED_ICON (gicon)); + icon_theme = gtk_icon_theme_get_default (); + + for (i = 0; names[i] != NULL; i++) + { + if (gtk_icon_theme_has_icon (icon_theme, names[i])) + return names[i]; + } + + return NULL; +} +#endif + static void activate_panel (GnomeControlCenter *shell, const gchar *id, const gchar *desktop_file, const gchar *name, - const gchar *icon_name) + GIcon *gicon) { GDesktopAppInfo *appinfo; GdkAppLaunchContext *context; @@ -153,6 +177,7 @@ GtkWidget *box; gint i; int nat_height; + const gchar *icon_name; /* create the panel plugin */ panel = g_object_new (panel_type, "shell", shell, NULL); @@ -173,6 +198,7 @@ gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i); /* set the title of the window */ + icon_name = get_icon_name_from_g_icon (gicon); 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); @@ -402,29 +428,39 @@ GtkTreeIter *iter, GnomeControlCenterPrivate *priv) { - gchar *name, *target; + gchar *name, *description; gchar *needle, *haystack; gboolean result; gchar **keywords; - gtk_tree_model_get (model, iter, COL_NAME, &name, - COL_SEARCH_TARGET, &target, + gtk_tree_model_get (model, iter, + COL_NAME, &name, + COL_DESCRIPTION, &description, COL_KEYWORDS, &keywords, -1); - if (!priv->filter_string || !name || !target) + if (!priv->filter_string || !name) { g_free (name); - g_free (target); + g_free (description); g_strfreev (keywords); return FALSE; } needle = g_utf8_casefold (priv->filter_string, -1); - haystack = g_utf8_casefold (target, -1); + haystack = g_utf8_casefold (name, -1); result = (strstr (haystack, needle) != NULL); + if (!result && description) + { + gchar *folded; + + folded = g_utf8_casefold (description, -1); + result = (strstr (folded, needle) != NULL); + g_free (folded); + } + if (!result && keywords) { gint i; @@ -439,7 +475,6 @@ } g_free (name); - g_free (target); g_free (haystack); g_free (needle); g_strfreev (keywords); @@ -585,7 +620,7 @@ "title", COL_NAME); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (search_view), priv->search_renderer, - "search-target", COL_SEARCH_TARGET); + "search-target", COL_DESCRIPTION); /* connect the activated signal */ g_signal_connect (search_view, "desktop-item-activated", @@ -655,43 +690,57 @@ static void reload_menu (GnomeControlCenter *shell) { - GSList *list, *l; + GError *error; GMenuTreeDirectory *d; + GMenuTreeIter *iter; + GMenuTreeItemType next_type; + + error = NULL; + if (!gmenu_tree_load_sync (shell->priv->menu_tree, &error)) + { + g_warning ("Could not load control center menu: %s", error->message); + g_clear_error (&error); + return; + } + d = gmenu_tree_get_root_directory (shell->priv->menu_tree); - list = gmenu_tree_directory_get_contents (d); + iter = gmenu_tree_directory_iter (d); - for (l = list; l; l = l->next) + while ((next_type = gmenu_tree_iter_next (iter)) != GMENU_TREE_ITEM_INVALID) { - GMenuTreeItemType type; - type = gmenu_tree_item_get_type (l->data); - - if (type == GMENU_TREE_ITEM_DIRECTORY) + if (next_type == GMENU_TREE_ITEM_DIRECTORY) { - GSList *contents, *f; + GMenuTreeDirectory *subdir; const gchar *dir_name; + GMenuTreeIter *sub_iter; + GMenuTreeItemType sub_next_type; - contents = gmenu_tree_directory_get_contents (l->data); - dir_name = gmenu_tree_directory_get_name (l->data); + subdir = gmenu_tree_iter_get_directory (iter); + dir_name = gmenu_tree_directory_get_name (subdir); maybe_add_category_view (shell, dir_name); /* add the items from this category to the model */ - for (f = contents; f; f = f->next) + sub_iter = gmenu_tree_directory_iter (subdir); + while ((sub_next_type = gmenu_tree_iter_next (sub_iter)) != GMENU_TREE_ITEM_INVALID) { - if (gmenu_tree_item_get_type (f->data) == GMENU_TREE_ITEM_ENTRY) + if (sub_next_type == GMENU_TREE_ITEM_ENTRY) { + GMenuTreeEntry *item = gmenu_tree_iter_get_entry (sub_iter); cc_shell_model_add_item (CC_SHELL_MODEL (shell->priv->store), dir_name, - f->data); + item); + gmenu_tree_item_unref (item); } } - g_slist_free (contents); + gmenu_tree_iter_unref (sub_iter); + gmenu_tree_item_unref (subdir); } } - g_slist_free (list); + gmenu_tree_iter_unref (iter); } static void @@ -713,17 +762,11 @@ 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 ("YaST-gnome.menu", 0); - - if (priv->menu_tree == NULL) - { - g_warning ("Could not find control center menu"); - return; - } + priv->menu_tree = gmenu_tree_new ("YaST-gnome.menu", 0); reload_menu (shell); - gmenu_tree_add_monitor (priv->menu_tree, (GMenuTreeChangedFunc)on_menu_changed, shell); + g_signal_connect (priv->menu_tree, "changed", G_CALLBACK (on_menu_changed), shell); } static void @@ -789,7 +832,8 @@ GtkTreeIter iter; gboolean iter_valid; gchar *name = NULL; - gchar *desktop, *icon_name; + gchar *desktop; + GIcon *gicon; GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (shell)->priv; @@ -804,7 +848,7 @@ gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter, COL_NAME, &name, COL_DESKTOP_FILE, &desktop, - COL_ICON_NAME, &icon_name, + COL_GICON, &gicon, COL_ID, &id, -1); @@ -818,7 +862,8 @@ g_free (id); g_free (name); g_free (desktop); - g_free (icon_name); + if (gicon) + g_object_unref (gicon); name = NULL; id = NULL; @@ -838,11 +883,12 @@ gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), CAPPLET_PAGE); activate_panel (GNOME_CONTROL_CENTER (shell), start_id, desktop, name, - icon_name); + gicon); g_free (name); g_free (desktop); - g_free (icon_name); + if (gicon) + g_object_unref (gicon); return TRUE; } @@ -945,8 +991,9 @@ if (priv->menu_tree) { - gmenu_tree_remove_monitor (priv->menu_tree, (GMenuTreeChangedFunc)on_menu_changed, object); - gmenu_tree_unref (priv->menu_tree); + g_signal_handlers_disconnect_by_func (priv->menu_tree, + G_CALLBACK (on_menu_changed), object); + g_object_unref (priv->menu_tree); } if (priv->category_views) @@ -1079,6 +1126,11 @@ gtk_widget_grab_focus (self->priv->search_entry); retval = TRUE; break; + case GDK_KEY_Q: + case GDK_KEY_q: + g_object_unref (self); + retval = TRUE; + break; } } return retval; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-control-center-gnome-2.21.1/src/shell-search-renderer.c new/yast2-control-center-gnome-2.21.2/src/shell-search-renderer.c --- old/yast2-control-center-gnome-2.21.1/src/shell-search-renderer.c 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-control-center-gnome-2.21.2/src/shell-search-renderer.c 2011-09-02 16:16:56.000000000 +0200 @@ -0,0 +1,355 @@ +/* + * 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 <t...@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; + /* Fix crash caused by empty comments in yast .desktop files */ + if (full_string) + haystack = g_utf8_casefold (full_string, -1); + else + haystack = g_strdup (""); + + /* 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); +} ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org