forked from enlightenment/enlightenment
Added start of a mime edit dialog. All disabled in config panel for now as
I'm still working on it. SVN revision: 26913
This commit is contained in:
parent
3825898025
commit
3e1e1c3396
|
@ -134,6 +134,7 @@ e_int_config_apps.h \
|
|||
e_int_config_cfgdialogs.h \
|
||||
e_int_config_color_classes.h \
|
||||
e_int_config_mime.h \
|
||||
e_int_config_mime_edit.h \
|
||||
e_deskpreview.h \
|
||||
e_exebuf.h \
|
||||
e_desklock.h \
|
||||
|
@ -286,6 +287,7 @@ e_int_config_cfgdialogs.c \
|
|||
e_int_config_intl.c \
|
||||
e_int_config_color_classes.c \
|
||||
e_int_config_mime.c \
|
||||
e_int_config_mime_edit.c \
|
||||
e_deskpreview.c \
|
||||
e_exebuf.c \
|
||||
e_desklock.c \
|
||||
|
|
|
@ -107,6 +107,7 @@
|
|||
#include "e_int_config_intl.h"
|
||||
#include "e_int_config_color_classes.h"
|
||||
#include "e_int_config_mime.h"
|
||||
#include "e_int_config_mime_edit.h"
|
||||
#include "e_deskpreview.h"
|
||||
#include "e_exebuf.h"
|
||||
#include "e_desklock.h"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
static void *_create_data (E_Config_Dialog *cfd);
|
||||
static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _fill_list (E_Config_Dialog_Data *cfdata);
|
||||
static void _cb_add (void *data, void *data2);
|
||||
|
@ -35,7 +34,6 @@ e_int_config_mime(E_Container *con)
|
|||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.apply_cfdata = _basic_apply;
|
||||
v->basic.create_widgets = _basic_create;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Mime Types"), "E", "_config_mime_dialog",
|
||||
|
@ -92,12 +90,6 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
|
@ -175,7 +167,25 @@ _cb_del(void *data, void *data2)
|
|||
static void
|
||||
_cb_config(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
E_Config_Mime_Icon *mi;
|
||||
Evas_List *l;
|
||||
int found = 0;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
if (!cfdata->sel_mt) return;
|
||||
|
||||
for (l = cfdata->mimes; l; l = l->next)
|
||||
{
|
||||
mi = l->data;
|
||||
if (!mi) continue;
|
||||
if (strcmp(mi->mime, cfdata->sel_mt)) continue;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
if (!found) return;
|
||||
e_int_config_mime_edit(mi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -0,0 +1,297 @@
|
|||
#include "e.h"
|
||||
|
||||
static void *_create_data (E_Config_Dialog *cfd);
|
||||
static void _fill_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static void _cb_icon_sel (void *data, void *data2);
|
||||
static Evas_Object *_get_icon (void *data);
|
||||
static void _cb_type (void *data, Evas_Object *obj, void *event_info);
|
||||
static void _cb_fsel_sel (void *data, Evas_Object *obj);
|
||||
static void _cb_fsel_ok (void *data, E_Dialog *dia);
|
||||
static void _cb_fsel_cancel (void *data, E_Dialog *dia);
|
||||
|
||||
typedef enum _Icon_Type Icon_Type;
|
||||
enum _Icon_Type
|
||||
{
|
||||
THUMB,
|
||||
EDJ,
|
||||
IMAGE
|
||||
};
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
char *mime;
|
||||
char *icon;
|
||||
int type;
|
||||
struct
|
||||
{
|
||||
Evas_Object *icon;
|
||||
E_Dialog *fsel;
|
||||
} gui;
|
||||
};
|
||||
|
||||
#define IFDUP(src, dst) if (src) dst = strdup(src); else dst = NULL;
|
||||
#define IFFREE(src) if (src) free(src); src = NULL;
|
||||
|
||||
EAPI E_Config_Dialog *
|
||||
e_int_config_mime_edit(E_Config_Mime_Icon *mime)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
E_Container *con;
|
||||
|
||||
if (e_config_dialog_find("E", "_config_mime_edit_dialog")) return NULL;
|
||||
|
||||
con = e_container_current_get(e_manager_current_get());
|
||||
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.create_widgets = _basic_create;
|
||||
v->basic.apply_cfdata = _basic_apply;
|
||||
|
||||
cfd = e_config_dialog_new(con, _("Mime Settings"), "E",
|
||||
"_config_mime_edit_dialog", "enlightenment/e",
|
||||
0, v, mime);
|
||||
return cfd;
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
_fill_data(cfd, cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_fill_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Config_Mime_Icon *mime;
|
||||
char *p;
|
||||
|
||||
if (!cfd->data) return;
|
||||
|
||||
mime = cfd->data;
|
||||
if (!mime) return;
|
||||
IFDUP(mime->mime, cfdata->mime);
|
||||
IFDUP(mime->icon, cfdata->icon);
|
||||
if (!cfdata->icon)
|
||||
{
|
||||
cfdata->type = THUMB;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp(cfdata->icon, "THUMB"))
|
||||
cfdata->type = THUMB;
|
||||
else
|
||||
{
|
||||
printf("Icon: %s\n", cfdata->icon);
|
||||
p = strrchr(cfdata->icon, '.');
|
||||
if ((p) && (!strcmp(p, ".edj")))
|
||||
cfdata->type = EDJ;
|
||||
else
|
||||
cfdata->type = IMAGE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
IFFREE(cfdata->mime);
|
||||
IFFREE(cfdata->icon);
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *of;
|
||||
Evas_Object *ob, *oi, *icon;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Basic Info"), 0);
|
||||
ob = e_widget_label_add(evas, _("Mime:"));
|
||||
e_widget_frametable_object_append(of, ob, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||
ob = e_widget_entry_add(evas, &(cfdata->mime));
|
||||
e_widget_min_size_set(ob, 100, 1);
|
||||
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 1, 1, 1, 1);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_frametable_add(evas, _("Icon"), 0);
|
||||
rg = e_widget_radio_group_new(&cfdata->type);
|
||||
ob = e_widget_radio_add(evas, _("Use Generated Thumbnail"), THUMB, rg);
|
||||
evas_object_smart_callback_add(ob, "changed", _cb_type, cfdata);
|
||||
e_widget_frametable_object_append(of, ob, 0, 0, 3, 1, 1, 1, 1, 1);
|
||||
ob = e_widget_radio_add(evas, _("Use Edje File"), EDJ, rg);
|
||||
evas_object_smart_callback_add(ob, "changed", _cb_type, cfdata);
|
||||
e_widget_frametable_object_append(of, ob, 0, 1, 3, 1, 1, 1, 1, 1);
|
||||
ob = e_widget_radio_add(evas, _("Use Image"), IMAGE, rg);
|
||||
evas_object_smart_callback_add(ob, "changed", _cb_type, cfdata);
|
||||
e_widget_frametable_object_append(of, ob, 0, 2, 3, 1, 1, 1, 1, 1);
|
||||
|
||||
oi = e_widget_button_add(evas, "", NULL, _cb_icon_sel, cfdata, cfd);
|
||||
cfdata->gui.icon = oi;
|
||||
if (cfdata->icon)
|
||||
{
|
||||
icon = _get_icon(cfdata);
|
||||
if (icon)
|
||||
e_widget_button_icon_set(oi, icon);
|
||||
}
|
||||
|
||||
e_widget_min_size_set(oi, 48, 48);
|
||||
e_widget_frametable_object_append(of, oi, 1, 3, 1, 1, 1, 1, 1, 1);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_icon_sel(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
E_Config_Dialog *cfd;
|
||||
E_Dialog *dia;
|
||||
Evas_Object *o;
|
||||
Evas_Coord w, h;
|
||||
char *dir = NULL;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
if (cfdata->gui.fsel) return;
|
||||
|
||||
cfd = data2;
|
||||
if (!cfd) return;
|
||||
|
||||
dia = e_dialog_new(cfd->con, "E", "_mime_icon_select_dialog");
|
||||
if (!dia) return;
|
||||
e_dialog_title_set(dia, _("Select an Icon"));
|
||||
dia->data = cfdata;
|
||||
if (cfdata->icon)
|
||||
dir = (char *)e_fm_mime_icon_get(cfdata->icon);
|
||||
if ((dir) && (cfdata->type != THUMB))
|
||||
{
|
||||
o = e_widget_fsel_add(dia->win->evas, dir, "/", NULL, NULL,
|
||||
_cb_fsel_sel, cfdata, NULL, cfdata, 1);
|
||||
free(dir);
|
||||
}
|
||||
else
|
||||
o = e_widget_fsel_add(dia->win->evas, "~/", "/", NULL, NULL,
|
||||
_cb_fsel_sel, cfdata, NULL, cfdata, 1);
|
||||
|
||||
evas_object_show(o);
|
||||
e_widget_min_size_get(o, &w, &h);
|
||||
e_dialog_content_set(dia, o, w, h);
|
||||
|
||||
e_dialog_button_add(dia, _("OK"), NULL, _cb_fsel_ok, cfdata);
|
||||
e_dialog_button_add(dia, _("Cancel"), NULL, _cb_fsel_cancel, cfdata);
|
||||
e_dialog_resizable_set(dia, 1);
|
||||
e_win_centered_set(dia->win, 1);
|
||||
e_dialog_show(dia);
|
||||
e_win_resize(dia->win, 475, 341);
|
||||
|
||||
cfdata->gui.fsel = dia;
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_get_icon(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Evas_Object *icon = NULL;
|
||||
const char *tmp;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return icon;
|
||||
|
||||
e_widget_disabled_set(cfdata->gui.icon, 1);
|
||||
|
||||
tmp = e_fm_mime_icon_get(cfdata->icon);
|
||||
switch (cfdata->type)
|
||||
{
|
||||
case THUMB:
|
||||
icon = edje_object_add(evas_object_evas_get(cfdata->gui.icon));
|
||||
e_theme_edje_object_set(icon, "base/theme/fileman", "e/icons/fileman/file");
|
||||
break;
|
||||
case EDJ:
|
||||
icon = edje_object_add(evas_object_evas_get(cfdata->gui.icon));
|
||||
if (!e_theme_edje_object_set(icon, "base/theme/fileman", cfdata->icon))
|
||||
e_theme_edje_object_set(icon, "base/theme/fileman", "e/icons/fileman/file");
|
||||
e_widget_disabled_set(cfdata->gui.icon, 0);
|
||||
break;
|
||||
case IMAGE:
|
||||
icon = e_icon_add(evas_object_evas_get(cfdata->gui.icon));
|
||||
e_icon_file_set(icon, cfdata->icon);
|
||||
e_widget_disabled_set(cfdata->gui.icon, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_type(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
switch (cfdata->type)
|
||||
{
|
||||
case THUMB:
|
||||
e_widget_disabled_set(cfdata->gui.icon, 1);
|
||||
break;
|
||||
case EDJ:
|
||||
e_widget_disabled_set(cfdata->gui.icon, 0);
|
||||
break;
|
||||
case IMAGE:
|
||||
e_widget_disabled_set(cfdata->gui.icon, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_fsel_sel(void *data, Evas_Object *obj)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_fsel_ok(void *data, E_Dialog *dia)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
_cb_fsel_cancel(data, dia);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_fsel_cancel(void *data, E_Dialog *dia)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
e_object_del(E_OBJECT(dia));
|
||||
cfdata->gui.fsel = NULL;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
#ifndef E_INT_CONFIG_MIME_EDIT_H
|
||||
#define E_INT_CONFIG_MIME_EDIT_H
|
||||
|
||||
EAPI E_Config_Dialog *e_int_config_mime_edit(E_Config_Mime_Icon *mime);
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue