This is an automated email from the git hooks/post-receive script. f 2 4 0 4 p u s h e d a c o m m i t t o b r a n c h m a s t e r in repository apps/ristretto.
commit a3fd5163eb57af4e7e5b7290fefedbdb1939b548 Author: Igor <f2...@yandex.ru> Date: Tue Sep 10 12:42:11 2019 -0400 Add inactivity timeout setting to Preferences This allows to set the period of inactivity after which the mouse cursor will be hidden in fullscreen mode. When set to 0, the cursor will never be hidden. --- src/main_window.c | 30 +++++++++++++++------- src/preferences_dialog.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++-- src/settings.c | 29 +++++++++++++++++++++ 3 files changed, 115 insertions(+), 11 deletions(-) diff --git a/src/main_window.c b/src/main_window.c index 75e2ffe..43cedd9 100644 --- a/src/main_window.c +++ b/src/main_window.c @@ -2414,6 +2414,9 @@ cb_rstto_main_window_state_event (GtkWidget *widget, GdkEventWindowState *event, { if (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) { + guint timeout = rstto_settings_get_uint_property (RSTTO_SETTINGS (window->priv->settings_manager), + "hide-mouse-cursor-fullscreen-timeout"); + rstto_image_viewer_set_show_clock ( RSTTO_IMAGE_VIEWER (window->priv->image_viewer), rstto_settings_get_boolean_property (window->priv->settings_manager, "show-clock")); @@ -2444,10 +2447,13 @@ cb_rstto_main_window_state_event (GtkWidget *widget, GdkEventWindowState *event, } } - window->priv->show_fs_mouse_cursor_timeout_id = - g_timeout_add_full (G_PRIORITY_DEFAULT, 500, - (GSourceFunc) cb_rstto_main_window_show_fs_mouse_cursor_timeout, window, - cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy); + if (timeout > 0) + { + window->priv->show_fs_mouse_cursor_timeout_id = + g_timeout_add_full (G_PRIORITY_DEFAULT, 1000 * timeout, + (GSourceFunc) cb_rstto_main_window_show_fs_mouse_cursor_timeout, window, + cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy); + } if (rstto_settings_get_boolean_property (window->priv->settings_manager, "hide-thumbnails-fullscreen")) { @@ -2556,6 +2562,9 @@ cb_rstto_main_window_motion_notify_event (RsttoMainWindow *window, GdkEventMotio { if (gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (window))) & GDK_WINDOW_STATE_FULLSCREEN) { + guint timeout = rstto_settings_get_uint_property (RSTTO_SETTINGS (window->priv->settings_manager), + "hide-mouse-cursor-fullscreen-timeout"); + /* Show toolbar when the mouse pointer is moved to the top of the screen */ if (event->y < 1) { @@ -2571,7 +2580,7 @@ cb_rstto_main_window_motion_notify_event (RsttoMainWindow *window, GdkEventMotio } } - /* Show the mouse cursor, but set a timer to hide it in 1 second if not moved again */ + /* Show the mouse cursor, but set a timer to hide it if not moved again */ if (window->priv->show_fs_mouse_cursor_timeout_id > 0) { REMOVE_SOURCE (window->priv->show_fs_mouse_cursor_timeout_id); @@ -2581,10 +2590,13 @@ cb_rstto_main_window_motion_notify_event (RsttoMainWindow *window, GdkEventMotio gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL); } - window->priv->show_fs_mouse_cursor_timeout_id = - g_timeout_add_full (G_PRIORITY_DEFAULT, 1000, - (GSourceFunc) cb_rstto_main_window_show_fs_mouse_cursor_timeout, window, - cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy); + if (timeout > 0) + { + window->priv->show_fs_mouse_cursor_timeout_id = + g_timeout_add_full (G_PRIORITY_DEFAULT, 1000 * timeout, + (GSourceFunc) cb_rstto_main_window_show_fs_mouse_cursor_timeout, window, + cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy); + } } return TRUE; } diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c index ff3ef6e..314261b 100644 --- a/src/preferences_dialog.c +++ b/src/preferences_dialog.c @@ -65,6 +65,10 @@ cb_show_clock_check_button_toggled ( GtkToggleButton *button, gpointer user_data); static void +cb_cursor_timeout_button_value_changed ( + GtkSpinButton *spin_button, + gpointer user_data); +static void cb_limit_quality_check_button_toggled ( GtkToggleButton *button, gpointer user_data); @@ -123,6 +127,13 @@ struct _RsttoPreferencesDialogPriv GtkWidget *clock_frame; GtkWidget *clock_label; GtkWidget *clock_button; + + GtkWidget *cursor_vbox; + GtkWidget *cursor_frame; + GtkWidget *cursor_label; + GtkWidget *cursor_hbox; + GtkWidget *cursor_timeout_label; + GtkWidget *cursor_timeout_button; } fullscreen_tab; struct @@ -223,6 +234,7 @@ rstto_preferences_dialog_init (RsttoPreferencesDialog *dialog) gboolean bool_bgcolor_override; guint uint_slideshow_timeout; gboolean bool_hide_thumbnails_fullscreen; + guint uint_hide_mouse_cursor_fullscreen_timeout; gboolean bool_wrap_images; gboolean bool_maximize_on_startup; gboolean bool_show_clock; @@ -262,6 +274,7 @@ rstto_preferences_dialog_init (RsttoPreferencesDialog *dialog) "bgcolor", &bgcolor, "slideshow-timeout", &uint_slideshow_timeout, "hide-thumbnails-fullscreen", &bool_hide_thumbnails_fullscreen, + "hide-mouse-cursor-fullscreen-timeout", &uint_hide_mouse_cursor_fullscreen_timeout, "maximize-on-startup", &bool_maximize_on_startup, "wrap-images", &bool_wrap_images, "desktop-type", &str_desktop_type, @@ -362,10 +375,31 @@ rstto_preferences_dialog_init (RsttoPreferencesDialog *dialog) gtk_container_add (GTK_CONTAINER (dialog->priv->fullscreen_tab.clock_vbox), dialog->priv->fullscreen_tab.clock_button); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->fullscreen_tab.clock_button), bool_show_clock); - g_signal_connect (G_OBJECT (dialog->priv->fullscreen_tab.hide_thumbnails_fullscreen_check_button), + dialog->priv->fullscreen_tab.cursor_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + dialog->priv->fullscreen_tab.cursor_frame = xfce_gtk_frame_box_new_with_content (_("Mouse cursor"), dialog->priv->fullscreen_tab.cursor_vbox); + gtk_box_pack_start (GTK_BOX (fullscreen_main_vbox), dialog->priv->fullscreen_tab.cursor_frame, FALSE, FALSE, 0); + + dialog->priv->fullscreen_tab.cursor_label = gtk_label_new (_("The mouse cursor can be automatically hidden after a certain period of inactivity\nwhen the window is fullscreen.")); + gtk_label_set_line_wrap (GTK_LABEL (dialog->priv->fullscreen_tab.cursor_label), TRUE); + gtk_label_set_xalign (GTK_LABEL (dialog->priv->fullscreen_tab.cursor_label), 0.0); + gtk_label_set_yalign (GTK_LABEL (dialog->priv->fullscreen_tab.cursor_label), 0.5); + gtk_container_add (GTK_CONTAINER (dialog->priv->fullscreen_tab.cursor_vbox), dialog->priv->fullscreen_tab.cursor_label); + + dialog->priv->fullscreen_tab.cursor_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); + dialog->priv->fullscreen_tab.cursor_timeout_label = gtk_label_new (_("Period of inactivity (seconds):")); + dialog->priv->fullscreen_tab.cursor_timeout_button = gtk_spin_button_new_with_range (0, 3600, 1); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (dialog->priv->fullscreen_tab.cursor_timeout_button), 0); + gtk_container_add (GTK_CONTAINER (dialog->priv->fullscreen_tab.cursor_hbox), dialog->priv->fullscreen_tab.cursor_timeout_label); + gtk_container_add (GTK_CONTAINER (dialog->priv->fullscreen_tab.cursor_hbox), dialog->priv->fullscreen_tab.cursor_timeout_button); + gtk_container_add (GTK_CONTAINER (dialog->priv->fullscreen_tab.cursor_vbox), dialog->priv->fullscreen_tab.cursor_hbox); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->fullscreen_tab.cursor_timeout_button), uint_hide_mouse_cursor_fullscreen_timeout); + + g_signal_connect (G_OBJECT (dialog->priv->fullscreen_tab.hide_thumbnails_fullscreen_check_button), "toggled", G_CALLBACK (cb_hide_thumbnails_fullscreen_check_button_toggled), dialog); - g_signal_connect (G_OBJECT (dialog->priv->fullscreen_tab.clock_button), + g_signal_connect (G_OBJECT (dialog->priv->fullscreen_tab.clock_button), "toggled", G_CALLBACK (cb_show_clock_check_button_toggled), dialog); + g_signal_connect (G_OBJECT (dialog->priv->fullscreen_tab.cursor_timeout_button), + "value-changed", G_CALLBACK (cb_cursor_timeout_button_value_changed), dialog); /* * Slideshow tab @@ -921,6 +955,35 @@ cb_show_clock_check_button_toggled ( } /** + * cb_cursor_timeout_button_value_changed: + * @button: The spin-button the user changed value for. + * @user_data: The user-data provided when connecting the + * callback-function, the preferences-dialog. + * + * + * This function is called when a user changes the inactivity + * timeout via the spin-button. This function then sets the right + * property in the ristretto settings container. + * + * When the property's value is greater than 0, it will serve as + * an inactivity timeout to hide the mouse cursor when in + * fullscreen mode. + */ +static void +cb_cursor_timeout_button_value_changed ( + GtkSpinButton *spin_button, + gpointer user_data) +{ + RsttoPreferencesDialog *dialog = RSTTO_PREFERENCES_DIALOG (user_data); + gdouble value = gtk_spin_button_get_value (spin_button); + + rstto_settings_set_uint_property ( + dialog->priv->settings, + "hide-mouse-cursor-fullscreen-timeout", + value > 0 ? (guint) value : 0); +} + +/** * cb_limit_quality_check_button_toggled: * @button: The check-button the user clicked. * @user_data: The user-data provided when connecting the diff --git a/src/settings.c b/src/settings.c index 64c4e87..c16a0fa 100644 --- a/src/settings.c +++ b/src/settings.c @@ -66,6 +66,7 @@ enum PROP_SHOW_CLOCK, PROP_LIMIT_QUALITY, PROP_HIDE_THUMBNAILS_FULLSCREEN, + PROP_HIDE_MOUSE_CURSOR_FULLSCREEN_TIMEOUT, PROP_WINDOW_WIDTH, PROP_WINDOW_HEIGHT, PROP_BGCOLOR, @@ -119,6 +120,7 @@ struct _RsttoSettingsPriv gboolean show_clock; gboolean limit_quality; gboolean hide_thumbnails_fullscreen; + guint hide_mouse_cursor_fullscreen_timeout; gchar *navigationbar_position; gboolean invert_zoom_direction; guint window_width; @@ -191,6 +193,7 @@ rstto_settings_init (GObject *object) settings->priv->use_thunar_properties = TRUE; settings->priv->maximize_on_startup = TRUE; settings->priv->hide_thumbnails_fullscreen = TRUE; + settings->priv->hide_mouse_cursor_fullscreen_timeout = 1; settings->priv->errors.missing_thumbnailer = TRUE; settings->priv->thumbnail_size = THUMBNAIL_SIZE_NORMAL; @@ -265,6 +268,13 @@ rstto_settings_init (GObject *object) xfconf_g_property_bind ( settings->priv->channel, + "/window/mouse-cursor/hide-fullscreen-timeout", + G_TYPE_UINT, + settings, + "hide-mouse-cursor-fullscreen-timeout"); + + xfconf_g_property_bind ( + settings->priv->channel, "/slideshow/timeout", G_TYPE_UINT, settings, @@ -457,6 +467,19 @@ rstto_settings_class_init (GObjectClass *object_class) PROP_HIDE_THUMBNAILS_FULLSCREEN, pspec); + pspec = g_param_spec_uint ( + "hide-mouse-cursor-fullscreen-timeout", + "", + "", + 0, + 3600, + 1, + G_PARAM_READWRITE); + g_object_class_install_property ( + object_class, + PROP_HIDE_MOUSE_CURSOR_FULLSCREEN_TIMEOUT, + pspec); + pspec = g_param_spec_string ( "navigationbar-position", "", @@ -777,6 +800,9 @@ rstto_settings_set_property (GObject *object, case PROP_HIDE_THUMBNAILS_FULLSCREEN: settings->priv->hide_thumbnails_fullscreen = g_value_get_boolean (value); break; + case PROP_HIDE_MOUSE_CURSOR_FULLSCREEN_TIMEOUT: + settings->priv->hide_mouse_cursor_fullscreen_timeout = g_value_get_uint (value); + break; case PROP_NAVBAR_POSITION: str_val = g_value_get_string (value); @@ -881,6 +907,9 @@ rstto_settings_get_property (GObject *object, case PROP_HIDE_THUMBNAILS_FULLSCREEN: g_value_set_boolean (value, settings->priv->hide_thumbnails_fullscreen); break; + case PROP_HIDE_MOUSE_CURSOR_FULLSCREEN_TIMEOUT: + g_value_set_uint (value, settings->priv->hide_mouse_cursor_fullscreen_timeout); + break; case PROP_NAVBAR_POSITION: g_value_set_string (value, settings->priv->navigationbar_position); break; -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits