[gtk+] color chooser: Use headerbar
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] color chooser: Use headerbar
- Date: Fri, 17 Jan 2014 23:04:22 +0000 (UTC)
commit 9c443b4a3cbff984efa1f353a09bde3e3fe9deeb
Author: William Jon McCann <william jon mccann gmail com>
Date: Sun Dec 8 15:13:25 2013 +0100
color chooser: Use headerbar
Make GtkColorChooserDialog use a headerbar when desired.
https://bugzilla.gnome.org/show_bug.cgi?id=720059
gtk/gtkcolorchooserdialog.c | 32 +++++++++++++++++++-------
gtk/gtkcolorchooserdialog.ui | 48 ----------------------------------------
gtk/gtkcolorchooserdialog.ui.h | 2 -
3 files changed, 23 insertions(+), 59 deletions(-)
---
diff --git a/gtk/gtkcolorchooserdialog.c b/gtk/gtkcolorchooserdialog.c
index 1998cbd..f9316b1 100644
--- a/gtk/gtkcolorchooserdialog.c
+++ b/gtk/gtkcolorchooserdialog.c
@@ -18,10 +18,12 @@
#include "config.h"
#include "gtkdialog.h"
+#include "gtkdialogprivate.h"
#include "gtkbutton.h"
#include "gtkbox.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtksettings.h"
#include "gtkcolorchooserprivate.h"
#include "gtkcolorchooserdialog.h"
@@ -42,9 +44,6 @@
struct _GtkColorChooserDialogPrivate
{
GtkWidget *chooser;
-
- GtkWidget *select_button;
- GtkWidget *cancel_button;
};
enum
@@ -92,10 +91,12 @@ color_activated_cb (GtkColorChooser *chooser,
}
static void
-selected_cb (GtkButton *button,
- GtkDialog *dialog)
+gtk_color_chooser_dialog_response (GtkDialog *dialog,
+ gint response_id,
+ gpointer user_data)
{
- save_color (GTK_COLOR_CHOOSER_DIALOG (dialog));
+ if (response_id == GTK_RESPONSE_OK)
+ save_color (GTK_COLOR_CHOOSER_DIALOG (dialog));
}
static void
@@ -104,6 +105,22 @@ gtk_color_chooser_dialog_init (GtkColorChooserDialog *cc)
cc->priv = gtk_color_chooser_dialog_get_instance_private (cc);
gtk_widget_init_template (GTK_WIDGET (cc));
+ gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (cc));
+ gtk_dialog_add_buttons (GTK_DIALOG (cc),
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Select"), GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (cc), GTK_RESPONSE_OK);
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (cc),
+ GTK_RESPONSE_OK,
+ GTK_RESPONSE_CANCEL,
+ -1);
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ g_signal_connect (cc, "response",
+ G_CALLBACK (gtk_color_chooser_dialog_response), NULL);
}
static void
@@ -203,9 +220,6 @@ gtk_color_chooser_dialog_class_init (GtkColorChooserDialogClass *class)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/libgtk/gtkcolorchooserdialog.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkColorChooserDialog, chooser);
- gtk_widget_class_bind_template_child_private (widget_class, GtkColorChooserDialog, cancel_button);
- gtk_widget_class_bind_template_child_private (widget_class, GtkColorChooserDialog, select_button);
- gtk_widget_class_bind_template_callback (widget_class, selected_cb);
gtk_widget_class_bind_template_callback (widget_class, propagate_notify);
gtk_widget_class_bind_template_callback (widget_class, color_activated_cb);
}
diff --git a/gtk/gtkcolorchooserdialog.ui b/gtk/gtkcolorchooserdialog.ui
index 7f5c4c5..8a64c4a 100644
--- a/gtk/gtkcolorchooserdialog.ui
+++ b/gtk/gtkcolorchooserdialog.ui
@@ -11,50 +11,6 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="select_button">
- <property name="label" translatable="yes">_Select</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="selected_cb" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
<child>
<object class="GtkColorChooserWidget" id="chooser">
<property name="visible">True</property>
@@ -74,9 +30,5 @@
</child>
</object>
</child>
- <action-widgets>
- <action-widget response="-6">cancel_button</action-widget>
- <action-widget response="-5">select_button</action-widget>
- </action-widgets>
</template>
</interface>
diff --git a/gtk/gtkcolorchooserdialog.ui.h b/gtk/gtkcolorchooserdialog.ui.h
index af0ef00..bc17571 100644
--- a/gtk/gtkcolorchooserdialog.ui.h
+++ b/gtk/gtkcolorchooserdialog.ui.h
@@ -1,3 +1 @@
N_("Select a Color");
-N_("_Cancel");
-N_("_Select");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]