2006-03-28 [colin] 2.0.0cvs180
authorColin Leroy <colin@colino.net>
Tue, 28 Mar 2006 17:31:10 +0000 (17:31 +0000)
committerColin Leroy <colin@colino.net>
Tue, 28 Mar 2006 17:31:10 +0000 (17:31 +0000)
* src/gtk/gtkutils.c
* src/gtk/gtkutils.h
Add a gtkut_get_link_btn() function that
creates a button which acts like an URI
* src/prefs_themes.c
* src/gtk/about.c
Use this function (factorizes codes)
* src/common/defs.h
* src/gtk/pluginwindow.c
Add a "Get more..." in the plugins window

ChangeLog
PATCHSETS
configure.ac
src/common/defs.h
src/gtk/about.c
src/gtk/gtkutils.c
src/gtk/gtkutils.h
src/gtk/pluginwindow.c
src/prefs_themes.c

index 94127a8..1dc9fdb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-03-28 [colin]     2.0.0cvs180
+
+       * src/gtk/gtkutils.c
+       * src/gtk/gtkutils.h
+               Add a gtkut_get_link_btn() function that
+               creates a button which acts like an URI
+       * src/prefs_themes.c
+       * src/gtk/about.c
+               Use this function (factorizes codes)
+       * src/common/defs.h
+       * src/gtk/pluginwindow.c
+               Add a "Get more..." in the plugins window
+
 2006-03-28 [colin]     2.0.0cvs179
 
        * src/common/smtp.c
index 45e1629..2713a34 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.96.2.104 -r 1.96.2.105 src/textview.c;  ) > 2.0.0cvs177.patchset
 ( cvs diff -u -r 1.13.2.7 -r 1.13.2.8 src/undo.c;  ) > 2.0.0cvs178.patchset
 ( cvs diff -u -r 1.11.2.16 -r 1.11.2.17 src/common/smtp.c;  cvs diff -u -r 1.3.2.4 -r 1.3.2.5 src/common/passcrypt.c;  cvs diff -u -r 1.13.2.8 -r 1.13.2.9 src/undo.c;  ) > 2.0.0cvs179.patchset
+( cvs diff -u -r 1.3.2.39 -r 1.3.2.40 src/prefs_themes.c;  cvs diff -u -r 1.9.2.23 -r 1.9.2.24 src/common/defs.h;  cvs diff -u -r 1.4.2.29 -r 1.4.2.30 src/gtk/about.c;  cvs diff -u -r 1.5.2.23 -r 1.5.2.24 src/gtk/gtkutils.c;  cvs diff -u -r 1.4.2.18 -r 1.4.2.19 src/gtk/gtkutils.h;  cvs diff -u -r 1.5.2.28 -r 1.5.2.29 src/gtk/pluginwindow.c;  ) > 2.0.0cvs180.patchset
index 4396554..5ebc08b 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=179
+EXTRA_VERSION=180
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 0de58cb..b08c097 100644 (file)
@@ -71,6 +71,7 @@
 #define HOMEPAGE_URI           "http://claws.sylpheed.org/"
 #define MANUAL_URI             "http://claws.sylpheed.org/manual/"
 #define FAQ_URI                        "http://claws.sylpheed.org/faq.php"
+#define PLUGINS_URI            "http://claws.sylpheed.org/plugins.php"
 #define BUGZILLA_URI           "http://www.thewildbeast.co.uk/sylpheed-claws/bugzilla/enter_bug.cgi"
 #define THEMES_URI             "http://claws.sylpheed.org/themes.php"
 #define MAILING_LIST_URI       "http://claws.sylpheed.org/MLs.php"
index d7d3e73..8162106 100644 (file)
@@ -60,7 +60,6 @@ static GdkCursor *text_cursor = NULL;
 
 static void about_create(void);
 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event);
-static void about_uri_clicked(GtkButton *button, gpointer data);
 static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj,
                                        GdkEvent *event, GtkTextIter *iter,
                                        GtkWidget *textview);
@@ -102,10 +101,6 @@ static void about_create(void)
        GtkWidget *button;
        GtkWidget *scrolledwin;
        GtkWidget *notebook;
