[gnome-flashback] input-sources: add GfCandidateBox



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

    input-sources: add GfCandidateBox

 gnome-flashback/libinput-sources/Makefile.am       |    2 +
 .../libinput-sources/gf-candidate-box.c            |  121 ++++++++++++++++++++
 .../libinput-sources/gf-candidate-box.h            |   39 +++++++
 3 files changed, 162 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..338445d
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.c
@@ -0,0 +1,121 @@
+/*
+ * 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 *box;
+
+  box = GF_CANDIDATE_BOX (object);
+
+  switch (property_id)
+    {
+      case PROP_INDEX:
+        box->index = g_value_get_uint (value);
+        break;
+
+      default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+        break;
+    }
+}
+
+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, G_MAXUINT, 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 *box)
+{
+  GtkWidget *hbox;
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_container_add (GTK_CONTAINER (box), hbox);
+  gtk_widget_show (hbox);
+
+  box->index_label = gtk_label_new (NULL);
+  gtk_container_add (GTK_CONTAINER (hbox), box->index_label);
+  gtk_widget_show (box->index_label);
+
+  box->candidate_label = gtk_label_new (NULL);
+  gtk_container_add (GTK_CONTAINER (hbox), box->candidate_label);
+  gtk_widget_show (box->candidate_label);
+}
+
+GtkWidget*
+gf_candidate_box_new (guint index)
+{
+  return g_object_new (GF_TYPE_CANDIDATE_BOX, "index", index, NULL);
+}
+
+void
+gf_candidate_box_set_labels (GfCandidateBox *box,
+                             const gchar    *index_label,
+                             const gchar    *candidate_label)
+{
+  gtk_label_set_text (GTK_LABEL (box->index_label), index_label);
+  gtk_label_set_text (GTK_LABEL (box->candidate_label), candidate_label);
+}
+
+guint
+gf_candidate_box_get_index (GfCandidateBox *box)
+{
+  return box->index;
+}
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..ae5febe
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.h
@@ -0,0 +1,39 @@
+/*
+ * 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);
+
+void       gf_candidate_box_set_labels (GfCandidateBox *box,
+                                        const gchar    *index_label,
+                                        const gchar    *candidate_label);
+
+guint      gf_candidate_box_get_index  (GfCandidateBox *box);
+
+G_END_DECLS
+
+#endif


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