Commit 84be0c3a authored by Daniel Byrne's avatar Daniel Byrne Committed by Cosimo Cecchi

Add a back button to take another screenshot

This commit adds a back button so users can take another screenshot when
launched in interactive mode.

https://bugzilla.gnome.org/show_bug.cgi?id=765941
parent d6a8a6f5
......@@ -107,6 +107,15 @@ set_recent_entry (ScreenshotApplication *self)
g_free (app_exec);
}
static void
screenshot_close_interactive_dialog (ScreenshotApplication *self)
{
ScreenshotDialog *dialog = self->priv->dialog;
save_folder_to_settings (self);
gtk_widget_destroy (dialog->dialog);
g_free (dialog);
}
static void
save_pixbuf_handle_success (ScreenshotApplication *self)
{
......@@ -114,11 +123,7 @@ save_pixbuf_handle_success (ScreenshotApplication *self)
if (screenshot_config->interactive)
{
ScreenshotDialog *dialog = self->priv->dialog;
save_folder_to_settings (self);
gtk_widget_destroy (dialog->dialog);
g_free (dialog);
screenshot_close_interactive_dialog (self);
}
else
{
......@@ -381,6 +386,13 @@ screenshot_save_to_file (ScreenshotApplication *self)
g_object_unref (target_file);
}
static void
screenshot_back (ScreenshotApplication *self)
{
screenshot_close_interactive_dialog (self);
screenshot_show_interactive_dialog (self);
}
static void
screenshot_save_to_clipboard (ScreenshotApplication *self)
{
......@@ -406,6 +418,9 @@ screenshot_dialog_response_cb (ScreenshotResponse response,
case SCREENSHOT_RESPONSE_COPY:
screenshot_save_to_clipboard (self);
break;
case SCREENSHOT_RESPONSE_BACK:
screenshot_back (self);
break;
default:
g_assert_not_reached ();
break;
......
......@@ -143,8 +143,12 @@ button_clicked (GtkWidget *button, ScreenshotDialog *dialog)
{
ScreenshotResponse res;
res = (button == dialog->save_button) ? SCREENSHOT_RESPONSE_SAVE
: SCREENSHOT_RESPONSE_COPY;
if (button == dialog->save_button)
res = SCREENSHOT_RESPONSE_SAVE;
else if (button == dialog->copy_button)
res = SCREENSHOT_RESPONSE_COPY;
else
res = SCREENSHOT_RESPONSE_BACK;
dialog->callback (res, dialog->user_data);
}
......@@ -241,6 +245,8 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
g_signal_connect (dialog->save_button, "clicked", G_CALLBACK (button_clicked), dialog);
dialog->copy_button = GTK_WIDGET (gtk_builder_get_object (ui, "copy_button"));
g_signal_connect (dialog->copy_button, "clicked", G_CALLBACK (button_clicked), dialog);
dialog->back_button = GTK_WIDGET (gtk_builder_get_object (ui, "back_button"));
g_signal_connect (dialog->back_button, "clicked", G_CALLBACK (button_clicked), dialog);
setup_drawing_area (dialog, ui);
......
......@@ -24,7 +24,9 @@
typedef enum {
SCREENSHOT_RESPONSE_SAVE,
SCREENSHOT_RESPONSE_COPY
SCREENSHOT_RESPONSE_COPY,
SCREENSHOT_RESPONSE_BACK
} ScreenshotResponse;
typedef void (*SaveScreenshotCallback) (ScreenshotResponse response, gpointer *user_data);
......@@ -38,6 +40,7 @@ typedef struct {
GtkWidget *filename_entry;
GtkWidget *save_button;
GtkWidget *copy_button;
GtkWidget *back_button;
gint drag_x;
gint drag_y;
......
......@@ -12,6 +12,27 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="back_button">
<property name="tooltip_text" translatable="yes">Back</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon_name">go-previous-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
<child>
<object class="GtkButton" id="copy_button">
<property name="label" translatable="yes">C_opy to Clipboard</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment