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



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

    input-sources: implement candidate-box

 .../libinput-sources/gf-candidate-box.c            |   98 ++++++++++++++++++++
 .../libinput-sources/gf-candidate-box.h            |   41 ++++++++
 2 files changed, 139 insertions(+), 0 deletions(-)
---
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..d189e02
--- /dev/null
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.c
@@ -0,0 +1,98 @@
+/*
+ * 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;
+};
+
+enum
+{
+  PROP_0,
+
+  PROP_INDEX,
+  PROP_INDEX_LABEL,
+  PROP_CANDIDATE_LABEL,
+
+  LAST_PROP
+};
+
+static GParamSpec *properties[LAST_PROP] = { 0 };
+
+G_DEFINE_TYPE (GfCandidateBox, gf_candidate_box, GTK_TYPE_EVENT_BOX)
+
+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->index_label),
+                      candidate_label);
+}
+
+static void
+gf_candidate_box_class_init (GfCandidateBoxClass *box_class)
+{
+  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);
+}
+
+static void
+gf_candidate_box_init (GfCandidateBox *candidate_box)
+{
+  GtkWidget *box,
+            *index_label,
+            *candidate_label;
+
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_container_add (GTK_CONTAINER (candidate_box), box);
+
+  index_label = gtk_label_new (NULL);
+  candidate_label = gtk_label_new (NULL);
+
+  gtk_container_add (GTK_CONTAINER (box), index_label);
+  gtk_container_add (GTK_CONTAINER (box), candidate_label);
+
+  gtk_widget_show_all (GTK_WIDGET (candidate_box));
+}
+
+GtkWidget *gf_candidate_box_new (gint index,
+                                 const gchar* index_label,
+                                 const gchar* candidate_label)
+{
+  return g_object_new (GF_TYPE_CANDIDATE_BOX,
+                       "index", index,
+                       "index_label", index_label,
+                       "candidate_label", candidate_label,
+                       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..89eb6e3
--- /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,
+                                                 const gchar* index_label,
+                                                 const gchar* candidate_label);
+
+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]