Commit be89df32 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

input-sources: add selected pseudo class to GfCandidateBox

parent 28d1a0c3
......@@ -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);
}
}
......
......@@ -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);
}
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment