[Pkg-e-commits] [SCM] Enlightenment DR17 toolkit based (based on the EFL) branch, upstream-vcs, updated. 447de88121d145a078f1754a0cfebb704d363821

jethomas jethomas at alioth.debian.org
Sat Jun 7 18:34:18 UTC 2008


The following commit has been merged in the upstream-vcs branch:
commit 738f960699671935e700d4a00d7f9c7dad0f651d
Author: jethomas <jethomas>
Date:   Sat Apr 26 21:07:35 2008 +0000

    Fix bug 391 and render bug 203 invalid.  Remove seperate highlight widgets from use in ewl, and add event data for EWL_CALLBACK_STATE_CHANGED.

diff --git a/data/themes/e17/e17.edc b/data/themes/e17/e17.edc
index cdce9b6..ff7b5d8 100644
--- a/data/themes/e17/e17.edc
+++ b/data/themes/e17/e17.edc
@@ -149,6 +149,8 @@ data
 	item: "/tree_header/button/group" "ewl/tree/header/button";
 	item: "/tree_header/grabber/vertical/group" "ewl/separator/vertical";
 	item: "/tree_header/header/button/group" "ewl/tree/header/button";
+	
+	item: "/cell/group" "ewl/tree/cell";
 
 	item: "/row/group" "ewl/row";
 	item: "/expansion/group" "ewl/tree/expansion";
diff --git a/data/themes/e17/groups/tree.edc b/data/themes/e17/groups/tree.edc
index e1efd24..8e35549 100644
--- a/data/themes/e17/groups/tree.edc
+++ b/data/themes/e17/groups/tree.edc
@@ -340,7 +340,6 @@ group
 			description
 			{
 				state: "default" 0.0;
-				visible: 0;
 				rel1 
 				{
 					offset: -4 -4;
@@ -349,13 +348,13 @@ group
 				{
 					offset: 3 3;
 				}
-				color: 245 205 109 102;
+				color: 245 205 109 0;
 			}
 			description
 			{
 				state: "selected" 0.0;
 				inherit: "default" 0.0;
-				visible: 1;
+				color: 245 205 109 102;
 			}
 		}
 	}
@@ -382,7 +381,7 @@ group
 		program
 		{
 			name: "select";
-			signal: "tree-selected";
+			signal: "selected";
 			source: "*";
 			action: STATE_SET "selected" 0.0;
 			transition: DECELERATE 0.25;
@@ -391,7 +390,7 @@ group
 		program
 		{
 			name: "un-select";
-			signal: "tree-deselect";
+			signal: "deselect";
 			source: "*";
 			action: STATE_SET "default" 0.0;
 			transition: ACCELERATE 0.01;
@@ -418,3 +417,59 @@ group
 	}
 }
 
+group
+{
+	name: "ewl/tree/cell";
+
+	parts
+	{
+		part
+		{
+			name: "selected";
+			mouse_events: 0;
+			type: RECT;
+			description
+			{
+				state: "default" 0.0;
+				rel1 
+				{
+					offset: -4 -4;
+				}
+				rel2
+				{
+					offset: 3 3;
+				}
+				color: 245 205 109 0;
+			}
+			description
+			{
+				state: "selected" 0.0;
+				inherit: "default" 0.0;
+				color: 245 205 109 102;
+			}
+		}
+	}
+	programs
+	{
+		program
+		{
+			name: "select";
+			signal: "selected";
+			source: "*";
+			action: STATE_SET "selected" 0.0;
+			transition: DECELERATE 0.25;
+			target: "selected";
+		}
+		program
+		{
+			name: "un-select";
+			signal: "deselect";
+			source: "*";
+			action: STATE_SET "default" 0.0;
+			transition: ACCELERATE 0.01;
+			target: "selected";
+		}
+	}
+}
+
+
diff --git a/src/bin/tests/filedialog/ewl_filedialog_test.c b/src/bin/tests/filedialog/ewl_filedialog_test.c
index 82e8c97..2c9d93d 100644
--- a/src/bin/tests/filedialog/ewl_filedialog_test.c
+++ b/src/bin/tests/filedialog/ewl_filedialog_test.c
@@ -145,5 +145,6 @@ fd_append(void *value, void *data)
 	ewl_label_text_set(EWL_LABEL(o), file);
 	ewl_container_child_append(EWL_CONTAINER(list), o);
 	ewl_widget_show(o);
