add the external editor support (currently by pressing "e" in the flow browser)

SVN revision: 52820
This commit is contained in:
Viktor Kojouharov 2010-09-27 22:02:10 +00:00
parent 5d473ea800
commit d9c7cfd80e
4 changed files with 56 additions and 6 deletions

View File

@ -89,6 +89,8 @@ struct _Ephoto_Config
double slideshow_timeout;
const char *slideshow_transition;
const char *editor;
};
/*Ephoto Main Structure*/

View File

@ -1,6 +1,6 @@
#include "ephoto.h"
#define CONFIG_VERSION 2
#define CONFIG_VERSION 3
static int _ephoto_config_load(Ephoto *em);
static Eina_Bool _ephoto_on_config_save(void *data);
@ -28,6 +28,7 @@ ephoto_config_init(Ephoto *em)
C_VAL(D, T, directory, EET_T_STRING);
C_VAL(D, T, slideshow_timeout, EET_T_DOUBLE);
C_VAL(D, T, slideshow_transition, EET_T_STRING);
C_VAL(D, T, editor, EET_T_STRING);
switch (_ephoto_config_load(em))
{
@ -37,15 +38,22 @@ ephoto_config_init(Ephoto *em)
em->config->thumb_size = 256;
em->config->remember_directory = 1;
em->config->slideshow_timeout = 4.0;
em->config->slideshow_transition = "fade";
em->config->slideshow_transition =
eina_stringshare_add("fade");
em->config->editor =
eina_stringshare_add("gimp %s");
break;
case -1:
if (em->config->config_version < 2)
{
em->config->remember_directory = 1;
em->config->slideshow_timeout = 4.0;
em->config->slideshow_transition = "fade";
em->config->slideshow_transition =
eina_stringshare_add("fade");
}
if (em->config->config_version < 3)
em->config->editor =
eina_stringshare_add("gimp %s");
/* Incremental additions */
em->config->config_version = CONFIG_VERSION;

View File

@ -14,6 +14,7 @@ static void _ephoto_go_previous(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_go_slideshow(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_go_rotate_counterclockwise(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_go_rotate_clockwise(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_go_editor(void *data, Evas_Object *obj, void *event_info);
static void _ephoto_key_pressed(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _ephoto_flow_browser_show_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _ephoto_flow_browser_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
@ -276,6 +277,7 @@ static const struct
{ "Escape", _ephoto_go_back },
{ "bracketleft", _ephoto_go_rotate_counterclockwise },
{ "bracketright", _ephoto_go_rotate_clockwise },
{ "e", _ephoto_go_editor },
{ NULL, NULL }
};
@ -423,3 +425,16 @@ _ephoto_go_rotate_clockwise(void *data, Evas_Object *obj, void *event_info)
break;
}
}
static void
_ephoto_go_editor(void *data, Evas_Object *obj, void *event_info)
{
Ephoto_Flow_Browser *ef = data;
Ecore_Exe *exe;
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), em->config->editor, (char *) ef->cur_image);
DBG("Editor command: %s", buf);
exe = ecore_exe_run(buf, NULL);
ecore_exe_free(exe);
}

View File

@ -10,7 +10,7 @@ ephoto_show_preferences(Ephoto *em)
{
if (!em->prefs_win)
{
Evas_Object *o, *tb, *box, *pager, *pg1, *pg2, *pg3;
Evas_Object *o, *tb, *box, *pager, *pg1, *pg2, *pg3, *scr;
const Eina_List *transitions, *l;
const char *transition;
@ -78,8 +78,6 @@ ephoto_show_preferences(Ephoto *em)
evas_object_show(o);
elm_table_pack(pg2, o, 0, 1, 1, 1);
/* XXX: The page cannot be the parent, since
* the items will be clipped to it */
o = elm_hoversel_add(pg2);
elm_hoversel_hover_parent_set(o, em->win);
elm_hoversel_label_set(o, em->config->slideshow_transition);
@ -98,6 +96,29 @@ ephoto_show_preferences(Ephoto *em)
evas_object_data_set(pg3, "pager", pager);
elm_toolbar_item_add(tb, NULL, "External Editor", _ephoto_preferences_pager_switch, pg3);
o = elm_label_add(pg3);
elm_label_label_set(o, "Image editor:");
elm_box_pack_end(pg3, o);
evas_object_show(o);
scr = elm_scroller_add(pg3);
elm_box_pack_end(pg3, scr);
elm_scroller_bounce_set(scr, EINA_TRUE, EINA_FALSE);
evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(scr);
o = elm_entry_add(pg3);
elm_entry_single_line_set(o, EINA_TRUE);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_entry_entry_set(o, em->config->editor);
evas_object_data_set(o, "config", "editor");
evas_object_smart_callback_add(o, "changed",
_ephoto_preferences_item_change, em);
elm_scroller_content_set(scr, o);
evas_object_show(o);
o = elm_button_add(box);
elm_button_label_set(o, "Close");
evas_object_size_hint_align_set(o, 1.0, 0.5);
@ -131,6 +152,10 @@ _ephoto_preferences_item_change(void *data, Evas_Object *obj, void *event_info)
em->config->remember_directory = elm_check_state_get(obj);
else if (!strcmp(key, "slideshow_timeout"))
em->config->slideshow_timeout = elm_spinner_value_get(obj);
else if (!strcmp(key, "editor"))
eina_stringshare_replace(
&em->config->editor,
eina_stringshare_add(elm_entry_entry_get(obj)));
ephoto_config_save(em, EINA_FALSE);
}