Fl_Shared_Image* IconLoader::get_icon(const char* name, IconSizes sz, IconContext ctx, unsigned long options) { const char* path; Fl_Shared_Image* img = NULL; /* Fl_Shared_Image::get(xxx, 0, 0) will not resize image */ int sz_wh = 0; if(NOT_SET(options, ICON_LOADER_OPTION_NO_ICON_SCALE)) sz_wh = (int)sz; if(NOT_SET(options, ICON_LOADER_OPTION_NO_ABSOLUTE_PATH)) { /* try to directly open it */ img = Fl_Shared_Image::get(name, sz_wh, sz_wh); if(img) return img; } path = get_icon_path(name, sz, ctx); img = Fl_Shared_Image::get(path, sz_wh, sz_wh); /* no image, try fallback then */ if(!img && fallback_icon) { path = get_icon_path(fallback_icon, sz, ctx); img = Fl_Shared_Image::get(path, sz_wh, sz_wh); } return img; }
void load_tray_icon() { if (!hime_status_tray) return; if (!tray_icon) { create_tray(NULL); return; } // wrong width & height if it is not embedded-ready if (!gtk_status_icon_is_embedded(tray_icon)) return; iw = gtk_status_icon_get_size(tray_icon), ih = gtk_status_icon_get_size(tray_icon); if (!pixbuf) { char icon_fname[128]; get_icon_path(HIME_TRAY_PNG, icon_fname); pixbuf = gdk_pixbuf_new_from_file_at_size(icon_fname, iw, ih, NULL); } char *iconame = HIME_TRAY_PNG; // if (current_CS && current_CS->in_method && inmd) // Workaround due to issue #161 if (current_CS && current_CS->im_state != HIME_STATE_DISABLED && current_CS->im_state != HIME_STATE_ENG_FULL) iconame = inmd[current_CS->in_method].icon; char fname[512]; if (iconame) get_icon_path(iconame, fname); if (strcmp(pixbuf_ch_fname, fname) && pixbuf_ch) { g_object_unref(pixbuf_ch); pixbuf_ch = NULL; } if (!pixbuf_ch) { strcpy(pixbuf_ch_fname, fname); pixbuf_ch = gdk_pixbuf_new_from_file_at_size(fname, iw, ih, NULL); } draw_icon(); iconame = NULL; }
void create_inmd_switch() { menu = gtk_menu_new (); int i; for(i=0; i < inmdN; i++) { if (!inmd[i].cname || !inmd[i].cname[0]) continue; char tt[64]; sprintf(tt, "%s ctrl-alt-%c", inmd[i].cname, inmd[i].key_ch); GtkWidget *item = gtk_image_menu_item_new_with_label (tt); if (inmd[i].icon) { char fname[512]; get_icon_path(inmd[i].icon, fname); GtkWidget *img = gtk_image_new_from_file(fname); if (img) gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); } g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (cb_update_menu_select), GINT_TO_POINTER(i)); gtk_widget_show(item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); } }
static gboolean tray_appindicator_load_icon(char fallback[], char iconfile[], char iconame[], char icondir[]) { char iconpath[256]; gboolean icon_readable; get_icon_path(iconfile, iconpath); icon_readable = !access(iconpath, R_OK); if (icon_readable) { // iconpath exists // TODO: check iconpath.endWith(iconfile); strcpy(icondir, iconpath); icondir[strlen(icondir)-strlen(iconfile)] = 0; // TODO: check file extension before cut 4 bytes strcpy(iconame, iconfile); iconame[strlen(iconame)-4] = 0; return icon_readable; } else if (strcmp(fallback, HIME_TRAY_PNG)) { // iconpath does not exist, then fallback strcpy(iconfile, fallback); return tray_appindicator_load_icon(HIME_TRAY_PNG, iconfile, iconame, icondir); } else { return FALSE; } }
void load_tray_icon_win32() { dbg("load_tray_icon_win32\n"); #if WIN32 // when login, creating icon too early may cause block in gtk_status_icon_new_from_file if (win32_tray_disabled /* || !gcin_status_tray */) return; #endif // dbg("load_tray_icon_win32\n"); #if UNIX char *tip; tip=""; #else wchar_t *tip; tip=L""; #endif char *iconame="en-tsin.png"; char tt[32]; strcpy(tt, iconame); if (!current_CS || current_CS->im_state == GCIN_STATE_DISABLED||current_CS->im_state == GCIN_STATE_ENG_FULL) { iconame=capslock_on?"en-gcin-A.png":GCIN_TRAY_PNG; } else { iconame=inmd[current_CS->in_method].icon; } // dbg("caps %d %s\n", capslock_on, iconame); // dbg("tsin_pho_mode() %d\n", tsin_pho_mode()); gboolean is_tsin = current_method_type()==method_type_TSIN; if (current_CS && current_CS->im_state == GCIN_STATE_CHINESE && !tsin_pho_mode()) { if ((is_tsin || current_method_type()==method_type_MODULE)) { strcpy(tt, "en-"); strcat(tt, iconame); if (capslock_on && is_tsin) strcpy(tt, "en-tsin-A.png"); } else { if (current_method_type()==method_type_GTAB) { strcpy(tt, capslock_on?"en-gtab-A.png":"en-gtab.png"); } } iconame = tt; } dbg("iconame %s\n", iconame); char fname[128]; fname[0]=0; if (iconame) get_icon_path(iconame, fname); char *icon_st=NULL; char fname_state[128]; // dbg("%d %d\n",current_CS->im_state,current_CS->b_half_full_char); if (current_CS && (current_CS->im_state == GCIN_STATE_ENG_FULL || current_CS->im_state != GCIN_STATE_DISABLED && current_CS->b_half_full_char || current_method_type()==method_type_TSIN && tss.tsin_half_full)) { if (gb_output) { icon_st="full-simp.png"; tip = _L("全形/簡體輸出"); } else { icon_st="full-trad.png"; tip = _L("全形/正體輸出"); } } else { if (gb_output) { icon_st="half-simp.png"; tip= _L("半形/簡體輸出"); } else { icon_st="half-trad.png"; tip = _L("半形/正體輸出"); } } get_icon_path(icon_st, fname_state); // dbg("wwwwwwww %s\n", fname_state); if (gcin_status_win) disp_win_screen_status(fname, fname_state); if (!gcin_status_tray) return; #if UNIX if (gcin_win32_icon==GCIN_TRAY_UNIX) return; #endif if (icon_main) { // dbg("set %s %s\n", fname, fname_state); gtk_status_icon_set_from_file(icon_main, fname); gtk_status_icon_set_from_file(icon_state, fname_state); } else { // dbg("gtk_status_icon_new_from_file a\n"); icon_main = gtk_status_icon_new_from_file(fname); g_signal_connect(G_OBJECT(icon_main),"activate", G_CALLBACK (cb_activate), NULL); g_signal_connect(G_OBJECT(icon_main),"popup-menu", G_CALLBACK (cb_popup), NULL); // dbg("gtk_status_icon_new_from_file %s b\n", fname_state); icon_state = gtk_status_icon_new_from_file(fname_state); g_signal_connect(G_OBJECT(icon_state),"activate", G_CALLBACK (cb_activate_state), NULL); g_signal_connect(G_OBJECT(icon_state),"popup-menu", G_CALLBACK (cb_popup_state), NULL); // dbg("icon %s %s\n", fname, fname_state); } #if GTK_CHECK_VERSION(2,16,0) if (icon_state) gtk_status_icon_set_tooltip_text(icon_state, _(tip)); #endif if (icon_main) { char tt[64]; if (current_CS && inmd[current_CS->in_method].cname && inmd[current_CS->in_method].cname[0]) { dbg("cname %s\n", inmd[current_CS->in_method].cname); strcpy(tt, inmd[current_CS->in_method].cname); } if (!iconame || !strcmp(iconame, GCIN_TRAY_PNG) || !tsin_pho_mode()) strcpy(tt, "English"); #if GTK_CHECK_VERSION(2,16,0) gtk_status_icon_set_tooltip_text(icon_main, tt); #endif } return; }
void load_tray_icon_double() { if (!hime_status_tray) return; if (hime_tray_display != HIME_TRAY_DISPLAY_DOUBLE) return; #if WIN32 // when login, creating icon too early may cause block in gtk_status_icon_new_from_file if (win32_tray_disabled) return; #endif destroy_other_tray(); // dbg("load_tray_icon_win32\n"); #if UNIX char *tip; tip=""; #else wchar_t *tip; tip=L""; #endif char *iconame; if (!current_CS || current_CS->im_state == HIME_STATE_DISABLED||current_CS->im_state == HIME_STATE_ENG_FULL) { iconame=HIME_TRAY_PNG; } else { iconame=inmd[current_CS->in_method].icon; } // dbg("tsin_pho_mode() %d\n", tsin_pho_mode()); char tt[32]; if (current_CS && current_CS->im_state == HIME_STATE_CHINESE && !tsin_pho_mode()) { if ((current_method_type()==method_type_TSIN || current_method_type()==method_type_MODULE)) { strcpy(tt, "en-"); strcat(tt, iconame); } else { strcpy(tt, "en-tsin.png"); } iconame = tt; } // dbg("iconame %s\n", iconame); char fname[128]; fname[0]=0; if (iconame) get_icon_path(iconame, fname); char *icon_st=NULL; char fname_state[128]; // dbg("%d %d\n",current_CS->im_state,current_CS->b_half_full_char); if (current_CS && (current_CS->im_state == HIME_STATE_ENG_FULL || (current_CS->im_state != HIME_STATE_DISABLED && current_CS->b_half_full_char) || (current_method_type()==method_type_TSIN && tss.tsin_half_full))) { if (gb_output) { icon_st="full-simp.png"; tip = _("全形/簡體輸出"); } else { icon_st="full-trad.png"; tip = _("全形/正體輸出"); } } else { if (gb_output) { icon_st="half-simp.png"; tip= _("半形/簡體輸出"); } else { icon_st="half-trad.png"; tip = _("半形/正體輸出"); } } get_icon_path(icon_st, fname_state); // dbg("wwwwwwww %s\n", fname_state); if (icon_main) { // dbg("set %s %s\n", fname, fname_state); gtk_status_icon_set_from_file(icon_main, fname); gtk_status_icon_set_from_file(icon_state, fname_state); } else { // dbg("gtk_status_icon_new_from_file a\n"); icon_main = gtk_status_icon_new_from_file(fname); g_signal_connect(G_OBJECT(icon_main),"activate", G_CALLBACK (cb_activate), NULL); g_signal_connect(G_OBJECT(icon_main),"popup-menu", G_CALLBACK (cb_popup), NULL); // dbg("gtk_status_icon_new_from_file %s b\n", fname_state); icon_state = gtk_status_icon_new_from_file(fname_state); g_signal_connect(G_OBJECT(icon_state),"activate", G_CALLBACK (cb_activate_state), NULL); g_signal_connect(G_OBJECT(icon_state),"popup-menu", G_CALLBACK (cb_popup_state), NULL); // dbg("icon %s %s\n", fname, fname_state); } #if GTK_CHECK_VERSION(2,16,0) if (icon_state) gtk_status_icon_set_tooltip_text(icon_state, _(tip)); #endif if (icon_main) { char tt[64]; if (current_CS && inmd[current_CS->in_method].cname[0]) strcpy(tt, inmd[current_CS->in_method].cname); if (!iconame || !strcmp(iconame, HIME_TRAY_PNG) || !tsin_pho_mode()) strcpy(tt, "English"); #if GTK_CHECK_VERSION(2,16,0) gtk_status_icon_set_tooltip_text(icon_main, tt); #endif } return; }
int resize_launcher(void *obj) { Launcher *launcher = obj; GSList *l; int count, icon_size; int icons_per_column=1, icons_per_row=1, marging=0; if (panel_horizontal) { icon_size = launcher->area.height; } else { icon_size = launcher->area.width; } icon_size = icon_size - (2 * launcher->area.bg->border.width) - (2 * launcher->area.paddingy); if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size) icon_size = launcher_max_icon_size; // Resize icons if necessary for (l = launcher->list_icons; l ; l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon *)l->data; if (launcherIcon->icon_size != icon_size || !launcherIcon->icon_original) { launcherIcon->icon_size = icon_size; launcherIcon->area.width = launcherIcon->icon_size; launcherIcon->area.height = launcherIcon->icon_size; // Get the path for an icon file with the new size char *new_icon_path = get_icon_path(launcher->list_themes, launcherIcon->icon_name, launcherIcon->icon_size); if (!new_icon_path) { // Draw a blank icon free_icon(launcherIcon->icon_original); launcherIcon->icon_original = NULL; free_icon(launcherIcon->icon_scaled); launcherIcon->icon_scaled = NULL; continue; } if (launcherIcon->icon_path && strcmp(new_icon_path, launcherIcon->icon_path) == 0) { // If it's the same file just rescale free_icon(launcherIcon->icon_scaled); launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, icon_size); free(new_icon_path); fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path); } else { // Free the old files free_icon(launcherIcon->icon_original); free_icon(launcherIcon->icon_scaled); launcherIcon->icon_original = launcherIcon->icon_scaled = NULL; // Load the new file and scale #ifdef HAVE_RSVG if (g_str_has_suffix(new_icon_path, ".svg")) { GError* err = NULL; RsvgHandle* svg = rsvg_handle_new_from_file(new_icon_path, &err); if (err != NULL) { fprintf(stderr, "Could not load svg image!: %s", err->message); g_error_free(err); launcherIcon->icon_original = NULL; } else { char suffix[128]; sprintf(suffix, "tmpicon-%d.png", getpid()); gchar *name = g_build_filename(g_get_user_config_dir(), "tint2", suffix, NULL); GdkPixbuf *pixbuf = rsvg_handle_get_pixbuf(svg); gdk_pixbuf_save(pixbuf, name, "png", NULL, NULL); launcherIcon->icon_original = imlib_load_image_immediately_without_cache(name); g_remove(name); g_free(name); g_object_unref(G_OBJECT(pixbuf)); g_object_unref(G_OBJECT(svg)); } } else #endif { launcherIcon->icon_original = imlib_load_image_immediately(new_icon_path); } // On loading error, fallback to default if (!launcherIcon->icon_original) { free(new_icon_path); new_icon_path = get_icon_path(launcher->list_themes, DEFAULT_ICON, launcherIcon->icon_size); if (new_icon_path) launcherIcon->icon_original = imlib_load_image_immediately(new_icon_path); } if (!launcherIcon->icon_original) { // Loading default icon failed, draw a blank icon free(new_icon_path); } else { // Loaded icon successfully launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, launcherIcon->icon_size); free(launcherIcon->icon_path); launcherIcon->icon_path = new_icon_path; fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path); } } } } count = g_slist_length(launcher->list_icons); if (panel_horizontal) { if (!count) { launcher->area.width = 0; } else { int height = launcher->area.height - 2*launcher->area.bg->border.width - 2*launcher->area.paddingy; // here icons_per_column always higher than 0 icons_per_column = (height+launcher->area.paddingx) / (icon_size+launcher->area.paddingx); marging = height - (icons_per_column-1)*(icon_size+launcher->area.paddingx) - icon_size; icons_per_row = count / icons_per_column + (count%icons_per_column != 0); launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_row) + ((icons_per_row-1) * launcher->area.paddingx); } } else { if (!count) { launcher->area.height = 0; } else { int width = launcher->area.width - 2*launcher->area.bg->border.width - 2*launcher->area.paddingy; // here icons_per_row always higher than 0 icons_per_row = (width+launcher->area.paddingx) / (icon_size+launcher->area.paddingx); marging = width - (icons_per_row-1)*(icon_size+launcher->area.paddingx) - icon_size; icons_per_column = count / icons_per_row+ (count%icons_per_row != 0); launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) + (icon_size * icons_per_column) + ((icons_per_column-1) * launcher->area.paddingx); } } int i, posx, posy; int start = launcher->area.bg->border.width + launcher->area.paddingy + marging/2; if (panel_horizontal) { posy = start; posx = launcher->area.bg->border.width + launcher->area.paddingxlr; } else { posx = start; posy = launcher->area.bg->border.width + launcher->area.paddingxlr; } for (i=1, l = launcher->list_icons; l ; i++, l = l->next) { LauncherIcon *launcherIcon = (LauncherIcon*)l->data; launcherIcon->y = posy; launcherIcon->x = posx; launcherIcon->area.posy = ((Area*)launcherIcon->area.parent)->posy + launcherIcon->y; launcherIcon->area.posx = ((Area*)launcherIcon->area.parent)->posx + launcherIcon->x; launcherIcon->area.width = launcherIcon->icon_size; launcherIcon->area.height = launcherIcon->icon_size; //printf("launcher %d : %d,%d\n", i, posx, posy); if (panel_horizontal) { if (i % icons_per_column) { posy += icon_size + launcher->area.paddingx; } else { posy = start; posx += (icon_size + launcher->area.paddingx); } } else { if (i % icons_per_row) { posx += icon_size + launcher->area.paddingx; } else { posx = start; posy += (icon_size + launcher->area.paddingx); } } } return 1; }
AnjutaPluginHandle* anjuta_plugin_handle_new (const gchar *plugin_desc_path) { AnjutaPluginHandle *plugin_handle; AnjutaPluginDescription *desc; char *str; gboolean enable; gchar *contents = NULL; gboolean success = TRUE; /* Load file content */ if (g_file_get_contents (plugin_desc_path, &contents, NULL, NULL)) { desc = anjuta_plugin_description_new_from_string (contents, NULL); g_free (contents); if (!desc) { g_warning ("Bad plugin file: %s\n", plugin_desc_path); return NULL; } } else { return NULL; } plugin_handle = g_object_new (ANJUTA_TYPE_PLUGIN_HANDLE, NULL); /* Initialize plugin handle */ plugin_handle->priv->description = desc; plugin_handle->priv->user_activatable = TRUE; plugin_handle->priv->resident = TRUE; plugin_handle->priv->path = g_path_get_dirname (plugin_desc_path); if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin", "Location", &str)) { plugin_handle->priv->id = str; } else { g_warning ("Couldn't find 'Location'"); success = FALSE; } if (anjuta_plugin_description_get_locale_string (desc, "Anjuta Plugin", "Name", &str)) { plugin_handle->priv->name = str; } else { g_warning ("couldn't find 'Name' attribute."); success = FALSE; } if (anjuta_plugin_description_get_locale_string (desc, "Anjuta Plugin", "Description", &str)) { plugin_handle->priv->about = str; } else { g_warning ("Couldn't find 'Description' attribute."); success = FALSE; } if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin", "Icon", &str)) { plugin_handle->priv->icon_path = get_icon_path (str); g_free (str); } if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin", "Dependencies", &str)) { plugin_handle->priv->dependency_names = property_to_list (str); g_free (str); } if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin", "Interfaces", &str)) { plugin_handle->priv->interfaces = property_to_list (str); g_free (str); } if (anjuta_plugin_description_get_boolean (desc, "Anjuta Plugin", "UserActivatable", &enable)) { plugin_handle->priv->user_activatable = enable; /* DEBUG_PRINT ("Plugin '%s' is not user activatable", plugin_handle->priv->name? plugin_handle->priv->name : "Unknown"); */ } if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin", "Resident", &str)) { if (str && strcasecmp (str, "no") == 0) { plugin_handle->priv->resident = FALSE; } g_free (str); } if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin", "Language", &str)) { plugin_handle->priv->language = str; } if (!success) { g_object_unref (plugin_handle); plugin_handle = NULL; } return plugin_handle; }
gboolean create_tray(gpointer data) { if (da) return FALSE; destroy_other_tray(); egg_tray_icon = egg_tray_icon_new ("hime"); if (!egg_tray_icon) return FALSE; GtkWidget *event_box = gtk_event_box_new (); // Do not use this, otherwise tray menu fails // gtk_event_box_set_visible_window (event_box, FALSE); gtk_container_add (GTK_CONTAINER (egg_tray_icon), event_box); #if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text (event_box, _("左:中英切換 中:小鍵盤 右:選項")); #else GtkTooltips *tips = gtk_tooltips_new (); gtk_tooltips_set_tip (GTK_TOOLTIPS (tips), event_box, _("左:中英切換 中:小鍵盤 右:選項"), NULL); #endif g_signal_connect (G_OBJECT (event_box), "button-press-event", G_CALLBACK (tray_button_press_event_cb), NULL); GError *err = NULL; if (pixbuf) g_object_unref(pixbuf); char icon_fname[128]; get_icon_path(HIME_TRAY_PNG, icon_fname); pixbuf = gdk_pixbuf_new_from_file(icon_fname, &err); int pwidth = gdk_pixbuf_get_width (pixbuf); int pheight = gdk_pixbuf_get_height (pixbuf); da = gtk_drawing_area_new(); g_signal_connect (G_OBJECT (event_box), "destroy", G_CALLBACK (gtk_widget_destroyed), &da); #if !GTK_CHECK_VERSION(2,91,0) g_signal_connect(G_OBJECT(da), "expose-event", G_CALLBACK(cb_expose), NULL); #else g_signal_connect(G_OBJECT(da), "draw", G_CALLBACK(cb_expose), NULL); #endif gtk_container_add (GTK_CONTAINER (event_box), da); gtk_widget_set_size_request(GTK_WIDGET(egg_tray_icon), pwidth, pheight); gtk_widget_show_all (GTK_WIDGET (egg_tray_icon)); tray_da_win = gtk_widget_get_window(da); // tray window is not ready ?? if (!tray_da_win || !GTK_WIDGET_DRAWABLE(da)) { gtk_widget_destroy(GTK_WIDGET(egg_tray_icon)); da = NULL; return FALSE; } PangoContext *context=gtk_widget_get_pango_context(da); PangoFontDescription* desc=pango_context_get_font_description(context); // dbg("zz %s %d\n", pango_font_description_to_string(desc), PANGO_SCALE); pango = gtk_widget_create_pango_layout(da, NULL); pango_layout_set_font_description(pango, desc); #if 1 // strange bug, why do we need this ? desc = (PangoFontDescription *)pango_layout_get_font_description(pango); #endif pango_font_description_set_size(desc, 9 * PANGO_SCALE); #if 0 dbg("aa %s\n", pango_font_description_to_string(desc)); dbg("context %x %x\n", pango_layout_get_context(pango), context); dbg("font %x %x\n",pango_layout_get_font_description(pango), desc); #endif #if !GTK_CHECK_VERSION(2,90,6) gc = gdk_gc_new (tray_da_win); #endif return FALSE; }
void load_tray_icon() { // dbg("load_tray_icon\n"); if (!hime_status_tray) return; if (!da) create_tray(NULL); char *iconame = inmd[current_CS->in_method].icon; char fname[512]; fname[0]=0; if (iconame) get_icon_path(iconame, fname); #if GTK_CHECK_VERSION(2,17,7) GtkAllocation dwdh; gtk_widget_get_allocation(da, &dwdh); int dw = dwdh.width, dh = dwdh.height; #else int dw = da->allocation.width, dh = da->allocation.height; #endif if (!pixbuf || gdk_pixbuf_get_width (pixbuf) != dw || gdk_pixbuf_get_height (pixbuf) != dh) { char icon_fname[128]; get_icon_path(HIME_TRAY_PNG, icon_fname); GError *err = NULL; // dbg("icon_name %s\n", icon_fname); pixbuf = gdk_pixbuf_new_from_file_at_size(icon_fname, dw, dh, &err); //Reduce troublesome when hime-tray.png does not exist //if (!pixbuf) // p_err("cannot load file %s", icon_fname); } #if 0 dbg("fname %x %s\n", fname, fname); #endif if (!fname[0]) { if (pixbuf_ch) g_object_unref(pixbuf_ch); pixbuf_ch = NULL; if (pixbuf_ch_fname) pixbuf_ch_fname[0] = 0; } else if (!pixbuf_ch_fname || strcmp(fname, pixbuf_ch_fname)) { free(pixbuf_ch_fname); pixbuf_ch_fname = strdup(fname); if (pixbuf_ch) g_object_unref(pixbuf_ch); dbg("ch %s\n", fname); GError *err = NULL; pixbuf_ch = gdk_pixbuf_new_from_file_at_size(fname, dw, dh, &err); } update_tray_icon(); }