[evolution/gnome-3-18] Forward ETable/ETree background events to an ETableItem



commit 298d0fe33270afb7903346ebbe6efc712d4a876b
Author: Milan Crha <mcrha redhat com>
Date:   Tue Nov 3 10:25:40 2015 +0100

    Forward ETable/ETree background events to an ETableItem
    
    The background can have focus, but then the events, like keyboard
    shortcuts, are not properly propagated to the ETableItem, thus they
    do not work for the user, even the UI suggests that everything is
    focused as it should be.

 e-util/e-table.c |   56 +++++++++++++++++++++++++++++++++++++++--------------
 e-util/e-tree.c  |    4 +++
 2 files changed, 45 insertions(+), 15 deletions(-)
---
diff --git a/e-util/e-table.c b/e-util/e-table.c
index 9d5b709..2525f2a 100644
--- a/e-util/e-table.c
+++ b/e-util/e-table.c
@@ -1256,6 +1256,33 @@ et_canvas_realize (GtkWidget *canvas,
        set_header_width (e_table);
 }
 
+static ETableItem *
+get_first_etable_item (ETableGroup *table_group)
+{
+       ETableItem *res = NULL;
+       GnomeCanvasGroup *group;
+       GList *link;
+
+       g_return_val_if_fail (E_IS_TABLE_GROUP (table_group), NULL);
+
+       group = GNOME_CANVAS_GROUP (table_group);
+       g_return_val_if_fail (group != NULL, NULL);
+
+       for (link = group->item_list; link && !res; link = g_list_next (link)) {
+               GnomeCanvasItem *item;
+
+               item = GNOME_CANVAS_ITEM (link->data);
+
+               if (E_IS_TABLE_GROUP (item))
+                       res = get_first_etable_item (E_TABLE_GROUP (item));
+               else if (E_IS_TABLE_ITEM (item)) {
+                       res = E_TABLE_ITEM (item);
+               }
+       }
+
+       return res;
+}
+
 static gboolean
 white_item_event (GnomeCanvasItem *white_item,
                   GdkEvent *event,
@@ -1267,6 +1294,15 @@ white_item_event (GnomeCanvasItem *white_item,
                e_table, et_signals[WHITE_SPACE_EVENT], 0,
                event, &return_val);
 
+       if (!return_val && e_table->group) {
+               ETableItem *item;
+
+               item = get_first_etable_item (e_table->group);
+
+               if (item)
+                       g_signal_emit_by_name (item, "event", event, &return_val);
+       }
+
        return return_val;
 }
 
@@ -1309,22 +1345,12 @@ et_canvas_root_event (GnomeCanvasItem *root,
 static void
 focus_first_etable_item (ETableGroup *group)
 {
-       GnomeCanvasGroup *cgroup;
-       GList *l;
+       ETableItem *item;
 
-       cgroup = GNOME_CANVAS_GROUP (group);
-
-       for (l = cgroup->item_list; l; l = l->next) {
-               GnomeCanvasItem *i;
-
-               i = GNOME_CANVAS_ITEM (l->data);
-
-               if (E_IS_TABLE_GROUP (i))
-                       focus_first_etable_item (E_TABLE_GROUP (i));
-               else if (E_IS_TABLE_ITEM (i)) {
-                       e_table_item_set_cursor (E_TABLE_ITEM (i), 0, 0);
-                       gnome_canvas_item_grab_focus (i);
-               }
+       item = get_first_etable_item (group);
+       if (item) {
+               e_table_item_set_cursor (item, 0, 0);
+               gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (item));
        }
 }
 
diff --git a/e-util/e-tree.c b/e-util/e-tree.c
index 8ff1bb3..83abbfe 100644
--- a/e-util/e-tree.c
+++ b/e-util/e-tree.c
@@ -1210,6 +1210,10 @@ white_item_event (GnomeCanvasItem *white_item,
                signals[WHITE_SPACE_EVENT], 0,
                event, &return_val);
 
+       if (!return_val && tree->priv->item) {
+               g_signal_emit_by_name (tree->priv->item, "event", event, &return_val);
+       }
+
        return return_val;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]