summaryrefslogtreecommitdiff
path: root/mate-screenshot
diff options
context:
space:
mode:
authorThiago Bighetti <[email protected]>2018-01-15 18:10:05 -0200
committerraveit65 <[email protected]>2018-01-15 21:10:05 +0100
commitd10215e69d9cc2831bb94d399a0b3c3674cb6c2c (patch)
tree42928bcc42aa89e5cb2358bbc263716911e962f2 /mate-screenshot
parentd61cde67b70756d0392d63a30291b12bbb96c332 (diff)
downloadmate-utils-d10215e69d9cc2831bb94d399a0b3c3674cb6c2c.tar.bz2
mate-utils-d10215e69d9cc2831bb94d399a0b3c3674cb6c2c.tar.xz
mate-screenshot: added New button (#184)
* mate-screenshot: added New button
Diffstat (limited to 'mate-screenshot')
-rw-r--r--mate-screenshot/data/mate-screenshot.ui12
-rw-r--r--mate-screenshot/src/mate-screenshot.c111
-rw-r--r--mate-screenshot/src/screenshot-dialog.h1
3 files changed, 76 insertions, 48 deletions
diff --git a/mate-screenshot/data/mate-screenshot.ui b/mate-screenshot/data/mate-screenshot.ui
index baaedcc0..9b53e315 100644
--- a/mate-screenshot/data/mate-screenshot.ui
+++ b/mate-screenshot/data/mate-screenshot.ui
@@ -37,6 +37,17 @@
</packing>
</child>
<child>
+ <object class="GtkButton" id="new_button">
+ <property name="visible">False</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-new</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkButton" id="copy_button">
<property name="label" translatable="yes">C_opy to Clipboard</property>
<property name="visible">True</property>
@@ -220,6 +231,7 @@
<action-widget response="1">copy_button</action-widget>
<action-widget response="-6">cancel_button</action-widget>
<action-widget response="-5">ok_button</action-widget>
+ <action-widget response="22">new_button</action-widget>
</action-widgets>
</object>
</interface>
diff --git a/mate-screenshot/src/mate-screenshot.c b/mate-screenshot/src/mate-screenshot.c
index 00b95677..0b5c3332 100644
--- a/mate-screenshot/src/mate-screenshot.c
+++ b/mate-screenshot/src/mate-screenshot.c
@@ -96,6 +96,8 @@ static char *last_save_dir = NULL;
static char *temporary_file = NULL;
static gboolean save_immediately = FALSE;
static GSettings *settings = NULL;
+static gboolean interactive_arg = FALSE;
+static guint delay_arg = 0;
/* Options */
static gboolean take_window_shot = FALSE;
@@ -117,6 +119,8 @@ static GtkWidget *effect_label = NULL;
static GtkWidget *effects_vbox = NULL;
static GtkWidget *delay_hbox = NULL;
+void loop_dialog_screenshot ();
+
static void
display_help (GtkWindow *parent)
{
@@ -737,6 +741,13 @@ screenshot_dialog_response_cb (GtkDialog *d,
{
display_help (GTK_WINDOW (d));
}
+ else if (response_id == SCREENSHOT_RESPONSE_NEW)
+ {
+ gtk_widget_destroy (GTK_WIDGET (d));
+ gtk_main_quit ();
+ interactive_arg = TRUE;
+ loop_dialog_screenshot();
+ }
else if (response_id == GTK_RESPONSE_OK)
{
uri = screenshot_dialog_get_uri (dialog);
@@ -1251,6 +1262,57 @@ screenshooter_init_stock_icons (void)
g_object_unref (factory);
}
+void
+loop_dialog_screenshot ()
+{
+ /* interactive mode overrides everything */
+ if (interactive_arg)
+ {
+ GtkWidget *dialog;
+ gint response;
+
+ dialog = create_interactive_dialog ();
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ switch (response)
+ {
+ case GTK_RESPONSE_DELETE_EVENT:
+ case GTK_RESPONSE_CANCEL:
+ return;
+ case GTK_RESPONSE_OK:
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+
+ if (((delay > 0 && interactive_arg) || delay_arg > 0) &&
+ !take_area_shot)
+ {
+ g_timeout_add (delay * 1000,
+ prepare_screenshot_timeout,
+ NULL);
+ }
+ else
+ {
+ if (interactive_arg)
+ {
+ /* HACK: give time to the dialog to actually disappear.
+ * We don't have any way to tell when the compositor has finished
+ * re-drawing.
+ */
+ g_timeout_add (200,
+ prepare_screenshot_timeout, NULL);
+ }
+ else
+ g_idle_add (prepare_screenshot_timeout, NULL);
+ }
+
+ gtk_main ();
+}
+
/* main */
int
main (int argc, char *argv[])
@@ -1260,10 +1322,8 @@ main (int argc, char *argv[])
gboolean area_arg = FALSE;
gboolean include_border_arg = FALSE;
gboolean disable_border_arg = FALSE;
- gboolean interactive_arg = FALSE;
gchar *border_effect_arg = NULL;
gboolean version_arg = FALSE;
- guint delay_arg = 0;
GError *error = NULL;
const GOptionEntry entries[] = {
@@ -1338,52 +1398,7 @@ main (int argc, char *argv[])
if (delay_arg > 0)
delay = delay_arg;
- /* interactive mode overrides everything */
- if (interactive_arg)
- {
- GtkWidget *dialog;
- gint response;
-
- dialog = create_interactive_dialog ();
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
-
- switch (response)
- {
- case GTK_RESPONSE_DELETE_EVENT:
- case GTK_RESPONSE_CANCEL:
- return EXIT_SUCCESS;
- case GTK_RESPONSE_OK:
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- }
-
- if (((delay > 0 && interactive_arg) || delay_arg > 0) &&
- !take_area_shot)
- {
- g_timeout_add (delay * 1000,
- prepare_screenshot_timeout,
- NULL);
- }
- else
- {
- if (interactive_arg)
- {
- /* HACK: give time to the dialog to actually disappear.
- * We don't have any way to tell when the compositor has finished
- * re-drawing.
- */
- g_timeout_add (200,
- prepare_screenshot_timeout, NULL);
- }
- else
- g_idle_add (prepare_screenshot_timeout, NULL);
- }
-
- gtk_main ();
+ loop_dialog_screenshot();
return EXIT_SUCCESS;
}
diff --git a/mate-screenshot/src/screenshot-dialog.h b/mate-screenshot/src/screenshot-dialog.h
index 0cd5e1da..ba9702d6 100644
--- a/mate-screenshot/src/screenshot-dialog.h
+++ b/mate-screenshot/src/screenshot-dialog.h
@@ -26,6 +26,7 @@ typedef struct ScreenshotDialog ScreenshotDialog;
/* Keep in sync with the value defined in the UI file */
#define SCREENSHOT_RESPONSE_COPY 1
+#define SCREENSHOT_RESPONSE_NEW 22
ScreenshotDialog *screenshot_dialog_new (GdkPixbuf *screenshot,
char *initial_uri,