~ubuntu-branches/ubuntu/saucy/gnome-control-center/saucy-proposed

« back to all changes in this revision

Viewing changes to .pc/58_ubuntu_icon_views_redesign.patch/shell/cc-shell-model.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Sebastien Bacher, Robert Ancell, Iain Lane, Edward Donovan, Rico Tzschichholz, Jeremy Bicha, David Henningsson
  • Date: 2012-11-21 19:32:45 UTC
  • mfrom: (1.1.63)
  • Revision ID: package-import@ubuntu.com-20121121193245-mj61nzz1z4fk3z25
Tags: 1:3.6.3-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in: recommends libcanberra-pulse (lp: #1004973)
* debian/patches/58_ubuntu_icon_views_redesign.patch:
  - drop most of the changes, keep the different grid size though
    to fit on screen with our extra icons
* debian/patches/91_dont_show_in_unity.patch:
  - dropped, show the upstream printer panel and the layout tab
* debian/patches/revert_git_keyboard_gsettings.patch,
  debian/patches/revert_git_stop_using_gconf.patch:
  - dropped the gconf->gsettings reverts

[ Robert Ancell ]
* New upstream release (LP: #1010317)
* debian/control:
  - Bump build-depends on libgnome-desktop-3-dev, libwacom-dev
  - Add build-depends on libclutter-1.0-dev, libclutter-gtk-1.0-dev,
    libpwquality-dev
  - Drop build-depends on libgnomekbd-dev
* debian/patches/60_ubuntu_nav_bar.patch:
  - Disabled for now, doesn't apply
* debian/patches/revert_ua_gsettings.patch:
  - We can use GSettings for universal access now
* debian/patches/00git_online_accounts_gtkgrid.patch:
* debian/patches/00git_online_accounts_layout.part:
* debian/patches/git_wacom_translations.patch:
  - Applied upstream

[ Iain Lane ]
* Add Build-Depends on libxkbfile-dev
* New upstream release.
* Refresh all patches to apply cleanly.

[ Edward Donovan ]
* debian/source_gnome-control-center.py: Fix for Python 3. (LP: #1013171)

[ Rico Tzschichholz ]
* debian/control.in:
  - Build-depend on gtk-doc-tools instead of docbook directly
  - Bump minimum glib-2.0, gnome-desktop3, gnome-settings-daemon
     and gsettings-desktop-schemas

[ Jeremy Bicha ]
* Dropped more patches applied in new version:
  - git_unmute_sound_event.patch
  - git_fix_big_editable_labels.patch
  - 96_sound_nua_panel.patch
* debian/patches/04_new_appearance_settings.patch:
  - Dropped, this is now packaged separately as gnome-control-center-unity
* debian/patches/10_keyboard_layout_on_unity.patch:
  - Don't change the keyboard panel name when not running Unity
* debian/patches/52_ubuntu_language_list_mods.patch:
  - Don't disable adding current language to the list. While this
    fix shows the current language twice, at least it avoids the
    "Ubuntu suddenly in Chinese" bug (LP: #1035219)
* debian/patches/53_use_ubuntu_help.patch:
  - Only show Ubuntu help when running Unity
* debian/patches/58_hide_gdm_notifications.patch:
  - Hide "Show notifications when locked" settings when running Unity
    since it's a GNOME Shell-specific feature
* debian/patches/63_normal_scrollbar_in_a11y.patch:
  - Drop, overlay-scrollbars should handle this instead
* debian/patches/91_dont_show_in_unity.patch:
  - Hide Printers & Region panels in Unity until we're ready to switch
    to them.
* debian/patches/fix-crash-on-user-panel.patch:
  - Dropped, GNOME says it's obsolete
* debian/rules:
  - Build with -z,defs again
  - Explicitly disable ibus support since ibus 1.4 isn't supported in
    this version
* debian/control.in:
  - Drop ubuntu-docs and gnome-user-guide from recommends to suggests
  - Don't recommend indicators; let's leave that to Unity

[ David Henningsson ]
* sound_nua_panel.patch: Rebase to gnome 3.6 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2009, 2010 Intel, Inc.
3
 
 * Copyright (c) 2010 Red Hat, Inc.
4
 
 *
5
 
 * The Control Center is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by the
7
 
 * Free Software Foundation; either version 2 of the License, or (at your
8
 
 * option) any later version.
9
 
 *
10
 
 * The Control Center is distributed in the hope that it will be useful, but
11
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13
 
 * for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License along
16
 
 * with the Control Center; if not, write to the Free Software Foundation,
17
 
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 *
19
 
 * Author: Thomas Wood <thos@gnome.org>
20
 
 */
21
 
 
22
 
#include "cc-shell-model.h"
23
 
#include <string.h>
24
 
 
25
 
#define GNOME_SETTINGS_PANEL_ID_KEY "X-GNOME-Settings-Panel"
26
 
#define GNOME_SETTINGS_PANEL_CATEGORY GNOME_SETTINGS_PANEL_ID_KEY
27
 
#define GNOME_SETTINGS_PANEL_ID_KEYWORDS "Keywords"
28
 
 
29
 
 
30
 
G_DEFINE_TYPE (CcShellModel, cc_shell_model, GTK_TYPE_LIST_STORE)
31
 
 
32
 
static GdkPixbuf *
33
 
load_pixbuf_for_gicon (GIcon *icon)
34
 
{
35
 
  GtkIconTheme *theme;
36
 
  GtkIconInfo *icon_info;
37
 
  GdkPixbuf *pixbuf = NULL;
38
 
  GError *err = NULL;
39
 
 
40
 
  if (icon == NULL)
41
 
    return NULL;
42
 
 
43
 
  theme = gtk_icon_theme_get_default ();
44
 
 
45
 
  icon_info = gtk_icon_theme_lookup_by_gicon (theme, icon,
46
 
                                              32, GTK_ICON_LOOKUP_FORCE_SIZE);
47
 
  if (icon_info)
48
 
    {
49
 
      pixbuf = gtk_icon_info_load_icon (icon_info, &err);
50
 
      if (err)
51
 
        {
52
 
          g_warning ("Could not load icon '%s': %s",
53
 
                     gtk_icon_info_get_filename (icon_info), err->message);
54
 
          g_error_free (err);
55
 
        }
56
 
 
57
 
      gtk_icon_info_free (icon_info);
58
 
    }
59
 
  else
60
 
    {
61
 
      g_warning ("Could not find icon");
62
 
    }
63
 
 
64
 
  return pixbuf;
65
 
}
66
 
 
67
 
static void
68
 
icon_theme_changed (GtkIconTheme *theme,
69
 
                    CcShellModel *self)
70
 
{
71
 
  GtkTreeIter iter;
72
 
  GtkTreeModel *model;
73
 
  gboolean cont;
74
 
 
75
 
  model = GTK_TREE_MODEL (self);
76
 
  cont = gtk_tree_model_get_iter_first (model, &iter);
77
 
  while (cont)
78
 
    {
79
 
      GdkPixbuf *pixbuf;
80
 
      GIcon *icon;
81
 
 
82
 
      gtk_tree_model_get (model, &iter,
83
 
                          COL_GICON, &icon,
84
 
                          -1);
85
 
      pixbuf = load_pixbuf_for_gicon (icon);
86
 
      g_object_unref (icon);
87
 
      gtk_list_store_set (GTK_LIST_STORE (model), &iter,
88
 
                          COL_PIXBUF, pixbuf,
89
 
                          -1);
90
 
 
91
 
      cont = gtk_tree_model_iter_next (model, &iter);
92
 
    }
93
 
}
94
 
 
95
 
static void
96
 
cc_shell_model_class_init (CcShellModelClass *klass)
97
 
{
98
 
}
99
 
 
100
 
static void
101
 
cc_shell_model_init (CcShellModel *self)
102
 
{
103
 
  GType types[] = {G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
104
 
      GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ICON, G_TYPE_STRV};
105
 
 
106
 
  gtk_list_store_set_column_types (GTK_LIST_STORE (self),
107
 
                                   N_COLS, types);
108
 
 
109
 
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (self), COL_NAME,
110
 
                                        GTK_SORT_ASCENDING);
111
 
 
112
 
  g_signal_connect (G_OBJECT (gtk_icon_theme_get_default ()), "changed",
113
 
                    G_CALLBACK (icon_theme_changed), self);
114
 
}
115
 
 
116
 
CcShellModel *
117
 
cc_shell_model_new (void)
118
 
{
119
 
  return g_object_new (CC_TYPE_SHELL_MODEL, NULL);
120
 
}
121
 
 
122
 
static gboolean
123
 
desktop_entry_has_panel_category (GKeyFile *key_file)
124
 
{
125
 
  char   **strv;
126
 
  gsize    len;
127
 
  int      i;
128
 
 
129
 
  strv = g_key_file_get_string_list (key_file,
130
 
                                     "Desktop Entry",
131
 
                                     "Categories",
132
 
                                     &len,
133
 
                                     NULL);
134
 
  if (!strv)
135
 
    return FALSE;
136
 
 
137
 
  for (i = 0; strv[i]; i++)
138
 
    {
139
 
      if (g_str_equal (strv[i], GNOME_SETTINGS_PANEL_CATEGORY))
140
 
        {
141
 
          g_strfreev (strv);
142
 
          return TRUE;
143
 
        }
144
 
    }
145
 
 
146
 
  g_strfreev (strv);
147
 
 
148
 
  return FALSE;
149
 
 
150
 
}
151
 
 
152
 
void
153
 
cc_shell_model_add_item (CcShellModel   *model,
154
 
                         const gchar    *category_name,
155
 
                         GMenuTreeEntry *item)
156
 
{
157
 
  GAppInfo    *appinfo = G_APP_INFO (gmenu_tree_entry_get_app_info (item));
158
 
  GIcon       *icon = g_app_info_get_icon (appinfo);
159
 
  const gchar *name = g_app_info_get_name (appinfo);
160
 
  const gchar *desktop = gmenu_tree_entry_get_desktop_file_path (item);
161
 
  const gchar *comment = g_app_info_get_description (appinfo);
162
 
  gchar *id;
163
 
  GdkPixbuf *pixbuf = NULL;
164
 
  GKeyFile *key_file;
165
 
  gchar **keywords;
166
 
 
167
 
  /* load the .desktop file since gnome-menus doesn't have a way to read
168
 
   * custom properties from desktop files */
169
 
 
170
 
  key_file = g_key_file_new ();
171
 
  g_key_file_load_from_file (key_file, desktop, 0, NULL);
172
 
 
173
 
  id = g_key_file_get_string (key_file, "Desktop Entry",
174
 
                              GNOME_SETTINGS_PANEL_ID_KEY, NULL);
175
 
 
176
 
  if (!id)
177
 
    {
178
 
      /* Refuse to load desktop files without a panel ID, but
179
 
       * with the X-GNOME-Settings-Panel category */
180
 
      if (desktop_entry_has_panel_category (key_file))
181
 
        {
182
 
          g_warning ("Not loading desktop file '%s' because it uses the "
183
 
                     GNOME_SETTINGS_PANEL_CATEGORY
184
 
                     " category but isn't a panel.",
185
 
                     desktop);
186
 
         g_key_file_free (key_file);
187
 
         return;
188
 
        }
189
 
      id = g_strdup (gmenu_tree_entry_get_desktop_file_id (item));
190
 
    }
191
 
 
192
 
  keywords = g_key_file_get_locale_string_list (key_file, "Desktop Entry",
193
 
                                                GNOME_SETTINGS_PANEL_ID_KEYWORDS,
194
 
                                                NULL, NULL, NULL);
195
 
 
196
 
  g_key_file_free (key_file);
197
 
  key_file = NULL;
198
 
 
199
 
  pixbuf = load_pixbuf_for_gicon (icon);
200
 
 
201
 
  gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, 0,
202
 
                                     COL_NAME, name,
203
 
                                     COL_DESKTOP_FILE, desktop,
204
 
                                     COL_ID, id,
205
 
                                     COL_PIXBUF, pixbuf,
206
 
                                     COL_CATEGORY, category_name,
207
 
                                     COL_DESCRIPTION, comment,
208
 
                                     COL_GICON, icon,
209
 
                                     COL_KEYWORDS, keywords,
210
 
                                     -1);
211
 
 
212
 
  g_free (id);
213
 
  g_strfreev (keywords);
214
 
}