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



commit 7d303769e149fbc0ce747e81b0862084b78f10e4
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            |  129 ++++++++++++++++++++
 .../libinput-sources/gf-candidate-box.h            |   41 ++++++
 3 files changed, 172 insertions(+), 0 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/Makefile.am b/gnome-flashback/libinput-sources/Makefile.am
index e7ce173..a26eb5a 100644
--- a/gnome-flashback/libinput-sources/Makefile.am
+++ b/gnome-flashback/libinput-sources/Makefile.am
@@ -15,6 +15,8 @@ libinput_sources_la_CFLAGS = \
        $(NULL)
 
 libinput_sources_la_SOURCES = \
+       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..03dac69
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.c
@@ -0,0 +1,129 @@
+/*
+ * 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 "gf-candidate-box.h"
+
+struct _GfCandidateBox
+{
+  GtkEventBox parent;
+
+  GtkWidget  *index_label;
+  GtkWidget  *candidate_label;
+
+  guint       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
+gf_candidate_box_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_uint (value);
+        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->set_property = gf_candidate_box_set_property;
+
+  properties[PROP_INDEX] =
+    g_param_spec_uint ("index", "index", "index", 0, INT_MAX, 0,
+                      G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE |
+                      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;
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_container_add (GTK_CONTAINER (candidate_box), box);
+
+  candidate_box->index_label = gtk_label_new (NULL);
+  candidate_box->candidate_label = gtk_label_new (NULL);
+
+  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 (guint index)
+{
+  return g_object_new (GF_TYPE_CANDIDATE_BOX,
+                       "index", index,
+                       NULL);
+}
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..4be90a4
--- /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 <gtk/gtk.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                 (guint           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]