-       GtkStyle *style;
-       GdkColormap *cmap;
-       GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
-       gboolean success[2];
        char *markup;
        GtkWidget *text;
        GtkWidget *confirm_area;
@@ -113,7 +108,7 @@ static void about_create(void)
        GtkTextBuffer *buffer;
        GtkTextIter iter;
        GtkTextTag *tag;
-
+       GdkColor uri_color;
 #if HAVE_SYS_UTSNAME_H
        struct utsname utsbuf;
 #endif
@@ -157,27 +152,8 @@ static void about_create(void)
        gtk_label_set_markup(GTK_LABEL(label), markup);
        g_free(markup);
 
-       button = gtk_button_new_with_label(" "HOMEPAGE_URI" ");
+       button = gtkut_get_link_btn(window, HOMEPAGE_URI, " "HOMEPAGE_URI" ");
        gtk_box_pack_start(GTK_BOX(vbox2), button, FALSE, FALSE, 0);
-       gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
-       g_signal_connect(G_OBJECT(button), "clicked",
-                        G_CALLBACK(about_uri_clicked), NULL);
-       buf[0] = ' ';
-       for (i = 1; i <= strlen(HOMEPAGE_URI); i++) buf[i] = '_';
-       strcpy(buf + i, " ");
-       gtk_label_set_pattern(GTK_LABEL(GTK_BIN(button)->child), buf);
-       cmap = gdk_drawable_get_colormap(window->window);
-       gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
-       if (success[0] == TRUE && success[1] == TRUE) {
-               gtk_widget_ensure_style(GTK_BIN(button)->child);
-               style = gtk_style_copy
-                       (gtk_widget_get_style(GTK_BIN(button)->child));
-               style->fg[GTK_STATE_NORMAL]   = uri_color[0];
-               style->fg[GTK_STATE_ACTIVE]   = uri_color[1];
-               style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
-               gtk_widget_set_style(GTK_BIN(button)->child, style);
-       } else
-               g_warning("about_create(): color allocation failed.\n");
 
 #if HAVE_SYS_UTSNAME_H
        uname(&utsbuf);
@@ -554,11 +530,6 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event)
        return FALSE;
 }
 
-static void about_uri_clicked(GtkButton *button, gpointer data)
-{
-       open_uri(HOMEPAGE_URI, prefs_common.uri_cmd);
-}
-
 static gboolean about_textview_uri_clicked(GtkTextTag *tag, GObject *obj,
                                        GdkEvent *event, GtkTextIter *iter,
                                        GtkWidget *textview)
index bdb7383..d0e8172 100644 (file)
@@ -1142,3 +1142,112 @@ GtkWidget *face_get_from_header(const gchar *o_face)
        g_object_unref(pixbuf);
        return image;
 }
