found in the Launcher category, this module allows for windows to be hidden/shown using bindings, and can be used to turn any window/application into a quake-style drop-down terminal or whatever else you would use triggered window hiding/showing for. config options: * autohide - hides window when focus is lost * hide instead of raise - by default, qa will raise an activated window if it doesn't have focus; use this option to make it hide instead of raising * automatically reopen when closed - this option, when set, causes qa to relaunch the application which created the window if the window is closed. it should (probably) only be used for terminals, and requires some magic for setting window names on terminals which I have created some infra for extending to non-standard terminal types; currently all xterm clones, urxvt, and terminology are supported. note that setting this option will cause the entry to become permanent, as any entry which is set to restart itself when closed cannot be transient * transient - a window added to qa is initially a transient entry, meaning it's temporary: once you close the window, the binding is deleted, though the binding will remain if you restart e17. if you uncheck this option, it will become a permanent entry which can only be deleted either through the quickaccess advanced settings or the keybindings dialog. fun fact: you can get to the quickaccess settings faster by clicking the Quickaccess... border menu item SVN revision: 75550devs/princeamd/enlightenment-0.17-elive
parent
09387b5106
commit
7b1eef157b
11 changed files with 1915 additions and 0 deletions
@ -0,0 +1,34 @@ |
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
MODULE = quickaccess
|
||||
|
||||
# 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_builddir)/src/bin \
|
||||
-I$(top_srcdir)/src/modules \
|
||||
@e_cflags@
|
||||
|
||||
pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH)
|
||||
pkg_LTLIBRARIES = module.la
|
||||
|
||||
module_la_SOURCES = e_mod_main.h \
|
||||
e_mod_main.c \
|
||||
e_mod_quickaccess.c \
|
||||
e_quickaccess_bindings.c \
|
||||
e_quickaccess_db.c \
|
||||
e_mod_config.c
|
||||
|
||||
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,555 @@ |
||||
#include "e_mod_main.h" |
||||
|
||||
typedef struct Config_Entry |
||||
{ |
||||
EINA_INLIST; |
||||
const char *id; |
||||
E_Quick_Access_Entry *entry; |
||||
} Config_Entry; |
||||
|
||||
struct _E_Config_Dialog_Data |
||||
{ |
||||
const char *entry; |
||||
Evas_Object *o_list_entry; |
||||
Evas_Object *o_list_transient; |
||||
E_Entry_Dialog *ed; |
||||
|
||||
Eina_Inlist *entries; |
||||
Eina_Inlist *transient_entries; |
||||
|
||||
int autohide; |
||||
int hide_when_behind; |
||||
int skip_taskbar; |
||||
int skip_pager; |
||||
int dont_bug_me; |
||||
}; |
||||
|
||||
/**
|
||||
* in priority order: |
||||
* |
||||
* @todo configure match name (to be used by actions) |
||||
* |
||||
* @todo configure match icccm match class and name. |
||||
* |
||||
* @todo configure show/hide effects: |
||||
* - fullscreen |
||||
* - centered |
||||
* - slide from top, bottom, left or right |
||||
* |
||||
* @todo match more than one, doing tabs (my idea is to do another |
||||
* tabbing module first, experiment with that, maybe use/reuse |
||||
* it here) |
||||
*/ |
||||
|
||||
static Config_Entry * |
||||
_config_entry_new(E_Quick_Access_Entry *entry) |
||||
{ |
||||
Config_Entry *ce; |
||||
|
||||
ce = E_NEW(Config_Entry, 1); |
||||
ce->entry = entry; |
||||
entry->cfg_entry = ce; |
||||
return ce; |
||||
} |
||||
|
||||
static void |
||||
_config_entry_free(Config_Entry *ce) |
||||
{ |
||||
if (!ce) return; |
||||
ce->entry->cfg_entry = NULL; |
||||
eina_stringshare_del(ce->id); |
||||
if (ce->entry->transient) |
||||
qa_mod->cfd->cfdata->transient_entries = eina_inlist_remove(qa_mod->cfd->cfdata->transient_entries, EINA_INLIST_GET(ce)); |
||||
else |
||||
qa_mod->cfd->cfdata->entries = eina_inlist_remove(qa_mod->cfd->cfdata->entries, EINA_INLIST_GET(ce)); |
||||
free(ce); |
||||
} |
||||
|
||||
static void |
||||
_fill_data(E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
Eina_List *l; |
||||
E_Quick_Access_Entry *entry; |
||||
|
||||
cfdata->autohide = qa_config->autohide; |
||||
cfdata->hide_when_behind = qa_config->hide_when_behind; |
||||
cfdata->skip_taskbar = qa_config->skip_taskbar; |
||||
cfdata->skip_pager = qa_config->skip_pager; |
||||
|
||||
EINA_LIST_FOREACH(qa_config->entries, l, entry) |
||||
cfdata->entries = eina_inlist_append(cfdata->entries, EINA_INLIST_GET(_config_entry_new(entry))); |
||||
|
||||
EINA_LIST_FOREACH(qa_config->transient_entries, l, entry) |
||||
cfdata->transient_entries = eina_inlist_append(cfdata->transient_entries, EINA_INLIST_GET(_config_entry_new(entry))); |
||||
} |
||||
|
||||
static void * |
||||
_create_data(E_Config_Dialog *cfd) |
||||
{ |
||||
E_Config_Dialog_Data *cfdata; |
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1); |
||||
_fill_data(cfdata); |
||||
qa_mod->cfd = cfd; |
||||
return cfdata; |
||||
} |
||||
|
||||
static void |
||||
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
Eina_Inlist *l; |
||||
Config_Entry *ce; |
||||
EINA_INLIST_FOREACH_SAFE(cfdata->entries, l, ce) |
||||
_config_entry_free(ce); |
||||
EINA_INLIST_FOREACH_SAFE(cfdata->transient_entries, l, ce) |
||||
_config_entry_free(ce); |
||||
free(cfdata); |
||||
qa_mod->cfd = NULL; |
||||
} |
||||
|
||||
static int |
||||
_advanced_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
Config_Entry *ce; |
||||
#define CHECK(X) \ |
||||
if (cfdata->X != qa_config->X) return 1 |
||||
|
||||
CHECK(dont_bug_me); |
||||
|
||||
EINA_INLIST_FOREACH(cfdata->entries, ce) |
||||
if (ce->id) return 1; |
||||
EINA_INLIST_FOREACH(cfdata->transient_entries, ce) |
||||
if (ce->id) return 1; |
||||
|
||||
#undef CHECK |
||||
return 0; |
||||
} |
||||
|
||||
static int |
||||
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
#define CHECK(X) \ |
||||
if (cfdata->X != qa_config->X) return 1 |
||||
|
||||
CHECK(autohide); |
||||
CHECK(skip_pager); |
||||
CHECK(skip_taskbar); |
||||
CHECK(hide_when_behind); |
||||
|
||||
#undef CHECK |
||||
return 0; |
||||
} |
||||
|
||||
static void |
||||
_list_select(void *data) |
||||
{ |
||||
Config_Entry *ce = data; |
||||
} |
||||
|
||||
static void |
||||
_list_fill(E_Config_Dialog_Data *cfdata, Evas_Object *list, Eina_Bool transient) |
||||
{ |
||||
Config_Entry *ce; |
||||
EINA_INLIST_FOREACH(transient ? cfdata->transient_entries : cfdata->entries, ce) |
||||
{ |
||||
e_widget_ilist_append(list, NULL, ce->id ?: ce->entry->id, _list_select, ce, ce->entry->id); |
||||
} |
||||
e_widget_ilist_selected_set(list, 0); |
||||
} |
||||
|
||||
static void |
||||
_rename_del(void *data) |
||||
{ |
||||
E_Config_Dialog_Data *cfdata = e_object_data_get(data); |
||||
if (!cfdata) return; |
||||
cfdata->ed = NULL; |
||||
} |
||||
|
||||
static void |
||||
_rename_ok(char *text, void *data) |
||||
{ |
||||
Config_Entry *ce = data; |
||||
const char *name; |
||||
Evas_Object *list; |
||||
|
||||
name = eina_stringshare_add(text); |
||||
if (name == ce->id) |
||||
{ |
||||
eina_stringshare_del(name); |
||||
return; |
||||
} |
||||
if (name == ce->entry->id) |
||||
{ |
||||
eina_stringshare_del(name); |
||||
if (!ce->id) return; |
||||
eina_stringshare_replace(&ce->id, NULL); |
||||
} |
||||
else |
||||
eina_stringshare_replace(&ce->id, text); |
||||
list = ce->entry->transient ? qa_mod->cfd->cfdata->o_list_transient : qa_mod->cfd->cfdata->o_list_entry; |
||||
e_widget_ilist_clear(list); |
||||
_list_fill(qa_mod->cfd->cfdata, list, ce->entry->transient); |
||||
} |
||||
|
||||
static void |
||||
_list_delete(void *data __UNUSED__, void *list) |
||||
{ |
||||
Config_Entry *ce; |
||||
|
||||
ce = e_widget_ilist_selected_data_get(list); |
||||
if (!ce) return; |
||||
e_qa_entry_free(ce->entry); |
||||
} |
||||
|
||||
static void |
||||
_list_rename(void *data, void *list) |
||||
{ |
||||
E_Config_Dialog_Data *cfdata = data; |
||||
Config_Entry *ce; |
||||
|
||||
if (cfdata->ed) |
||||
{ |
||||
e_win_raise(cfdata->ed->dia->win); |
||||
return; |
||||
} |
||||
|
||||
ce = e_widget_ilist_selected_data_get(list); |
||||
if (!ce) return; |
||||
cfdata->ed = e_entry_dialog_show(_("Rename"), "edit-rename", _("Enter a unique name for this entry"), |
||||
ce->id ?: ce->entry->id, NULL, NULL, |
||||
_rename_ok, NULL, ce); |
||||
e_object_data_set(E_OBJECT(cfdata->ed), cfdata); |
||||
e_object_del_attach_func_set(E_OBJECT(cfdata->ed), _rename_del); |
||||
} |
||||
|
||||
static Evas_Object * |
||||
_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
Evas_Object *ob, *ol, *otb, *tab; |
||||
int w, h; |
||||
|
||||
tab = e_widget_table_add(evas, 0); |
||||
evas_object_name_set(tab, "dia_table"); |
||||
|
||||
otb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale); |
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
ol = e_widget_list_add(evas, 0, 0); |
||||
ob = e_widget_check_add(evas, _("Disable Warning Dialogs"), (int*)&(cfdata->dont_bug_me)); |
||||
e_widget_list_object_append(ol, ob, 1, 0, 0.5); |
||||
|
||||
e_widget_toolbook_page_append(otb, NULL, _("Behavior"), ol, 1, 1, 1, 1, 0.5, 0.5); |
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
ol = e_widget_table_add(evas, 0); |
||||
e_widget_table_freeze(ol); |
||||
|
||||
cfdata->o_list_entry = ob = e_widget_ilist_add(evas, 0, 0, &cfdata->entry); |
||||
evas_event_freeze(evas_object_evas_get(ob)); |
||||
edje_freeze(); |
||||
e_widget_ilist_freeze(ob); |
||||
|
||||
_list_fill(cfdata, ob, EINA_FALSE); |
||||
|
||||
e_widget_size_min_get(ob, &w, &h); |
||||
e_widget_size_min_set(ob, MIN(w, 200), MIN(h, 100)); |
||||
e_widget_ilist_go(ob); |
||||
e_widget_ilist_thaw(ob); |
||||
edje_thaw(); |
||||
evas_event_thaw(evas_object_evas_get(ol)); |
||||
|
||||
e_widget_table_object_append(ol, ob, 0, 0, 2, 1, 1, 1, 1, 1); |
||||
|
||||
ob = e_widget_button_add(evas, _("Rename"), "edit-rename", _list_rename, cfdata, cfdata->o_list_entry); |
||||
e_widget_table_object_append(ol, ob, 0, 1, 1, 1, 1, 1, 0, 0); |
||||
|
||||
ob = e_widget_button_add(evas, _("Delete"), "edit-delete", _list_delete, cfdata, cfdata->o_list_entry); |
||||
e_widget_table_object_append(ol, ob, 1, 1, 1, 1, 1, 1, 0, 0); |
||||
|
||||
|
||||
e_widget_table_thaw(ol); |
||||
|
||||
e_widget_toolbook_page_append(otb, NULL, _("Entries"), ol, 1, 1, 1, 1, 0.5, 0.5); |
||||
/////////////////////////////////////////////////////////////////
|
||||
ol = e_widget_table_add(evas, 0); |
||||
e_widget_table_freeze(ol); |
||||
|
||||
cfdata->o_list_transient = ob = e_widget_ilist_add(evas, 0, 0, &cfdata->entry); |
||||
evas_event_freeze(evas_object_evas_get(ob)); |
||||
edje_freeze(); |
||||
e_widget_ilist_freeze(ob); |
||||
|
||||
_list_fill(cfdata, ob, EINA_TRUE); |
||||
|
||||
e_widget_size_min_get(ob, &w, &h); |
||||
e_widget_size_min_set(ob, MIN(w, 200), MIN(h, 100)); |
||||
e_widget_ilist_go(ob); |
||||
e_widget_ilist_thaw(ob); |
||||
edje_thaw(); |
||||
evas_event_thaw(evas_object_evas_get(ol)); |
||||
|
||||
e_widget_table_object_append(ol, ob, 0, 0, 2, 1, 1, 1, 1, 1); |
||||
|
||||
ob = e_widget_button_add(evas, _("Rename"), "edit-rename", _list_rename, cfdata, cfdata->o_list_transient); |
||||
e_widget_table_object_append(ol, ob, 0, 1, 1, 1, 1, 1, 0, 0); |
||||
|
||||
ob = e_widget_button_add(evas, _("Delete"), "edit-delete", _list_delete, cfdata, cfdata->o_list_transient); |
||||
e_widget_table_object_append(ol, ob, 1, 1, 1, 1, 1, 1, 0, 0); |
||||
|
||||
e_widget_table_thaw(ol); |
||||
|
||||
e_widget_toolbook_page_append(otb, NULL, _("Transients"), ol, 1, 1, 1, 1, 0.5, 0.5); |
||||
/////////////////////////////////////////////////////////////////
|
||||
e_widget_toolbook_page_show(otb, 0); |
||||
|
||||
e_dialog_resizable_set(cfd->dia, 1); |
||||
|
||||
e_widget_table_object_append(tab, otb, 0, 0, 1, 1, 1, 1, 1, 1); |
||||
return tab; |
||||
} |
||||
|
||||
static Evas_Object * |
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
Evas_Object *ob, *ol, *otb, *tab; |
||||
|
||||
cfdata->o_list_entry = cfdata->o_list_transient = NULL; |
||||
|
||||
tab = e_widget_table_add(evas, 0); |
||||
evas_object_name_set(tab, "dia_table"); |
||||
|
||||
otb = e_widget_toolbook_add(evas, 48 * e_scale, 48 * e_scale); |
||||
|
||||
ol = e_widget_list_add(evas, 0, 0); |
||||
|
||||
ob = e_widget_check_add(evas, _("Hide Instead Of Raising"), &cfdata->hide_when_behind); |
||||
e_widget_list_object_append(ol, ob, 1, 0, 0.5); |
||||
|
||||
ob = e_widget_check_add(evas, _("Hide If Focus Lost"), &cfdata->autohide); |
||||
e_widget_list_object_append(ol, ob, 1, 0, 0.5); |
||||
|
||||
ob = e_widget_check_add(evas, _("Skip Taskbar"), &cfdata->skip_taskbar); |
||||
e_widget_list_object_append(ol, ob, 1, 0, 0.5); |
||||
|
||||
ob = e_widget_check_add(evas, _("Skip Pager"), &cfdata->skip_pager); |
||||
e_widget_list_object_append(ol, ob, 1, 0, 0.5); |
||||
|
||||
e_widget_toolbook_page_append(otb, NULL, _("Behavior"), ol, 1, 1, 1, 1, 0.5, 0.5); |
||||
|
||||
e_widget_toolbook_page_show(otb, 0); |
||||
|
||||
e_dialog_resizable_set(cfd->dia, 1); |
||||
|
||||
e_widget_table_object_append(tab, otb, 0, 0, 1, 1, 1, 1, 1, 1); |
||||
return tab; |
||||
} |
||||
|
||||
|
||||
static int |
||||
_advanced_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
Config_Entry *ce; |
||||
Eina_Bool entry_changed = EINA_FALSE, transient_changed = EINA_FALSE; |
||||
#define SET(X) qa_config->X = cfdata->X |
||||
|
||||
SET(dont_bug_me); |
||||
|
||||
EINA_INLIST_FOREACH(cfdata->entries, ce) |
||||
{ |
||||
if (!ce->id) continue; |
||||
if (!e_qa_entry_rename(ce->entry, ce->id)) |
||||
entry_changed = EINA_TRUE; |
||||
eina_stringshare_replace(&ce->id, NULL); |
||||
} |
||||
EINA_INLIST_FOREACH(cfdata->transient_entries, ce) |
||||
{ |
||||
if (!ce->id) continue; |
||||
if (!e_qa_entry_rename(ce->entry, ce->id)) |
||||
transient_changed = EINA_TRUE; |
||||
eina_stringshare_replace(&ce->id, NULL); |
||||
} |
||||
if (entry_changed) |
||||
{ |
||||
e_widget_ilist_clear(cfdata->o_list_entry); |
||||
_list_fill(qa_mod->cfd->cfdata, cfdata->o_list_entry, EINA_FALSE); |
||||
} |
||||
if (transient_changed) |
||||
{ |
||||
e_widget_ilist_clear(cfdata->o_list_transient); |
||||
_list_fill(qa_mod->cfd->cfdata, cfdata->o_list_transient, EINA_TRUE); |
||||
} |
||||
e_config_save_queue(); |
||||
return 1; |
||||
} |
||||
|
||||
static int |
||||
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) |
||||
{ |
||||
#define SET(X) qa_config->X = cfdata->X |
||||
SET(autohide); |
||||
SET(hide_when_behind); |
||||
SET(skip_taskbar); |
||||
SET(skip_pager); |
||||
e_qa_entries_update(); |
||||
e_config_save_queue(); |
||||
return 1; |
||||
} |
||||
|
||||
static void |
||||
_list_item_add(E_Quick_Access_Entry *entry) |
||||
{ |
||||
Evas_Object *list; |
||||
Config_Entry *ce = entry->cfg_entry; |
||||
|
||||
list = ce->entry->transient ? qa_mod->cfd->cfdata->o_list_transient : qa_mod->cfd->cfdata->o_list_entry; |
||||
if (!list) return; |
||||
e_widget_ilist_append(list, NULL, ce->id ?: ce->entry->id, _list_select, ce, ce->entry->id); |
||||
if (e_widget_ilist_selected_get(list) == -1) e_widget_ilist_selected_set(list, 0); |
||||
} |
||||
|
||||
static void |
||||
_list_item_delete(E_Quick_Access_Entry *entry) |
||||
{ |
||||
Eina_List *l, *ll; |
||||
E_Ilist_Item *ili; |
||||
Evas_Object *list; |
||||
unsigned int x = 0; |
||||
|
||||
list = entry->transient ? qa_mod->cfd->cfdata->o_list_transient : qa_mod->cfd->cfdata->o_list_entry; |
||||
if (!list) return; |
||||
l = e_widget_ilist_items_get(list); |
||||
EINA_LIST_FOREACH(l, ll, ili) |
||||
{ |
||||
if (e_widget_ilist_item_data_get(ili) == entry->cfg_entry) |
||||
{ |
||||
e_widget_ilist_remove_num(list, x); |
||||
break; |
||||
} |
||||
x++; |
||||
} |
||||
if (e_widget_ilist_selected_get(list) == -1) e_widget_ilist_selected_set(list, 0); |
||||
} |
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
E_Config_DD * |
||||
e_qa_config_dd_new(void) |
||||
{ |
||||
E_Config_DD *conf_edd, *entry_edd; |
||||
|
||||
conf_edd = E_CONFIG_DD_NEW("Quickaccess_Config", Config); |
||||
entry_edd = E_CONFIG_DD_NEW("E_Quick_Access_Entry", E_Quick_Access_Entry); |
||||
|
||||
#undef T |
||||
#undef D |
||||
#define T E_Quick_Access_Entry |
||||
#define D entry_edd |
||||
E_CONFIG_VAL(D, T, id, STR); |
||||
E_CONFIG_VAL(D, T, name, STR); |
||||
E_CONFIG_VAL(D, T, class, STR); |
||||
E_CONFIG_VAL(D, T, cmd, STR); |
||||
E_CONFIG_VAL(D, T, win, UINT); |
||||
E_CONFIG_VAL(D, T, config.autohide, UCHAR); |
||||
E_CONFIG_VAL(D, T, config.relaunch, UCHAR); |
||||
E_CONFIG_VAL(D, T, config.hidden, UCHAR); |
||||
E_CONFIG_VAL(D, T, transient, UCHAR); |
||||
#undef T |
||||
#undef D |
||||
#define T Config |
||||
#define D conf_edd |
||||
E_CONFIG_VAL(D, T, config_version, UINT); |
||||
E_CONFIG_LIST(D, T, entries, entry_edd); |
||||
E_CONFIG_LIST(D, T, transient_entries, entry_edd); |
||||
E_CONFIG_VAL(D, T, autohide, UCHAR); |
||||
E_CONFIG_VAL(D, T, hide_when_behind, UCHAR); |
||||
E_CONFIG_VAL(D, T, skip_taskbar, UCHAR); |
||||
E_CONFIG_VAL(D, T, skip_pager, UCHAR); |
||||
E_CONFIG_VAL(D, T, dont_bug_me, UCHAR); |
||||
return conf_edd; |
||||
} |
||||
|
||||
void * |
||||
e_qa_config_dd_free(E_Config_DD *conf_dd) |
||||
{ |
||||
free(conf_dd); |
||||
return NULL; |
||||
} |
||||
|
||||
void |
||||
e_qa_config_free(Config *conf) |
||||
{ |
||||
if (!conf) return; |
||||
E_FREE_LIST(conf->entries, e_qa_entry_free); |
||||
E_FREE_LIST(conf->transient_entries, e_qa_entry_free); |
||||
free(conf); |
||||
} |
||||
|
||||
Config * |
||||
e_qa_config_new(void) |
||||
{ |
||||
Config *conf; |
||||
|
||||
conf = E_NEW(Config, 1); |
||||
conf->skip_taskbar = 1; |
||||
conf->skip_pager = 1; |
||||
return conf; |
||||
} |
||||
|
||||
void |
||||
e_qa_config_entry_transient_convert(E_Quick_Access_Entry *entry) |
||||
{ |
||||
if (!entry) return; |
||||
if (!entry->cfg_entry) return; |
||||
_list_item_delete(entry); |
||||
entry->transient = !entry->transient; |
||||
_list_item_add(entry); |
||||
entry->transient = !entry->transient; |
||||
} |
||||
|
||||
void |
||||
e_qa_config_entry_free(E_Quick_Access_Entry *entry) |
||||
{ |
||||
if (!entry) return; |
||||
if (!entry->cfg_entry) return; |
||||
_list_item_delete(entry); |
||||
_config_entry_free(entry->cfg_entry); |
||||
entry->cfg_entry = NULL; |
||||
} |
||||
|
||||
void |
||||
e_qa_config_entry_add(E_Quick_Access_Entry *entry) |
||||
{ |
||||
Config_Entry *ce; |
||||
|
||||
if (!entry) return; |
||||
if (!qa_mod->cfd) return; |
||||
ce = _config_entry_new(entry); |
||||
if (entry->transient) |
||||
qa_mod->cfd->cfdata->transient_entries = eina_inlist_append(qa_mod->cfd->cfdata->transient_entries, EINA_INLIST_GET(ce)); |
||||
else |
||||
qa_mod->cfd->cfdata->entries = eina_inlist_append(qa_mod->cfd->cfdata->entries, EINA_INLIST_GET(ce)); |
||||
_list_item_add(entry); |
||||
} |
||||
|
||||
E_Config_Dialog * |
||||
e_int_config_qa_module(E_Container *con, const char *params __UNUSED__) |
||||
{ |
||||
E_Config_Dialog *cfd; |
||||
E_Config_Dialog_View *v; |
||||
char buf[PATH_MAX]; |
||||
|
||||
if (qa_mod->cfd) return NULL; |
||||
v = E_NEW(E_Config_Dialog_View, 1); |
||||
|
||||
v->create_cfdata = _create_data; |
||||
v->free_cfdata = _free_data; |
||||
v->basic.apply_cfdata = _basic_apply_data; |
||||
v->basic.create_widgets = _basic_create_widgets; |
||||
v->basic.check_changed = _basic_check_changed; |
||||
v->advanced.apply_cfdata = _advanced_apply_data; |
||||
v->advanced.create_widgets = _advanced_create_widgets; |
||||
v->advanced.check_changed = _advanced_check_changed; |
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-quickaccess.edj", e_module_dir_get(qa_mod->module)); |
||||
cfd = e_config_dialog_new(con, _("Quickaccess Settings"), |
||||
"E", "launcher/quickaccess", buf, 32, v, NULL); |
||||
return cfd; |
||||
} |
@ -0,0 +1,119 @@ |
||||
#include "e_mod_main.h" |
||||
|
||||
EINTERN int _e_quick_access_log_dom = -1; |
||||
static E_Config_DD *conf_edd = NULL; |
||||
Mod *qa_mod = NULL; |
||||
Config *qa_config = NULL; |
||||
|
||||
|
||||
/**
|
||||
* in priority order: |
||||
* |
||||
* @todo config (see e_mod_config.c) |
||||
* |
||||
* @todo custom border based on E_Quick_Access_Entry_Mode/E_Gadcon_Orient |
||||
* |
||||
* @todo show/hide effects: |
||||
* - fullscreen |
||||
* - centered |
||||
* - slide from top, bottom, left or right |
||||
* |
||||
* @todo match more than one, doing tabs (my idea is to do another |
||||
* tabbing module first, experiment with that, maybe use/reuse |
||||
* it here) |
||||
*/ |
||||
|
||||
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Quickaccess"}; |
||||
|
||||
static Eina_Bool |
||||
_e_mod_cb_config_timer(void *data) |
||||
{ |
||||
e_util_dialog_show(_("Quickaccess Settings Updated"), "%s", (char *)data); |
||||
return ECORE_CALLBACK_CANCEL; |
||||
} |
||||
|
||||
//////////////////////////////
|
||||
EAPI void * |
||||
e_modapi_init(E_Module *m) |
||||
{ |
||||
char buf[PATH_MAX]; |
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-quickaccess.edj", e_module_dir_get(m)); |
||||
e_configure_registry_category_add("launcher", 80, _("Launcher"), NULL, |
||||
"preferences-extensions"); |
||||
e_configure_registry_item_add("launcher/quickaccess", 1, _("Quickaccess"), NULL, |
||||
buf, e_int_config_qa_module); |
||||
|
||||
qa_mod = E_NEW(Mod, 1); |
||||
qa_mod->module = m; |
||||
m->data = qa_mod; |
||||
conf_edd = e_qa_config_dd_new(); |
||||
qa_config = e_config_domain_load("module.quickaccess", conf_edd); |
||||
if (qa_config) |
||||
{ |
||||
if ((qa_config->config_version >> 16) < MOD_CONFIG_FILE_EPOCH) |
||||
{ |
||||
e_qa_config_free(qa_config); |
||||
qa_config = NULL; |
||||
ecore_timer_add(1.0, _e_mod_cb_config_timer, |
||||
_("Quickaccess module settings data needed upgrading. Your old configuration<br>" |
||||
"has been wiped and a new set of defaults initialized. This<br>" |
||||
"will happen regularly during development, so don't report a<br>" |
||||
"bug. This means Quickaccess module needs new configuration<br>" |
||||
"data by default for usable functionality that your old<br>" |
||||
"configuration lacked. This new set of defaults will fix<br>" |
||||
"that by adding it in. You can re-configure things now to your<br>" |
||||
"liking. Sorry for the hiccup in your configuration.<br>")); |
||||
} |
||||
else if (qa_config->config_version > MOD_CONFIG_FILE_VERSION) |
||||
{ |
||||
e_qa_config_free(qa_config); |
||||
qa_config = NULL; |
||||
ecore_timer_add(1.0, _e_mod_cb_config_timer, |
||||
_("Your Quickaccess module configuration is NEWER than Quickaccess module version. This is very<br>" |
||||
"strange. This should not happen unless you downgraded<br>" |
||||
"the Quickaccess Module or copied the configuration from a place where<br>" |
||||
"a newer version of the Quickaccess Module was running. This is bad and<br>" |
||||
"as a precaution your configuration has been now restored to<br>" |
||||
"defaults. Sorry for the inconvenience.<br>")); |
||||
} |
||||
} |
||||
|
||||
if (!qa_config) qa_config = e_qa_config_new(); |
||||
qa_config->config_version = MOD_CONFIG_FILE_VERSION; |
||||
|
||||
_e_quick_access_log_dom = eina_log_domain_register("quickaccess", EINA_COLOR_ORANGE); |
||||
eina_log_domain_level_set("quickaccess", EINA_LOG_LEVEL_DBG); |
||||
|
||||
if (!e_qa_init()) |
||||
{ |
||||
eina_log_domain_unregister(_e_quick_access_log_dom); |
||||
_e_quick_access_log_dom = -1; |
||||
return NULL; |
||||
} |
||||
|
||||
return m; |
||||
} |
||||
|
||||
EAPI int |
||||
e_modapi_shutdown(E_Module *m __UNUSED__) |
||||
{ |
||||
e_qa_shutdown(); |
||||
|
||||
conf_edd = e_qa_config_dd_free(conf_edd); |
||||
eina_log_domain_unregister(_e_quick_access_log_dom); |
||||
_e_quick_access_log_dom = -1; |
||||
e_qa_config_free(qa_config); |
||||
free(qa_mod); |
||||
qa_config = NULL; |
||||
qa_mod = NULL; |
||||
return 1; |
||||
} |
||||
|
||||
EAPI int |
||||
e_modapi_save(E_Module *m __UNUSED__) |
||||
{ |
||||
e_config_domain_save("module.quickaccess", conf_edd, qa_config); |
||||
return 1; |
||||
} |
||||
|
@ -0,0 +1,93 @@ |
||||
#ifndef E_MOD_MAIN_H |
||||
#define E_MOD_MAIN_H |
||||
|
||||
#ifdef HAVE_CONFIG_H |
||||
#include "config.h" |
||||
#endif |
||||
|
||||
#include "e.h" |
||||
|
||||
/* Increment for Major Changes */ |
||||
#define MOD_CONFIG_FILE_EPOCH 0x0001 |
||||
/* Increment for Minor Changes (ie: user doesn't need a new config) */ |
||||
#define MOD_CONFIG_FILE_GENERATION 0x0001 |
||||
#define MOD_CONFIG_FILE_VERSION ((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION) |
||||
|
||||
typedef struct E_Quick_Access_Entry |
||||
{ |
||||
const char *id; /* entry identifier (config, actions...), stringshared */ |
||||
const char *name; /* icccm name, stringshared */ |
||||
const char *class; /* icccm class, stringshared */ |
||||
const char *cmd; /* stringshared */ |
||||
Ecore_X_Window win; /* current window */ |
||||
E_Border *border; /* associated border, if any */ |
||||
Ecore_Event_Handler *exe_handler; /* for catching exe delete */ |
||||
Ecore_Exe *exe; /* if executed cmd but still no border associated */ |
||||
E_Dialog *dia; // used for option handling
|
||||
void *cfg_entry; // created by config dialog
|
||||
|
||||
struct |
||||
{ |
||||
Eina_Bool autohide; // hide when focus lost
|
||||
Eina_Bool hide_when_behind; // hide when window is not focused instead of raising
|
||||
Eina_Bool hidden; // FIXME: used for tracking current state to restore on restart
|
||||
Eina_Bool relaunch; // reopen on exit
|
||||
} config; |
||||
Eina_Bool transient; |
||||
} E_Quick_Access_Entry; |
||||
|
||||
typedef struct Config |
||||
{ |
||||
unsigned int config_version; |
||||
Eina_List *entries; |
||||
Eina_List *transient_entries; |
||||
|
||||
Eina_Bool autohide; |
||||
Eina_Bool hide_when_behind; |
||||
Eina_Bool skip_taskbar; |
||||
Eina_Bool skip_pager; |
||||
Eina_Bool dont_bug_me; |
||||
} Config; |
||||
|
||||
typedef struct Mod |
||||
{ |
||||
E_Module *module; |
||||
E_Config_Dialog *cfd; |
||||
} Mod; |
||||
|
||||
extern Config *qa_config; |
||||
extern Mod *qa_mod; |
||||
extern int _e_quick_access_log_dom; |
||||
extern const char *_act_toggle; |
||||
#undef DBG |
||||
#undef INF |
||||
#undef WRN |
||||
#undef ERR |
||||
#undef CRIT |
||||
#define DBG(...) EINA_LOG_DOM_DBG(_e_quick_access_log_dom, __VA_ARGS__) |
||||
#define INF(...) EINA_LOG_DOM_INFO(_e_quick_access_log_dom, __VA_ARGS__) |
||||
#define WRN(...) EINA_LOG_DOM_WARN(_e_quick_access_log_dom, __VA_ARGS__) |
||||
#define ERR(...) EINA_LOG_DOM_ERR(_e_quick_access_log_dom, __VA_ARGS__) |
||||
#define CRIT(...) EINA_LOG_DOM_CRIT(_e_quick_access_log_dom, __VA_ARGS__) |
||||
|
||||
Eina_Bool e_qa_init(void); |
||||
void e_qa_shutdown(void); |
||||
void e_qa_entry_free(E_Quick_Access_Entry *entry); |
||||
E_Quick_Access_Entry *e_qa_entry_new(const char *id, Eina_Bool transient); |
||||
void e_qa_entries_update(void); |
||||
Eina_Bool e_qa_entry_rename(E_Quick_Access_Entry *entry, const char *name); |
||||
|
||||
E_Config_DD *e_qa_config_dd_new(void); |
||||
void e_qa_config_free(Config *conf); |
||||
Config *e_qa_config_new(void); |
||||
void *e_qa_config_dd_free(E_Config_DD *conf_dd); |
||||
void e_qa_config_entry_free(E_Quick_Access_Entry *entry); |
||||
void e_qa_config_entry_add(E_Quick_Access_Entry *entry); |
||||
void e_qa_config_entry_transient_convert(E_Quick_Access_Entry *entry); |
||||
E_Config_Dialog *e_int_config_qa_module(E_Container *con, const char *params __UNUSED__); |
||||
|
||||
char *e_qa_db_class_lookup(const char *class); |
||||
|
||||
void e_qa_entry_bindings_cleanup(E_Quick_Access_Entry *entry); |
||||
void e_qa_entry_bindings_rename(E_Quick_Access_Entry *entry, const char *name); |
||||
#endif |
@ -0,0 +1,955 @@ |
||||
#include "e_mod_main.h" |
||||
|
||||
EINTERN int _e_qa_log_dom = -1; |
||||
static E_Action *_e_qa_toggle = NULL; |
||||
static E_Action *_e_qa_add = NULL; |
||||
static E_Action *_e_qa_del = NULL; |
||||
static const char _e_qa_name[] = "Quickaccess"; |
||||
static const char _lbl_toggle[] = "Toggle Visibility"; |
||||
static const char _lbl_add[] = "Add Quickaccess For Current Window"; |
||||
static const char _lbl_del[] = "Remove Quickaccess From Current Window"; |
||||
const char *_act_toggle = NULL; |
||||
static const char _act_add[] = "qa_add"; |
||||
static const char _act_del[] = "qa_del"; |
||||
static E_Grab_Dialog *eg = NULL; |
||||
static Eina_List *_e_qa_border_hooks = NULL; |
||||
static Eina_List *_e_qa_event_handlers = NULL; |
||||
|
||||
static E_Border_Menu_Hook *border_hook = NULL; |
||||
|
||||
static Eina_Bool qa_running = EINA_FALSE; |
||||
|
||||
|
||||
static void _e_qa_bd_menu_add(void *data, E_Menu *m, E_Menu_Item *mi); |
||||
static void _e_qa_bd_menu_del(void *data, E_Menu *m, E_Menu_Item *mi); |
||||
static void _e_qa_entry_transient_convert(E_Quick_Access_Entry *entry); |
||||
|
||||
/**
|
||||
* in priority order: |
||||
* |
||||
* @todo config (see e_mod_config.c) |
||||
* |
||||
* @todo custom border based on E_Quick_Access_Entry_Mode/E_Gadcon_Orient |
||||
* |
||||
* @todo show/hide effects: |
||||
* - fullscreen |
||||
* - centered |
||||
* - slide from top, bottom, left or right |
||||
* |
||||
* @todo match more than one, doing tabs (my idea is to do another |
||||
* tabbing module first, experiment with that, maybe use/reuse |
||||
* it here) |
||||
*/ |
||||
|
||||
static void |
||||
_e_qa_entry_dia_hide(void *data) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
entry = e_object_data_get(data); |
||||
if (entry) entry->dia = NULL; |
||||
} |
||||
|
||||
/* note: id must be stringshared! */ |
||||
static E_Quick_Access_Entry * |
||||
_e_qa_entry_find(const char *id) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
const Eina_List *n; |
||||
EINA_LIST_FOREACH(qa_config->transient_entries, n, entry) |
||||
if (entry->id == id) |
||||
return entry; |
||||
EINA_LIST_FOREACH(qa_config->entries, n, entry) |
||||
if (entry->id == id) |
||||
return entry; |
||||
return NULL; |
||||
} |
||||
|
||||
static E_Quick_Access_Entry * |
||||
_e_qa_entry_find_exe(const Ecore_Exe *exe) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
const Eina_List *n; |
||||
EINA_LIST_FOREACH(qa_config->transient_entries, n, entry) |
||||
if (entry->exe == exe) |
||||
return entry; |
||||
EINA_LIST_FOREACH(qa_config->entries, n, entry) |
||||
if (entry->exe == exe) |
||||
return entry; |
||||
return NULL; |
||||
} |
||||
|
||||
static E_Quick_Access_Entry * |
||||
_e_qa_entry_find_border(const E_Border *bd) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
const Eina_List *n; |
||||
EINA_LIST_FOREACH(qa_config->transient_entries, n, entry) |
||||
if ((entry->win == bd->client.win) || (entry->border == bd)) |
||||
return entry; |
||||
EINA_LIST_FOREACH(qa_config->entries, n, entry) |
||||
if (entry->border == bd) |
||||
return entry; |
||||
return NULL; |
||||
} |
||||
|
||||
static E_Quick_Access_Entry * |
||||
_e_qa_entry_find_match_stringshared(const char *name, const char *class) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
const Eina_List *n; |
||||
EINA_LIST_FOREACH(qa_config->transient_entries, n, entry) |
||||
{ |
||||
if (entry->win) continue; |
||||
if (entry->class != class) continue; |
||||
/* no entry name matches all */ |
||||
if ((entry->name) && (entry->name != name)) continue; |
||||
|
||||
return entry; |
||||
} |
||||
EINA_LIST_FOREACH(qa_config->entries, n, entry) |
||||
{ |
||||
if (entry->win) continue; |
||||
if (entry->class != class) continue; |
||||
/* no entry name matches all */ |
||||
if ((entry->name) && (entry->name != name)) continue; |
||||
|
||||
return entry; |
||||
} |
||||
|
||||
return NULL; |
||||
} |
||||
|
||||
static E_Quick_Access_Entry * |
||||
_e_qa_entry_find_match(const E_Border *bd) |
||||
{ |
||||
const char *name, *class; |
||||
E_Quick_Access_Entry *entry; |
||||
|
||||
name = bd->client.icccm.name; |
||||
class = bd->client.icccm.class; |
||||
entry = _e_qa_entry_find_match_stringshared(name, class); |
||||
|
||||
return entry; |
||||
} |
||||
|
||||
static Eina_Bool |
||||
_e_qa_event_exe_del_cb(void *data, int type __UNUSED__, Ecore_Exe_Event_Del *ev) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
|
||||
if (!data) return ECORE_CALLBACK_RENEW; |
||||
|
||||
entry = _e_qa_entry_find_exe(ev->exe); |
||||
if (!entry) return ECORE_CALLBACK_RENEW; |
||||
entry->exe = NULL; /* not waiting/running anymore */ |
||||
if (entry->exe_handler) ecore_event_handler_del(entry->exe_handler); |
||||
entry->exe_handler = NULL; |
||||
|
||||
return ECORE_CALLBACK_RENEW; |
||||
} |
||||
|
||||
static void |
||||
_e_qa_entry_border_props_restore(E_Quick_Access_Entry *entry __UNUSED__, E_Border *bd) |
||||
{ |
||||
#undef SET |
||||
#define SET(X) \ |
||||
bd->X = 0 |
||||
|
||||
SET(lock_user_iconify); |
||||
SET(lock_client_iconify); |
||||
SET(lock_user_sticky); |
||||
SET(lock_client_sticky); |
||||
SET(user_skip_winlist); |
||||
SET(sticky); |
||||
#undef SET |
||||
|
||||
bd->client.netwm.state.skip_taskbar = 0; |
||||
bd->client.netwm.state.skip_pager = 0; |
||||
bd->changed = 1; |
||||
} |
||||
|
||||
static void |
||||
_e_qa_border_activate(E_Quick_Access_Entry *entry) |
||||
{ |
||||
entry->config.hidden = 0; |
||||
if (!entry->border) return; |
||||
e_border_raise(entry->border); |
||||
e_border_show(entry->border); |
||||
e_border_focus_set(entry->border, 1, 1); |
||||
|
||||
} |
||||
|
||||
static void |
||||
_e_qa_border_deactivate(E_Quick_Access_Entry *entry) |
||||
{ |
||||
entry->config.hidden = 1; |
||||
if (!entry->border) return; |
||||
e_border_hide(entry->border, 1); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_entry_border_props_apply(E_Quick_Access_Entry *entry) |
||||
{ |
||||
if (!entry->border) return; |
||||
|
||||
if (entry->config.autohide && (!entry->border->focused)) |
||||
_e_qa_border_deactivate(entry); |
||||
if (qa_config->skip_taskbar) |
||||
entry->border->client.netwm.state.skip_taskbar = 1; |
||||
if (qa_config->skip_pager) |
||||
entry->border->client.netwm.state.skip_pager = 1; |
||||
} |
||||
|
||||
static void |
||||
_e_qa_entry_border_associate(E_Quick_Access_Entry *entry, E_Border *bd) |
||||
{ |
||||
if (entry->exe) entry->exe = NULL; /* not waiting anymore */ |
||||
|
||||
if (!entry->border) |
||||
{ |
||||
entry->border = bd; |
||||
|
||||
#define SET(X) \ |
||||
bd->X = 1 |
||||
|
||||
SET(lock_user_iconify); |
||||
SET(lock_client_iconify); |
||||
SET(lock_user_sticky); |
||||
SET(lock_client_sticky); |
||||
SET(user_skip_winlist); |
||||
SET(sticky); |
||||
#undef SET |
||||
|
||||
//bd->client.e.state.centered = 1;
|
||||
} |
||||
/* FIXME: doesn't work, causes window to flicker on associate
|
||||
if (entry->config.hidden) |
||||
_e_qa_border_deactivate(entry); |
||||
else |
||||
*/ |
||||
_e_qa_entry_border_props_apply(entry); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_entry_relaunch_setup_continue(void *data, E_Dialog *dia) |
||||
{ |
||||
E_Quick_Access_Entry *entry = data; |
||||
char buf[8192]; |
||||
int i; |
||||
|
||||
if (dia) e_object_del(E_OBJECT(dia)); |
||||
entry->dia = NULL; |
||||
if (!entry->border->client.icccm.command.argv) |
||||
{ |
||||
e_util_dialog_show(_("Quickaccess Error"), _("Could not determine command for starting this application!")); |
||||
/* FIXME: e_entry_dialog? */ |
||||
return; |
||||
} |
||||
entry->config.relaunch = 1; |
||||
buf[0] = 0; |
||||
for (i = 0; i < entry->border->client.icccm.command.argc; i++) |
||||
{ |
||||
if ((sizeof(buf) - strlen(buf)) < |
||||
(strlen(entry->border->client.icccm.command.argv[i]) - 2)) |
||||
break; |
||||
strcat(buf, entry->border->client.icccm.command.argv[i]); |
||||
strcat(buf, " "); |
||||
} |
||||
entry->cmd = eina_stringshare_add(buf); |
||||
if (entry->transient) |
||||
_e_qa_entry_transient_convert(entry); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_entry_relaunch_setup_cancel(void *data, E_Dialog *dia) |
||||
{ |
||||
E_Quick_Access_Entry *entry = data; |
||||
|
||||
e_object_del(E_OBJECT(dia)); |
||||
entry->config.relaunch = 0; |
||||
} |
||||
|
||||
static void |
||||
_e_qa_entry_relaunch_setup_help(void *data, E_Dialog *dia) |
||||
{ |
||||
E_Quick_Access_Entry *entry = data; |
||||
char buf[8192]; |
||||
|
||||
e_object_del(E_OBJECT(dia)); |
||||
entry->dia = NULL; |
||||
entry->dia = dia = e_dialog_new(NULL, "E", "_quickaccess_cmd_help_dialog"); |
||||
|
||||
snprintf(buf, sizeof(buf), "%s<br>%s/e-module-quickaccess.edj<br>%s<br>" |
||||
"data.item: \"%s\" \"--OPT\";", _("The reopen option is meant to be used<br>" |
||||
"with terminal applications to create a persistent<br>" |
||||
"terminal which reopens when closed, generally seen<br>" |
||||
"in quake-style drop-down terminals.<br>" |
||||
"Either the selected application is not a terminal<br>" |
||||
"or the cmdline flag for changing the terminal's window<br>" |
||||
"name is not known. Feel free to submit a bug report if this<br>" |
||||
"is a terminal which can change its window name.<br>" |
||||
"Alternatively, you can add a data.item to"), |
||||
e_module_dir_get(qa_mod->module), |
||||
_("Like so:"), entry->class); |
||||
|
||||
e_dialog_title_set(dia, _("Quickaccess Help")); |
||||
e_dialog_icon_set(dia, "enlightenment", 64); |
||||
e_dialog_text_set(dia, buf); |
||||
e_dialog_button_add(dia, _("Cancel"), NULL, _e_qa_entry_relaunch_setup_cancel, entry); |
||||
e_win_centered_set(dia->win, 1); |
||||
e_dialog_show(dia); |
||||
e_object_data_set(E_OBJECT(dia), entry); |
||||
e_object_del_attach_func_set(E_OBJECT(dia), _e_qa_entry_dia_hide); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_entry_relaunch_setup(E_Quick_Access_Entry *entry) |
||||
{ |
||||
char *opt; |
||||
const char *name; |
||||
int i; |
||||
char buf[4096]; |
||||
Eina_List *l; |
||||
E_Quick_Access_Entry *e; |
||||
|
||||
if (entry->dia) |
||||
{ |
||||
e_win_raise(entry->dia->win); |
||||
return; |
||||
} |
||||
if ((!entry->class) || (!entry->name)) |
||||
{ |
||||
e_util_dialog_show(_("Quickaccess Error"), _("Cannot set relaunch for window without name and class!")); |
||||
entry->config.relaunch = 0; |
||||
return; |
||||
} |
||||
if (!strcmp(entry->name, "E")) |
||||
{ |
||||
/* can't set relaunch for internal E dialogs; safety #2 */ |
||||
e_util_dialog_show(_("Quickaccess Error"), _("Cannot set relaunch for internal E dialog!")); |
||||
entry->config.relaunch = 0; |
||||
return; |
||||
} |
||||
opt = e_qa_db_class_lookup(entry->class); |
||||
if ((!opt) || (!opt[0])) |
||||
{ |
||||
E_Dialog *dia; |
||||
|
||||
free(opt); |
||||
if (qa_config->dont_bug_me) |
||||
{ |
||||
_e_qa_entry_relaunch_setup_continue(entry, NULL); |
||||
return; |
||||
} |
||||
entry->dia = dia = e_dialog_new(NULL, "E", "_quickaccess_cmd_dialog"); |
||||
|
||||
snprintf(buf, sizeof(buf), "%s<br>%s<br>%s<br>%s<br>%s", _("The selected window created with name:"), |
||||
entry->name, _("and class:"), entry->class, _("could not be found in the quicklaunch app database<br" |
||||
"This means that either the app is unknown to us<br>" |
||||
"or it is not intended for use with this option.<br>" |
||||
"Please choose an action to take:")); |
||||
|
||||
e_dialog_title_set(dia, _("Quickaccess Error")); |
||||
e_dialog_icon_set(dia, "enlightenment", 64); |
||||
e_dialog_text_set(dia, buf); |
||||
e_dialog_button_add(dia, _("Continue"), NULL, _e_qa_entry_relaunch_setup_continue, entry); |
||||
e_dialog_button_add(dia, _("More Help"), NULL, _e_qa_entry_relaunch_setup_help, entry); |
||||
e_dialog_button_add(dia, _("Cancel"), NULL, _e_qa_entry_relaunch_setup_cancel, entry); |
||||
e_win_centered_set(dia->win, 1); |
||||
e_dialog_show(dia); |
||||
e_object_data_set(E_OBJECT(dia), entry); |
||||
e_object_del_attach_func_set(E_OBJECT(dia), _e_qa_entry_dia_hide); |
||||
entry->config.relaunch = 0; |
||||
return; |
||||
} |
||||
if (!entry->border->client.icccm.command.argv) |
||||
{ |
||||
free(opt); |
||||
e_util_dialog_show(_("Quickaccess Error"), _("Could not determine command for starting this application!")); |
||||
/* FIXME: e_entry_dialog? */ |
||||
return; |
||||
} |
||||
|
||||
buf[0] = 0; |
||||
for (i = 0; i < entry->border->client.icccm.command.argc; i++) |
||||
{ |
||||
if ((sizeof(buf) - strlen(buf)) < |
||||
(strlen(entry->border->client.icccm.command.argv[i]) - 2)) |
||||
break; |
||||
strcat(buf, entry->border->client.icccm.command.argv[i]); |
||||
strcat(buf, " "); |
||||
} |
||||
name = entry->name; |
||||
entry->name = eina_stringshare_printf("e-%s-%u", entry->name, entry->border->client.netwm.pid); |
||||
while (i) |
||||
{ |
||||
i = 0; |
||||
EINA_LIST_FOREACH(qa_config->entries, l, e) |
||||
{ |
||||
if (e == entry) continue; |
||||
if (e->class != entry->class) continue; |
||||
if ((e->name == entry->name) || (e->id == entry->name)) |
||||
{ |
||||
eina_stringshare_del(entry->name); |
||||
entry->name = eina_stringshare_printf("e-%s-%u%d", entry->name, entry->border->client.netwm.pid, i); |
||||
i++; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
eina_stringshare_del(name); |
||||
entry->cmd = eina_stringshare_printf("%s %s \"%s\"", buf, opt, entry->name); |
||||
entry->config.relaunch = 1; |
||||
if (entry->transient) |
||||
_e_qa_entry_transient_convert(entry); |
||||
free(opt); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_border_new(E_Quick_Access_Entry *entry) |
||||
{ |
||||
E_Exec_Instance *ei; |
||||
|
||||
if (!entry->cmd) return; |
||||
if (entry->exe) |
||||
{ |
||||
INF("already waiting '%s' to start for '%s' (name=%s, class=%s), " |
||||
"run request ignored.", entry->cmd, entry->id, entry->name, entry->class); |
||||
return; |
||||
} |
||||
|
||||
INF("start quick access '%s' (name=%s, class=%s), " |
||||
"run command '%s'", entry->id, entry->name, entry->class, entry->cmd); |
||||
|
||||
ei = e_exec(NULL, NULL, entry->cmd, NULL, NULL); |
||||
if ((!ei) || (!ei->exe)) |
||||
{ |
||||
ERR("could not execute '%s'", entry->cmd); |
||||
return; |
||||
} |
||||
|
||||
entry->exe = ei->exe; |
||||
entry->exe_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, (Ecore_Event_Handler_Cb)_e_qa_event_exe_del_cb, entry); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_del_cb(E_Object *obj __UNUSED__, const char *params __UNUSED__) |
||||
{ |
||||
_e_qa_bd_menu_del(_e_qa_entry_find_border(e_border_focused_get()), NULL, NULL); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_add_cb(E_Object *obj __UNUSED__, const char *params __UNUSED__) |
||||
{ |
||||
_e_qa_bd_menu_del(e_border_focused_get(), NULL, NULL); |
||||
} |
||||
|
||||
static void |
||||
_e_qa_toggle_cb(E_Object *obj __UNUSED__, const char *params) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
|
||||
if (!params) |
||||
{ |
||||
ERR("%s got params == NULL", _act_toggle); |
||||
return; |
||||
} |
||||
/* params is stringshared according to e_bindings.c */ |
||||
DBG("%s %s (stringshared=%p)", _act_toggle, params, params); |
||||
|
||||
entry = _e_qa_entry_find(params); |
||||
if (!entry) |
||||
{ |
||||
e_util_dialog_show(_("Quickaccess Error"), _("The requested Quickaccess entry does not exist!")); |
||||
return; |
||||
} |
||||
|
||||
if (entry->border) |
||||
{ |
||||
if (entry->border->focused || entry->config.hide_when_behind) |
||||
{ |
||||
_e_qa_border_deactivate(entry); |
||||
return; |
||||
} |
||||
|
||||
DBG("activate border for identifier '%s' (name=%s, class=%s).", |
||||
entry->id, entry->name, entry->class); |
||||
_e_qa_border_activate(entry); |
||||
} |
||||
else |
||||
{ |
||||
DBG("no border known for identifier '%s' (name=%s, class=%s).", |
||||
entry->id, entry->name, entry->class); |
||||
_e_qa_border_new(entry); |
||||
} |
||||
} |
||||
|
||||
static void |
||||
_e_qa_border_eval_pre_post_fetch_cb(void *data __UNUSED__, void *border) |
||||
{ |
||||
E_Border *bd = border; |
||||
E_Quick_Access_Entry *entry; |
||||
|
||||
if ((!bd->new_client) || (bd->internal)) return; |
||||
if ((!bd->client.icccm.class) || (!bd->client.icccm.class[0])) return; |
||||
if ((!bd->client.icccm.name) || (!bd->client.icccm.name[0])) return; |
||||
|
||||
entry = _e_qa_entry_find_match(bd); |
||||
if (!entry) return; |
||||
DBG("border=%p matches entry %s", bd, entry->id); |
||||
_e_qa_entry_border_associate(entry, bd); |
||||
} |
||||
|
||||
static Eina_Bool |
||||
_e_qa_event_border_focus_out_cb(void *data __UNUSED__, int type __UNUSED__, E_Event_Border_Focus_Out *ev) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
|
||||
entry = _e_qa_entry_find_border(ev->border); |
||||
if (entry && entry->config.autohide) _e_qa_border_deactivate(entry); |
||||
return ECORE_CALLBACK_RENEW; |
||||
} |
||||
|
||||
static Eina_Bool |
||||
_e_qa_event_module_init_end_cb(void *data __UNUSED__, int type __UNUSED__, void *ev __UNUSED__) |
||||
{ |
||||
Eina_List *l, *ll; |
||||
E_Quick_Access_Entry *entry; |
||||
unsigned int count; |
||||
/* assume that by now, e has successfully placed all windows */ |
||||
count = eina_list_count(qa_config->transient_entries); |
||||
EINA_LIST_FOREACH_SAFE(qa_config->transient_entries, l, ll, entry) |
||||
{ |
||||
if (entry->border) continue; |
||||
entry->border = e_border_find_by_client_window(entry->win); |
||||
if (entry->border) |
||||
{ |
||||
DBG("qa window for %u:transient:%s still exists; restoring", entry->win, entry->id); |
||||
_e_qa_entry_border_associate(entry, entry->border); |
||||
continue; |
||||
} |
||||
DBG("qa window for %u:transient:%s no longer exists; deleting", entry->win, entry->id); |
||||
e_qa_entry_free(entry); |
||||
} |
||||
if (count != eina_list_count(qa_config->transient_entries)) e_bindings_reset(); |
||||
qa_running = EINA_TRUE; |
||||
return ECORE_CALLBACK_RENEW; |
||||
} |
||||
|
||||
static Eina_Bool |
||||
_e_qa_event_border_remove_cb(void *data __UNUSED__, int type __UNUSED__, E_Event_Border_Remove *ev) |
||||
{ |
||||
E_Quick_Access_Entry *entry; |
||||
|
||||
entry = _e_qa_entry_find_border(ev->border); |
||||
if (!entry) return ECORE_CALLBACK_RENEW; |
||||
if (entry->transient) |
||||