2017-06-07 22:38:21 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
#include "Edi.h"
|
2017-09-30 04:27:19 -07:00
|
|
|
#include <Eio.h>
|
2017-09-29 13:37:21 -07:00
|
|
|
#include "edi_scm_ui.h"
|
2017-06-06 17:45:44 -07:00
|
|
|
#include "edi_private.h"
|
|
|
|
|
2017-10-03 06:57:05 -07:00
|
|
|
#define DEFAULT_USER_ICON "applications-development"
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
typedef struct _Edi_Scm_Ui_Data {
|
2017-09-30 12:31:21 -07:00
|
|
|
Ecore_Thread *thread;
|
|
|
|
Eio_Monitor *monitor;
|
|
|
|
Elm_Code *code;
|
|
|
|
const char *workdir;
|
2017-09-30 15:59:33 -07:00
|
|
|
void *data;
|
2017-09-30 12:31:21 -07:00
|
|
|
|
|
|
|
Eina_Bool results_max;
|
|
|
|
Eina_Bool is_configured;
|
|
|
|
Eina_Bool in_progress;
|
|
|
|
|
2017-09-30 05:06:58 -07:00
|
|
|
Evas_Object *parent;
|
2017-09-30 04:27:19 -07:00
|
|
|
Evas_Object *list;
|
|
|
|
Evas_Object *check;
|
|
|
|
Evas_Object *commit_button;
|
|
|
|
Evas_Object *commit_entry;
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
} Edi_Scm_Ui_Data;
|
2017-09-29 13:37:21 -07:00
|
|
|
|
|
|
|
const char *
|
|
|
|
_edi_scm_ui_avatar_cache_path_get(const char *email)
|
|
|
|
{
|
|
|
|
return eina_stringshare_printf("%s/%s/avatars/%s.jpeg", efreet_cache_home_get(),
|
|
|
|
PACKAGE_NAME, email);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _edi_scm_ui_screens_avatar_download_complete(void *data, const char *file,
|
2017-12-28 15:44:28 -08:00
|
|
|
int status)
|
2017-09-29 13:37:21 -07:00
|
|
|
{
|
|
|
|
Evas_Object *image = data;
|
|
|
|
|
|
|
|
if (status != 200)
|
|
|
|
{
|
|
|
|
ecore_file_remove(file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-28 16:57:51 -08:00
|
|
|
elm_photo_file_set(image, file);
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_scm_ui_screens_avatar_load(Evas_Object *image, const char *email)
|
|
|
|
{
|
2017-10-03 06:40:10 -07:00
|
|
|
char *tmp, *tmp2;
|
|
|
|
const char *cache, *cachedir, *cacheparentdir;
|
2017-09-29 13:37:21 -07:00
|
|
|
|
|
|
|
cache = _edi_scm_ui_avatar_cache_path_get(email);
|
|
|
|
if (ecore_file_exists(cache))
|
|
|
|
{
|
2017-12-28 16:57:51 -08:00
|
|
|
elm_photo_file_set(image, cache);
|
2017-09-29 13:37:21 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-03 06:40:10 -07:00
|
|
|
tmp = strdup(cache);
|
|
|
|
cachedir = dirname(tmp);
|
|
|
|
tmp2 = strdup(tmp);
|
|
|
|
cacheparentdir = dirname(tmp2);
|
2017-10-03 06:57:05 -07:00
|
|
|
if ((ecore_file_exists(cacheparentdir) || ecore_file_mkdir(cacheparentdir))
|
|
|
|
&& (ecore_file_exists(cachedir) || ecore_file_mkdir(cachedir)))
|
|
|
|
{
|
|
|
|
ecore_file_download(edi_scm_avatar_url_get(email), cache,
|
|
|
|
_edi_scm_ui_screens_avatar_download_complete, NULL,
|
|
|
|
image, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elm_icon_standard_set(image, DEFAULT_USER_ICON);
|
|
|
|
}
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-10-03 06:40:10 -07:00
|
|
|
free(tmp2);
|
|
|
|
free(tmp);
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
2017-06-06 17:45:44 -07:00
|
|
|
|
|
|
|
static void
|
2017-09-29 13:37:21 -07:00
|
|
|
_edi_scm_ui_screens_message_close_cb(void *data EINA_UNUSED,
|
2017-12-28 15:44:28 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2017-06-06 17:45:44 -07:00
|
|
|
{
|
|
|
|
Evas_Object *popup = data;
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-06-06 17:45:44 -07:00
|
|
|
evas_object_del(popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-09-30 05:06:58 -07:00
|
|
|
_edi_scm_ui_screens_message_open(Evas_Object *parent, const char *message)
|
2017-06-06 17:45:44 -07:00
|
|
|
{
|
|
|
|
Evas_Object *popup, *button;
|
|
|
|
|
2017-09-30 05:06:58 -07:00
|
|
|
popup = elm_popup_add(parent);
|
2017-06-06 17:45:44 -07:00
|
|
|
elm_object_part_text_set(popup, "title,text",
|
2017-09-29 13:37:21 -07:00
|
|
|
message);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
|
|
|
button = elm_button_add(popup);
|
2017-09-11 13:06:22 -07:00
|
|
|
elm_object_text_set(button, _("OK"));
|
2017-06-06 17:45:44 -07:00
|
|
|
elm_object_part_content_set(popup, "button1", button);
|
|
|
|
evas_object_smart_callback_add(button, "clicked",
|
2017-09-29 13:37:21 -07:00
|
|
|
_edi_scm_ui_screens_message_close_cb, popup);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
|
|
|
evas_object_show(popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-09-30 05:06:58 -07:00
|
|
|
_edi_scm_ui_screens_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
2017-12-28 15:44:28 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2017-06-06 17:45:44 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = data;
|
2017-09-30 05:06:58 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->thread)
|
|
|
|
ecore_thread_cancel(pd->thread);
|
2017-09-30 12:31:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
while ((ecore_thread_wait(pd->thread, 0.1)) != EINA_TRUE);
|
2017-09-30 14:53:09 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
evas_object_del(pd->parent);
|
2017-09-30 05:06:58 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->monitor)
|
|
|
|
eio_monitor_del(pd->monitor);
|
2017-09-30 05:06:58 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
free(pd);
|
2017-09-30 05:06:58 -07:00
|
|
|
|
|
|
|
elm_exit();
|
2017-06-06 17:45:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-09-29 13:37:21 -07:00
|
|
|
_edi_scm_ui_screens_commit_cb(void *data,
|
2017-12-28 15:44:28 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
void *event_info EINA_UNUSED)
|
2017-06-06 17:45:44 -07:00
|
|
|
{
|
2017-06-07 14:32:38 -07:00
|
|
|
Edi_Scm_Engine *engine;
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd;
|
2017-06-29 15:51:33 -07:00
|
|
|
const char *text;
|
|
|
|
char *message;
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-06-07 14:32:38 -07:00
|
|
|
engine = edi_scm_engine_get();
|
|
|
|
if (!engine)
|
|
|
|
return;
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd = data;
|
|
|
|
|
|
|
|
text = elm_object_text_get((Evas_Object *) pd->commit_entry);
|
2017-06-29 15:51:33 -07:00
|
|
|
if (!text || !text[0])
|
2017-06-06 17:45:44 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_screens_message_open(pd->parent, _("Please enter a valid commit message."));
|
2017-06-06 17:45:44 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-29 15:51:33 -07:00
|
|
|
message = elm_entry_markup_to_utf8(text);
|
2017-06-06 17:45:44 -07:00
|
|
|
edi_scm_commit(message);
|
2017-06-29 15:51:33 -07:00
|
|
|
|
|
|
|
free(message);
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->thread)
|
|
|
|
ecore_thread_cancel(pd->thread);
|
2017-09-30 12:56:31 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
while ((ecore_thread_wait(pd->thread, 0.1)) != EINA_TRUE);
|
2017-09-30 12:56:31 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
evas_object_del(pd->parent);
|
2017-09-30 12:56:31 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->monitor)
|
|
|
|
eio_monitor_del(pd->monitor);
|
2017-09-30 04:27:19 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
free(pd);
|
2017-09-30 04:27:19 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
elm_exit();
|
2017-06-06 17:45:44 -07:00
|
|
|
}
|
|
|
|
|
2017-09-21 06:13:41 -07:00
|
|
|
static const char *
|
2017-09-27 11:46:09 -07:00
|
|
|
_icon_status(Edi_Scm_Status_Code code)
|
2017-09-15 17:19:54 -07:00
|
|
|
{
|
2017-09-21 06:13:41 -07:00
|
|
|
switch (code)
|
2017-09-15 17:19:54 -07:00
|
|
|
{
|
2017-09-21 06:13:41 -07:00
|
|
|
case EDI_SCM_STATUS_NONE:
|
2017-09-27 11:46:09 -07:00
|
|
|
case EDI_SCM_STATUS_UNKNOWN:
|
|
|
|
return NULL;
|
2017-09-21 06:13:41 -07:00
|
|
|
case EDI_SCM_STATUS_RENAMED:
|
|
|
|
return "document-new";
|
|
|
|
case EDI_SCM_STATUS_DELETED:
|
|
|
|
return "edit-delete";
|
|
|
|
case EDI_SCM_STATUS_RENAMED_STAGED:
|
|
|
|
return "document-new";
|
|
|
|
case EDI_SCM_STATUS_DELETED_STAGED:
|
|
|
|
return "edit-delete";
|
2017-09-15 17:19:54 -07:00
|
|
|
case EDI_SCM_STATUS_ADDED:
|
2017-09-21 06:13:41 -07:00
|
|
|
return "document-new";
|
2017-09-15 17:19:54 -07:00
|
|
|
case EDI_SCM_STATUS_ADDED_STAGED:
|
2017-09-21 06:13:41 -07:00
|
|
|
return "document-new";
|
2017-09-15 17:19:54 -07:00
|
|
|
case EDI_SCM_STATUS_MODIFIED:
|
2017-09-21 06:13:41 -07:00
|
|
|
return "document-save-as";
|
2017-09-15 17:19:54 -07:00
|
|
|
case EDI_SCM_STATUS_MODIFIED_STAGED:
|
2017-09-21 06:13:41 -07:00
|
|
|
return "document-save-as";
|
2017-09-15 17:19:54 -07:00
|
|
|
case EDI_SCM_STATUS_UNTRACKED:
|
2017-09-21 06:13:41 -07:00
|
|
|
return "dialog-question";
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-09-27 11:46:09 -07:00
|
|
|
static void
|
2017-09-29 13:37:21 -07:00
|
|
|
_edi_scm_ui_status_free(Edi_Scm_Status *status)
|
2017-09-27 11:46:09 -07:00
|
|
|
{
|
|
|
|
eina_stringshare_del(status->fullpath);
|
|
|
|
eina_stringshare_del(status->path);
|
|
|
|
eina_stringshare_del(status->unescaped);
|
|
|
|
|
|
|
|
free(status);
|
|
|
|
}
|
|
|
|
|
2017-09-21 06:13:41 -07:00
|
|
|
static void
|
|
|
|
_content_del(void *data, Evas_Object *obj EINA_UNUSED)
|
|
|
|
{
|
2017-09-29 13:37:21 -07:00
|
|
|
Edi_Scm_Status *status = (Edi_Scm_Status *) data;
|
2017-09-21 06:13:41 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
_edi_scm_ui_status_free(status);
|
2017-09-21 06:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_content_get(void *data, Evas_Object *obj, const char *source)
|
|
|
|
{
|
|
|
|
Evas_Object *box, *lbox, *mbox, *rbox, *label, *ic;
|
2017-09-30 11:51:28 -07:00
|
|
|
const char *text, *icon_file, *icon_status, *mime;
|
2017-09-27 11:46:09 -07:00
|
|
|
Edi_Scm_Status *status;
|
2017-09-21 06:13:41 -07:00
|
|
|
|
2017-10-01 04:40:00 -07:00
|
|
|
icon_file = NULL;
|
|
|
|
|
2017-09-21 06:13:41 -07:00
|
|
|
if (strcmp(source, "elm.swallow.content"))
|
|
|
|
return NULL;
|
|
|
|
|
2017-09-27 11:46:09 -07:00
|
|
|
status = (Edi_Scm_Status *) data;
|
2017-09-21 12:26:13 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
mime = efreet_mime_type_get(status->fullpath);
|
|
|
|
if (mime)
|
2017-09-30 11:51:28 -07:00
|
|
|
icon_file = efreet_mime_type_icon_get(mime, elm_config_icon_theme_get(), 32);
|
2017-10-03 06:40:10 -07:00
|
|
|
|
2017-09-30 11:51:28 -07:00
|
|
|
if (!icon_file)
|
|
|
|
icon_file = "dialog-information";
|
2017-09-21 06:13:41 -07:00
|
|
|
|
|
|
|
box = elm_box_add(obj);
|
|
|
|
elm_box_horizontal_set(box, EINA_TRUE);
|
|
|
|
elm_box_align_set(box, 0, 0);
|
|
|
|
|
|
|
|
lbox = elm_box_add(box);
|
|
|
|
elm_box_horizontal_set(lbox, EINA_TRUE);
|
|
|
|
elm_box_padding_set(lbox, 5, 0);
|
|
|
|
evas_object_show(lbox);
|
|
|
|
|
|
|
|
ic = elm_icon_add(lbox);
|
2017-09-30 11:51:28 -07:00
|
|
|
elm_icon_standard_set(ic, icon_file);
|
2017-09-21 06:13:41 -07:00
|
|
|
evas_object_size_hint_min_set(ic, ELM_SCALE_SIZE(16), ELM_SCALE_SIZE(16));
|
|
|
|
evas_object_show(ic);
|
|
|
|
elm_box_pack_end(lbox, ic);
|
|
|
|
|
|
|
|
label = elm_label_add(lbox);
|
2017-09-27 11:46:09 -07:00
|
|
|
elm_object_text_set(label, status->unescaped);
|
2017-09-21 06:13:41 -07:00
|
|
|
evas_object_show(label);
|
|
|
|
elm_box_pack_end(lbox, label);
|
|
|
|
|
|
|
|
mbox = elm_box_add(lbox);
|
|
|
|
elm_box_horizontal_set(mbox, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(mbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_show(mbox);
|
|
|
|
|
|
|
|
rbox = elm_box_add(mbox);
|
|
|
|
elm_box_horizontal_set(rbox, EINA_TRUE);
|
|
|
|
elm_box_padding_set(rbox, 5, 0);
|
|
|
|
evas_object_show(rbox);
|
|
|
|
|
2017-09-30 11:51:28 -07:00
|
|
|
icon_status = _icon_status(status->change);
|
2017-09-21 06:13:41 -07:00
|
|
|
if (icon_status)
|
|
|
|
{
|
|
|
|
ic = elm_icon_add(rbox);
|
|
|
|
elm_icon_standard_set(ic, icon_status);
|
|
|
|
evas_object_size_hint_min_set(ic, ELM_SCALE_SIZE(16), ELM_SCALE_SIZE(16));
|
|
|
|
evas_object_show(ic);
|
|
|
|
elm_box_pack_end(rbox, ic);
|
|
|
|
|
2017-09-27 11:46:09 -07:00
|
|
|
if (status->staged)
|
2017-09-21 06:13:41 -07:00
|
|
|
{
|
|
|
|
ic = elm_icon_add(mbox);
|
|
|
|
elm_icon_standard_set(ic, "dialog-information");
|
|
|
|
evas_object_size_hint_min_set(ic, ELM_SCALE_SIZE(16), ELM_SCALE_SIZE(16));
|
|
|
|
evas_object_show(ic);
|
|
|
|
elm_box_pack_end(rbox, ic);
|
|
|
|
text = _("Staged changes");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ic = elm_icon_add(mbox);
|
|
|
|
elm_icon_standard_set(ic, "dialog-error");
|
|
|
|
evas_object_size_hint_min_set(ic, ELM_SCALE_SIZE(16), ELM_SCALE_SIZE(16));
|
|
|
|
evas_object_show(ic);
|
|
|
|
elm_box_pack_end(rbox, ic);
|
|
|
|
|
2017-09-27 11:46:09 -07:00
|
|
|
if (status->change != EDI_SCM_STATUS_UNTRACKED)
|
2017-09-21 06:13:41 -07:00
|
|
|
text = _("Unstaged changes");
|
|
|
|
else
|
|
|
|
text = _("Untracked changes");
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_object_tooltip_text_set(box, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
elm_box_pack_end(box, lbox);
|
|
|
|
elm_box_pack_end(box, mbox);
|
|
|
|
elm_box_pack_end(box, rbox);
|
|
|
|
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_status_list_fill(Edi_Scm_Ui_Data *pd)
|
2017-09-21 06:13:41 -07:00
|
|
|
{
|
2017-09-29 13:37:21 -07:00
|
|
|
Elm_Genlist_Item_Class *itc;
|
|
|
|
Edi_Scm_Status *status;
|
2017-09-21 06:13:41 -07:00
|
|
|
Edi_Scm_Engine *e;
|
2017-09-27 11:46:09 -07:00
|
|
|
Eina_List *l;
|
2017-09-21 06:13:41 -07:00
|
|
|
Eina_Bool staged = EINA_FALSE;
|
2017-12-28 15:44:28 -08:00
|
|
|
Evas_Object *list = pd->list;
|
2017-09-21 06:13:41 -07:00
|
|
|
|
|
|
|
e = edi_scm_engine_get();
|
|
|
|
if (!e)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
itc = elm_genlist_item_class_new();
|
|
|
|
itc->item_style = "full";
|
|
|
|
itc->func.text_get = NULL;
|
|
|
|
itc->func.content_get = _content_get;
|
|
|
|
itc->func.state_get = NULL;
|
|
|
|
itc->func.del = _content_del;
|
|
|
|
|
2017-09-30 14:53:09 -07:00
|
|
|
if (!edi_scm_status_get())
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(e->statuses, l, status)
|
2017-09-21 06:13:41 -07:00
|
|
|
{
|
2017-10-08 06:57:46 -07:00
|
|
|
if (status->staged)
|
|
|
|
staged = EINA_TRUE;
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->results_max)
|
2017-09-30 14:53:09 -07:00
|
|
|
{
|
|
|
|
elm_genlist_item_append(list, itc, status, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
2017-09-21 06:13:41 -07:00
|
|
|
{
|
2017-09-29 13:37:21 -07:00
|
|
|
if (status->staged)
|
2017-09-30 14:53:09 -07:00
|
|
|
elm_genlist_item_append(list, itc, status, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
|
|
|
else
|
|
|
|
_edi_scm_ui_status_free(status);
|
2017-09-21 06:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e->statuses)
|
|
|
|
{
|
|
|
|
eina_list_free(e->statuses);
|
|
|
|
e->statuses = NULL;
|
2017-09-15 17:19:54 -07:00
|
|
|
}
|
2017-09-30 14:53:09 -07:00
|
|
|
done:
|
2017-09-21 06:13:41 -07:00
|
|
|
elm_genlist_item_class_free(itc);
|
|
|
|
|
|
|
|
return staged;
|
2017-09-15 17:19:54 -07:00
|
|
|
}
|
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
static void
|
2017-12-28 15:44:28 -08:00
|
|
|
_diff_widget_lines_append(Ecore_Thread *thread, Elm_Code *code, char *text)
|
2017-09-30 11:51:28 -07:00
|
|
|
{
|
|
|
|
char *pos = text;
|
|
|
|
char *start, *end = NULL;
|
|
|
|
|
|
|
|
if (!*pos) return;
|
|
|
|
|
|
|
|
start = pos;
|
|
|
|
while (*pos++ != '\0')
|
|
|
|
{
|
|
|
|
if (*pos == '\n')
|
|
|
|
end = pos;
|
|
|
|
|
|
|
|
if (start && end)
|
|
|
|
{
|
|
|
|
ecore_thread_main_loop_begin();
|
|
|
|
elm_code_file_line_append(code->file, start, end - start, NULL);
|
|
|
|
ecore_thread_main_loop_end();
|
|
|
|
start = end + 1;
|
|
|
|
end = NULL;
|
|
|
|
if (ecore_thread_check(thread))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end = pos;
|
|
|
|
|
|
|
|
if (end > start)
|
|
|
|
{
|
|
|
|
ecore_thread_main_loop_begin();
|
|
|
|
elm_code_file_line_append(code->file, start, end - start, NULL);
|
|
|
|
ecore_thread_main_loop_end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-09-30 12:31:21 -07:00
|
|
|
_edi_scm_diff_thread_cancel_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
|
2017-09-30 11:51:28 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = data;
|
2017-09-30 14:53:09 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->in_progress = EINA_FALSE;
|
|
|
|
pd->thread = NULL;
|
2017-09-30 15:59:33 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->data)
|
2017-09-30 15:59:33 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
free(pd->data);
|
|
|
|
pd->data = NULL;
|
2017-09-30 15:59:33 -07:00
|
|
|
}
|
2017-09-30 11:51:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_scm_diff_thread_end_cb(void *data, Ecore_Thread *thread EINA_UNUSED)
|
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = data;
|
2017-09-30 11:51:28 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->in_progress = EINA_FALSE;
|
|
|
|
pd->thread = NULL;
|
2017-09-30 11:51:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_scm_diff_thread_cb(void *data, Ecore_Thread *thread)
|
2017-09-29 13:37:21 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = data;
|
2017-09-30 11:51:28 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->in_progress) return;
|
2017-09-30 11:51:28 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->data = edi_scm_diff(!pd->results_max);
|
2017-09-30 11:51:28 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->in_progress = EINA_TRUE;
|
|
|
|
pd->thread = thread;
|
2017-09-30 11:51:28 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
_diff_widget_lines_append(thread, pd->code, pd->data);
|
2017-09-30 11:51:28 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
free(pd->data);
|
|
|
|
pd->data = NULL;
|
2017-09-30 11:51:28 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_refresh(Edi_Scm_Ui_Data *pd)
|
2017-09-30 11:51:28 -07:00
|
|
|
{
|
2017-09-29 13:37:21 -07:00
|
|
|
Eina_Bool staged;
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->results_max = elm_check_state_get(pd->check);
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
elm_genlist_clear(pd->list);
|
2017-09-30 12:56:31 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
elm_code_file_clear(pd->code->file);
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
staged = _edi_scm_ui_status_list_fill(pd);
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (!pd->is_configured)
|
2017-09-29 13:37:21 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
elm_object_disabled_set(pd->commit_button, EINA_TRUE);
|
|
|
|
elm_entry_editable_set(pd->commit_entry, EINA_FALSE);
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
elm_object_disabled_set(pd->commit_button, !staged);
|
|
|
|
elm_entry_editable_set(pd->commit_entry, staged);
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
elm_genlist_realized_items_update(pd->list);
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
ecore_thread_run(_edi_scm_diff_thread_cb, _edi_scm_diff_thread_end_cb, _edi_scm_diff_thread_cancel_cb, pd);
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edi_scm_ui_refresh_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = data;
|
2017-09-30 04:27:19 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->thread)
|
|
|
|
ecore_thread_cancel(pd->thread);
|
2017-09-30 12:31:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
while ((ecore_thread_wait(pd->thread, 0.1)) != EINA_TRUE);
|
2017-09-30 12:31:21 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
if (pd->data)
|
2017-09-30 15:59:33 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
free(pd->data);
|
|
|
|
pd->data = NULL;
|
2017-09-30 15:59:33 -07:00
|
|
|
}
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_refresh(pd);
|
2017-09-30 04:27:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_edi_scm_ui_file_changes_cb(void *data EINA_UNUSED, int type EINA_UNUSED,
|
2017-12-28 15:44:28 -08:00
|
|
|
void *event EINA_UNUSED)
|
2017-09-30 04:27:19 -07:00
|
|
|
{
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = data;
|
2017-09-30 04:27:19 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_refresh(pd);
|
2017-09-30 04:27:19 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_DONE;
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
|
|
|
|
2017-12-20 13:47:21 -08:00
|
|
|
static void
|
|
|
|
_item_menu_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
void *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
evas_object_del(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_scm_stage_cb(void *data, Evas_Object *obj,
|
2017-12-28 15:44:28 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2017-12-20 13:47:21 -08:00
|
|
|
{
|
|
|
|
Edi_Scm_Status *status;
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = evas_object_data_get(obj, "edi_scm_ui");
|
2017-12-20 13:47:21 -08:00
|
|
|
|
|
|
|
status = data;
|
|
|
|
|
|
|
|
edi_scm_stage(status->path);
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_refresh(pd);
|
2017-12-20 13:47:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_item_menu_scm_unstage_cb(void *data, Evas_Object *obj,
|
2017-12-28 15:44:28 -08:00
|
|
|
void *event_info EINA_UNUSED)
|
2017-12-20 13:47:21 -08:00
|
|
|
{
|
|
|
|
Edi_Scm_Status *status;
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = evas_object_data_get(obj, "edi_scm_ui");
|
2017-12-20 13:47:21 -08:00
|
|
|
|
|
|
|
status = data;
|
|
|
|
|
|
|
|
edi_scm_unstage(status->path);
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_refresh(pd);
|
2017-12-20 13:47:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-12-28 15:44:28 -08:00
|
|
|
_item_menu_scm_staged_toggle(Edi_Scm_Status *status, Edi_Scm_Ui_Data *pd)
|
2017-12-20 13:47:21 -08:00
|
|
|
{
|
|
|
|
if (status->staged)
|
|
|
|
edi_scm_unstage(status->path);
|
|
|
|
else
|
|
|
|
edi_scm_stage(status->path);
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_refresh(pd);
|
2017-12-20 13:47:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2017-12-28 15:44:28 -08:00
|
|
|
_item_menu_create(Edi_Scm_Ui_Data *pd, Edi_Scm_Status *status)
|
2017-12-20 13:47:21 -08:00
|
|
|
{
|
|
|
|
Evas_Object *menu, *parent;
|
|
|
|
Elm_Object_Item *menu_it;
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
parent = pd->parent;
|
2017-12-20 13:47:21 -08:00
|
|
|
|
|
|
|
menu = elm_menu_add(parent);
|
2017-12-28 15:44:28 -08:00
|
|
|
evas_object_data_set(menu, "edi_scm_ui", pd);
|
2017-12-20 13:47:21 -08:00
|
|
|
evas_object_smart_callback_add(menu, "dismissed", _item_menu_dismissed_cb, NULL);
|
|
|
|
|
|
|
|
menu_it = elm_menu_item_add(menu, NULL, "document-properties", basename((char *)status->path), NULL, NULL);
|
|
|
|
elm_object_item_disabled_set(menu_it, EINA_TRUE);
|
|
|
|
elm_menu_item_separator_add(menu, NULL);
|
|
|
|
|
|
|
|
menu_it = elm_menu_item_add(menu, NULL, "document-save-as", _("Stage Changes"), _item_menu_scm_stage_cb, status);
|
|
|
|
if (status->staged)
|
|
|
|
elm_object_item_disabled_set(menu_it, EINA_TRUE);
|
|
|
|
|
|
|
|
menu_it = elm_menu_item_add(menu, NULL, "edit-undo", _("Unstage Changes"), _item_menu_scm_unstage_cb, status);
|
|
|
|
if (!status->staged)
|
|
|
|
elm_object_item_disabled_set(menu_it, EINA_TRUE);
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_list_item_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
2017-12-28 15:44:28 -08:00
|
|
|
void *event_info)
|
2017-12-20 13:47:21 -08:00
|
|
|
{
|
|
|
|
Evas_Object *menu;
|
|
|
|
Evas_Event_Mouse_Up *ev;
|
|
|
|
Elm_Object_Item *it;
|
|
|
|
Edi_Scm_Status *status;
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd = data;
|
2017-12-20 13:47:21 -08:00
|
|
|
|
|
|
|
ev = event_info;
|
|
|
|
it = elm_genlist_at_xy_item_get(obj, ev->output.x, ev->output.y, NULL);
|
|
|
|
status = elm_object_item_data_get(it);
|
|
|
|
|
|
|
|
if (!status)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ev->button != 3)
|
|
|
|
{
|
|
|
|
if (ev->button == 1 && ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
|
2017-12-28 15:44:28 -08:00
|
|
|
_item_menu_scm_staged_toggle(status, pd);
|
2017-12-20 13:47:21 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
menu = _item_menu_create(pd, status);
|
2017-12-20 13:47:21 -08:00
|
|
|
elm_menu_move(menu, ev->canvas.x, ev->canvas.y);
|
|
|
|
evas_object_show(menu);
|
|
|
|
}
|
|
|
|
|
2017-12-28 16:57:51 -08:00
|
|
|
static void
|
|
|
|
_avatar_effect(Evas_Object *avatar)
|
|
|
|
{
|
|
|
|
Evas_Map *map;
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
evas_object_move(avatar, 20 * elm_config_scale_get(), 20 * elm_config_scale_get());
|
|
|
|
evas_object_resize(avatar, 72 * elm_config_scale_get(), 72 * elm_config_scale_get());
|
|
|
|
evas_object_geometry_get(avatar, NULL, NULL, &w, &h);
|
|
|
|
|
|
|
|
map = evas_map_new(4);
|
|
|
|
evas_map_smooth_set(map, EINA_TRUE);
|
|
|
|
evas_map_util_points_populate_from_object(map, avatar);
|
|
|
|
evas_map_util_rotate(map, 8, w, h);
|
|
|
|
evas_object_map_set(avatar, map);
|
|
|
|
evas_object_map_enable_set(avatar, EINA_TRUE);
|
|
|
|
evas_map_free(map);
|
|
|
|
}
|
|
|
|
|
2017-10-06 07:30:14 -07:00
|
|
|
void
|
2017-09-29 13:37:21 -07:00
|
|
|
edi_scm_ui_add(Evas_Object *parent)
|
2017-06-06 17:45:44 -07:00
|
|
|
{
|
2017-09-29 13:37:21 -07:00
|
|
|
Evas_Object *box, *frame, *hbox, *cbox, *label, *avatar, *input, *button;
|
2017-09-30 02:05:04 -07:00
|
|
|
Evas_Object *table, *rect, *list, *pbox, *check, *sep;
|
2017-09-12 02:19:34 -07:00
|
|
|
Elm_Code_Widget *entry;
|
|
|
|
Elm_Code *code;
|
2017-09-21 06:13:41 -07:00
|
|
|
Eina_Strbuf *string;
|
2017-06-07 14:32:38 -07:00
|
|
|
Edi_Scm_Engine *engine;
|
2017-12-28 15:44:28 -08:00
|
|
|
Edi_Scm_Ui_Data *pd;
|
2017-09-29 13:37:21 -07:00
|
|
|
const char *remote_name, *remote_email;
|
2017-06-17 04:59:10 -07:00
|
|
|
Eina_Bool staged_changes;
|
2017-06-07 14:32:38 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
engine = edi_scm_engine_get();
|
2017-06-07 14:32:38 -07:00
|
|
|
if (!engine)
|
2017-09-30 11:51:28 -07:00
|
|
|
exit(1 << 1);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd = calloc(1, sizeof(Edi_Scm_Ui_Data));
|
|
|
|
pd->workdir = engine->root_directory;
|
|
|
|
pd->monitor = eio_monitor_add(pd->workdir);
|
|
|
|
pd->parent = parent;
|
|
|
|
pd->results_max = isatty(fileno(stdin));
|
2017-09-30 04:27:19 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
ecore_event_handler_add(EIO_MONITOR_FILE_CREATED, _edi_scm_ui_file_changes_cb, pd);
|
|
|
|
ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, _edi_scm_ui_file_changes_cb, pd);
|
|
|
|
ecore_event_handler_add(EIO_MONITOR_FILE_DELETED, _edi_scm_ui_file_changes_cb, pd);
|
|
|
|
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_CREATED, _edi_scm_ui_file_changes_cb, pd);
|
|
|
|
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_MODIFIED, _edi_scm_ui_file_changes_cb, pd);
|
|
|
|
ecore_event_handler_add(EIO_MONITOR_DIRECTORY_DELETED, _edi_scm_ui_file_changes_cb, pd);
|
2017-09-30 04:27:19 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
box = elm_box_add(parent);
|
2017-06-06 17:45:44 -07:00
|
|
|
elm_box_horizontal_set(box, EINA_FALSE);
|
2017-09-12 02:19:34 -07:00
|
|
|
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2017-09-29 13:37:21 -07:00
|
|
|
elm_object_content_set(parent, box);
|
|
|
|
evas_object_show(box);
|
2017-09-30 04:27:19 -07:00
|
|
|
|
|
|
|
frame = elm_frame_add(parent);
|
|
|
|
elm_object_text_set(frame, _("User information"));
|
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(frame);
|
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
hbox = elm_box_add(parent);
|
2017-06-07 22:38:21 -07:00
|
|
|
elm_box_horizontal_set(hbox, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(hbox);
|
2017-09-12 16:09:12 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
remote_name = engine->remote_name_get();
|
|
|
|
remote_email = engine->remote_email_get();
|
|
|
|
|
2017-12-28 16:57:51 -08:00
|
|
|
if (remote_name[0] && remote_email[0])
|
|
|
|
avatar = elm_photo_add(parent);
|
|
|
|
else
|
|
|
|
avatar = elm_icon_add(parent);
|
2017-12-28 15:44:28 -08:00
|
|
|
|
2017-12-28 16:57:51 -08:00
|
|
|
evas_object_size_hint_min_set(avatar, 72 * elm_config_scale_get(), 72 * elm_config_scale_get());
|
2017-10-03 06:57:05 -07:00
|
|
|
evas_object_size_hint_weight_set(avatar, 0.1, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(avatar, 1.0, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(avatar);
|
|
|
|
elm_box_pack_end(hbox, avatar);
|
2017-09-30 11:51:28 -07:00
|
|
|
|
2017-09-30 12:56:31 -07:00
|
|
|
/* General information */
|
2017-06-07 22:38:21 -07:00
|
|
|
|
|
|
|
label = elm_label_add(hbox);
|
2017-09-30 11:51:28 -07:00
|
|
|
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 1.0);
|
2017-06-07 14:32:38 -07:00
|
|
|
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(label);
|
2017-06-07 22:38:21 -07:00
|
|
|
elm_box_pack_end(hbox, label);
|
2017-06-07 14:32:38 -07:00
|
|
|
|
2017-09-30 04:27:19 -07:00
|
|
|
pbox = elm_box_add(parent);
|
|
|
|
elm_box_horizontal_set(pbox, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(pbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(pbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(pbox);
|
|
|
|
elm_box_pack_end(hbox, pbox);
|
|
|
|
|
2017-10-03 06:57:05 -07:00
|
|
|
string = eina_strbuf_new();
|
2017-12-28 15:44:28 -08:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
if (!remote_name[0] && !remote_email[0])
|
|
|
|
{
|
2017-09-30 11:51:28 -07:00
|
|
|
eina_strbuf_append(string, _("Unable to obtain user information."));
|
2017-10-03 06:57:05 -07:00
|
|
|
elm_icon_standard_set(avatar, DEFAULT_USER_ICON);
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-30 04:27:19 -07:00
|
|
|
eina_strbuf_append_printf(string, "%s:<br><b>%s</b> <%s>", _("Author"),
|
2017-12-29 03:53:26 -08:00
|
|
|
remote_name, remote_email);
|
2017-12-29 12:50:45 -08:00
|
|
|
_edi_scm_ui_screens_avatar_load(avatar, remote_email);
|
2017-12-28 16:57:51 -08:00
|
|
|
_avatar_effect(avatar);
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->is_configured = EINA_TRUE;
|
2017-09-29 13:37:21 -07:00
|
|
|
}
|
|
|
|
|
2017-09-21 06:13:41 -07:00
|
|
|
elm_object_text_set(label, eina_strbuf_string_get(string));
|
|
|
|
eina_strbuf_free(string);
|
2017-06-07 14:32:38 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->check = check = elm_check_add(parent);
|
2017-10-03 07:22:18 -07:00
|
|
|
elm_object_text_set(check, _("Show unstaged changes"));
|
2017-12-28 15:44:28 -08:00
|
|
|
elm_check_state_set(check, pd->results_max);
|
2017-09-29 13:37:21 -07:00
|
|
|
evas_object_show(check);
|
|
|
|
evas_object_smart_callback_add(check, "changed",
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_refresh_cb, pd);
|
2017-09-30 04:27:19 -07:00
|
|
|
elm_box_pack_end(hbox, check);
|
|
|
|
elm_object_content_set(frame, hbox);
|
|
|
|
elm_box_pack_end(box, frame);
|
2017-09-29 13:37:21 -07:00
|
|
|
|
2017-09-30 05:06:58 -07:00
|
|
|
/* File listing */
|
2017-09-30 02:05:04 -07:00
|
|
|
hbox = elm_box_add(parent);
|
|
|
|
elm_box_horizontal_set(hbox, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(hbox);
|
2017-09-30 04:27:19 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->list = list = elm_genlist_add(box);
|
2017-09-21 06:13:41 -07:00
|
|
|
elm_genlist_mode_set(list, ELM_LIST_SCROLL);
|
2017-12-20 13:47:21 -08:00
|
|
|
elm_genlist_select_mode_set(list, ELM_OBJECT_SELECT_MODE_NONE);
|
2017-09-21 06:13:41 -07:00
|
|
|
elm_scroller_bounce_set(list, EINA_TRUE, EINA_TRUE);
|
|
|
|
elm_scroller_policy_set(list, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON);
|
2017-06-17 04:59:10 -07:00
|
|
|
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2017-09-21 06:13:41 -07:00
|
|
|
evas_object_show(list);
|
2017-12-28 15:44:28 -08:00
|
|
|
evas_object_event_callback_add(list, EVAS_CALLBACK_MOUSE_UP, _list_item_clicked_cb, pd);
|
2017-06-17 04:59:10 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
table = elm_table_add(parent);
|
2017-09-21 06:13:41 -07:00
|
|
|
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
rect = evas_object_rectangle_add(table);
|
|
|
|
evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_min_set(rect, 300 * elm_config_scale_get(), 100 * elm_config_scale_get());
|
|
|
|
elm_table_pack(table, rect, 0, 0, 1, 1);
|
|
|
|
evas_object_show(table);
|
2017-06-17 04:59:10 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
frame = elm_frame_add(parent);
|
2017-09-21 06:13:41 -07:00
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_text_set(frame, _("File changes"));
|
|
|
|
evas_object_show(frame);
|
|
|
|
elm_object_content_set(frame, table);
|
|
|
|
elm_table_pack(table, list, 0, 0, 1, 1);
|
|
|
|
elm_object_content_set(frame, table);
|
2017-09-30 02:05:04 -07:00
|
|
|
elm_box_pack_end(hbox, frame);
|
|
|
|
elm_box_pack_end(box, hbox);
|
2017-09-19 03:29:25 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
staged_changes = _edi_scm_ui_status_list_fill(pd);
|
2017-06-17 04:59:10 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
/* Commit entry */
|
|
|
|
table = elm_table_add(parent);
|
2017-09-21 06:13:41 -07:00
|
|
|
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
rect = evas_object_rectangle_add(table);
|
|
|
|
evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_min_set(rect, 300 * elm_config_scale_get(), 100 * elm_config_scale_get());
|
|
|
|
elm_table_pack(table, rect, 0, 0, 1, 1);
|
|
|
|
evas_object_show(table);
|
2017-06-17 04:59:10 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
frame = elm_frame_add(parent);
|
2017-09-12 16:09:12 -07:00
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_text_set(frame, _("Commit message"));
|
|
|
|
evas_object_show(frame);
|
2017-09-21 06:13:41 -07:00
|
|
|
elm_object_content_set(frame, table);
|
2017-09-12 16:09:12 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->commit_entry = input = elm_entry_add(box);
|
2017-09-11 13:06:22 -07:00
|
|
|
elm_object_text_set(input, _("Enter commit summary<br><br>And change details<br>"));
|
2017-06-06 17:45:44 -07:00
|
|
|
evas_object_size_hint_weight_set(input, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2017-06-17 04:59:10 -07:00
|
|
|
elm_entry_editable_set(input, staged_changes);
|
2017-09-11 08:27:40 -07:00
|
|
|
elm_entry_scrollable_set(input, EINA_TRUE);
|
2017-09-21 06:13:41 -07:00
|
|
|
elm_entry_single_line_set(input, EINA_FALSE);
|
|
|
|
elm_entry_line_wrap_set(input, ELM_WRAP_WORD);
|
|
|
|
|
|
|
|
elm_table_pack(table, input, 0, 0, 1, 1);
|
2017-06-06 17:45:44 -07:00
|
|
|
evas_object_show(input);
|
2017-09-21 06:13:41 -07:00
|
|
|
|
|
|
|
elm_object_content_set(frame, table);
|
2017-09-30 02:05:04 -07:00
|
|
|
elm_box_pack_end(hbox, frame);
|
|
|
|
elm_box_pack_end(box, hbox);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
/* Start of elm_code diff widget */
|
|
|
|
frame = elm_frame_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_object_text_set(frame, _("Source changes"));
|
|
|
|
evas_object_show(frame);
|
|
|
|
|
|
|
|
cbox = elm_box_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(cbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(cbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2017-09-30 02:05:04 -07:00
|
|
|
evas_object_size_hint_min_set(cbox, 350 * elm_config_scale_get(), 150 * elm_config_scale_get());
|
2017-09-29 13:37:21 -07:00
|
|
|
evas_object_show(cbox);
|
|
|
|
elm_object_content_set(frame, cbox);
|
|
|
|
elm_box_pack_end(box, frame);
|
2017-09-11 08:27:40 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->code = code = elm_code_create();
|
2017-09-29 13:37:21 -07:00
|
|
|
entry = elm_code_widget_add(box, code);
|
|
|
|
elm_code_parser_standard_add(code, ELM_CODE_PARSER_STANDARD_DIFF);
|
2017-10-21 06:09:57 -07:00
|
|
|
elm_obj_code_widget_gravity_set(entry, 0.0, 0.0);
|
2017-09-29 13:37:21 -07:00
|
|
|
elm_obj_code_widget_editable_set(entry, EINA_FALSE);
|
|
|
|
elm_obj_code_widget_line_numbers_set(entry, EINA_FALSE);
|
|
|
|
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(entry);
|
|
|
|
elm_box_pack_end(cbox, entry);
|
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
ecore_thread_run(_edi_scm_diff_thread_cb, _edi_scm_diff_thread_end_cb, _edi_scm_diff_thread_cancel_cb, pd);
|
2017-09-11 08:27:40 -07:00
|
|
|
|
2017-09-30 02:05:04 -07:00
|
|
|
sep = elm_separator_add(parent);
|
|
|
|
elm_separator_horizontal_set(sep, EINA_TRUE);
|
|
|
|
evas_object_show(sep);
|
|
|
|
elm_box_pack_end(box, sep);
|
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
/* Start of confirm and cancel buttons */
|
|
|
|
hbox = elm_box_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
|
|
|
|
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_box_horizontal_set(hbox, EINA_TRUE);
|
|
|
|
evas_object_show(hbox);
|
2017-10-03 06:40:10 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
button = elm_button_add(parent);
|
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(button);
|
2017-09-11 13:06:22 -07:00
|
|
|
elm_object_text_set(button, _("Cancel"));
|
2017-06-06 17:45:44 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked",
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_screens_cancel_cb, pd);
|
2017-09-29 13:37:21 -07:00
|
|
|
elm_box_pack_end(hbox, button);
|
2017-06-06 17:45:44 -07:00
|
|
|
|
2017-12-28 15:44:28 -08:00
|
|
|
pd->commit_button = button = elm_button_add(parent);
|
2017-09-29 13:37:21 -07:00
|
|
|
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2017-06-06 17:45:44 -07:00
|
|
|
evas_object_data_set(button, "input", input);
|
2017-09-29 13:37:21 -07:00
|
|
|
evas_object_show(button);
|
2017-09-11 13:06:22 -07:00
|
|
|
elm_object_text_set(button, _("Commit"));
|
2017-06-17 04:59:10 -07:00
|
|
|
elm_object_disabled_set(button, !staged_changes);
|
2017-06-06 17:45:44 -07:00
|
|
|
evas_object_smart_callback_add(button, "clicked",
|
2017-12-28 15:44:28 -08:00
|
|
|
_edi_scm_ui_screens_commit_cb, pd);
|
2017-06-07 22:38:21 -07:00
|
|
|
|
2017-09-29 13:37:21 -07:00
|
|
|
elm_box_pack_end(hbox, button);
|
|
|
|
elm_box_pack_end(box, hbox);
|
2017-06-07 22:38:21 -07:00
|
|
|
}
|
|
|
|
|