From 9b41718e4b95f37edb868e7e345a0804939b9d9e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 10 Jun 2019 15:57:54 -0300 Subject: [PATCH 01/16] power: Capitalize and improve labels As spotted by Allan, these labels do not follow the correct capitalization rules. Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/552 --- panels/power/cc-power-panel.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c index d24b68d542..5a70ed9e15 100644 --- a/panels/power/cc-power-panel.c +++ b/panels/power/cc-power-panel.c @@ -1851,7 +1851,7 @@ add_power_saving_section (CcPowerPanel *self) gtk_container_add (GTK_CONTAINER (box), widget); gtk_box_pack_start (GTK_BOX (self->vbox_power), box, FALSE, TRUE, 0); - row = add_brightness_row (self, _("_Screen brightness"), &self->brightness_scale); + row = add_brightness_row (self, _("_Screen Brightness"), &self->brightness_scale); gtk_widget_show (row); self->brightness_row = row; @@ -1872,7 +1872,7 @@ add_power_saving_section (CcPowerPanel *self) gtk_widget_show (row); box = row_box_new (); gtk_container_add (GTK_CONTAINER (row), box); - title = row_title_new (_("Automatic brightness"), NULL, &label); + title = row_title_new (_("Automatic Brightness"), NULL, &label); gtk_box_pack_start (GTK_BOX (box), title, TRUE, TRUE, 0); self->als_switch = gtk_switch_new (); @@ -1885,7 +1885,7 @@ add_power_saving_section (CcPowerPanel *self) g_signal_connect (G_OBJECT (self->als_switch), "notify::active", G_CALLBACK (als_switch_changed), self); - row = add_brightness_row (self, _("_Keyboard brightness"), &self->kbd_brightness_scale); + row = add_brightness_row (self, _("_Keyboard Brightness"), &self->kbd_brightness_scale); gtk_widget_show (row); self->kbd_brightness_row = row; @@ -1896,7 +1896,7 @@ add_power_saving_section (CcPowerPanel *self) gtk_widget_show (row); box = row_box_new (); gtk_container_add (GTK_CONTAINER (row), box); - title = row_title_new (_("_Dim screen when inactive"), NULL, &label); + title = row_title_new (_("_Dim Screen When Inactive"), NULL, &label); gtk_box_pack_start (GTK_BOX (box), title, TRUE, TRUE, 0); sw = gtk_switch_new (); @@ -1914,7 +1914,7 @@ add_power_saving_section (CcPowerPanel *self) gtk_widget_show (row); box = row_box_new (); gtk_container_add (GTK_CONTAINER (row), box); - title = row_title_new (_("_Blank screen"), NULL, &label); + title = row_title_new (_("_Blank Screen"), NULL, &label); gtk_box_pack_start (GTK_BOX (box), title, TRUE, TRUE, 0); combo = gtk_combo_box_text_new (); @@ -1954,7 +1954,7 @@ add_power_saving_section (CcPowerPanel *self) gtk_widget_hide (row); box = row_box_new (); gtk_container_add (GTK_CONTAINER (row), box); - title = row_title_new (_("_Mobile broadband"), + title = row_title_new (_("_Mobile Broadband"), _("Mobile broadband (LTE, 4G, 3G, etc.) can be turned off to save power."), NULL); gtk_box_pack_start (GTK_BOX (box), title, TRUE, TRUE, 0); @@ -2298,7 +2298,7 @@ add_suspend_and_power_off_section (CcPowerPanel *self) gtk_widget_show (row); box = row_box_new (); gtk_container_add (GTK_CONTAINER (row), box); - title = row_title_new (_("_Automatic suspend"), NULL, NULL); + title = row_title_new (_("_Automatic Suspend"), NULL, NULL); atk_object_set_name (ATK_OBJECT (gtk_widget_get_accessible (self->automatic_suspend_row)), _("Automatic suspend")); gtk_box_pack_start (GTK_BOX (box), title, TRUE, TRUE, 0); @@ -2356,7 +2356,7 @@ add_suspend_and_power_off_section (CcPowerPanel *self) box = row_box_new (); gtk_container_add (GTK_CONTAINER (row), box); - title = row_title_new (_("_When the Power Button is pressed"), NULL, &label); + title = row_title_new (_("Po_wer Button Action"), NULL, &label); gtk_box_pack_start (GTK_BOX (box), title, TRUE, TRUE, 0); combo = gtk_combo_box_text_new (); -- GitLab From be5d6bfba1b3bf5b8dc7f65bea810797bbaed1b9 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 10 Jun 2019 16:26:21 -0300 Subject: [PATCH 02/16] power: Scale row subtitles to 0.9 This matches what the Mouse & Touchpad panel do, and fixes a small inconsistency with the panel. Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/553 --- panels/power/cc-power-panel.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c index 5a70ed9e15..facbb74351 100644 --- a/panels/power/cc-power-panel.c +++ b/panels/power/cc-power-panel.c @@ -219,6 +219,7 @@ row_title_new (const gchar *title, const gchar *subtitle, GtkWidget **title_label) { + PangoAttrList *attributes; GtkWidget *box, *label; box = (GtkWidget *) g_object_new (GTK_TYPE_BOX, @@ -245,6 +246,9 @@ row_title_new (const gchar *title, if (subtitle == NULL) return box; + attributes = pango_attr_list_new (); + pango_attr_list_insert (attributes, pango_attr_scale_new (0.9)); + label = (GtkWidget *) g_object_new (GTK_TYPE_LABEL, "ellipsize", PANGO_ELLIPSIZE_END, "halign", GTK_ALIGN_START, @@ -253,11 +257,14 @@ row_title_new (const gchar *title, "use-underline", TRUE, "visible", TRUE, "xalign", 0.0, + "attributes", attributes, NULL); gtk_style_context_add_class (gtk_widget_get_style_context (label), GTK_STYLE_CLASS_DIM_LABEL); gtk_container_add (GTK_CONTAINER (box), label); + pango_attr_list_unref (attributes); + return box; } -- GitLab From f833bb13addda9b998eff77289df02ac389ab6e1 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 10 Jun 2019 17:08:18 -0300 Subject: [PATCH 03/16] power: Tweak margins and spacing * Add another vertical size group handling only battery rows. * Add more vertical margins to the battery rows -- set to 16px and 14px, respectivelly, the top and bottom margins. * Increase spacing between battery level and labels to 10px. * Increase spacing between titles and subtitles to 4px. Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/553 --- panels/power/cc-power-panel.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c index facbb74351..c31249c514 100644 --- a/panels/power/cc-power-panel.c +++ b/panels/power/cc-power-panel.c @@ -76,6 +76,7 @@ struct _CcPowerPanel GList *boxes; GList *boxes_reverse; + GtkSizeGroup *battery_row_sizegroup; GtkSizeGroup *row_sizegroup; GtkSizeGroup *battery_sizegroup; GtkSizeGroup *charge_sizegroup; @@ -223,6 +224,7 @@ row_title_new (const gchar *title, GtkWidget *box, *label; box = (GtkWidget *) g_object_new (GTK_TYPE_BOX, + "spacing", 4, "margin-bottom", 6, "margin-top", 6, "orientation", GTK_ORIENTATION_VERTICAL, @@ -469,14 +471,14 @@ set_primary (CcPowerPanel *panel, UpDevice *device) row = no_prelight_row_new (); gtk_widget_show (row); - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); gtk_widget_show (box); gtk_container_add (GTK_CONTAINER (row), box); gtk_widget_set_margin_start (box, 12); gtk_widget_set_margin_end (box, 12); - gtk_widget_set_margin_top (box, 6); - gtk_widget_set_margin_bottom (box, 6); + gtk_widget_set_margin_top (box, 16); + gtk_widget_set_margin_bottom (box, 14); levelbar = gtk_level_bar_new (); gtk_widget_show (levelbar); @@ -512,7 +514,7 @@ set_primary (CcPowerPanel *panel, UpDevice *device) gtk_widget_get_accessible (label)); gtk_container_add (GTK_CONTAINER (panel->battery_list), row); - gtk_size_group_add_widget (panel->row_sizegroup, row); + gtk_size_group_add_widget (panel->battery_row_sizegroup, row); g_object_set_data (G_OBJECT (row), "primary", GINT_TO_POINTER (TRUE)); @@ -551,8 +553,14 @@ add_battery (CcPowerPanel *panel, UpDevice *device) row = no_prelight_row_new (); gtk_widget_show (row); box = row_box_new (); + gtk_box_set_spacing (GTK_BOX (box), 10); gtk_container_add (GTK_CONTAINER (row), box); + gtk_widget_set_margin_start (box, 12); + gtk_widget_set_margin_end (box, 12); + gtk_widget_set_margin_top (box, 16); + gtk_widget_set_margin_bottom (box, 14); + box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_widget_show (box2); title = row_title_new (name, NULL, NULL); @@ -603,7 +611,7 @@ add_battery (CcPowerPanel *panel, UpDevice *device) g_object_set_data (G_OBJECT (row), "kind", GINT_TO_POINTER (kind)); gtk_container_add (GTK_CONTAINER (panel->battery_list), row); - gtk_size_group_add_widget (panel->row_sizegroup, row); + gtk_size_group_add_widget (panel->battery_row_sizegroup, row); gtk_widget_set_visible (panel->battery_section, TRUE); } @@ -2536,6 +2544,7 @@ cc_power_panel_init (CcPowerPanel *self) self->gsd_settings = g_settings_new ("org.gnome.settings-daemon.plugins.power"); self->session_settings = g_settings_new ("org.gnome.desktop.session"); + self->battery_row_sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); self->row_sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); self->battery_sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); self->charge_sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); -- GitLab From b46aef0cb65154664565f09050027ccadb9f7d2f Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 11 Jun 2019 08:26:53 -0300 Subject: [PATCH 04/16] display: Make night light dialog a GtkBin And create the dialog manually instead. The next commit will move it to a different page in the panel itself, so not much care was put into makin the dialog perfectly matching. https://gitlab.gnome.org/GNOME/gnome-control-center/issues/533 --- panels/display/cc-display-panel.c | 20 +- panels/display/cc-night-light-dialog.ui | 542 ------------------ ...t-light-dialog.c => cc-night-light-page.c} | 159 +++-- ...t-light-dialog.h => cc-night-light-page.h} | 6 +- panels/display/cc-night-light-page.ui | 514 +++++++++++++++++ panels/display/display.gresource.xml | 2 +- panels/display/meson.build | 4 +- 7 files changed, 615 insertions(+), 632 deletions(-) delete mode 100644 panels/display/cc-night-light-dialog.ui rename panels/display/{cc-night-light-dialog.c => cc-night-light-page.c} (84%) rename panels/display/{cc-night-light-dialog.h => cc-night-light-page.h} (80%) create mode 100644 panels/display/cc-night-light-page.ui diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index 7970e8654d..5030221d05 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -36,7 +36,7 @@ #include "cc-display-config-manager-dbus.h" #include "cc-display-config.h" #include "cc-display-arrangement.h" -#include "cc-night-light-dialog.h" +#include "cc-night-light-page.h" #include "cc-display-resources.h" #include "cc-display-settings.h" @@ -73,7 +73,8 @@ struct _CcDisplayPanel guint focus_id; - CcNightLightDialog *night_light_dialog; + CcNightLightPage *night_light_page; + GtkDialog *night_light_dialog; GSettings *settings_color; UpClient *up_client; @@ -478,6 +479,19 @@ on_night_light_list_box_row_activated_cb (CcDisplayPanel *panel) { GtkWindow *toplevel; toplevel = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)))); + + if (!panel->night_light_dialog) + { + GtkWidget *content_area; + + panel->night_light_dialog = (GtkDialog *)gtk_dialog_new (); + + content_area = gtk_dialog_get_content_area (panel->night_light_dialog); + gtk_container_add (GTK_CONTAINER (content_area), + GTK_WIDGET (panel->night_light_page)); + gtk_widget_show (GTK_WIDGET (panel->night_light_page)); + } + gtk_window_set_transient_for (GTK_WINDOW (panel->night_light_dialog), toplevel); gtk_window_present (GTK_WINDOW (panel->night_light_dialog)); } @@ -1208,7 +1222,7 @@ cc_display_panel_init (CcDisplayPanel *self) 0); gtk_cell_renderer_set_visible (renderer, TRUE); - self->night_light_dialog = cc_night_light_dialog_new (); + self->night_light_page = cc_night_light_page_new (); self->settings_color = g_settings_new ("org.gnome.settings-daemon.plugins.color"); g_signal_connect_object (self->settings_color, "changed", diff --git a/panels/display/cc-night-light-dialog.ui b/panels/display/cc-night-light-dialog.ui deleted file mode 100644 index 69d77d20f9..0000000000 --- a/panels/display/cc-night-light-dialog.ui +++ /dev/null @@ -1,542 +0,0 @@ - - - - - - 23 - 1 - 10 - - - - 59 - 1 - 10 - - - - 23 - 1 - 10 - - - - 59 - 1 - 10 - - - - 3000 - 6000 - 100 - 500 - - - diff --git a/panels/display/cc-night-light-dialog.c b/panels/display/cc-night-light-page.c similarity index 84% rename from panels/display/cc-night-light-dialog.c rename to panels/display/cc-night-light-page.c index 9068155370..7b4d212ea4 100644 --- a/panels/display/cc-night-light-dialog.c +++ b/panels/display/cc-night-light-page.c @@ -25,12 +25,12 @@ #include #include -#include "cc-night-light-dialog.h" +#include "cc-night-light-page.h" #include "shell/cc-object-storage.h" -struct _CcNightLightDialog { - GtkDialog parent; +struct _CcNightLightPage { + GtkBin parent; GtkWidget *box_manual; GtkWidget *infobar_disabled; @@ -62,7 +62,7 @@ struct _CcNightLightDialog { GDesktopClockFormat clock_format; }; -G_DEFINE_TYPE (CcNightLightDialog, cc_night_light_dialog, GTK_TYPE_DIALOG); +G_DEFINE_TYPE (CcNightLightPage, cc_night_light_page, GTK_TYPE_BIN); #define CLOCK_SCHEMA "org.gnome.desktop.interface" #define DISPLAY_SCHEMA "org.gnome.settings-daemon.plugins.color" @@ -70,11 +70,11 @@ G_DEFINE_TYPE (CcNightLightDialog, cc_night_light_dialog, GTK_TYPE_DIALOG); #define NIGHT_LIGHT_PREVIEW_TIMEOUT_SECONDS 5 static void -dialog_adjustments_set_frac_hours (CcNightLightDialog *self, - gdouble value, - GtkAdjustment *adj_hours, - GtkAdjustment *adj_mins, - GtkStack *stack) +dialog_adjustments_set_frac_hours (CcNightLightPage *self, + gdouble value, + GtkAdjustment *adj_hours, + GtkAdjustment *adj_mins, + GtkStack *stack) { gdouble hours; gdouble mins = 0.f; @@ -116,13 +116,12 @@ dialog_adjustments_set_frac_hours (CcNightLightDialog *self, } static void -dialog_update_state (CcNightLightDialog *self) +dialog_update_state (CcNightLightPage *self) { gboolean automatic; gboolean disabled_until_tomorrow = FALSE; gboolean enabled; gdouble value = 0.f; - g_autoptr(GDateTime) dt = g_date_time_new_now_local (); GtkToggleButton *toggle_button; /* only show the infobar if we are disabled */ @@ -239,23 +238,23 @@ dialog_update_state (CcNightLightDialog *self) static gboolean dialog_tick_cb (gpointer user_data) { - CcNightLightDialog *self = (CcNightLightDialog *) user_data; + CcNightLightPage *self = (CcNightLightPage *) user_data; dialog_update_state (self); return G_SOURCE_CONTINUE; } static void -dialog_enabled_notify_cb (GtkSwitch *sw, - GParamSpec *pspec, - CcNightLightDialog *self) +dialog_enabled_notify_cb (GtkSwitch *sw, + GParamSpec *pspec, + CcNightLightPage *self) { g_settings_set_boolean (self->settings_display, "night-light-enabled", gtk_switch_get_active (sw)); } static void -dialog_mode_changed_cb (GtkToggleButton *togglebutton, - CcNightLightDialog *self) +dialog_mode_changed_cb (GtkToggleButton *togglebutton, + CcNightLightPage *self) { if (self->ignore_value_changed) return; @@ -294,8 +293,8 @@ dialog_undisable_call_cb (GObject *source_object, } static void -dialog_undisable_clicked_cb (GtkButton *button, - CcNightLightDialog *self) +dialog_undisable_clicked_cb (GtkButton *button, + CcNightLightPage *self) { g_dbus_proxy_call (self->proxy_color_props, "Set", @@ -311,10 +310,10 @@ dialog_undisable_clicked_cb (GtkButton *button, } static gdouble -dialog_adjustments_get_frac_hours (CcNightLightDialog *self, - GtkAdjustment *adj_hours, - GtkAdjustment *adj_mins, - GtkStack *stack) +dialog_adjustments_get_frac_hours (CcNightLightPage *self, + GtkAdjustment *adj_hours, + GtkAdjustment *adj_mins, + GtkStack *stack) { gdouble value; @@ -328,8 +327,8 @@ dialog_adjustments_get_frac_hours (CcNightLightDialog *self, } static void -dialog_time_from_value_changed_cb (GtkAdjustment *adjustment, - CcNightLightDialog *self) +dialog_time_from_value_changed_cb (GtkAdjustment *adjustment, + CcNightLightPage *self) { gdouble value; @@ -350,8 +349,8 @@ dialog_time_from_value_changed_cb (GtkAdjustment *adjustment, } static void -dialog_time_to_value_changed_cb (GtkAdjustment *adjustment, - CcNightLightDialog *self) +dialog_time_to_value_changed_cb (GtkAdjustment *adjustment, + CcNightLightPage *self) { gdouble value; @@ -371,8 +370,8 @@ dialog_time_to_value_changed_cb (GtkAdjustment *adjustment, } static void -dialog_color_temperature_value_changed_cb (GtkAdjustment *adjustment, - CcNightLightDialog *self) +dialog_color_temperature_value_changed_cb (GtkAdjustment *adjustment, + CcNightLightPage *self) { gdouble value; @@ -397,10 +396,10 @@ dialog_color_temperature_value_changed_cb (GtkAdjustment *adjustment, } static void -dialog_color_properties_changed_cb (GDBusProxy *proxy, - GVariant *changed_properties, - GStrv invalidated_properties, - CcNightLightDialog *self) +dialog_color_properties_changed_cb (GDBusProxy *proxy, + GVariant *changed_properties, + GStrv invalidated_properties, + CcNightLightPage *self) { dialog_update_state (self); } @@ -410,7 +409,7 @@ dialog_got_proxy_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - CcNightLightDialog *self = (CcNightLightDialog *) user_data; + CcNightLightPage *self = (CcNightLightPage *) user_data; GDBusProxy *proxy; g_autoptr(GError) error = NULL; @@ -435,7 +434,7 @@ dialog_got_proxy_props_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - CcNightLightDialog *self = (CcNightLightDialog *) user_data; + CcNightLightPage *self = (CcNightLightPage *) user_data; GDBusProxy *proxy; g_autoptr(GError) error = NULL; @@ -451,8 +450,8 @@ dialog_got_proxy_props_cb (GObject *source_object, } static gboolean -dialog_format_minutes_combobox (GtkSpinButton *spin, - CcNightLightDialog *self) +dialog_format_minutes_combobox (GtkSpinButton *spin, + CcNightLightPage *self) { GtkAdjustment *adjustment; g_autofree gchar *text = NULL; @@ -464,7 +463,7 @@ dialog_format_minutes_combobox (GtkSpinButton *spin, static gboolean dialog_format_hours_combobox (GtkSpinButton *spin, - CcNightLightDialog *self) + CcNightLightPage *self) { GtkAdjustment *adjustment; g_autofree gchar *text = NULL; @@ -478,7 +477,7 @@ dialog_format_hours_combobox (GtkSpinButton *spin, } static void -dialog_update_adjustments (CcNightLightDialog *self) +dialog_update_adjustments (CcNightLightPage *self) { /* from */ if (self->clock_format == G_DESKTOP_CLOCK_FORMAT_24H) @@ -512,17 +511,17 @@ dialog_update_adjustments (CcNightLightDialog *self) } static void -dialog_settings_changed_cb (GSettings *settings_display, - gchar *key, - CcNightLightDialog *self) +dialog_settings_changed_cb (GSettings *settings_display, + gchar *key, + CcNightLightPage *self) { dialog_update_state (self); } static void -dialog_clock_settings_changed_cb (GSettings *settings_display, - gchar *key, - CcNightLightDialog *self) +dialog_clock_settings_changed_cb (GSettings *settings_display, + gchar *key, + CcNightLightPage *self) { self->clock_format = g_settings_get_enum (settings_display, CLOCK_FORMAT_KEY); @@ -542,8 +541,8 @@ dialog_clock_settings_changed_cb (GSettings *settings_display, } static void -dialog_am_pm_from_button_clicked_cb (GtkButton *button, - CcNightLightDialog *self) +dialog_am_pm_from_button_clicked_cb (GtkButton *button, + CcNightLightPage *self) { gdouble value; value = g_settings_get_double (self->settings_display, "night-light-schedule-from"); @@ -558,8 +557,8 @@ dialog_am_pm_from_button_clicked_cb (GtkButton *button, } static void -dialog_am_pm_to_button_clicked_cb (GtkButton *button, - CcNightLightDialog *self) +dialog_am_pm_to_button_clicked_cb (GtkButton *button, + CcNightLightPage *self) { gdouble value; value = g_settings_get_double (self->settings_display, "night-light-schedule-to"); @@ -575,9 +574,9 @@ dialog_am_pm_to_button_clicked_cb (GtkButton *button, /* GObject overrides */ static void -cc_night_light_dialog_finalize (GObject *object) +cc_night_light_page_finalize (GObject *object) { - CcNightLightDialog *self = CC_NIGHT_LIGHT_DIALOG (object); + CcNightLightPage *self = CC_NIGHT_LIGHT_PAGE (object); g_cancellable_cancel (self->cancellable); @@ -589,37 +588,37 @@ cc_night_light_dialog_finalize (GObject *object) if (self->timer_id > 0) g_source_remove (self->timer_id); - G_OBJECT_CLASS (cc_night_light_dialog_parent_class)->finalize (object); + G_OBJECT_CLASS (cc_night_light_page_parent_class)->finalize (object); } static void -cc_night_light_dialog_class_init (CcNightLightDialogClass *klass) +cc_night_light_page_class_init (CcNightLightPageClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - object_class->finalize = cc_night_light_dialog_finalize; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/display/cc-night-light-dialog.ui"); - - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, adjustment_from_hours); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, adjustment_from_minutes); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, adjustment_to_hours); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, adjustment_to_minutes); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, adjustment_color_temperature); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, box_manual); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, infobar_disabled); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, scale_color_temperature); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, spinbutton_from_hours); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, spinbutton_from_minutes); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, spinbutton_to_hours); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, spinbutton_to_minutes); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, stack_from); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, stack_to); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, togglebutton_box); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, togglebutton_automatic); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, togglebutton_manual); - gtk_widget_class_bind_template_child (widget_class, CcNightLightDialog, togglebutton_off); + object_class->finalize = cc_night_light_page_finalize; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/display/cc-night-light-page.ui"); + + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_from_hours); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_from_minutes); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_to_hours); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_to_minutes); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_color_temperature); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, box_manual); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, infobar_disabled); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, scale_color_temperature); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, spinbutton_from_hours); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, spinbutton_from_minutes); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, spinbutton_to_hours); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, spinbutton_to_minutes); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, stack_from); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, stack_to); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_box); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_automatic); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_manual); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_off); gtk_widget_class_bind_template_callback (widget_class, dialog_am_pm_from_button_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_am_pm_to_button_clicked_cb); @@ -635,10 +634,9 @@ cc_night_light_dialog_class_init (CcNightLightDialogClass *klass) } static void -cc_night_light_dialog_init (CcNightLightDialog *self) +cc_night_light_page_init (CcNightLightPage *self) { g_autoptr(GtkCssProvider) provider = NULL; - g_autoptr(GError) error = NULL; gtk_widget_init_template (GTK_WIDGET (self)); @@ -713,11 +711,10 @@ cc_night_light_dialog_init (CcNightLightDialog *self) dialog_update_state (self); } -CcNightLightDialog * -cc_night_light_dialog_new (void) +CcNightLightPage * +cc_night_light_page_new (void) { - return g_object_new (CC_TYPE_NIGHT_LIGHT_DIALOG, - "use-header-bar", TRUE, + return g_object_new (CC_TYPE_NIGHT_LIGHT_PAGE, NULL); } diff --git a/panels/display/cc-night-light-dialog.h b/panels/display/cc-night-light-page.h similarity index 80% rename from panels/display/cc-night-light-dialog.h rename to panels/display/cc-night-light-page.h index fec383367e..79422bbcb4 100644 --- a/panels/display/cc-night-light-dialog.h +++ b/panels/display/cc-night-light-page.h @@ -24,9 +24,9 @@ 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, GtkDialog) +#define CC_TYPE_NIGHT_LIGHT_PAGE (cc_night_light_page_get_type ()) +G_DECLARE_FINAL_TYPE (CcNightLightPage, cc_night_light_page, CC, NIGHT_LIGHT_PAGE, GtkBin) -CcNightLightDialog* cc_night_light_dialog_new (void); +CcNightLightPage* cc_night_light_page_new (void); G_END_DECLS diff --git a/panels/display/cc-night-light-page.ui b/panels/display/cc-night-light-page.ui new file mode 100644 index 0000000000..fc58b20ab3 --- /dev/null +++ b/panels/display/cc-night-light-page.ui @@ -0,0 +1,514 @@ + + + + + + 23 + 1 + 10 + + + + 59 + 1 + 10 + + + + 23 + 1 + 10 + + + + 59 + 1 + 10 + + + + 3000 + 6000 + 100 + 500 + + + diff --git a/panels/display/display.gresource.xml b/panels/display/display.gresource.xml index 04600346b2..fcac1a274e 100644 --- a/panels/display/display.gresource.xml +++ b/panels/display/display.gresource.xml @@ -3,7 +3,7 @@ cc-display-panel.ui cc-display-settings.ui - cc-night-light-dialog.ui + cc-night-light-page.ui display-arrangement.css night-light.css diff --git a/panels/display/meson.build b/panels/display/meson.build index d448e822c8..f2b6f09c43 100644 --- a/panels/display/meson.build +++ b/panels/display/meson.build @@ -25,13 +25,13 @@ sources = files( 'cc-display-config-manager-dbus.c', 'cc-display-config-manager.c', 'cc-display-settings.c', - 'cc-night-light-dialog.c', + 'cc-night-light-page.c', ) resource_data = files( 'cc-display-panel.ui', 'cc-display-settings.ui', - 'cc-night-light-dialog.ui', + 'cc-night-light-page.ui', ) sources += gnome.compile_resources( -- GitLab From 50be7b13c8ba87e6e849223bffad4fbacabfdebc Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 11 Jun 2019 08:49:33 -0300 Subject: [PATCH 05/16] display: Make night light a panel page This introduces a GtkStack to handle the pages; move the current panel to be the "displays" page; and adds the Night Light page as "night-light". A stack switcher was added, as a header widget, to control the stack. https://gitlab.gnome.org/GNOME/gnome-control-center/issues/533 --- panels/display/cc-display-panel.c | 41 +- panels/display/cc-display-panel.ui | 635 ++++++++++++++--------------- 2 files changed, 323 insertions(+), 353 deletions(-) diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index 5030221d05..b15a774f3d 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -75,7 +75,6 @@ struct _CcDisplayPanel CcNightLightPage *night_light_page; GtkDialog *night_light_dialog; - GSettings *settings_color; UpClient *up_client; gboolean lid_is_closed; @@ -104,13 +103,13 @@ struct _CcDisplayPanel GtkWidget *config_type_switcher_frame; GtkLabel *current_output_label; GtkWidget *display_settings_frame; - GtkLabel *night_light_status_label; GtkSwitch *output_enabled_switch; GtkComboBox *output_selection_combo; GtkStack *output_selection_stack; GtkButtonBox *output_selection_two_first; GtkButtonBox *output_selection_two_second; HdyComboRow *primary_display_row; + GtkWidget *stack_switcher; }; CC_PANEL_REGISTER (CcDisplayPanel, cc_display_panel) @@ -428,7 +427,6 @@ cc_display_panel_dispose (GObject *object) g_clear_object (&self->manager); g_clear_object (&self->current_config); g_clear_object (&self->up_client); - g_clear_object (&self->settings_color); g_cancellable_cancel (self->shell_cancellable); g_clear_object (&self->shell_cancellable); @@ -622,6 +620,14 @@ cc_display_panel_get_help_uri (CcPanel *panel) return "help:gnome-help/prefs-display"; } +static GtkWidget * +cc_display_panel_get_title_widget (CcPanel *panel) +{ + CcDisplayPanel *self = CC_DISPLAY_PANEL (panel); + + return self->stack_switcher; +} + static void cc_display_panel_class_init (CcDisplayPanelClass *klass) { @@ -629,7 +635,10 @@ cc_display_panel_class_init (CcDisplayPanelClass *klass) CcPanelClass *panel_class = CC_PANEL_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + g_type_ensure (CC_TYPE_NIGHT_LIGHT_PAGE); + panel_class->get_help_uri = cc_display_panel_get_help_uri; + panel_class->get_title_widget = cc_display_panel_get_title_widget; object_class->constructed = cc_display_panel_constructed; object_class->dispose = cc_display_panel_dispose; @@ -644,13 +653,14 @@ cc_display_panel_class_init (CcDisplayPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, config_type_single); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, current_output_label); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, display_settings_frame); - gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, night_light_status_label); + gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, night_light_page); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, output_enabled_switch); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, output_selection_combo); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, output_selection_stack); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, output_selection_two_first); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, output_selection_two_second); gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, primary_display_row); + gtk_widget_class_bind_template_child (widget_class, CcDisplayPanel, stack_switcher); gtk_widget_class_bind_template_callback (widget_class, on_config_type_toggled_cb); gtk_widget_class_bind_template_callback (widget_class, on_night_light_list_box_row_activated_cb); @@ -1132,22 +1142,6 @@ sensor_proxy_vanished_cb (GDBusConnection *connection, update_has_accel (self); } -static void -night_light_sync_label (GtkWidget *label, GSettings *settings) -{ - gboolean ret = g_settings_get_boolean (settings, "night-light-enabled"); - gtk_label_set_label (GTK_LABEL (label), - /* TRANSLATORS: the state of the night light setting */ - ret ? _("On") : _("Off")); -} - -static void -settings_color_changed_cb (GSettings *settings, gchar *key, GtkWidget *label) -{ - if (g_strcmp0 (key, "night-light-enabled") == 0) - night_light_sync_label (label, settings); -} - static void session_bus_ready (GObject *source, GAsyncResult *res, @@ -1222,13 +1216,6 @@ cc_display_panel_init (CcDisplayPanel *self) 0); gtk_cell_renderer_set_visible (renderer, TRUE); - self->night_light_page = cc_night_light_page_new (); - self->settings_color = g_settings_new ("org.gnome.settings-daemon.plugins.color"); - - g_signal_connect_object (self->settings_color, "changed", - G_CALLBACK (settings_color_changed_cb), self->night_light_status_label, 0); - night_light_sync_label (GTK_WIDGET (self->night_light_status_label), self->settings_color); - self->up_client = up_client_new (); if (up_client_get_lid_is_present (self->up_client)) { diff --git a/panels/display/cc-display-panel.ui b/panels/display/cc-display-panel.ui index 07b3a530fd..5ceff8fdf8 100644 --- a/panels/display/cc-display-panel.ui +++ b/panels/display/cc-display-panel.ui @@ -33,455 +33,438 @@ video-single-display-symbolic 3 + + True + stack + -- GitLab From 28b0acb24ee4dbd104fea7b818de72673833622b Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 11 Jun 2019 10:55:30 -0300 Subject: [PATCH 06/16] display: Rework Night Light page The new Night Light page, as described by the latest mockups [1], uses a listbox to display the options. Also, there is a small revamp on how the disabled state is handled; it now is a switch in a row, instead of an extra radio button. This commit changes the Night Light page to have a listbox, and uses libhandy's rows to achieve the desired interface. Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/533 --- panels/display/cc-night-light-page.c | 127 +++-- panels/display/cc-night-light-page.ui | 637 ++++++++++++-------------- panels/display/night-light.css | 3 +- 3 files changed, 358 insertions(+), 409 deletions(-) diff --git a/panels/display/cc-night-light-page.c b/panels/display/cc-night-light-page.c index 7b4d212ea4..8fb2766466 100644 --- a/panels/display/cc-night-light-page.c +++ b/panels/display/cc-night-light-page.c @@ -26,6 +26,7 @@ #include #include "cc-night-light-page.h" +#include "list-box-helper.h" #include "shell/cc-object-storage.h" @@ -34,17 +35,16 @@ struct _CcNightLightPage { GtkWidget *box_manual; GtkWidget *infobar_disabled; + GtkListBox *listbox; GtkWidget *scale_color_temperature; + GtkWidget *night_light_toggle_switch; + GtkComboBox *schedule_type_combo; GtkWidget *spinbutton_from_hours; GtkWidget *spinbutton_from_minutes; GtkWidget *spinbutton_to_hours; GtkWidget *spinbutton_to_minutes; GtkStack *stack_from; GtkStack *stack_to; - GtkWidget *togglebutton_box; - GtkWidget *togglebutton_automatic; - GtkWidget *togglebutton_manual; - GtkWidget *togglebutton_off; GtkAdjustment *adjustment_from_hours; GtkAdjustment *adjustment_from_minutes; @@ -122,7 +122,6 @@ dialog_update_state (CcNightLightPage *self) gboolean disabled_until_tomorrow = FALSE; gboolean enabled; gdouble value = 0.f; - GtkToggleButton *toggle_button; /* only show the infobar if we are disabled */ if (self->proxy_color != NULL) @@ -139,45 +138,9 @@ dialog_update_state (CcNightLightPage *self) enabled = g_settings_get_boolean (self->settings_display, "night-light-enabled"); automatic = g_settings_get_boolean (self->settings_display, "night-light-schedule-automatic"); - self->ignore_value_changed = TRUE; - if (!enabled) - toggle_button = GTK_TOGGLE_BUTTON (self->togglebutton_off); - else if (automatic) - toggle_button = GTK_TOGGLE_BUTTON (self->togglebutton_automatic); - else - toggle_button = GTK_TOGGLE_BUTTON (self->togglebutton_manual); - gtk_toggle_button_set_active (toggle_button, TRUE); - self->ignore_value_changed = FALSE; - gtk_widget_set_sensitive (self->box_manual, enabled && !automatic); - gtk_widget_set_sensitive (self->scale_color_temperature, enabled); - /* Don't show the off button if it can't be turned off */ - /* Don't allow choosing Manual or "Sunset to Sunrise" if it can't be turned on */ - if (!g_settings_is_writable (self->settings_display, "night-light-enabled")) - { - gtk_widget_set_visible (self->togglebutton_off, !enabled); - gtk_widget_set_sensitive (self->togglebutton_box, enabled); - } - else - { - gtk_widget_set_visible (self->togglebutton_off, TRUE); - gtk_widget_set_sensitive (self->togglebutton_box, TRUE); - } - - /* Don't show the Manual buttons if Manual can't be enabled. Same for "Sunset to Sunrise". */ - if (!g_settings_is_writable (self->settings_display, "night-light-schedule-automatic")) - { - gtk_widget_set_visible (self->togglebutton_automatic, automatic); - gtk_widget_set_visible (self->togglebutton_manual, !automatic); - gtk_widget_set_visible (self->box_manual, !automatic); - } - else - { - gtk_widget_set_visible (self->togglebutton_automatic, TRUE); - gtk_widget_set_visible (self->togglebutton_manual, TRUE); - gtk_widget_set_visible (self->box_manual, TRUE); - } + gtk_combo_box_set_active_id (self->schedule_type_combo, automatic ? "automatic" : "manual"); /* set from */ if (automatic && self->proxy_color != NULL) @@ -235,6 +198,42 @@ dialog_update_state (CcNightLightPage *self) self->ignore_value_changed = FALSE; } +static void +build_schedule_combo_row (CcNightLightPage *self) +{ + gboolean automatic; + gboolean enabled; + + self->ignore_value_changed = TRUE; + + + enabled = g_settings_get_boolean (self->settings_display, "night-light-enabled"); + automatic = g_settings_get_boolean (self->settings_display, "night-light-schedule-automatic"); + + gtk_widget_set_sensitive (self->box_manual, enabled && !automatic); + + gtk_combo_box_set_active_id (self->schedule_type_combo, automatic ? "automatic" : "manual"); + + self->ignore_value_changed = FALSE; +} + +static void +on_schedule_type_combo_active_changed_cb (GtkComboBox *combo_box, + GParamSpec *pspec, + CcNightLightPage *self) +{ + const gchar *active_id; + gboolean automatic; + + if (self->ignore_value_changed) + return; + + active_id = gtk_combo_box_get_active_id (combo_box); + automatic = g_str_equal (active_id, "automatic"); + + g_settings_set_boolean (self->settings_display, "night-light-schedule-automatic", automatic); +} + static gboolean dialog_tick_cb (gpointer user_data) { @@ -252,29 +251,6 @@ dialog_enabled_notify_cb (GtkSwitch *sw, gtk_switch_get_active (sw)); } -static void -dialog_mode_changed_cb (GtkToggleButton *togglebutton, - CcNightLightPage *self) -{ - if (self->ignore_value_changed) - return; - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->togglebutton_automatic))) - { - g_settings_set_boolean (self->settings_display, "night-light-enabled", TRUE); - g_settings_set_boolean (self->settings_display, "night-light-schedule-automatic", TRUE); - } - else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->togglebutton_manual))) - { - g_settings_set_boolean (self->settings_display, "night-light-enabled", TRUE); - g_settings_set_boolean (self->settings_display, "night-light-schedule-automatic", FALSE); - } - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->togglebutton_off))) - { - g_settings_set_boolean (self->settings_display, "night-light-enabled", FALSE); - } -} - static void dialog_undisable_call_cb (GObject *source_object, GAsyncResult *res, @@ -608,6 +584,9 @@ cc_night_light_page_class_init (CcNightLightPageClass *klass) gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, adjustment_color_temperature); gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, box_manual); gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, infobar_disabled); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, listbox); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, night_light_toggle_switch); + gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, schedule_type_combo); gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, scale_color_temperature); gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, spinbutton_from_hours); gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, spinbutton_from_minutes); @@ -615,21 +594,17 @@ cc_night_light_page_class_init (CcNightLightPageClass *klass) gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, spinbutton_to_minutes); gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, stack_from); gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, stack_to); - gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_box); - gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_automatic); - gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_manual); - gtk_widget_class_bind_template_child (widget_class, CcNightLightPage, togglebutton_off); gtk_widget_class_bind_template_callback (widget_class, dialog_am_pm_from_button_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_am_pm_to_button_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_enabled_notify_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_format_hours_combobox); gtk_widget_class_bind_template_callback (widget_class, dialog_format_minutes_combobox); - gtk_widget_class_bind_template_callback (widget_class, dialog_mode_changed_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_time_from_value_changed_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_time_to_value_changed_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_color_temperature_value_changed_cb); gtk_widget_class_bind_template_callback (widget_class, dialog_undisable_clicked_cb); + gtk_widget_class_bind_template_callback (widget_class, on_schedule_type_combo_active_changed_cb); } @@ -640,6 +615,8 @@ cc_night_light_page_init (CcNightLightPage *self) gtk_widget_init_template (GTK_WIDGET (self)); + gtk_list_box_set_header_func (self->listbox, cc_list_box_update_header_func, NULL, NULL); + gtk_scale_add_mark (GTK_SCALE (self->scale_color_temperature), 3000, GTK_POS_BOTTOM, _("More Warm")); @@ -661,6 +638,16 @@ cc_night_light_page_init (CcNightLightPage *self) g_signal_connect (self->settings_display, "changed", G_CALLBACK (dialog_settings_changed_cb), self); + build_schedule_combo_row (self); + + g_settings_bind (self->settings_display, "night-light-enabled", + self->night_light_toggle_switch, "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind_writable (self->settings_display, "night-light-enabled", + self->night_light_toggle_switch, "sensitive", + FALSE); + g_settings_bind_writable (self->settings_display, "night-light-schedule-from", self->spinbutton_from_hours, "sensitive", FALSE); diff --git a/panels/display/cc-night-light-page.ui b/panels/display/cc-night-light-page.ui index fc58b20ab3..45ab12627e 100644 --- a/panels/display/cc-night-light-page.ui +++ b/panels/display/cc-night-light-page.ui @@ -98,382 +98,345 @@ True False - none - - - True - False - start - True - 22 - Schedule - - - - - - + True False - vertical - 22 + none + + - + True - False - fill - True - expand - - - Sunset to Sunrise - True - True - True - False - True - - - - True - True - 0 - - - - - Manual - True - True - True - togglebutton_automatic - False - - - - True - True - 1 - - - - - _Off + Schedule + night_light_toggle_switch + + + True - True - True - False - togglebutton_automatic - True - - - - True - True - 2 - - - - - - - - - - - - True - False - 12 - 18 - - - True - False - start - center - From - spinbutton_from_hours - - - - - - True - False - 6 - - - True - True - 2 - 4 - vertical - adjustment_from_hours - True - True - 4 - - - - - Hour + center + + - - True - False - : - - - - + True - True - 2 - 0 - vertical - adjustment_from_minutes - True - True - - - - - Minute + Schedule Type + + + + + True + center + + + Sunset to Sunrise + Set Time + + + - + True - False - - - AM - True - True - True - center - - - - - am - - - - - PM + Times + + + + True - True - True - center - + False + 6 + 12 + 12 - - - pm - 1 - - - - - True - False - - - blank - 2 - - - - - - - - - True - False - 6 - - - True - True - 2 - 4 - number - vertical - adjustment_to_hours - True - True - 4 - - - - - Hour - - - - - - - True - False - : - - - - - True - True - 2 - 0 - vertical - adjustment_to_minutes - True - True - - - - - Minute + + + True + False + From + spinbutton_from_hours + + + + + + True + False + 4 + + + True + True + 2 + 4 + vertical + adjustment_from_hours + True + True + 4 + + + + + Hour + + + + + + + True + False + : + + + + + True + True + 2 + 0 + vertical + adjustment_from_minutes + True + True + + + + + Minute + + + + + + + True + False + False + + + AM + True + True + True + center + + + + + am + + + + + PM + True + True + True + center + + + + + pm + 1 + + + + + True + False + + + blank + 2 + + + + + + + + + True + False + 6 + To + spinbutton_to_hours + + + + + + True + False + 4 + + + True + True + 2 + 4 + number + vertical + adjustment_to_hours + True + True + 4 + + + + + Hour + + + + + + + True + False + : + + + + + True + True + 2 + 0 + vertical + adjustment_to_minutes + True + True + + + + + Minute + + + + + + + True + False + False + + + AM + True + True + True + center + + + + + am + + + + + PM + True + True + True + center + + + + + pm + 1 + + + + + True + False + + + blank + 2 + + + + + + + + - + True - False - - - AM - True - True - True - center - - - - - am - - - - - PM + Color Temperature + + + + True True - True - center - + True + 12 + 12 + 280 + adjustment_color_temperature + True + False + 1 + 0 + False + False + bottom - - pm - 1 - - - - - True - False - - - blank - 2 - + - - False - True - end - 2 - - - - True - False - start - center - 3 - To - spinbutton_to_hours - - - - False - False - end - 3 - - - - - - - True - False - start - True - Color Temperature - scale_color_temperature - - - - - - - - True - True - True - adjustment_color_temperature - True - False - 1 - 0 - False - False - bottom - + diff --git a/panels/display/night-light.css b/panels/display/night-light.css index a318f2b20e..ce90582083 100644 --- a/panels/display/night-light.css +++ b/panels/display/night-light.css @@ -19,8 +19,7 @@ } .padded-spinbutton { - font-size: 110%; - min-width: 50px; + min-width: 40px; } .unpadded-button { -- GitLab From 70b668855d4a9de8820ab0e7f4153b01fa02bae4 Mon Sep 17 00:00:00 2001 From: Allan Day Date: Fri, 14 Jun 2019 11:13:09 +0100 Subject: [PATCH 07/16] network: Equal spacing between list sections There should be an equal amount of vertical space between each list section. Fixes #550 --- panels/network/cc-network-panel.ui | 1 + 1 file changed, 1 insertion(+) diff --git a/panels/network/cc-network-panel.ui b/panels/network/cc-network-panel.ui index 14c70cde37..e4e75d51c3 100644 --- a/panels/network/cc-network-panel.ui +++ b/panels/network/cc-network-panel.ui @@ -79,6 +79,7 @@ True False vertical + 24 -- GitLab From ed8561ca346ba040f60e8e4ff60f50d651bed7f3 Mon Sep 17 00:00:00 2001 From: p3732 Date: Fri, 7 Jun 2019 01:58:17 +0200 Subject: [PATCH 08/16] wifi: Reorder icons displayed for wifi access points Change the layout of the wifi access point rows according to the new mockups. Fixes #554 --- panels/network/cc-wifi-connection-row.ui | 55 ++++++++++++++---------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/panels/network/cc-wifi-connection-row.ui b/panels/network/cc-wifi-connection-row.ui index 91461491f1..d8be88b9f5 100644 --- a/panels/network/cc-wifi-connection-row.ui +++ b/panels/network/cc-wifi-connection-row.ui @@ -26,6 +26,15 @@ + + + True + False + 6 + network-wireless-signal-excellent-symbolic + 1 + + True @@ -45,13 +54,33 @@ 1 + + + True + False + True + end + network-wireless-encrypted-symbolic + 1 + + + + + True + False + 6 + 6 + 6 + 6 + + button_stack True False end - True + False options_button @@ -96,36 +125,16 @@ - + True - False - - - + empty_box empty - 2 - - - True - False - network-wireless-encrypted-symbolic - 1 - - - - - True - False - network-wireless-signal-excellent-symbolic - 1 - - -- GitLab From e08bc0353382c0ba3c8870fc8870942b6f36f13b Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 14 Jun 2019 13:58:46 -0300 Subject: [PATCH 09/16] network: Add NetDeviceWifi::scanning property This is a boolean property that notifies whether the device is scanning for new access points. This is implemented by monitoring the NMDeviceWifi::last-scan property, as suggested by NetworkManager developers (and due to the lack of a better API), since this property is updated *after* the scan is completed. --- panels/network/net-device-wifi.c | 87 ++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c index 360fbfc72b..dd99a74855 100644 --- a/panels/network/net-device-wifi.c +++ b/panels/network/net-device-wifi.c @@ -61,10 +61,21 @@ struct _NetDeviceWifi gchar *selected_ssid_title; gchar *selected_connection_id; gchar *selected_ap_id; + + gint64 last_scan; + gboolean scanning; + + guint monitor_scanning_id; guint scan_id; GCancellable *cancellable; }; +enum { + PROP_0, + PROP_SCANNING, + PROP_LAST, +}; + G_DEFINE_TYPE (NetDeviceWifi, net_device_wifi, NET_TYPE_DEVICE) GtkWidget * @@ -147,6 +158,10 @@ static void disable_scan_timeout (NetDeviceWifi *device_wifi) { g_debug ("Disabling periodic Wi-Fi scan"); + if (device_wifi->monitor_scanning_id > 0) { + g_source_remove (device_wifi->monitor_scanning_id); + device_wifi->monitor_scanning_id = 0; + } if (device_wifi->scan_id > 0) { g_source_remove (device_wifi->scan_id); device_wifi->scan_id = 0; @@ -407,6 +422,42 @@ out: g_free (last_used); } +static void +set_scanning (NetDeviceWifi *self, + gboolean scanning, + gint64 last_scan) +{ + gboolean scanning_changed = self->scanning != scanning; + + self->scanning = scanning; + self->last_scan = last_scan; + + if (scanning_changed) + g_object_notify (G_OBJECT (self), "scanning"); +} + +static gboolean +update_scanning (gpointer user_data) +{ + NetDeviceWifi *device_wifi = user_data; + NMDevice *nm_device; + gint64 last_scan; + + nm_device = net_device_get_nm_device (NET_DEVICE (device_wifi)); + last_scan = nm_device_wifi_get_last_scan (NM_DEVICE_WIFI (nm_device)); + + /* The last_scan property is updated after the device finished scanning, + * so notify about it and stop monitoring for changes. + */ + if (device_wifi->last_scan != last_scan) { + set_scanning (device_wifi, FALSE, last_scan); + device_wifi->monitor_scanning_id = 0; + return G_SOURCE_REMOVE; + } + + return G_SOURCE_CONTINUE; +} + static gboolean request_scan (gpointer user_data) { @@ -416,6 +467,15 @@ request_scan (gpointer user_data) g_debug ("Periodic Wi-Fi scan requested"); nm_device = net_device_get_nm_device (NET_DEVICE (device_wifi)); + + set_scanning (device_wifi, TRUE, + nm_device_wifi_get_last_scan (NM_DEVICE_WIFI (nm_device))); + + if (device_wifi->monitor_scanning_id == 0) { + device_wifi->monitor_scanning_id = g_timeout_add (1500, update_scanning, + device_wifi); + } + nm_device_wifi_request_scan_async (NM_DEVICE_WIFI (nm_device), device_wifi->cancellable, NULL, NULL); @@ -1394,6 +1454,24 @@ device_wifi_edit (NetObject *object) g_free (cmdline); } +static void +net_device_wifi_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + NetDeviceWifi *self = NET_DEVICE_WIFI (object); + + switch (prop_id) { + case PROP_SCANNING: + g_value_set_boolean (value, self->scanning); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + static void net_device_wifi_class_init (NetDeviceWifiClass *klass) { @@ -1402,9 +1480,18 @@ net_device_wifi_class_init (NetDeviceWifiClass *klass) object_class->finalize = net_device_wifi_finalize; object_class->constructed = net_device_wifi_constructed; + object_class->get_property = net_device_wifi_get_property; parent_class->add_to_stack = device_wifi_proxy_add_to_stack; parent_class->refresh = device_wifi_refresh; parent_class->edit = device_wifi_edit; + + g_object_class_install_property (object_class, + PROP_SCANNING, + g_param_spec_boolean ("scanning", + "Scanning", + "Whether the device is scanning for access points", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); } static void -- GitLab From 0d9aa40cf09cb62f8b7ba4862d4857dd229ec333 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 14 Jun 2019 14:02:55 -0300 Subject: [PATCH 10/16] wifi: Add device widgets after caching in the array This will be required to bind the "scanning" property of the NetDeviceWifi to the GtkSpinner. --- panels/network/cc-wifi-panel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c index de5069425e..63aa3dc58a 100644 --- a/panels/network/cc-wifi-panel.c +++ b/panels/network/cc-wifi-panel.c @@ -166,8 +166,6 @@ add_wifi_device (CcWifiPanel *self, "id", nm_device_get_udi (device), NULL); - net_object_add_to_stack (net_device, self->stack, self->sizegroup); - /* And add to the header widgets */ header_widget = net_device_wifi_get_header_widget (NET_DEVICE_WIFI (net_device)); @@ -177,6 +175,9 @@ add_wifi_device (CcWifiPanel *self, g_ptr_array_add (self->devices, net_device); update_devices_names (self); + + /* Needs to be added after the device is added to the self->devices array */ + net_object_add_to_stack (net_device, self->stack, self->sizegroup); } static void -- GitLab From c4e846481824d2a0a07f4d7039941c6bffb76657 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 14 Jun 2019 14:03:46 -0300 Subject: [PATCH 11/16] wifi: Show a spinner when scanning for new access points The spinner was already present in the UI file! It just needs minor cleanups (such as moving the bottom margin from the label to the parent box) and binding the widget to the structure. We need to monitor which device is visible since the Wi-Fi panel deals with multiple Wi-Fi devices as well. Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/551 --- panels/network/cc-wifi-panel.c | 32 ++++++++++++++++++++++++++++++++ panels/network/cc-wifi-panel.ui | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c index 63aa3dc58a..3dec9a85f2 100644 --- a/panels/network/cc-wifi-panel.c +++ b/panels/network/cc-wifi-panel.c @@ -53,12 +53,14 @@ struct _CcWifiPanel GtkStack *header_stack; GtkStack *main_stack; GtkSizeGroup *sizegroup; + GtkWidget *spinner; GtkStack *stack; NMClient *client; GPtrArray *devices; + GBinding *spinner_binding; GCancellable *cancellable; /* Command-line arguments */ @@ -546,6 +548,34 @@ rfkill_switch_notify_activate_cb (GtkSwitch *rfkill_switch, NULL); } +static void +on_stack_visible_child_changed_cb (GtkStack *stack, + GParamSpec *pspec, + CcWifiPanel *self) +{ + const gchar *visible_device_id = NULL; + guint i; + + /* Remove previous bindings */ + g_clear_pointer (&self->spinner_binding, g_binding_unbind); + + visible_device_id = gtk_stack_get_visible_child_name (stack); + for (i = 0; i < self->devices->len; i++) + { + NetObject *object = g_ptr_array_index (self->devices, i); + + if (g_strcmp0 (net_object_get_id (object), visible_device_id) == 0) + { + self->spinner_binding = g_object_bind_property (object, + "scanning", + self->spinner, + "active", + G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); + break; + } + } +} + /* Overrides */ static const gchar * @@ -687,9 +717,11 @@ cc_wifi_panel_class_init (CcWifiPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, rfkill_switch); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, rfkill_widget); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, sizegroup); + gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, spinner); gtk_widget_class_bind_template_child (widget_class, CcWifiPanel, stack); gtk_widget_class_bind_template_callback (widget_class, rfkill_switch_notify_activate_cb); + gtk_widget_class_bind_template_callback (widget_class, on_stack_visible_child_changed_cb); g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters"); } diff --git a/panels/network/cc-wifi-panel.ui b/panels/network/cc-wifi-panel.ui index 8dd3570ce4..8b86098acd 100644 --- a/panels/network/cc-wifi-panel.ui +++ b/panels/network/cc-wifi-panel.ui @@ -220,12 +220,12 @@ True start 6 + 12 True Visible Networks 0.0 - 12 @@ -233,6 +233,7 @@ + True True @@ -253,6 +254,7 @@ True True crossfade + -- GitLab From e8bd7c24ee3b605d8dc6fdf8856161885c5c3f78 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 14 Jun 2019 11:46:00 -0300 Subject: [PATCH 12/16] sound: Remove icon from sound theme buttons Remove the icon and adjust the label to be vertically centralized. Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/549 --- panels/sound/cc-sound-button.ui | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/panels/sound/cc-sound-button.ui b/panels/sound/cc-sound-button.ui index 1bce20f655..c7eddd9277 100644 --- a/panels/sound/cc-sound-button.ui +++ b/panels/sound/cc-sound-button.ui @@ -7,10 +7,9 @@ True vertical 12 - 12 + center - True audio-speakers-symbolic 32 -- GitLab From a9f02483761fd30b5065560b3e8c1f88b3db667e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 14 Jun 2019 12:34:39 -0300 Subject: [PATCH 13/16] sound: Use fallback icon when stream's icon doesn't exist Some streams may give us an icon name that doesn't exist in the icon theme (e.g. Spotify giving "audio"). While it's fundamentally an application problem, we can deal with this case a bit better than showing the ugly "image-missing" icon. Detect when an icon doesn't exist by performing an icon theme lookup and, if the icon really doesn't exist, use a proper fallback icon. It also avoids a small GIcon leak. Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/548 --- panels/sound/cc-stream-row.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/panels/sound/cc-stream-row.c b/panels/sound/cc-stream-row.c index a750e82e45..62bac69434 100644 --- a/panels/sound/cc-stream-row.c +++ b/panels/sound/cc-stream-row.c @@ -20,6 +20,8 @@ #include "cc-stream-row.h" #include "cc-volume-slider.h" +#define SPEECH_DISPATCHER_PREFIX "speech-dispatcher-" + struct _CcStreamRow { GtkListBoxRow parent_instance; @@ -75,12 +77,34 @@ cc_stream_row_new (GtkSizeGroup *size_group, guint id) { CcStreamRow *self; + g_autoptr(GtkIconInfo) icon_info = NULL; + g_autoptr(GIcon) gicon = NULL; + const gchar *stream_name; + const gchar *icon_name; self = g_object_new (CC_TYPE_STREAM_ROW, NULL); self->stream = g_object_ref (stream); self->id = id; - gtk_image_set_from_gicon (self->icon_image, gvc_mixer_stream_get_gicon (stream), GTK_ICON_SIZE_LARGE_TOOLBAR); + icon_name = gvc_mixer_stream_get_icon_name (stream); + stream_name = gvc_mixer_stream_get_name (stream); + + /* Explicitly lookup for the icon, since some streams may give us an + * icon name (e.g. "audio") that doesn't really exist in the theme. + */ + icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (), + icon_name, + 24, + GTK_ICON_LOOKUP_GENERIC_FALLBACK); + + if (icon_info) + gicon = g_themed_icon_new_with_default_fallbacks (icon_name); + else if (g_str_has_prefix (stream_name, SPEECH_DISPATCHER_PREFIX)) + gicon = g_themed_icon_new_with_default_fallbacks ("preferences-desktop-accessibility-symbolic"); + else + gicon = g_themed_icon_new_with_default_fallbacks ("application-x-executable-symbolic"); + + gtk_image_set_from_gicon (self->icon_image, gicon, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_label_set_label (self->name_label, gvc_mixer_stream_get_name (stream)); cc_volume_slider_set_stream (self->volume_slider, stream); -- GitLab From 041284427a2df2f21b53dce8574a756df72a565b Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 15 Jun 2019 11:32:23 -0300 Subject: [PATCH 14/16] project: Update subprojects Updates libhandy and GVC. The interesting change we are looking for is in GVC, switching the icon of the "System Sounds" stream to "emblem-system-symbolic". --- subprojects/gvc | 2 +- subprojects/libhandy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/gvc b/subprojects/gvc index ae1a34aafc..468022b708 160000 --- a/subprojects/gvc +++ b/subprojects/gvc @@ -1 +1 @@ -Subproject commit ae1a34aafce7026b8c0f65a43c9192d756fe1057 +Subproject commit 468022b708fc1a56154f3b0cc5af3b938fb3e9fb diff --git a/subprojects/libhandy b/subprojects/libhandy index 56b0aa62f6..2d77767735 160000 --- a/subprojects/libhandy +++ b/subprojects/libhandy @@ -1 +1 @@ -Subproject commit 56b0aa62f6251ee19a88fc208b7ca8dcf9c9633c +Subproject commit 2d777677352d037b6f5cc24d9c1c8d9a74ac0ded -- GitLab From b542e9835958d2fda7c3ceeb8ad8eb0c432d262d Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 14 Jun 2019 18:07:45 +0300 Subject: [PATCH 15/16] sounds: Use correct mute icon in the input section The current code does not differenciate between input and output, and thus it shows the same icon for muting outputs and inputs. As per design suggesion [1], the input row should use the "microphone-sensitivity-muted-symbolic" icon. In order to achieve that, move the CcLevelBarStreamType enum to a separate header, and rename it to CcStreamType. And also pass the stream type to the volume slider. In CcVolumeSlider, update the code to switch to the correct mute icon depending on the stream type. [1] https://gitlab.gnome.org/GNOME/gnome-control-center/issues/539 Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/539 --- panels/sound/cc-level-bar.c | 13 +++++++------ panels/sound/cc-level-bar.h | 14 +++++--------- panels/sound/cc-sound-enums.h | 30 ++++++++++++++++++++++++++++++ panels/sound/cc-sound-panel.c | 8 ++++---- panels/sound/cc-stream-list-box.c | 12 +++++++++++- panels/sound/cc-stream-list-box.h | 5 +++++ panels/sound/cc-stream-row.c | 6 ++++-- panels/sound/cc-stream-row.h | 5 ++++- panels/sound/cc-volume-slider.c | 24 +++++++++++++++++++++++- panels/sound/cc-volume-slider.h | 5 ++++- panels/sound/cc-volume-slider.ui | 2 +- 11 files changed, 98 insertions(+), 26 deletions(-) create mode 100644 panels/sound/cc-sound-enums.h diff --git a/panels/sound/cc-level-bar.c b/panels/sound/cc-level-bar.c index ee351383c1..a37ce2ea1a 100644 --- a/panels/sound/cc-level-bar.c +++ b/panels/sound/cc-level-bar.c @@ -17,13 +17,14 @@ */ #include "cc-level-bar.h" +#include "cc-sound-enums.h" #include "gvc-mixer-stream-private.h" struct _CcLevelBar { GtkWidget parent_instance; - CcLevelBarStreamType type; + CcStreamType type; pa_stream *level_stream; gdouble last_input_peak; @@ -139,10 +140,10 @@ cc_level_bar_draw (GtkWidget *widget, switch (self->type) { default: - case CC_LEVEL_BAR_STREAM_TYPE_OUTPUT: + case CC_STREAM_TYPE_OUTPUT: gdk_rgba_parse (&active_color, "#4a90d9"); break; - case CC_LEVEL_BAR_STREAM_TYPE_INPUT: + case CC_STREAM_TYPE_INPUT: gdk_rgba_parse (&active_color, "#ff0000"); break; } @@ -214,9 +215,9 @@ cc_level_bar_init (CcLevelBar *self) } void -cc_level_bar_set_stream (CcLevelBar *self, - GvcMixerStream *stream, - CcLevelBarStreamType type) +cc_level_bar_set_stream (CcLevelBar *self, + GvcMixerStream *stream, + CcStreamType type) { pa_context *context; pa_sample_spec sample_spec; diff --git a/panels/sound/cc-level-bar.h b/panels/sound/cc-level-bar.h index d30a3ad699..34ef1ea60a 100644 --- a/panels/sound/cc-level-bar.h +++ b/panels/sound/cc-level-bar.h @@ -22,19 +22,15 @@ #include #include +#include "cc-sound-enums.h" + G_BEGIN_DECLS #define CC_TYPE_LEVEL_BAR (cc_level_bar_get_type ()) G_DECLARE_FINAL_TYPE (CcLevelBar, cc_level_bar, CC, LEVEL_BAR, GtkWidget) -typedef enum -{ - CC_LEVEL_BAR_STREAM_TYPE_OUTPUT, - CC_LEVEL_BAR_STREAM_TYPE_INPUT -} CcLevelBarStreamType; - -void cc_level_bar_set_stream (CcLevelBar *bar, - GvcMixerStream *stream, - CcLevelBarStreamType type); +void cc_level_bar_set_stream (CcLevelBar *bar, + GvcMixerStream *stream, + CcStreamType type); G_END_DECLS diff --git a/panels/sound/cc-sound-enums.h b/panels/sound/cc-sound-enums.h new file mode 100644 index 0000000000..bf29d274aa --- /dev/null +++ b/panels/sound/cc-sound-enums.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 Jordan Petridis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#pragma once + +#include + +G_BEGIN_DECLS + +typedef enum +{ + CC_STREAM_TYPE_OUTPUT, + CC_STREAM_TYPE_INPUT, +} CcStreamType; + +G_END_DECLS diff --git a/panels/sound/cc-sound-panel.c b/panels/sound/cc-sound-panel.c index 072f491245..672b2b1abf 100644 --- a/panels/sound/cc-sound-panel.c +++ b/panels/sound/cc-sound-panel.c @@ -107,8 +107,8 @@ output_device_changed_cb (CcSoundPanel *self) if (device != NULL) stream = gvc_mixer_control_get_stream_from_device (self->mixer_control, device); - cc_volume_slider_set_stream (self->output_volume_slider, stream); - cc_level_bar_set_stream (self->output_level_bar, stream, CC_LEVEL_BAR_STREAM_TYPE_OUTPUT); + cc_volume_slider_set_stream (self->output_volume_slider, stream, CC_STREAM_TYPE_OUTPUT); + cc_level_bar_set_stream (self->output_level_bar, stream, CC_STREAM_TYPE_OUTPUT); if (stream != NULL) { @@ -141,8 +141,8 @@ input_device_changed_cb (CcSoundPanel *self) if (device != NULL) stream = gvc_mixer_control_get_stream_from_device (self->mixer_control, device); - cc_volume_slider_set_stream (self->input_volume_slider, stream); - cc_level_bar_set_stream (self->input_level_bar, stream, CC_LEVEL_BAR_STREAM_TYPE_INPUT); + cc_volume_slider_set_stream (self->input_volume_slider, stream, CC_STREAM_TYPE_INPUT); + cc_level_bar_set_stream (self->input_level_bar, stream, CC_STREAM_TYPE_INPUT); if (device != NULL) gvc_mixer_control_change_input (self->mixer_control, device); diff --git a/panels/sound/cc-stream-list-box.c b/panels/sound/cc-stream-list-box.c index f11442ba26..fcc249a25a 100644 --- a/panels/sound/cc-stream-list-box.c +++ b/panels/sound/cc-stream-list-box.c @@ -22,6 +22,7 @@ #include "cc-stream-list-box.h" #include "cc-stream-row.h" +#include "cc-sound-enums.h" struct _CcStreamListBox { @@ -29,6 +30,7 @@ struct _CcStreamListBox GtkSizeGroup *label_size_group; GvcMixerControl *mixer_control; + CcStreamType stream_type; guint stream_added_handler_id; guint stream_removed_handler_id; }; @@ -97,7 +99,7 @@ stream_added_cb (CcStreamListBox *self, return; } - row = cc_stream_row_new (self->label_size_group, stream, id); + row = cc_stream_row_new (self->label_size_group, stream, id, self->stream_type); gtk_widget_show (GTK_WIDGET (row)); gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), FALSE); gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (row)); @@ -230,3 +232,11 @@ cc_stream_list_box_set_mixer_control (CcStreamListBox *self, G_CALLBACK (stream_removed_cb), self, G_CONNECT_SWAPPED); } + +void cc_stream_list_box_set_stream_type (CcStreamListBox *self, + CcStreamType stream_type) +{ + g_return_if_fail (CC_IS_STREAM_LIST_BOX (self)); + + self->stream_type = stream_type; +} diff --git a/panels/sound/cc-stream-list-box.h b/panels/sound/cc-stream-list-box.h index 374ecaf55b..8a46fd7c9f 100644 --- a/panels/sound/cc-stream-list-box.h +++ b/panels/sound/cc-stream-list-box.h @@ -22,6 +22,8 @@ #include #include +#include "cc-sound-enums.h" + G_BEGIN_DECLS #define CC_TYPE_STREAM_LIST_BOX (cc_stream_list_box_get_type ()) @@ -30,4 +32,7 @@ G_DECLARE_FINAL_TYPE (CcStreamListBox, cc_stream_list_box, CC, STREAM_LIST_BOX, void cc_stream_list_box_set_mixer_control (CcStreamListBox *combo_box, GvcMixerControl *mixer_control); +void cc_stream_list_box_set_stream_type (CcStreamListBox *combo_box, + CcStreamType type); + G_END_DECLS diff --git a/panels/sound/cc-stream-row.c b/panels/sound/cc-stream-row.c index 62bac69434..31d6be79e8 100644 --- a/panels/sound/cc-stream-row.c +++ b/panels/sound/cc-stream-row.c @@ -19,6 +19,7 @@ #include "cc-sound-resources.h" #include "cc-stream-row.h" #include "cc-volume-slider.h" +#include "cc-sound-enums.h" #define SPEECH_DISPATCHER_PREFIX "speech-dispatcher-" @@ -74,7 +75,8 @@ cc_stream_row_init (CcStreamRow *self) CcStreamRow * cc_stream_row_new (GtkSizeGroup *size_group, GvcMixerStream *stream, - guint id) + guint id, + CcStreamType stream_type) { CcStreamRow *self; g_autoptr(GtkIconInfo) icon_info = NULL; @@ -107,7 +109,7 @@ cc_stream_row_new (GtkSizeGroup *size_group, gtk_image_set_from_gicon (self->icon_image, gicon, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_label_set_label (self->name_label, gvc_mixer_stream_get_name (stream)); - cc_volume_slider_set_stream (self->volume_slider, stream); + cc_volume_slider_set_stream (self->volume_slider, stream, stream_type); gtk_size_group_add_widget (size_group, GTK_WIDGET (self->label_box)); diff --git a/panels/sound/cc-stream-row.h b/panels/sound/cc-stream-row.h index 9d9440e586..3819eef18f 100644 --- a/panels/sound/cc-stream-row.h +++ b/panels/sound/cc-stream-row.h @@ -22,6 +22,8 @@ #include #include +#include "cc-sound-enums.h" + G_BEGIN_DECLS #define CC_TYPE_STREAM_ROW (cc_stream_row_get_type ()) @@ -29,7 +31,8 @@ G_DECLARE_FINAL_TYPE (CcStreamRow, cc_stream_row, CC, STREAM_ROW, GtkListBoxRow) CcStreamRow *cc_stream_row_new (GtkSizeGroup *size_group, GvcMixerStream *stream, - guint id); + guint id, + CcStreamType stream_type); GvcMixerStream *cc_stream_row_get_stream (CcStreamRow *row); diff --git a/panels/sound/cc-volume-slider.c b/panels/sound/cc-volume-slider.c index 8f58f656b5..ca2f70b90d 100644 --- a/panels/sound/cc-volume-slider.c +++ b/panels/sound/cc-volume-slider.c @@ -30,6 +30,7 @@ struct _CcVolumeSlider GtkBox parent_instance; GtkToggleButton *mute_button; + GtkImage *stream_type_icon; GtkAdjustment *volume_adjustment; GtkScale *volume_scale; @@ -109,6 +110,7 @@ cc_volume_slider_class_init (CcVolumeSliderClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/sound/cc-volume-slider.ui"); gtk_widget_class_bind_template_child (widget_class, CcVolumeSlider, mute_button); + gtk_widget_class_bind_template_child (widget_class, CcVolumeSlider, stream_type_icon); gtk_widget_class_bind_template_child (widget_class, CcVolumeSlider, volume_adjustment); gtk_widget_class_bind_template_child (widget_class, CcVolumeSlider, volume_scale); @@ -132,7 +134,8 @@ cc_volume_slider_init (CcVolumeSlider *self) void cc_volume_slider_set_stream (CcVolumeSlider *self, - GvcMixerStream *stream) + GvcMixerStream *stream, + CcStreamType type) { g_return_if_fail (CC_IS_VOLUME_SLIDER (self)); @@ -145,6 +148,25 @@ cc_volume_slider_set_stream (CcVolumeSlider *self, } g_clear_object (&self->stream); + switch (type) + { + case CC_STREAM_TYPE_INPUT: + gtk_image_set_from_icon_name (self->stream_type_icon, + "microphone-sensitivity-muted-symbolic", + GTK_ICON_SIZE_BUTTON); + break; + + case CC_STREAM_TYPE_OUTPUT: + gtk_image_set_from_icon_name (self->stream_type_icon, + "audio-volume-muted-symbolic", + GTK_ICON_SIZE_BUTTON); + break; + + default: + g_assert_not_reached (); + break; + } + if (stream != NULL) { self->stream = g_object_ref (stream); diff --git a/panels/sound/cc-volume-slider.h b/panels/sound/cc-volume-slider.h index 079354d666..68b5dc1d2a 100644 --- a/panels/sound/cc-volume-slider.h +++ b/panels/sound/cc-volume-slider.h @@ -22,13 +22,16 @@ #include #include +#include "cc-sound-enums.h" + G_BEGIN_DECLS #define CC_TYPE_VOLUME_SLIDER (cc_volume_slider_get_type ()) G_DECLARE_FINAL_TYPE (CcVolumeSlider, cc_volume_slider, CC, VOLUME_SLIDER, GtkBox) void cc_volume_slider_set_stream (CcVolumeSlider *slider, - GvcMixerStream *stream); + GvcMixerStream *stream, + CcStreamType type); void cc_volume_slider_set_is_amplified (CcVolumeSlider *slider, gboolean is_amplified); diff --git a/panels/sound/cc-volume-slider.ui b/panels/sound/cc-volume-slider.ui index 7ab849cafa..4fb0540279 100644 --- a/panels/sound/cc-volume-slider.ui +++ b/panels/sound/cc-volume-slider.ui @@ -17,7 +17,7 @@ none - + True audio-volume-muted-symbolic -- GitLab From 05b531ec287a961a87437b270947ff267bec30cf Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 15 Jun 2019 21:56:19 -0300 Subject: [PATCH 16/16] sound: Remove unused variable --- panels/sound/cc-level-bar.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/panels/sound/cc-level-bar.c b/panels/sound/cc-level-bar.c index a37ce2ea1a..8d8b2c9c9a 100644 --- a/panels/sound/cc-level-bar.c +++ b/panels/sound/cc-level-bar.c @@ -172,8 +172,6 @@ cc_level_bar_draw (GtkWidget *widget, static void close_stream (pa_stream *stream) { - g_autoptr(GMainLoop) loop = NULL; - if (stream == NULL) return; -- GitLab