1. The confirmation dialog on shelf delete is added. Somebody on IRC proposed to have it.

Also it is added on Key Binding deletion (see Key Bindings dialog).

Code duplicates were moved to a separate function e_confirm_dialog_show.

2. Two new events E_EVENT_BORDER_FOCUS_IN and E_EVENT_BORDER_FOCUS_OUT are added.


SVN revision: 22844
This commit is contained in:
sndev 2006-05-22 20:28:33 +00:00 committed by sndev
parent 775e1b460d
commit b8ed636f52
9 changed files with 253 additions and 44 deletions

View File

@ -154,7 +154,8 @@ e_widget_preview.h \
e_int_config_paths.h \
e_int_shelf_config.h \
e_int_config_shelf.h \
e_int_gadcon_config.h
e_int_gadcon_config.h \
e_confirm_dialog.h
enlightenment_src = \
e_user.c \
@ -290,6 +291,7 @@ e_int_config_paths.c \
e_int_shelf_config.c \
e_int_config_shelf.c \
e_int_gadcon_config.c \
e_confirm_dialog.c \
$(ENLIGHTENMENTHEADERS)
enlightenment_SOURCES = \

View File

@ -67,6 +67,8 @@ static void _e_border_event_border_zone_set_free(void *data, void *ev);
static void _e_border_event_border_desk_set_free(void *data, void *ev);
static void _e_border_event_border_stack_free(void *data, void *ev);
static void _e_border_event_border_icon_change_free(void *data, void *ev);
static void _e_border_event_border_focus_in_free(void *data, void *ev);
static void _e_border_event_border_focus_out_free(void *data, void *ev);
static void _e_border_event_border_resize_free(void *data, void *ev);
static void _e_border_event_border_move_free(void *data, void *ev);
static void _e_border_event_border_show_free(void *data, void *ev);
@ -127,6 +129,8 @@ EAPI int E_EVENT_BORDER_STICK = 0;
EAPI int E_EVENT_BORDER_UNSTICK = 0;
EAPI int E_EVENT_BORDER_STACK = 0;
EAPI int E_EVENT_BORDER_ICON_CHANGE = 0;
EAPI int E_EVENT_BORDER_FOCUS_IN = 0;
EAPI int E_EVENT_BORDER_FOCUS_OUT = 0;
#define GRAV_SET(bd, grav) \
ecore_x_window_gravity_set(bd->bg_win, grav); \
@ -177,6 +181,8 @@ e_border_init(void)
E_EVENT_BORDER_UNSTICK = ecore_event_type_new();
E_EVENT_BORDER_STACK = ecore_event_type_new();
E_EVENT_BORDER_ICON_CHANGE = ecore_event_type_new();
E_EVENT_BORDER_FOCUS_IN = ecore_event_type_new();
E_EVENT_BORDER_FOCUS_OUT = ecore_event_type_new();
return 1;
}
@ -1280,13 +1286,31 @@ e_border_focus_set(E_Border *bd, int focus, int set)
#endif
if (bd->focused)
{
E_Event_Border_Focus_In *ev;
focused = bd;
//printf("set focused to %p\n", focused);
ev = calloc(1, sizeof(E_Event_Border_Focus_In));
ev->border = bd;
e_object_ref(E_OBJECT(bd));
ecore_event_add(E_EVENT_BORDER_FOCUS_IN, ev,
_e_border_event_border_focus_in_free, NULL);
}
else if ((!bd->focused) && (focused == bd))
{
E_Event_Border_Focus_Out *ev;
focused = NULL;
//printf("set focused to %p\n", focused);
ev = calloc(1, sizeof(E_Event_Border_Focus_Out));
ev->border = bd;
e_object_ref(E_OBJECT(bd));
ecore_event_add(E_EVENT_BORDER_FOCUS_OUT, ev,
_e_border_event_border_focus_out_free, NULL);
}
}
@ -6311,6 +6335,26 @@ _e_border_event_border_icon_change_free(void *data, void *ev)
free(e);
}
static void
_e_border_event_border_focus_in_free(void *data, void *ev)
{
E_Event_Border_Focus_In *e;
e = ev;
e_object_unref(E_OBJECT(e->border));
free(e);
}
static void
_e_border_event_border_focus_out_free(void *data, void *ev)
{
E_Event_Border_Focus_Out *e;
e = ev;
e_object_unref(E_OBJECT(e->border));
free(e);
}
static void
_e_border_zone_update(E_Border *bd)
{

View File

@ -84,6 +84,8 @@ typedef struct _E_Event_Border_Zone_Set E_Event_Border_Zone_Set;
typedef struct _E_Event_Border_Desk_Set E_Event_Border_Desk_Set;
typedef struct _E_Event_Border_Stack E_Event_Border_Stack;
typedef struct _E_Event_Border_Icon_Change E_Event_Border_Icon_Change;
typedef struct _E_Event_Border_Focus_In E_Event_Border_Focus_In;
typedef struct _E_Event_Border_Focus_Out E_Event_Border_Focus_Out;
#else
#ifndef E_BORDER_H
@ -484,6 +486,16 @@ struct _E_Event_Border_Icon_Change
E_Border *border;
};
struct _E_Event_Border_Focus_In
{
E_Border *border;
};
struct _E_Event_Border_Focus_Out
{
E_Border *border;
};
EAPI int e_border_init(void);
EAPI int e_border_shutdown(void);
@ -573,6 +585,8 @@ extern EAPI int E_EVENT_BORDER_ZONE_SET;
extern EAPI int E_EVENT_BORDER_DESK_SET;
extern EAPI int E_EVENT_BORDER_STACK;
extern EAPI int E_EVENT_BORDER_ICON_CHANGE;
extern EAPI int E_EVENT_BORDER_FOCUS_IN;
extern EAPI int E_EVENT_BORDER_FOCUS_OUT;
#endif
#endif

