[maemo-commits] [maemo-commits] r19352 - in projects/haf/trunk/hildon-input-method-plugins-example: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Sep 15 14:12:04 EEST 2009
Author: jrocha
Date: 2009-09-15 14:11:55 +0300 (Tue, 15 Sep 2009)
New Revision: 19352

Modified:
   projects/haf/trunk/hildon-input-method-plugins-example/ChangeLog
   projects/haf/trunk/hildon-input-method-plugins-example/src/hildon-im-onehand-fkb.c
Log:
2009-09-15  Joaquim Rocha <jrocha at igalia.com>

    * hildon-im-onehand-fkb.c: Added persisten press mode (press a button
      until a value is inserted) to input the "persistent_value" text.

Modified: projects/haf/trunk/hildon-input-method-plugins-example/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-input-method-plugins-example/ChangeLog	2009-09-15 10:39:36 UTC (rev 19351)
+++ projects/haf/trunk/hildon-input-method-plugins-example/ChangeLog	2009-09-15 11:11:55 UTC (rev 19352)
@@ -4,7 +4,10 @@
 	  one-handexample keyboard; Added support to favorite hand, for use in
 	  landscape mode.	
 	* hildon-im-onehand-fkb.c (create_sliding_key): Aligned the button title
-	  to the midle of the button so it looks better.
+	  to the midle of the button so it looks better; Added "persistent_value"
+	  data to each created key.
+	* hildon-im-onehand-fkb.c: Added persisten press mode (press a button 
+	  until a value is inserted) to input the "persistent_value" text.
 
 2009-09-10  Murray Cumming  <murrayc at murrayc.com>
 

Modified: projects/haf/trunk/hildon-input-method-plugins-example/src/hildon-im-onehand-fkb.c
===================================================================
--- projects/haf/trunk/hildon-input-method-plugins-example/src/hildon-im-onehand-fkb.c	2009-09-15 10:39:36 UTC (rev 19351)
+++ projects/haf/trunk/hildon-input-method-plugins-example/src/hildon-im-onehand-fkb.c	2009-09-15 11:11:55 UTC (rev 19352)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2006-2007 Nokia Corporation. All rights reserved.
  *
- * Author: Joaquim Rocha <jrocha at maemo.org>
+ * Author: Joaquim Rocha <jrocha at igalia.com>
  *
  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  *
@@ -100,6 +100,7 @@
   gint timeout_id;
 
   GtkWidget *repeating_key;
+  GtkWidget *pressed_key;
 }
 HildonIMOneHandFKBPrivate;
 
@@ -740,8 +741,8 @@
   }
 }
 
-static gint
-slide_expired (gpointer data)
+static gboolean
+press_expired (gpointer data)
 {
   HildonIMOneHandFKB *self = HILDON_IM_ONEHAND_FKB (data);
   HildonIMOneHandFKBPrivate *priv;
@@ -751,12 +752,55 @@
   priv->slide_index = -1;
   priv->repeating_key = NULL;
 
+  const gchar *text = g_strdup (g_object_get_data (G_OBJECT (priv->pressed_key),
+                                                   "persistent_value"));
+
+  if (text == NULL)
+  {
+    gchar *key_values = g_object_get_data (G_OBJECT (priv->pressed_key),
+                                           "key_values");
+    text = g_strdup (get_first_char (key_values));
+  }
+
+  if (text != NULL)
+  {
+    write (self, text);
+  }
+
+  priv->pressed_key = NULL;
+
   return FALSE;
 }
 
 static void
 sliding_key_pressed_cb (GtkWidget *key, gpointer data)
 {
+  HildonIMOneHandFKB *self = HILDON_IM_ONEHAND_FKB (data);
+  HildonIMOneHandFKBPrivate *priv;
+  priv = HILDON_IM_ONEHAND_FKB_GET_PRIVATE (self);
+
+  clear_timeout_id (self);
+  priv->pressed_key = key;
+  priv->timeout_id = g_timeout_add (SLIDING_TIMEOUT, press_expired, self);
+}
+
+static gboolean
+slide_expired (gpointer data)
+{
+  HildonIMOneHandFKB *self = HILDON_IM_ONEHAND_FKB (data);
+  HildonIMOneHandFKBPrivate *priv;
+  priv = HILDON_IM_ONEHAND_FKB_GET_PRIVATE (self);
+
+  priv->replace_previous_char = FALSE;
+  priv->slide_index = -1;
+  priv->repeating_key = NULL;
+
+  return FALSE;
+}
+
+static void
+sliding_key_released_cb (GtkWidget *key, gpointer data)
+{
   const gchar *key_value = NULL;
   gchar *sub_str = NULL;
   gint nr_values = 1;
@@ -766,6 +810,11 @@
   HildonIMOneHandFKBPrivate *priv;
   priv = HILDON_IM_ONEHAND_FKB_GET_PRIVATE (self);
 
+  if (priv->pressed_key == NULL)
+  {
+    return;
+  }
+
   caps_on = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->caps_button));
 
   key_value = g_object_get_data (G_OBJECT (key), "key_values");
@@ -821,6 +870,7 @@
                                       HILDON_BUTTON_ARRANGEMENT_VERTICAL);
 
   g_object_set_data (G_OBJECT (key), "key_values", key_values);
+  g_object_set_data (G_OBJECT (key), "persistent_value", title);
 
   if (visible_offset > 0)
   {
@@ -834,10 +884,15 @@
   hildon_button_set_title_alignment (HILDON_BUTTON (key), 0.5, 0.5);
 
   g_signal_connect (key,
-                    "clicked",
+                    "pressed",
                     G_CALLBACK (sliding_key_pressed_cb),
                     self);
 
+  g_signal_connect (key,
+                    "released",
+                    G_CALLBACK (sliding_key_released_cb),
+                    self);
+
   return key;
 }
 

More information about the maemo-commits mailing list