[gnome-flashback] input-sources: add selected pseudo class to GfCandidateBox
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] input-sources: add selected pseudo class to GfCandidateBox
- Date: Mon, 18 Jan 2016 11:14:23 +0000 (UTC)
commit be89df320f7465bac917e3be5c58636fa9cded95
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Jan 18 12:58:35 2016 +0200
input-sources: add selected pseudo class to GfCandidateBox
.../libinput-sources/gf-candidate-area.c | 3 ++
.../libinput-sources/gf-candidate-box.c | 31 ++++++++++++++++++-
.../libinput-sources/gf-candidate-box.h | 13 +++++---
3 files changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-candidate-area.c
b/gnome-flashback/libinput-sources/gf-candidate-area.c
index 8ca69af..87a18be 100644
--- a/gnome-flashback/libinput-sources/gf-candidate-area.c
+++ b/gnome-flashback/libinput-sources/gf-candidate-area.c
@@ -263,6 +263,9 @@ gf_candidate_area_set_candidates (GfCandidateArea *area,
gf_candidate_box_set_labels (GF_CANDIDATE_BOX (candidate_box),
index_text, candidate_text);
+
+ gf_candidate_box_set_selected (GF_CANDIDATE_BOX (candidate_box),
+ cursor_visible && i == cursor_position);
}
}
diff --git a/gnome-flashback/libinput-sources/gf-candidate-box.c
b/gnome-flashback/libinput-sources/gf-candidate-box.c
index 8d70867..298e2a1 100644
--- a/gnome-flashback/libinput-sources/gf-candidate-box.c
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.c
@@ -23,10 +23,12 @@ struct _GfCandidateBox
{
GtkEventBox parent;
+ guint index;
+
GtkWidget *index_label;
GtkWidget *candidate_label;
- guint index;
+ gboolean selected;
};
enum
@@ -77,7 +79,16 @@ static gboolean
gf_candidate_box_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
- gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_NORMAL, TRUE);
+ GfCandidateBox *box;
+ GtkStateFlags flags;
+
+ box = GF_CANDIDATE_BOX (widget);
+ flags = GTK_STATE_FLAG_NORMAL;
+
+ if (box->selected)
+ flags |= GTK_STATE_FLAG_SELECTED;
+
+ gtk_widget_set_state_flags (widget, flags, TRUE);
return GDK_EVENT_PROPAGATE;
}
@@ -144,3 +155,19 @@ gf_candidate_box_get_index (GfCandidateBox *box)
{
return box->index;
}
+
+void
+gf_candidate_box_set_selected (GfCandidateBox *box,
+ gboolean selected)
+{
+ GtkStateFlags flags;
+
+ if (box->selected == selected)
+ return;
+
+ box->selected = selected;
+
+ flags = selected ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_NORMAL;
+
+ gtk_widget_set_state_flags (GTK_WIDGET (box), flags, TRUE);
+}
diff --git a/gnome-flashback/libinput-sources/gf-candidate-box.h
b/gnome-flashback/libinput-sources/gf-candidate-box.h
index ae5febe..9c39e9d 100644
--- a/gnome-flashback/libinput-sources/gf-candidate-box.h
+++ b/gnome-flashback/libinput-sources/gf-candidate-box.h
@@ -26,13 +26,16 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GfCandidateBox, gf_candidate_box,
GF, CANDIDATE_BOX, GtkEventBox)
-GtkWidget *gf_candidate_box_new (guint index);
+GtkWidget *gf_candidate_box_new (guint index);
-void gf_candidate_box_set_labels (GfCandidateBox *box,
- const gchar *index_label,
- const gchar *candidate_label);
+void gf_candidate_box_set_labels (GfCandidateBox *box,
+ const gchar *index_label,
+ const gchar *candidate_label);
-guint gf_candidate_box_get_index (GfCandidateBox *box);
+guint gf_candidate_box_get_index (GfCandidateBox *box);
+
+void gf_candidate_box_set_selected (GfCandidateBox *box,
+ gboolean selected);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]