SF.net SVN: geany:[3361] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Thu Dec 11 16:51:46 UTC 2008


Revision: 3361
          http://geany.svn.sourceforge.net/geany/?rev=3361&view=rev
Author:   eht16
Date:     2008-12-11 16:51:46 +0000 (Thu, 11 Dec 2008)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/plugins.c
    trunk/src/toolbar.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-12-11 16:49:59 UTC (rev 3360)
+++ trunk/ChangeLog	2008-12-11 16:51:46 UTC (rev 3361)
@@ -1,3 +1,11 @@
+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>
 
  * src/utils.h, src/prefs.c, src/stash.c, src/stash.h, src/keyfile.c,

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2008-12-11 16:49:59 UTC (rev 3360)
+++ trunk/src/plugins.c	2008-12-11 16:51:46 UTC (rev 3361)
@@ -1255,13 +1255,12 @@
 		GtkToolItem *sep;
 
 		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();
-		gtk_toolbar_insert(toolbar, sep, pos + 1);
+		gtk_toolbar_insert(toolbar, sep, pos);
 		autosep->widget = GTK_WIDGET(sep);
+
+		gtk_toolbar_insert(toolbar, item, pos + 1);
 	}
 	else
 	{

Modified: trunk/src/toolbar.c
===================================================================
--- trunk/src/toolbar.c	2008-12-11 16:49:59 UTC (rev 3360)
+++ trunk/src/toolbar.c	2008-12-11 16:51:46 UTC (rev 3361)
@@ -247,15 +247,32 @@
 /*  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).
+ *  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)
 {
 	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;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list