night-light: Rework implementation

This commit improves the Night Light code in various
ways:

 * Turn it into a template class, subclass of GtkDialog,
   and adapts all the code to reflect that.

 * Update the code style in various places, to make it
   more conformant with the documented code style.

 * Reorganize the code a bit, moving functions around,
   to make it more conformant with the documented order.
parent f0bba596
Pipeline #13477 passed with stages
in 3 minutes and 21 seconds
......@@ -269,13 +269,14 @@ cc_display_panel_dispose (GObject *object)
g_clear_object (&priv->current_config);
g_clear_object (&priv->up_client);
g_clear_object (&priv->settings_color);
g_clear_object (&priv->night_light_dialog);
g_clear_object (&priv->main_size_group);
g_cancellable_cancel (priv->shell_cancellable);
g_clear_object (&priv->shell_cancellable);
g_clear_object (&priv->shell_proxy);
g_clear_pointer (&priv->night_light_dialog, gtk_widget_destroy);
G_OBJECT_CLASS (cc_display_panel_parent_class)->dispose (object);
}
......@@ -2145,7 +2146,8 @@ cc_display_panel_night_light_activated (CcDisplayPanel *panel)
CcDisplayPanelPrivate *priv = panel->priv;
GtkWindow *toplevel;
toplevel = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel))));
cc_night_light_dialog_present (priv->night_light_dialog, toplevel);
gtk_window_set_transient_for (GTK_WINDOW (priv->night_light_dialog), toplevel);
gtk_window_present (GTK_WINDOW (priv->night_light_dialog));
}
static void
......
This diff is collapsed.
......@@ -25,10 +25,8 @@
G_BEGIN_DECLS
#define CC_TYPE_NIGHT_LIGHT_DIALOG (cc_night_light_dialog_get_type ())
G_DECLARE_FINAL_TYPE (CcNightLightDialog, cc_night_light_dialog, CC, NIGHT_LIGHT_DIALOG, GObject)
G_DECLARE_FINAL_TYPE (CcNightLightDialog, cc_night_light_dialog, CC, NIGHT_LIGHT_DIALOG, GtkDialog)
CcNightLightDialog *cc_night_light_dialog_new (void);
void cc_night_light_dialog_present (CcNightLightDialog *self,
GtkWindow *parent);
CcNightLightDialog* cc_night_light_dialog_new (void);
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/display">
<file preprocess="xml-stripblanks">display.ui</file>
<file preprocess="xml-stripblanks">cc-night-light-dialog.ui</file>
<file>display-arrangement.css</file>
<file>16x16/sunrise.png</file>
<file>16x16/sunset.png</file>
......
......@@ -29,7 +29,7 @@ sources = files(
)
resource_data = files(
'display.ui',
'cc-night-light-dialog.ui',
'icons/16x16/sunset.png',
'icons/16x16/sunrise.png'
)
......
......@@ -31,7 +31,7 @@ panels/datetime/middle.ui
panels/datetime/org.gnome.controlcenter.datetime.policy.in
panels/datetime/ydm.ui
panels/display/cc-display-panel.c
panels/display/display.ui
panels/display/cc-night-light-dialog.ui
panels/display/gnome-display-panel.desktop.in.in
panels/info/cc-info-overview-panel.c
panels/info/cc-info-removable-media-panel.c
......
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