[maemo-commits] [maemo-commits] r11988 - in projects/haf/trunk/hildon-1: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed May 30 16:52:29 EEST 2007
Author: xan
Date: 2007-05-30 16:52:28 +0300 (Wed, 30 May 2007)
New Revision: 11988

Modified:
   projects/haf/trunk/hildon-1/ChangeLog
   projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c
   projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.h
Log:
	* src/hildon-bread-crumb-trail.c (hildon_bread_crumb_trail_class_init):
	Add a new signal "move-parent", bind Escape and BackSpace to it. The handler
	will fake an activation on the previous to the last item of the trail, so
	the effect can be overrided by the developer as usual.
	Also change the callback for the back button to do the same thing, so its
	effect can be overrided too.


Modified: projects/haf/trunk/hildon-1/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-1/ChangeLog	2007-05-30 12:43:46 UTC (rev 11987)
+++ projects/haf/trunk/hildon-1/ChangeLog	2007-05-30 13:52:28 UTC (rev 11988)
@@ -1,3 +1,12 @@
+2007-05-30  Xan Lopez  <xan.lopez at nokia.com>
+
+	* src/hildon-bread-crumb-trail.c (hildon_bread_crumb_trail_class_init):
+	Add a new signal "move-parent", bind Escape and BackSpace to it. The handler
+	will fake an activation on the previous to the last item of the trail, so
+	the effect can be overrided by the developer as usual.
+	Also change the callback for the back button to do the same thing, so its
+	effect can be overrided too.
+
 2007-05-30  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
 
 	* src/hildon-caption.c: Implementing the proper focus grabbing in the

Modified: projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c	2007-05-30 12:43:46 UTC (rev 11987)
+++ projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.c	2007-05-30 13:52:28 UTC (rev 11988)
@@ -37,6 +37,7 @@
  * implemented if needed. See #HildonBreadCrumb for more details.
  */
 
+#include <gdk/gdkkeysyms.h>
 #include "hildon-marshalers.h"
 #include "hildon-bread-crumb-trail.h"
 #include "hildon-bread-crumb-widget.h"
@@ -54,6 +55,7 @@
 
 enum {
   CRUMB_CLICKED,
+  MOVE_PARENT,
   LAST_SIGNAL
 };
 
@@ -79,7 +81,10 @@
 static void hildon_bread_crumb_trail_scroll_back (GtkWidget *button,
                                                   HildonBreadCrumbTrail *bct);
 static void hildon_bread_crumb_trail_update_back_button_sensitivity (HildonBreadCrumbTrail *bct);
+static void hildon_bread_crumb_trail_move_parent (HildonBreadCrumbTrail *bct);
 
+static gpointer get_bread_crumb_id (HildonBreadCrumb *item);
+
 static guint bread_crumb_trail_signals[LAST_SIGNAL] = { 0 };
 
 /* GType methods */
@@ -93,6 +98,7 @@
   GtkObjectClass *object_class = (GtkObjectClass*)klass;
   GtkWidgetClass *widget_class = (GtkWidgetClass*)klass;
   GtkContainerClass *container_class = (GtkContainerClass*)klass;
+  GtkBindingSet *binding_set;
 
   /* GObject signals */
   gobject_class->finalize = hildon_bread_crumb_trail_finalize;
@@ -106,6 +112,9 @@
   container_class->forall = hildon_bread_crumb_trail_forall;
   container_class->remove = hildon_bread_crumb_trail_remove;
 
+  /* HildonBreadCrumbTrail signals */
+  klass->move_parent = hildon_bread_crumb_trail_move_parent;
+
   /* Style properties */
 
 #define _BREAD_CRUMB_TRAIL_MINIMUM_WIDTH 10
@@ -140,7 +149,26 @@
                   _hildon_marshal_BOOLEAN__POINTER,
                   G_TYPE_BOOLEAN, 1,
                   G_TYPE_POINTER);
+
+  bread_crumb_trail_signals[MOVE_PARENT] =
+    g_signal_new ("move-parent",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                  G_STRUCT_OFFSET (HildonBreadCrumbTrailClass, move_parent),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE,
+                  0);
                   
+
+  /* Binding set */
+  binding_set = gtk_binding_set_by_class (widget_class);
+
+  gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0,
+                                "move-parent", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0,
+                                "move-parent", 0);
+                                
   /* Private data */
   g_type_class_add_private (gobject_class, sizeof (HildonBreadCrumbTrailPrivate));
 }
@@ -156,6 +184,16 @@
 }
 
 static void
+hildon_bread_crumb_trail_move_parent (HildonBreadCrumbTrail *bct)
+{
+  if (g_list_length (bct->priv->item_list) > 1)
+    {
+      g_signal_emit_by_name (HILDON_BREAD_CRUMB (bct->priv->item_list->next->data),
+                             "crumb-activated");
+    }
+}
+
+static void
 hildon_bread_crumb_trail_size_request (GtkWidget *widget,
                                        GtkRequisition *requisition)
 {
@@ -354,6 +392,7 @@
   if (signal_handled == FALSE)
     {
       GtkWidget *child;
+      gboolean focus_last_item = FALSE;
       HildonBreadCrumbTrailPrivate *priv;
 
       priv = bct->priv;
@@ -363,6 +402,9 @@
       /* We remove the tip of the list until we hit the clicked button */
       while (child && child != button)
         {
+          if (GTK_WIDGET_HAS_FOCUS (child))
+            focus_last_item = TRUE;
+
           gtk_container_remove (GTK_CONTAINER (bct), child);
 
           if (priv->item_list == NULL)
@@ -370,6 +412,9 @@
 
           child = GTK_WIDGET (priv->item_list->data);
         }
+
+      if (focus_last_item)
+        gtk_widget_grab_focus (GTK_WIDGET (bct->priv->item_list->data));
     }
 }
 
@@ -524,14 +569,7 @@
 hildon_bread_crumb_trail_scroll_back (GtkWidget *button,
                                       HildonBreadCrumbTrail *bct)
 {
-  HildonBreadCrumb *item;
-
-  hildon_bread_crumb_trail_pop (bct);
-
-  item = HILDON_BREAD_CRUMB (bct->priv->item_list->data);
-
-  g_signal_emit (bct, bread_crumb_trail_signals[CRUMB_CLICKED], 0,
-                 get_bread_crumb_id (item));
+  hildon_bread_crumb_trail_move_parent (bct);
 }
 
 static void

Modified: projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.h
===================================================================
--- projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.h	2007-05-30 12:43:46 UTC (rev 11987)
+++ projects/haf/trunk/hildon-1/src/hildon-bread-crumb-trail.h	2007-05-30 13:52:28 UTC (rev 11988)
@@ -57,6 +57,8 @@
 
   void (*crumb_clicked) (HildonBreadCrumbTrail *bct,
                          gpointer id);
+
+  void (*move_parent) (HildonBreadCrumbTrail *bct);
 };
 
 GType hildon_bread_crumb_trail_get_type (void) G_GNUC_CONST;


More information about the maemo-commits mailing list