Added morlenxus' Profile Configuration module.
SVN revision: 30834
This commit is contained in:
parent
6aee1fef3d
commit
84a19c6a53
|
@ -0,0 +1,7 @@
|
|||
.deps
|
||||
.libs
|
||||
Makefile
|
||||
Makefile.in
|
||||
*.lo
|
||||
module.la
|
||||
module.desktop
|
|
@ -0,0 +1,31 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = conf_profiles
|
||||
|
||||
# data files for the module
|
||||
filesdir = $(libdir)/enlightenment/modules/$(MODULE)
|
||||
files_DATA = \
|
||||
e-module-$(MODULE).edj module.desktop
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
||||
# the module .so file
|
||||
INCLUDES = -I. \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/modules/$(MODULE) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = e_mod_main.c \
|
||||
e_mod_main.h \
|
||||
e_int_config_profiles.c \
|
||||
e_int_config_profiles.h
|
||||
|
||||
module_la_LIBADD = @e_libs@ @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE)
|
Binary file not shown.
|
@ -0,0 +1,319 @@
|
|||
#include "e.h"
|
||||
|
||||
EAPI E_Config_Dialog *e_int_config_profiles(E_Container *con);
|
||||
static void *_create_data(E_Config_Dialog *cfd);
|
||||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static void _ilist_fill(E_Config_Dialog_Data *cfdata);
|
||||
static void _ilist_cb_selected(void *data);
|
||||
static void _cb_add(void *data, void *data2);
|
||||
static void _cb_select(void *data, void *data2);
|
||||
static void _cb_delete(void *data, void *data2);
|
||||
static void _cb_dialog_yes(void *data);
|
||||
static void _cb_dialog_destroy(void *data);
|
||||
|
||||
EAPI E_Dialog *_dia_new_profile(E_Config_Dialog_Data *cfdata);
|
||||
static void _new_profile_cb_close(void *data, E_Dialog *dia);
|
||||
static void _new_profile_cb_ok(void *data, E_Dialog *dia);
|
||||
static void _new_profile_cb_dia_del(void *obj);
|
||||
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
Evas_Object *o_list;
|
||||
Evas_Object *o_select;
|
||||
Evas_Object *o_delete;
|
||||
char *sel_profile;
|
||||
|
||||
E_Dialog *dia_new_profile;
|
||||
char *new_profile;
|
||||
};
|
||||
|
||||
typedef struct _Del_Profile_Confirm_Data Del_Profile_Confirm_Data;
|
||||
struct _Del_Profile_Confirm_Data
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
};
|
||||
|
||||
EAPI E_Config_Dialog *
|
||||
e_int_config_profiles(E_Container *con)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
E_Config_Dialog_View *v;
|
||||
|
||||
if (e_config_dialog_find("E", "_config_profiles_dialog")) return NULL;
|
||||
v = E_NEW(E_Config_Dialog_View, 1);
|
||||
if (!v) return NULL;
|
||||
v->create_cfdata = _create_data;
|
||||
v->free_cfdata = _free_data;
|
||||
v->basic.create_widgets = _create_widgets;
|
||||
|
||||
cfd = e_config_dialog_new(con,
|
||||
_("Profile Selector"),
|
||||
"E", "_config_profiles_dialog",
|
||||
"enlightenment/profiles", 0, v, NULL);
|
||||
return cfd;
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
cfdata->cfd = cfd;
|
||||
return cfdata;
|
||||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_FREE(cfdata);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *of, *ot, *ob;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 1);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Available Profiles"), 0);
|
||||
cfdata->o_list = e_widget_ilist_add(evas, 24, 24, &(cfdata->sel_profile));
|
||||
e_widget_min_size_set(cfdata->o_list, 155, 150);
|
||||
e_widget_framelist_object_append(of, cfdata->o_list);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
ot = e_widget_table_add(evas, 0);
|
||||
ob = e_widget_button_add(evas, _("Add"), "widget/add", _cb_add, cfdata, NULL);
|
||||
e_widget_table_object_append(ot, ob, 0, 0, 1, 1, 1, 1, 0, 0);
|
||||
cfdata->o_select = e_widget_button_add(evas, _("Select"), "widget/select", _cb_select, cfdata, NULL);
|
||||
e_widget_table_object_append(ot, cfdata->o_select, 0, 1, 1, 1, 1, 1, 0, 0);
|
||||
cfdata->o_delete = e_widget_button_add(evas, _("Delete"), "widget/del", _cb_delete, cfdata, NULL);
|
||||
e_widget_table_object_append(ot, cfdata->o_delete, 0, 2, 1, 1, 1, 1, 0, 0);
|
||||
|
||||
e_widget_disabled_set(cfdata->o_select, 1);
|
||||
e_widget_disabled_set(cfdata->o_delete, 1);
|
||||
|
||||
e_widget_list_object_append(o, ot, 1, 0, 0.0);
|
||||
|
||||
_ilist_fill(cfdata);
|
||||
|
||||
e_dialog_resizable_set(cfd->dia, 1);
|
||||
return o;
|
||||
}
|
||||
|
||||
static void
|
||||
_ilist_fill(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas *evas;
|
||||
Evas_List *l;
|
||||
char *cur_profile;
|
||||
|
||||
if (!cfdata) return;
|
||||
if (!cfdata->o_list) return;
|
||||
|
||||
evas = evas_object_evas_get(cfdata->o_list);
|
||||
evas_event_freeze(evas);
|
||||
edje_freeze();
|
||||
e_widget_ilist_freeze(cfdata->o_list);
|
||||
|
||||
e_widget_ilist_clear(cfdata->o_list);
|
||||
e_widget_ilist_go(cfdata->o_list);
|
||||
|
||||
cur_profile = e_config_profile_get ();
|
||||
for (l = e_config_profile_list(); l; l = l->next)
|
||||
{
|
||||
Evas_Object *ob;
|
||||
|
||||
ob = edje_object_add(evas);
|
||||
e_widget_ilist_append(cfdata->o_list, ob, l->data, _ilist_cb_selected, cfdata, l->data);
|
||||
if (!strcmp (cur_profile, l->data))
|
||||
{
|
||||
e_util_edje_icon_set(ob, "enlightenment/e");
|
||||
e_widget_ilist_selected_set(cfdata->o_list, e_widget_ilist_count(cfdata->o_list));
|
||||
}
|
||||
}
|
||||
|
||||
e_widget_min_size_set(cfdata->o_list, 155, 250);
|
||||
e_widget_ilist_go(cfdata->o_list);
|
||||
|
||||
e_widget_ilist_thaw(cfdata->o_list);
|
||||
edje_thaw();
|
||||
evas_event_thaw(evas);
|
||||
}
|
||||
|
||||
static void
|
||||
_ilist_cb_selected(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
char *cur_profile;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
cur_profile = e_config_profile_get ();
|
||||
if (!strcmp (cur_profile, cfdata->sel_profile))
|
||||
{
|
||||
e_widget_disabled_set(cfdata->o_select, 1);
|
||||
e_widget_disabled_set(cfdata->o_delete, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
e_widget_disabled_set(cfdata->o_select, 0);
|
||||
e_widget_disabled_set(cfdata->o_delete, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_add(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
if (cfdata->dia_new_profile)
|
||||
e_win_raise (cfdata->dia_new_profile->win);
|
||||
else
|
||||
cfdata->dia_new_profile = _dia_new_profile(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_select(void *data, void *data2)
|
||||
{
|
||||
E_Action *a;
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
e_config_save_flush ();
|
||||
e_config_profile_set (cfdata->sel_profile);
|
||||
e_config_profile_save ();
|
||||
e_config_save_block_set (1);
|
||||
|
||||
a = e_action_find("restart");
|
||||
if ((a) && (a->func.go)) a->func.go(NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_delete(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
Del_Profile_Confirm_Data *d;
|
||||
char buf[4096];
|
||||
|
||||
d = E_NEW(Del_Profile_Confirm_Data, 1);
|
||||
if (!d) return;
|
||||
d->cfdata = data;
|
||||
if (!d->cfdata) return;
|
||||
|
||||
snprintf(buf, sizeof(buf), _("You requested to delete \"%s\".<br><br>"
|
||||
"Are you sure you want to delete this profile?"),
|
||||
cfdata->sel_profile);
|
||||
e_confirm_dialog_show(_("Are you sure you want to delete this profile?"),
|
||||
"enlightenment/exit", buf, NULL, NULL, _cb_dialog_yes, NULL, d, NULL,
|
||||
_cb_dialog_destroy, d);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_dialog_yes(void *data)
|
||||
{
|
||||
Del_Profile_Confirm_Data *d;
|
||||
|
||||
d = data;
|
||||
if (!data) return;
|
||||
|
||||
e_config_profile_del (d->cfdata->sel_profile);
|
||||
e_config_save_queue();
|
||||
_ilist_fill(d->cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_dialog_destroy(void *data)
|
||||
{
|
||||
Del_Profile_Confirm_Data *d;
|
||||
|
||||
d = data;
|
||||
if (!data) return;
|
||||
|
||||
E_FREE(d);
|
||||
}
|
||||
|
||||
EAPI E_Dialog *
|
||||
_dia_new_profile(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
E_Dialog *dia;
|
||||
Evas *evas;
|
||||
Evas_Coord mw, mh;
|
||||
Evas_Object *ol, *ob;
|
||||
|
||||
dia = e_dialog_new(cfdata->cfd->con, "E", "profiles_new_profile_dialog");
|
||||
if (!dia) return NULL;
|
||||
dia->data = cfdata;
|
||||
|
||||
e_object_del_attach_func_set(E_OBJECT(dia), _new_profile_cb_dia_del);
|
||||
e_win_centered_set(dia->win, 1);
|
||||
|
||||
evas = e_win_evas_get(dia->win);
|
||||
|
||||
e_dialog_title_set(dia, _("Add New Profile"));
|
||||
ol = e_widget_table_add(evas, 0);
|
||||
e_widget_table_object_append(ol, e_widget_label_add(evas, _("Name:")),
|
||||
0, 0, 1, 1,
|
||||
1, 1, 0, 1);
|
||||
ob = e_widget_entry_add(evas, &(cfdata->new_profile));
|
||||
e_widget_table_object_append(ol, ob,
|
||||
1, 0, 1, 1,
|
||||
1, 1, 1, 1);
|
||||
e_widget_min_size_get(ol, &mw, &mh);
|
||||
e_dialog_content_set(dia, ol, mw, mh);
|
||||
|
||||
e_dialog_button_add(dia, _("OK"), NULL, _new_profile_cb_ok, cfdata);
|
||||
e_dialog_button_add(dia, _("Cancel"), NULL, _new_profile_cb_close, cfdata);
|
||||
|
||||
e_dialog_resizable_set(dia, 0);
|
||||
e_dialog_show(dia);
|
||||
|
||||
return dia;
|
||||
}
|
||||
|
||||
static void
|
||||
_new_profile_cb_close(void *data, E_Dialog *dia)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
e_object_unref(E_OBJECT(dia));
|
||||
cfdata->dia_new_profile = NULL;
|
||||
cfdata->new_profile = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_new_profile_cb_ok(void *data, E_Dialog *dia)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
cfdata = data;
|
||||
if (!cfdata) return;
|
||||
|
||||
e_object_unref(E_OBJECT(dia));
|
||||
cfdata->dia_new_profile = NULL;
|
||||
|
||||
if (cfdata->new_profile) e_config_profile_add(cfdata->new_profile);
|
||||
cfdata->new_profile = NULL;
|
||||
_ilist_fill(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_new_profile_cb_dia_del(void *obj)
|
||||
{
|
||||
E_Dialog *dia = obj;
|
||||
E_Config_Dialog_Data *cfdata = dia->data;
|
||||
|
||||
cfdata->dia_new_profile = NULL;
|
||||
cfdata->new_profile = NULL;
|
||||
e_object_unref(E_OBJECT(dia));
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
#else
|
||||
#ifndef E_INT_CONFIG_PROFILES_H
|
||||
#define E_INT_CONFIG_PROFILES_H
|
||||
|
||||
EAPI E_Config_Dialog *e_int_config_profiles(E_Container *con);
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
|
||||
/***************************************************************************/
|
||||
/**/
|
||||
/* actual module specifics */
|
||||
|
||||
static E_Module *conf_module = NULL;
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
/***************************************************************************/
|
||||
/**/
|
||||
|
||||
/**/
|
||||
/***************************************************************************/
|
||||
|
||||
/***************************************************************************/
|
||||
/**/
|
||||
/* module setup */
|
||||
EAPI E_Module_Api e_modapi =
|
||||
{
|
||||
E_MODULE_API_VERSION,
|
||||
"Configuration - Profiles"
|
||||
};
|
||||
|
||||
EAPI void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
e_configure_registry_category_add("advanced", 80, _("Advanced"), NULL, "enlightenment/advanced");
|
||||
e_configure_registry_item_add("advanced/profiles", 50, _("Profiles"), NULL, "enlightenment/profiles", e_int_config_profiles);
|
||||
conf_module = m;
|
||||
return m;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
{
|
||||
E_Config_Dialog *cfd;
|
||||
while ((cfd = e_config_dialog_get("E", "_config_profiles_dialog"))) e_object_del(E_OBJECT(cfd));
|
||||
e_configure_registry_item_del("advanced/profiles");
|
||||
e_configure_registry_category_del("advanced");
|
||||
conf_module = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_about(E_Module *m)
|
||||
{
|
||||
e_module_dialog_show(m,
|
||||
_("Enlightenment Configuration Module - Profiles"),
|
||||
_("Configuration dialog for config profiles."));
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
#ifndef E_MOD_MAIN_H
|
||||
#define E_MOD_MAIN_H
|
||||
|
||||
#define E_TYPEDEFS 1
|
||||
#include "e_int_config_profiles.h"
|
||||
|
||||
#undef E_TYPEDEFS
|
||||
#include "e_int_config_profiles.h"
|
||||
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
||||
EAPI void *e_modapi_init (E_Module *m);
|
||||
EAPI int e_modapi_shutdown (E_Module *m);
|
||||
EAPI int e_modapi_save (E_Module *m);
|
||||
EAPI int e_modapi_about (E_Module *m);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Link
|
||||
Name=Configuration - Profiles
|
||||
Icon=e-module-conf_profiles
|
Loading…
Reference in New Issue