View File

@ -0,0 +1,99 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
typedef struct _E_Confirm_Dialog E_Confirm_Dialog;
struct _E_Confirm_Dialog
{
struct
{
void *data;
void (*func)(void *data);
} yes;
struct
{
void *data;
void (*func)(void *data);
} no;
E_Dialog *dia;
};
/******** private function definitions **********/
static void _e_confirm_dialog_delete(E_Win *win);
static void _e_confirm_dialog_yes(void *data, E_Dialog *dia);
static void _e_confirm_dialog_no(void *data, E_Dialog *dia);
/********** externally accesible functions ****************/
EAPI void
e_confirm_dialog_show(const char *title, const char *icon, const char *text,
const char *button_text, const char *button2_text, void (*func)(void *data),
void (*func2)(void *data), void *data, void *data2)
{
E_Confirm_Dialog *cd;
E_Dialog *dia;
cd = E_NEW(E_Confirm_Dialog, 1);
cd->yes.func = func;
cd->yes.data = data;
cd->no.func = func2;
cd->no.data = data2;
dia = e_dialog_new(e_container_current_get(e_manager_current_get()));
if (!dia)
{
E_FREE(cd);
return;
}
dia->data = cd;
cd->dia = dia;
e_win_delete_callback_set(dia->win, _e_confirm_dialog_delete);
if (title) e_dialog_title_set(dia, title);
if (icon) e_dialog_icon_set(dia, icon, 64);
if (text) e_dialog_text_set(dia, text);
e_dialog_button_add(dia, !button_text ? _("Yes") : button_text, NULL, _e_confirm_dialog_yes, cd);
e_dialog_button_add(dia, !button2_text ? _("No") : button2_text, NULL, _e_confirm_dialog_no, cd);
e_dialog_button_focus_num(dia, 1);
e_win_centered_set(dia->win, 1);
e_dialog_show(dia);
}
/********* private function bodies ************/
static void
_e_confirm_dialog_yes(void *data, E_Dialog *dia)
{
E_Confirm_Dialog *cd;
cd = data;
if (cd->yes.func) cd->yes.func(cd->yes.data);
_e_confirm_dialog_delete(cd->dia->win);
}
static void
_e_confirm_dialog_no(void *data, E_Dialog *dia)
{
E_Confirm_Dialog *cd;
cd = data;
if (cd->no.func) cd->no.func(cd->no.data);
_e_confirm_dialog_delete(cd->dia->win);
}
static void
_e_confirm_dialog_delete(E_Win *win)
{
E_Dialog *dia;
E_Confirm_Dialog *cd;
dia = win->data;
cd = dia->data;
e_object_del(E_OBJECT(dia));
free(cd);
}

View File

@ -0,0 +1,24 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEF
#else
#ifndef E_CONFIRM_DIALOG_H
#define E_CONFIRM_DIALOG_H
/*
* @title - dialog title
* @icon - dialog icon
* @text - the text show in the dialog
* @button_text - "yes" button text
* @button2_text - "no" button text
* func - the function is called if yes is pressed
* func2 - the function is called if no is pressed
* data - the pointer passed to func
* data2 - the pointer passed to func2
*/
EAPI void e_confirm_dialog_show(const char *title, const char *icon, const char *text, const char *button_text, const char *button2_text, void (*func)(void *data), void (*func2)(void *data), void *data, void *data2);
#endif
#endif