+	printf("%s\n", file);
 }
 
diff --git a/src/bin/tests/list/ewl_list_test.c b/src/bin/tests/list/ewl_list_test.c
index 03862dd..a9bce7f 100644
--- a/src/bin/tests/list/ewl_list_test.c
+++ b/src/bin/tests/list/ewl_list_test.c
@@ -55,8 +55,6 @@ create_test(Ewl_Container *box)
 	Ewl_Widget *list, *o;
 	Ewl_Model *model;
 	Ewl_View *view;
-	char *strs[] = {"foo", "bar", "baz", "bobby", NULL};
-	int i;
 	void *data;
 
 	/* create a list using an ecore_list of strings of labels */
@@ -129,29 +127,6 @@ create_test(Ewl_Container *box)
 	ewl_widget_show(list);
 
 
-	/* create a list by appending label widgets. This dosne't use the
-	 * MVC controls just allows you to use the container functions */
-	o = ewl_border_new();
-	ewl_border_label_set(EWL_BORDER(o), "Container Functions");
-	ewl_container_child_append(EWL_CONTAINER(box), o);
-	ewl_widget_show(o);
-
-	list = ewl_list_new();
-	ewl_container_child_append(EWL_CONTAINER(o), list);
-	ewl_mvc_selection_mode_set(EWL_MVC(list), EWL_SELECTION_MODE_NONE);
-	ewl_callback_append(list, EWL_CALLBACK_VALUE_CHANGED,
-					list_cb_select_none, NULL);
-	ewl_widget_show(list);
-
-	for (i = 0; strs[i]; i++)
-	{
-		o = ewl_label_new();
-		ewl_label_text_set(EWL_LABEL(o), strs[i]);
-		ewl_widget_show(o);
-
-		ewl_container_child_append(EWL_CONTAINER(list), o);
-	}
-
 	return 1;
 }
 
diff --git a/src/lib/ewl_cell.c b/src/lib/ewl_cell.c
index 8c0fb87..323e49a 100644
--- a/src/lib/ewl_cell.c
+++ b/src/lib/ewl_cell.c
@@ -5,6 +5,8 @@
 #include "ewl_private.h"
 #include "ewl_debug.h"
 
