diff options
author | rbuj <[email protected]> | 2020-03-15 22:36:39 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-04-09 21:28:48 +0200 |
commit | 344cc22f4ce85dfaf7256b2db7e530741bc29156 (patch) | |
tree | c21e7bc37f8ff010a531d92aa630ea3232797dae /src | |
parent | 9f3cc047877e01dc158e365850ea22d896815d0e (diff) | |
download | mate-screensaver-344cc22f4ce85dfaf7256b2db7e530741bc29156.tar.bz2 mate-screensaver-344cc22f4ce85dfaf7256b2db7e530741bc29156.tar.xz |
Custom background image for lock screen
Diffstat (limited to 'src')
-rw-r--r-- | src/gs-manager.c | 20 | ||||
-rw-r--r-- | src/mate-screensaver-preferences.c | 15 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/gs-manager.c b/src/gs-manager.c index cca90d8..139a305 100644 --- a/src/gs-manager.c +++ b/src/gs-manager.c @@ -1048,6 +1048,13 @@ gs_manager_init (GSManager *manager) manager); mate_bg_load_from_preferences (manager->priv->bg); + GSettings *settings = g_settings_new ("org.mate.screensaver"); + char *filename= g_settings_get_string (settings, "picture-filename"); + if (g_file_test (filename, G_FILE_TEST_EXISTS)) { + mate_bg_set_filename (manager->priv->bg, filename); + } + g_free (filename); + g_object_unref (settings); } static void @@ -1260,11 +1267,22 @@ static void apply_background_to_window (GSManager *manager, GSWindow *window) { + GSettings *settings; + char *filename; cairo_surface_t *surface; int width; int height; - mate_bg_load_from_preferences (manager->priv->bg); + mate_bg_load_from_preferences(manager->priv->bg); + + settings = g_settings_new ("org.mate.screensaver"); + filename = g_settings_get_string (settings, "picture-filename"); + + if (g_file_test (filename, G_FILE_TEST_EXISTS)) { + mate_bg_set_filename (manager->priv->bg, filename); + } + g_free (filename); + g_object_unref (settings); if (manager->priv->bg == NULL) { diff --git a/src/mate-screensaver-preferences.c b/src/mate-screensaver-preferences.c index 4ead5ed..8efb25a 100644 --- a/src/mate-screensaver-preferences.c +++ b/src/mate-screensaver-preferences.c @@ -1086,6 +1086,12 @@ enabled_checkbox_toggled (GtkToggleButton *button, gpointer user_data) } static void +picture_filename_changed (GtkFileChooserButton *button, gpointer user_data) +{ + g_settings_set_string (screensaver_settings, "picture-filename", gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (button))); +} + +static void ui_disable_lock (gboolean disable) { GtkWidget *widget; @@ -1533,6 +1539,7 @@ init_capplet (void) GtkWidget *fullscreen_preview_previous; GtkWidget *fullscreen_preview_next; GtkWidget *fullscreen_preview_close; + GtkWidget *picture_filename; gdouble activate_delay; gboolean enabled; gboolean is_writable; @@ -1579,6 +1586,7 @@ init_capplet (void) fullscreen_preview_close = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_close")); fullscreen_preview_previous = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_previous_button")); fullscreen_preview_next = GTK_WIDGET (gtk_builder_get_object (builder, "fullscreen_preview_next_button")); + picture_filename = GTK_WIDGET (gtk_builder_get_object (builder, "picture_filename")); label = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), activate_delay_hscale); @@ -1629,6 +1637,13 @@ init_capplet (void) g_signal_connect (lock_checkbox, "toggled", G_CALLBACK (lock_checkbox_toggled), NULL); + char *path = g_settings_get_string (screensaver_settings, "picture-filename"); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (gtk_builder_get_object (builder, "picture_filename")), path); + gtk_file_filter_add_pixbuf_formats (GTK_FILE_FILTER (gtk_builder_get_object (builder, "picture_filefilter"))); + g_free (path); + g_signal_connect (picture_filename, "selection-changed", + G_CALLBACK (picture_filename_changed), NULL); + enabled = config_get_enabled (&is_writable); ui_set_enabled (enabled); if (! is_writable) |