Commit 2862f04e authored by Victor Ananjevsky's avatar Victor Ananjevsky

add hook for changing image in picture dialog

parent 103d4362
...@@ -867,6 +867,9 @@ Set increment value for scaling image. ...@@ -867,6 +867,9 @@ Set increment value for scaling image.
.TP .TP
.B \-\-filename=\fIFILENAME\fP .B \-\-filename=\fIFILENAME\fP
Set picture filename. If no file name is specified extra data will be used. In this case several filenames can be specified. Set picture filename. If no file name is specified extra data will be used. In this case several filenames can be specified.
.TP
.B \-\-image-changed=\fICMD\fP
Set command which runs after changing image. Argument of a command is a filename of current image. Argument can be specified by '\fI%s\fP' pattern or will be the last part of a command.
.PP .PP
Some actions on a picture like navigation, scaling or rotating available from popup menu. Those actions can be made only on static images. Some actions on a picture like navigation, scaling or rotating available from popup menu. Those actions can be made only on static images.
......
...@@ -562,6 +562,8 @@ static GOptionEntry picture_options[] = { ...@@ -562,6 +562,8 @@ static GOptionEntry picture_options[] = {
N_("Set initial size (fit or orig)"), N_("TYPE") }, N_("Set initial size (fit or orig)"), N_("TYPE") },
{ "inc", 0, 0, G_OPTION_ARG_INT, &options.picture_data.inc, { "inc", 0, 0, G_OPTION_ARG_INT, &options.picture_data.inc,
N_("Set increment for picture scaling (default - 5)"), N_("NUMBER") }, N_("Set increment for picture scaling (default - 5)"), N_("NUMBER") },
{ "image-changed", 0, 0, G_OPTION_ARG_STRING, &options.picture_data.change_cmd,
N_("Set action on image changing"), "CMD" },
{ NULL } { NULL }
}; };
...@@ -1824,6 +1826,7 @@ yad_options_init (void) ...@@ -1824,6 +1826,7 @@ yad_options_init (void)
/* Initialize picture data */ /* Initialize picture data */
options.picture_data.size = YAD_PICTURE_ORIG; options.picture_data.size = YAD_PICTURE_ORIG;
options.picture_data.inc = 5; options.picture_data.inc = 5;
options.picture_data.change_cmd = NULL;
/* Initialize print data */ /* Initialize print data */
options.print_data.type = YAD_PRINT_TEXT; options.print_data.type = YAD_PRINT_TEXT;
......
...@@ -81,6 +81,25 @@ load_picture () ...@@ -81,6 +81,25 @@ load_picture ()
} }
static void static void
img_changed_hook ()
{
gchar *qfn, *cmd = NULL;
if (options.picture_data.change_cmd == NULL)
return;
qfn = g_shell_quote (img->filename);
if (g_strstr_len (options.picture_data.change_cmd, -1, "%s") != NULL)
cmd = g_strdup_printf (options.picture_data.change_cmd, qfn);
else
cmd = g_strdup_printf ("%s '%s'", options.picture_data.change_cmd, qfn);
g_free (qfn);
run_command_async (cmd);
g_free (cmd);
}
static void
next_img_cb (GtkWidget *w, gpointer d) next_img_cb (GtkWidget *w, gpointer d)
{ {
lp = g_list_next (lp); lp = g_list_next (lp);
...@@ -92,6 +111,7 @@ next_img_cb (GtkWidget *w, gpointer d) ...@@ -92,6 +111,7 @@ next_img_cb (GtkWidget *w, gpointer d)
load_picture (); load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT) if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window (); picture_fit_to_window ();
img_changed_hook ();
} }
static void static void
...@@ -106,6 +126,7 @@ prev_img_cb (GtkWidget *w, gpointer d) ...@@ -106,6 +126,7 @@ prev_img_cb (GtkWidget *w, gpointer d)
load_picture (); load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT) if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window (); picture_fit_to_window ();
img_changed_hook ();
} }
static void static void
...@@ -118,6 +139,7 @@ first_img_cb (GtkWidget *w, gpointer d) ...@@ -118,6 +139,7 @@ first_img_cb (GtkWidget *w, gpointer d)
load_picture (); load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT) if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window (); picture_fit_to_window ();
img_changed_hook ();
} }
static void static void
...@@ -130,6 +152,7 @@ last_img_cb (GtkWidget *w, gpointer d) ...@@ -130,6 +152,7 @@ last_img_cb (GtkWidget *w, gpointer d)
load_picture (); load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT) if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window (); picture_fit_to_window ();
img_changed_hook ();
} }
void void
......
...@@ -428,6 +428,7 @@ typedef struct { ...@@ -428,6 +428,7 @@ typedef struct {
typedef struct { typedef struct {
YadPictureType size; YadPictureType size;
gchar *change_cmd;
gint inc; gint inc;
} YadPictureData; } YadPictureData;
......
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