* 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.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gtktextview.h"
#include "gtkiconfactory.h"
#include "gtkshow.h"
-#include "gtkmainprivate.h"
+#include "gtkmain.h"
#include "gtkmessagedialog.h"
#include "gtktogglebutton.h"
#include "gtktypebuiltins.h"
/* Translators: this is the license preamble; the string at the end
* contains the URL of the license.
*/
-static const gchar *gtk_license_preamble = N_("This program comes with ABSOLUTELY NO WARRANTY; for details, visit <a href=\"%s\">%s</a>");
+static const gchar *gtk_license_preamble = N_("This program comes with ABSOLUTELY NO WARRANTY;\nfor details, visit <a href=\"%s\">%s</a>");
/* URLs for each GtkLicense type; keep in the same order as the enumeration */
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;
gchar **documenters;
gchar **artists;
+
+ GSList *credit_sections;
+
gint credits_page;
gint license_page;
guint wrap_license : 1;
};
+
+
#define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate))
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")));
gtk_about_dialog_set_logo (about, NULL);
}
+static 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)
{
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);
else
{
markup = g_strdup_printf ("<a href=\"%s\">%s</a>",
- priv->website_url, _("Homepage"));
+ priv->website_url, _("Website"));
}
gtk_label_set_markup (GTK_LABEL (priv->website_label), markup);
button_event = (GdkEventButton *)event;
- if (button_event->button != 1)
+ if (button_event->button != GDK_BUTTON_PRIMARY)
return FALSE;
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
GdkColor color;
GdkColor link_color;
GdkColor visited_link_color;
- gint size;
- PangoFontDescription *font_desc;
GtkAboutDialogPrivate *priv = about->priv;
- GtkStyleContext *context;
- GtkStateFlags state;
+ GtkTextIter start_iter, end_iter;
+ GtkTextTag *tag;
gtk_widget_style_get (GTK_WIDGET (about),
"link-color", &style_link_color,
gtk_text_view_set_editable (text_view, FALSE);
gtk_text_view_set_wrap_mode (text_view, wrap_mode);
- context = gtk_widget_get_style_context (view);
- state = gtk_widget_get_state_flags (view);
-
- size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
- font_desc = pango_font_description_new ();
- pango_font_description_set_size (font_desc, size * PANGO_SCALE_SMALL);
- gtk_widget_modify_font (view, font_desc);
- pango_font_description_free (font_desc);
+ gtk_text_buffer_get_start_iter (buffer, &start_iter);
+ gtk_text_buffer_get_start_iter (buffer, &end_iter);
+ tag = gtk_text_tag_new (NULL);
+ g_object_set (tag, "font-scale", PANGO_SCALE_SMALL, NULL);
+ gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
gtk_text_view_set_left_margin (text_view, 8);
gtk_text_view_set_right_margin (text_view, 8);
}
/* skip one at the end */
+ label = gtk_label_new ("");
+ gtk_grid_attach (grid, label, 1, *row, 1, 1);
(*row)++;
}
priv->credits_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
grid = gtk_grid_new ();
gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
- gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
- gtk_grid_set_row_spacing (GTK_GRID (grid), 12);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 8);
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
gtk_widget_set_valign (grid, GTK_ALIGN_START);
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), grid);
+ gtk_container_add (GTK_CONTAINER (sw), grid);
+ gtk_style_context_add_class (gtk_widget_get_style_context (gtk_bin_get_child (GTK_BIN (sw))),
+ GTK_STYLE_CLASS_VIEW);
+
+ row = 0;
if (priv->authors != NULL)
add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors);
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);
}
priv->license_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL);
sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_set_border_width (GTK_CONTAINER (sw), 5);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
return about->priv->license_type;
}
+
+/**
+ * gtk_about_dialog_add_credit_section:
+ * @about: A #GtkAboutDialog
+ * @section_name: The name of the section
+ * @people: (array zero-terminated=1): 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);
+}