diff options
author | Alexander Mikhaylenko <alexm@gnome.org> | 2020-03-10 20:39:59 +0500 |
---|---|---|
committer | Alexander Mikhaylenko <alexm@gnome.org> | 2020-03-10 15:41:47 +0000 |
commit | 525309ad0f346d556df0ae82ea0bb04767b29ce4 (patch) | |
tree | a3ca554e92566300975eeada95a528a2f77fda1a | |
parent | dca44518b707e2cdd2d98c6c4d31f292920483f9 (diff) | |
download | gnome-screenshot-525309ad0f346d556df0ae82ea0bb04767b29ce4.tar.gz |
Add back window effects cli option
!7 replaced -e option with --use-border. Undo that change for now, and just
not expose the effects in the UI.
-rw-r--r-- | data/org.gnome.gnome-screenshot.gschema.xml | 8 | ||||
-rw-r--r-- | src/screenshot-application.c | 25 | ||||
-rw-r--r-- | src/screenshot-config.c | 24 | ||||
-rw-r--r-- | src/screenshot-config.h | 5 | ||||
-rw-r--r-- | src/screenshot-interactive-dialog.c | 9 |
5 files changed, 48 insertions, 23 deletions
diff --git a/data/org.gnome.gnome-screenshot.gschema.xml b/data/org.gnome.gnome-screenshot.gschema.xml index 494b28e..b998853 100644 --- a/data/org.gnome.gnome-screenshot.gschema.xml +++ b/data/org.gnome.gnome-screenshot.gschema.xml @@ -41,10 +41,10 @@ <summary>Include ICC Profile</summary> <description>Include the ICC profile of the target in the screenshot file</description> </key> - <key name="use-shadow" type="b"> - <default>false</default> - <summary>Use Shadow</summary> - <description>Apply a window shadow to the screenshot</description> + <key name="border-effect" type="s"> + <default>'none'</default> + <summary>Border Effect</summary> + <description>Effect to add to the outside of a border. Possible values are “shadow”, “none”, and “border”.</description> </key> <key name="default-file-type" enum="org.gnome.gnome-screenshot.file-types"> <default>'png'</default> diff --git a/src/screenshot-application.c b/src/screenshot-application.c index b64b6fb..2258862 100644 --- a/src/screenshot-application.c +++ b/src/screenshot-application.c @@ -481,9 +481,20 @@ finish_prepare_screenshot (ScreenshotApplication *self, if (screenshot_config->take_window_shot) { - if (screenshot_config->use_shadow) - { + switch (screenshot_config->border_effect[0]) + { + case 's': /* shadow */ screenshot_add_shadow (&screenshot); + break; + case 'b': /* border */ + screenshot_add_border (&screenshot); + break; + case 'v': /* vintage */ + screenshot_add_vintage (&screenshot); + break; + case 'n': /* none */ + default: + break; } } @@ -590,7 +601,7 @@ static const GOptionEntry entries[] = { { "remove-border", 'B', 0, G_OPTION_ARG_NONE, NULL, N_("Remove the window border from the screenshot"), NULL }, { "include-pointer", 'p', 0, G_OPTION_ARG_NONE, NULL, N_("Include the pointer with the screenshot"), NULL }, { "delay", 'd', 0, G_OPTION_ARG_INT, NULL, N_("Take screenshot after specified delay [in seconds]"), N_("seconds") }, - { "use-shadow", 'b', 0, G_OPTION_ARG_NONE, NULL, N_("Apply a window shadow to the screenshot"), NULL }, + { "border-effect", 'e', 0, G_OPTION_ARG_STRING, NULL, N_("Effect to add to the border (shadow, border, vintage or none)"), N_("effect") }, { "interactive", 'i', 0, G_OPTION_ARG_NONE, NULL, N_("Interactively set options"), NULL }, { "file", 'f', 0, G_OPTION_ARG_FILENAME, NULL, N_("Save screenshot directly to this file"), N_("filename") }, { "version", 0, 0, G_OPTION_ARG_NONE, &version_arg, N_("Print version information and exit"), NULL }, @@ -634,6 +645,7 @@ screenshot_application_command_line (GApplication *app, gboolean disable_border_arg = FALSE; gboolean include_pointer_arg = FALSE; gboolean interactive_arg = FALSE; + gchar *border_effect_arg = NULL; gboolean use_shadow_arg = FALSE; guint delay_arg = 0; gchar *file_arg = NULL; @@ -649,6 +661,7 @@ screenshot_application_command_line (GApplication *app, g_variant_dict_lookup (options, "remove-border", "b", &disable_border_arg); g_variant_dict_lookup (options, "include-pointer", "b", &include_pointer_arg); g_variant_dict_lookup (options, "interactive", "b", &interactive_arg); + g_variant_dict_lookup (options, "border-effect", "&s", &border_effect_arg); g_variant_dict_lookup (options, "use-shadow", "b", &use_shadow_arg); g_variant_dict_lookup (options, "delay", "i", &delay_arg); g_variant_dict_lookup (options, "file", "^&ay", &file_arg); @@ -659,7 +672,7 @@ screenshot_application_command_line (GApplication *app, include_border_arg, disable_border_arg, include_pointer_arg, - use_shadow_arg, + border_effect_arg, delay_arg, interactive_arg, file_arg); @@ -748,7 +761,7 @@ action_screen_shot (GSimpleAction *action, FALSE, /* include border */ FALSE, /* disable border */ FALSE, /* include pointer */ - FALSE, /* use shadow */ + NULL, /* border effect */ 0, /* delay */ FALSE, /* interactive */ NULL); /* file */ @@ -768,7 +781,7 @@ action_window_shot (GSimpleAction *action, FALSE, /* include border */ FALSE, /* disable border */ FALSE, /* include pointer */ - FALSE, /* use shadow */ + NULL, /* border effect */ 0, /* delay */ FALSE, /* interactive */ NULL); /* file */ diff --git a/src/screenshot-config.c b/src/screenshot-config.c index ff2b82b..c095f24 100644 --- a/src/screenshot-config.c +++ b/src/screenshot-config.c @@ -26,7 +26,7 @@ #include "screenshot-config.h" -#define USE_SHADOW_KEY "use-shadow" +#define BORDER_EFFECT_KEY "border-effect" #define DELAY_KEY "delay" #define INCLUDE_BORDER_KEY "include-border" #define INCLUDE_POINTER_KEY "include-pointer" @@ -57,9 +57,9 @@ screenshot_load_config (void) config->include_pointer = g_settings_get_boolean (config->settings, INCLUDE_POINTER_KEY); - config->use_shadow = - g_settings_get_boolean (config->settings, - USE_SHADOW_KEY); + config->border_effect = + g_settings_get_string (config->settings, + BORDER_EFFECT_KEY); config->file_type = g_settings_get_string (config->settings, DEFAULT_FILE_TYPE_KEY); @@ -67,6 +67,9 @@ screenshot_load_config (void) g_settings_get_boolean (config->settings, INCLUDE_ICC_PROFILE); + if (config->border_effect == NULL) + config->border_effect = g_strdup ("none"); + config->take_window_shot = FALSE; config->take_area_shot = FALSE; @@ -90,8 +93,8 @@ screenshot_save_config (void) INCLUDE_BORDER_KEY, c->include_border); g_settings_set_boolean (c->settings, INCLUDE_POINTER_KEY, c->include_pointer); - g_settings_set_boolean (c->settings, - USE_SHADOW_KEY, c->use_shadow); + g_settings_set_string (c->settings, + BORDER_EFFECT_KEY, c->border_effect); if (!c->take_area_shot) g_settings_set_int (c->settings, DELAY_KEY, c->delay); @@ -104,7 +107,7 @@ screenshot_config_parse_command_line (gboolean clipboard_arg, gboolean include_border_arg, gboolean disable_border_arg, gboolean include_pointer_arg, - gboolean use_shadow_arg, + const gchar *border_effect_arg, guint delay_arg, gboolean interactive_arg, const gchar *file_arg) @@ -153,11 +156,16 @@ screenshot_config_parse_command_line (gboolean clipboard_arg, screenshot_config->include_border = !disable_border_arg; screenshot_config->include_pointer = include_pointer_arg; screenshot_config->copy_to_clipboard = clipboard_arg; - screenshot_config->use_shadow = use_shadow_arg; if (file_arg != NULL) screenshot_config->file = g_file_new_for_commandline_arg (file_arg); } + if (border_effect_arg != NULL) + { + g_free (screenshot_config->border_effect); + screenshot_config->border_effect = g_strdup (border_effect_arg); + } + screenshot_config->take_window_shot = window_arg; screenshot_config->take_area_shot = area_arg; diff --git a/src/screenshot-config.h b/src/screenshot-config.h index f3923c0..f765aaf 100644 --- a/src/screenshot-config.h +++ b/src/screenshot-config.h @@ -40,8 +40,7 @@ typedef struct { gboolean include_icc_profile; gboolean include_border; - - gboolean use_shadow; + gchar *border_effect; guint delay; @@ -58,7 +57,7 @@ gboolean screenshot_config_parse_command_line (gboolean clipboard_arg, gboolean include_border_arg, gboolean disable_border_arg, gboolean include_pointer_arg, - gboolean use_shadow_arg, + const gchar *border_effect_arg, guint delay_arg, gboolean interactive_arg, const gchar *file_arg); diff --git a/src/screenshot-interactive-dialog.c b/src/screenshot-interactive-dialog.c index ec6b3cc..afd2221 100644 --- a/src/screenshot-interactive-dialog.c +++ b/src/screenshot-interactive-dialog.c @@ -94,7 +94,10 @@ static void use_shadow_toggled_cb (GtkSwitch *toggle, gpointer user_data) { - screenshot_config->use_shadow = gtk_switch_get_active (toggle); + if (gtk_switch_get_active (toggle)) + screenshot_config->border_effect = "shadow"; + else + screenshot_config->border_effect = "none"; gtk_switch_set_state (toggle, gtk_switch_get_active (toggle)); } @@ -103,6 +106,7 @@ connect_effects_frame (GtkBuilder *ui) { GtkWidget *pointer; GtkWidget *shadow; + gboolean use_shadow; /** Include pointer **/ pointer = GTK_WIDGET (gtk_builder_get_object (ui, "pointer")); @@ -112,8 +116,9 @@ connect_effects_frame (GtkBuilder *ui) NULL); /** Use shadow **/ + use_shadow = !g_strcmp0 (screenshot_config->border_effect, "shadow"); shadow = GTK_WIDGET (gtk_builder_get_object (ui, "shadow")); - gtk_switch_set_active (GTK_SWITCH (shadow), screenshot_config->use_shadow); + gtk_switch_set_active (GTK_SWITCH (shadow), use_shadow); g_signal_connect (shadow, "state-set", G_CALLBACK (use_shadow_toggled_cb), NULL); |