[gnome-control-center] region: "move up" and "move down" buttons in input row menu
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] region: "move up" and "move down" buttons in input row menu
- Date: Tue, 15 Sep 2020 22:18:20 +0000 (UTC)
commit 0dce812e18dc60b351318453b317608a31522454
Author: Ian Douglas Scott <idscott system76 com>
Date: Tue Sep 15 09:22:51 2020 -0700
region: "move up" and "move down" buttons in input row menu
Implementation borrowed from cc-search-panel-row.c
panels/region/cc-input-row.c | 45 ++++++++++++++++++++++++++++++++++++++++---
panels/region/cc-input-row.ui | 40 ++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 3 deletions(-)
---
diff --git a/panels/region/cc-input-row.c b/panels/region/cc-input-row.c
index eadc20443..bc38d9bef 100644
--- a/panels/region/cc-input-row.c
+++ b/panels/region/cc-input-row.c
@@ -29,6 +29,7 @@ struct _CcInputRow
GtkLabel *name_label;
GtkButton *remove_button;
GtkButton *settings_button;
+ GtkSeparator *settings_separator;
GtkListBox *drag_widget;
};
@@ -112,6 +113,40 @@ drag_data_received_cb (CcInputRow *self,
self);
}
+static void
+move_up_button_clicked_cb (CcInputRow *self,
+ GtkButton *button)
+{
+ GtkListBox *list_box = GTK_LIST_BOX (gtk_widget_get_parent (GTK_WIDGET (self)));
+ gint previous_idx = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (self)) - 1;
+ GtkListBoxRow *previous_row = gtk_list_box_get_row_at_index (list_box, previous_idx);
+
+ if (previous_row == NULL)
+ return;
+
+ g_signal_emit (self,
+ signals[SIGNAL_MOVE_ROW],
+ 0,
+ previous_row);
+}
+
+static void
+move_down_button_clicked_cb (CcInputRow *self,
+ GtkButton *button)
+{
+ GtkListBox *list_box = GTK_LIST_BOX (gtk_widget_get_parent (GTK_WIDGET (self)));
+ gint next_idx = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (self)) + 1;
+ GtkListBoxRow *next_row = gtk_list_box_get_row_at_index (list_box, next_idx);
+
+ if (next_row == NULL)
+ return;
+
+ g_signal_emit (next_row,
+ signals[SIGNAL_MOVE_ROW],
+ 0,
+ self);
+}
+
static void
settings_button_clicked_cb (CcInputRow *self)
{
@@ -160,14 +195,17 @@ cc_input_row_class_init (CcInputRowClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcInputRow, name_label);
gtk_widget_class_bind_template_child (widget_class, CcInputRow, remove_button);
gtk_widget_class_bind_template_child (widget_class, CcInputRow, settings_button);
+ gtk_widget_class_bind_template_child (widget_class, CcInputRow, settings_separator);
- gtk_widget_class_bind_template_callback (widget_class, drag_data_get_cb);
gtk_widget_class_bind_template_callback (widget_class, drag_begin_cb);
- gtk_widget_class_bind_template_callback (widget_class, drag_end_cb);
+ gtk_widget_class_bind_template_callback (widget_class, drag_data_get_cb);
gtk_widget_class_bind_template_callback (widget_class, drag_data_received_cb);
+ gtk_widget_class_bind_template_callback (widget_class, drag_end_cb);
gtk_widget_class_bind_template_callback (widget_class, layout_button_clicked_cb);
- gtk_widget_class_bind_template_callback (widget_class, settings_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, move_down_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, move_up_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, remove_button_clicked_cb);
+ gtk_widget_class_bind_template_callback (widget_class, settings_button_clicked_cb);
signals[SIGNAL_SHOW_SETTINGS] =
g_signal_new ("show-settings",
@@ -243,6 +281,7 @@ cc_input_row_new (CcInputSource *source)
label_changed_cb (self);
gtk_widget_set_visible (GTK_WIDGET (self->settings_button), CC_IS_INPUT_SOURCE_IBUS (source));
+ gtk_widget_set_visible (GTK_WIDGET (self->settings_separator), CC_IS_INPUT_SOURCE_IBUS (source));
return self;
}
diff --git a/panels/region/cc-input-row.ui b/panels/region/cc-input-row.ui
index cb98c58f1..4021175c2 100644
--- a/panels/region/cc-input-row.ui
+++ b/panels/region/cc-input-row.ui
@@ -68,6 +68,34 @@
<property name="can-focus">False</property>
<property name="margin">6</property>
<property name="orientation">vertical</property>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Move up</property>
+ <signal name="clicked" handler="move_up_button_clicked_cb" object="CcInputRow" swapped="yes"/>
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Move down</property>
+ <signal name="clicked" handler="move_down_button_clicked_cb" object="CcInputRow" swapped="yes"/>
+ <style>
+ <class name="flat"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ </object>
+ </child>
<child>
<object class="GtkButton" id="settings_button">
<property name="visible">False</property>
@@ -79,6 +107,12 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkSeparator" id="settings_separator">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ </object>
+ </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
@@ -90,6 +124,12 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ </object>
+ </child>
<child>
<object class="GtkButton" id="remove_button">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]