Luncher: Introduce Enlightenment's new launcher/taskbar/iconify manager: Luncher

You are required to update efl along with this update to have the luncher theme files.
This commit is contained in:
Stephen okra Houston 2016-10-28 13:26:28 -05:00
parent 41b861214a
commit e82ec31175
12 changed files with 2392 additions and 4 deletions

View File

@ -1121,6 +1121,7 @@ src/modules/packagekit/module.desktop
src/modules/wl_desktop_shell/module.desktop
src/modules/wireless/module.desktop
src/modules/time/module.desktop
src/modules/luncher/module.desktop
data/xsession/enlightenment.desktop
data/etc/sysactions.conf
data/units/enlightenment.service

View File

@ -1009,6 +1009,7 @@ _e_module_whitelist_check(void)
"ibox",
"layout",
"lokker",
"luncher",
"mixer",
"msgbus",
"notification",

View File

@ -94,6 +94,8 @@ include src/modules/Makefile_teamwork.mk
include src/modules/Makefile_lokker.mk
include src/modules/Makefile_luncher.mk
include src/modules/Makefile_shot.mk
include src/modules/Makefile_backlight.mk

View File

@ -0,0 +1,23 @@
EXTRA_DIST += src/modules/luncher/module.desktop.in \
src/modules/luncher/e-module-luncher.edj
if USE_MODULE_IBAR
luncherdir = $(MDIR)/luncher
luncher_DATA = src/modules/luncher/e-module-luncher.edj \
src/modules/luncher/module.desktop
luncherpkgdir = $(MDIR)/luncher/$(MODULE_ARCH)
luncherpkg_LTLIBRARIES = src/modules/luncher/module.la
src_modules_luncher_module_la_LIBADD = $(MOD_LIBS)
src_modules_luncher_module_la_CPPFLAGS = $(MOD_CPPFLAGS) -Wall
src_modules_luncher_module_la_LDFLAGS = $(MOD_LDFLAGS)
src_modules_luncher_module_la_SOURCES = src/modules/luncher/mod.c \
src/modules/luncher/luncher.h \
src/modules/luncher/bar.c \
src/modules/luncher/config.c
PHONIES += luncher install-luncher
luncher: $(luncherpkg_LTLIBRARIES) $(luncher_DATA)
install-luncher: install-luncherDATA install-luncherpkgLTLIBRARIES
endif

View File

@ -84,7 +84,7 @@ e_int_config_apps_ibar(Evas_Object *parent EINA_UNUSED, const char *params EINA_
e_user_dir_concat_static(buff, "applications/bar/default/.order");
data = E_NEW(E_Config_Data, 1);
data->title = eina_stringshare_add(_("IBar Applications"));
data->title = eina_stringshare_add(_("Launcher Applications"));
data->dialog = eina_stringshare_add("applications/ibar_applications");
data->icon = eina_stringshare_add("preferences-applications-ibar");
data->filename = eina_stringshare_add(buff);
@ -98,7 +98,7 @@ e_int_config_apps_ibar_other(Evas_Object *parent EINA_UNUSED, const char *path)
if (!path) return NULL;
data = E_NEW(E_Config_Data, 1);
data->title = eina_stringshare_add(_("IBar Applications"));
data->title = eina_stringshare_add(_("Launcher Applications"));
data->dialog = eina_stringshare_add("internal/ibar_other");
data->icon = eina_stringshare_add("preferences-applications-ibar");
data->filename = eina_stringshare_add(path);

View File

@ -30,7 +30,7 @@ e_modapi_init(E_Module *m)
"user-bookmarks",
e_int_config_apps_favs);
e_configure_registry_item_add("applications/ibar_applications", 40,
_("IBar Applications"), NULL,
_("Launcher Applications"), NULL,
"preferences-applications-ibar",
e_int_config_apps_ibar);
e_configure_registry_item_add("applications/screen_lock_applications", 45,
@ -59,7 +59,7 @@ e_modapi_init(E_Module *m)
e_int_config_deskenv);
e_configure_registry_category_add("internal", -1, _("Internal"), NULL,
"enlightenment/internal");
e_configure_registry_item_add("internal/ibar_other", -1, _("IBar Other"),
e_configure_registry_item_add("internal/ibar_other", -1, _("Launcher Other"),
NULL, "preferences-system-windows",
e_int_config_apps_ibar_other);

1773
src/modules/luncher/bar.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,377 @@
#include "luncher.h"
static void
_config_close(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
luncher_config->list = NULL;
evas_object_del(luncher_config->config_dialog);
luncher_config->config_dialog = NULL;
e_config_save_queue();
}
static void
_config_source_changed(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Instance *inst = data;
const char *dir = elm_object_item_text_get(elm_list_selected_item_get(luncher_config->list));
if (!strcmp(inst->cfg->dir, dir))
return;
if (inst->cfg->dir) eina_stringshare_del(inst->cfg->dir);
inst->cfg->dir = NULL;
if (dir) inst->cfg->dir = eina_stringshare_ref(dir);
bar_reorder(inst);
}
static void
_config_populate_order_list(Evas_Object *list, Instance *inst)
{
Eina_List *dirs;
char buf[4096], *file;
size_t len;
Elm_Object_Item *it;
elm_list_clear(list);
len = e_user_dir_concat_static(buf, "applications/bar");
if (len + 2 >= sizeof(buf)) return;
dirs = ecore_file_ls(buf);
buf[len] = '/';
len++;
EINA_LIST_FREE(dirs, file)
{
if (file[0] == '.') continue;
if (eina_strlcpy(buf + len, file, sizeof(buf) - len) >= sizeof(buf) - len)
continue;
if (ecore_file_is_dir(buf))
{
it = elm_list_item_append(list, file, NULL, NULL, _config_source_changed, inst);
if ((inst->cfg->dir) && (!strcmp(inst->cfg->dir, file)))
elm_list_item_selected_set(it, EINA_TRUE);
}
free(file);
}
elm_list_go(list);
}
static void
_config_source_cancel(void *data)
{
Instance *inst = data;
config_luncher(e_zone_current_get(), inst, luncher_config->bar);
}
static void
_config_source_added(void *data, char *text)
{
Instance *inst = data;
char buf[4096];
char tmp[4096] = {0};
FILE *f;
size_t len;
len = e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s", text);
if (len + sizeof("/.order") >= sizeof(buf)) return;
while (!ecore_file_exists(buf))
{
ecore_file_mkdir(buf);
memcpy(buf + len, "/.order", sizeof("/.order"));
e_user_dir_concat_static(tmp, "applications/bar/default/.order");
if (ecore_file_cp(tmp, buf)) break;
f = fopen(buf, "w");
if (!f) break;
/* Populate this .order file with some defaults */
snprintf(tmp, sizeof(tmp),
"terminology.desktop\n"
"sylpheed.desktop\n"
"firefox.desktop\n"
"openoffice.desktop\n"
"xchat.desktop\n"
"gimp.desktop\n");
fwrite(tmp, sizeof(char), strlen(tmp), f);
fclose(f);
break;
}
config_luncher(e_zone_current_get(), inst, luncher_config->bar);
}
static void
_config_source_deleted(void *data)
{
char buf[4096];
Instance *inst = data;
if (e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s", inst->cfg->dir) >= sizeof(buf))
return;
if (ecore_file_is_dir(buf))
ecore_file_recursive_rm(buf);
e_object_del(E_OBJECT(inst->order));
config_luncher(e_zone_current_get(), inst, luncher_config->bar);
}
static void
_config_source_add(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
{
Instance *inst = data;
evas_object_del(luncher_config->config_dialog);
e_entry_dialog_show(_("Create new Luncher source"), "enlightenment",
_("Enter a name for this new source:"), "", NULL, NULL,
_config_source_added, _config_source_cancel, inst);
}
static void
_config_source_del(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
{
Instance *inst = data;
char buf[4096];
evas_object_del(luncher_config->config_dialog);
snprintf(buf, sizeof(buf), _("You requested to delete \"%s\".<br><br>"
"Are you sure you want to delete this bar source?"),
inst->cfg->dir);
e_confirm_dialog_show(_("Are you sure you want to delete this bar source?"),
"application-exit", buf, _("Delete"), _("Keep"),
_config_source_deleted, _config_source_cancel, inst, inst,
NULL, NULL);
}
static void
_config_contents(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
{
Instance *inst = data;
Evas_Object *popup = evas_object_data_get(obj, "popup");
if (e_configure_registry_exists("applications/ibar_applications"))
{
char path[PATH_MAX];
e_user_dir_snprintf(path, sizeof(path), "applications/bar/%s/.order",
inst->cfg->dir);
e_configure_registry_call("internal/ibar_other", NULL, path);
evas_object_del(popup);
}
}
static void
_config_create_icon(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
{
Instance *inst = data;
Evas_Object *popup = evas_object_data_get(obj, "popup");
if (e_configure_registry_exists("applications/new_application"))
{
char path[PATH_MAX];
e_user_dir_snprintf(path, sizeof(path), "applications/bar/%s/.order",
inst->cfg->dir);
e_configure_registry_call("applications/new_application", NULL, path);
evas_object_del(popup);
}
}
static void
_icon_theme_file_set(Evas_Object *img, const char *icon)
{
const char *path = NULL, *k = NULL;
int len = 0;
if (!icon)
path = NULL;
else if (strncmp(icon, "/", 1) && !ecore_file_exists(icon))
{
path = efreet_icon_path_find(e_config->icon_theme, icon, 48);
if (!path)
{
if (e_util_strcmp(e_config->icon_theme, "hicolor"))
path = efreet_icon_path_find("hicolor", icon, 48);
}
}
else if (ecore_file_exists(icon))
{
path = icon;
}
if (!path)
{
char buf[4096];
snprintf(buf, sizeof(buf), "e/icons/%s", icon);
if (eina_list_count(e_theme_collection_items_find("base/theme/icons", buf)))
{
path = e_theme_edje_file_get("base/theme/icons", buf);
k = buf;
}
else
{
path = e_theme_edje_file_get("base/theme/icons", "e/icons/unknown");
k = "e/icons/unknown";
}
}
if (path && icon)
{
len = strlen(icon);
if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj")))
k = "icon";
}
elm_image_file_set(img, path, k);
}
EINTERN Evas_Object *
config_luncher(E_Zone *zone, Instance *inst, Eina_Bool bar)
{
Evas_Object *popup, *tb, *lbl, *fr, *box, *list;
Evas_Object *butbox, *sep, *hbox, *img, *but;
luncher_config->bar = bar;
popup = elm_popup_add(e_comp->elm);
E_EXPAND(popup);
elm_popup_allow_events_set(popup, 1);
elm_popup_scrollable_set(popup, 1);
tb = elm_table_add(popup);
E_EXPAND(tb);
evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(tb);
elm_object_content_set(popup, tb);
lbl = elm_label_add(tb);
evas_object_size_hint_weight_set(lbl, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(lbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_style_set(lbl, "marker");
evas_object_show(lbl);
elm_object_text_set(lbl, _("Luncher Configuration"));
elm_table_pack(tb, lbl, 0, 0, 1, 1);
box = elm_box_add(tb);
elm_box_horizontal_set(box, EINA_FALSE);
E_EXPAND(box);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_table_pack(tb, box, 0, 1, 1, 1);
evas_object_show(box);
fr = elm_frame_add(box);
elm_object_text_set(fr, _("Icon Order"));
E_EXPAND(fr);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, fr);
evas_object_show(fr);
box = elm_box_add(fr);
elm_box_horizontal_set(box, EINA_FALSE);
E_EXPAND(box);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(box);
hbox = elm_box_add(box);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_homogeneous_set(hbox, EINA_FALSE);
evas_object_size_hint_expand_set(hbox, 0.0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, hbox);
evas_object_show(hbox);
list = elm_list_add(hbox);
E_ALIGN(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
E_WEIGHT(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(hbox, list);
elm_list_select_mode_set(list, ELM_OBJECT_SELECT_MODE_ALWAYS);
elm_scroller_content_min_limit(list, 1, 1);
evas_object_show(list);
luncher_config->list = list;
_config_populate_order_list(list, inst);
butbox = elm_box_add(hbox);
elm_box_horizontal_set(butbox, EINA_FALSE);
E_EXPAND(butbox);
evas_object_size_hint_align_set(butbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(hbox, butbox);
evas_object_show(butbox);
sep = elm_separator_add(box);
elm_separator_horizontal_set(sep, EINA_TRUE);
elm_box_pack_end(box, sep);
evas_object_show(sep);
img = elm_icon_add(butbox);
evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
_icon_theme_file_set(img, "list-add");
evas_object_show(img);
but = elm_button_add(butbox);
elm_object_part_content_set(but, "icon", img);
elm_object_text_set(but, _("Add"));
E_EXPAND(but);
evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(but, "popup", popup);
evas_object_smart_callback_add(but, "clicked", _config_source_add, inst);
elm_box_pack_end(butbox, but);
evas_object_show(but);
img = elm_icon_add(butbox);
evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
_icon_theme_file_set(img, "list-remove");
evas_object_show(img);
but = elm_button_add(butbox);
elm_object_part_content_set(but, "icon", img);
elm_object_text_set(but, _("Delete"));
E_EXPAND(but);
evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(but, "popup", popup);
evas_object_smart_callback_add(but, "clicked", _config_source_del, inst);
elm_box_pack_end(butbox, but);
evas_object_show(but);
hbox = elm_box_add(box);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_homogeneous_set(hbox, EINA_TRUE);
E_EXPAND(box);
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, hbox);
evas_object_show(hbox);
img = elm_icon_add(hbox);
evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
_icon_theme_file_set(img, "document-new");
evas_object_show(img);
but = elm_button_add(hbox);
elm_object_part_content_set(but, "icon", img);
elm_object_text_set(but, _("Create New Icon"));
E_EXPAND(but);
evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(but, "popup", popup);
evas_object_smart_callback_add(but, "clicked", _config_create_icon, inst);
elm_box_pack_end(hbox, but);
evas_object_show(but);
img = elm_icon_add(hbox);
evas_object_size_hint_aspect_set(img, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
_icon_theme_file_set(img, "list-add");
evas_object_show(img);
but = elm_button_add(hbox);
elm_object_part_content_set(but, "icon", img);
elm_object_text_set(but, _("Contents"));
E_EXPAND(but);
evas_object_size_hint_align_set(but, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_data_set(but, "popup", popup);
evas_object_smart_callback_add(but, "clicked", _config_contents, inst);
elm_box_pack_end(hbox, but);
evas_object_show(but);
elm_object_content_set(fr, box);
popup = e_comp_object_util_add(popup, E_COMP_OBJECT_TYPE_NONE);
evas_object_layer_set(popup, E_LAYER_POPUP);
evas_object_resize(popup, zone->w / 4, zone->h / 3);
e_comp_object_util_center(popup);
evas_object_show(popup);
e_comp_object_util_autoclose(popup, NULL, e_comp_object_util_autoclose_on_escape, NULL);
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _config_close, NULL);
return luncher_config->config_dialog = popup;
}

Binary file not shown.

View File

@ -0,0 +1,87 @@
#ifndef LUNCHER_H
#define LUNCHER_H
#include "e.h"
E_API extern E_Module_Api e_modapi;
E_API void *e_modapi_init (E_Module *m);
E_API int e_modapi_shutdown (E_Module *m);
E_API int e_modapi_save (E_Module *m);
typedef struct _Config Config;
typedef struct _Config_Item Config_Item;
typedef struct _Instance Instance;
typedef struct _Icon Icon;
struct _Config
{
Eina_List *items;
E_Module *module;
Evas_Object *config_dialog;
Evas_Object *list;
Eina_Bool bar;
};
struct _Config_Item
{
int id;
Eina_Stringshare *dir;
};
struct _Instance
{
Evas_Object *o_main;
Evas_Object *o_icon_con;
E_Order *order;
Config_Item *cfg;
Eina_List *icons;
Eina_Hash *icons_desktop_hash;
Eina_Hash *icons_clients_hash;
Evas_Coord size;
Ecore_Job *resize_job;
E_Comp_Object_Mover *iconify_provider;
Evas_Object *drop_handler;
Evas_Object *place_holder;
Icon *drop_before;
};
struct _Icon
{
Instance *inst;
Evas_Object *o_layout;
Evas_Object *o_icon;
Evas_Object *o_overlay;
Evas_Object *preview;
Evas_Object *preview_box;
E_Exec_Instance *exec;
Efreet_Desktop *desktop;
Eina_List *execs;
Eina_List *clients;
Ecore_Timer *mouse_in_timer;
Ecore_Timer *mouse_out_timer;
Ecore_Timer *drag_timer;
Eina_Stringshare *icon;
Eina_Stringshare *key;
Eina_Bool in_order;
Eina_Bool active;
Eina_Bool starting;
struct
{
unsigned char start : 1;
unsigned char dnd : 1;
int x, y;
} drag;
};
EINTERN Evas_Object *config_luncher(E_Zone *zone, Instance *inst, Eina_Bool bar);
EINTERN Evas_Object *bar_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient);
EINTERN void bar_reorder(Instance *inst);
EINTERN void bar_recalculate(Instance *inst);
extern Config *luncher_config;
extern Eina_List *luncher_instances;
extern E_Module *module;
#endif

87
src/modules/luncher/mod.c Normal file
View File

@ -0,0 +1,87 @@
#include "luncher.h"
static E_Config_DD *conf_edd = NULL;
static E_Config_DD *conf_item_edd = NULL;
Eina_List *luncher_instances = NULL;
E_Module *module = NULL;
Config *luncher_config = NULL;
EINTERN void
luncher_init(void)
{
conf_item_edd = E_CONFIG_DD_NEW("Luncher_Config_Item", Config_Item);
#undef T
#undef D
#define T Config_Item
#define D conf_item_edd
E_CONFIG_VAL(D, T, id, INT);
E_CONFIG_VAL(D, T, dir, STR);
conf_edd = E_CONFIG_DD_NEW("Luncher_Config", Config);
#undef T
#undef D
#define T Config
#define D conf_edd
E_CONFIG_LIST(D, T, items, conf_item_edd);
luncher_config = e_config_domain_load("module.luncher", conf_edd);
if (!luncher_config)
{
Config_Item *ci;
luncher_config = E_NEW(Config, 1);
ci = E_NEW(Config_Item, 1);
ci->id = 0;
ci->dir = eina_stringshare_add("default");
luncher_config->items = eina_list_append(luncher_config->items, ci);
}
e_gadget_type_add("Luncher Bar", bar_create, NULL);
}
EINTERN void
luncher_shutdown(void)
{
if (luncher_config)
{
Config_Item *ci;
EINA_LIST_FREE(luncher_config->items, ci)
{
eina_stringshare_del(ci->dir);
free(ci);
}
E_FREE(luncher_config);
}
E_CONFIG_DD_FREE(conf_edd);
E_CONFIG_DD_FREE(conf_item_edd);
e_gadget_type_del("Luncher Bar");
}
E_API E_Module_Api e_modapi =
{
E_MODULE_API_VERSION,
"Luncher"
};
E_API void *
e_modapi_init(E_Module *m)
{
luncher_init();
module = m;
return m;
}
E_API int
e_modapi_shutdown(E_Module *m EINA_UNUSED)
{
luncher_shutdown();
return 1;
}
E_API int
e_modapi_save(E_Module *m EINA_UNUSED)
{
e_config_domain_save("module.luncher", conf_edd, luncher_config);
return 1;
}

View File

@ -0,0 +1,37 @@
[Desktop Entry]
Encoding=UTF-8
Type=Link
Name=Luncher
Name[ca]=Luncher
Name[cs]=Lišta spouštěčů
Name[de]=Luncher
Name[eo]=Breto Luncher
Name[fi]=Luncher
Name[fr]=Luncher
Name[gl]=Luncher
Name[ja]=Luncher
Name[ms]=Luncher
Name[pl]=Luncher
Name[ru]=Luncher
Name[sr]=И-трака
Name[tr]=Luncher
Comment=Iconic application launcher.
Comment[ca]=Barra d'icones per a executar aplicacions.
Comment[cs]=Lišta se spouštěči.
Comment[de]=Symbolbasierter Anwendungsstarter.
Comment[el]=Εικονικός εκκινητής εφαρμογών.
Comment[eo]=Lanĉilo de piktograma aplikaĵo.
Comment[es]=Lanzador de aplicaciones con íconos.
Comment[fi]=Ikoninen sovelluskäynnistin.
Comment[fr]=Barre d'icones permettant de lancer des applications.
Comment[gl]=Unha barra de iconas para iniciar aplicativos.
Comment[hu]=Ikonokkal bővíthető alkalmazásindító modul.
Comment[it]=Una barra di icone per il lancio di applicazioni.
Comment[ja]=Iconic アプリケーションランチャー
Comment[ms]=Pelancar aplikasi ikonik
Comment[pt]=Barra para iniciar aplicações
Comment[ru]=Панель для запуска приложений, представленных в виде значков.
Comment[sr]=Трака иконица покретача програма.
Comment[tr]=Uygulama başlatıcı.
Icon=e-module-ibar
X-Enlightenment-ModuleType=utils