im.pidgin.pidgin: 9c910ea3009780694450a04dc7a9227f6f8ca1eb
sadrul at pidgin.im
sadrul at pidgin.im
Mon Nov 26 02:40:33 EST 2007
-----------------------------------------------------------------
Revision: 9c910ea3009780694450a04dc7a9227f6f8ca1eb
Ancestor: 55decf7b3893d1f4798d2a966b93eb9f08858f67
Author: sadrul at pidgin.im
Date: 2007-11-26T07:35:16
Branch: im.pidgin.pidgin
Modified files:
pidgin/gtkblist.c pidgin/gtkscrollbook.c
ChangeLog:
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.
-------------- next part --------------
============================================================
--- pidgin/gtkblist.c 0d95759db5ab57cf7381c8cc32bf41e66fdba224
+++ pidgin/gtkblist.c ba0d1270c90f5ea6b6bd9eba07dccfc62ef07726
@@ -4230,7 +4230,7 @@ static gboolean pidgin_blist_select_note
{
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 @@ static gboolean pidgin_blist_select_note
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 @@ generic_error_destroy_cb(GtkObject *dial
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 @@ add_generic_error_dialog(PurpleAccount *
gboolean enabled =
purple_account_get_enabled(account, purple_core_get_ui());
char *primary;
-
+
if (enabled)
primary = g_strdup_printf(_("%s disconnected"), username);
else
============================================================
--- pidgin/gtkscrollbook.c ae0527657ed6d97d2b6b4a560aba8dda7467e608
+++ pidgin/gtkscrollbook.c a00c4006cadb2125aea25639d5a8317cd36d63a1
@@ -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_class_ini
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 @@ scroll_right_cb(PidginScrollBook *scroll
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 *scr
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,10 +134,15 @@ page_count_change_cb(PidginScrollBook *s
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
switch_page_cb(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, PidginScrollBook *scroll_book)
{
int count;
@@ -154,7 +165,7 @@ pidgin_scroll_book_add(GtkContainer *con
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,24 +173,13 @@ pidgin_scroll_book_remove(GtkContainer *
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;
+ scroll_book->children = g_list_remove(scroll_book->children, widget);
+ /* gtk_widget_unparent(widget); */
- 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;
- }
-
page = gtk_notebook_page_num(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), widget);
if (page >= 0) {
gtk_notebook_remove_page(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), page);
@@ -225,26 +225,66 @@ pidgin_scroll_book_class_init (PidginScr
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 @@ pidgin_scroll_book_init (PidginScrollBoo
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()
{
More information about the Commits
mailing list