# HG changeset patch # User Sean Egan # Date 1165898702 0 # Node ID fbe2187bceec17643dae04eca86f2a2f8b4cec6a # Parent 4b500bd49d389d882eccc60a7f56856fafa6b9fa [gaim-migrate @ 17968] incomplete. Working on this from home. You may see where it's going. committer: Tailor Script diff -r 4b500bd49d38 -r fbe2187bceec gtk/gtkblist.c --- a/gtk/gtkblist.c Tue Dec 12 03:30:49 2006 +0000 +++ b/gtk/gtkblist.c Tue Dec 12 04:45:02 2006 +0000 @@ -3671,6 +3671,26 @@ return FALSE; } +static gboolean +headline_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, GaimGtkBuddyList *gtkblist) +{ + gdk_window_set_cursor(widget->window, gtkblist->hand_cursor); + return FALSE; +} + +static gboolean +headline_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, GaimGtkBuddyList *gtkblist) +{ + gdk_window_set_cursor(widget->window, gtkblist->arrow_cursor); + return FALSE; +} + +static gboolean +headline_box_press_cb(GtkWidget *widget, GdkEventButton *event, GaimGtkBuddyList *box) +{ + gtk_widget_hide(gtkblist->headline_hbox); +} + /***********************************/ /* Connection error handling stuff */ /***********************************/ @@ -3790,6 +3810,26 @@ create_connection_error_buttons, NULL); } +static gboolean +paint_headline_hbox (GtkWidget *widget, + GdkEventExpose *event, + gpointer user_data) +{ + gtk_paint_flat_box (widget->style, + widget->window, + GTK_STATE_NORMAL, + GTK_SHADOW_OUT, + NULL, + widget, + "tooltip", + widget->allocation.x + 1, + widget->allocation.y + 1, + widget->allocation.width - 2, + widget->allocation.height - 2); + + return FALSE; +} + /******************************************/ /* End of connection error handling stuff */ @@ -3848,6 +3888,7 @@ GtkCellRenderer *rend; GtkTreeViewColumn *column; GtkWidget *menu; + GtkWidget *ebox; GtkWidget *sw; GtkWidget *sep; GtkWidget *label; @@ -3941,6 +3982,25 @@ gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkblist->notebook), 1); } + ebox = gtk_event_box_new(); + gtk_box_pack_start(GTK_BOX(gtkblist->vbox), ebox, FALSE, FALSE, 0); + gtkblist->headline_hbox = gtk_hbox_new(FALSE, 3); + gtk_container_set_border_width(GTK_CONTAINER(gtkblist->headline_hbox), 6); + gtk_container_add(GTK_CONTAINER(ebox), gtkblist->headline_hbox); + gtkblist->headline_image = gtk_image_new_from_pixbuf(NULL); + gtkblist->headline_label = gtk_label_new(NULL); + gtk_box_pack_start(GTK_BOX(gtkblist->headline_hbox), gtkblist->headline_image, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(gtkblist->headline_hbox), gtkblist->headline_label, TRUE, TRUE, 0); + g_signal_connect (gtkblist->headline_hbox, + "expose_event", + G_CALLBACK (paint_headline_hbox), + NULL); + gtkblist->hand_cursor = gdk_cursor_new (GDK_HAND2); + gtkblist->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); + 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); + /****************************** GtkTreeView **********************************/ sw = gtk_scrolled_window_new(NULL,NULL); gtk_widget_show(sw); @@ -4082,11 +4142,11 @@ gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0); gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); + sep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sep, FALSE, FALSE, 0); + gtkblist->scrollbook = gtk_gaim_scroll_book_new(); gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->scrollbook, FALSE, FALSE, 0); - - sep = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sep, FALSE, FALSE, 0); /* Create an empty vbox used for showing connection errors */ gtkblist->error_buttons = gtk_vbox_new(FALSE, 0); @@ -4745,6 +4805,11 @@ g_free(gtkblist); accountmenu = NULL; gtkblist = NULL; + + gdk_cursor_unref(gtkblist->hand_cursor); + gdk_cursor_unref(gtkblist->arrow_cursor); + gtkblist->hand_cursor = NULL; + gtkblist->arrow_cursor = NULL; gaim_prefs_disconnect_by_handle(gaim_gtk_blist_get_handle()); } @@ -5413,6 +5478,16 @@ gtk_container_add(GTK_CONTAINER(gtkblist->scrollbook), widget); } +void +gaim_gtk_blist_set_headline(const char *text, GdkPixbuf *pixbuf, GCallback callback, gpointer user_data) +{ + gtk_label_set_markup(gtkblist->headline_label, text); + gtk_image_set_from_pixbuf(gtkblist->headline_image, pixbuf); + + gtkblist->headline_callback = callback; + gtkblist->headline_data = user_data; + gtk_widget_show_all(gtkblist->headline_hbox); +} static GaimBlistUiOps blist_ui_ops = { diff -r 4b500bd49d38 -r fbe2187bceec gtk/gtkblist.h --- a/gtk/gtkblist.h Tue Dec 12 03:30:49 2006 +0000 +++ b/gtk/gtkblist.h Tue Dec 12 04:45:02 2006 +0000 @@ -95,9 +95,17 @@ GList *tooltipdata; /**< The data for each "chunk" of the tooltip */ GaimBlistNode *selected_node; /**< The currently selected node */ + + GdkCursor *hand_cursor; /**< Hand cursor */ + GdkCursor *arrow_cursor; /**< Arrow cursor */ GtkWidget *scrollbook; /**< Scrollbook for alerts */ - + GtkWidget *headline_hbox; /**< Hbox for headline notification */ + GtkWidget *headline_label; /**< Label for headline notifications */ + GtkWidget *headline_image; /**< Image for headline notifications */ + GCallback headline_callback; /**< Callback for headline notifications */ + gpointer headline_data; /**< User data for headline notifications */ + GtkWidget *error_buttons; /**< Box containing the connection error buttons */ GtkWidget *statusbox; /**< The status selector dropdown */ }; @@ -314,4 +322,17 @@ */ void gaim_gtk_blist_update_account_error_state(GaimAccount *account, const char *message); +/** + * Sets a headline notification + * + * This is currently used for mail notification, but could theoretically be used for anything. + * Only the most recent headline will be shown. + * + * @param text Pango Markup for the label text + * @param pixbuf The GdkPixbuf for the icon + * @param callback The callback to call when headline is clicked + * @param user_data The userdata to include in the callback + */ +void gaim_gtk_blist_set_headline(const char *text, GdkPixbuf *pixbuf, GCallback callback, gpointer user_data); + #endif /* _GAIM_GTKBLIST_H_ */ diff -r 4b500bd49d38 -r fbe2187bceec gtk/gtkscrollbook.c --- a/gtk/gtkscrollbook.c Tue Dec 12 03:30:49 2006 +0000 +++ b/gtk/gtkscrollbook.c Tue Dec 12 04:45:02 2006 +0000 @@ -92,7 +92,6 @@ refresh_scroll_box(GtkGaimScrollBook *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)); @@ -120,9 +119,10 @@ static void page_count_change_cb(GtkGaimScrollBook *scroll_book) { + int count; int index = gtk_notebook_get_current_page(GTK_NOTEBOOK(scroll_book->notebook)); #if GTK_CHECK_VERSION(2,2,0) - int count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook)); + count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(scroll_book->notebook)); #else count = g_list_length(GTK_NOTEBOOK(scroll_book->notebook)->children); #endif @@ -146,6 +146,7 @@ { gtk_widget_show(widget); gtk_notebook_append_page(GTK_NOTEBOOK(GTK_GAIM_SCROLL_BOOK(container)->notebook), widget, NULL); + page_count_change_cb(GTK_GAIM_SCROLL_BOOK(container)); } static void @@ -155,9 +156,8 @@ gpointer callback_data) { GtkGaimScrollBook *scroll_book = GTK_GAIM_SCROLL_BOOK(container); - if (include_internals) { + if (include_internals) (*callback)(scroll_book->hbox, callback_data); - } (*callback)(scroll_book->notebook, callback_data); } @@ -201,9 +201,10 @@ gtk_box_pack_start(GTK_BOX(scroll_book), scroll_book->notebook, TRUE, TRUE, 0); - g_signal_connect_swapped(G_OBJECT(scroll_book->notebook), "add", G_CALLBACK(page_count_change_cb), scroll_book); 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->hbox); + gtk_widget_show_all(scroll_book->notebook); }