View File

@ -135,3 +135,4 @@
#include "e_int_shelf_config.h"
#include "e_int_config_shelf.h"
#include "e_int_gadcon_config.h"
#include "e_confirm_dialog.h"

View File

@ -34,7 +34,7 @@ static void _e_keybinding_binding_ilist_cb_change(void *data, Evas_Object *o
static void _e_keybinding_default_keybinding_settings(E_Config_Dialog_Data *cfdata);
static void _e_keybinding_keybind_cb_del_keybinding(void *data, void *data2);
static void _e_keybinding_keybind_delete_keybinding(E_Config_Dialog_Data *cfdata);
//static void _e_keybinding_keybind_delete_keybinding(E_Config_Dialog_Data *cfdata);
static void _e_keybinding_keybind_cb_add_keybinding(void *data, void *data2);
@ -105,6 +105,8 @@ struct _E_Config_Dialog_Data
Evas_Object *bind_context[E_BINDING_CONTEXT_NUMBER];
Evas_Object *key_action;
Evas_Object *key_params;
E_Dialog *confirm_dialog;
} gui;
struct {
@ -1035,15 +1037,24 @@ _e_keybinding_update_action_param_entries(E_Config_Dialog_Data *cfdata)
}
static void
_e_keybinding_keybind_cb_del_keybinding(void *data, void *data2)
_e_keybinding_cb_confirm_dialog_yes(void *data)
{
E_Config_Dialog_Data *cfdata = data;
E_Config_Binding_Key *eb;
E_Config_Dialog_Data *cfdata;
if (!cfdata) return;
if (!cfdata->current_act && cfdata->current_act_selector < 0)
return;
if (!(cfdata = data))
if ((!cfdata->current_act) && (cfdata->current_act_selector < 0)) return;
_e_keybinding_keybind_delete_keybinding(cfdata);
eb = evas_list_nth(cfdata->current_act->key_bindings, cfdata->current_act_selector);
cfdata->current_act->key_bindings = evas_list_remove(cfdata->current_act->key_bindings, eb);
if (eb->key) evas_stringshare_del(eb->key);
if (eb->action) evas_stringshare_del(eb->action);
if (eb->params) evas_stringshare_del(eb->params);
E_FREE(eb);
if (cfdata->current_act_selector >= evas_list_count(cfdata->current_act->key_bindings))
cfdata->current_act_selector = evas_list_count(cfdata->current_act->key_bindings) - 1;
_e_keybinding_update_binding_list(cfdata);
e_widget_ilist_go(cfdata->gui.binding_ilist);
@ -1060,30 +1071,23 @@ _e_keybinding_keybind_cb_del_keybinding(void *data, void *data2)
//cfdata->changed = 1;
}
static void
_e_keybinding_keybind_delete_keybinding(E_Config_Dialog_Data *cfdata)
_e_keybinding_keybind_cb_del_keybinding(void *data, void *data2)
{
E_Config_Binding_Key *eb;
char buf[4096];
E_Config_Dialog_Data *cfdata = data;
if (!cfdata) return;
if (!cfdata->current_act && cfdata->current_act_selector < 0)
return;
eb = evas_list_nth(cfdata->current_act->key_bindings, cfdata->current_act_selector);
cfdata->current_act->key_bindings = evas_list_remove(cfdata->current_act->key_bindings, eb);
snprintf(buf, sizeof(buf), _("You requested to delte \"%s\" keybinding.<br>"
"<br>"
"Are you sure you want to delete it?"),
e_widget_ilist_selected_label_get(cfdata->gui.binding_ilist));
if (!evas_list_count(cfdata->current_act->key_bindings))
{
evas_list_free(cfdata->current_act->key_bindings);
cfdata->current_act->key_bindings = NULL;
}
if (eb->key) evas_stringshare_del(eb->key);
if (eb->action) evas_stringshare_del(eb->action);
if (eb->params) evas_stringshare_del(eb->params);
E_FREE(eb);
e_confirm_dialog_show(_("Delete?"), "enlightenment/exit", buf, NULL, NULL,
_e_keybinding_cb_confirm_dialog_yes, NULL, cfdata, NULL);
if (cfdata->current_act_selector >= evas_list_count(cfdata->current_act->key_bindings))
cfdata->current_act_selector = evas_list_count(cfdata->current_act->key_bindings) - 1;
}
static void
_e_keybinding_update_binding_ilist_cur_selection_icon(E_Config_Dialog_Data *cfdata)

