summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2020-08-01 13:23:42 +0100
committerAlastair Poole <netstar@gmail.com>2020-08-01 13:23:42 +0100
commit9ddb932c095b016df43483bd84ee57ca4791a82e (patch)
tree500c3516b8357b545dd45de6e340e108af337a01
parent9aea02bf061b681fb5ba21f9acee7f5a0dcc03ee (diff)
editor: image. Display properly. Can Edit.
-rw-r--r--src/bin/edi_content.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/src/bin/edi_content.c b/src/bin/edi_content.c
index a2b6bd1..d29cc70 100644
--- a/src/bin/edi_content.c
+++ b/src/bin/edi_content.c
@@ -37,10 +37,60 @@ edi_content_diff_add(Evas_Object *parent, Edi_Mainview_Item *item)
37 return diff; 37 return diff;
38} 38}
39 39
40static const char *_image_path = NULL;
41
42static void
43_item_menu_edit_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
44{
45 const char *program = data;
46 const char *path = _image_path;
47
48 if (path)
49 ecore_exe_run(eina_slstr_printf("%s %s", program, path), NULL);
50 _image_path = NULL;
51}
52
53static Evas_Object *
54_image_menu_create(const char *path)
55{
56 Elm_Object_Item *menu_it, *menu_it2;
57 Evas_Object *menu;
58
59 _image_path = path;
60
61 menu = elm_menu_add(edi_main_win_get());
62 menu_it = elm_menu_item_add(menu, NULL, "edit", _("Edit with..."), NULL, NULL);
63 if (ecore_file_app_installed("gimp"))
64 menu_it2 = elm_menu_item_add(menu, menu_it, "gimp", _("Gimp"), _item_menu_edit_cb, "gimp");
65 if (ecore_file_app_installed("inkscape"))
66 menu_it2 = elm_menu_item_add(menu, menu_it, "inkscape", _("Inkscape"), _item_menu_edit_cb, "inkscape");
67
68 return menu;
69}
70
71static void
72_image_secondary_clicked_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
73 Evas_Object *obj EINA_UNUSED, void *event_info)
74{
75 Evas_Object *menu;
76 Evas_Event_Mouse_Up *ev;
77 const char *path = data;
78
79 ev = event_info;
80 if (ev->button != 3) return;
81
82 menu = _image_menu_create(path);
83 if (!menu) return;
84
85 elm_menu_move(menu, ev->canvas.x, ev->canvas.y);
86 evas_object_show(menu);
87}
88
40Evas_Object * 89Evas_Object *
41edi_content_image_add(Evas_Object *parent, Edi_Mainview_Item *item) 90edi_content_image_add(Evas_Object *parent, Edi_Mainview_Item *item)
42{ 91{
43 Evas_Object *vbox, *box, *searchbar, *statusbar, *scroll, *img; 92 Evas_Object *vbox, *box, *searchbar, *statusbar, *scroll, *img;
93 Evas_Coord w, h;
44 94
45 vbox = elm_box_add(parent); 95 vbox = elm_box_add(parent);
46 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 96 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -69,14 +119,19 @@ edi_content_image_add(Evas_Object *parent, Edi_Mainview_Item *item)
69 evas_object_size_hint_weight_set(scroll, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 119 evas_object_size_hint_weight_set(scroll, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70 evas_object_size_hint_align_set(scroll, EVAS_HINT_FILL, EVAS_HINT_FILL); 120 evas_object_size_hint_align_set(scroll, EVAS_HINT_FILL, EVAS_HINT_FILL);
71 evas_object_show(scroll); 121 evas_object_show(scroll);
72 img = elm_image_add(vbox);
73 elm_image_file_set(img, item->path, NULL);
74 elm_image_no_scale_set(img, EINA_TRUE);
75 elm_object_content_set(scroll, img);
76 evas_object_show(img);
77
78 elm_box_pack_end(box, scroll); 122 elm_box_pack_end(box, scroll);
79 123
124 img = evas_object_image_filled_add(vbox);
125 evas_object_image_file_set(img, item->path, NULL);
126 evas_object_image_size_get(img, &w, &h);
127 evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
128 evas_object_size_hint_align_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL);
129 evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_BOTH, w, h);
130 evas_object_size_hint_max_set(img, w, h);
131 evas_object_show(img);
132 evas_object_event_callback_add(img, EVAS_CALLBACK_MOUSE_UP, _image_secondary_clicked_cb, item->path);
133 elm_object_content_set(scroll, img);
134
80 edi_content_statusbar_add(statusbar, item); 135 edi_content_statusbar_add(statusbar, item);
81 edi_content_statusbar_position_set(item->pos, 0, 0); 136 edi_content_statusbar_position_set(item->pos, 0, 0);
82 137