[gnome-flashback/wip/segeiger/gnome-3-18-inputmethods: 3/4] input-sources: implement auxiliary and preedit text callbacks



commit 842cc29cacec20df87ca8088a1984d1b24a99c8c
Author: Sebastian Geiger <sbastig gmx net>
Date:   Mon Jan 18 16:05:26 2016 +0100

    input-sources: implement auxiliary and preedit text callbacks

 .../libinput-sources/gf-candidate-popup.c          |   45 +++++++++++++++++---
 1 files changed, 39 insertions(+), 6 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-candidate-popup.c 
b/gnome-flashback/libinput-sources/gf-candidate-popup.c
index 337aaba..5cfcfdd 100644
--- a/gnome-flashback/libinput-sources/gf-candidate-popup.c
+++ b/gnome-flashback/libinput-sources/gf-candidate-popup.c
@@ -48,40 +48,73 @@ update_preedit_text_cb (IBusPanelService *service,
                         IBusText         *text,
                         guint             cursor_pos,
                         gboolean          visible,
-                        gpointer          user_data)
+                        GfCandidatePopup *popup)
 {
+  IBusAttrList *attributes;
+
+  gtk_widget_set_visible (popup->pre_edit_text, visible);
+
+  gtk_label_set_text (GTK_LABEL (popup->pre_edit_text),
+                      ibus_text_get_text (text));
+
+  attributes = ibus_text_get_attributes (text);
+
+  if (attributes)
+  {
+    IBusAttribute *attribute;
+    guint i;
+
+    for (i = 0; (attribute = ibus_attr_list_get (attributes, i)) != NULL; i++)
+    {
+      guint start;
+      guint end;
+      if (ibus_attribute_get_type () != IBUS_ATTR_TYPE_BACKGROUND)
+        continue;
+
+      start = ibus_attribute_get_start_index (attribute);
+      end = ibus_attribute_get_end_index (attribute);
+      gtk_label_select_region (GTK_LABEL (popup->pre_edit_text), start, end);
+    }
+  }
 }
 
 static void
 show_preedit_text_cb (IBusPanelService *service,
-                      gpointer          user_data)
+                      GfCandidatePopup *popup)
 {
+  gtk_widget_show (popup->pre_edit_text);
 }
 
 static void
 hide_preedit_text_cb (IBusPanelService *service,
-                      gpointer          user_data)
+                      GfCandidatePopup *popup)
 {
+  gtk_widget_hide (popup->pre_edit_text);
 }
 
 static void
 update_auxiliary_text_cb (IBusPanelService *service,
                           IBusText         *text,
                           gboolean          visible,
-                          gpointer          user_data)
+                          GfCandidatePopup *popup)
 {
+  gtk_widget_set_visible (popup->aux_text, visible);
+
+  gtk_label_set_text (GTK_LABEL (popup->aux_text), ibus_text_get_text (text));
 }
 
 static void
 show_auxiliary_text_cb (IBusPanelService *service,
-                        gpointer          user_data)
+                        GfCandidatePopup *popup)
 {
+  gtk_widget_show (popup->aux_text);
 }
 
 static void
 hide_auxiliary_text_cb (IBusPanelService *service,
-                        gpointer          user_data)
+                        GfCandidatePopup *popup)
 {
+  gtk_widget_hide (popup->aux_text);
 }
 
 static void


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