Places: New option: autoclose_popup

* autoclose_popup: true, will close the popup like connman. False will keep it open like the clock module
 * factorized _places_run_fm()

SVN revision: 84535
This commit is contained in:
Davide Andreoli 2013-04-29 18:26:32 +00:00 committed by Tom Hacohen
parent 7a4deacc6d
commit 87db6172c0
4 changed files with 74 additions and 50 deletions

View File

@ -13,6 +13,7 @@ struct _E_Config_Dialog_Data
Evas_Object *entry;
int show_menu;
int hide_header;
int autoclose_popup;
int show_home;
int show_desk;
int show_trash;
@ -86,6 +87,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->show_menu = places_conf->show_menu;
cfdata->hide_header = places_conf->hide_header;
cfdata->autoclose_popup = places_conf->autoclose_popup;
cfdata->show_home = places_conf->show_home;
cfdata->show_desk = places_conf->show_desk;
cfdata->show_trash = places_conf->show_trash;
@ -144,6 +146,10 @@ _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
&(cfdata->hide_header));
e_widget_framelist_object_append(of, ow);
ow = e_widget_check_add(evas, D_("Auto close the popup"),
&(cfdata->autoclose_popup));
e_widget_framelist_object_append(of, ow);
ow = e_widget_check_add(evas, D_("Mount volumes at boot"),
&(cfdata->boot_mount));
e_widget_framelist_object_append(of, ow);
@ -203,6 +209,7 @@ _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
places_conf->show_menu = cfdata->show_menu;
places_conf->hide_header = cfdata->hide_header;
places_conf->autoclose_popup = cfdata->autoclose_popup;
places_conf->auto_mount = cfdata->auto_mount;
places_conf->boot_mount = cfdata->boot_mount;
places_conf->auto_open = cfdata->auto_open;

View File

@ -83,6 +83,7 @@ e_modapi_init(E_Module *m)
E_CONFIG_LIST(D, T, conf_items, conf_item_edd);
E_CONFIG_VAL(D, T, show_menu, UCHAR);
E_CONFIG_VAL(D, T, hide_header, UCHAR);
E_CONFIG_VAL(D, T, autoclose_popup, UCHAR);
E_CONFIG_VAL(D, T, show_home, UCHAR);
E_CONFIG_VAL(D, T, show_desk, UCHAR);
E_CONFIG_VAL(D, T, show_trash, UCHAR);
@ -247,6 +248,19 @@ _gc_shutdown(E_Gadcon_Client *gcc)
_places_cb_mouse_down);
places_empty_box(inst->o_main);
evas_object_del(inst->o_main);
inst->o_main = NULL;
}
if (inst->popup)
{
e_object_del(E_OBJECT(inst->popup));
inst->popup = NULL;
}
if (inst->o_icon)
{
evas_object_del(inst->o_icon);
inst->o_icon = NULL;
}
E_FREE(inst);
@ -351,6 +365,7 @@ _places_conf_new(void)
places_conf->auto_open = 0;
places_conf->show_home = 1;
places_conf->hide_header = 0;
places_conf->autoclose_popup = 0;
places_conf->show_desk = 1;
places_conf->show_trash = 0;
places_conf->show_root = 0;
@ -428,9 +443,13 @@ _places_popup_del_cb(Evas_Object *obj)
inst = e_object_data_get(E_OBJECT(obj));
if (!inst) return;
places_empty_box(inst->o_main);
evas_object_del(inst->o_main);
inst->o_main = NULL;
if (inst->o_main)
{
places_empty_box(inst->o_main);
evas_object_del(inst->o_main);
inst->o_main = NULL;
}
inst->popup = NULL;
}
@ -445,7 +464,7 @@ _places_popup_new(Instance *inst)
// create the popup
popup = e_gadcon_popup_new(inst->gcc);
if (0) // TODO make popup_autoclose an option (and close when volume selected?)
if (places_conf->autoclose_popup)
e_popup_autoclose(popup->win, NULL, NULL);
e_object_data_set(E_OBJECT(popup), inst);
E_OBJECT_DEL_SET(popup, _places_popup_del_cb);

