[gspell] language-chooser-dialog: add a GtkDialogFlags parameter
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] language-chooser-dialog: add a GtkDialogFlags parameter
- Date: Fri, 20 Nov 2015 16:07:14 +0000 (UTC)
commit 454924b3427e0331cbb99ac6bfb4653045f87182
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Nov 20 15:14:20 2015 +0100
language-chooser-dialog: add a GtkDialogFlags parameter
To be able to use an headerbar and have more options.
The app must have the choice to use an headerbar when using directly the
dialog, because for some cases it is not suitable. For example in gedit,
a Help button is added, but with an headerbar it is not ideal.
For the LanguageChooserButton, use an headerbar for the dialog, since it
is not possible to add more buttons in that case and an headerbar looks
nicer in my opinion.
gspell/gspell-language-chooser-button.c | 7 +++++--
gspell/gspell-language-chooser-dialog.c | 29 ++++++++++++++++++++++++++++-
gspell/gspell-language-chooser-dialog.h | 3 ++-
gspell/resources/language-dialog.ui | 2 --
4 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/gspell/gspell-language-chooser-button.c b/gspell/gspell-language-chooser-button.c
index 0eef2fa..b04914d 100644
--- a/gspell/gspell-language-chooser-button.c
+++ b/gspell/gspell-language-chooser-button.c
@@ -202,8 +202,11 @@ ensure_dialog (GspellLanguageChooserButton *button)
parent = GTK_WINDOW (toplevel);
}
- priv->dialog = GSPELL_LANGUAGE_CHOOSER_DIALOG (gspell_language_chooser_dialog_new (parent,
- priv->language));
+ priv->dialog = GSPELL_LANGUAGE_CHOOSER_DIALOG (
+ gspell_language_chooser_dialog_new (parent,
+ priv->language,
+ GTK_DIALOG_DESTROY_WITH_PARENT |
+ GTK_DIALOG_USE_HEADER_BAR));
if (parent != NULL)
{
diff --git a/gspell/gspell-language-chooser-dialog.c b/gspell/gspell-language-chooser-dialog.c
index a4ea095..76c09f9 100644
--- a/gspell/gspell-language-chooser-dialog.c
+++ b/gspell/gspell-language-chooser-dialog.c
@@ -221,6 +221,27 @@ gspell_language_chooser_dialog_set_property (GObject *object,
}
static void
+gspell_language_chooser_dialog_constructed (GObject *object)
+{
+ gint use_header_bar;
+
+ if (G_OBJECT_CLASS (gspell_language_chooser_dialog_parent_class)->constructed != NULL)
+ {
+ G_OBJECT_CLASS (gspell_language_chooser_dialog_parent_class)->constructed (object);
+ }
+
+ g_object_get (object,
+ "use-header-bar", &use_header_bar,
+ NULL);
+
+ if (use_header_bar)
+ {
+ /* Avoid the title being ellipsized, if possible (for translations too). */
+ gtk_widget_set_size_request (GTK_WIDGET (object), 450, -1);
+ }
+}
+
+static void
dialog_response_cb (GtkDialog *gtk_dialog,
gint response)
{
@@ -265,6 +286,7 @@ gspell_language_chooser_dialog_class_init (GspellLanguageChooserDialogClass *kla
object_class->get_property = gspell_language_chooser_dialog_get_property;
object_class->set_property = gspell_language_chooser_dialog_set_property;
+ object_class->constructed = gspell_language_chooser_dialog_constructed;
g_object_class_override_property (object_class, PROP_LANGUAGE, "language");
@@ -373,18 +395,23 @@ gspell_language_chooser_dialog_init (GspellLanguageChooserDialog *dialog)
* gspell_language_chooser_dialog_new:
* @parent: transient parent of the dialog.
* @current_language: the #GspellLanguage to select initially.
+ * @flags: #GtkDialogFlags
*
* Returns: a new #GspellLanguageChooserDialog widget.
*/
GtkWidget *
gspell_language_chooser_dialog_new (GtkWindow *parent,
- const GspellLanguage *current_language)
+ const GspellLanguage *current_language,
+ GtkDialogFlags flags)
{
g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
return g_object_new (GSPELL_TYPE_LANGUAGE_CHOOSER_DIALOG,
"transient-for", parent,
"language", current_language,
+ "modal", (flags & GTK_DIALOG_MODAL) != 0,
+ "destroy-with-parent", (flags & GTK_DIALOG_DESTROY_WITH_PARENT) != 0,
+ "use-header-bar", (flags & GTK_DIALOG_USE_HEADER_BAR) != 0,
NULL);
}
diff --git a/gspell/gspell-language-chooser-dialog.h b/gspell/gspell-language-chooser-dialog.h
index 595b41d..62effc3 100644
--- a/gspell/gspell-language-chooser-dialog.h
+++ b/gspell/gspell-language-chooser-dialog.h
@@ -40,7 +40,8 @@ struct _GspellLanguageChooserDialogClass
};
GtkWidget * gspell_language_chooser_dialog_new (GtkWindow *parent,
- const GspellLanguage *current_language);
+ const GspellLanguage *current_language,
+ GtkDialogFlags flags);
G_END_DECLS
diff --git a/gspell/resources/language-dialog.ui b/gspell/resources/language-dialog.ui
index 24a7735..c227c07 100644
--- a/gspell/resources/language-dialog.ui
+++ b/gspell/resources/language-dialog.ui
@@ -6,8 +6,6 @@
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="title" translatable="yes">Set Language</property>
- <property name="modal">True</property>
- <property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]