forked from enlightenment/edi
edi_scm: make sure we give a sensible window title.
When using edi_scm outside of EDI it's useful to show the toplevel of the repository as the window title.
This commit is contained in:
parent
3421d668f0
commit
83adef96a9
|
@ -1,8 +1,8 @@
|
||||||
#include <Edi.h>
|
#include <Edi.h>
|
||||||
#include "edi_scm_ui.h"
|
#include "edi_scm_ui.h"
|
||||||
|
|
||||||
#define DEFAULT_WIDTH 460
|
#define DEFAULT_WIDTH 480
|
||||||
#define DEFAULT_HEIGHT 280
|
#define DEFAULT_HEIGHT 360
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_win_del_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
_win_del_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||||
|
@ -12,20 +12,17 @@ _win_del_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUS
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_setup_win(void)
|
window_setup(void)
|
||||||
{
|
{
|
||||||
Evas_Object *win, *icon;
|
Evas_Object *win, *icon;
|
||||||
Eina_Strbuf *title;
|
Eina_Strbuf *title;
|
||||||
char *cwd;
|
char *path;
|
||||||
|
|
||||||
cwd = getcwd(NULL, PATH_MAX);
|
|
||||||
|
|
||||||
title = eina_strbuf_new();
|
title = eina_strbuf_new();
|
||||||
eina_strbuf_append_printf(title, "Edi Source Control :: %s", cwd);
|
|
||||||
|
|
||||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||||
|
|
||||||
win = elm_win_util_standard_add(eina_strbuf_string_get(title), eina_strbuf_string_get(title));
|
win = elm_win_util_standard_add("edi_scm", "edi_scm");
|
||||||
icon = elm_icon_add(win);
|
icon = elm_icon_add(win);
|
||||||
elm_icon_standard_set(icon, "edi");
|
elm_icon_standard_set(icon, "edi");
|
||||||
elm_win_icon_object_set(win, icon);
|
elm_win_icon_object_set(win, icon);
|
||||||
|
@ -33,23 +30,33 @@ _setup_win(void)
|
||||||
evas_object_resize(win, DEFAULT_WIDTH * elm_config_scale_get(), DEFAULT_HEIGHT * elm_config_scale_get());
|
evas_object_resize(win, DEFAULT_WIDTH * elm_config_scale_get(), DEFAULT_HEIGHT * elm_config_scale_get());
|
||||||
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, NULL);
|
evas_object_smart_callback_add(win, "delete,request", _win_del_cb, NULL);
|
||||||
|
|
||||||
|
path = edi_scm_ui_add(win);
|
||||||
|
if (!path)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERR: unable to obtain path from SCM engine!\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
eina_strbuf_append_printf(title, "Edi Source Control :: %s", path);
|
||||||
|
|
||||||
|
elm_win_title_set(win, eina_strbuf_string_get(title));
|
||||||
|
|
||||||
|
elm_win_center(win, EINA_TRUE, EINA_TRUE);
|
||||||
|
|
||||||
|
evas_object_show(win);
|
||||||
|
|
||||||
eina_strbuf_free(title);
|
eina_strbuf_free(title);
|
||||||
free(cwd);
|
free(path);
|
||||||
|
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Evas_Object *win;
|
|
||||||
|
|
||||||
ecore_init();
|
ecore_init();
|
||||||
elm_init(argc, argv);
|
elm_init(argc, argv);
|
||||||
|
|
||||||
win = _setup_win();
|
window_setup();
|
||||||
edi_scm_ui_add(win);
|
|
||||||
elm_win_center(win, EINA_TRUE, EINA_TRUE);
|
|
||||||
evas_object_show(win);
|
|
||||||
|
|
||||||
ecore_main_loop_begin();
|
ecore_main_loop_begin();
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,32 @@ _edi_scm_ui_file_changes_cb(void *data EINA_UNUSED, int type EINA_UNUSED,
|
||||||
return ECORE_CALLBACK_DONE;
|
return ECORE_CALLBACK_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static char *
|
||||||
|
_edi_scm_find_directory(Edi_Scm_Engine *engine)
|
||||||
|
{
|
||||||
|
char *path;
|
||||||
|
char *directory = strdup(engine->workdir);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (!strcmp(directory, "/") || !strcmp(directory, "/home"))
|
||||||
|
break;
|
||||||
|
|
||||||
|
path = edi_path_append(directory, engine->directory);
|
||||||
|
if (ecore_file_exists(path))
|
||||||
|
{
|
||||||
|
free(path);
|
||||||
|
return directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(path);
|
||||||
|
directory = ecore_file_dir_get(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
edi_scm_ui_add(Evas_Object *parent)
|
edi_scm_ui_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
Evas_Object *box, *frame, *hbox, *cbox, *label, *avatar, *input, *button;
|
Evas_Object *box, *frame, *hbox, *cbox, *label, *avatar, *input, *button;
|
||||||
|
@ -747,5 +772,7 @@ edi_scm_ui_add(Evas_Object *parent)
|
||||||
|
|
||||||
elm_box_pack_end(hbox, button);
|
elm_box_pack_end(hbox, button);
|
||||||
elm_box_pack_end(box, hbox);
|
elm_box_pack_end(box, hbox);
|
||||||
|
|
||||||
|
return _edi_scm_find_directory(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,14 @@ extern "C" {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the commit dialog UI.
|
* Create the commit dialog UI.
|
||||||
*
|
*
|
||||||
* @param parent Parent object to add the commit UI to.
|
* @param parent Parent object to add the commit UI to.
|
||||||
|
*
|
||||||
|
* @return Path of repository directory.
|
||||||
|
*
|
||||||
* @ingroup SCM
|
* @ingroup SCM
|
||||||
*/
|
*/
|
||||||
void edi_scm_ui_add(Evas_Object *parent);
|
char *edi_scm_ui_add(Evas_Object *parent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|
Loading…
Reference in New Issue