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.
This commit is contained in:
parent
7322cdc45b
commit
50094b45a6
5 changed files with 96 additions and 2 deletions
|
@ -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 += ' Wacom (Wacom tablet panel) ................. ' + host_is_linux_not_s390.to_string() + '\n'
|
||||||
output += ' Wayland .................................... ' + enable_wayland.to_string() + '\n'
|
output += ' Wayland .................................... ' + enable_wayland.to_string() + '\n'
|
||||||
|
|
||||||
message(output)
|
message(output)
|
|
@ -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('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('ibus', type: 'boolean', value: true, description: 'build with IBus support')
|
||||||
option('tracing', type: 'boolean', value: false, description: 'add extra debugging information')
|
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')
|
|
@ -65,6 +65,7 @@ struct _CcWindow
|
||||||
GtkWidget *search_entry;
|
GtkWidget *search_entry;
|
||||||
GtkWidget *lock_button;
|
GtkWidget *lock_button;
|
||||||
GtkWidget *current_panel_box;
|
GtkWidget *current_panel_box;
|
||||||
|
GtkWidget *development_warning_dialog;
|
||||||
GtkWidget *current_panel;
|
GtkWidget *current_panel;
|
||||||
char *current_panel_id;
|
char *current_panel_id;
|
||||||
GQueue *previous_panels;
|
GQueue *previous_panels;
|
||||||
|
@ -91,6 +92,47 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Auxiliary methods */
|
/* 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);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_style_context_add_provider_for_screen (gtk_widget_get_screen (GTK_WIDGET (self)),
|
||||||
|
GTK_STYLE_PROVIDER (provider),
|
||||||
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
get_symbolic_icon_name_from_g_icon (GIcon *gicon)
|
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);
|
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 */
|
/* CcShell implementation */
|
||||||
static gboolean
|
static gboolean
|
||||||
cc_window_set_active_panel_from_id (CcShell *shell,
|
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;
|
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 */
|
/* GObject Implementation */
|
||||||
static void
|
static void
|
||||||
cc_window_get_property (GObject *object,
|
cc_window_get_property (GObject *object,
|
||||||
|
@ -695,10 +761,13 @@ cc_window_class_init (CcWindowClass *klass)
|
||||||
object_class->dispose = cc_window_dispose;
|
object_class->dispose = cc_window_dispose;
|
||||||
object_class->finalize = cc_window_finalize;
|
object_class->finalize = cc_window_finalize;
|
||||||
|
|
||||||
|
widget_class->map = cc_window_map;
|
||||||
|
|
||||||
g_object_class_override_property (object_class, PROP_ACTIVE_PANEL, "active-panel");
|
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_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);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, header_box);
|
gtk_widget_class_bind_template_child (widget_class, CcWindow, header_box);
|
||||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, header_sizegroup);
|
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_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, 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, 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, previous_button_clicked_cb);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, search_entry_activate_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_set_active_panel (CC_PANEL_LIST (self->panel_list), id);
|
||||||
else
|
else
|
||||||
cc_panel_list_activate (CC_PANEL_LIST (self->panel_list));
|
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 *
|
CcWindow *
|
||||||
|
|
|
@ -8,5 +8,12 @@
|
||||||
will be ignored and the first panel in the list selected.
|
will be ignored and the first panel in the list selected.
|
||||||
</description>
|
</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="show-development-warning" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Show warning when running a development build of Settings</summary>
|
||||||
|
<description>
|
||||||
|
Whether Settings should show a warning when running a development build.
|
||||||
|
</description>
|
||||||
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|
|
@ -224,4 +224,17 @@
|
||||||
<widget name="sidebar_box"/>
|
<widget name="sidebar_box"/>
|
||||||
</widgets>
|
</widgets>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
|
<!-- 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" />
|
||||||
|
</object>
|
||||||
|
|
||||||
</interface>
|
</interface>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue