From 414e01d4ab6d5da1d64dd2268b9c5018496312a5 Mon Sep 17 00:00:00 2001 From: Tomasz Golinski Date: Fri, 13 Oct 2017 16:55:27 +0100 Subject: [PATCH] Addl fix #510: Rudimentary video support https://github.com/BestImageViewer/geeqie/issues/510 Additional option to start video playback via left-click. --- doc/docbook/GuideOptionsBehavior.xml | 8 +++++ src/img-view.c | 6 +++- src/layout_image.c | 6 +++- src/options.c | 2 ++ src/options.h | 2 ++ src/preferences.c | 50 ++++++++++++++++++++++++++++ src/rcfile.c | 4 +++ web/help/GuideOptionsBehavior.html | 6 ++++ 8 files changed, 82 insertions(+), 2 deletions(-) diff --git a/doc/docbook/GuideOptionsBehavior.xml b/doc/docbook/GuideOptionsBehavior.xml index ec414d9f..673cc59d 100644 --- a/doc/docbook/GuideOptionsBehavior.xml +++ b/doc/docbook/GuideOptionsBehavior.xml @@ -183,6 +183,14 @@ If selected, mouse left-click will select the next image; mouse middle-click will select the previous image. + + + Play video by left click on image + + + If selected, mouse left-click on an image belonging to the video class will start a program chosen in a box below. + +
diff --git a/src/img-view.c b/src/img-view.c index 9d7646f0..057b2964 100644 --- a/src/img-view.c +++ b/src/img-view.c @@ -580,7 +580,11 @@ static void button_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) switch (event->button) { case MOUSE_BUTTON_LEFT: - if (options->image_lm_click_nav) + if (options->image_l_click_video && options->image_l_click_video_editor && imd->image_fd->format_class == FORMAT_CLASS_VIDEO) + { + start_editor_from_file(options->image_l_click_video_editor, imd->image_fd); + } + else if (options->image_lm_click_nav) view_step_next(vw); break; case MOUSE_BUTTON_MIDDLE: diff --git a/src/layout_image.c b/src/layout_image.c index 52f9a389..a4316374 100644 --- a/src/layout_image.c +++ b/src/layout_image.c @@ -1698,7 +1698,11 @@ static void layout_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpoi switch (event->button) { case MOUSE_BUTTON_LEFT: - if (options->image_lm_click_nav && lw->split_mode == SPLIT_NONE) + if (options->image_l_click_video && options->image_l_click_video_editor && imd->image_fd->format_class == FORMAT_CLASS_VIDEO) + { + start_editor_from_file(options->image_l_click_video_editor, imd->image_fd); + } + else if (options->image_lm_click_nav && lw->split_mode == SPLIT_NONE) layout_image_next(lw); break; case MOUSE_BUTTON_MIDDLE: diff --git a/src/options.c b/src/options.c index a9d6b033..869754e2 100644 --- a/src/options.c +++ b/src/options.c @@ -123,6 +123,8 @@ ConfOptions *init_options(ConfOptions *options) options->lazy_image_sync = FALSE; options->mousewheel_scrolls = FALSE; options->image_lm_click_nav = TRUE; + options->image_l_click_video = FALSE; + options->image_l_click_video_editor = NULL; options->open_recent_list_maxsize = 10; options->place_dialogs_under_mouse = FALSE; diff --git a/src/options.h b/src/options.h index 26bc0038..3a62a2ac 100644 --- a/src/options.h +++ b/src/options.h @@ -31,6 +31,8 @@ struct _ConfOptions gboolean place_dialogs_under_mouse; gboolean mousewheel_scrolls; gboolean image_lm_click_nav; + gboolean image_l_click_video; + gchar *image_l_click_video_editor; gboolean show_icon_names; /* various */ diff --git a/src/preferences.c b/src/preferences.c index 387ff8a3..7261330e 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -301,6 +301,8 @@ static void config_window_apply(void) options->mousewheel_scrolls = c_options->mousewheel_scrolls; options->image_lm_click_nav = c_options->image_lm_click_nav; + options->image_l_click_video = c_options->image_l_click_video; + options->image_l_click_video_editor = c_options->image_l_click_video_editor; options->file_ops.enable_in_place_rename = c_options->file_ops.enable_in_place_rename; @@ -741,6 +743,48 @@ static void add_stereo_mode_menu(GtkWidget *table, gint column, gint row, const gtk_widget_show(combo); } +static void video_menu_cb(GtkWidget *combo, gpointer data) +{ + gchar **option = data; + + EditorDescription *ed = g_list_nth_data(editor_list_get(), gtk_combo_box_get_active(GTK_COMBO_BOX(combo))); + *option = ed->key; +} + +static void video_menu_populate(gpointer data, gpointer user_data) +{ + GtkWidget *combo = user_data; + EditorDescription *ed = data; + + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), ed->name); +} + +static void add_video_menu(GtkWidget *table, gint column, gint row, const gchar *text, + gchar *option, gchar **option_c) +{ + GtkWidget *combo; + gint current; +/* use lists since they are sorted */ + GList *eds = editor_list_get(); + + *option_c = option; + + pref_table_label(table, column, row, text, 0.0); + + combo = gtk_combo_box_text_new(); + g_list_foreach(eds,video_menu_populate,(gpointer)combo); + current = option ? g_list_index(eds,g_hash_table_lookup(editors,option)): -1; + + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current); + + g_signal_connect(G_OBJECT(combo), "changed", + G_CALLBACK(video_menu_cb), option_c); + + gtk_table_attach(GTK_TABLE(table), combo, column + 1, column + 2, row, row + 1, + GTK_EXPAND | GTK_FILL, 0, 0, 0); + gtk_widget_show(combo); +} + static void filter_store_populate(void) { GList *work; @@ -2220,6 +2264,7 @@ static void config_tab_behavior(GtkWidget *notebook) GtkWidget *tabcomp; GtkWidget *ct_button; GtkWidget *spin; + GtkWidget *table; vbox = scrolled_notebook_page(notebook, _("Behavior")); @@ -2289,6 +2334,11 @@ static void config_tab_behavior(GtkWidget *notebook) options->mousewheel_scrolls, &c_options->mousewheel_scrolls); pref_checkbox_new_int(group, _("Navigation by left or middle click on image"), options->image_lm_click_nav, &c_options->image_lm_click_nav); + pref_checkbox_new_int(group, _("Play video by left click on image"), + options->image_l_click_video, &c_options->image_l_click_video); + table = pref_table_new(group, 2, 1, FALSE, FALSE); + add_video_menu(table, 0, 0, _("Play with:"), options->image_l_click_video_editor, &c_options->image_l_click_video_editor); + #ifdef DEBUG group = pref_group_new(vbox, FALSE, _("Debugging"), GTK_ORIENTATION_VERTICAL); diff --git a/src/rcfile.c b/src/rcfile.c index bbdd354f..4f135bda 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -327,6 +327,8 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_BOOL(*options, mousewheel_scrolls); WRITE_NL(); WRITE_BOOL(*options, image_lm_click_nav); + WRITE_NL(); WRITE_BOOL(*options, image_l_click_video); + WRITE_NL(); WRITE_CHAR(*options, image_l_click_video_editor); WRITE_NL(); WRITE_INT(*options, open_recent_list_maxsize); WRITE_NL(); WRITE_INT(*options, dnd_icon_size); WRITE_NL(); WRITE_BOOL(*options, place_dialogs_under_mouse); @@ -623,6 +625,8 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_BOOL(*options, mousewheel_scrolls)) continue; if (READ_BOOL(*options, image_lm_click_nav)) continue; + if (READ_BOOL(*options, image_l_click_video)) continue; + if (READ_CHAR(*options, image_l_click_video_editor)) continue; if (READ_INT(*options, open_recent_list_maxsize)) continue; if (READ_INT(*options, dnd_icon_size)) continue; diff --git a/web/help/GuideOptionsBehavior.html b/web/help/GuideOptionsBehavior.html index ef9b17ca..51b7ae80 100644 --- a/web/help/GuideOptionsBehavior.html +++ b/web/help/GuideOptionsBehavior.html @@ -619,6 +619,12 @@ dd.answer div.label { float: left; }

If selected, mouse left-click will select the next image; mouse middle-click will select the previous image.

+
+ Play video by left click on image +
+
+

If selected, mouse left-click on an image belonging to the video class will start a program chosen in a box below.

+
-- 2.20.1