[gtk+/dialogs: 15/25] color chooser: Use headerbar
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/dialogs: 15/25] color chooser: Use headerbar
- Date: Wed, 15 Jan 2014 12:33:36 +0000 (UTC)
commit 5a99500355799a752584fe32446173b5fb605ed2
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 | 36 ++++++++++++++++++++++-------
gtk/gtkcolorchooserdialog.ui | 48 ----------------------------------------
gtk/gtkcolorchooserdialog.ui.h | 2 -
3 files changed, 27 insertions(+), 59 deletions(-)
---
diff --git a/gtk/gtkcolorchooserdialog.c b/gtk/gtkcolorchooserdialog.c
index 1998cbd..d2543c0 100644
--- a/gtk/gtkcolorchooserdialog.c
+++ b/gtk/gtkcolorchooserdialog.c
@@ -22,6 +22,7 @@
#include "gtkbox.h"
#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtksettings.h"
#include "gtkcolorchooserprivate.h"
#include "gtkcolorchooserdialog.h"
@@ -42,9 +43,6 @@
struct _GtkColorChooserDialogPrivate
{
GtkWidget *chooser;
-
- GtkWidget *select_button;
- GtkWidget *cancel_button;
};
enum
@@ -92,10 +90,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 +104,21 @@ 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_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 +218,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);
}
@@ -265,8 +277,14 @@ gtk_color_chooser_dialog_new (const gchar *title,
GtkWindow *parent)
{
GtkColorChooserDialog *dialog;
+ gboolean use_header;
+ g_object_get (gtk_settings_get_default (),
+ "gtk-dialogs-use-header", &use_header,
+ NULL);
+ g_print ("use header: %d\n", use_header);
dialog = g_object_new (GTK_TYPE_COLOR_CHOOSER_DIALOG,
+ "use-header-bar", use_header,
"title", title,
"transient-for", parent,
NULL);
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]