From b7472341170e1c01170313662a1212ee15f3dd52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Mon, 8 Sep 2008 14:28:59 +0000 Subject: [PATCH] Add ui_get_toolbar_insert_position() for plugins to get a position to insert new toolbar items. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2930 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 3 +++ src/plugindata.h | 1 + src/plugins.c | 3 ++- src/ui_utils.c | 19 +++++++++++++++++++ src/ui_utils.h | 2 ++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8816882e..3c9a0a17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * scripts/missing-mnemonics.sh, scripts/svn-add.sh: Remove bashisms. Add support for passing asterisk wildcards to missing-mnemonics.sh. + * src/plugindata.h, src/plugins.c, src/ui_utils.c, src/ui_utils.h: + Add ui_get_toolbar_insert_position() for plugins to get a position to + insert new toolbar items. 2008-09-07 Frank Lanitz diff --git a/src/plugindata.h b/src/plugindata.h index fb88cff9..83180b6f 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -335,6 +335,7 @@ typedef struct UIUtilsFuncs void (*table_add_row) (GtkTable *table, gint row, ...) G_GNUC_NULL_TERMINATED; GtkWidget* (*path_box_new) (const gchar *title, GtkFileChooserAction action, GtkEntry *entry); GtkWidget* (*button_new_with_image) (const gchar *stock_id, const gchar *text); + gint (*get_toolbar_insert_position) (void); } UIUtilsFuncs; diff --git a/src/plugins.c b/src/plugins.c index 23193b03..8789ceb6 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -173,7 +173,7 @@ static UtilsFuncs utils_funcs = { &utils_get_setting_integer, &utils_get_setting_string, &utils_spawn_sync, - &utils_spawn_async, + &utils_spawn_async }; static UIUtilsFuncs uiutils_funcs = { @@ -183,6 +183,7 @@ static UIUtilsFuncs uiutils_funcs = { &ui_table_add_row, &ui_path_box_new, &ui_button_new_with_image, + &ui_get_toolbar_insert_position }; static DialogFuncs dialog_funcs = { diff --git a/src/ui_utils.c b/src/ui_utils.c index 1c2c69db..a47fb53f 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -1532,3 +1532,22 @@ void ui_init(void) } +/** Returns the position for adding new toolbar items. The returned position can be used + * to add new toolbar items with @c gtk_toolbar_insert(). The toolbar object can be accessed + * with @a geany->main_widgets->toolbar. + * The position is always the last one before the Quit button (if it is shown). + * + * @return The position for new toolbar items or @c -1 if an error occurred. + */ +gint ui_get_toolbar_insert_position(void) +{ + GtkWidget *quit = lookup_widget(main_widgets.window, "toolbutton_quit"); + gint pos = gtk_toolbar_get_item_index(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOL_ITEM(quit)); + + if (pos > 0) + pos--; /* use one position before the real position of the quit button to place new + * items between the last separator and the quit button */ + + return pos; +} + diff --git a/src/ui_utils.h b/src/ui_utils.h index bd6efb4f..18cea619 100644 --- a/src/ui_utils.h +++ b/src/ui_utils.h @@ -231,4 +231,6 @@ gboolean ui_tree_view_find_previous(GtkTreeView *treeview, TVMatchCallback cb); void ui_statusbar_showhide(gboolean state); +gint ui_get_toolbar_insert_position(void); + #endif