Mercurial > pidgin.yaz
changeset 21644:6018f0ba6aca
Patch from DB42 to add a little '¡ß' in a scrollbook. I edited the patch in
a few places, and may have broken a few things. Someone should fix those.
Closes #2924.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 26 Nov 2007 07:35:16 +0000 |
parents | 146766959840 |
children | d0ea3a86add5 ae8a9f2866bd |
files | pidgin/gtkblist.c pidgin/gtkscrollbook.c |
diffstat | 2 files changed, 78 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Mon Nov 26 06:41:00 2007 +0000 +++ b/pidgin/gtkblist.c Mon Nov 26 07:35:16 2007 +0000 @@ -4230,7 +4230,7 @@ { PidginBuddyList *gtkblist = (PidginBuddyList *)user_data; int errors = 0; - GList *list; + GList *list = NULL; PidginBuddyListPrivate *priv; priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist); @@ -4243,8 +4243,7 @@ errors = g_list_length(GTK_NOTEBOOK(priv->error_scrollbook->notebook)->children); #endif } - if ((list = purple_accounts_get_all_active()) != NULL || errors || - (list = gtk_container_get_children(GTK_CONTAINER(priv->error_scrollbook)))) { + if ((list = purple_accounts_get_all_active()) != NULL || errors) { gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkblist->notebook), 1); g_list_free(list); } else @@ -4491,6 +4490,7 @@ PurpleAccount *account) { g_hash_table_remove(gtkblist->connection_errors, account); + purple_account_clear_current_error(account); } #define SSL_FAQ_URI "http://d.pidgin.im/wiki/FAQssl" @@ -4511,7 +4511,7 @@ gboolean enabled = purple_account_get_enabled(account, purple_core_get_ui()); char *primary; - + if (enabled) primary = g_strdup_printf(_("%s disconnected"), username); else
--- a/pidgin/gtkscrollbook.c Mon Nov 26 06:41:00 2007 +0000 +++ b/pidgin/gtkscrollbook.c Mon Nov 26 07:35:16 2007 +0000 @@ -1,5 +1,5 @@ /* - * @file gtkscrollbook.c GTK+ Scrolling notebook widget + * @file gtkscrollbook.c GTK+ Scrolling notebook widget * @ingroup pidgin */ @@ -29,9 +29,9 @@ static void pidgin_scroll_book_init (PidginScrollBook *scroll_book); static void pidgin_scroll_book_class_init (PidginScrollBookClass *klass); -static void pidgin_scroll_book_forall (GtkContainer *c, +static void pidgin_scroll_book_forall (GtkContainer *c, gboolean include_internals, - GtkCallback callback, + GtkCallback callback, gpointer user_data); GType @@ -83,8 +83,8 @@ count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook)); #else count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children); -#endif - +#endif + if (index + 1 < count) gtk_notebook_set_current_page(GTK_NOTEBOOK(scroll_book->notebook), index + 1); } @@ -93,24 +93,30 @@ refresh_scroll_box(PidginScrollBook *scroll_book, int index, int count) { char *label; + gtk_widget_show_all(GTK_WIDGET(scroll_book)); - if (count <= 1) - gtk_widget_hide(GTK_WIDGET(scroll_book->hbox)); - else - gtk_widget_show_all(GTK_WIDGET(scroll_book->hbox)); - - + if (count < 1) + gtk_widget_hide_all(scroll_book->hbox); + else { + gtk_widget_show_all(scroll_book->hbox); + if (count == 1) { + gtk_widget_hide(scroll_book->label); + gtk_widget_hide(scroll_book->left_arrow); + gtk_widget_hide(scroll_book->right_arrow); + } + } + label = g_strdup_printf("<span size='smaller' weight='bold'>(%d/%d)</span>", index+1, count); gtk_label_set_markup(GTK_LABEL(scroll_book->label), label); - g_free(label); + g_free(label); if (index == 0) gtk_widget_set_sensitive(scroll_book->left_arrow, FALSE); else gtk_widget_set_sensitive(scroll_book->left_arrow, TRUE); - - if (index +1== count) + + if (index + 1 == count) gtk_widget_set_sensitive(scroll_book->right_arrow, FALSE); else gtk_widget_set_sensitive(scroll_book->right_arrow, TRUE); @@ -128,7 +134,12 @@ count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children); #endif refresh_scroll_box(scroll_book, index, count); - +} + +static void +scroll_close_cb(PidginScrollBook *scroll_book) +{ + gtk_widget_destroy(gtk_notebook_get_nth_page(GTK_NOTEBOOK(scroll_book->notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook)))); } static void @@ -154,7 +165,7 @@ scroll_book = PIDGIN_SCROLL_BOOK(container); scroll_book->children = g_list_append(scroll_book->children, widget); gtk_widget_show(widget); - gtk_notebook_append_page(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), widget, NULL); + gtk_notebook_append_page(GTK_NOTEBOOK(scroll_book->notebook), widget, NULL); page_count_change_cb(PIDGIN_SCROLL_BOOK(container)); } @@ -162,23 +173,12 @@ pidgin_scroll_book_remove(GtkContainer *container, GtkWidget *widget) { int page; - GList *children; - GtkWidget *child; PidginScrollBook *scroll_book; g_return_if_fail(GTK_IS_WIDGET(widget)); scroll_book = PIDGIN_SCROLL_BOOK(container); - children = scroll_book->children; - - while (children) { - child = children->data; - if (child == widget) { - gtk_widget_unparent (widget); - scroll_book->children = g_list_delete_link(scroll_book->children, children); - break; - } - children = children->next; - } + scroll_book->children = g_list_remove(scroll_book->children, widget); + /* gtk_widget_unparent(widget); */ page = gtk_notebook_page_num(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), widget); if (page >= 0) { @@ -225,26 +225,66 @@ container_class->add = pidgin_scroll_book_add; container_class->remove = pidgin_scroll_book_remove; - container_class->forall = pidgin_scroll_book_forall; - + container_class->forall = pidgin_scroll_book_forall; +} + +static gboolean +close_button_left_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label) +{ + static GdkCursor *ptr = NULL; + if (ptr == NULL) { + ptr = gdk_cursor_new(GDK_LEFT_PTR); + } + + gtk_label_set_markup(label, "×"); + gdk_window_set_cursor(event->window, ptr); + return FALSE; +} + +static gboolean +close_button_entered_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label) +{ + static GdkCursor *hand = NULL; + if (hand == NULL) { + hand = gdk_cursor_new(GDK_HAND2); + } + + gtk_label_set_markup(label, "<u>×</u>"); + gdk_window_set_cursor(event->window, hand); + return FALSE; } static void pidgin_scroll_book_init (PidginScrollBook *scroll_book) { GtkWidget *eb; + GtkWidget *close_button; scroll_book->hbox = gtk_hbox_new(FALSE, 0); + /* Close */ + eb = gtk_event_box_new(); + gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0); + gtk_event_box_set_visible_window(GTK_EVENT_BOX(eb), FALSE); + gtk_widget_set_events(eb, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + close_button = gtk_label_new("×"); + g_signal_connect(G_OBJECT(eb), "enter-notify-event", G_CALLBACK(close_button_entered_cb), close_button); + g_signal_connect(G_OBJECT(eb), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_button); + gtk_container_add(GTK_CONTAINER(eb), close_button); + g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_close_cb), scroll_book); + + /* Right arrow */ eb = gtk_event_box_new(); gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0); scroll_book->right_arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE); gtk_container_add(GTK_CONTAINER(eb), scroll_book->right_arrow); g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_right_cb), scroll_book); + /* Count */ scroll_book->label = gtk_label_new(NULL); gtk_box_pack_end(GTK_BOX(scroll_book->hbox), scroll_book->label, FALSE, FALSE, 0); + /* Left arrow */ eb = gtk_event_box_new(); gtk_box_pack_end(GTK_BOX(scroll_book->hbox), eb, FALSE, FALSE, 0); scroll_book->left_arrow = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_NONE); @@ -252,20 +292,18 @@ g_signal_connect_swapped(G_OBJECT(eb), "button-press-event", G_CALLBACK(scroll_left_cb), scroll_book); gtk_box_pack_start(GTK_BOX(scroll_book), scroll_book->hbox, FALSE, FALSE, 0); - + scroll_book->notebook = gtk_notebook_new(); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(scroll_book->notebook), FALSE); gtk_notebook_set_show_border(GTK_NOTEBOOK(scroll_book->notebook), FALSE); - + gtk_box_pack_start(GTK_BOX(scroll_book), scroll_book->notebook, TRUE, TRUE, 0); - + g_signal_connect_swapped(G_OBJECT(scroll_book->notebook), "remove", G_CALLBACK(page_count_change_cb), scroll_book); g_signal_connect(G_OBJECT(scroll_book->notebook), "switch-page", G_CALLBACK(switch_page_cb), scroll_book); gtk_widget_show_all(scroll_book->notebook); } - - GtkWidget * pidgin_scroll_book_new() {