+static void ewl_cell_cb_state_changed(Ewl_Widget *w, void *ev, void *data);
+
 /**
  * @return Returns a newly allocated cell on success, NULL on failure.
  * @brief Allocate and initialize a new cell
@@ -155,3 +157,79 @@ ewl_cell_cb_child_resize(Ewl_Container *c, Ewl_Widget *w,
 	DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/**
+ * @internal
+ * @param cell: The cell to work with
+ * @return: Returns no value
+ * @brief Adds the callback to send state changes on to the cell's children
+ */
+void
+ewl_cell_state_change_cb_add(Ewl_Cell *cell)
+{
+	DENTER_FUNCTION(DLEVEL_STABLE);
+	DCHECK_PARAM_PTR(cell);
+	DCHECK_TYPE(cell, EWL_CELL_TYPE);
+
+	ewl_callback_append(EWL_WIDGET(cell), EWL_CALLBACK_STATE_CHANGED,
+			ewl_cell_cb_state_changed, NULL);
+
+	DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param cell: The cell to work with
+ * @return: Returns no value
+ * @brief Removes the callback to send state changes on to the cell's children
+ */
+void
+ewl_cell_state_change_cb_del(Ewl_Cell *cell)
+{
+	DENTER_FUNCTION(DLEVEL_STABLE);
+	DCHECK_PARAM_PTR(cell);
+	DCHECK_TYPE(cell, EWL_CELL_TYPE);
+
+	ewl_callback_del(EWL_WIDGET(cell), EWL_CALLBACK_STATE_CHANGED,
+			ewl_cell_cb_state_changed);
+
+	DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @internal
+ * @param w: The widget to work with
+ * @ev: The Ewl_Event_State_Change struct
+ * @data: UNUSED
+ * @return Returns no value
+ * @brief Sends the state on to the cell's children
+ */
+void
+ewl_cell_cb_state_changed(Ewl_Widget *w, void *ev, void *data __UNUSED__)
+{
+	Ewl_Widget *o;
+	Ewl_Event_State_Change *e;
+	const char *send_state;
+
+	DENTER_FUNCTION(DLEVEL_STABLE);
+	DCHECK_PARAM_PTR(w);
+	DCHECK_PARAM_PTR(ev);
+	DCHECK_TYPE(w, EWL_CELL_TYPE);
+
+	e = EWL_EVENT_STATE_CHANGE(ev);
+
+	/* Only want this for selected signals */
+	if (!strcmp(e->state, "selected"))
+		send_state = "parent,selected";
+	else if (!strcmp(e->state, "deselect"))
+		send_state = "parent,deselect";
+	else if ((!strcmp(e->state, "parent,selected")) ||
+			(!strcmp(e->state, "parent,deselect")))
+		send_state = e->state;
+	else
+		DRETURN(DLEVEL_STABLE);
+
+	ewl_container_child_iterate_begin(EWL_CONTAINER(w));
+	while ((o = ewl_container_child_next(EWL_CONTAINER(w))))
+		ewl_widget_state_set(o, send_state, e->flag);
+
+	DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
diff --git a/src/lib/ewl_cell.h b/src/lib/ewl_cell.h
index ecb3a43..048c4f7 100644
--- a/src/lib/ewl_cell.h
+++ b/src/lib/ewl_cell.h
@@ -52,6 +52,8 @@ struct Ewl_Cell
 
 Ewl_Widget 	*ewl_cell_new(void);
 int 		 ewl_cell_init(Ewl_Cell *cell);
+void		 ewl_cell_state_change_cb_add(Ewl_Cell *cell);
+void		 ewl_cell_state_change_cb_del(Ewl_Cell *cell);
 
 /*
  * Internally used callbacks, override at your own risk.
diff --git a/src/lib/ewl_events.h b/src/lib/ewl_events.h
index eb4455c..6ce7aa4 100644
--- a/src/lib/ewl_events.h
+++ b/src/lib/ewl_events.h
@@ -352,6 +352,26 @@ struct Ewl_Event_Action_Response
 	unsigned int response; /**< The response ID */
 };
 
+/**
+ * @def EWL_EVENT_STATE_CHANGE(e)
+ * Typedefs a pointer to an Ewl_Event_State_Change pointer
+ */
+#define EWL_EVENT_STATE_CHANGE(e) ((Ewl_Event_State_Change*)(e))
+
+/**
+ * The Ewl_Event_State_Change type
+ */
+typedef struct Ewl_Event_State_Change Ewl_Event_State_Change;
+
+/**
+ * @brief Provides information about the changed state
+ */
+struct Ewl_Event_State_Change
+{
+	const char *state;
+	Ewl_State_Type flag;
+};
+
 unsigned int 	ewl_ev_modifiers_get(void);
 void 		ewl_ev_modifiers_set(unsigned int modifiers);
 
diff --git a/src/lib/ewl_filelist.c b/src/lib/ewl_filelist.c
index 552be93..4feca79 100644
--- a/src/lib/ewl_filelist.c
+++ b/src/lib/ewl_filelist.c
@@ -118,6 +118,8 @@ ewl_filelist_setup(Ewl_Filelist *fl)
 	fl->controller = ewl_tree_new();
 	ewl_mvc_view_set(EWL_MVC(fl->controller), fl->view);
 	ewl_mvc_model_set(EWL_MVC(fl->controller), fl->model);
+	ewl_tree_selection_type_set(EWL_TREE(fl->controller),
+			EWL_TREE_SELECTION_TYPE_ROW);
 	ewl_container_child_append(EWL_CONTAINER(fl), fl->controller);
 	ewl_callback_append(EWL_WIDGET(fl->controller),
 			EWL_CALLBACK_CLICKED, ewl_filelist_cb_clicked, fl);
@@ -158,8 +160,6 @@ ewl_filelist_view_setup(Ewl_Filelist *fl)
 								TRUE);
 		ewl_tree_alternate_row_colors_set
 				(EWL_TREE(fl->controller), TRUE);
-		ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-					EWL_TREE_SELECTION_TYPE_CELL);
 		ewl_model_expansion_data_fetch_set(fl->model,
 			ewl_filelist_model_data_expansion_data_fetch);
 		ewl_model_data_expandable_set(fl->model,
@@ -173,8 +173,6 @@ ewl_filelist_view_setup(Ewl_Filelist *fl)
 								TRUE);
 		ewl_tree_alternate_row_colors_set
 				(EWL_TREE(fl->controller), TRUE);
