mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-11 21:20:09 +00:00
Remove url hooks from GtkAboutDialog and GtkLinkButton
With gtk_show_uri, global configurability of link activation has moved to GIO/gvfs. For local overrides, GtkLinkButton has the ::clicked signal, and GtkAboutDialog gets an ::activate-link signal. Bug 339745
This commit is contained in:
parent
0e1bba6ef5
commit
b0713fb3bb
@ -67,25 +67,6 @@ activate_radio_action (GtkAction *action, GtkRadioAction *current)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activate_email (GtkAboutDialog *about,
|
||||
const gchar *link,
|
||||
gpointer data)
|
||||
{
|
||||
gchar *text;
|
||||
text = g_strdup_printf ("send mail to %s", link);
|
||||
g_print ("%s\n", text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_url (GtkAboutDialog *about,
|
||||
const gchar *link,
|
||||
gpointer data)
|
||||
{
|
||||
g_print ("show url %s\n", link);
|
||||
}
|
||||
|
||||
static void
|
||||
about_cb (GtkAction *action,
|
||||
GtkWidget *window)
|
||||
@ -120,8 +101,6 @@ about_cb (GtkAction *action,
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
gtk_about_dialog_set_email_hook (activate_email, NULL, NULL);
|
||||
gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
|
||||
gtk_show_about_dialog (GTK_WINDOW (window),
|
||||
"program-name", "GTK+ Code Demos",
|
||||
"version", g_strdup_printf ("%s,\nRunning against GTK+ %d.%d.%d",
|
||||
|
@ -1925,8 +1925,6 @@ gtk_link_button_new
|
||||
gtk_link_button_new_with_label
|
||||
gtk_link_button_get_uri
|
||||
gtk_link_button_set_uri
|
||||
GtkLinkButtonUriFunc
|
||||
gtk_link_button_set_uri_hook
|
||||
gtk_link_button_get_visited
|
||||
gtk_link_button_set_visited
|
||||
|
||||
|
@ -48,13 +48,11 @@ gtk_about_dialog_set_authors
|
||||
gtk_about_dialog_set_comments
|
||||
gtk_about_dialog_set_copyright
|
||||
gtk_about_dialog_set_documenters
|
||||
gtk_about_dialog_set_email_hook
|
||||
gtk_about_dialog_set_license
|
||||
gtk_about_dialog_set_license_type
|
||||
gtk_about_dialog_set_logo
|
||||
gtk_about_dialog_set_logo_icon_name
|
||||
gtk_about_dialog_set_translator_credits
|
||||
gtk_about_dialog_set_url_hook
|
||||
gtk_about_dialog_set_version
|
||||
gtk_about_dialog_set_website
|
||||
gtk_about_dialog_set_website_label
|
||||
@ -1809,7 +1807,6 @@ gtk_link_button_new
|
||||
gtk_link_button_new_with_label
|
||||
gtk_link_button_get_uri
|
||||
gtk_link_button_set_uri
|
||||
gtk_link_button_set_uri_hook
|
||||
gtk_link_button_get_visited
|
||||
gtk_link_button_set_visited
|
||||
#endif
|
||||
|
@ -216,80 +216,28 @@ static void follow_if_link (GtkAboutDialog
|
||||
GtkTextView *text_view,
|
||||
GtkTextIter *iter);
|
||||
static void set_cursor_if_appropriate (GtkAboutDialog *about,
|
||||
GtkTextView *text_view,
|
||||
GtkTextView *text_view,
|
||||
GdkDevice *device,
|
||||
gint x,
|
||||
gint y);
|
||||
gint x,
|
||||
gint y);
|
||||
static void display_credits_dialog (GtkWidget *button,
|
||||
gpointer data);
|
||||
static void display_license_dialog (GtkWidget *button,
|
||||
gpointer data);
|
||||
static void close_cb (GtkAboutDialog *about);
|
||||
static void default_url_hook (GtkAboutDialog *about,
|
||||
const gchar *uri,
|
||||
gpointer user_data);
|
||||
static void default_email_hook (GtkAboutDialog *about,
|
||||
const gchar *email_address,
|
||||
gpointer user_data);
|
||||
static gboolean gtk_about_dialog_activate_link (GtkAboutDialog *about,
|
||||
const gchar *uri);
|
||||
|
||||
static gboolean activate_email_hook_set = FALSE;
|
||||
static GtkAboutDialogActivateLinkFunc activate_email_hook = NULL;
|
||||
static gpointer activate_email_hook_data = NULL;
|
||||
static GDestroyNotify activate_email_hook_destroy = NULL;
|
||||
enum {
|
||||
ACTIVATE_LINK,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static gboolean activate_url_hook_set = FALSE;
|
||||
static GtkAboutDialogActivateLinkFunc activate_url_hook = NULL;
|
||||
static gpointer activate_url_hook_data = NULL;
|
||||
static GDestroyNotify activate_url_hook_destroy = NULL;
|
||||
|
||||
static void
|
||||
default_url_hook (GtkAboutDialog *about,
|
||||
const gchar *uri,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GError *error = NULL;
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (about));
|
||||
|
||||
if (!gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (about),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT |
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", _("Could not show link"));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
default_email_hook (GtkAboutDialog *about,
|
||||
const gchar *email_address,
|
||||
gpointer user_data)
|
||||
{
|
||||
char *escaped, *uri;
|
||||
|
||||
escaped = g_uri_escape_string (email_address, NULL, FALSE);
|
||||
uri = g_strdup_printf ("mailto:%s", escaped);
|
||||
g_free (escaped);
|
||||
|
||||
default_url_hook (about, uri, user_data);
|
||||
g_free (uri);
|
||||
}
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
|
||||
static void
|
||||
gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
|
||||
{
|
||||
@ -306,6 +254,30 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
|
||||
|
||||
widget_class->show = gtk_about_dialog_show;
|
||||
|
||||
klass->activate_link = gtk_about_dialog_activate_link;
|
||||
|
||||
/**
|
||||
* GtkAboutDialog::activate-link:
|
||||
* @label: The object on which the signal was emitted
|
||||
* @uri: the URI that is activated
|
||||
*
|
||||
* The signal which gets emitted to activate a URI.
|
||||
* Applications may connect to it to override the default behaviour,
|
||||
* which is to call gtk_show_uri().
|
||||
*
|
||||
* Returns: %TRUE if the link has been activated
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
signals[ACTIVATE_LINK] =
|
||||
g_signal_new ("activate-link",
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkAboutDialogClass, activate_link),
|
||||
_gtk_boolean_handled_accumulator, NULL,
|
||||
_gtk_marshal_BOOLEAN__STRING,
|
||||
G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
|
||||
|
||||
/**
|
||||
* GtkAboutDialog:program-name:
|
||||
*
|
||||
@ -574,25 +546,12 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
website_clicked (GtkLabel *label,
|
||||
const gchar *uri,
|
||||
GtkAboutDialog *about)
|
||||
emit_activate_link (GtkAboutDialog *about,
|
||||
const gchar *uri)
|
||||
{
|
||||
GtkAboutDialogActivateLinkFunc url_hook;
|
||||
gpointer url_hook_data;
|
||||
gboolean handled = FALSE;
|
||||
|
||||
if (activate_url_hook_set)
|
||||
{
|
||||
url_hook = activate_url_hook;
|
||||
url_hook_data = activate_url_hook_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
url_hook = default_url_hook;
|
||||
url_hook_data = NULL;
|
||||
}
|
||||
|
||||
url_hook (about, uri, url_hook_data);
|
||||
g_signal_emit (about, signals[ACTIVATE_LINK], 0, uri, &handled);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -668,8 +627,8 @@ gtk_about_dialog_init (GtkAboutDialog *about)
|
||||
gtk_widget_set_no_show_all (button, TRUE);
|
||||
gtk_label_set_selectable (GTK_LABEL (button), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
||||
g_signal_connect (button, "activate-link",
|
||||
G_CALLBACK (website_clicked), about);
|
||||
g_signal_connect_swapped (button, "activate-link",
|
||||
G_CALLBACK (emit_activate_link), about);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (priv->logo_image);
|
||||
@ -688,7 +647,7 @@ gtk_about_dialog_init (GtkAboutDialog *about)
|
||||
gtk_button_set_image (GTK_BUTTON (button), image);
|
||||
gtk_widget_set_no_show_all (button, TRUE);
|
||||
gtk_box_pack_end (GTK_BOX (action_area),
|
||||
button, FALSE, TRUE, 0);
|
||||
button, FALSE, TRUE, 0);
|
||||
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (display_credits_dialog), about);
|
||||
@ -700,7 +659,7 @@ gtk_about_dialog_init (GtkAboutDialog *about)
|
||||
gtk_widget_set_can_default (button, TRUE);
|
||||
gtk_widget_set_no_show_all (button, TRUE);
|
||||
gtk_box_pack_end (GTK_BOX (action_area),
|
||||
button, FALSE, TRUE, 0);
|
||||
button, FALSE, TRUE, 0);
|
||||
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE);
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (display_license_dialog), about);
|
||||
@ -817,7 +776,7 @@ gtk_about_dialog_get_property (GObject *object,
|
||||
{
|
||||
GtkAboutDialog *about = GTK_ABOUT_DIALOG (object);
|
||||
GtkAboutDialogPrivate *priv = about->priv;
|
||||
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_NAME:
|
||||
@ -882,6 +841,38 @@ gtk_about_dialog_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_about_dialog_activate_link (GtkAboutDialog *about,
|
||||
const gchar *uri)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GError *error = NULL;
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (about));
|
||||
|
||||
if (!gtk_show_uri (screen, uri, gtk_get_current_event_time (), &error))
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new (GTK_WINDOW (about),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT |
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"%s", _("Could not show link"));
|
||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||
"%s", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
update_website (GtkAboutDialog *about)
|
||||
{
|
||||
@ -889,7 +880,7 @@ update_website (GtkAboutDialog *about)
|
||||
|
||||
gtk_widget_show (priv->website_label);
|
||||
|
||||
if (priv->website_url && (!activate_url_hook_set || activate_url_hook != NULL))
|
||||
if (priv->website_url)
|
||||
{
|
||||
gchar *markup;
|
||||
|
||||
@ -1796,52 +1787,18 @@ follow_if_link (GtkAboutDialog *about,
|
||||
{
|
||||
GSList *tags = NULL, *tagp = NULL;
|
||||
GtkAboutDialogPrivate *priv = about->priv;
|
||||
gchar *url = NULL;
|
||||
GtkAboutDialogActivateLinkFunc email_hook, url_hook;
|
||||
gpointer email_hook_data, url_hook_data;
|
||||
|
||||
if (activate_email_hook_set)
|
||||
{
|
||||
email_hook = activate_email_hook;
|
||||
email_hook_data = activate_email_hook_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
email_hook = default_email_hook;
|
||||
email_hook_data = NULL;
|
||||
}
|
||||
|
||||
if (activate_url_hook_set)
|
||||
{
|
||||
url_hook = activate_url_hook;
|
||||
url_hook_data = activate_url_hook_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
url_hook = default_url_hook;
|
||||
url_hook_data = NULL;
|
||||
}
|
||||
gchar *uri = NULL;
|
||||
|
||||
tags = gtk_text_iter_get_tags (iter);
|
||||
for (tagp = tags; tagp != NULL && !url; tagp = tagp->next)
|
||||
for (tagp = tags; tagp != NULL && !uri; tagp = tagp->next)
|
||||
{
|
||||
GtkTextTag *tag = tagp->data;
|
||||
|
||||
if (email_hook != NULL)
|
||||
{
|
||||
url = g_object_get_data (G_OBJECT (tag), "email");
|
||||
if (url)
|
||||
email_hook (about, url, email_hook_data);
|
||||
}
|
||||
uri = g_object_get_data (G_OBJECT (tag), "uri");
|
||||
if (uri)
|
||||
emit_activate_link (about, uri);
|
||||
|
||||
if (!url && url_hook != NULL)
|
||||
{
|
||||
url = g_object_get_data (G_OBJECT (tag), "url");
|
||||
if (url)
|
||||
url_hook (about, url, url_hook_data);
|
||||
}
|
||||
|
||||
if (url && !g_slist_find_custom (priv->visited_links, url, (GCompareFunc)strcmp))
|
||||
if (uri && !g_slist_find_custom (priv->visited_links, uri, (GCompareFunc)strcmp))
|
||||
{
|
||||
GdkColor *style_visited_link_color;
|
||||
GdkColor color;
|
||||
@ -1860,7 +1817,7 @@ follow_if_link (GtkAboutDialog *about,
|
||||
|
||||
g_object_set (G_OBJECT (tag), "foreground-gdk", &color, NULL);
|
||||
|
||||
priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (url));
|
||||
priv->visited_links = g_slist_prepend (priv->visited_links, g_strdup (uri));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1932,10 +1889,10 @@ text_view_event_after (GtkWidget *text_view,
|
||||
|
||||
static void
|
||||
set_cursor_if_appropriate (GtkAboutDialog *about,
|
||||
GtkTextView *text_view,
|
||||
GtkTextView *text_view,
|
||||
GdkDevice *device,
|
||||
gint x,
|
||||
gint y)
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GtkAboutDialogPrivate *priv = about->priv;
|
||||
GSList *tags = NULL, *tagp = NULL;
|
||||
@ -1948,10 +1905,9 @@ set_cursor_if_appropriate (GtkAboutDialog *about,
|
||||
for (tagp = tags; tagp != NULL; tagp = tagp->next)
|
||||
{
|
||||
GtkTextTag *tag = tagp->data;
|
||||
gchar *email = g_object_get_data (G_OBJECT (tag), "email");
|
||||
gchar *url = g_object_get_data (G_OBJECT (tag), "url");
|
||||
gchar *uri = g_object_get_data (G_OBJECT (tag), "uri");
|
||||
|
||||
if (email != NULL || url != NULL)
|
||||
if (uri != NULL)
|
||||
{
|
||||
hovering_over_link = TRUE;
|
||||
break;
|
||||
@ -2033,7 +1989,6 @@ text_view_new (GtkAboutDialog *about,
|
||||
GtkWidget *view;
|
||||
GtkTextView *text_view;
|
||||
GtkTextBuffer *buffer;
|
||||
gboolean linkify_email, linkify_urls;
|
||||
GdkColor *style_link_color;
|
||||
GdkColor *style_visited_link_color;
|
||||
GdkColor color;
|
||||
@ -2042,9 +1997,6 @@ text_view_new (GtkAboutDialog *about,
|
||||
|
||||
GtkAboutDialogPrivate *priv = about->priv;
|
||||
|
||||
linkify_email = (!activate_email_hook_set || activate_email_hook != NULL);
|
||||
linkify_urls = (!activate_url_hook_set || activate_url_hook != NULL);
|
||||
|
||||
gtk_widget_ensure_style (GTK_WIDGET (about));
|
||||
gtk_widget_style_get (GTK_WIDGET (about),
|
||||
"link-color", &style_link_color,
|
||||
@ -2096,9 +2048,9 @@ text_view_new (GtkAboutDialog *about,
|
||||
q0 = *p;
|
||||
while (*q0)
|
||||
{
|
||||
q1 = linkify_email ? strchr (q0, '<') : NULL;
|
||||
q1 = strchr (q0, '<');
|
||||
q2 = q1 ? strchr (q1, '>') : NULL;
|
||||
r1 = linkify_urls ? strstr (q0, "http://") : NULL;
|
||||
r1 = strstr (q0, "http://");
|
||||
if (r1)
|
||||
{
|
||||
r2 = strpbrk (r1, " \n\t");
|
||||
@ -2118,6 +2070,7 @@ text_view_new (GtkAboutDialog *about,
|
||||
{
|
||||
GtkTextIter end;
|
||||
gchar *link;
|
||||
gchar *uri;
|
||||
const gchar *link_type;
|
||||
GtkTextTag *tag;
|
||||
|
||||
@ -2126,13 +2079,13 @@ text_view_new (GtkAboutDialog *about,
|
||||
gtk_text_buffer_insert_at_cursor (buffer, q0, (q1 - q0) + 1);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||
q1++;
|
||||
link_type = I_("email");
|
||||
link_type = "email";
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||
link_type = I_("url");
|
||||
link_type = "uri";
|
||||
}
|
||||
|
||||
q0 = q2;
|
||||
@ -2148,7 +2101,11 @@ text_view_new (GtkAboutDialog *about,
|
||||
"foreground-gdk", &color,
|
||||
"underline", PANGO_UNDERLINE_SINGLE,
|
||||
NULL);
|
||||
g_object_set_data_full (G_OBJECT (tag), link_type, g_strdup (link), g_free);
|
||||
if (strcmp (link_type, "email") == 0)
|
||||
uri = g_strconcat ("mailto:", link, NULL);
|
||||
else
|
||||
uri = g_strdup (link);
|
||||
g_object_set_data_full (G_OBJECT (tag), I_("uri"), uri, g_free);
|
||||
gtk_text_buffer_insert_with_tags (buffer, &end, link, -1, tag, NULL);
|
||||
|
||||
g_free (link);
|
||||
@ -2291,10 +2248,10 @@ display_license_dialog (GtkWidget *button,
|
||||
}
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons (_("License"),
|
||||
GTK_WINDOW (about),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
GTK_WINDOW (about),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL,
|
||||
NULL);
|
||||
license_dialog = GTK_DIALOG (dialog);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (license_dialog);
|
||||
@ -2354,78 +2311,6 @@ gtk_about_dialog_new (void)
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_about_dialog_set_email_hook:
|
||||
* @func: a function to call when an email link is activated.
|
||||
* @data: data to pass to @func
|
||||
* @destroy: #GDestroyNotify for @data
|
||||
*
|
||||
* Installs a global function to be called whenever the user activates an
|
||||
* email link in an about dialog.
|
||||
*
|
||||
* Since 2.18 there exists a default function which uses gtk_show_uri(). To
|
||||
* deactivate it, you can pass %NULL for @func.
|
||||
*
|
||||
* Return value: the previous email hook.
|
||||
*
|
||||
* Since: 2.6
|
||||
*/
|
||||
GtkAboutDialogActivateLinkFunc
|
||||
gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy)
|
||||
{
|
||||
GtkAboutDialogActivateLinkFunc old;
|
||||
|
||||
if (activate_email_hook_destroy != NULL)
|
||||
(* activate_email_hook_destroy) (activate_email_hook_data);
|
||||
|
||||
old = activate_email_hook;
|
||||
|
||||
activate_email_hook_set = TRUE;
|
||||
activate_email_hook = func;
|
||||
activate_email_hook_data = data;
|
||||
activate_email_hook_destroy = destroy;
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_about_dialog_set_url_hook:
|
||||
* @func: a function to call when a URL link is activated.
|
||||
* @data: data to pass to @func
|
||||
* @destroy: #GDestroyNotify for @data
|
||||
*
|
||||
* Installs a global function to be called whenever the user activates a
|
||||
* URL link in an about dialog.
|
||||
*
|
||||
* Since 2.18 there exists a default function which uses gtk_show_uri(). To
|
||||
* deactivate it, you can pass %NULL for @func.
|
||||
*
|
||||
* Return value: the previous URL hook.
|
||||
*
|
||||
* Since: 2.6
|
||||
*/
|
||||
GtkAboutDialogActivateLinkFunc
|
||||
gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy)
|
||||
{
|
||||
GtkAboutDialogActivateLinkFunc old;
|
||||
|
||||
if (activate_url_hook_destroy != NULL)
|
||||
(* activate_url_hook_destroy) (activate_url_hook_data);
|
||||
|
||||
old = activate_url_hook;
|
||||
|
||||
activate_url_hook_set = TRUE;
|
||||
activate_url_hook = func;
|
||||
activate_url_hook_data = data;
|
||||
activate_url_hook_destroy = destroy;
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
static void
|
||||
close_cb (GtkAboutDialog *about)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ typedef enum {
|
||||
* The <structname>GtkAboutDialog</structname> struct contains
|
||||
* only private fields and should not be directly accessed.
|
||||
*/
|
||||
struct _GtkAboutDialog
|
||||
struct _GtkAboutDialog
|
||||
{
|
||||
GtkDialog parent_instance;
|
||||
|
||||
@ -93,10 +93,13 @@ struct _GtkAboutDialog
|
||||
GtkAboutDialogPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkAboutDialogClass
|
||||
struct _GtkAboutDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
|
||||
gboolean (*activate_link) (GtkAboutDialog *dialog,
|
||||
const gchar *uri);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
@ -107,23 +110,23 @@ struct _GtkAboutDialogClass
|
||||
GType gtk_about_dialog_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget *gtk_about_dialog_new (void);
|
||||
void gtk_show_about_dialog (GtkWindow *parent,
|
||||
const gchar *first_property_name,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
const gchar *first_property_name,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_program_name (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_program_name (GtkAboutDialog *about,
|
||||
const gchar *name);
|
||||
const gchar *name);
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_version (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_version (GtkAboutDialog *about,
|
||||
const gchar *version);
|
||||
const gchar *version);
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_copyright (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_copyright (GtkAboutDialog *about,
|
||||
const gchar *copyright);
|
||||
const gchar *copyright);
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_comments (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_comments (GtkAboutDialog *about,
|
||||
const gchar *comments);
|
||||
const gchar *comments);
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_license (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_license (GtkAboutDialog *about,
|
||||
const gchar *license);
|
||||
const gchar *license);
|
||||
void gtk_about_dialog_set_license_type (GtkAboutDialog *about,
|
||||
GtkLicense license_type);
|
||||
GtkLicense gtk_about_dialog_get_license_type (GtkAboutDialog *about);
|
||||
@ -134,50 +137,28 @@ void gtk_about_dialog_set_wrap_license (GtkAboutDialog
|
||||
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_website (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_website (GtkAboutDialog *about,
|
||||
const gchar *website);
|
||||
const gchar *website);
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_website_label (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_website_label (GtkAboutDialog *about,
|
||||
const gchar *website_label);
|
||||
const gchar *website_label);
|
||||
G_CONST_RETURN gchar* G_CONST_RETURN * gtk_about_dialog_get_authors (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_authors (GtkAboutDialog *about,
|
||||
const gchar **authors);
|
||||
const gchar **authors);
|
||||
G_CONST_RETURN gchar* G_CONST_RETURN * gtk_about_dialog_get_documenters (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_documenters (GtkAboutDialog *about,
|
||||
const gchar **documenters);
|
||||
const gchar **documenters);
|
||||
G_CONST_RETURN gchar* G_CONST_RETURN * gtk_about_dialog_get_artists (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_artists (GtkAboutDialog *about,
|
||||
const gchar **artists);
|
||||
const gchar **artists);
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_translator_credits (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_translator_credits (GtkAboutDialog *about,
|
||||
const gchar *translator_credits);
|
||||
const gchar *translator_credits);
|
||||
GdkPixbuf *gtk_about_dialog_get_logo (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_logo (GtkAboutDialog *about,
|
||||
GdkPixbuf *logo);
|
||||
GdkPixbuf *logo);
|
||||
G_CONST_RETURN gchar *gtk_about_dialog_get_logo_icon_name (GtkAboutDialog *about);
|
||||
void gtk_about_dialog_set_logo_icon_name (GtkAboutDialog *about,
|
||||
const gchar *icon_name);
|
||||
|
||||
/**
|
||||
* GtkAboutDialogActivateLinkFunc:
|
||||
* @about: the #GtkAboutDialog in which the link was activated
|
||||
* @link_: the URL or email address to which the activated link points
|
||||
* @data: user data that was passed when the function was registered
|
||||
* with gtk_about_dialog_set_email_hook() or
|
||||
* gtk_about_dialog_set_url_hook()
|
||||
*
|
||||
* The type of a function which is called when a URL or email
|
||||
* link is activated.
|
||||
*/
|
||||
typedef void (* GtkAboutDialogActivateLinkFunc) (GtkAboutDialog *about,
|
||||
const gchar *link_,
|
||||
gpointer data);
|
||||
|
||||
GtkAboutDialogActivateLinkFunc gtk_about_dialog_set_email_hook (GtkAboutDialogActivateLinkFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy);
|
||||
GtkAboutDialogActivateLinkFunc gtk_about_dialog_set_url_hook (GtkAboutDialogActivateLinkFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy);
|
||||
const gchar *icon_name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -105,10 +105,6 @@ static const GtkTargetEntry link_drop_types[] = {
|
||||
static const GdkColor default_link_color = { 0, 0, 0, 0xeeee };
|
||||
static const GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b };
|
||||
|
||||
static GtkLinkButtonUriFunc uri_func = NULL;
|
||||
static gpointer uri_func_data = NULL;
|
||||
static GDestroyNotify uri_func_destroy = NULL;
|
||||
|
||||
G_DEFINE_TYPE (GtkLinkButton, gtk_link_button, GTK_TYPE_BUTTON)
|
||||
|
||||
static void
|
||||
@ -476,28 +472,22 @@ static void
|
||||
gtk_link_button_clicked (GtkButton *button)
|
||||
{
|
||||
GtkLinkButton *link_button = GTK_LINK_BUTTON (button);
|
||||
GdkScreen *screen;
|
||||
GError *error;
|
||||
|
||||
if (uri_func)
|
||||
(* uri_func) (link_button, link_button->priv->uri, uri_func_data);
|
||||
if (gtk_widget_has_screen (GTK_WIDGET (button)))
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (button));
|
||||
else
|
||||
screen = NULL;
|
||||
|
||||
error = NULL;
|
||||
gtk_show_uri (screen, link_button->priv->uri, GDK_CURRENT_TIME, &error);
|
||||
if (error)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GError *error;
|
||||
|
||||
if (gtk_widget_has_screen (GTK_WIDGET (button)))
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (button));
|
||||
else
|
||||
screen = NULL;
|
||||
|
||||
error = NULL;
|
||||
gtk_show_uri (screen, link_button->priv->uri, GDK_CURRENT_TIME, &error);
|
||||
if (error)
|
||||
{
|
||||
g_warning ("Unable to show '%s': %s",
|
||||
link_button->priv->uri,
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
g_warning ("Unable to show '%s': %s",
|
||||
link_button->priv->uri,
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
gtk_link_button_set_visited (link_button, TRUE);
|
||||
@ -705,41 +695,6 @@ gtk_link_button_get_uri (GtkLinkButton *link_button)
|
||||
return link_button->priv->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_link_button_set_uri_hook:
|
||||
* @func: (allow-none): a function called each time a #GtkLinkButton is clicked, or %NULL
|
||||
* @data: (allow-none): user data to be passed to @func, or %NULL
|
||||
* @destroy: (allow-none): a #GDestroyNotify that gets called when @data is no longer needed, or %NULL
|
||||
*
|
||||
* Sets @func as the function that should be invoked every time a user clicks
|
||||
* a #GtkLinkButton. This function is called before every callback registered
|
||||
* for the "clicked" signal.
|
||||
*
|
||||
* If no uri hook has been set, GTK+ defaults to calling gtk_show_uri().
|
||||
*
|
||||
* Return value: the previously set hook function.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
GtkLinkButtonUriFunc
|
||||
gtk_link_button_set_uri_hook (GtkLinkButtonUriFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy)
|
||||
{
|
||||
GtkLinkButtonUriFunc old_uri_func;
|
||||
|
||||
if (uri_func_destroy)
|
||||
(* uri_func_destroy) (uri_func_data);
|
||||
|
||||
old_uri_func = uri_func;
|
||||
|
||||
uri_func = func;
|
||||
uri_func_data = data;
|
||||
uri_func_destroy = destroy;
|
||||
|
||||
return old_uri_func;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_link_button_set_visited:
|
||||
* @link_button: a #GtkLinkButton
|
||||
|
@ -44,10 +44,6 @@ typedef struct _GtkLinkButton GtkLinkButton;
|
||||
typedef struct _GtkLinkButtonClass GtkLinkButtonClass;
|
||||
typedef struct _GtkLinkButtonPrivate GtkLinkButtonPrivate;
|
||||
|
||||
typedef void (*GtkLinkButtonUriFunc) (GtkLinkButton *button,
|
||||
const gchar *link_,
|
||||
gpointer user_data);
|
||||
|
||||
struct _GtkLinkButton
|
||||
{
|
||||
GtkButton parent_instance;
|
||||
@ -75,10 +71,6 @@ G_CONST_RETURN gchar *gtk_link_button_get_uri (GtkLinkButton *link_but
|
||||
void gtk_link_button_set_uri (GtkLinkButton *link_button,
|
||||
const gchar *uri);
|
||||
|
||||
GtkLinkButtonUriFunc gtk_link_button_set_uri_hook (GtkLinkButtonUriFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy);
|
||||
|
||||
gboolean gtk_link_button_get_visited (GtkLinkButton *link_button);
|
||||
void gtk_link_button_set_visited (GtkLinkButton *link_button,
|
||||
gboolean visited);
|
||||
|
Loading…
Reference in New Issue
Block a user