diff options
-rw-r--r-- | data/mate-screensaver-preferences.ui | 88 | ||||
-rw-r--r-- | src/mate-screensaver-preferences.c | 73 |
2 files changed, 125 insertions, 36 deletions
diff --git a/data/mate-screensaver-preferences.ui b/data/mate-screensaver-preferences.ui index 0311064..c49b04c 100644 --- a/data/mate-screensaver-preferences.ui +++ b/data/mate-screensaver-preferences.ui @@ -14,6 +14,13 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment2"> + <property name="lower">0</property> + <property name="upper">120</property> + <property name="value">10</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkWindow" id="fullscreen_preview_window"> <property name="can_focus">True</property> <property name="has_focus">True</property> @@ -387,27 +394,30 @@ <property name="spacing">6</property> <child> <object class="GtkBox" id="activate_delay_hbox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">12</property> - <child> - <object class="GtkLabel" id="activate_delay_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Regard the computer as _idle after:</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> +- <property name="visible">True</property> +- <property name="can_focus">False</property> +- <property name="spacing">12</property> <child> - <object class="GtkBox" id="hbox4"> + <object class="GtkGrid" id="time_grid"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">6</property> + <property name="hexpand">True</property> + <property name="column-homogeneous">True</property> + <property name="column_spacing">6</property> + <child> + <object class="GtkLabel" id="activate_delay_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Regard the computer as _idle after:</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> <child> <object class="GtkScale" id="activate_delay_hscale"> <property name="visible">True</property> @@ -416,24 +426,48 @@ <property name="digits">0</property> </object> <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">3</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="lock_delay_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Time before locking:</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkScale" id="lock_delay_hscale"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment2</property> + <property name="digits">0</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">3</property> + <property name="height">1</property> </packing> </child> </object> <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">0</property> </packing> </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> </child> <child> <object class="GtkCheckButton" id="enable_checkbox"> diff --git a/src/mate-screensaver-preferences.c b/src/mate-screensaver-preferences.c index 105380c..d20c364 100644 --- a/src/mate-screensaver-preferences.c +++ b/src/mate-screensaver-preferences.c @@ -118,6 +118,31 @@ config_set_activate_delay (gint32 timeout) g_settings_set_int (session_settings, KEY_IDLE_DELAY, timeout); } +static gdouble +config_get_lock_delay (gboolean *is_writable) +{ + gint delay; + + if (is_writable) + { + *is_writable = g_settings_is_writable (screensaver_settings, + KEY_LOCK_DELAY); + } + + if ((delay = g_settings_get_int (screensaver_settings, KEY_LOCK_DELAY)) < 1) + { + return 0.0; + } + + return (gdouble) delay; +} + +static void +config_set_lock_delay (gint32 timeout) +{ + g_settings_set_int (screensaver_settings, KEY_LOCK_DELAY, timeout); +} + static int config_get_mode (gboolean *is_writable) { @@ -576,6 +601,16 @@ activate_delay_value_changed_cb (GtkRange *range, config_set_activate_delay ((gint32)value); } +static void +lock_delay_value_changed_cb (GtkRange *range, + gpointer user_data) +{ + gdouble value; + + value = gtk_range_get_value (range); + config_set_lock_delay ((gint32)value); +} + static int compare_theme_names (char *name_a, char *name_b, @@ -1028,7 +1063,6 @@ time_to_string_text (long time) size_t max_len; string = g_strdup_printf (_("%s"), mins); - if (min == 1) max_len = (size_t) (len_minutes + inc_len + 3); else if (min < 10) @@ -1067,8 +1101,9 @@ static char * format_value_callback_time (GtkScale *scale, gdouble value) { + /*You need to make up for 27 characters in length, otherwise the display will split into different lines*/ if (value == 0) - return g_strdup_printf (_("Never")); + return g_strdup_printf (_("Never ")); return time_to_string_text ((long) (value * 60.0)); } @@ -1152,11 +1187,11 @@ ui_set_enabled (gboolean enabled) } static void -ui_set_delay (gdouble delay) +ui_set_delay (const char *name, gdouble delay) { GtkWidget *widget; - widget = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale")); + widget = GTK_WIDGET (gtk_builder_get_object (builder, name)); gtk_range_set_value (GTK_RANGE (widget), delay); } @@ -1199,8 +1234,14 @@ key_changed_cb (GSettings *settings, const gchar *key, gpointer data) int delay; delay = g_settings_get_int (settings, key); - ui_set_delay ((gdouble) delay); + ui_set_delay ("activate_delay_hscale", (gdouble) delay); + } + else if (strcmp (key, KEY_LOCK_DELAY) == 0) + { + int delay; + delay = g_settings_get_int (settings, key); + ui_set_delay ("lock_delay_hscale", (gdouble) delay); } else { @@ -1596,7 +1637,7 @@ init_capplet (void) GtkWidget *treeview; GtkWidget *list_scroller; GtkWidget *activate_delay_hscale; - GtkWidget *activate_delay_hbox; + GtkWidget *lock_delay_hscale; GtkWidget *label; GtkWidget *enabled_checkbox; GtkWidget *lock_checkbox; @@ -1645,7 +1686,7 @@ init_capplet (void) treeview = GTK_WIDGET (gtk_builder_get_object (builder, "savers_treeview")); list_scroller = GTK_WIDGET (gtk_builder_get_object (builder, "themes_scrolled_window")); activate_delay_hscale = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hscale")); - activate_delay_hbox = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_hbox")); + lock_delay_hscale = GTK_WIDGET (gtk_builder_get_object (builder, "lock_delay_hscale")); enabled_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "enable_checkbox")); lock_checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "lock_checkbox")); root_warning_label = GTK_WIDGET (gtk_builder_get_object (builder, "root_warning_label")); @@ -1660,6 +1701,8 @@ init_capplet (void) label = GTK_WIDGET (gtk_builder_get_object (builder, "activate_delay_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), activate_delay_hscale); + label = GTK_WIDGET (gtk_builder_get_object (builder, "lock_delay_label")); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), lock_delay_hscale); label = GTK_WIDGET (gtk_builder_get_object (builder, "savers_label")); gtk_label_set_mnemonic_widget (GTK_LABEL (label), treeview); @@ -1691,14 +1734,23 @@ init_capplet (void) NULL); activate_delay = config_get_activate_delay (&is_writable); - ui_set_delay (activate_delay); + ui_set_delay ("activate_delay_hscale", activate_delay); if (! is_writable) { - gtk_widget_set_sensitive (activate_delay_hbox, FALSE); + gtk_widget_set_sensitive (activate_delay_hscale, FALSE); } g_signal_connect (activate_delay_hscale, "format-value", G_CALLBACK (format_value_callback_time), NULL); + activate_delay = config_get_lock_delay (&is_writable); + ui_set_delay ("lock_delay_hscale", activate_delay); + if (! is_writable) + { + gtk_widget_set_sensitive (lock_delay_hscale, FALSE); + } + g_signal_connect (lock_delay_hscale, "format-value", + G_CALLBACK (format_value_callback_time), NULL); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lock_checkbox), config_get_lock (&is_writable)); if (! is_writable) { @@ -1770,6 +1822,9 @@ init_capplet (void) g_signal_connect (activate_delay_hscale, "value-changed", G_CALLBACK (activate_delay_value_changed_cb), NULL); + g_signal_connect (lock_delay_hscale, "value-changed", + G_CALLBACK (lock_delay_value_changed_cb), NULL); + g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL); |