-		ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-					EWL_TREE_SELECTION_TYPE_ROW);
 		view = ewl_tree_view_scrolled_get();
 	}
 	/* Until column view is written just default and throw a warning */
@@ -185,8 +183,6 @@ ewl_filelist_view_setup(Ewl_Filelist *fl)
 								FALSE);
 		ewl_tree_alternate_row_colors_set
 				(EWL_TREE(fl->controller), FALSE);
-		ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-					EWL_TREE_SELECTION_TYPE_ROW);
 		view = ewl_tree_view_freebox_get();
 		DWARNING("Column view not implemented");
 	}
@@ -201,8 +197,6 @@ ewl_filelist_view_setup(Ewl_Filelist *fl)
 								FALSE);
 		ewl_tree_alternate_row_colors_set
 				(EWL_TREE(fl->controller), FALSE);
-		ewl_tree_selection_type_set(EWL_TREE(fl->controller),
-					EWL_TREE_SELECTION_TYPE_ROW);
 		view = ewl_tree_view_freebox_get();
 		fl->view_flag = EWL_FILELIST_VIEW_ICON;
 	}
diff --git a/src/lib/ewl_list.c b/src/lib/ewl_list.c
index db6fa7b..009b6fe 100644
--- a/src/lib/ewl_list.c
+++ b/src/lib/ewl_list.c
@@ -56,8 +56,6 @@ ewl_list_init(Ewl_List *list)
 	ewl_callback_append(EWL_WIDGET(list), EWL_CALLBACK_CONFIGURE,
 						ewl_list_cb_configure, NULL);
 
-	ewl_container_add_notify_set(EWL_CONTAINER(list), ewl_list_cb_child_add);
-
 	DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
 
