Kaydet (Commit) eb04c514 authored tarafından Nick Treleaven's avatar Nick Treleaven

Add API function ui_lookup_stock_label()

Using this can avoid adding i18n strings unnecessarily.
üst 8f44132d
......@@ -302,6 +302,8 @@
geany_functions->p_ui->ui_combo_box_add_to_history
#define ui_menu_add_document_items_sorted \
geany_functions->p_ui->ui_menu_add_document_items_sorted
#define ui_lookup_stock_label \
geany_functions->p_ui->ui_lookup_stock_label
#define dialogs_show_question \
geany_functions->p_dialogs->dialogs_show_question
#define dialogs_show_msgbox \
......
......@@ -199,18 +199,6 @@ static void set_state(enum State id)
}
static const gchar *ui_get_stock_label(const gchar *stock_id)
{
GtkStockItem item;
if (gtk_stock_lookup(stock_id, &item))
return item.label;
g_warning("No stock id '%s'!", stock_id);
return "";
}
/* Create a GtkToolButton with stock icon, label and tooltip.
* @param label can be NULL to use stock label text. @a label can contain underscores,
* which will be removed.
......@@ -222,7 +210,7 @@ static GtkWidget *ui_tool_button_new(const gchar *stock_id, const gchar *label,
if (stock_id && !label)
{
label = ui_get_stock_label(stock_id);
label = ui_lookup_stock_label(stock_id);
}
dupl = utils_str_remove_chars(g_strdup(label), "_");
label = dupl;
......
......@@ -265,7 +265,8 @@ static void init_default_kb(void)
keybindings_set_item(group, GEANY_KEYS_PROJECT_OPEN, NULL,
0, 0, "project_open", _("Open"), LW(project_open1));
keybindings_set_item(group, GEANY_KEYS_PROJECT_PROPERTIES, NULL,
0, 0, "project_properties", _("Project properties"), LW(project_properties1));
0, 0, "project_properties",
ui_lookup_stock_label(GTK_STOCK_PROPERTIES), LW(project_properties1));
group = keybindings_get_core_group(GEANY_KEY_GROUP_EDITOR);
......
......@@ -477,6 +477,7 @@ typedef struct UIUtilsFuncs
const gchar *text, gint history_len);
void (*ui_menu_add_document_items_sorted) (GtkMenu *menu, struct GeanyDocument *active,
GCallback callback, GCompareFunc compare_func);
const gchar* (*ui_lookup_stock_label)(const gchar *stock_id);
}
UIUtilsFuncs;
......
......@@ -247,7 +247,8 @@ static UIUtilsFuncs uiutils_funcs = {
&ui_is_keyval_enter_or_return,
&ui_get_gtk_settings_integer,
&ui_combo_box_add_to_history,
&ui_menu_add_document_items_sorted
&ui_menu_add_document_items_sorted,
&ui_lookup_stock_label
};
static DialogFuncs dialog_funcs = {
......
......@@ -2784,3 +2784,19 @@ void ui_focus_current_document(void)
if (doc != NULL)
document_grab_focus(doc);
}
/** Finds the label text associated with @a stock_id.
* @p stock_id e.g. @c GTK_STOCK_OPEN.
* @return .
* @since Geany 1.22 */
const gchar *ui_lookup_stock_label(const gchar *stock_id)
{
GtkStockItem item;
if (gtk_stock_lookup(stock_id, &item))
return item.label;
g_warning("No stock id '%s'!", stock_id);
return NULL;
}
......@@ -229,6 +229,8 @@ GtkWidget *ui_label_new_bold(const gchar *text);
void ui_label_set_markup(GtkLabel *label, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
const gchar *ui_lookup_stock_label(const gchar *stock_id);
/* End of general widget functions */
void ui_init_builder(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment