[gnome-flashback/wip/segeiger/gnome-3-18-inputmethods] Some more changes



commit a156478f0a2eb6416f7477725d44d180dfbefdb0
Author: Sebastian Geiger <sbastig gmx net>
Date:   Wed Jan 13 00:08:11 2016 +0100

    Some more changes

 .idea/codeStyleSettings.xml                        |   38 ++++++
 .../libinput-sources/gf-candidate-area.c           |    4 +-
 .../libinput-sources/gf-candidate-popup.c          |  120 ++++++++++++++++++--
 3 files changed, 153 insertions(+), 9 deletions(-)
---
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
new file mode 100644
index 0000000..258342b
--- /dev/null
+++ b/.idea/codeStyleSettings.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectCodeStyleSettingsManager">
+    <option name="PER_PROJECT_SETTINGS">
+      <value>
+        <Objective-C-extensions>
+          <option name="GENERATE_INSTANCE_VARIABLES_FOR_PROPERTIES" value="ASK" />
+          <option name="RELEASE_STYLE" value="IVAR" />
+          <option name="TYPE_QUALIFIERS_PLACEMENT" value="BEFORE" />
+          <file>
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
+          </file>
+          <class>
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
+            <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
+          </class>
+          <extensions>
+            <pair source="cpp" header="h" />
+            <pair source="c" header="h" />
+          </extensions>
+        </Objective-C-extensions>
+      </value>
+    </option>
+    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Tilda" />
+  </component>
+</project>
\ No newline at end of file
diff --git a/gnome-flashback/libinput-sources/gf-candidate-area.c 
b/gnome-flashback/libinput-sources/gf-candidate-area.c
index 97b2932..534d01e 100644
--- a/gnome-flashback/libinput-sources/gf-candidate-area.c
+++ b/gnome-flashback/libinput-sources/gf-candidate-area.c
@@ -70,7 +70,7 @@ button_clicked_cb (GtkWidget *widget,
         index = i;
       }
     }
-  g_signal_emit (area,  signals[SIGNAL_CANDIDATE_CLICKED], 0, i, event);
+  g_signal_emit (area,  signals[SIGNAL_CANDIDATE_CLICKED], 0, index, event);
 
   return GDK_EVENT_PROPAGATE;
 }
@@ -233,6 +233,8 @@ gf_candidate_area_init (GfCandidateArea *area)
       gtk_container_add (GTK_CONTAINER (box), candidate_label);
       gtk_container_add (GTK_CONTAINER (area->box_layout), box);
 
+      gtk_widget_show_all (box);
+
       area->candidate_boxes = g_list_append (area->candidate_boxes, box);
 
       g_signal_connect (box, "button-release-event",
diff --git a/gnome-flashback/libinput-sources/gf-candidate-popup.c 
b/gnome-flashback/libinput-sources/gf-candidate-popup.c
index 94deb72..47b7816 100644
--- a/gnome-flashback/libinput-sources/gf-candidate-popup.c
+++ b/gnome-flashback/libinput-sources/gf-candidate-popup.c
@@ -17,6 +17,11 @@
 
 #include "config.h"
 
+/* _XOPEN_SOURCE macro needed for floor function from math library */
+#define _XOPEN_SOURCE 600
+
+#include "math.h"
+
 #include "gf-candidate-popup.h"
 #include "gf-candidate-area.h"
 
@@ -35,11 +40,32 @@ struct _GfCandidatePopup
   GtkWidget        *aux_text;
 
   GtkWidget        *box_layout;
+
+  gboolean          pre_edit_text_visible;
+  gboolean          aux_text_visible;
+  gboolean          candidate_area_visible;
 };
 
 G_DEFINE_TYPE (GfCandidatePopup, gf_candidate_popup, G_TYPE_OBJECT)
 
 static void
