summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-01-25 18:21:47 -0500
committerMatthias Clasen <mclasen@redhat.com>2012-01-25 18:25:43 -0500
commitd00368cac9ab631c5c596078095a4db3f4197868 (patch)
treec62583bc90323c7cb62268f2f4dcbe7ed9bc4947
parentfe1907708c4edb5a97184a2e027b7a028a7b5554 (diff)
downloadgtk+-d00368cac9ab631c5c596078095a4db3f4197868.tar.gz
GtkAboutDialog: Make credits section extensible
This commit adds API that allows to add new named sections to the Credits part of GtkAboutDialog, in addition to the hardcoded sections for authors, documenters, artists and translators. https://bugzilla.gnome.org/show_bug.cgi?id=484693
-rw-r--r--docs/reference/gtk/gtk3-sections.txt1
-rw-r--r--gtk/gtk.symbols1
-rw-r--r--gtk/gtkaboutdialog.c65
-rw-r--r--gtk/gtkaboutdialog.h3
4 files changed, 70 insertions, 0 deletions
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 41e42a9e18..393e274eff 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -37,6 +37,7 @@ gtk_about_dialog_get_logo
gtk_about_dialog_set_logo
gtk_about_dialog_get_logo_icon_name
gtk_about_dialog_set_logo_icon_name
+gtk_about_dialog_add_credit_section
gtk_show_about_dialog
<SUBSECTION Standard>
GTK_ABOUT_DIALOG
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 3f377b166d..4acba3d662 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -1,6 +1,7 @@
/* This list defines the GTK+ ABI. It is used to generate the gtk.def
* file.
*/
+gtk_about_dialog_add_credit_section
gtk_about_dialog_get_artists
gtk_about_dialog_get_authors
gtk_about_dialog_get_comments
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index 6d916b61d3..a4cc9c33ad 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -122,6 +122,12 @@ static const gchar *gtk_license_urls[] = {
"http://opensource.org/licenses/artistic-license-2.0.php"
};
+typedef struct
+{
+ gchar *heading;
+ gchar **people;
+} CreditSection;
+
struct _GtkAboutDialogPrivate
{
gchar *name;
@@ -137,6 +143,9 @@ struct _GtkAboutDialogPrivate
gchar **documenters;
gchar **artists;
+
+ GSList *credit_sections;
+
gint credits_page;
gint license_page;
@@ -163,6 +172,8 @@ struct _GtkAboutDialogPrivate
guint wrap_license : 1;
};
+
+
#define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
@@ -561,6 +572,7 @@ update_credits_button_visibility (GtkAboutDialog *about)
show = (priv->authors != NULL ||
priv->documenters != NULL ||
priv->artists != NULL ||
+ priv->credit_sections != NULL ||
(priv->translator_credits != NULL &&
strcmp (priv->translator_credits, "translator_credits") &&
strcmp (priv->translator_credits, "translator-credits")));
@@ -775,6 +787,15 @@ gtk_about_dialog_init (GtkAboutDialog *about)
gtk_about_dialog_set_logo (about, NULL);
}
+
+void destroy_credit_section (gpointer data)
+{
+ CreditSection *cs = data;
+ g_free (cs->heading);
+ g_strfreev (cs->people);
+ g_slice_free (CreditSection, data);
+}
+
static void
gtk_about_dialog_finalize (GObject *object)
{
@@ -794,6 +815,8 @@ gtk_about_dialog_finalize (GObject *object)
g_strfreev (priv->documenters);
g_strfreev (priv->artists);
+ g_slist_free_full (priv->credit_sections, destroy_credit_section);
+
g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
g_slist_free (priv->visited_links);
@@ -2393,6 +2416,16 @@ create_credits_page (GtkAboutDialog *about)
if (priv->artists != NULL)
add_credits_section (about, GTK_GRID (grid), &row, _("Artwork by"), priv->artists);
+ if (priv->credit_sections != NULL)
+ {
+ GSList *cs;
+ for (cs = priv->credit_sections; cs != NULL; cs = cs->next)
+ {
+ CreditSection *section = cs->data;
+ add_credits_section (about, GTK_GRID (grid), &row, section->heading, section->people);
+ }
+ }
+
gtk_widget_show_all (sw);
}
@@ -2627,3 +2660,35 @@ gtk_about_dialog_get_license_type (GtkAboutDialog *about)
return about->priv->license_type;
}
+
+/**
+ * gtk_about_dialog_add_credit_section:
+ * @about: A #GtkAboutDialog
+ * @section_name: The name of the section
+ * @people: The people who belong to that section
+ *
+ * Creates a new section in the Credits page.
+ *
+ * Since: 3.4
+ */
+void
+gtk_about_dialog_add_credit_section (GtkAboutDialog *about,
+ const gchar *section_name,
+ const gchar **people)
+{
+ GtkAboutDialogPrivate *priv;
+ CreditSection *new_entry;
+
+ g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
+ g_return_if_fail (section_name != NULL);
+ g_return_if_fail (people != NULL);
+
+ priv = about->priv;
+
+ new_entry = g_slice_new (CreditSection);
+ new_entry->heading = g_strdup ((gchar *)section_name);
+ new_entry->people = g_strdupv ((gchar **)people);
+
+ priv->credit_sections = g_slist_append (priv->credit_sections, new_entry);
+ update_credits_button_visibility (about);
+}
diff --git a/gtk/gtkaboutdialog.h b/gtk/gtkaboutdialog.h
index 68c24d7b40..b174294fb3 100644
--- a/gtk/gtkaboutdialog.h
+++ b/gtk/gtkaboutdialog.h
@@ -159,6 +159,9 @@ void gtk_about_dialog_set_logo (GtkAboutDialog
const gchar * gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about);
void gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
const gchar *icon_name);
+void gtk_about_dialog_add_credit_section (GtkAboutDialog *about,
+ const gchar *section_name,
+ const gchar **people);
G_END_DECLS