[gnome-flashback/wip/segeiger/gnome-3-18-inputmethods: 3/5] input-sources: implement candidate-box



commit 3ca809299c696ecea483b9e9dfa6ad22b5ec7227
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sun Jan 17 15:38:40 2016 +0100

    input-sources: implement candidate-box

 gnome-flashback/libinput-sources/Makefile.am       |    2 +
 .../libinput-sources/gf-candidate-box.c            |  161 ++++++++++++++++++++
 .../libinput-sources/gf-candidate-box.h            |   41 +++++
 3 files changed, 204 insertions(+), 0 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/Makefile.am b/gnome-flashback/libinput-sources/Makefile.am
index 80fb88d..b5612e2 100644
--- a/gnome-flashback/libinput-sources/Makefile.am
+++ b/gnome-flashback/libinput-sources/Makefile.am
@@ -17,6 +17,8 @@ libinput_sources_la_CFLAGS = \
 libinput_sources_la_SOURCES = \
        gf-candidate-area.c \
        gf-candidate-area.h \
+       gf-candidate-box.c \
+       gf-candidate-box.h \
        gf-candidate-popup.c \
        gf-candidate-popup.h \
        gf-ibus-manager.c \
diff --git a/gnome-flashback/libinput-sources/gf-candidate-box.c 
b/gnome-flashback/libinput-sources/gf-candidate-box.c
new file mode 100644
index 0000000..e296b2d
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2016 Sebastian Geiger
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "gf-candidate-box.h"
+
+struct _GfCandidateBox
+{
+  GtkEventBox parent;
+
+  GtkWidget *index_label;
+  GtkWidget *candidate_label;
+
+  gint index;
+};
+
+enum
+{
+  PROP_0,
+
+  PROP_INDEX,
+
+  LAST_PROP
+};
+
+static GParamSpec *properties[LAST_PROP] = { NULL };
+
+G_DEFINE_TYPE (GfCandidateBox, gf_candidate_box, GTK_TYPE_EVENT_BOX)
+
+static void
+set_property (GObject        *object,
+              guint           property_id,
+              const GValue   *value,
+              GParamSpec     *pspec)
+{
+  GfCandidateBox *candidate_box;
+
+  candidate_box = GF_CANDIDATE_BOX (object);
+
+  switch (property_id)
+    {
+      case PROP_INDEX:
+        candidate_box->index = g_value_get_int (value);
+        break;
+
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+static void
+get_property (GObject        *object,
+              guint           property_id,
+              GValue         *value,
+              GParamSpec     *pspec)
+{
+  GfCandidateBox *candidate_box;
+
+  candidate_box = GF_CANDIDATE_BOX (object);
+
+  switch (property_id)
+    {
+      case PROP_INDEX:
+        g_value_set_int (value, candidate_box->index);
+        break;
+
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+gint
+gf_candidate_box_get_index (GfCandidateBox *candidate_box)
+{
+  return candidate_box->index;
+}
+
+void
+gf_candidate_box_set_index_label (GfCandidateBox *candidate_box,
+                                  const gchar *index_label)
+{
+  gtk_label_set_text (GTK_LABEL (candidate_box->index_label),
+                      index_label);
+}
+
+void
+gf_candidate_box_set_candidate_label (GfCandidateBox *candidate_box,
+                                      const gchar *candidate_label)
+{
+  gtk_label_set_text (GTK_LABEL (candidate_box->candidate_label),
+                      candidate_label);
+}
+
+static void
+gf_candidate_box_class_init (GfCandidateBoxClass *box_class)
+{
+  GObjectClass *object_class;
+
+  object_class = G_OBJECT_CLASS (box_class);
+
+  object_class->get_property = get_property;
+  object_class->set_property = set_property;
+
+  properties[PROP_INDEX] =
+    g_param_spec_int ("index", "index", "index", -1, INT_MAX, 0,
+                      G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
+                      G_PARAM_STATIC_STRINGS);
+
+  g_object_class_install_properties (object_class, LAST_PROP, properties);
+}
+
+static void
+gf_candidate_box_init (GfCandidateBox *candidate_box)
+{
+  GtkWidget *box;
+  GtkStyleContext *context;
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  context = gtk_widget_get_style_context (box);
+  gtk_style_context_add_class (context, "candidate-box");
+  gtk_container_add (GTK_CONTAINER (candidate_box), box);
+
+  candidate_box->index_label = gtk_label_new (NULL);
+  context = gtk_widget_get_style_context (candidate_box->index_label);
+  gtk_style_context_add_class (context, "candidate-index");
+
+  candidate_box->candidate_label = gtk_label_new (NULL);
+  context = gtk_widget_get_style_context (candidate_box->candidate_label);
+  gtk_style_context_add_class (context, "candidate-label");
+
+  gtk_container_add (GTK_CONTAINER (box), candidate_box->index_label);
+  gtk_container_add (GTK_CONTAINER (box), candidate_box->candidate_label);
+
+  gtk_widget_show_all (GTK_WIDGET (candidate_box));
+}
+
+GtkWidget *gf_candidate_box_new (gint index)
+{
+  return g_object_new (GF_TYPE_CANDIDATE_BOX,
+                       "index", index,
+                       NULL);
+}
\ No newline at end of file
diff --git a/gnome-flashback/libinput-sources/gf-candidate-box.h 
b/gnome-flashback/libinput-sources/gf-candidate-box.h
new file mode 100644
index 0000000..ea5e2b2
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 Sebastian Geiger
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GF_CANDIDATE_BOX_H
+#define GF_CANDIDATE_BOX_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GF_TYPE_CANDIDATE_BOX gf_candidate_box_get_type ()
+G_DECLARE_FINAL_TYPE (GfCandidateBox, gf_candidate_box,
+                      GF, CANDIDATE_BOX, GtkEventBox)
+
+GtkWidget   *gf_candidate_box_new                 (gint index);
+
+gint         gf_candidate_box_get_index           (GfCandidateBox *candidate_box);
+
+void         gf_candidate_box_set_index_label     (GfCandidateBox *candidate_box,
+                                                   const gchar    *index_label);
+
+void         gf_candidate_box_set_candidate_label (GfCandidateBox *candidate_box,
+                                                   const gchar    *candidate_label);
+
+G_END_DECLS
+
+#endif


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