static void setup_button (Launcher *launcher) { char *comment; char *name; char *str; char *icon; char *unescaped_str; g_return_if_fail (launcher != NULL); name = panel_key_file_get_locale_string (launcher->key_file, "Name"); comment = panel_key_file_get_locale_string (launcher->key_file, "Comment"); /* Setup tooltip */ if (!PANEL_GLIB_STR_EMPTY (name) && !PANEL_GLIB_STR_EMPTY (comment)) str = g_strdup_printf ("%s\n%s", name, comment); else if (!PANEL_GLIB_STR_EMPTY (name)) str = g_strdup (name); else str = g_strdup (comment); g_free (name); g_free (comment); /* If we can unescape the string, then we probably have an escaped * string (a location e.g.). If we can't, then it most probably means * we have a % that is not here to encode a character, and we don't * want to unescape in this case. See bug #170516 for details. */ unescaped_str = g_uri_unescape_string (str, NULL); if (unescaped_str) { g_free (str); str = unescaped_str; } panel_util_set_tooltip_text (launcher->button, str); /* Setup accessible name */ panel_a11y_set_atk_name_desc (launcher->button, str, NULL); g_free (str); /* Setup icon */ icon = panel_key_file_get_locale_string (launcher->key_file, "Icon"); if (icon && icon[0] == '\0') { g_free (icon); icon = NULL; } if (!icon) icon = guess_icon_from_exec (button_widget_get_icon_theme (BUTTON_WIDGET (launcher->button)), launcher->key_file); if (!icon) icon = g_strdup (PANEL_ICON_LAUNCHER); button_widget_set_icon_name (BUTTON_WIDGET (launcher->button), icon); g_free (icon); }
void panel_action_button_set_type (PanelActionButton *button, PanelActionButtonType type) { g_return_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST); if (type == button->priv->type) return; button->priv->type = type; if (actions [type].icon_name != NULL) button_widget_set_icon_name (BUTTON_WIDGET (button), actions [type].icon_name); panel_util_set_tooltip_text (GTK_WIDGET (button), _(actions [type].tooltip)); panel_a11y_set_atk_name_desc (GTK_WIDGET (button), _(actions [type].tooltip), NULL); panel_action_button_update_sensitivity (button); }