Commit 50094b45 authored by Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto
Browse files

window: Warn about development builds

With this commit, a message dialog pops up whenever a
development build runs. This is meant to actually annoy,
so that we're always reminded that things may not work
as expected.

Since the dialog can be dismissed with a single button
press, it is not the end of the world. But people still
should be aware that Settings is ~not~ meant to run with
Flatpak, and that this is a development tool only.
parent 7322cdc4
Pipeline #11523 passed with stages
in 4 minutes and 42 seconds
......@@ -282,4 +282,4 @@ output += ' NetworkManager (Network panel) ............. ' + host_is_linux.t
output += ' Wacom (Wacom tablet panel) ................. ' + host_is_linux_not_s390.to_string() + '\n'
output += ' Wayland .................................... ' + enable_wayland.to_string() + '\n'
\ No newline at end of file
......@@ -3,4 +3,4 @@ option('documentation', type: 'boolean', value: false, description: 'build docum
option('gnome_session_libexecdir', type: 'string', value: '', description: 'Directory for gnome-session\'s libexecdir')
option('ibus', type: 'boolean', value: true, description: 'build with IBus support')
option('tracing', type: 'boolean', value: false, description: 'add extra debugging information')
option('wayland', type: 'boolean', value: true, description: 'build with Wayland support')
option('wayland', type: 'boolean', value: true, description: 'build with Wayland support')
\ No newline at end of file
......@@ -65,6 +65,7 @@ struct _CcWindow
GtkWidget *search_entry;
GtkWidget *lock_button;
GtkWidget *current_panel_box;
GtkWidget *development_warning_dialog;
GtkWidget *current_panel;
char *current_panel_id;
GQueue *previous_panels;
......@@ -91,6 +92,47 @@ enum
/* Auxiliary methods */
static gboolean
in_flatpak_sandbox (void)
return g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
static void
add_development_build_css (CcWindow *self)
g_autoptr(GtkCssProvider) provider = NULL;
g_autoptr(GError) error = NULL;
/* This CSS snipped is added on development builds of GNOME Settings. It is
* not meant to be beautiful (althout it is) and is only supposed to integrate
* with Adwaita light (although it integrates well with dark too).
const gchar *development_build_css =
"window.development-version headerbar {\n"
" background: @theme_bg_color linear-gradient(to top,\n"
" alpha(@theme_selected_bg_color, 0.34),\n"
" alpha(@theme_selected_bg_color, 0.27) 2px,\n"
" alpha(@theme_selected_bg_color, 0.20) 3px);\n"
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "development-version");
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, development_build_css, -1, &error);
if (error)
g_error ("Failed to load CSS: %s", error->message);
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (self)),
static gchar *
get_symbolic_icon_name_from_g_icon (GIcon *gicon)
......@@ -580,6 +622,17 @@ split_decorations_cb (GtkSettings *settings,
gtk_header_bar_set_decoration_layout (GTK_HEADER_BAR (self->panel_headerbar), layout_end);
static void
on_development_warning_dialog_responded_cb (GtkWidget *dialog,
gint response,
CcWindow *self)
g_debug ("Disabling development build warning dialog");
g_settings_set_boolean (self->settings, "show-development-warning", FALSE);
gtk_widget_hide (dialog);
/* CcShell implementation */
static gboolean
cc_window_set_active_panel_from_id (CcShell *shell,
......@@ -618,6 +671,19 @@ 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 */
if (in_flatpak_sandbox () && g_settings_get_boolean (self->settings, "show-development-warning"))
gtk_window_present (GTK_WINDOW (self->development_warning_dialog));
/* GObject Implementation */
static void
cc_window_get_property (GObject *object,
......@@ -695,10 +761,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, development_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);
......@@ -714,6 +783,7 @@ cc_window_class_init (CcWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcWindow, top_right_box);
gtk_widget_class_bind_template_callback (widget_class, gdk_window_set_cb);
gtk_widget_class_bind_template_callback (widget_class, on_development_warning_dialog_responded_cb);
gtk_widget_class_bind_template_callback (widget_class, panel_list_view_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, previous_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, search_entry_activate_cb);
......@@ -760,6 +830,10 @@ cc_window_init (CcWindow *self)
cc_panel_list_set_active_panel (CC_PANEL_LIST (self->panel_list), id);
cc_panel_list_activate (CC_PANEL_LIST (self->panel_list));
/* Add a custom CSS class on development builds */
if (in_flatpak_sandbox ())
add_development_build_css (self);
CcWindow *
......@@ -8,5 +8,12 @@
will be ignored and the first panel in the list selected.
<key name="show-development-warning" type="b">
<summary>Show warning when running a development build of Settings</summary>
Whether Settings should show a warning when running a development build.
......@@ -224,4 +224,17 @@
<widget name="sidebar_box"/>
<!-- Warning dialog for development builds -->
<object class="GtkMessageDialog" id="development_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">Warning: Development Version</property>
<property name="secondary-text" translatable="yes">This version of Settings should only be used for development purposes. You may experience incorrect system behavior, data loss, and other unexpected issues. </property>
<signal name="response" handler="on_development_warning_dialog_responded_cb" object="CcWindow" swapped="no" />
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment