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
|
@ -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);
|
||||
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 *
|
||||
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);
|
||||
else
|
||||
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 *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue