From: Ben Pfaff Date: Tue, 5 Feb 2013 06:40:50 +0000 (-0800) Subject: psppire-window: Avoid doubled separator in Windows menu. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f4e7f1f7846b6a4a68e5f0614ba01ef9ab79fac;p=pspp psppire-window: Avoid doubled separator in Windows menu. John Darrington noticed that sometimes the separator was doubled in the Windows menu. It seems that the code for detecting that we've already added the separator was unreliable, because it would re-add the separator if the number of windows increased from zero, dropped to zero, and then increased again. --- diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 4c7fcf57dc..c1784ac1f1 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009, 2010, 2011 Free Software Foundation + Copyright (C) 2009, 2010, 2011, 2013 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -340,11 +340,12 @@ insert_menuitem_into_menu (PsppireWindow *window, gpointer key) /* Add a separator before adding the first real item. If we add a separator at any other time, sometimes GtkUIManager removes it. */ - if (g_hash_table_size (window->menuitem_table) == 0) + if (!window->added_separator) { GtkWidget *separator = gtk_separator_menu_item_new (); gtk_widget_show (separator); gtk_menu_shell_append (window->menu, separator); + window->added_separator = TRUE; } filename = g_filename_display_name (key); @@ -467,6 +468,7 @@ psppire_window_init (PsppireWindow *window) G_CALLBACK (remove_menuitem), window); + window->added_separator = FALSE; window->dirty = FALSE; g_signal_connect_swapped (window, "delete-event", G_CALLBACK (on_delete), window); diff --git a/src/ui/gui/psppire-window.h b/src/ui/gui/psppire-window.h index e7851cce77..f1273b17a8 100644 --- a/src/ui/gui/psppire-window.h +++ b/src/ui/gui/psppire-window.h @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation + Copyright (C) 2008, 2009, 2010, 2011, 2013 Free Software Foundation This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -73,6 +73,7 @@ struct _PsppireWindow guint insert_handler; guint remove_handler; + gboolean added_separator; gboolean dirty; GTimeVal savetime; };