Mercurial > pidgin.yaz
diff pidgin/gtkblist.c @ 30016:97005a2e99d7
Use a small GtkButton instead of the custom "X" for close in various
places in the Buddy List and conversations. The minidialog still uses the
X, but it's a little different, anyway.
Refs #8727.
committer: Elliott Sales de Andrade <qulogic@pidgin.im>
author | Kosta Arvanitis <karvanitis@hotmail.com> |
---|---|
date | Sat, 20 Mar 2010 06:02:11 +0000 |
parents | 41c53be0e8b5 |
children | 0d613fa75e5f |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Fri Mar 19 02:44:22 2010 +0000 +++ b/pidgin/gtkblist.c Sat Mar 20 06:02:11 2010 +0000 @@ -70,8 +70,6 @@ #include <gtk/gtk.h> #include <gdk/gdk.h> -#define HEADLINE_CLOSE_SIZE 11 - typedef struct { PurpleAccount *account; @@ -4983,58 +4981,16 @@ } static gboolean -headline_hover_close(int x, int y) -{ - GtkWidget *w = gtkblist->headline_hbox; - if (x <= w->allocation.width && x >= w->allocation.width - HEADLINE_CLOSE_SIZE && - y >= 0 && y <= HEADLINE_CLOSE_SIZE) - return TRUE; - return FALSE; -} - -static gboolean headline_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, PidginBuddyList *gtkblist) { gdk_window_set_cursor(widget->window, gtkblist->hand_cursor); - - if (gtkblist->headline_close) { - gdk_draw_pixbuf(widget->window, NULL, gtkblist->headline_close, - 0, 0, - widget->allocation.width - 2 - HEADLINE_CLOSE_SIZE, 2, - HEADLINE_CLOSE_SIZE, HEADLINE_CLOSE_SIZE, - GDK_RGB_DITHER_NONE, 0, 0); - gtk_paint_focus(widget->style, widget->window, GTK_STATE_PRELIGHT, - NULL, widget, NULL, - widget->allocation.width - HEADLINE_CLOSE_SIZE - 3, 1, - HEADLINE_CLOSE_SIZE + 2, HEADLINE_CLOSE_SIZE + 2); - } - return FALSE; } -#if 0 -static gboolean -headline_box_motion_cb(GtkWidget *widget, GdkEventMotion *event, PidginBuddyList *gtkblist) -{ - purple_debug_fatal("motion", "%d %d\n", (int)event->x, (int)event->y); - if (headline_hover_close((int)event->x, (int)event->y)) - gtk_paint_focus(widget->style, widget->window, GTK_STATE_PRELIGHT, - NULL, widget, NULL, - widget->allocation.width - HEADLINE_CLOSE_SIZE - 3, 1, - HEADLINE_CLOSE_SIZE + 2, HEADLINE_CLOSE_SIZE + 2); - return FALSE; -} -#endif - static gboolean headline_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, PidginBuddyList *gtkblist) { gdk_window_set_cursor(widget->window, gtkblist->arrow_cursor); - if (gtkblist->headline_close) { - GdkRectangle rect = {widget->allocation.width - 3 - HEADLINE_CLOSE_SIZE, 1, - HEADLINE_CLOSE_SIZE + 2, HEADLINE_CLOSE_SIZE + 2}; - gdk_window_invalidate_rect(widget->window, &rect, TRUE); - } return FALSE; } @@ -5057,10 +5013,17 @@ } static gboolean +headline_close_press_cb(GtkButton *button, PidginBuddyList *gtkblist) +{ + gtk_widget_hide(gtkblist->headline_hbox); + return FALSE; +} + +static gboolean headline_box_press_cb(GtkWidget *widget, GdkEventButton *event, PidginBuddyList *gtkblist) { gtk_widget_hide(gtkblist->headline_hbox); - if (gtkblist->headline_callback && !headline_hover_close((int)event->x, (int)event->y)) + if (gtkblist->headline_callback) g_idle_add(headline_click_callback, NULL); else { if (gtkblist->headline_destroy) @@ -5812,6 +5775,7 @@ GtkWidget *sw; GtkWidget *sep; GtkWidget *label; + GtkWidget *close; char *pretty, *tmp; const char *theme_name; GtkAccelGroup *accel_group; @@ -5940,11 +5904,18 @@ NULL); gtk_widget_set_name(gtkblist->headline_hbox, "gtk-tooltips"); - gtkblist->headline_close = gtk_widget_render_icon(ebox, GTK_STOCK_CLOSE, - gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC), NULL); gtkblist->hand_cursor = gdk_cursor_new (GDK_HAND2); gtkblist->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); + /* Close button. */ + close = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); + gtkblist->headline_close = pidgin_create_small_button(close); + gtk_box_pack_start(GTK_BOX(gtkblist->headline_hbox), gtkblist->headline_close, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(2,12,0) + gtk_widget_set_tooltip_text(gtkblist->headline_close, _("Close")); +#endif + g_signal_connect(gtkblist->headline_close, "clicked", G_CALLBACK(headline_close_press_cb), gtkblist); + g_signal_connect(G_OBJECT(ebox), "enter-notify-event", G_CALLBACK(headline_box_enter_cb), gtkblist); g_signal_connect(G_OBJECT(ebox), "leave-notify-event", G_CALLBACK(headline_box_leave_cb), gtkblist); g_signal_connect(G_OBJECT(ebox), "button-press-event", G_CALLBACK(headline_box_press_cb), gtkblist); @@ -6948,9 +6919,6 @@ purple_signals_disconnect_by_handle(gtkblist); - if (gtkblist->headline_close) - g_object_unref(G_OBJECT(gtkblist->headline_close)); - gtk_widget_destroy(gtkblist->window); pidgin_blist_tooltip_destroy();