~ballogy/indicator-session/better-fallback-icon

« back to all changes in this revision

Viewing changes to src/indicator-session.c

  • Committer: György Balló
  • Date: 2013-01-02 12:03:07 UTC
  • Revision ID: ballogy@freestart.hu-20130102120307-7n8x7oduj0wsh2ze
Improve fallback icon handling

Instead of monitoring theme changes and use a 
hard-coded "gtk-missing-image", use 
g_themed_icon_new_with_default_fallbacks () to get a proper fallback 
icon (e.g. "system").

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
  GDBusProxy * service_proxy;
65
65
  GSettings * settings;
66
66
  DbusmenuClient * menu_client;
67
 
  GtkIconTheme * icon_theme;
68
67
};
69
68
 
70
69
GType indicator_session_get_type (void);
79
78
                               DbusmenuClient * client,
80
79
                               gpointer user_data);
81
80
static void on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session);
82
 
static void indicator_session_update_icon_callback (GtkWidget * widget, gpointer callback_data);
83
81
static void indicator_session_update_icon_and_a11y (IndicatorSession * self);
84
82
static void indicator_session_update_users_label (IndicatorSession* self,
85
83
                                                  const gchar* name);
129
127
  self->entry.image = GTK_IMAGE (gtk_image_new());
130
128
  self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME,
131
129
                                                    INDICATOR_SESSION_DBUS_OBJECT));
132
 
  /* We need to check if the current icon theme has the hard coded icons.
133
 
   * If not, we'll fall back to a standard icon */
134
 
  self->icon_theme = gtk_icon_theme_get_default();
135
 
  g_signal_connect(G_OBJECT(self->icon_theme),
136
 
                   "changed",
137
 
                   G_CALLBACK(indicator_session_update_icon_callback), self);
138
 
 
139
130
  indicator_session_update_icon_and_a11y (self);
140
131
  g_settings_bind (self->settings, "show-real-name-on-panel",
141
132
                   self->entry.label, "visible",
408
399
  else
409
400
    icon = ICON_ALERT;
410
401
 
411
 
  if (gtk_icon_theme_has_icon (indicator->icon_theme, icon) == FALSE)
412
 
    icon = "gtk-missing-image";
413
 
 
414
 
  g_debug (G_STRLOC" setting icon to \"%s\"", icon);
415
 
  gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image),
416
 
                                icon,
417
 
                                GTK_ICON_SIZE_BUTTON);
 
402
  GIcon * gicon = g_themed_icon_new_with_default_fallbacks (icon);
 
403
  gtk_image_set_from_gicon (GTK_IMAGE(indicator->entry.image),
 
404
                            gicon,
 
405
                            GTK_ICON_SIZE_BUTTON);
 
406
  g_object_unref(gicon);
418
407
}
419
408
  
420
409
static int
448
437
}
449
438
 
450
439
static void
451
 
indicator_session_update_icon_callback (GtkWidget * widget, gpointer callback_data)
452
 
{
453
 
  indicator_session_update_icon_and_a11y ((IndicatorSession *)callback_data);
454
 
}
455
 
 
456
 
static void
457
440
indicator_session_update_icon_and_a11y (IndicatorSession * indicator)
458
441
{
459
442
  const int disposition = calculate_disposition (indicator);