? d
Index: gtk/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/Makefile.am,v
retrieving revision 1.299
diff -u -p -d -r1.299 Makefile.am
--- gtk/Makefile.am	29 Mar 2006 20:05:08 -0000	1.299
+++ gtk/Makefile.am	30 Mar 2006 09:12:28 -0000
@@ -313,6 +313,7 @@ gtk_private_h_sources =		\
 	gtkfilesystemunix.h	\
 	gtkfilesystemmodel.h	\
 	gtkiconcache.h		\
+	gtklicensetext.h	\
 	gtkpathbar.h		\
 	gtkplugprivate.h	\
 	gtkrbtree.h		\
@@ -434,6 +435,7 @@ gtk_c_sources =                 \
 	gtklabel.c		\
 	gtklayout.c		\
 	gtklinkbutton.c		\
+	gtklicensetext.c	\
 	gtklist.c		\
 	gtklistitem.c		\
 	gtkliststore.c		\
Index: gtk/gtkaboutdialog.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkaboutdialog.c,v
retrieving revision 1.48
diff -u -p -d -r1.48 gtkaboutdialog.c
--- gtk/gtkaboutdialog.c	10 Mar 2006 22:05:36 -0000	1.48
+++ gtk/gtkaboutdialog.c	30 Mar 2006 09:12:29 -0000
@@ -50,6 +50,7 @@
 #include "gtkiconfactory.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
+#include "gtklicensetext.h"
 
 #include "gtkalias.h"
 
@@ -69,6 +70,7 @@ struct _GtkAboutDialogPrivate 
   gchar *website_label;
   gchar *translator_credits;
   gchar *license;
+  gchar *license_name;
   
   gchar **authors;
   gchar **documenters;
@@ -107,6 +109,7 @@ enum 
   PROP_WEBSITE,
   PROP_WEBSITE_LABEL,
   PROP_LICENSE,
+  PROP_LICENSE_NAME,
   PROP_AUTHORS,
   PROP_DOCUMENTERS,
   PROP_TRANSLATOR_CREDITS,
