]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkimcontext.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkimcontext.c
index 7aec5c1d6b89263afc7cf057f5dd361571ba6eed..f0f351fbda1657e63e4733ea0090435c7f73463c 100644 (file)
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 #include <string.h>
 #include "gtkimcontext.h"
-#include "gtkmain.h"           /* For _gtk_boolean_handled_accumulator */
+#include "gtkprivate.h"
+#include "gtktypebuiltins.h"
 #include "gtkmarshalers.h"
 #include "gtkintl.h"
-#include "gtkalias.h"
 
 /**
  * SECTION:gtkimcontext
@@ -110,7 +108,20 @@ enum {
   LAST_SIGNAL
 };
 
-static guint im_context_signals[LAST_SIGNAL] = { 0 };
+enum {
+  PROP_INPUT_PURPOSE = 1,
+  PROP_INPUT_HINTS,
+  LAST_PROPERTY
+};
+
+static guint im_context_signals[LAST_SIGNAL] = { 0, };
+static GParamSpec *properties[LAST_PROPERTY] = { NULL, };
+
+typedef struct _GtkIMContextPrivate GtkIMContextPrivate;
+struct _GtkIMContextPrivate {
+  GtkInputPurpose purpose;
+  GtkInputHints hints;
+};
 
 static void     gtk_im_context_real_get_preedit_string (GtkIMContext   *context,
                                                        gchar         **str,
@@ -126,6 +137,16 @@ static void     gtk_im_context_real_set_surrounding    (GtkIMContext   *context,
                                                        gint            len,
                                                        gint            cursor_index);
 
+static void     gtk_im_context_get_property            (GObject        *obj,
+                                                        guint           property_id,
+                                                        GValue         *value,
+                                                        GParamSpec     *pspec);
+static void     gtk_im_context_set_property            (GObject        *obj,
+                                                        guint           property_id,
+                                                        const GValue   *value,
+                                                        GParamSpec     *pspec);
+
+
 G_DEFINE_ABSTRACT_TYPE (GtkIMContext, gtk_im_context, G_TYPE_OBJECT)
 
 /**
@@ -160,7 +181,7 @@ G_DEFINE_ABSTRACT_TYPE (GtkIMContext, gtk_im_context, G_TYPE_OBJECT)
  *   character.
  * @focus_in: Called via gtk_im_context_focus_in() when the input widget
  *   has gained focus. May be overridden to keep track of the current focus.
- * @focus_out: Called via gtk_im_context_focus_in() when the input widget
+ * @focus_out: Called via gtk_im_context_focus_out() when the input widget
  *   has lost focus. May be overridden to keep track of the current focus.
  * @reset: Called via gtk_im_context_reset() to signal a change such as a
  *   change in cursor position. An input method that implements preediting
@@ -188,6 +209,11 @@ G_DEFINE_ABSTRACT_TYPE (GtkIMContext, gtk_im_context, G_TYPE_OBJECT)
 static void
 gtk_im_context_class_init (GtkIMContextClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->get_property = gtk_im_context_get_property;
+  object_class->set_property = gtk_im_context_set_property;
+
   klass->get_preedit_string = gtk_im_context_real_get_preedit_string;
   klass->filter_keypress = gtk_im_context_real_filter_keypress;
   klass->get_surrounding = gtk_im_context_real_get_surrounding;
@@ -300,6 +326,25 @@ gtk_im_context_class_init (GtkIMContextClass *klass)
                   G_TYPE_BOOLEAN, 2,
                   G_TYPE_INT,
                  G_TYPE_INT);
+
+  properties[PROP_INPUT_PURPOSE] =
+    g_param_spec_enum ("input-purpose",
+                         P_("Purpose"),
+                         P_("Purpose of the text field"),
+                         GTK_TYPE_INPUT_PURPOSE,
+                         GTK_INPUT_PURPOSE_FREE_FORM,
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_INPUT_HINTS] =
+    g_param_spec_flags ("input-hints",
+                         P_("hints"),
+                         P_("Hints for the text field behaviour"),
+                         GTK_TYPE_INPUT_HINTS,
+                         GTK_INPUT_HINT_NONE,
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  g_type_class_add_private (klass, sizeof (GtkIMContextPrivate));
+  g_object_class_install_properties (object_class, LAST_PROPERTY, properties);
 }
 
 static void
@@ -420,12 +465,12 @@ gtk_im_context_set_client_window (GtkIMContext *context,
 /**
  * gtk_im_context_get_preedit_string:
  * @context:    a #GtkIMContext
- * @str:        location to store the retrieved string. The
- *              string retrieved must be freed with g_free ().
- * @attrs:      location to store the retrieved attribute list.
- *              When you are done with this list, you must
- *              unreference it with pango_attr_list_unref().
- * @cursor_pos: location to store position of cursor (in characters)
+ * @str:        (out) (transfer full): location to store the retrieved
+ *              string. The string retrieved must be freed with g_free().
+ * @attrs:      (out) (transfer full): location to store the retrieved
+ *              attribute list.  When you are done with this list, you
+ *              must unreference it with pango_attr_list_unref().
+ * @cursor_pos: (out): location to store position of cursor (in characters)
  *              within the preedit string.  
  * 
  * Retrieve the current preedit string for the input context,
@@ -621,12 +666,12 @@ gtk_im_context_set_surrounding (GtkIMContext  *context,
 /**
  * gtk_im_context_get_surrounding:
  * @context: a #GtkIMContext
- * @text: location to store a UTF-8 encoded string of text
- *        holding context around the insertion point.
- *        If the function returns %TRUE, then you must free
- *        the result stored in this location with g_free().
- * @cursor_index: location to store byte index of the insertion cursor
- *        within @text.
+ * @text: (out) (transfer full): location to store a UTF-8 encoded
+ *        string of text holding context around the insertion point.
+ *        If the function returns %TRUE, then you must free the result
+ *        stored in this location with g_free().
+ * @cursor_index: (out): location to store byte index of the insertion
+ *        cursor within @text.
  * 
  * Retrieves context around the insertion point. Input methods
  * typically want context in order to constrain input text based on
@@ -710,5 +755,46 @@ gtk_im_context_delete_surrounding (GtkIMContext *context,
   return result;
 }
 
-#define __GTK_IM_CONTEXT_C__
-#include "gtkaliasdef.c"
+static void
+gtk_im_context_get_property (GObject    *obj,
+                             guint       property_id,
+                             GValue     *value,
+                             GParamSpec *pspec)
+{
+  GtkIMContextPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, GTK_TYPE_IM_CONTEXT, GtkIMContextPrivate);
+
+  switch (property_id)
+    {
+    case PROP_INPUT_PURPOSE:
+      g_value_set_enum (value, priv->purpose);
+      break;
+    case PROP_INPUT_HINTS:
+      g_value_set_flags (value, priv->hints);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gtk_im_context_set_property (GObject      *obj,
+                             guint         property_id,
+                             const GValue *value,
+                             GParamSpec   *pspec)
+{
+  GtkIMContextPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, GTK_TYPE_IM_CONTEXT, GtkIMContextPrivate);
+
+  switch (property_id)
+    {
+    case PROP_INPUT_PURPOSE:
+      priv->purpose = g_value_get_enum (value);
+      break;
+    case PROP_INPUT_HINTS:
+      priv->hints = g_value_get_flags (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
+      break;
+    }
+}