Mercurial > pidgin
changeset 5906:390d32a6b130
[gaim-migrate @ 6338]
auto-join for chats in the buddy list. Yes, the interface sucks. I suck at
making interfaces. I'm sure someone more talented will make it pretty, or
maybe even HIG-y.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 16 Jun 2003 05:14:05 +0000 |
parents | dbe2a2174be9 |
children | 18486c860a46 |
files | src/blist.c src/blist.h src/dialogs.c src/gtkblist.h src/gtkutils.c src/gtkutils.h src/main.c |
diffstat | 7 files changed, 96 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/blist.c Mon Jun 16 04:15:35 2003 +0000 +++ b/src/blist.c Mon Jun 16 05:14:05 2003 +0000 @@ -313,6 +313,8 @@ if(alias && strlen(alias)) chat->alias = g_strdup(alias); chat->components = components; + chat->settings = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); ((GaimBlistNode*)chat)->type = GAIM_BLIST_CHAT_NODE; @@ -1244,6 +1246,7 @@ static char *blist_parser_setting_name = NULL; static char *blist_parser_setting_value = NULL; static GHashTable *blist_parser_buddy_settings = NULL; +static GHashTable *blist_parser_chat_settings = NULL; static GHashTable *blist_parser_group_settings = NULL; static GHashTable *blist_parser_chat_components = NULL; static int blist_parser_privacy_mode = 0; @@ -1386,12 +1389,17 @@ struct group *g = gaim_find_group(blist_parser_group_name); gaim_blist_add_chat(chat,g, gaim_blist_get_last_child((GaimBlistNode*)g)); + if(blist_parser_chat_settings) { + g_hash_table_destroy(chat->settings); + chat->settings = blist_parser_chat_settings; + } } g_free(blist_parser_chat_alias); blist_parser_chat_alias = NULL; g_free(blist_parser_account_name); blist_parser_account_name = NULL; blist_parser_chat_components = NULL; + blist_parser_chat_settings = NULL; tag_stack = g_list_delete_link(tag_stack, tag_stack); } else if(!strcmp(element_name, "person")) { g_free(blist_parser_person_name); @@ -1446,6 +1454,15 @@ g_strdup(blist_parser_setting_name), g_strdup(blist_parser_setting_value)); } + } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_CHAT) { + if(!blist_parser_chat_settings) + blist_parser_chat_settings = g_hash_table_new_full(g_str_hash, + g_str_equal, g_free, g_free); + if(blist_parser_setting_name && blist_parser_setting_value) { + g_hash_table_replace(blist_parser_buddy_settings, + g_strdup(blist_parser_setting_name), + g_strdup(blist_parser_setting_value)); + } } else if(GPOINTER_TO_INT(tag_stack->next->data) == BLIST_TAG_GROUP) { if(!blist_parser_group_settings) blist_parser_group_settings = g_hash_table_new_full(g_str_hash, @@ -1738,6 +1755,9 @@ } g_hash_table_foreach(chat->components, blist_print_chat_components, file); + /* works for chats too, I don't feel like renaming */ + g_hash_table_foreach(chat->settings, + blist_print_buddy_settings, file); fprintf(file, "\t\t\t</chat>\n"); g_free(acct_name); } @@ -1902,6 +1922,21 @@ return g_strdup(g_hash_table_lookup(g->settings, key)); } +void gaim_chat_set_setting(struct chat *c, const char *key, + const char *value) +{ + if(!c) + return; + g_hash_table_replace(c->settings, g_strdup(key), g_strdup(value)); +} + +char *gaim_chat_get_setting(struct chat *c, const char *key) +{ + if(!c) + return NULL; + return g_strdup(g_hash_table_lookup(c->settings, key)); +} + void gaim_buddy_set_setting(struct buddy *b, const char *key, const char *value) { if(!b)
--- a/src/blist.h Mon Jun 16 04:15:35 2003 +0000 +++ b/src/blist.h Mon Jun 16 05:14:05 2003 +0000 @@ -118,6 +118,7 @@ char *alias; /**< The display name of this chat. */ GHashTable *components; /**< the stuff the protocol needs to know to join the chat */ GaimAccount *account; /**< The account this chat is attached to */ + GHashTable *settings; /**< per-chat settings from the XML buddy list, set by plugins and the likes. */ }; @@ -504,6 +505,23 @@ */ char *gaim_group_get_setting(struct group *g, const char *key); +/** + * Associates some data with the chat in the xml buddy list + * + * @param b The chat the data is associated with + * @param key The key used to retrieve the data + * @param value The data to set + */ +void gaim_chat_set_setting(struct chat *c, const char *key, const char *value); + +/** + * Retrieves data from the XML buddy list set by gaim_chat_set_setting()) + * + * @param b The chat to retrieve data from + * @param key The key to retrieve the data with + * @return The associated data or NULL if no data is associated + */ +char *gaim_chat_get_setting(struct chat *c, const char *key); /** * Associates some data with the buddy in the xml buddy list
--- a/src/dialogs.c Mon Jun 16 04:15:35 2003 +0000 +++ b/src/dialogs.c Mon Jun 16 05:14:05 2003 +0000 @@ -3598,7 +3598,7 @@ GtkWidget *label; GtkWidget *alias_entry; - dialog = gtk_dialog_new_with_buttons(_("Alias Buddy"), NULL, + dialog = gtk_dialog_new_with_buttons(_("Alias Chat"), NULL, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK,
--- a/src/gtkblist.h Mon Jun 16 04:15:35 2003 +0000 +++ b/src/gtkblist.h Mon Jun 16 05:14:05 2003 +0000 @@ -5,7 +5,7 @@ * gaim * * Copyright (C) 2002-2003, Sean Egan <sean.egan@binghamton.edu> - * + * * 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 @@ -82,6 +82,12 @@ /************************************************************************** * @name GTK+ Buddy List API **************************************************************************/ + +/** + * Initializes the GTK+ blist system. + */ +void gaim_gtk_blist_init(void); + /** * Returns the UI operations structure for the buddy list. *
--- a/src/gtkutils.c Mon Jun 16 04:15:35 2003 +0000 +++ b/src/gtkutils.c Mon Jun 16 05:14:05 2003 +0000 @@ -444,6 +444,25 @@ return menuitem; } +GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str, + GtkSignalFunc sf, gpointer data, gboolean checked) +{ + GtkWidget *menuitem; + menuitem = gtk_check_menu_item_new_with_mnemonic(str); + + if(menu) + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + if (sf) + g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); + + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked); + + gtk_widget_show_all(menuitem); + + return menuitem; +} + GtkWidget *gaim_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) { GtkWidget *menuitem;
--- a/src/gtkutils.h Mon Jun 16 04:15:35 2003 +0000 +++ b/src/gtkutils.h Mon Jun 16 05:14:05 2003 +0000 @@ -131,7 +131,21 @@ * * @return The newly created menu item. */ -GtkWidget *gaim_new_item(GtkWidget *menu, const char *str); +GtkWidget *gaim_new_item(GtkWidget *menu, const char *str); + +/** + * Creates a check menu item. + * + * @param menu The menu to which to append the check menu item. + * @param str The title to use for the newly created menu item. + * @param sf A function to call when the menu item is activated. + * @param data Data to pass to the signal function. + * @param checked The initial state of the check item + * + * @return The newly created menu item. + */ +GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str, + GtkSignalFunc sf, gpointer data, gboolean checked); /** * Creates a menu item.