# HG changeset patch # User Sean Egan # Date 1109493311 0 # Node ID 868aafbe859b1b5ceb88654dd5f355da72e1f071 # Parent 0376d4c84b9ff9ae135680ee80d0df34dc00705f [gaim-migrate @ 12153] GtkGaimStatusBox, a new status selection widget. It currently sucks. Pretty much just the UI code with enough copy/paste code hacked in from gtkstatusselector to minimally work. Minimally work provided you're only using protocol which have already been updated to handle offline/online as statuses. Which I think is limited to AIM and Yahoo! right now. Anyway, it's cool. committer: Tailor Script diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/Makefile.am --- a/pixmaps/Makefile.am Sat Feb 26 19:25:44 2005 +0000 +++ b/pixmaps/Makefile.am Sun Feb 27 08:35:11 2005 +0000 @@ -26,6 +26,18 @@ online.png \ pause.png \ send-im.png \ + status-online.png \ + status-offline.png \ + status-away.png \ + status-invisible.png \ + status-typing0.png \ + status-typing1.png \ + status-typing2.png \ + status-typing3.png \ + status-connect0.png \ + status-connect1.png \ + status-connect2.png \ + status-connect3.png \ tb_drag_arrow_down.xpm \ tb_drag_arrow_left.xpm \ tb_drag_arrow_right.xpm \ @@ -65,7 +77,7 @@ gaimiconpix_DATA = away.png connect.png msgpend.png offline.png online.png msgunread.png info.png gaimdistpixdir = $(datadir)/pixmaps/gaim -gaimdistpix_DATA = logo.png tb_drag_arrow_down.xpm tb_drag_arrow_left.xpm tb_drag_arrow_right.xpm tb_drag_arrow_up.xpm typed.png typing.png +gaimdistpix_DATA = logo.png tb_drag_arrow_down.xpm tb_drag_arrow_left.xpm tb_drag_arrow_right.xpm tb_drag_arrow_up.xpm typed.png typing.png status-online.png status-offline.png status-away.png status-invisible.png status-typing0.png status-typing1.png status-typing2.png status-typing3.png status-connect0.png status-connect1.png status-connect2.png status-connect3.png distpixmapdir = $(datadir)/pixmaps distpixmap_DATA = gaim.png diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-away.png Binary file pixmaps/status-away.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-connect0.png Binary file pixmaps/status-connect0.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-connect1.png Binary file pixmaps/status-connect1.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-connect2.png Binary file pixmaps/status-connect2.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-connect3.png Binary file pixmaps/status-connect3.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-invisible.png Binary file pixmaps/status-invisible.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-offline.png Binary file pixmaps/status-offline.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-online.png Binary file pixmaps/status-online.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-typing0.png Binary file pixmaps/status-typing0.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-typing1.png Binary file pixmaps/status-typing1.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-typing2.png Binary file pixmaps/status-typing2.png has changed diff -r 0376d4c84b9f -r 868aafbe859b pixmaps/status-typing3.png Binary file pixmaps/status-typing3.png has changed diff -r 0376d4c84b9f -r 868aafbe859b src/Makefile.am --- a/src/Makefile.am Sat Feb 26 19:25:44 2005 +0000 +++ b/src/Makefile.am Sun Feb 27 08:35:11 2005 +0000 @@ -171,7 +171,7 @@ gtksavedstatuses.c \ gtksound.c \ gtksourceiter.c \ - gtkstatusselector.c \ + gtkstatusbox.c \ gtkstock.c \ gtkthemes.c \ gtkutils.c \ @@ -206,7 +206,7 @@ gtksavedstatuses.h \ gtksound.h \ gtksourceiter.h \ - gtkstatusselector.h \ + gtkstatusbox.h \ gtkstock.h \ gtkutils.h \ internal.h diff -r 0376d4c84b9f -r 868aafbe859b src/gtkblist.c --- a/src/gtkblist.c Sat Feb 26 19:25:44 2005 +0000 +++ b/src/gtkblist.c Sun Feb 27 08:35:11 2005 +0000 @@ -53,7 +53,7 @@ #include "gtkroomlist.h" #include "gtksavedstatuses.h" #include "gtksound.h" -#include "gtkstatusselector.h" +#include "gtkstatusbox.h" #include "gtkutils.h" #include @@ -3353,7 +3353,6 @@ GtkTreeViewColumn *column; GtkWidget *menu; GtkWidget *sw; - GtkWidget *selector; GtkAccelGroup *accel_group; GtkTreeSelection *selection; GtkTargetEntry dte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, @@ -3495,9 +3494,10 @@ gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); gaim_gtk_blist_update_columns(); - selector = gaim_gtk_status_selector_new(); - gtk_widget_show(selector); - gtk_box_pack_start(GTK_BOX(gtkblist->vbox), selector, FALSE, TRUE, 0); + gtkblist->statusbox = gtk_gaim_status_box_new(); + + gtk_widget_show(gtkblist->statusbox); + gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); /* set the Show Offline Buddies option. must be done * after the treeview or faceprint gets mad. -Robot101 @@ -4749,6 +4749,11 @@ return &blist_ui_ops; } +GaimGtkBuddyList *gaim_gtk_blist_get_default_gtk_blist() +{ + return gtkblist; +} + static void account_signon_cb(GaimConnection *gc, gpointer z) { GaimAccount *account = gaim_connection_get_account(gc); diff -r 0376d4c84b9f -r 868aafbe859b src/gtkblist.h --- a/src/gtkblist.h Sat Feb 26 19:25:44 2005 +0000 +++ b/src/gtkblist.h Sun Feb 27 08:35:11 2005 +0000 @@ -83,7 +83,7 @@ GtkWidget *tipwindow; /**< The window used by the tooltip */ GaimBlistNode *selected_node; /**< The currently selected node */ - + GtkWidget *statusbox; /**< The status selector dropdown */ GdkPixbuf *east, *south; /**< Drop shadow stuff */ GdkWindow *east_shadow, *south_shadow; /**< Drop shadow stuff */ @@ -122,6 +122,17 @@ GaimBlistUiOps *gaim_gtk_blist_get_ui_ops(void); /** + * Returns the default gtk buddy list + * + * There's normally only one buddy list window, but that isn't a necessity. This function + * returns the GaimGtkBuddyList we're most likely wanting to work with. This is slightly + * cleaner than an externed global. + * + * @return The default GTK buddy list + */ +GaimGtkBuddyList *gaim_gtk_blist_get_default_gtk_blist(); + +/** * Returns the base image to represent the account, based on the currently selected theme * * @param account The account. diff -r 0376d4c84b9f -r 868aafbe859b src/gtkconn.c --- a/src/gtkconn.c Sat Feb 26 19:25:44 2005 +0000 +++ b/src/gtkconn.c Sun Feb 27 08:35:11 2005 +0000 @@ -29,6 +29,8 @@ #include "debug.h" #include "notify.h" #include "prefs.h" +#include "gtkblist.h" +#include "gtkstatusbox.h" #include "gtkstock.h" #include "util.h" @@ -39,24 +41,32 @@ static void gaim_gtk_connection_connect_progress(GaimConnection *gc, const char *text, size_t step, size_t step_count) { - /* SME - Pulse the statusselector */ + GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); + if (!gtkblist) + return; + gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), + (gaim_connections_get_connecting() != NULL)); + gtk_gaim_status_box_pulse_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox)); } static void gaim_gtk_connection_connected(GaimConnection *gc) { - -#if 0 /* XXX CORE/UI */ - do_away_menu(); -#endif + GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); + if (!gtkblist) + return; + gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), + (gaim_connections_get_connecting() != NULL)); gaim_gtk_blist_update_protocol_actions(); } static void gaim_gtk_connection_disconnected(GaimConnection *gc) { -#if 0 /* XXX CORE/UI */ - do_away_menu(); -#endif + GaimGtkBuddyList *gtkblist = gaim_gtk_blist_get_default_gtk_blist(); + if (!gtkblist) + return; + gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), + (gaim_connections_get_connecting() != NULL)); gaim_gtk_blist_update_protocol_actions(); if (gaim_connections_get_all() != NULL) diff -r 0376d4c84b9f -r 868aafbe859b src/gtkstatusbox.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gtkstatusbox.c Sun Feb 27 08:35:11 2005 +0000 @@ -0,0 +1,475 @@ +/* + * @file gtkstatusbox.c GTK+ Status Selection Widget + * @ingroup gtkui + * + * gaim + * + * Gaim is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "internal.h" +#include "account.h" +#include "status.h" +#include "gtkgaim.h" +#include "gtkstock.h" +#include "gtkstatusbox.h" + +static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); + +static void gtk_gaim_status_box_changed(GtkComboBox *box); +static void gtk_gaim_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void gtk_gaim_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); +static gboolean gtk_gaim_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); +static void gtk_gaim_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); + +static void (*combo_box_size_request)(GtkWidget *widget, GtkRequisition *requisition); +static void (*combo_box_size_allocate)(GtkWidget *widget, GtkAllocation *allocation); +static gboolean (*combo_box_expose_event)(GtkWidget *widget, GdkEventExpose *event); +static void (*combo_box_forall) (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); +enum { + ICON_COLUMN, + TEXT_COLUMN, + TITLE_COLUMN, + DESC_COLUMN, + TYPE_COLUMN, + NUM_COLUMNS +}; + +static void gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass); +static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box); + +GType +gtk_gaim_status_box_get_type (void) +{ + static GType status_box_type = 0; + + if (!status_box_type) + { + static const GTypeInfo status_box_info = + { + sizeof (GtkGaimStatusBoxClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gtk_gaim_status_box_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkGaimStatusBox), + 0, + (GInstanceInitFunc) gtk_gaim_status_box_init + }; + + status_box_type = g_type_register_static (GTK_TYPE_COMBO_BOX, + "GtkGaimStatusBox", + &status_box_info, + 0); + } + + return status_box_type; +} + +static void +gtk_gaim_status_box_class_init (GtkGaimStatusBoxClass *klass) +{ + GObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkComboBoxClass *parent_class = (GtkComboBoxClass*)klass; + GtkContainerClass *container_class = (GtkContainerClass*)klass; + + parent_class->changed = gtk_gaim_status_box_changed; + widget_class = (GtkWidgetClass*)klass; + combo_box_size_request = widget_class->size_request; + widget_class->size_request = gtk_gaim_status_box_size_request; + combo_box_size_allocate = widget_class->size_allocate; + widget_class->size_allocate = gtk_gaim_status_box_size_allocate; + combo_box_expose_event = widget_class->expose_event; + widget_class->expose_event = gtk_gaim_status_box_expose_event; + + combo_box_forall = container_class->forall; + container_class->forall = gtk_gaim_status_box_forall; + + object_class = (GObjectClass *)klass; +} + +static void +gtk_gaim_status_box_refresh(GtkGaimStatusBox *status_box) +{ + char *text; + char aa_color[8]; + GdkPixbuf *pixbuf; + + GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); + snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", + style->text_aa[GTK_STATE_NORMAL].red >> 8, + style->text_aa[GTK_STATE_NORMAL].green >> 8, + style->text_aa[GTK_STATE_NORMAL].blue >> 8); + + if (status_box->error) { + text = g_strdup_printf("%s\n%s", + status_box->title, status_box->error); + } else if (status_box->typing) { + text = text = g_strdup_printf("%s\n%s", + status_box->title, + aa_color, + _("Typing")); + } else if (status_box->connecting) { + text = g_strdup_printf("%s\n%s", + status_box->title, + aa_color, + _("Connecting")); + } else if (status_box->desc) { + text = g_strdup_printf("%s\n%s", + status_box->title, aa_color, status_box->desc); + } else { + text = g_strdup_printf("%s", status_box->title); + } + + if (status_box->error) + pixbuf = status_box->error_pixbuf; + else if (status_box->typing) + pixbuf = status_box->typing_pixbufs[status_box->typing_index]; + else if (status_box->connecting) + pixbuf = status_box->connecting_pixbufs[status_box->connecting_index]; + else + pixbuf = status_box->pixbuf; + + gtk_list_store_set(status_box->store, &(status_box->iter), + ICON_COLUMN, pixbuf, + TEXT_COLUMN, text, + TITLE_COLUMN, status_box->title, + DESC_COLUMN, status_box->desc, + TYPE_COLUMN, NULL, -1); + gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), gtk_tree_path_new_from_string("0")); + + g_free(text); +} + +static void +gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) +{ + GtkCellRenderer *text_rend = gtk_cell_renderer_text_new(); + GtkCellRenderer *icon_rend = gtk_cell_renderer_pixbuf_new(); + GtkTextBuffer *buffer; + GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; + GtkIconSize icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); + + status_box->imhtml_visible = FALSE; + status_box->error_pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, + icon_size, "GtkGaimStatusBox"); + status_box->connecting_index = 0; + status_box->connecting_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT0, + icon_size, "GtkGaimStatusBox"); + status_box->connecting_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT1, + icon_size, "GtkGaimStatusBox"); + status_box->connecting_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT2, + icon_size, "GtkGaimStatusBox"); + status_box->connecting_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_CONNECT3, + icon_size, "GtkGaimStatusBox"); + + status_box->typing_index = 0; + status_box->typing_pixbufs[0] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING0, + icon_size, "GtkGaimStatusBox"); + status_box->typing_pixbufs[1] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING1, + icon_size, "GtkGaimStatusBox"); + status_box->typing_pixbufs[2] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING2, + icon_size, "GtkGaimStatusBox"); + status_box->typing_pixbufs[3] = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_TYPING3, + icon_size, "GtkGaimStatusBox"); + status_box->connecting = FALSE; + status_box->typing = FALSE; + status_box->title = NULL; + status_box->pixbuf = NULL; + status_box->cell_view = gtk_cell_view_new(); + gtk_widget_show (status_box->cell_view); + + status_box->store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + gtk_combo_box_set_model(GTK_COMBO_BOX(status_box), GTK_TREE_MODEL(status_box->dropdown_store)); + gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); + gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(status_box), 0); + gtk_list_store_append(status_box->store, &(status_box->iter)); + gtk_gaim_status_box_refresh(status_box); + gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(status_box->cell_view), gtk_tree_path_new_from_string("0")); + gtk_container_add(GTK_CONTAINER(status_box), status_box->cell_view); + + status_box->icon_rend = gtk_cell_renderer_pixbuf_new(); + status_box->text_rend = gtk_cell_renderer_text_new(); + + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), icon_rend, FALSE); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box), text_rend, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), icon_rend, "pixbuf", ICON_COLUMN, NULL); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box), text_rend, "markup", TEXT_COLUMN, NULL); + + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); + + status_box->vbox = gtk_vbox_new(0, FALSE); + status_box->imhtml = gtk_imhtml_new(NULL, NULL); + buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(status_box->imhtml)); + g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(imhtml_changed_cb), status_box); + gtk_imhtml_set_editable(GTK_IMHTML(status_box->imhtml), TRUE); + gtk_widget_set_parent(status_box->vbox, GTK_WIDGET(status_box)); + status_box->sw = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(status_box->sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(status_box->sw), GTK_SHADOW_IN); + gtk_container_add(GTK_CONTAINER(status_box->sw), status_box->imhtml); + gtk_box_pack_start(GTK_BOX(status_box->vbox), status_box->sw, TRUE, TRUE, 0); + pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_ONLINE, + icon_size, "GtkGaimStatusBox"); + pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_AWAY, + icon_size, "GtkGaimStatusBox"); + pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_OFFLINE, + icon_size, "GtkGaimStatusBox"); + pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box), GAIM_STOCK_STATUS_INVISIBLE, + icon_size, "GtkGaimStatusBox"); + /* hacks */ + gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Available"), NULL, "available"); + gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf2, _("Away"), NULL, "away"); + gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf4, _("Invisible"), NULL, "invisible"); + gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf3, _("Offline"), NULL, "offline"); + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); + +} + + +static void +gtk_gaim_status_box_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkRequisition box_req; + combo_box_size_request(widget, requisition); + + gtk_widget_size_request(GTK_GAIM_STATUS_BOX(widget)->vbox, &box_req); + if (box_req.height > 1) + requisition->height = requisition->height + box_req.height + 6; + + requisition->width = 1; + +} + +static void +gtk_gaim_status_box_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkRequisition req = {0,0}; + GtkAllocation parent_alc = *allocation, box_alc = *allocation ; + combo_box_size_request(widget, &req); + + /* EVIL XXX */ + box_alc.height = 80;//MAX(1,box_alc.height - req.height - 6); + + box_alc.y = box_alc.y + req.height + 6; + gtk_widget_size_allocate((GTK_GAIM_STATUS_BOX(widget))->vbox, &box_alc); + + parent_alc.height = MAX(1,req.height); + combo_box_size_allocate(widget, &parent_alc); + widget->allocation = *allocation; +} + + +static gboolean +gtk_gaim_status_box_expose_event (GtkWidget *widget, + GdkEventExpose *event) +{ + + GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (widget); + combo_box_expose_event(widget, event); + + gtk_container_propagate_expose (GTK_CONTAINER (widget), + status_box->vbox, event); + return FALSE; +} + +static void +gtk_gaim_status_box_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data) +{ + GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX (container); + + if (include_internals) + { + (* callback) (status_box->vbox, callback_data); + } + + combo_box_forall(container, include_internals, callback, callback_data); +} + +GtkWidget * +gtk_gaim_status_box_new() +{ + return g_object_new(GTK_GAIM_TYPE_STATUS_BOX, NULL); +} + + +void +gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit) +{ + GtkTreeIter iter; + char *t; + + if (sec_text) { + char aa_color[8]; + GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(status_box)); + snprintf(aa_color, sizeof(aa_color), "#%02x%02x%02x", + style->text_aa[GTK_STATE_NORMAL].red >> 8, + style->text_aa[GTK_STATE_NORMAL].green >> 8, + style->text_aa[GTK_STATE_NORMAL].blue >> 8); + t = g_strdup_printf("%s\n%s", text, aa_color, sec_text); + } else { + t = g_strdup(text); + } + + gtk_list_store_append(status_box->dropdown_store, &iter); + gtk_list_store_set(status_box->dropdown_store, &iter, + ICON_COLUMN, pixbuf, + TEXT_COLUMN, t, + TITLE_COLUMN, text, + DESC_COLUMN, sec_text, + TYPE_COLUMN, edit, -1); +} + +void +gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error) +{ + status_box->error = g_strdup(error); + gtk_gaim_status_box_refresh(status_box); +} + +void +gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting) +{ + if (!status_box) + return; + status_box->connecting = connecting; + gtk_gaim_status_box_refresh(status_box); +} + +void +gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box) +{ + if (!status_box) + return; + if (status_box->connecting_index == 3) + status_box->connecting_index = 0; + else + status_box->connecting_index++; + gtk_gaim_status_box_refresh(status_box); +} + +void +gtk_gaim_status_box_pulse_typing(GtkGaimStatusBox *status_box) +{ + if (status_box->typing_index == 3) + status_box->typing_index = 0; + else + status_box->typing_index++; + gtk_gaim_status_box_refresh(status_box); +} + +static void remove_typing_cb(GtkGaimStatusBox *box) +{ + gchar *status_type_id; + GList *l; + GtkTreeIter iter; + + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(box), &iter); + gtk_tree_model_get(GTK_TREE_MODEL(box->dropdown_store), &iter, TYPE_COLUMN, &status_type_id, -1); + for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { + GaimAccount *account = (GaimAccount*)l->data; + GaimStatusType *status_type; + + if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) + continue; + + status_type = gaim_account_get_status_type(account, status_type_id); + + if (status_type == NULL) + continue; + gaim_account_set_status(account, status_type_id, TRUE, + "message",gtk_imhtml_get_markup(GTK_IMHTML(box->imhtml)), NULL); + } + g_source_remove(box->typing); + box->typing = 0; + gtk_gaim_status_box_refresh(box); +} + +static void gtk_gaim_status_box_changed(GtkComboBox *box) +{ + GtkGaimStatusBox *status_box = GTK_GAIM_STATUS_BOX(box); + GtkTreeIter iter; + char *text, *sec_text; + GdkPixbuf *pixbuf; + gchar *status_type_id; + GList *l; + + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); + gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, TITLE_COLUMN, &text, + DESC_COLUMN, &sec_text, ICON_COLUMN, &pixbuf, + TYPE_COLUMN, &status_type_id, -1); + if (status_box->title) + g_free(status_box->title); + status_box->title = g_strdup(text); + if (status_box->desc && sec_text) + g_free(status_box->desc); + status_box->desc = g_strdup(sec_text); + if (status_box->pixbuf) + g_object_unref(status_box->pixbuf); + status_box->pixbuf = pixbuf; + + if (!strcmp(status_type_id, "away")) { + gtk_widget_show_all(status_box->vbox); + status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); + gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); + gtk_widget_grab_focus(status_box->imhtml); + } else { + if (status_box->typing) { + g_source_remove(status_box->typing); + status_box->typing = 0; + } + gtk_widget_hide_all(status_box->vbox); + for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { + GaimAccount *account = (GaimAccount*)l->data; + GaimStatusType *status_type; + + if (!gaim_account_get_enabled(account, GAIM_GTK_UI)) + continue; + + status_type = gaim_account_get_status_type(account, status_type_id); + + if (status_type == NULL) + continue; + gaim_account_set_status(account, status_type_id, TRUE, NULL); + } + } + gtk_gaim_status_box_refresh(status_box); +} + +static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) +{ + GtkGaimStatusBox *box = (GtkGaimStatusBox*)data; + if (box->typing) { + gtk_gaim_status_box_pulse_typing(box); + g_source_remove(box->typing); + } + box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); + gtk_gaim_status_box_refresh(box); +} diff -r 0376d4c84b9f -r 868aafbe859b src/gtkstatusbox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gtkstatusbox.h Sun Feb 27 08:35:11 2005 +0000 @@ -0,0 +1,111 @@ +/* + * @file gtkstatusbox.c GTK+ Status Selection Widget + * @ingroup gtkui + * + * gaim + * + * Gaim is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef __GTK_GAIM_STATUS_BOX_H__ +#define __GTK_GAIM_STATUS_BOX_H__ + +#include +#include "gtkimhtml.h" +#include +#include + +G_BEGIN_DECLS + +#define GTK_GAIM_TYPE_STATUS_BOX (gtk_gaim_status_box_get_type ()) +#define GTK_GAIM_STATUS_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_GAIM_TYPE_STATUS_BOX, GtkGaimStatusBox)) +#define GTK_GAIM_STATUS_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GTK_GAIM_TYPE_STATUS_BOX, GtkGaimStatusBoxClass)) +#define GTK_GAIM_IS_STATUS_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_GAIM_TYPE_STATUS_BOX)) +#define GTK_GAIM_IS_STATUS_BOX_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GTK_GAIM_TYPE_STATUS_BOX)) +#define GTK_GAIM_STATUS_BOX_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GTK_GAIM_TYPE_STATUS_BOX, GtkGaimStatusBoxClass)) + +typedef struct _GtkGaimStatusBox GtkGaimStatusBox; +typedef struct _GtkGaimStatusBoxClass GtkGaimStatusBoxClass; + +struct _GtkGaimStatusBox +{ + GtkComboBox parent_instance; + + GtkListStore *store; + GtkListStore *dropdown_store; + + GtkWidget *vbox, *sw; + GtkWidget *imhtml; + gboolean imhtml_visible; + + GtkWidget *cell_view; + GtkCellRenderer *icon_rend; + GtkCellRenderer *text_rend; + + GdkPixbuf *error_pixbuf; + int connecting_index; + GdkPixbuf *connecting_pixbufs[4]; + int typing_index; + GdkPixbuf *typing_pixbufs[4]; + + gboolean connecting; + gboolean typing; + + + GtkTreeIter iter; + GdkPixbuf *pixbuf; + char *title; + char *desc; + char *error; +}; + +struct _GtkGaimStatusBoxClass +{ + GtkComboBoxClass parent_class; + + /* signals */ + void (* changed) (GtkComboBox *combo_box); + + /* Padding for future expansion */ + void (*_gtk_reserved0) (void); + void (*_gtk_reserved1) (void); + void (*_gtk_reserved2) (void); + void (*_gtk_reserved3) (void); +}; + + +GType gtk_gaim_status_box_get_type (void) G_GNUC_CONST; +GtkWidget *gtk_gaim_status_box_new (void); + +void +gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit); + +void +gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error); + +void +gtk_gaim_status_box_set_connecting(GtkGaimStatusBox *status_box, gboolean connecting); + +void +gtk_gaim_status_box_pulse_connecting(GtkGaimStatusBox *status_box); + +G_END_DECLS + +#endif /* __GTK_GAIM_GTK_STATUS_COMBO_BOX_H__ */ diff -r 0376d4c84b9f -r 868aafbe859b src/gtkstock.c --- a/src/gtkstock.c Sat Feb 26 19:25:44 2005 +0000 +++ b/src/gtkstock.c Sun Feb 27 08:35:11 2005 +0000 @@ -79,6 +79,18 @@ { GAIM_STOCK_TEXT_SMALLER, "buttons", "text_smaller.png" }, { GAIM_STOCK_TYPED, "gaim", "typed.png" }, { GAIM_STOCK_TYPING, "gaim", "typing.png" }, + { GAIM_STOCK_STATUS_ONLINE, "gaim", "status-online.png" }, + { GAIM_STOCK_STATUS_OFFLINE, "gaim", "status-offline.png" }, + { GAIM_STOCK_STATUS_AWAY, "gaim", "status-away.png" }, + { GAIM_STOCK_STATUS_INVISIBLE,"gaim", "status-invisible.png" }, + { GAIM_STOCK_STATUS_TYPING0, "gaim", "status-typing0.png" }, + { GAIM_STOCK_STATUS_TYPING1, "gaim", "status-typing1.png" }, + { GAIM_STOCK_STATUS_TYPING2, "gaim", "status-typing2.png" }, + { GAIM_STOCK_STATUS_TYPING3, "gaim", "status-typing3.png" }, + { GAIM_STOCK_STATUS_CONNECT0, "gaim", "status-connect0.png" }, + { GAIM_STOCK_STATUS_CONNECT1, "gaim", "status-connect1.png" }, + { GAIM_STOCK_STATUS_CONNECT2, "gaim", "status-connect2.png" }, + { GAIM_STOCK_STATUS_CONNECT3, "gaim", "status-connect3.png" }, { GAIM_STOCK_UPLOAD, NULL, GTK_STOCK_GO_UP }, { GAIM_STOCK_WARN, NULL, GTK_STOCK_DIALOG_WARNING } }; @@ -221,6 +233,7 @@ /* register custom icon sizes */ gtk_icon_size_register(GAIM_ICON_SIZE_LOGO, 330, 90); gtk_icon_size_register(GAIM_ICON_SIZE_DIALOG_COOL, 40, 60); + gtk_icon_size_register(GAIM_ICON_SIZE_STATUS, 30, 30); g_object_unref(G_OBJECT(icon_factory)); diff -r 0376d4c84b9f -r 868aafbe859b src/gtkstock.h --- a/src/gtkstock.h Sat Feb 26 19:25:44 2005 +0000 +++ b/src/gtkstock.h Sun Feb 27 08:35:11 2005 +0000 @@ -68,6 +68,18 @@ #define GAIM_STOCK_SIGN_OFF "gaim-sign-off" #define GAIM_STOCK_SIGN_ON "gaim-sign-on" #define GAIM_STOCK_SMILEY "gaim-smiley" +#define GAIM_STOCK_STATUS_ONLINE "gaim-status-online" +#define GAIM_STOCK_STATUS_AWAY "gaim-status-away" +#define GAIM_STOCK_STATUS_INVISIBLE "gaim-status-invisible" +#define GAIM_STOCK_STATUS_OFFLINE "gaim-status-offline" +#define GAIM_STOCK_STATUS_TYPING0 "gaim-status-typing0" +#define GAIM_STOCK_STATUS_TYPING1 "gaim-status-typing1" +#define GAIM_STOCK_STATUS_TYPING2 "gaim-status-typing2" +#define GAIM_STOCK_STATUS_TYPING3 "gaim-status-typing3" +#define GAIM_STOCK_STATUS_CONNECT0 "gaim-status-connect0" +#define GAIM_STOCK_STATUS_CONNECT1 "gaim-status-connect1" +#define GAIM_STOCK_STATUS_CONNECT2 "gaim-status-connect2" +#define GAIM_STOCK_STATUS_CONNECT3 "gaim-status-connect3" #define GAIM_STOCK_TEXT_BIGGER "gaim-text-bigger" #define GAIM_STOCK_TEXT_NORMAL "gaim-text-normal" #define GAIM_STOCK_TEXT_SMALLER "gaim-text-smaller" @@ -82,6 +94,7 @@ */ #define GAIM_ICON_SIZE_DIALOG_COOL "gaim-icon-size-dialog-cool" #define GAIM_ICON_SIZE_LOGO "gaim-icon-size-logo" +#define GAIM_ICON_SIZE_STATUS "gaim-icon-size-status" /** * Sets up the gaim stock repository.