[gnome-about] Title box is a hyperlink
- From: ERDI Gergo <cactus cactus rulez org>
- To: gnome-devel-list gnome org
- Subject: [gnome-about] Title box is a hyperlink
- Date: Fri, 31 Dec 1999 18:07:31 +0100 (CET)
Hi,
I remember reading on James Cape's gnomeui page that someone requested the
functionality to be able to add a URL to About windows and thus making the
home page of an application only a click away from the app itself. My
patch (attached) does exactly this, while of course breaking compatibility
(that's what HEAD's for, isn't it? <g>). Please review and allow me to
commit.
--
.--= ULLA! =----------------------------. finger cactus@cactus.rulez.org
\ http://cactus.rulez.org \ for PGP public key
`----------= cactus@cactus.rulez.org =--'
Used Cars: Why go elsewhere to be cheated? Come here first!
Index: gnome-about.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-about.c,v
retrieving revision 1.44
diff -u -r1.44 gnome-about.c
--- gnome-about.c 1999/12/21 00:43:34 1.44
+++ gnome-about.c 1999/12/31 17:06:53
@@ -21,6 +21,7 @@
#include "gnome-about.h"
#include "libgnome/gnome-util.h"
#include "libgnome/gnome-i18nP.h"
+#include "libgnome/gnome-url.h"
#include "gnome-stock.h"
#include <string.h>
#include <gtk/gtk.h>
@@ -39,6 +40,7 @@
typedef struct
{
gchar *title;
+ gchar *url;
gchar *copyright;
GList *names;
gchar *comments;
@@ -65,6 +67,7 @@
GdkGC *gc,
gint x, gint y, gint w,
const gchar *comments);
+static void gnome_about_buttonpress (GtkWidget*, GdkEventButton*, GnomeAboutInfo*);
/**
@@ -124,6 +127,9 @@
gc = gdk_gc_new (win);
gdk_window_clear (win);
+
+ /* Please synchronize with gnome_about_buttonpressed if you
+ modify layout here */
/* Draw pixmap first */
y = 1;
@@ -396,8 +402,9 @@
static GnomeAboutInfo*
gnome_fill_info (GtkWidget *widget,
- const gchar *title,
- const gchar *version,
+ const gchar *title,
+ const gchar *version,
+ const gchar *url,
const gchar *copyright,
const gchar **authors,
const gchar *comments,
@@ -447,6 +454,11 @@
gai->title = g_strconcat (title, " ", version ? version : "", NULL);
else
gai->title = NULL;
+
+ if (url)
+ gai->url = g_strdup(url);
+ else
+ gai->url = NULL;
gai->copyright = g_strdup(copyright);
@@ -485,6 +497,7 @@
/* Free memory used for title, copyright and comments */
g_free (gai->title);
+ g_free (gai->url);
g_free (gai->copyright);
g_free (gai->comments);
@@ -525,6 +538,7 @@
GtkWidget*
gnome_about_new (const gchar *title,
const gchar *version,
+ const gchar *url,
const gchar *copyright,
const gchar **authors,
const gchar *comments,
@@ -540,7 +554,7 @@
about = gtk_type_new (gnome_about_get_type ());
- gnome_about_construct(about, title, version, copyright,
+ gnome_about_construct(about, title, version, url, copyright,
authors, comments, logo);
return GTK_WIDGET (about);
@@ -573,6 +587,7 @@
gnome_about_construct (GnomeAbout *about,
const gchar *title,
const gchar *version,
+ const gchar *url,
const gchar *copyright,
const gchar **authors,
const gchar *comments,
@@ -613,11 +628,14 @@
style = gtk_widget_get_style (drawing_area);
ai = gnome_fill_info (drawing_area,
- title, version,
+ title, version, url,
copyright, authors,
comments, logo);
gtk_signal_connect(GTK_OBJECT(about),"destroy",
GTK_SIGNAL_FUNC(gnome_destroy_about),ai);
+ gtk_signal_connect(GTK_OBJECT(drawing_area),
+ "button_press_event",
+ (GtkSignalFunc)gnome_about_buttonpress, ai);
w = ai->w; h = ai->h;
/* x = (gdk_screen_width () - w) / 2; */
@@ -655,7 +673,7 @@
}
gtk_widget_set_usize ( GTK_WIDGET (drawing_area), w, h);
- gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK);
+ gtk_widget_set_events (drawing_area, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
(GtkSignalFunc) gnome_about_repaint, (gpointer) ai);
@@ -668,3 +686,23 @@
gnome_dialog_set_close( GNOME_DIALOG(about),
TRUE );
}
+
+static void
+gnome_about_buttonpress (GtkWidget *widget, GdkEventButton *event, GnomeAboutInfo *ai)
+{
+ int Tx1, Tx2, Ty1, Ty2; /* coordinates of the title box */
+
+ Ty1 = 1;
+ if (ai->logo)
+ Ty1 += 2 + 2 + ai->logo_h;
+ Ty2 = Ty1 + ai->font_title->descent + ai->font_title->ascent + 13;
+
+ Tx1 = 2;
+ Tx2 = Tx1 + ai->w - 5;
+
+ if (event->y >= Ty1 && event->y <= Ty2 &&
+ event->x >= Tx1 && event->x <= Tx2)
+ if (ai->url)
+ gnome_url_show(ai->url);
+}
+
Index: gnome-about.h
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-about.h,v
retrieving revision 1.7
diff -u -r1.7 gnome-about.h
--- gnome-about.h 1998/08/14 16:51:15 1.7
+++ gnome-about.h 1999/12/31 17:06:53
@@ -53,6 +53,7 @@
GtkWidget* gnome_about_new (const gchar *title, /* Name of the application. */
const gchar *version, /* Version. */
+ const gchar *url, /* URL of home page */
const gchar *copyright, /* Copyright notice (one
line.) */
const gchar **authors, /* NULL terminated list of
@@ -67,6 +68,7 @@
gnome_about_construct (GnomeAbout *about,
const gchar *title,
const gchar *version,
+ const gchar *url,
const gchar *copyright,
const gchar **authors,
const gchar *comments,
Index: winhints_demo.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/winhints_demo.c,v
retrieving revision 1.15
diff -u -r1.15 winhints_demo.c
--- winhints_demo.c 1999/11/22 17:51:45 1.15
+++ winhints_demo.c 1999/12/31 17:06:55
@@ -408,6 +408,7 @@
const gchar *authors[] = {"Max Watson", NULL};
about = gnome_about_new (_("WIN_HINTS Test"), "0.1",
+ "http://www.gnome.org",
_("Copyright (C) 1998"),
authors,
_("Simple test app to check how the WIN_HINTS work.\n"
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]