+
+static GdkCursor *hand_cursor = NULL;
+
+static void link_btn_enter(GtkButton *button, gpointer data)
+{
+       GtkWidget *window = (GtkWidget *)data;
+
+       if (!hand_cursor)
+               hand_cursor = gdk_cursor_new(GDK_HAND2);
+       if (window && window->window)
+               gdk_window_set_cursor(window->window, hand_cursor);
+
+       gtk_button_set_relief(button, GTK_RELIEF_NONE);
+       gtk_widget_set_state(GTK_WIDGET(button), GTK_STATE_NORMAL);
+       
+}
+
+static void link_btn_leave(GtkButton *button, gpointer data)
+{
+       GtkWidget *window = (GtkWidget *)data;
+
+       if (window && window->window)
+               gdk_window_set_cursor(window->window, NULL);
+
+       gtk_button_set_relief(button, GTK_RELIEF_NONE);
+       gtk_widget_set_state(GTK_WIDGET(button), GTK_STATE_NORMAL);
+}
+
+static void link_btn_pressed(GtkButton *button, gpointer data)
+{
+       gtk_button_set_relief(button, GTK_RELIEF_NONE);
+       gtk_widget_set_state(GTK_WIDGET(button), GTK_STATE_NORMAL);
+}
+
+static void link_btn_released(GtkButton *button, gpointer data)
+{
+       gtk_button_set_relief(button, GTK_RELIEF_NONE);
+       gtk_widget_set_state(GTK_WIDGET(button), GTK_STATE_NORMAL);
+}
+
+static void link_btn_clicked(GtkButton *button, gpointer data)
+{
+       gchar *url = (gchar *)data;
+       gtk_button_set_relief(button, GTK_RELIEF_NONE);
+       gtk_widget_set_state(GTK_WIDGET(button), GTK_STATE_NORMAL);
+       open_uri(url, prefs_common.uri_cmd);
+}
+
+static void link_btn_unrealize(GtkButton *button, gpointer data)
+{
+       gchar *url = (gchar *)data;
+       g_signal_handlers_disconnect_by_func(G_OBJECT(button), 
+                        G_CALLBACK(link_btn_clicked), url);
+       g_free(url);
+}
+
+GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *label)
+{
+       GtkWidget *btn;
+       GtkWidget *btn_label;
+       GdkColormap *cmap;
+       GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
+       gboolean success[2];
+       gchar *underlined = NULL;
+       gchar *local_url = NULL;
+       if (!url)
+               return NULL;
+
+       gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+                                              &uri_color[0]);
+       gtkut_convert_int_to_gdk_color(prefs_common.uri_col,
+                                              &uri_color[1]);
+
+       underlined = g_markup_printf_escaped("<u>%s</u>", label?label:url);
+       btn = gtk_button_new_with_label(underlined);
+       g_free(underlined);
+       gtk_button_set_relief(GTK_BUTTON(btn), GTK_RELIEF_NONE);
+       btn_label = GTK_BIN(btn)->child;
+       gtk_label_set_use_markup(GTK_LABEL(btn_label), TRUE);
+       cmap = gdk_drawable_get_colormap(window->window);
+       gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
+       if (success[0] == TRUE && success[1] == TRUE) {
+               GtkStyle *style;
+               gtk_widget_ensure_style(btn_label);
+               style = gtk_style_copy
+                       (gtk_widget_get_style(btn_label));
+               style->fg[GTK_STATE_NORMAL]   = uri_color[0];
+               style->fg[GTK_STATE_ACTIVE]   = uri_color[1];
+               style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
+               gtk_widget_set_style(btn_label, style);
+       } else
+               g_warning("about_create(): color allocation failed.\n");
+
+       g_signal_connect(G_OBJECT(btn), "enter",
+                        G_CALLBACK(link_btn_enter), window);
+       g_signal_connect(G_OBJECT(btn), "leave",
+                        G_CALLBACK(link_btn_leave), window);
+       g_signal_connect(G_OBJECT(btn), "pressed",
+                        G_CALLBACK(link_btn_pressed), window);
+       g_signal_connect(G_OBJECT(btn), "released",
+                        G_CALLBACK(link_btn_released), window);
+                        
+       local_url = g_strdup(url);
+       g_signal_connect(G_OBJECT(btn), "clicked",
+                        G_CALLBACK(link_btn_clicked), local_url);
+       g_signal_connect(G_OBJECT(btn), "unrealize",
+                        G_CALLBACK(link_btn_unrealize), local_url);
+       return btn;
+}
index c401497..154d5b0 100644 (file)
@@ -201,5 +201,6 @@ gboolean get_tag_range(GtkTextIter *iter,
                                       GtkTextIter *end_iter);
 
 GtkWidget *face_get_from_header(const gchar *o_face);
+GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *label);
 
 #endif /* __GTKUTILS_H__ */
index 86b60d5..67381f7 100644 (file)
@@ -28,6 +28,7 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
+#include "defs.h"
 #include "plugin.h"
 
 #include "filesel.h"
@@ -264,10 +265,11 @@ void pluginwindow_create()
        GtkWidget *label13;
        GtkWidget *scrolledwindow3;
        GtkWidget *plugin_desc;
-       GtkWidget *hbuttonbox1;
+       GtkWidget *hbuttonbox1, *hbox3;
        GtkWidget *load_btn;
        GtkWidget *unload_btn;
        GtkWidget *close_btn;
+       GtkWidget *get_more_btn;
        static GdkGeometry geometry;
        
        debug_print("Creating plugins window...\n");
@@ -324,9 +326,19 @@ void pluginwindow_create()
        gtk_widget_show(plugin_desc);
        gtk_container_add(GTK_CONTAINER(scrolledwindow3), plugin_desc);
 