@@ -99,12 +97,19 @@ ewl_list_cb_configure(Ewl_Widget *w, void *ev __UNUSED__,
 	ewl_container_reset(EWL_CONTAINER(list));
 	for (i = 0; i < (int)model->count(mvc_data); i++)
 	{
-		Ewl_Widget *o;
+		Ewl_Widget *o, *cell;
+
+		cell = ewl_cell_new();
+		ewl_cell_state_change_cb_add(EWL_CELL(cell));
+		ewl_container_child_append(EWL_CONTAINER(list), cell);
+		ewl_callback_append(cell, EWL_CALLBACK_CLICKED,
+				ewl_list_cb_item_clicked, list);
+		ewl_widget_show(cell);
 
 		o = view->fetch(model->fetch(mvc_data, i, 0), i, 0);
 		ewl_widget_show(o);
 
-		ewl_container_child_append(EWL_CONTAINER(list), o);
+		ewl_container_child_append(EWL_CONTAINER(cell), o);
 	}
 
 	ewl_list_cb_selected_change(EWL_MVC(list));
@@ -115,32 +120,6 @@ ewl_list_cb_configure(Ewl_Widget *w, void *ev __UNUSED__,
 
 /**
  * @internal
- * @param c: The container to work with
- * @param w: The widget that was added
- * @return Returns no value
- * @brief Adds the needed callbacks to the widget
- */
-void
-ewl_list_cb_child_add(Ewl_Container *c, Ewl_Widget *w)
-{
-	DENTER_FUNCTION(DLEVEL_STABLE);
-	DCHECK_PARAM_PTR(c);
-	DCHECK_PARAM_PTR(w);
-	DCHECK_TYPE(c, EWL_LIST_TYPE);
-	DCHECK_TYPE(w, EWL_WIDGET_TYPE);
-
-	if (ewl_mvc_selection_mode_get(EWL_MVC(c)) ==
-					EWL_SELECTION_MODE_NONE)
-		DRETURN(DLEVEL_STABLE);
-
-	ewl_callback_append(w, EWL_CALLBACK_CLICKED,
-				ewl_list_cb_item_clicked, c);
-
-	DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @internal
  * @param w: The widget that was clicked
  * @param ev: The event data
  * @param data: The list widget
@@ -160,6 +139,10 @@ ewl_list_cb_item_clicked(Ewl_Widget *w, void *ev __UNUSED__, void *data)
 	DCHECK_TYPE(w, EWL_WIDGET_TYPE);
 	DCHECK_TYPE(data, EWL_LIST_TYPE);
 
+	if (ewl_mvc_selection_mode_get(EWL_MVC(data)) ==
+					EWL_SELECTION_MODE_NONE)
+		DRETURN(DLEVEL_STABLE);
+
 	model = ewl_mvc_model_get(EWL_MVC(data));
 	mvc_data = ewl_mvc_data_get(EWL_MVC(data));
 	row = ewl_container_child_index_get(EWL_CONTAINER(data), w);
@@ -167,17 +150,8 @@ ewl_list_cb_item_clicked(Ewl_Widget *w, void *ev __UNUSED__, void *data)
 
 	if ((unsigned int) row > model->count(mvc_data))
 	{
-		if (!EWL_HIGHLIGHT_IS(w))
-		{
-			DWARNING("Unknown widget clicked for container.");
-			DRETURN(DLEVEL_STABLE);
-		}
-
-		/* our row is the index that corresponds to the followed
-		 * widget for this highlight widget */
-		row = ewl_container_child_index_get(EWL_CONTAINER(data),
-				ewl_highlight_follow_get(EWL_HIGHLIGHT(w)));
-		if (row < 0) DRETURN(DLEVEL_STABLE);
+		DWARNING("Don't use container function on MVC widget!");
+		DRETURN(DLEVEL_STABLE);
 	}
 
 	ewl_mvc_handle_click(EWL_MVC(data), NULL, mvc_data, row, 0);
diff --git a/src/lib/ewl_mvc.c b/src/lib/ewl_mvc.c
index 6286f9a..91e7b84 100644
--- a/src/lib/ewl_mvc.c
+++ b/src/lib/ewl_mvc.c
@@ -456,7 +456,8 @@ ewl_mvc_selected_set(Ewl_MVC *mvc, const Ewl_Model *model, void *data,
 	DCHECK_PARAM_PTR(mvc);
 	DCHECK_TYPE(mvc, EWL_MVC_TYPE);
 
-	if (mvc->selection_mode == EWL_SELECTION_MODE_NONE)
+	if ((mvc->selection_mode == EWL_SELECTION_MODE_NONE) ||
+			(ewl_mvc_selected_is(mvc, data, row, column)))
 		DRETURN(DLEVEL_STABLE);
 
 	ewl_mvc_selected_clear_private(mvc);
@@ -572,7 +573,10 @@ ewl_mvc_selected_rm(Ewl_MVC *mvc, void *data __UNUSED__, unsigned int row,
 		sel = ecore_list_current(mvc->selected);
 
 		if (sel->type == EWL_SELECTION_TYPE_INDEX)
-			ecore_list_remove(mvc->selected);
+		{
+			sel = ecore_list_remove(mvc->selected);
+			ewl_mvc_selection_free(sel);
+		}
 		else
 			ewl_mvc_selected_range_split(mvc,
 				EWL_SELECTION_RANGE(sel), row, column);
@@ -742,6 +746,7 @@ ewl_mvc_selected_insert(Ewl_MVC *mvc, const Ewl_Model *model, void *data,
 	ecore_list_first_goto(mvc->selected);
 	while ((cur = ecore_list_current(mvc->selected)))
 	{
+		/* ecore_list_remove updates the index by itself */
 		if (ewl_mvc_selection_intersects(range, cur))
 		{
 			ecore_list_remove(mvc->selected);
@@ -749,14 +754,13 @@ ewl_mvc_selected_insert(Ewl_MVC *mvc, const Ewl_Model *model, void *data,
 			/* just free indexes as their covered by the
 			 * range and don't need to be re-inserted */
 			if (cur->type == EWL_SELECTION_TYPE_INDEX)
-			{
 				ewl_mvc_selection_free(cur);
-			}
 			else
 				ecore_list_append(intersections, cur);
 
 		}
-		ecore_list_next(mvc->selected);
+		else
+			ecore_list_next(mvc->selected);
 	}
 
 	/* if we intersect nothing just add ourselves to the list
@@ -1082,6 +1086,7 @@ ewl_mvc_selected_range_split(Ewl_MVC *mvc, Ewl_Selection_Range *range,
 							row, range->end.column);
 		ecore_list_append(mvc->selected, sel);
 	}
+
 	ewl_mvc_selection_free(EWL_SELECTION(range));
 
 	DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -1249,8 +1254,6 @@ static void
 ewl_mvc_highlight_do(Ewl_MVC *mvc __UNUSED__, Ewl_Container *c,
 				Ewl_Selection *sel, Ewl_Widget *w)
 {
-	Ewl_Widget *h;
-
 	DENTER_FUNCTION(DLEVEL_STABLE);
 	DCHECK_PARAM_PTR(c);
 	DCHECK_PARAM_PTR(sel);
@@ -1258,20 +1261,17 @@ ewl_mvc_highlight_do(Ewl_MVC *mvc __UNUSED__, Ewl_Container *c,
 	DCHECK_TYPE(c, EWL_CONTAINER_TYPE);
 	DCHECK_TYPE(w, EWL_WIDGET_TYPE);
 
-	h = ewl_highlight_new();
-	ewl_highlight_follow_set(EWL_HIGHLIGHT(h), w);
-	ewl_container_child_append(EWL_CONTAINER(c), h);
-	ewl_callback_prepend(h, EWL_CALLBACK_DESTROY,
+	ewl_widget_state_set(w, "selected", EWL_STATE_PERSISTENT);
+	ewl_callback_prepend(w, EWL_CALLBACK_DESTROY,
 			ewl_mvc_cb_highlight_destroy, sel);
-	ewl_widget_show(h);
 
 	if (sel->type == EWL_SELECTION_TYPE_INDEX)
-		sel->highlight = h;
+		sel->highlight = w;
 	else
 	{
 		if (!sel->highlight)
 			sel->highlight = ecore_list_new();
-		ecore_list_append(sel->highlight, h);
+		ecore_list_append(sel->highlight, w);
 	}
 
 	DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -1392,7 +1392,8 @@ ewl_mvc_selection_free(Ewl_Selection *sel)
 		{
 			ewl_callback_del(sel->highlight, EWL_CALLBACK_DESTROY,
 					ewl_mvc_cb_highlight_destroy);
-			ewl_widget_destroy(sel->highlight);
+			ewl_widget_state_set(sel->highlight, "deselect",
+					EWL_STATE_PERSISTENT);
 		}
 		else
 		{
@@ -1402,12 +1403,12 @@ ewl_mvc_selection_free(Ewl_Selection *sel)
 			{
 				ewl_callback_del(w, EWL_CALLBACK_DESTROY,
 						ewl_mvc_cb_highlight_destroy);
-				ewl_widget_destroy(w);
+				ewl_widget_state_set(w, "deselect",
+					EWL_STATE_PERSISTENT);
 			}
 
 			IF_FREE_LIST(sel->highlight);
 		}
-		sel->highlight = NULL;
 	}
 	FREE(sel);
 
diff --git a/src/lib/ewl_row.c b/src/lib/ewl_row.c
index 058cdd9..d2ec53b 100644
--- a/src/lib/ewl_row.c
+++ b/src/lib/ewl_row.c
@@ -5,6 +5,8 @@
 #include "ewl_private.h"
 #include "ewl_debug.h"
 
+static void ewl_row_cb_state_changed(Ewl_Widget *w, void *ev, void *data);
+
 /**
  * @return Returns a newly allocated row on success, NULL on failure.
  * @brief Allocate and initialize a new row
@@ -56,6 +58,8 @@ ewl_row_init(Ewl_Row *row)
 
 	ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_CONFIGURE,
 				ewl_row_cb_configure, NULL);
+	ewl_callback_append(EWL_WIDGET(row), EWL_CALLBACK_STATE_CHANGED,
+				ewl_row_cb_state_changed, NULL);
 
 	ewl_widget_focusable_set(EWL_WIDGET(row), FALSE);
 
@@ -375,3 +379,40 @@ ewl_row_cb_child_resize(Ewl_Container *c, Ewl_Widget *w __UNUSED__,
 	DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+/**
+ * @internal
+ * @param w: The widget to work with
+ * @ev: The Ewl_Event_State_Change struct
+ * @data: UNUSED
+ * @return Returns no value
+ * @brief Sends the state on to the row's children
+ */
+static void
+ewl_row_cb_state_changed(Ewl_Widget *w, void *ev, void *data __UNUSED__)
+{
+	Ewl_Widget *o;
+	Ewl_Event_State_Change *e;
+	const char *send_state;
+
+	DENTER_FUNCTION(DLEVEL_STABLE);
+	DCHECK_PARAM_PTR(w);
+	DCHECK_PARAM_PTR(ev);
+	DCHECK_TYPE(w, EWL_ROW_TYPE);
+
+	e = EWL_EVENT_STATE_CHANGE(ev);
+
+	/* Only want this for selected signals */
+	if (!strcmp(e->state, "selected"))
+		send_state = "parent,selected";
+	else if (!strcmp(e->state, "deselect"))
+		send_state = "parent,deselect";
+	else
+		DRETURN(DLEVEL_STABLE);
+
+	ewl_container_child_iterate_begin(EWL_CONTAINER(w));
+	while ((o = ewl_container_child_next(EWL_CONTAINER(w))))
+		ewl_widget_state_set(o, send_state, e->flag);
+
+	DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
diff --git a/src/lib/ewl_tree.c b/src/lib/ewl_tree.c
index 8f115c0..28915b7 100644
--- a/src/lib/ewl_tree.c
+++ b/src/lib/ewl_tree.c
@@ -819,6 +819,7 @@ ewl_tree_column_build(Ewl_Row *row, const Ewl_Model *model,
 	DCHECK_TYPE(row, EWL_ROW_TYPE);
 
 	cell = ewl_cell_new();
+	ewl_cell_state_change_cb_add(EWL_CELL(cell));
 	ewl_object_fill_policy_set(EWL_OBJECT(cell), EWL_FLAG_FILL_ALL);
 	ewl_container_child_append(EWL_CONTAINER(row), cell);
 	ewl_callback_append(cell, EWL_CALLBACK_CLICKED,
@@ -1134,13 +1135,14 @@ ewl_tree_widget_at(Ewl_MVC *mvc, void *data, unsigned int row,
 
 	/* find the row in the container */
 	r = ewl_container_child_get(c, row);
+	r = EWL_WIDGET(EWL_TREE_NODE(r)->row);
+
 	if (tree->type == EWL_TREE_SELECTION_TYPE_ROW)
-		w = EWL_WIDGET(r);
+		w = r;
 	else
 	{
 		/* infact our row is a node so we have to get the row
 		 * to search for the right container */
-		r = EWL_WIDGET(EWL_TREE_NODE(r)->row);
 		w = ewl_container_child_get(EWL_CONTAINER(r), column);
 	}
 
diff --git a/src/lib/ewl_widget.c b/src/lib/ewl_widget.c
index c48129b..c9664a1 100644
--- a/src/lib/ewl_widget.c
+++ b/src/lib/ewl_widget.c
@@ -754,6 +754,8 @@ ewl_widget_appearance_path_get(Ewl_Widget *w)
 void
 ewl_widget_state_set(Ewl_Widget *w, const char *state, Ewl_State_Type flag)
 {
+	Ewl_Event_State_Change ev;
+
 	DENTER_FUNCTION(DLEVEL_STABLE);
 	DCHECK_PARAM_PTR(w);
 	DCHECK_PARAM_PTR(state);
@@ -774,7 +776,10 @@ ewl_widget_state_set(Ewl_Widget *w, const char *state, Ewl_State_Type flag)
 		edje_object_signal_emit(w->theme_object, state, "EWL");
 	}
 
-	ewl_callback_call(w, EWL_CALLBACK_STATE_CHANGED);
+	ev.state = state;
+	ev.flag = flag;
+
+	ewl_callback_call_with_event_data(w, EWL_CALLBACK_STATE_CHANGED, &ev);
 
 	DRETURN(DLEVEL_STABLE);
 }

-- 
Enlightenment DR17 toolkit based (based on the EFL)



More information about the Pkg-e-commits mailing list