[recipes] Prevent the 'whats new' dialog open repeatedly



commit bb964bdb1ab13270e052a86569d6a8b516f958b3
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 12 22:56:00 2017 -0400

    Prevent the 'whats new' dialog open repeatedly
    
    Treat the 'whats new' dialog like all the other modals,
    and don't allow it to be opened multiple times.

 src/gr-window.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index 98ca2fd..332a5eb 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -93,6 +93,7 @@ struct _GrWindow
 
         GtkWidget *chef_dialog;
         GtkWidget *about_dialog;
+        GtkWidget *news_dialog;
 
         GList *dialogs;
 
@@ -1392,6 +1393,18 @@ gr_window_show_about_dialog (GrWindow *window)
         gr_window_present_dialog (window, GTK_WINDOW (window->about_dialog));
 }
 
+static gboolean
+news_dialog_closed (GtkWidget *widget,
+                    GdkEvent  *event,
+                    gpointer   data)
+{
+        GrWindow *window = data;
+
+        window->news_dialog = NULL;
+
+        return FALSE;
+}
+
 void
 gr_window_show_news (GrWindow *window)
 {
@@ -1401,6 +1414,9 @@ gr_window_show_news (GrWindow *window)
         GtkWidget *box;
         int i;
 
+        if (window->news_dialog)
+                return;
+
         news = get_release_info (PACKAGE_VERSION, "0.0.0");
         if (news->len == 0)
                 return;
@@ -1409,6 +1425,8 @@ gr_window_show_news (GrWindow *window)
         dialog = GTK_WINDOW (gtk_builder_get_object (builder, "dialog"));
         gtk_window_set_transient_for (dialog, GTK_WINDOW (window));
 
+        window->news_dialog = (GtkWidget *)dialog;
+
         gtk_widget_realize (GTK_WIDGET (dialog));
         gdk_window_set_functions (gtk_widget_get_window (GTK_WIDGET (dialog)),
                                   GDK_FUNC_ALL | GDK_FUNC_MINIMIZE | GDK_FUNC_MAXIMIZE);
@@ -1461,6 +1479,7 @@ gr_window_show_news (GrWindow *window)
         }
 
         gtk_widget_show_all (box);
+        g_signal_connect (dialog, "delete-event", G_CALLBACK (news_dialog_closed), window);
         gr_window_present_dialog (GR_WINDOW (window), dialog);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]