+update_visibility (GfCandidatePopup *popup)
+{
+  gboolean visible = popup->pre_edit_text_visible ||
+                     popup->aux_text_visible ||
+                     popup->candidate_area_visible;
+
+  if (visible)
+    {
+      // TODO: do something with the box pointer
+    }
+  else
+    {
+      // TODO: hide the box pointer
+    }
+}
+
+static void
 set_cursor_location_cb (IBusPanelService *service,
                         gint              x,
                         gint              y,
@@ -57,21 +83,49 @@ update_preedit_text_cb (IBusPanelService *service,
                         gboolean          visible,
                         gpointer          user_data)
 {
+  GfCandidatePopup *popup;
+  IBusAttrList *attributes;
+
   g_message ("update_preedit_text_cb");
+
+  popup = GF_CANDIDATE_POPUP (user_data);
+
+  gtk_label_set_text (GTK_LABEL (popup->pre_edit_text),
+                      ibus_text_get_text (text));
+
+  attributes = ibus_text_get_attributes (text);
+
+  if (attributes)
+  {
+    //TODO: set text attributes
+  }
+
 }
 
 static void
 show_preedit_text_cb (IBusPanelService *service,
                       gpointer          user_data)
 {
+  GfCandidatePopup *popup;
+
   g_message ("show_preedit_text_cb");
+
+  popup = GF_CANDIDATE_POPUP (user_data);
+
+  gtk_widget_show (popup->pre_edit_text);
 }
 
 static void
 hide_preedit_text_cb (IBusPanelService *service,
                       gpointer          user_data)
 {
+  GfCandidatePopup *popup;
+
   g_message ("hide_preedit_text_cb");
+
+  popup = GF_CANDIDATE_POPUP (user_data);
+
+  gtk_widget_hide (popup->pre_edit_text);
 }
 
 static void
@@ -87,14 +141,26 @@ static void
 show_auxiliary_text_cb (IBusPanelService *service,
                         gpointer          user_data)
 {
+  GfCandidatePopup *popup;
+
   g_message ("show_auxiliary_text_cb");
+
+  popup = GF_CANDIDATE_POPUP (user_data);
+
+  gtk_widget_show (popup->aux_text);
 }
 
 static void
 hide_auxiliary_text_cb (IBusPanelService *service,
                         gpointer          user_data)
 {
+  GfCandidatePopup *popup;
+
   g_message ("hide_auxiliary_text_cb");
+
+  popup = GF_CANDIDATE_POPUP (user_data);
+
+  gtk_widget_hide (popup->aux_text);
 }
 
 static void
@@ -103,7 +169,50 @@ update_lookup_table_cb (IBusPanelService *service,
                         gboolean          visible,
                         gpointer          user_data)
 {
-  //g_message ("update_lookup_table_cb");
+  GfCandidatePopup *popup;
+  guint n_candidates,
+        cursor_position,
+        page_size, n_pages, page,
+        start_index, end_index,
+        i;
+  GList *indexes, *candidates;
+  IBusText *index_label;
+
+  popup = GF_CANDIDATE_POPUP (user_data);
+  indexes = NULL;
+  candidates = NULL;
+
+  popup->candidate_area_visible = visible;
+  gtk_widget_set_visible (popup->window, visible);
+  n_candidates = ibus_lookup_table_get_number_of_candidates (lookup_table);
+  cursor_position = ibus_lookup_table_get_cursor_pos (lookup_table);
+  page_size = ibus_lookup_table_get_page_size (lookup_table);
+  page = ((cursor_position == 0) ? 0 :
+          (guint) floor (cursor_position / page_size));
+  start_index = page * page_size;
+  end_index = MIN ((page + 1) * page_size, n_candidates);
+
+  for (i = 0; (index_label = ibus_lookup_table_get_candidate (lookup_table, i)) != NULL; i++)
+    {
+      gchar *text;
+
+      text = g_strdup (ibus_text_get_text (index_label));
+      indexes = g_list_append (indexes, text);
+      g_free (text);
+    }
+
+  for (i = start_index; i < end_index; i++)
+    {
+      IBusText *ibus_text;
+      gchar* text;
+
+      ibus_text = ibus_lookup_table_get_candidate(lookup_table, i);
+      text = g_strdup (ibus_text_get_text(ibus_text));
+      candidates = g_list_append (candidates, text);
+      g_free (text);
+    }
+
+  gf_candidate_area_set_candidates (popup->candidateArea, indexes, candidates, cursor_position, visible);
 }
 
 static void
@@ -111,15 +220,12 @@ show_lookup_table_cb (IBusPanelService *service,
                       gpointer          user_data)
 {
   GfCandidatePopup *popup;
-  GtkWidget *box_layout;
 
   g_message ("show_lookup_table_cb");
 
   popup = GF_CANDIDATE_POPUP (user_data);
 
-  box_layout = gf_candidate_area_get_box_layout (popup->candidateArea);
-
-  gtk_widget_show (box_layout);
+  gtk_widget_show (popup->window);
 }
 
 static void
@@ -133,9 +239,7 @@ hide_lookup_table_cb (IBusPanelService *service,
 
   popup = GF_CANDIDATE_POPUP (user_data);
 
-  box_layout = gf_candidate_area_get_box_layout (popup->candidateArea);
-
-  gtk_widget_hide (box_layout);
+  gtk_widget_hide (popup->window);
 }
 
 static void


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