background: Remove lock-screen preview

Without different lock-screen settings, there's little reason to
keep showing a lock-screen preview. So rather than updating the
preview to a blurred version of the regular background, just remove
it altogether.

https://gitlab.gnome.org/GNOME/gnome-control-center/issues/864
This commit is contained in:
Florian Müllner 2020-02-11 15:14:07 +01:00 committed by Julian Sparber
parent 7c436727a3
commit 33c23eaef6
2 changed files with 21 additions and 58 deletions

View file

@ -57,12 +57,10 @@ struct _CcBackgroundPanel
GnomeDesktopThumbnailFactory *thumb_factory; GnomeDesktopThumbnailFactory *thumb_factory;
CcBackgroundItem *current_background; CcBackgroundItem *current_background;
CcBackgroundItem *current_lock_background;
CcBackgroundChooser *background_chooser; CcBackgroundChooser *background_chooser;
GtkWidget *add_picture_button; GtkWidget *add_picture_button;
CcBackgroundPreview *desktop_preview; CcBackgroundPreview *desktop_preview;
CcBackgroundPreview *lock_screen_preview;
GtkWidget *spinner; GtkWidget *spinner;
GtkWidget *chooser; GtkWidget *chooser;
@ -70,55 +68,41 @@ struct _CcBackgroundPanel
CC_PANEL_REGISTER (CcBackgroundPanel, cc_background_panel) CC_PANEL_REGISTER (CcBackgroundPanel, cc_background_panel)
static CcBackgroundItem *
get_current_background (CcBackgroundPanel *panel,
GSettings *settings)
{
if (settings == panel->settings)
return panel->current_background;
else
return panel->current_lock_background;
}
static void static void
update_preview (CcBackgroundPanel *panel, update_preview (CcBackgroundPanel *panel)
GSettings *settings)
{ {
CcBackgroundItem *current_background; CcBackgroundItem *current_background;
current_background = get_current_background (panel, settings); current_background = panel->current_background;
cc_background_preview_set_item (panel->desktop_preview, current_background);
if (settings == panel->settings)
cc_background_preview_set_item (panel->desktop_preview, current_background);
else
cc_background_preview_set_item (panel->lock_screen_preview, current_background);
} }
static gchar * static gchar *
get_save_path (CcBackgroundPanel *panel, GSettings *settings) get_save_path (void)
{ {
return g_build_filename (g_get_user_config_dir (), return g_build_filename (g_get_user_config_dir (),
"gnome-control-center", "gnome-control-center",
"backgrounds", "backgrounds",
settings == panel->settings ? "last-edited.xml" : "last-edited-lock.xml", "last-edited.xml",
NULL); NULL);
} }
static void static void
reload_current_bg (CcBackgroundPanel *panel, reload_current_bg (CcBackgroundPanel *panel)
GSettings *settings)
{ {
g_autoptr(CcBackgroundItem) saved = NULL; g_autoptr(CcBackgroundItem) saved = NULL;
CcBackgroundItem *configured; CcBackgroundItem *configured;
GSettings *settings = NULL;
g_autofree gchar *uri = NULL; g_autofree gchar *uri = NULL;
g_autofree gchar *pcolor = NULL; g_autofree gchar *pcolor = NULL;
g_autofree gchar *scolor = NULL; g_autofree gchar *scolor = NULL;
/* Load the saved configuration */ /* Load the saved configuration */
uri = get_save_path (panel, settings); uri = get_save_path ();
saved = cc_background_xml_get_item (uri); saved = cc_background_xml_get_item (uri);
/* initalise the current background information from settings */ /* initalise the current background information from settings */
settings = panel->settings;
uri = g_settings_get_string (settings, WP_URI_KEY); uri = g_settings_get_string (settings, WP_URI_KEY);
if (uri && *uri == '\0') if (uri && *uri == '\0')
g_clear_pointer (&uri, g_free); g_clear_pointer (&uri, g_free);
@ -150,16 +134,8 @@ reload_current_bg (CcBackgroundPanel *panel,
NULL); NULL);
} }
if (settings == panel->settings) g_clear_object (&panel->current_background);
{ panel->current_background = configured;
g_clear_object (&panel->current_background);
panel->current_background = configured;
}
else
{
g_clear_object (&panel->current_lock_background);
panel->current_lock_background = configured;
}
cc_background_item_load (configured, NULL); cc_background_item_load (configured, NULL);
} }
@ -220,9 +196,9 @@ set_background (CcBackgroundPanel *panel,
g_settings_apply (settings); g_settings_apply (settings);
/* Save the source XML if there is one */ /* Save the source XML if there is one */
filename = get_save_path (panel, settings); filename = get_save_path ();
if (create_save_dir ()) if (create_save_dir ())
cc_background_xml_save (get_current_background (panel, settings), filename); cc_background_xml_save (panel->current_background, filename);
} }
@ -282,7 +258,6 @@ cc_background_panel_finalize (GObject *object)
CcBackgroundPanel *panel = CC_BACKGROUND_PANEL (object); CcBackgroundPanel *panel = CC_BACKGROUND_PANEL (object);
g_clear_object (&panel->current_background); g_clear_object (&panel->current_background);
g_clear_object (&panel->current_lock_background);
G_OBJECT_CLASS (cc_background_panel_parent_class)->finalize (object); G_OBJECT_CLASS (cc_background_panel_parent_class)->finalize (object);
} }
@ -308,7 +283,6 @@ cc_background_panel_class_init (CcBackgroundPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, add_picture_button); gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, add_picture_button);
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, background_chooser); gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, background_chooser);
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, desktop_preview); gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, desktop_preview);
gtk_widget_class_bind_template_child (widget_class, CcBackgroundPanel, lock_screen_preview);
gtk_widget_class_bind_template_callback (widget_class, on_chooser_background_chosen_cb); gtk_widget_class_bind_template_callback (widget_class, on_chooser_background_chosen_cb);
gtk_widget_class_bind_template_callback (widget_class, on_add_picture_button_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, on_add_picture_button_clicked_cb);
@ -319,8 +293,8 @@ on_settings_changed (GSettings *settings,
gchar *key, gchar *key,
CcBackgroundPanel *panel) CcBackgroundPanel *panel)
{ {
reload_current_bg (panel, settings); reload_current_bg (panel);
update_preview (panel, settings); update_preview (panel);
} }
static void static void
@ -336,17 +310,14 @@ cc_background_panel_init (CcBackgroundPanel *panel)
panel->settings = g_settings_new (WP_PATH_ID); panel->settings = g_settings_new (WP_PATH_ID);
g_settings_delay (panel->settings); g_settings_delay (panel->settings);
panel->lock_settings = g_settings_new (WP_LOCK_PATH_ID); panel->lock_settings = g_settings_new (WP_LOCK_PATH_ID);
g_settings_delay (panel->lock_settings); g_settings_delay (panel->lock_settings);
/* Load the backgrounds */ /* Load the background */
reload_current_bg (panel, panel->settings); reload_current_bg (panel);
update_preview (panel, panel->settings); update_preview (panel);
reload_current_bg (panel, panel->lock_settings);
update_preview (panel, panel->lock_settings);
/* Background settings */ /* Background settings */
g_signal_connect (panel->settings, "changed", G_CALLBACK (on_settings_changed), panel); g_signal_connect (panel->settings, "changed", G_CALLBACK (on_settings_changed), panel);
g_signal_connect (panel->lock_settings, "changed", G_CALLBACK (on_settings_changed), panel);
} }

View file

@ -13,8 +13,8 @@
<child> <child>
<object class="HdyColumn"> <object class="HdyColumn">
<property name="visible">1</property> <property name="visible">1</property>
<property name="maximum_width">600</property> <property name="maximum_width">300</property>
<property name="linear_growth_width">400</property> <property name="linear_growth_width">200</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
@ -32,14 +32,6 @@
<property name="valign">center</property> <property name="valign">center</property>
</object> </object>
</child> </child>
<child>
<object class="CcBackgroundPreview" id="lock_screen_preview">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="is-lock-screen">True</property>
<property name="valign">center</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>