[gnome-control-center/gbsneto/build-system-improvements: 10/10] window: Warn about flatpak builds



commit f0becd343a85f67b499041c6255ecf65ff2fc075
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri May 11 23:12:52 2018 -0300

    window: Warn about flatpak builds
    
    With this commit, a message dialog pops up whenever
    a flatpak build runs. This is meant to actually annoy,
    so that we're always reminded that things may not work
    as expected.
    
    But the dialog can be dismissed with a single button
    press, so not the end of the world too.

 build-aux/flatpak/org.gnome.Settings.json |  1 +
 shell/cc-window.c                         | 18 ++++++++++++++++++
 shell/window.ui                           | 13 +++++++++++++
 3 files changed, 32 insertions(+)
---
diff --git a/build-aux/flatpak/org.gnome.Settings.json b/build-aux/flatpak/org.gnome.Settings.json
index 75ef6471a..b55e926be 100644
--- a/build-aux/flatpak/org.gnome.Settings.json
+++ b/build-aux/flatpak/org.gnome.Settings.json
@@ -443,6 +443,7 @@
                 }
             ],
             "config-opts" : [
+                "-Dprofile=flatpak",
                 "-Dtracing=true"
             ]
         }
diff --git a/shell/cc-window.c b/shell/cc-window.c
index c6f04abf1..2f6024cd3 100644
--- a/shell/cc-window.c
+++ b/shell/cc-window.c
@@ -65,6 +65,7 @@ struct _CcWindow
   GtkWidget  *search_entry;
   GtkWidget  *lock_button;
   GtkWidget  *current_panel_box;
+  GtkWidget  *flatpak_warning_dialog;
   GtkWidget  *current_panel;
   char       *current_panel_id;
   GQueue     *previous_panels;
@@ -650,6 +651,20 @@ cc_shell_iface_init (CcShellInterface *iface)
   iface->get_toplevel = cc_window_get_toplevel;
 }
 
+/* GtkWidget overrides */
+static void
+cc_window_map (GtkWidget *widget)
+{
+  CcWindow *self = (CcWindow *) widget;
+
+  GTK_WIDGET_CLASS (cc_window_parent_class)->map (widget);
+
+  /* Show a warning for Flatpak builds */
+#ifdef FLATPAK_BUILD
+  gtk_window_present (GTK_WINDOW (self->flatpak_warning_dialog));
+#endif
+}
+
 /* GObject Implementation */
 static void
 cc_window_get_property (GObject    *object,
@@ -727,10 +742,13 @@ cc_window_class_init (CcWindowClass *klass)
   object_class->dispose = cc_window_dispose;
   object_class->finalize = cc_window_finalize;
 
+  widget_class->map = cc_window_map;
+
   g_object_class_override_property (object_class, PROP_ACTIVE_PANEL, "active-panel");
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/ControlCenter/gtk/window.ui");
 
+  gtk_widget_class_bind_template_child (widget_class, CcWindow, flatpak_warning_dialog);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, header);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, header_box);
   gtk_widget_class_bind_template_child (widget_class, CcWindow, header_sizegroup);
diff --git a/shell/window.ui b/shell/window.ui
index 92ff197ce..c45307886 100644
--- a/shell/window.ui
+++ b/shell/window.ui
@@ -224,4 +224,17 @@
       <widget name="sidebar_box"/>
     </widgets>
   </object>
+
+  <!-- Warning dialog for Flatpak builds -->
+  <object class="GtkMessageDialog" id="flatpak_warning_dialog">
+    <property name="message-type">warning</property>
+    <property name="transient-for">CcWindow</property>
+    <property name="resizable">false</property>
+    <property name="modal">true</property>
+    <property name="buttons">ok</property>
+    <property name="text" translatable="yes">GNOME Settings is running with Flatpak</property>
+    <property name="secondary-text" translatable="yes">Flatpak builds are experimental, and only meant to be 
used for development purposes. You may experience misbehaviors, data loss and other unexpected issues. Use 
with caution.</property>
+    <signal name="response" handler="gtk_widget_hide" object="CcWindow" swapped="no" />
+  </object>
+
 </interface>


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