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.
.TP
.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.
.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
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[] = {
N_("Set initial size (fit or orig)"), N_("TYPE") },
{ "inc", 0, 0, G_OPTION_ARG_INT, &options.picture_data.inc,
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 }
};
......@@ -1824,6 +1826,7 @@ yad_options_init (void)
/* Initialize picture data */
options.picture_data.size = YAD_PICTURE_ORIG;
options.picture_data.inc = 5;
options.picture_data.change_cmd = NULL;
/* Initialize print data */
options.print_data.type = YAD_PRINT_TEXT;
......
......@@ -81,6 +81,25 @@ load_picture ()
}
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)
{
lp = g_list_next (lp);
......@@ -92,6 +111,7 @@ next_img_cb (GtkWidget *w, gpointer d)
load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window ();
img_changed_hook ();
}
static void
......@@ -106,6 +126,7 @@ prev_img_cb (GtkWidget *w, gpointer d)
load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window ();
img_changed_hook ();
}
static void
......@@ -118,6 +139,7 @@ first_img_cb (GtkWidget *w, gpointer d)
load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window ();
img_changed_hook ();
}
static void
......@@ -130,6 +152,7 @@ last_img_cb (GtkWidget *w, gpointer d)
load_picture ();
if (options.picture_data.size == YAD_PICTURE_FIT)
picture_fit_to_window ();
img_changed_hook ();
}
void
......
......@@ -428,6 +428,7 @@ typedef struct {
typedef struct {
YadPictureType size;
gchar *change_cmd;
gint inc;
} 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