View File

@ -12,7 +12,7 @@
/* Macros used for config file versioning */
#define MOD_CONFIG_FILE_EPOCH 0x0001
#define MOD_CONFIG_FILE_GENERATION 0x008f
#define MOD_CONFIG_FILE_GENERATION 0x0090
#define MOD_CONFIG_FILE_VERSION \
((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION)
@ -28,18 +28,19 @@ struct _Config
int version;
const char *fm;
unsigned char auto_mount;
unsigned char boot_mount;
unsigned char auto_open;
unsigned char show_menu;
unsigned char hide_header;
Eina_Bool auto_mount;
Eina_Bool boot_mount;
Eina_Bool auto_open;
Eina_Bool show_menu;
Eina_Bool hide_header;
Eina_Bool autoclose_popup;
unsigned char show_home;
unsigned char show_desk;
unsigned char show_trash;
unsigned char show_root;
unsigned char show_temp;
unsigned char show_bookm;
Eina_Bool show_home;
Eina_Bool show_desk;
Eina_Bool show_trash;
Eina_Bool show_root;
Eina_Bool show_temp;
Eina_Bool show_bookm;
};
typedef struct _Config_Item Config_Item;

View File

@ -19,7 +19,7 @@
static Eina_Bool _places_poller(void *data);
static const char *_places_human_size_get(unsigned long long size);
static void _places_volume_object_update(Volume *vol, Evas_Object *obj);
static void _places_run_fm(void *data, E_Menu *m, E_Menu_Item *mi);
static void _places_run_fm(const char *directory);
/* Edje callbacks */
void _places_icon_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source);
@ -110,8 +110,6 @@ places_volume_add(const char *id, Eina_Bool first_time)
v->label = eina_stringshare_add("");
v->mount_point = eina_stringshare_add("");
v->fstype = eina_stringshare_add("");
v->to_mount = EINA_FALSE;
v->force_open = EINA_FALSE;
v->drive_type = eina_stringshare_add("");
v->model = eina_stringshare_add("");
v->serial = eina_stringshare_add("");
@ -227,7 +225,7 @@ places_volume_update(Volume *vol)
// the volume has been mounted as requested, open the fm
if (vol->force_open && vol->mounted && vol->mount_point)
{
_places_run_fm((void*)vol->mount_point,NULL, NULL);
_places_run_fm(vol->mount_point);
vol->force_open = EINA_FALSE;
}
}
@ -612,14 +610,17 @@ _places_run_fm_external(const char *fm, const char *directory)
}
static void
_places_run_fm(void *data, E_Menu *m, E_Menu_Item *mi)
_places_run_fm(const char *directory)
{
const char *directory = data;
// TODO close the popup if any...but I miss inst here :/
// if (!m && inst->popup && places_conf->autoclose_popup)
// {
// e_object_del(E_OBJECT(inst->popup));
// }
if (places_conf->fm && places_conf->fm[0])
{
_places_run_fm_external(places_conf->fm, directory);
return;
}
else
{
@ -711,7 +712,7 @@ _places_icon_activated_cb(void *data, Evas_Object *o, const char *emission, cons
Volume *vol = data;
if (vol->mounted)
_places_run_fm((void*)vol->mount_point, NULL, NULL);
_places_run_fm((void*)vol->mount_point);
else
{
vol->force_open = EINA_TRUE;
@ -722,8 +723,7 @@ _places_icon_activated_cb(void *data, Evas_Object *o, const char *emission, cons
void // work in progress
_places_custom_icon_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source)
{
//data is char *uri
_places_run_fm(data, NULL, NULL);
_places_run_fm((const char*)data);
}
void
@ -740,11 +740,17 @@ _places_eject_activated_cb(void *data, Evas_Object *o, const char *emission, con
void
_places_header_activated_cb(void *data, Evas_Object *o, const char *emission, const char *source)
{
_places_run_fm((char*)e_user_homedir_get(), NULL, NULL);
_places_run_fm(e_user_homedir_get());
}
/* E17 menu augmentation */
void
_places_menu_cb(void *data, E_Menu *m, E_Menu_Item *mi)
{
_places_run_fm((const char*) data);
}
static void
_places_bookmarks_parse(E_Menu *em)
{
@ -770,17 +776,14 @@ _places_bookmarks_parse(E_Menu *em)
alias++;
}
uri = efreet_uri_decode(line);
if (uri && uri->path)
if (uri && uri->path && ecore_file_exists(uri->path))
{
if (ecore_file_exists(uri->path))
{
mi = e_menu_item_new(em);
e_menu_item_label_set(mi, alias ? alias :
ecore_file_file_get(uri->path));
e_util_menu_item_theme_icon_set(mi, "folder");
e_menu_item_callback_set(mi, _places_run_fm,
strdup(uri->path)); //TODO free somewhere
}
mi = e_menu_item_new(em);
e_menu_item_label_set(mi, alias ? alias :
ecore_file_file_get(uri->path));
e_util_menu_item_theme_icon_set(mi, "folder");
e_menu_item_callback_set(mi, _places_menu_cb,
strdup(uri->path)); //TODO free somewhere
}
if (uri) efreet_uri_free(uri);
}
@ -788,12 +791,6 @@ _places_bookmarks_parse(E_Menu *em)
}
}
void
places_menu_click_cb(void *data, E_Menu *m, E_Menu_Item *mi)
{
_places_icon_activated_cb(data, NULL, NULL, NULL);
}
void
places_generate_menu(void *data, E_Menu *em)
{
@ -806,7 +803,7 @@ places_generate_menu(void *data, E_Menu *em)
mi = e_menu_item_new(em);
e_menu_item_label_set(mi, D_("Home"));
e_util_menu_item_theme_icon_set(mi, "user-home");
e_menu_item_callback_set(mi, _places_run_fm, (char*)e_user_homedir_get());
e_menu_item_callback_set(mi, _places_menu_cb, (char*)e_user_homedir_get());
}
// Desktop
@ -816,7 +813,7 @@ places_generate_menu(void *data, E_Menu *em)
e_menu_item_label_set(mi, D_("Desktop"));
e_util_menu_item_theme_icon_set(mi, "user-desktop");
snprintf(buf, sizeof(buf), "%s/Desktop", (char*)e_user_homedir_get());
e_menu_item_callback_set(mi, _places_run_fm, strdup(buf)); //TODO free somewhere
e_menu_item_callback_set(mi, _places_menu_cb, strdup(buf)); //TODO free somewhere
}
// Trash
@ -825,7 +822,7 @@ places_generate_menu(void *data, E_Menu *em)
mi = e_menu_item_new(em);
e_menu_item_label_set(mi, D_("Trash"));
e_util_menu_item_theme_icon_set(mi, "user-trash");
e_menu_item_callback_set(mi, _places_run_fm, "trash:///");
e_menu_item_callback_set(mi, _places_menu_cb, "trash:///");
}
// File System
@ -834,7 +831,7 @@ places_generate_menu(void *data, E_Menu *em)
mi = e_menu_item_new(em);
e_menu_item_label_set(mi, D_("Filesystem"));
e_util_menu_item_theme_icon_set(mi, "drive-harddisk");
e_menu_item_callback_set(mi, _places_run_fm, "/");
e_menu_item_callback_set(mi, _places_menu_cb, "/");
}
// Temp
@ -843,7 +840,7 @@ places_generate_menu(void *data, E_Menu *em)
mi = e_menu_item_new(em);
e_menu_item_label_set(mi, D_("Temp"));
e_util_menu_item_theme_icon_set(mi, "user-temp");
e_menu_item_callback_set(mi, _places_run_fm, "/tmp");
e_menu_item_callback_set(mi, _places_menu_cb, "/tmp");
}
// Separator
@ -873,7 +870,7 @@ places_generate_menu(void *data, E_Menu *em)
if (vol->icon)
e_util_menu_item_theme_icon_set(mi, vol->icon);
e_menu_item_callback_set(mi, places_menu_click_cb, vol);
e_menu_item_callback_set(mi, _places_menu_cb, vol);
volumes_visible = 1;
}