diff -ur xfce4-time-out-plugin-1.1.0/panel-plugin/time-out.c xfce4-time-out-plugin-1.1.0m/panel-plugin/time-out.c --- xfce4-time-out-plugin-1.1.0/panel-plugin/time-out.c 2019-10-03 21:34:22.000000000 -0600 +++ xfce4-time-out-plugin-1.1.0m/panel-plugin/time-out.c 2020-01-10 17:56:47.801147511 -0700 @@ -134,6 +134,8 @@ static void time_out_start_lock_countdown (TimeOutPlugin *time_out); static void time_out_stop_lock_countdown (TimeOutPlugin *time_out); static void time_out_postpone (TimeOutLockScreen *lock_screen, + TimeOutPlugin *time_out); +static void time_out_lock (TimeOutLockScreen *lock_screen, TimeOutPlugin *time_out); static void time_out_resume (TimeOutLockScreen *lock_screen, TimeOutPlugin *time_out); @@ -173,6 +175,9 @@ /* Connect to 'postpone' signal of the lock screen */ g_signal_connect (G_OBJECT (time_out->lock_screen), "postpone", G_CALLBACK (time_out_postpone), time_out); + /* Connect to 'lock' signal of the lock screen */ + g_signal_connect (G_OBJECT (time_out->lock_screen), "lock", G_CALLBACK (time_out_lock), time_out); + /* Connect to 'resume' signal of the lock screen */ g_signal_connect (G_OBJECT (time_out->lock_screen), "resume", G_CALLBACK (time_out_resume), time_out); @@ -1049,6 +1054,34 @@ time_out_start_break_countdown (time_out, time_out->postpone_countdown_seconds); } +static void +time_out_lock (TimeOutLockScreen *lock_screen, + TimeOutPlugin *time_out) +{ + GError *error = NULL; + gboolean succeed = FALSE; + gint exit_status; + + g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen)); + g_return_if_fail (time_out != NULL); + + /* Unlock the screen so screensaver can show */ + time_out_lock_screen_hide (time_out->lock_screen); + + /* Lock screen and check for errors */ + succeed = g_spawn_command_line_sync ("xflock4", NULL, NULL, &exit_status , &error); + + if (!succeed) + { + xfce_dialog_show_error (NULL, error, + _("Failed to lock screen")); + } + + /* Display the lock screen under screensaver */ + time_out_lock_screen_show (time_out->lock_screen, time_out->lock_countdown_seconds); + +} + static void diff -ur xfce4-time-out-plugin-1.1.0/panel-plugin/time-out-lock-screen.c xfce4-time-out-plugin-1.1.0m/panel-plugin/time-out-lock-screen.c --- xfce4-time-out-plugin-1.1.0/panel-plugin/time-out-lock-screen.c 2019-11-03 08:40:28.000000000 -0700 +++ xfce4-time-out-plugin-1.1.0m/panel-plugin/time-out-lock-screen.c 2020-01-02 21:06:51.227087269 -0700 @@ -36,6 +36,8 @@ static void time_out_lock_screen_finalize (GObject *object); static void time_out_lock_screen_postpone (GtkButton *button, TimeOutLockScreen *lock_screen); +static void time_out_lock_screen_lock (GtkButton *button, + TimeOutLockScreen *lock_screen); static void time_out_lock_screen_resume (GtkButton *button, TimeOutLockScreen *lock_screen); static void time_out_lock_screen_grab_seat (GdkSeat *seat, @@ -49,10 +51,12 @@ /* Signals */ void (*postpone) (TimeOutLockScreen *lock_screen); + void (*lock) (TimeOutLockScreen *lock_screen); void (*resume) (TimeOutLockScreen *lock_screen); /* Signal identifiers */ guint postpone_signal_id; + guint lock_signal_id; guint resume_signal_id; }; @@ -82,6 +86,7 @@ GtkWidget *window; GtkWidget *time_label; GtkWidget *postpone_button; + GtkWidget *lock_button; GtkWidget *resume_button; GtkWidget *progress; @@ -149,6 +154,17 @@ G_TYPE_NONE, 0); + /* Register 'lock' signal */ + klass->lock_signal_id = g_signal_new ("lock", + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, + G_STRUCT_OFFSET (TimeOutLockScreenClass, lock), + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + /* Register 'resume' signal */ klass->resume_signal_id = g_signal_new ("resume", G_TYPE_FROM_CLASS (gobject_class), @@ -168,6 +184,7 @@ { GdkPixbuf *pixbuf; GtkWidget *vbox; + GtkWidget *button_box; GtkWidget *image; GtkCssProvider *provider; @@ -221,15 +238,26 @@ gtk_box_pack_start (GTK_BOX (vbox), lock_screen->progress, FALSE, FALSE, 0); gtk_widget_show (lock_screen->progress); + /* Create box for buttons */ + button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); + gtk_box_pack_start (GTK_BOX (vbox), button_box, TRUE, TRUE, 0); + gtk_widget_show (button_box); + /* Create postpone button */ lock_screen->postpone_button = gtk_button_new_with_mnemonic (_("_Postpone")); - gtk_box_pack_start (GTK_BOX (vbox), lock_screen->postpone_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (button_box), lock_screen->postpone_button, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (lock_screen->postpone_button), "clicked", G_CALLBACK (time_out_lock_screen_postpone), lock_screen); gtk_widget_show (lock_screen->postpone_button); + /* Create lock button */ + lock_screen->lock_button = gtk_button_new_with_mnemonic (_("_Lock")); + gtk_box_pack_end (GTK_BOX (button_box), lock_screen->lock_button, FALSE, FALSE, 0); + g_signal_connect (G_OBJECT (lock_screen->lock_button), "clicked", G_CALLBACK (time_out_lock_screen_lock), lock_screen); + gtk_widget_show (lock_screen->lock_button); + /* Create resume button */ lock_screen->resume_button = gtk_button_new_with_mnemonic (_("_Resume")); - gtk_box_pack_start (GTK_BOX (vbox), lock_screen->resume_button, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (button_box), lock_screen->resume_button, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (lock_screen->resume_button), "clicked", G_CALLBACK (time_out_lock_screen_resume), lock_screen); } @@ -424,7 +452,16 @@ g_signal_emit_by_name (lock_screen, "postpone", NULL); } +static void +time_out_lock_screen_lock (GtkButton *button, + TimeOutLockScreen *lock_screen) +{ + g_return_if_fail (GTK_IS_BUTTON (button)); + g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen)); + /* Emit postpone signal */ + g_signal_emit_by_name (lock_screen, "lock", NULL); +} static void time_out_lock_screen_resume (GtkButton *button,