forked from enlightenment/enlightenment
Added ability to create/delete bar sources in config dialog now.
Uses new e_entry_dialog code. Added ability to select which eap field is shown in the label. This removes TODO items for ibar :) SVN revision: 23095
This commit is contained in:
parent
057af1edf4
commit
5ba5902c22
|
@ -3,11 +3,15 @@
|
|||
*/
|
||||
#include "e.h"
|
||||
#include "e_mod_main.h"
|
||||
#include <Ecore_File.h>
|
||||
|
||||
struct _E_Config_Dialog_Data
|
||||
{
|
||||
char *dir;
|
||||
int show_label;
|
||||
int eap_label;
|
||||
|
||||
Evas_Object *tlist;
|
||||
};
|
||||
|
||||
/* Protos */
|
||||
|
@ -15,6 +19,11 @@ static void *_create_data(E_Config_Dialog *cfd);
|
|||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static void _cb_add(void *data, void *data2);
|
||||
static void _cb_del(void *data, void *data2);
|
||||
static void _cb_entry_ok(char *text, void *data);
|
||||
static void _cb_confirm_dialog_yes(void *data);
|
||||
static void _load_tlist(E_Config_Dialog_Data *cfdata);
|
||||
|
||||
void
|
||||
_config_ibar_module(Config_Item *ci)
|
||||
|
@ -46,6 +55,7 @@ _fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
|
|||
else
|
||||
cfdata->dir = strdup("");
|
||||
cfdata->show_label = ci->show_label;
|
||||
cfdata->eap_label = ci->eap_label;
|
||||
}
|
||||
|
||||
static void *
|
||||
|
@ -71,19 +81,138 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *of, *ol, *ob;
|
||||
Ecore_List *dirs;
|
||||
char *home, buf[4096], *file;
|
||||
int selnum = -1;
|
||||
Evas_Object *o, *of, *ol, *ob, *ot;
|
||||
E_Radio_Group *rg;
|
||||
|
||||
o = e_widget_list_add(evas, 0, 0);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Selected Bar Source"), 0);
|
||||
|
||||
ol = e_widget_tlist_add(evas, &(cfdata->dir));
|
||||
e_widget_min_size_set(ol, 160, 160);
|
||||
e_widget_framelist_object_append(of, ol);
|
||||
of = e_widget_frametable_add(evas, _("Selected Bar Source"), 0);
|
||||
|
||||
ol = e_widget_tlist_add(evas, &(cfdata->dir));
|
||||
cfdata->tlist = ol;
|
||||
_load_tlist(cfdata);
|
||||
e_widget_min_size_set(ol, 160, 160);
|
||||
e_widget_frametable_object_append(of, ol, 0, 0, 1, 2, 1, 0, 1, 0);
|
||||
|
||||
ob = e_widget_button_add(evas, _("Add"), "widget/add", _cb_add, cfdata, NULL);
|
||||
e_widget_frametable_object_append(of, ob, 1, 0, 1, 1, 1, 1, 1, 0);
|
||||
ob = e_widget_button_add(evas, _("Delete"), "widget/del", _cb_del, cfdata, NULL);
|
||||
e_widget_frametable_object_append(of, ob, 1, 1, 1, 1, 1, 1, 1, 0);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Icon Labels"), 0);
|
||||
ob = e_widget_check_add(evas, _("Show Icon Label"), &(cfdata->show_label));
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
|
||||
rg = e_widget_radio_group_new(&(cfdata->eap_label));
|
||||
ob = e_widget_radio_add(evas, _("Display Eap Name"), 0, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Display Eap Comment"), 1, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Display Eap Generic"), 2, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = cfd->data;
|
||||
if (ci->dir) evas_stringshare_del(ci->dir);
|
||||
ci->dir = NULL;
|
||||
if (cfdata->dir) ci->dir = evas_stringshare_add(cfdata->dir);
|
||||
ci->show_label = cfdata->show_label;
|
||||
ci->eap_label = cfdata->eap_label;
|
||||
_ibar_config_update();
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_add(void *data, void *data2)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
e_entry_dialog_show(_("Create new ibar source"), "enlightenment/e",
|
||||
_("Enter a name for this new source"), NULL, NULL,
|
||||
_cb_entry_ok, NULL, cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_del(void *data, void *data2)
|
||||
{
|
||||
char buf[4096];
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = data;
|
||||
snprintf(buf, sizeof(buf), _("You requested to delete \"%s\".<br>"
|
||||
"<br>"
|
||||
"Are you sure you want to delete this bar source?"),
|
||||
cfdata->dir);
|
||||
|
||||
e_confirm_dialog_show(_("Are you sure you want to delete this bar source?"),
|
||||
"enlightenment/exit", buf, NULL, NULL, _cb_confirm_dialog_yes, NULL, cfdata, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_entry_ok(char *text, void *data)
|
||||
{
|
||||
char buf[4096];
|
||||
char tmp[4096];
|
||||
FILE *f;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s",
|
||||
e_user_homedir_get(), text);
|
||||
|
||||
if (!ecore_file_exists(buf))
|
||||
{
|
||||
ecore_file_mkdir(buf);
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s/.order",
|
||||
e_user_homedir_get(), text);
|
||||
f = fopen(buf, "w");
|
||||
if (f)
|
||||
{
|
||||
/* Populate this .order file with some defaults */
|
||||
snprintf(tmp, sizeof(tmp), "xterm.eap\n" "sylpheed.eap\n"
|
||||
"firefox.eap\n" "openoffice.eap\n" "xchat.eap\n"
|
||||
"gimp.eap\n" "xmms.eap\n");
|
||||
fwrite(tmp, sizeof(char), strlen(tmp), f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
_load_tlist(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_confirm_dialog_yes(void *data)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
char buf[4096];
|
||||
|
||||
cfdata = data;
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s", e_user_homedir_get(), cfdata->dir);
|
||||
if (ecore_file_is_dir(buf))
|
||||
ecore_file_recursive_rm(buf);
|
||||
|
||||
_load_tlist(cfdata);
|
||||
}
|
||||
|
||||
static void
|
||||
_load_tlist(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Ecore_List *dirs;
|
||||
char *home, buf[4096], *file;
|
||||
int selnum = -1;
|
||||
|
||||
e_widget_tlist_clear(cfdata->tlist);
|
||||
|
||||
home = e_user_homedir_get();
|
||||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar", home);
|
||||
dirs = ecore_file_ls(buf);
|
||||
|
@ -99,7 +228,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
snprintf(buf, sizeof(buf), "%s/.e/e/applications/bar/%s", home, file);
|
||||
if (ecore_file_is_dir(buf))
|
||||
{
|
||||
e_widget_tlist_append(ol, file, NULL, NULL, file);
|
||||
e_widget_tlist_append(cfdata->tlist, file, NULL, NULL, file);
|
||||
if ((cfdata->dir) && (!strcmp(cfdata->dir, file)))
|
||||
selnum = i;
|
||||
i++;
|
||||
|
@ -108,29 +237,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
ecore_list_destroy(dirs);
|
||||
}
|
||||
free(home);
|
||||
e_widget_tlist_go(ol);
|
||||
e_widget_tlist_go(cfdata->tlist);
|
||||
if (selnum >= 0)
|
||||
e_widget_tlist_selected_set(ol, selnum);
|
||||
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
ob = e_widget_check_add(evas, _("Show Icon Label"), &(cfdata->show_label));
|
||||
e_widget_list_object_append(o, ob, 1, 1, 0.5);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Config_Item *ci;
|
||||
|
||||
ci = cfd->data;
|
||||
if (ci->dir) evas_stringshare_del(ci->dir);
|
||||
ci->dir = NULL;
|
||||
if (cfdata->dir) ci->dir = evas_stringshare_add(cfdata->dir);
|
||||
ci->show_label = cfdata->show_label;
|
||||
_ibar_config_update();
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
e_widget_tlist_selected_set(cfdata->tlist, selnum);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ struct _IBar
|
|||
E_App *apps;
|
||||
Evas_List *icons;
|
||||
int show_label;
|
||||
int eap_label;
|
||||
};
|
||||
|
||||
struct _IBar_Icon
|
||||
|
@ -134,6 +135,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
|
|||
inst->dir = evas_stringshare_add(ci->dir);
|
||||
b = _ibar_new(gc->evas, ci->dir);
|
||||
b->show_label = ci->show_label;
|
||||
b->eap_label = ci->eap_label;
|
||||
b->inst = inst;
|
||||
inst->ibar = b;
|
||||
o = b->o_box;
|
||||
|
@ -446,6 +448,7 @@ _ibar_config_item_get(const char *id)
|
|||
ci = E_NEW(Config_Item, 1);
|
||||
ci->id = evas_stringshare_add(id);
|
||||
ci->show_label = 1;
|
||||
ci->eap_label = 0;
|
||||
ibar_config->items = evas_list_append(ibar_config->items, ci);
|
||||
return ci;
|
||||
}
|
||||
|
@ -454,6 +457,7 @@ void
|
|||
_ibar_config_update(void)
|
||||
{
|
||||
Evas_List *l;
|
||||
Evas_List *i;
|
||||
|
||||
for (l = ibar_config->instances; l; l = l->next)
|
||||
{
|
||||
|
@ -491,6 +495,29 @@ _ibar_config_update(void)
|
|||
_gc_orient(inst->gcc);
|
||||
}
|
||||
inst->ibar->show_label = ci->show_label;
|
||||
inst->ibar->eap_label = ci->eap_label;
|
||||
|
||||
for (i = inst->ibar->icons; i; i = i->next)
|
||||
{
|
||||
IBar_Icon *ic;
|
||||
|
||||
ic = i->data;
|
||||
switch (ci->eap_label)
|
||||
{
|
||||
case 0:
|
||||
edje_object_part_text_set(ic->o_holder, "label", ic->app->name);
|
||||
edje_object_part_text_set(ic->o_holder2, "label", ic->app->name);
|
||||
break;
|
||||
case 1:
|
||||
edje_object_part_text_set(ic->o_holder, "label", ic->app->comment);
|
||||
edje_object_part_text_set(ic->o_holder2, "label", ic->app->comment);
|
||||
break;
|
||||
case 2:
|
||||
edje_object_part_text_set(ic->o_holder, "label", ic->app->generic);
|
||||
edje_object_part_text_set(ic->o_holder2, "label", ic->app->generic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -590,8 +617,21 @@ _ibar_icon_fill(IBar_Icon *ic)
|
|||
evas_object_pass_events_set(ic->o_icon2, 1);
|
||||
evas_object_show(ic->o_icon2);
|
||||
|
||||
edje_object_part_text_set(ic->o_holder, "label", ic->app->name);
|
||||
edje_object_part_text_set(ic->o_holder2, "label", ic->app->name);
|
||||
switch (ic->ibar->eap_label)
|
||||
{
|
||||
case 0: /* Eap Name */
|
||||
edje_object_part_text_set(ic->o_holder, "label", ic->app->name);
|
||||
edje_object_part_text_set(ic->o_holder2, "label", ic->app->name);
|
||||
break;
|
||||
case 1: /* Eap Comment */
|
||||
edje_object_part_text_set(ic->o_holder, "label", ic->app->comment);
|
||||
edje_object_part_text_set(ic->o_holder2, "label", ic->app->comment);
|
||||
break;
|
||||
case 2: /* Eap Generic */
|
||||
edje_object_part_text_set(ic->o_holder, "label", ic->app->generic);
|
||||
edje_object_part_text_set(ic->o_holder2, "label", ic->app->generic);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1248,6 +1288,7 @@ e_modapi_init(E_Module *m)
|
|||
E_CONFIG_VAL(D, T, id, STR);
|
||||
E_CONFIG_VAL(D, T, dir, STR);
|
||||
E_CONFIG_VAL(D, T, show_label, INT);
|
||||
E_CONFIG_VAL(D, T, eap_label, INT);
|
||||
|
||||
conf_edd = E_CONFIG_DD_NEW("IBar_Config", Config);
|
||||
#undef T
|
||||
|
@ -1268,7 +1309,7 @@ e_modapi_init(E_Module *m)
|
|||
ci->id = evas_stringshare_add("0");
|
||||
ci->dir = evas_stringshare_add("default");
|
||||
ci->show_label = 1;
|
||||
|
||||
ci->eap_label = 0;
|
||||
ibar_config->items = evas_list_append(ibar_config->items, ci);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ struct _Config_Item
|
|||
const char *id;
|
||||
const char *dir;
|
||||
int show_label;
|
||||
int eap_label;
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
|
Loading…
Reference in New Issue