color chooser: Use headerbar

Make GtkColorChooserDialog use a headerbar when desired.

https://bugzilla.gnome.org/show_bug.cgi?id=720059
This commit is contained in:
William Jon McCann 2013-12-08 15:13:25 +01:00 committed by Matthias Clasen
parent 3eb2430a98
commit 9c443b4a3c
3 changed files with 23 additions and 59 deletions

View File

@ -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);
}

View File

@ -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>

View File

@ -1,3 +1 @@
N_("Select a Color");
N_("_Cancel");
N_("_Select");