@@ -277,6 +280,25 @@ gtk_about_dialog_class_init (GtkAboutDia
 							GTK_PARAM_READWRITE));
 
   /**
+   * GtkAboutDialog:license-name:
+   *
+   * 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 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
+   */  
+  g_object_class_install_property (object_class,
+				   PROP_LICENSE_NAME,
+				   g_param_spec_string ("license-name",
+							_("License Name"),
+							_("The name of the license of the program"),
+							NULL,
+							GTK_PARAM_READWRITE));
+
+  /**
    * GtkAboutDialog:website:
    *
    * The URL for the link to the website of the program. 
@@ -446,6 +468,7 @@ gtk_about_dialog_init (GtkAboutDialog *a
   priv->website_label = NULL;
   priv->translator_credits = NULL;
   priv->license = NULL;
+  priv->license_name = NULL;
   priv->authors = NULL;
   priv->documenters = NULL;
   priv->artists = NULL;
@@ -588,6 +611,9 @@ gtk_about_dialog_set_property (GObject  
     case PROP_LICENSE:
       gtk_about_dialog_set_license (about, g_value_get_string (value));
       break;
+    case PROP_LICENSE_NAME:
+      gtk_about_dialog_set_license_name (about, g_value_get_string (value));
+      break;
     case PROP_COPYRIGHT:
       gtk_about_dialog_set_copyright (about, g_value_get_string (value));
       break;
@@ -650,6 +676,9 @@ gtk_about_dialog_get_property (GObject  
     case PROP_LICENSE:
       g_value_set_string (value, priv->license);
       break;
+    case PROP_LICENSE_NAME:
+      g_value_set_string (value, priv->license_name);
+      break;
     case PROP_TRANSLATOR_CREDITS:
       g_value_set_string (value, priv->translator_credits);
       break;
@@ -1026,7 +1055,8 @@ gtk_about_dialog_set_license (GtkAboutDi
   else
     {
       priv->license = NULL;
-      gtk_widget_hide (priv->license_button);
+      if (!priv->license_name)
+	gtk_widget_hide (priv->license_button);
     }
   g_free (tmp);
 
@@ -1034,6 +1064,68 @@ gtk_about_dialog_set_license (GtkAboutDi
 }
 
 /**
+ * gtk_about_dialog_get_license_name:
+ * @about: a #GtkAboutDialog
+ * 
+ * Returns the name of the application license.
+ * 
+ * Return value: The license name information. The string is owned by the
+ *  about dialog and must not be modified.
+ *
+ * Since: 2.10
+ **/
+G_CONST_RETURN gchar *
+gtk_about_dialog_get_license_name (GtkAboutDialog *about)
+{
+  GtkAboutDialogPrivate *priv;
+  
+  g_return_val_if_fail (GTK_IS_ABOUT_DIALOG (about), NULL);
+
+  priv = (GtkAboutDialogPrivate *)about->private_data;
+
+  return priv->license_name;
+}
+
+/**
+ * gtk_about_dialog_set_license_name:
+ * @about: a #GtkAboutDialog
+ * @license_name: the license name or %NULL
+ *
+ * Sets the name of the license of the application.  The license name
+ * will be used to show the respective license if no license text is
+ * set explicitly.
+ * 
+ * Since: 2.10
+ **/
+void
+gtk_about_dialog_set_license_name (GtkAboutDialog *about, 
+			           const gchar    *license_name)
+{
+  GtkAboutDialogPrivate *priv;
+  gchar *tmp;
+
+  g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
+
+  priv = (GtkAboutDialogPrivate *)about->private_data;
+
+  tmp = priv->license_name;
+  if (license_name) 
+    {
+      priv->license_name = g_strdup (license_name);
+      gtk_widget_show (priv->license_button);
+    }
+  else
+    {
+      priv->license_name = NULL;
+      if (!priv->license)
+	gtk_widget_hide (priv->license_button);
+    }
+  g_free (tmp);
+
+  g_object_notify (G_OBJECT (about), "license-name");
+}
+
+/**
  * gtk_about_dialog_get_wrap_license:
  * @about: a #GtkAboutDialog
  *
@@ -2103,10 +2195,30 @@ display_license_dialog (GtkWidget *butto
   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);
+  if (priv->license)
+    {
+      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);
+    }
+  else
+    {
+      char *license = _gtk_license_text_get_for_name (priv->license_name,
+						      priv->name);
+
+      if (!license)
+        {
+	  license = g_strdup_printf (_("%s is licensed under the %s license."),
+				     priv->name, priv->license_name);
+	}
+
+      gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
+      gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)), 
+				license, -1);
+
+      g_free (license);
+    }
 
   gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
   gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
Index: gtk/gtkaboutdialog.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkaboutdialog.h,v
retrieving revision 1.7
diff -u -p -d -r1.7 gtkaboutdialog.h
--- gtk/gtkaboutdialog.h	5 Jul 2005 14:53:36 -0000	1.7
+++ gtk/gtkaboutdialog.h	30 Mar 2006 09:12:29 -0000
@@ -79,11 +79,12 @@ void                   gtk_about_dialog_
 G_CONST_RETURN gchar  *gtk_about_dialog_get_license            (GtkAboutDialog  *about);
 void                   gtk_about_dialog_set_license            (GtkAboutDialog  *about,
 								const gchar     *license);
-
+G_CONST_RETURN gchar  *gtk_about_dialog_get_license_name       (GtkAboutDialog  *about);
+void                   gtk_about_dialog_set_license_name       (GtkAboutDialog  *about,
+								const gchar     *license_name);
 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);
Index: gtk/gtklicensetext.c
===================================================================
RCS file: gtk/gtklicensetext.c
diff -N gtk/gtklicensetext.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gtk/gtklicensetext.c	30 Mar 2006 09:12:29 -0000
@@ -0,0 +1,138 @@
+/* GTK - The GIMP Toolkit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public 
+ * License as published by the Free Software Foundation; either 
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the 
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Author: Behdad Esfahbod  <behdad@gnome.org>
+ */
+
+#include <config.h>
+
+#include "gtklicensetext.h"
+#include "gtkintl.h"
+
+#include "gtkalias.h"
+
+#include <string.h>
+
+
+typedef struct _GtkLicenseText        _GtkLicenseText;
+
+struct _GtkLicenseText
+{
+  const char name[16];		/* normalized name */
+  const char *paragraphs;	/* NUL-separated NUL-terminated paragraphs */
+};
+
+static const _GtkLicenseText _gtk_license_texts[];
+static char *_gtk_license_text_normalize_name (const char *license_name);
+
+
+static char *
+_gtk_license_text_normalize_name (const char *license_name)
+{
+  GString *s = g_string_new (NULL);
+  const char *p;
+
+  for (p = license_name; *p; p++)
+    if (*p != ' ')
+      g_string_append_c (s, *p);
+
+  g_string_ascii_down (s);
+
+  return g_string_free (s, FALSE);
+}
+
+char *
+_gtk_license_text_get_for_name (const char *license_name,
+				const char *application_name)
+{
+  char *license = NULL;
+  const _GtkLicenseText *license_text;
+  char *name = _gtk_license_text_normalize_name (license_name);
+
+  for (license_text = _gtk_license_texts; license_text->paragraphs; license_text++)
+    if (!strcmp (name, license_text->name))
+      break;
+
+  if (license_text->paragraphs)
+    {
+      GString *s = g_string_new (NULL);
+      const char *par;
+
+      for (par = license_text->paragraphs; *par; par += strlen (par) + 1)
+	{
+	  char *subst_par;
+
+	  subst_par = g_strdup_printf (_(par),
+				       application_name,
+				       application_name,
+				       application_name,
+				       application_name);
+
+	  g_string_append (s, subst_par);
+	  g_string_append (s, "\n\n");
+	  g_free (subst_par);
+	}
+
+      license = g_string_free (s, FALSE);
+    }
+
+  g_free (name);
+
+  return license;
+}
+
+
+#undef N_
+#define N_(String) String "\0"
+
+static const _GtkLicenseText _gtk_license_texts[] = {
+  {
+    "gpl2+",
+    N_("%s is free software; you can redistribute it and/or modify "
+       "it under the terms of the GNU General Public License "
+       "as published by the Free Software Foundation; either "
+       "version 2 of the License, or (at your option) any later version.")
+    N_("%s is distributed in the hope that it will be useful, "
+       "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+       "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+       "GNU General Public License for more details.")
+    N_("You should have received a copy of the GNU General Public License "
+       "along with %s; if not, write to the Free Software Foundation, Inc., "
+       "51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.")
+  },
+  {
+    "lgpl2.1+",
+    N_("%s is free software; you can redistribute it and/or modify "
+       "it under the terms of the GNU Lesser General Public License "
+       "as published by the Free Software Foundation; either "
+       "version 2.1 of the License, or (at your option) any later version.")
+    N_("%s is distributed in the hope that it will be useful, "
+       "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+       "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the "
+       "GNU Lesser General Public License for more details.")
+    N_("You should have received a copy of the GNU Lesser General Public License "
+       "along with %s; if not, write to the Free Software Foundation, Inc., "
+       "51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.")
+  },
+  { "", NULL }
+};
+
+
+#define __GTK_LICENSE_TEXT_C__
+#include "gtkaliasdef.c"
Index: gtk/gtklicensetext.h
===================================================================
RCS file: gtk/gtklicensetext.h
diff -N gtk/gtklicensetext.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gtk/gtklicensetext.h	30 Mar 2006 09:12:29 -0000
@@ -0,0 +1,33 @@
+/* GTK - The GIMP Toolkit
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Behdad Esfahbod  <behdad@gnome.org>
+*/
+
+#ifndef __GTK_LICENSE_TEXTS_H__
+#define __GTK_LICENSE_TEXTS_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+char *_gtk_license_text_get_for_name (const char *license_name,
+				      const char *application_name);
+
+G_END_DECLS
+
+#endif /* __GTK_LICENSE_TEXTS_H__ */

