psppire-window: Avoid doubled separator in Windows menu. 20130205032134/pspp 20130206032048/pspp 20130207032111/pspp 20130208032126/pspp 20130209032123/pspp 20130210032050/pspp 20130211032108/pspp 20130212032112/pspp 20130213032105/pspp 20130214032106/pspp 20130215032137/pspp 20130216032128/pspp 20130217032054/pspp 20130218032052/pspp 20130219032106/pspp 20130220032108/pspp 20130221032107/pspp 20130222032012/pspp 20130223032034/pspp 20130224032110/pspp 20130225032119/pspp 20130226031903/pspp 20130227031905/pspp 20130228031906/pspp 20130301031844/pspp 20130302032046/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 5 Feb 2013 06:40:50 +0000 (22:40 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 5 Feb 2013 06:40:50 +0000 (22:40 -0800)
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.

src/ui/gui/psppire-window.c
src/ui/gui/psppire-window.h

index 4c7fcf57dc2040c32357e9e371bbad8f6339d75d..c1784ac1f14d7df9a2e1880b27b971de8dc8e624 100644 (file)
@@ -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);
index e7851cce77d520dc5a8de776724faab63d28f69a..f1273b17a84989e02d0635b6572215ca10029aeb 100644 (file)
@@ -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;
 };