Mercurial > pidgin
changeset 11732:03c813a42c76
[gaim-migrate @ 14023]
here's what iw as working on, with the bits that activiate it commented out.
its not finished at all, but i'm tired of people breaking it ;)
hopefully this will motivate me to finish it tonight/tomorrow.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sun, 23 Oct 2005 01:42:01 +0000 |
parents | d9aab67a9e07 |
children | ef511dec9903 |
files | src/account.h src/gtkblist.c src/gtkblist.h src/gtkstatusbox.c src/gtkstatusbox.h |
diffstat | 5 files changed, 167 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/src/account.h Sun Oct 23 01:22:25 2005 +0000 +++ b/src/account.h Sun Oct 23 01:42:01 2005 +0000 @@ -764,7 +764,7 @@ * Deletes an account. * * This will remove any buddies from the buddy list that belong to this - * account, buddy pounces that belong to this account, and will also + * account, buddy pounces that belong to this account, and will also * destroy @a account. * * @param account The account. @@ -789,7 +789,9 @@ /** * Returns a list of all enabled accounts * - * @return A list of all enabled accounts. + * @return A list of all enabled accounts. The list is owned + * by the caller, and must be g_list_free()d to avoid + * leaking the nodes. */ GList *gaim_accounts_get_all_active(void);
--- a/src/gtkblist.c Sun Oct 23 01:22:25 2005 +0000 +++ b/src/gtkblist.c Sun Oct 23 01:42:01 2005 +0000 @@ -3281,10 +3281,31 @@ gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview); gaim_gtk_blist_update_columns(); - 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); + /* TODO: functionize this */ + { + GList *accounts, *l; + + /* Set up some per account status boxes */ + gtkblist->statusboxbox = gtk_vbox_new(FALSE, 0); + gtkblist->statusboxes = NULL; +#if 0 + for (l = accounts = gaim_accounts_get_all_active(); l; l = l->next) { + GtkWidget *statusbox = gtk_gaim_status_box_new_with_account(l->data); + gtkblist->statusboxes = g_list_append(gtkblist->statusboxes, statusbox); + gtk_box_pack_start(GTK_BOX(gtkblist->statusboxbox), statusbox, FALSE, TRUE, 0); + gtk_widget_show(statusbox); + } + g_list_free(accounts); +#endif + gtk_widget_show(gtkblist->statusboxbox); + gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusboxbox, 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
--- a/src/gtkblist.h Sun Oct 23 01:22:25 2005 +0000 +++ b/src/gtkblist.h Sun Oct 23 01:42:01 2005 +0000 @@ -87,6 +87,8 @@ GaimBlistNode *selected_node; /**< The currently selected node */ GtkWidget *statusbox; /**< The status selector dropdown */ + GtkWidget *statusboxbox; /**< A box to hold per account status boxes */ + GList *statusboxes; /**< A list of the per account status boxes */ GdkPixbuf *east, *south; /**< Drop shadow stuff */ GdkWindow *east_shadow, *south_shadow; /**< Drop shadow stuff */ @@ -126,11 +128,11 @@ /** * 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();
--- a/src/gtkstatusbox.c Sun Oct 23 01:22:25 2005 +0000 +++ b/src/gtkstatusbox.c Sun Oct 23 01:42:01 2005 +0000 @@ -27,6 +27,7 @@ #include "internal.h" #include "savedstatuses.h" #include "status.h" +#include "debug.h" #include "gtkgaim.h" #include "gtksavedstatuses.h" @@ -36,6 +37,7 @@ static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data); static void remove_typing_cb(GtkGaimStatusBox *box); +static void gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box); 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); @@ -117,6 +119,7 @@ switch (param_id) { case PROP_ACCOUNT: statusbox->account = g_value_get_pointer(value); + gtk_gaim_status_box_regenerate(statusbox); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); @@ -216,17 +219,141 @@ g_free(text); } +static GdkPixbuf * +load_icon(const char *basename) +{ + char basename2[BUFSIZ]; + char *filename; + GdkPixbuf *pixbuf, *scale = NULL; + + if (!strcmp(basename, "available")) + basename = "online"; + else if (!strcmp(basename, "hidden")) + basename = "invisible"; + + /* + * TODO: Find a way to fallback to the GaimStatusPrimitive + * if an icon for this id does not exist. + */ + g_snprintf(basename2, sizeof(basename2), "%s.png", + basename); + + + filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", + basename2, NULL); + pixbuf = gdk_pixbuf_new_from_file(filename, NULL); + g_free(filename); + + if (pixbuf != NULL) { + scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, + GDK_INTERP_BILINEAR); + + g_object_unref(G_OBJECT(pixbuf)); + } else { + filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", + "default", basename, NULL); + scale = gdk_pixbuf_new_from_file(filename, NULL); + g_free(filename); + } + + return scale; +} + +static void +gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) +{ + GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; + GtkIconSize icon_size; + const char *current_savedstatus_name; + GaimSavedStatus *saved_status; + + + icon_size = gtk_icon_size_from_name(GAIM_ICON_SIZE_STATUS); + + gtk_list_store_clear(status_box->dropdown_store); + + if (!(GTK_GAIM_STATUS_BOX(status_box)->account)) { + 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_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Custom..."), NULL, "custom"); + gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Saved..."), NULL, "saved"); + + current_savedstatus_name = gaim_prefs_get_string("/core/status/current"); + saved_status = gaim_savedstatus_find(current_savedstatus_name); + if (saved_status == NULL) + { + /* Default to "available" */ + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); + } + else + { + GaimStatusPrimitive primitive; + const char *message; + + primitive = gaim_savedstatus_get_type(saved_status); + if (gaim_savedstatus_has_substatuses(saved_status) || + ((primitive != GAIM_STATUS_AVAILABLE) && + (primitive != GAIM_STATUS_OFFLINE) && + (primitive != GAIM_STATUS_AWAY) && + (primitive != GAIM_STATUS_HIDDEN))) + { + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 4); + } + else + { + if (primitive == GAIM_STATUS_AVAILABLE) + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); + if (primitive == GAIM_STATUS_OFFLINE) + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3); + else if (primitive == GAIM_STATUS_AWAY) + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1); + else if (primitive == GAIM_STATUS_HIDDEN) + gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); + } + + message = gaim_savedstatus_get_message(saved_status); + if (message != NULL) + gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); + } + + + } else { + const GList *l; + for (l = gaim_account_get_status_types(GTK_GAIM_STATUS_BOX(status_box)->account); l != NULL; l = l->next) { + GaimStatusType *status_type = (GaimStatusType *)l->data; + + if (!gaim_status_type_is_user_settable(status_type)) + continue; + + gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), load_icon(gaim_status_type_get_id(status_type)), + gaim_status_type_get_name(status_type), + NULL, + gaim_status_type_get_id(status_type)); + + } + } + +} + static void gtk_gaim_status_box_init (GtkGaimStatusBox *status_box) { GtkCellRenderer *text_rend; GtkCellRenderer *icon_rend; GtkTextBuffer *buffer; - GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4; + GtkTreePath *path; GtkIconSize icon_size; - GtkTreePath *path; - const char *current_savedstatus_name; - GaimSavedStatus *saved_status; text_rend = gtk_cell_renderer_text_new(); icon_rend = gtk_cell_renderer_pixbuf_new(); @@ -298,59 +425,8 @@ 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_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Custom..."), NULL, "custom"); - gtk_gaim_status_box_add(GTK_GAIM_STATUS_BOX(status_box), pixbuf, _("Saved..."), NULL, "saved"); - current_savedstatus_name = gaim_prefs_get_string("/core/status/current"); - saved_status = gaim_savedstatus_find(current_savedstatus_name); - if (saved_status == NULL) - { - /* Default to "available" */ - gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); - } - else - { - GaimStatusPrimitive primitive; - const char *message; - - primitive = gaim_savedstatus_get_type(saved_status); - if (gaim_savedstatus_has_substatuses(saved_status) || - ((primitive != GAIM_STATUS_AVAILABLE) && - (primitive != GAIM_STATUS_OFFLINE) && - (primitive != GAIM_STATUS_AWAY) && - (primitive != GAIM_STATUS_HIDDEN))) - { - gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 4); - } - else - { - if (primitive == GAIM_STATUS_AVAILABLE) - gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); - if (primitive == GAIM_STATUS_OFFLINE) - gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3); - else if (primitive == GAIM_STATUS_AWAY) - gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1); - else if (primitive == GAIM_STATUS_HIDDEN) - gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); - } - - message = gaim_savedstatus_get_message(saved_status); - if (message != NULL) - gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); - } + gtk_gaim_status_box_regenerate(status_box); } @@ -434,7 +510,7 @@ } void -gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit) +gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, const char *edit) { GtkTreeIter iter; char *t;
--- a/src/gtkstatusbox.h Sun Oct 23 01:22:25 2005 +0000 +++ b/src/gtkstatusbox.h Sun Oct 23 01:42:01 2005 +0000 @@ -108,7 +108,7 @@ GtkWidget *gtk_gaim_status_box_new_with_account (GaimAccount *); void -gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, char *edit); +gtk_gaim_status_box_add(GtkGaimStatusBox *status_box, GdkPixbuf *pixbuf, const char *text, const char *sec_text, const char *edit); void gtk_gaim_status_box_set_error(GtkGaimStatusBox *status_box, const gchar *error);