+       hbox3 = gtk_hbox_new(FALSE, 0);
+       gtk_widget_show(hbox3);
        hbuttonbox1 = gtk_hbutton_box_new();
        gtk_widget_show(hbuttonbox1);
-       gtk_box_pack_start(GTK_BOX(vbox1), hbuttonbox1, FALSE, FALSE, 0);
+
+       gtk_widget_realize(window);
+       get_more_btn = gtkut_get_link_btn(window, PLUGINS_URI, _("Get more..."));
+       gtk_misc_set_alignment(GTK_MISC(GTK_BIN(get_more_btn)->child), 0, 0.5);
+       gtk_widget_show(get_more_btn);
+
+       gtk_box_pack_start(GTK_BOX(hbox3), get_more_btn, TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox3), hbuttonbox1, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox1), hbox3, FALSE, FALSE, 0);
        gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1),
                                  GTK_BUTTONBOX_END);
        gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 6);
index dd1f99a..cb8fd6f 100644 (file)
@@ -579,11 +579,6 @@ end_inst:
        g_free(themename);
 }
 
-static void prefs_themes_btn_more_clicked_cb(GtkWidget *widget, gpointer data)
-{
-       open_uri(THEMES_URI, prefs_common.uri_cmd);
-}
-
 static void prefs_themes_menu_item_activated_cb(GtkWidget *widget, gpointer data)
 {
        ThemesData *tdata = prefs_themes_data;
@@ -805,11 +800,6 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
 {
        ThemesPage *prefs_themes = (ThemesPage *)page;
        ThemesData *tdata = prefs_themes_data;
-       /* from gtk/about.c */
-       GtkStyle *style;
-       GdkColormap *cmap;
-       GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
-       gboolean success[2];
 
        GtkWidget *vbox1;
        GtkWidget *frame1;
@@ -875,27 +865,9 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
        gtk_box_pack_start (GTK_BOX (hbox3), btn_install, FALSE, FALSE, 0);
        GTK_WIDGET_SET_FLAGS (btn_install, GTK_CAN_DEFAULT);
 
-       btn_more = gtk_button_new_with_label (_("<u>Get more...</u>"));
+       btn_more = gtkut_get_link_btn(window, THEMES_URI, _("Get more..."));
        gtk_widget_show (btn_more);
        gtk_box_pack_start (GTK_BOX (hbox3), btn_more, FALSE, FALSE, 0);
-       GTK_WIDGET_SET_FLAGS (btn_more, GTK_CAN_DEFAULT);
-       /* make it look like an uri */
-       gtk_button_set_relief(GTK_BUTTON(btn_more), GTK_RELIEF_NONE);
-       gtk_label_set_use_markup(GTK_LABEL(GTK_BIN(btn_more)->child), TRUE);
-
-       cmap = gdk_drawable_get_colormap((mainwindow_get_mainwindow())->window->window);
-       gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
-       if (success[0] == TRUE && success[1] == TRUE) {
-               gtk_widget_ensure_style(GTK_BIN(btn_more)->child);
-               style = gtk_style_copy
-                       (gtk_widget_get_style(GTK_BIN(btn_more)->child));
-               style->fg[GTK_STATE_NORMAL]   = uri_color[0];
-               style->fg[GTK_STATE_ACTIVE]   = uri_color[1];
-               style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
-               gtk_widget_set_style(GTK_BIN(btn_more)->child, style);
-       } else
-               g_warning("prefs_themes_create_widget(): color allocation failed.\n");
-
 
        label_global_status = gtk_label_new ("");
        gtk_widget_show (label_global_status);
@@ -1038,9 +1010,6 @@ static void prefs_themes_create_widget(PrefsPage *page, GtkWindow *window, gpoin
        g_signal_connect(G_OBJECT(btn_install), "clicked",
                         G_CALLBACK(prefs_themes_btn_install_clicked_cb),
                         NULL);
-       g_signal_connect(G_OBJECT(btn_more), "clicked",
-                        G_CALLBACK(prefs_themes_btn_more_clicked_cb),
-                        NULL);
 
        prefs_themes->window = GTK_WIDGET(window);