From bf9bfd06ca0671d0c7cd5354dc02fb8b39f4b350 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 5 Jul 2005 14:53:37 +0000 Subject: [PATCH] Add a GtkAboutDialog::wrap-license property --- ChangeLog | 7 +++ ChangeLog.pre-2-10 | 7 +++ ChangeLog.pre-2-8 | 7 +++ docs/reference/ChangeLog | 4 ++ docs/reference/gtk/gtk-sections.txt | 2 + gtk/gtk.symbols | 2 + gtk/gtkaboutdialog.c | 86 ++++++++++++++++++++++++++++- gtk/gtkaboutdialog.h | 5 ++ 8 files changed, 117 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 484c156c56..eb6b1112c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-07-05 Matthias Clasen + + * gtk/gtk.symbols: + * gtk/gtkaboutdialog.[hc]: Add a wrap-license property + with getter and setter. (#165012, Christian Rose, + based on a patch by Christian Persch) + 2005-07-05 Matthias Clasen * gdk/Makefile.am: Distribute the keyname-table.h header diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 484c156c56..eb6b1112c6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2005-07-05 Matthias Clasen + + * gtk/gtk.symbols: + * gtk/gtkaboutdialog.[hc]: Add a wrap-license property + with getter and setter. (#165012, Christian Rose, + based on a patch by Christian Persch) + 2005-07-05 Matthias Clasen * gdk/Makefile.am: Distribute the keyname-table.h header diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 484c156c56..eb6b1112c6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2005-07-05 Matthias Clasen + + * gtk/gtk.symbols: + * gtk/gtkaboutdialog.[hc]: Add a wrap-license property + with getter and setter. (#165012, Christian Rose, + based on a patch by Christian Persch) + 2005-07-05 Matthias Clasen * gdk/Makefile.am: Distribute the keyname-table.h header diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 2aaf298f87..0e1500bc16 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2005-07-05 Matthias Clasen + + * gtk/gtk-sections.txt: Add new api. + 2005-07-04 Matthias Clasen * gtk/framebuffer.sgml: Add a warning. diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 2779236b94..a51905e7a9 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -16,6 +16,8 @@ gtk_about_dialog_get_comments gtk_about_dialog_set_comments gtk_about_dialog_get_license gtk_about_dialog_set_license +gtk_about_dialog_get_wrap_license +gtk_about_dialog_set_wrap_license gtk_about_dialog_get_website gtk_about_dialog_set_website gtk_about_dialog_get_website_label diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index ba9b06356f..d6e84cc925 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -37,6 +37,7 @@ gtk_about_dialog_get_type G_GNUC_CONST gtk_about_dialog_get_version gtk_about_dialog_get_website gtk_about_dialog_get_website_label +gtk_about_dialog_get_wrap_license gtk_about_dialog_new gtk_about_dialog_set_artists gtk_about_dialog_set_authors @@ -53,6 +54,7 @@ gtk_about_dialog_set_url_hook gtk_about_dialog_set_version gtk_about_dialog_set_website gtk_about_dialog_set_website_label +gtk_about_dialog_set_wrap_license #endif #endif diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index 59eaeac7f2..c65553ebba 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -84,6 +84,7 @@ struct _GtkAboutDialogPrivate GdkCursor *hand_cursor; GdkCursor *regular_cursor; gboolean hovering_over_link; + gboolean wrap_license; }; #define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate)) @@ -104,7 +105,8 @@ enum PROP_TRANSLATOR_CREDITS, PROP_ARTISTS, PROP_LOGO, - PROP_LOGO_ICON_NAME + PROP_LOGO_ICON_NAME, + PROP_WRAP_LICENSE }; static void gtk_about_dialog_finalize (GObject *object); @@ -259,8 +261,9 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass) * * The license of the program. This string is displayed in a * text view in a secondary dialog, therefore it is fine to use - * a long multi-paragraph text. Note that the text is not wrapped - * in the text view, thus it must contain the intended linebreaks. + * a long multi-paragraph text. Note that the text is only wrapped + * in the text view if the "wrap-license" property is set to %TRUE; + * otherwise the text itself must contain the intended linebreaks. * * Since: 2.6 */ @@ -405,6 +408,20 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass) P_("A named icon to use as the logo for the about box."), NULL, GTK_PARAM_READWRITE)); + /** + * GtkAboutDialog:wrap-license: + * + * Whether to wrap the text in the license dialog. + * + * Since: 2.6 + */ + g_object_class_install_property (object_class, + PROP_WRAP_LICENSE, + g_param_spec_boolean ("wrap-license", + P_("Wrap license"), + P_("Whether to wrap the license text."), + FALSE, + GTK_PARAM_READWRITE)); /* Style properties */ gtk_widget_class_install_style_property (widget_class, @@ -442,6 +459,7 @@ gtk_about_dialog_init (GtkAboutDialog *about) priv->hand_cursor = gdk_cursor_new (GDK_HAND2); priv->regular_cursor = gdk_cursor_new (GDK_XTERM); priv->hovering_over_link = FALSE; + priv->wrap_license = FALSE; gtk_dialog_set_has_separator (GTK_DIALOG (about), FALSE); @@ -551,6 +569,7 @@ gtk_about_dialog_set_property (GObject *object, GParamSpec *pspec) { GtkAboutDialog *about = GTK_ABOUT_DIALOG (object); + GtkAboutDialogPrivate *priv = (GtkAboutDialogPrivate *)about->private_data; switch (prop_id) { @@ -593,6 +612,9 @@ gtk_about_dialog_set_property (GObject *object, case PROP_LOGO_ICON_NAME: gtk_about_dialog_set_logo_icon_name (about, g_value_get_string (value)); break; + case PROP_WRAP_LICENSE: + priv->wrap_license = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -660,6 +682,9 @@ gtk_about_dialog_get_property (GObject *object, else g_value_set_string (value, NULL); break; + case PROP_WRAP_LICENSE: + g_value_set_boolean (value, priv->wrap_license); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1011,6 +1036,59 @@ gtk_about_dialog_set_license (GtkAboutDialog *about, g_object_notify (G_OBJECT (about), "license"); } +/** + * gtk_about_dialog_get_wrap_license: + * @about: a #GtkAboutDialog + * + * Returns whether the license text in @about is + * automatically wrapped. + * + * Returns: %TRUE if the license text is wrapped + * + * Since: 2.8 + */ +gboolean +gtk_about_dialog_get_wrap_license (GtkAboutDialog *about) +{ + GtkAboutDialogPrivate *priv; + + g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), FALSE); + + priv = (GtkAboutDialogPrivate *)about->private_data; + + return priv->wrap_license; +} + +/** + * gtk_about_dialog_set_wrap_license: + * @about: a #GtkAboutDialog + * @wrap_license: whether to wrap the license + * + * Sets whether the license text in @about is + * automatically wrapped. + * + * Since: 2.8 + */ +void +gtk_about_dialog_set_wrap_license (GtkAboutDialog *about, + gboolean wrap_license) +{ + GtkAboutDialogPrivate *priv; + + g_return_if_fail (GTK_IS_ABOUT_DIALOG (about)); + + priv = (GtkAboutDialogPrivate *)about->private_data; + + wrap_license = wrap_license != FALSE; + + if (priv->wrap_license != wrap_license) + { + priv->wrap_license = wrap_license; + + g_object_notify (G_OBJECT (about), "wrap-license"); + } +} + /** * gtk_about_dialog_get_website: * @about: a #GtkAboutDialog @@ -2053,6 +2131,8 @@ display_license_dialog (GtkWidget *button, gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), sw, TRUE, TRUE, 0); view = gtk_text_view_new (); + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), + priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE); gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)), priv->license, -1); diff --git a/gtk/gtkaboutdialog.h b/gtk/gtkaboutdialog.h index 003667541b..f9337e6095 100644 --- a/gtk/gtkaboutdialog.h +++ b/gtk/gtkaboutdialog.h @@ -79,6 +79,11 @@ void gtk_about_dialog_set_comments (GtkAboutDialog G_CONST_RETURN gchar *gtk_about_dialog_get_license (GtkAboutDialog *about); void gtk_about_dialog_set_license (GtkAboutDialog *about, const gchar *license); + +gboolean gtk_about_dialog_get_wrap_license (GtkAboutDialog *about); +void gtk_about_dialog_set_wrap_license (GtkAboutDialog *about, + gboolean wrap_license); + G_CONST_RETURN gchar *gtk_about_dialog_get_website (GtkAboutDialog *about); void gtk_about_dialog_set_website (GtkAboutDialog *about, const gchar *website);