View File

@ -144,7 +144,7 @@ _cb_add(void *data, void *data2)
e_widget_ilist_selected_set(cfdata->ilist, e_widget_ilist_count(cfdata->ilist) - 1);
}
static void
/*static void
_cb_confirm_dialog_no(void *data, E_Dialog *dia)
{
E_Config_Dialog_Data *cfdata;
@ -185,8 +185,31 @@ _cb_confirm_dialog_delete(E_Win *win)
E_Config_Dialog_Data *cfdata;
cfdata = ((E_Dialog *)win->data)->data;
_cb_confirm_dialog_no(cfdata, cfdata->confirm_dialog);
}
}*/
static void
_cb_confirm_dialog_yes(void *data)
{
E_Shelf *es;
E_Config_Shelf *cfg;
E_Config_Dialog_Data *cfdata;
cfdata = data;
es = evas_list_nth(e_shelf_list(), e_widget_ilist_selected_get(cfdata->ilist));
if (es)
{
cfg = es->cfg;
e_object_del(E_OBJECT(es));
e_config->shelves = evas_list_remove(e_config->shelves, cfg);
if (cfg->name) evas_stringshare_del(cfg->name);
if (cfg->style) evas_stringshare_del(cfg->style);
E_FREE(cfg);
e_config_save_queue();
_ilist_fill(cfdata);
}
}
static void
_cb_del(void *data, void *data2)
{
@ -194,26 +217,13 @@ _cb_del(void *data, void *data2)
E_Config_Dialog_Data *cfdata;
cfdata = data;
if (cfdata->confirm_dialog) e_object_del(E_OBJECT(cfdata->confirm_dialog));
cfdata->confirm_dialog = e_dialog_new(e_container_current_get(e_manager_current_get()));
if (!cfdata->confirm_dialog) return;
cfdata->confirm_dialog->data = cfdata;
e_win_delete_callback_set(cfdata->confirm_dialog->win, _cb_confirm_dialog_delete);
e_dialog_title_set(cfdata->confirm_dialog, _("Are you sure you want to delete this shelf?"));
snprintf(buf, sizeof(buf), _("You requested to delete \"%s\".<br>"
"<br>"
"Are you sure you want to delete this shelf?"),
e_widget_ilist_selected_label_get(cfdata->ilist));
e_dialog_text_set(cfdata->confirm_dialog, buf);
e_dialog_icon_set(cfdata->confirm_dialog, "enlightenment/exit", 64);
e_dialog_button_add(cfdata->confirm_dialog, _("Yes"), NULL, _cb_confirm_dialog_yes, cfdata);
e_dialog_button_add(cfdata->confirm_dialog, _("No"), NULL, _cb_confirm_dialog_no, cfdata);
e_dialog_button_focus_num(cfdata->confirm_dialog, 1);
e_win_centered_set(cfdata->confirm_dialog->win, 1);
e_dialog_show(cfdata->confirm_dialog);
e_confirm_dialog_show(_("Are you sure you want to delete this shelf?"), "enlightenment/exit",
buf, NULL, NULL, _cb_confirm_dialog_yes, NULL, cfdata, NULL);
}
static void

View File

@ -735,11 +735,11 @@ _e_shelf_cb_menu_contents(void *data, E_Menu *m, E_Menu_Item *mi)
}
static void
_e_shelf_cb_menu_delete(void *data, E_Menu *m, E_Menu_Item *mi)
_e_shelf_cb_confirm_dialog_yes(void *data)
{
E_Config_Shelf *cfg;
E_Shelf *es;
es = data;
cfg = es->cfg;
e_object_del(E_OBJECT(es));
@ -751,6 +751,17 @@ _e_shelf_cb_menu_delete(void *data, E_Menu *m, E_Menu_Item *mi)
e_config_save_queue();
}
static void
_e_shelf_cb_menu_delete(void *data, E_Menu *m, E_Menu_Item *mi)
{
e_confirm_dialog_show(_("Are you sure you want to delete this shelf?"), "enlightenment/exit",
_("You requested to delete this shelf.<br>"
"<br>"
"Are you sure you want to delete it?"), NULL, NULL,
_e_shelf_cb_confirm_dialog_yes, NULL, data, NULL);
}
static void
_e_shelf_cb_menu_post(void *data, E_Menu *m)
{