Branch: refs/heads/document-messages Author: Nick Treleaven nick.treleaven@btinternet.com Committer: Nick Treleaven nick.treleaven@btinternet.com Date: Sun, 08 Jan 2012 17:37:58 Commit: eb04c514bab87af60f01ae3c8e9ee1d3fd9bccf8 https://github.com/geany/geany/commit/eb04c514bab87af60f01ae3c8e9ee1d3fd9bcc...
Log Message: ----------- Add API function ui_lookup_stock_label()
Using this can avoid adding i18n strings unnecessarily.
Modified Paths: -------------- plugins/geanyfunctions.h plugins/splitwindow.c src/keybindings.c src/plugindata.h src/plugins.c src/ui_utils.c src/ui_utils.h
Modified: plugins/geanyfunctions.h 2 files changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -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 \
Modified: plugins/splitwindow.c 14 files changed, 1 insertions(+), 13 deletions(-) =================================================================== @@ -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;
Modified: src/keybindings.c 3 files changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -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);
Modified: src/plugindata.h 1 files changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -477,6 +477,7 @@ 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;
Modified: src/plugins.c 3 files changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -247,7 +247,8 @@ &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 = {
Modified: src/ui_utils.c 16 files changed, 16 insertions(+), 0 deletions(-) =================================================================== @@ -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; +}
Modified: src/ui_utils.h 2 files changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -229,6 +229,8 @@ void ui_editable_insert_text_callback(GtkEditable *editable, gchar *new_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);
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).