Kaydet (Commit) 5d97590d authored tarafından Enrico Tröger's avatar Enrico Tröger

Fix plugin toolbar icon placement. Now they are always inserted before the Quit…

Fix plugin toolbar icon placement. Now they are always inserted before the Quit button if it is the last toolbar element or at the end otherwise.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3361 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst f40aedef
2008-12-11 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/plugins.c, src/toolbar.c:
Fix plugin toolbar icon placement. Now they are always inserted
before the Quit button if it is the last toolbar element or at
the end otherwise.
2008-12-11 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2008-12-11 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/utils.h, src/prefs.c, src/stash.c, src/stash.h, src/keyfile.c, * src/utils.h, src/prefs.c, src/stash.c, src/stash.h, src/keyfile.c,
......
...@@ -1255,13 +1255,12 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item) ...@@ -1255,13 +1255,12 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
GtkToolItem *sep; GtkToolItem *sep;
pos = toolbar_get_insert_position(); pos = toolbar_get_insert_position();
/* pos should be valid even if the quit btn is hidden */
g_return_if_fail(pos >= 0);
gtk_toolbar_insert(toolbar, item, pos);
sep = gtk_separator_tool_item_new(); sep = gtk_separator_tool_item_new();
gtk_toolbar_insert(toolbar, sep, pos + 1); gtk_toolbar_insert(toolbar, sep, pos);
autosep->widget = GTK_WIDGET(sep); autosep->widget = GTK_WIDGET(sep);
gtk_toolbar_insert(toolbar, item, pos + 1);
} }
else else
{ {
......
...@@ -247,14 +247,31 @@ GtkWidget *toolbar_init(void) ...@@ -247,14 +247,31 @@ GtkWidget *toolbar_init(void)
/* Returns the position for adding new toolbar items. The returned position can be used /* 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 * to add new toolbar items with @c gtk_toolbar_insert(). The toolbar object can be accessed
* with @a geany->main_widgets->toolbar. * with @a geany->main_widgets->toolbar.
* The position is always the last one before the Quit button (if it is shown). * The position is always the last one before the Quit button or the very last position if the
* Quit button is not the last toolbar item.
* *
* @return The position for new toolbar items or @c -1 if an error occurred. * @return The position for new toolbar items.
*/ */
gint toolbar_get_insert_position(void) gint toolbar_get_insert_position(void)
{ {
GtkWidget *quit = toolbar_get_widget_by_name("Quit"); GtkWidget *quit = toolbar_get_widget_by_name("Quit");
gint pos = gtk_toolbar_get_item_index(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOL_ITEM(quit)); gint quit_pos = -1, pos;
if (quit != NULL)
quit_pos = gtk_toolbar_get_item_index(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOL_ITEM(quit));
pos = gtk_toolbar_get_n_items(GTK_TOOLBAR(main_widgets.toolbar));
if (quit_pos == (pos - 1))
{
/* if the toolbar item before the quit button is a separator, insert new items before */
if (GTK_IS_SEPARATOR_TOOL_ITEM(gtk_toolbar_get_nth_item(
GTK_TOOLBAR(main_widgets.toolbar), quit_pos - 1)))
{
return quit_pos - 1;
}
/* else return the position of the quit button to insert new items before */
return quit_pos;
}
return pos; return pos;
} }
......
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