[gedit/wip/merge-encoding-settings] EncodingsDialog: add Reset button
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/merge-encoding-settings] EncodingsDialog: add Reset button
- Date: Sun, 22 Mar 2015 17:50:43 +0000 (UTC)
commit 86026bd376a8ed2174cb4dbbe4e7b92a0b862b31
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Mar 22 18:24:29 2015 +0100
EncodingsDialog: add Reset button
To not add a useless object attribute, use
gtk_widget_get_template_child(), since the reset_button is used in only
one function, we don't need to update its sensitivity or doing something
else with it. And it's better to limit the number of attributes.
gedit/gedit-encodings-dialog.c | 47 ++++++++++++++++++++++++++
gedit/resources/ui/gedit-encodings-dialog.ui | 16 +++++++++
2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-encodings-dialog.c b/gedit/gedit-encodings-dialog.c
index 2ff7fc1..ea476ed 100644
--- a/gedit/gedit-encodings-dialog.c
+++ b/gedit/gedit-encodings-dialog.c
@@ -153,6 +153,7 @@ gedit_encodings_dialog_class_init (GeditEncodingsDialogClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GeditEncodingsDialog, remove_button);
gtk_widget_class_bind_template_child_private (widget_class, GeditEncodingsDialog, up_button);
gtk_widget_class_bind_template_child_private (widget_class, GeditEncodingsDialog, down_button);
+ gtk_widget_class_bind_template_child_full (widget_class, "reset_button", FALSE, 0);
}
static void
@@ -458,9 +459,46 @@ init_liststores (GeditEncodingsDialog *dialog)
}
static void
+reset_button_clicked_cb (GtkWidget *button,
+ GeditEncodingsDialog *dialog)
+{
+ GtkDialog *msg_dialog;
+ gint response;
+
+ msg_dialog = GTK_DIALOG (gtk_message_dialog_new (GTK_WINDOW (dialog),
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ "%s",
+ _("Do you really want to reset the "
+ "character encodings' preferences?")));
+
+ gtk_dialog_add_buttons (msg_dialog,
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Reset"), GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ response = gtk_dialog_run (msg_dialog);
+
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ g_settings_reset (dialog->priv->enc_settings, GEDIT_SETTINGS_CANDIDATE_ENCODINGS);
+
+ gtk_list_store_clear (dialog->priv->liststore_available);
+ gtk_list_store_clear (dialog->priv->liststore_chosen);
+
+ init_liststores (dialog);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (msg_dialog));
+}
+
+static void
gedit_encodings_dialog_init (GeditEncodingsDialog *dialog)
{
GtkTreeSelection *selection;
+ GtkButton *reset_button;
dialog->priv = gedit_encodings_dialog_get_instance_private (dialog);
@@ -517,6 +555,15 @@ gedit_encodings_dialog_init (GeditEncodingsDialog *dialog)
"clicked",
G_CALLBACK (down_button_clicked_cb),
dialog);
+
+ reset_button = GTK_BUTTON (gtk_widget_get_template_child (GTK_WIDGET (dialog),
+ GEDIT_TYPE_ENCODINGS_DIALOG,
+ "reset_button"));
+
+ g_signal_connect (reset_button,
+ "clicked",
+ G_CALLBACK (reset_button_clicked_cb),
+ dialog);
}
GtkWidget *
diff --git a/gedit/resources/ui/gedit-encodings-dialog.ui b/gedit/resources/ui/gedit-encodings-dialog.ui
index 6abdeec..9211d20 100644
--- a/gedit/resources/ui/gedit-encodings-dialog.ui
+++ b/gedit/resources/ui/gedit-encodings-dialog.ui
@@ -304,6 +304,22 @@
<property name="top_attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="reset_button">
+ <property name="label" translatable="yes">_Reset</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]