Mercurial > pidgin
comparison src/gtkblist.c @ 9019:db1dc2d02020
[gaim-migrate @ 9795]
Fiddled with a few small things
1) Added a GAIM_CONNECTION_IS_CONNECTED(gc) #define to connection.h
2) In the functions that build the Account Actions and Plugin Actions
menus, I didn't think the comment "plugin and gc will be set from
the counting loop already" was accurate (but it might be, becase
it seemed like the account actions menu worked with one account
online). So I made sure plugin and gc are set to what they should
be.
3) Changed gaim_account_is_connected() to use GAIM_CONNECTION_IS_CONNECTED
Previously gaim_account_is_connected() would return true for gc's
that were "GAIM_CONNECTING." Now it only returns true for gc's that
are "GAIM_CONNECTED."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 22 May 2004 23:08:27 +0000 |
parents | 67421e0dc497 |
children | 7ab20f829190 |
comparison
equal
deleted
inserted
replaced
9018:bb168141eb5f | 9019:db1dc2d02020 |
---|---|
4975 GList *l; | 4975 GList *l; |
4976 GaimConnection *gc = NULL; | 4976 GaimConnection *gc = NULL; |
4977 GaimPlugin *plugin = NULL; | 4977 GaimPlugin *plugin = NULL; |
4978 int count = 0; | 4978 int count = 0; |
4979 | 4979 |
4980 if (! protomenu) | 4980 if (protomenu == NULL) |
4981 return; | 4981 return; |
4982 | 4982 |
4983 /* Clear the old Account Actions menu */ | |
4983 for (l = gtk_container_get_children(GTK_CONTAINER(protomenu)); l; l = l->next) { | 4984 for (l = gtk_container_get_children(GTK_CONTAINER(protomenu)); l; l = l->next) { |
4984 GaimPluginAction *action; | 4985 GaimPluginAction *action; |
4985 | 4986 |
4986 menuitem = l->data; | 4987 menuitem = l->data; |
4987 action = (GaimPluginAction *) g_object_get_data(G_OBJECT(menuitem), | 4988 action = (GaimPluginAction *) g_object_get_data(G_OBJECT(menuitem), |
4989 g_free(action); | 4990 g_free(action); |
4990 | 4991 |
4991 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem)); | 4992 gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem)); |
4992 } | 4993 } |
4993 | 4994 |
4995 /* Count the number of accounts with actions */ | |
4994 for (l = gaim_connections_get_all(); l; l = l->next) { | 4996 for (l = gaim_connections_get_all(); l; l = l->next) { |
4995 gc = l->data; | 4997 gc = l->data; |
4996 plugin = gc->prpl; | 4998 plugin = gc->prpl; |
4997 | 4999 |
5000 if (GAIM_CONNECTION_IS_CONNECTED(gc) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5001 count++; | |
5002 | |
4998 /* no need to count past 2, so don't */ | 5003 /* no need to count past 2, so don't */ |
4999 if (gc->login_time && GAIM_PLUGIN_HAS_ACTIONS(plugin) && count++) | 5004 if (count > 1) |
5000 break; | 5005 break; |
5001 } | 5006 } |
5002 | 5007 |
5003 | |
5004 if (count == 0) { | 5008 if (count == 0) { |
5005 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | 5009 menuitem = gtk_menu_item_new_with_label(_("No actions available")); |
5006 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); | 5010 gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem); |
5007 gtk_widget_set_sensitive(menuitem, FALSE); | 5011 gtk_widget_set_sensitive(menuitem, FALSE); |
5008 gtk_widget_show(menuitem); | 5012 gtk_widget_show(menuitem); |
5009 | 5013 } |
5010 } | 5014 |
5011 else | 5015 else if (count == 1) { |
5012 if (count == 1) { | 5016 /* Find the one account that has actions */ |
5013 /* plugin and gc will be set from the counting loop already */ | 5017 for (l = gaim_connections_get_all(); l; l = l->next) { |
5018 gc = l->data; | |
5019 plugin = gc->prpl; | |
5020 | |
5021 if (GAIM_CONNECTION_IS_CONNECTED(gc) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5022 break; | |
5023 } | |
5024 | |
5014 build_plugin_actions(protomenu, plugin, gc); | 5025 build_plugin_actions(protomenu, plugin, gc); |
5015 } | 5026 } |
5027 | |
5016 else { | 5028 else { |
5017 for (l = gaim_connections_get_all(); l; l = l->next) { | 5029 for (l = gaim_connections_get_all(); l; l = l->next) { |
5018 GaimAccount *account; | 5030 GaimAccount *account; |
5019 GdkPixbuf *pixbuf, *scale; | 5031 GdkPixbuf *pixbuf, *scale; |
5020 GtkWidget *image; | 5032 GtkWidget *image; |
5021 char *buf; | 5033 char *buf; |
5022 | 5034 |
5023 gc = l->data; | 5035 gc = l->data; |
5024 plugin = gc->prpl; | 5036 plugin = gc->prpl; |
5025 | 5037 |
5026 if (gc->login_time == 0 || !GAIM_PLUGIN_HAS_ACTIONS(plugin)) | 5038 if (!GAIM_CONNECTION_IS_CONNECTED(gc) || !GAIM_PLUGIN_HAS_ACTIONS(plugin)) |
5027 continue; | 5039 continue; |
5028 | 5040 |
5029 account = gaim_connection_get_account(gc); | 5041 account = gaim_connection_get_account(gc); |
5030 buf = g_strconcat(gaim_account_get_username(account), " (", | 5042 buf = g_strconcat(gaim_account_get_username(account), " (", |
5031 plugin->info->name, ")", NULL); | 5043 plugin->info->name, ")", NULL); |
5032 menuitem = gtk_image_menu_item_new_with_label(buf); | 5044 menuitem = gtk_image_menu_item_new_with_label(buf); |
5033 g_free(buf); | 5045 g_free(buf); |
5034 | 5046 |
5035 pixbuf = create_prpl_icon(account); | 5047 pixbuf = create_prpl_icon(account); |
5036 if(pixbuf) { | 5048 if (pixbuf) { |
5037 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | 5049 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
5038 GDK_INTERP_BILINEAR); | 5050 GDK_INTERP_BILINEAR); |
5039 image = gtk_image_new_from_pixbuf(scale); | 5051 image = gtk_image_new_from_pixbuf(scale); |
5040 g_object_unref(G_OBJECT(pixbuf)); | 5052 g_object_unref(G_OBJECT(pixbuf)); |
5041 g_object_unref(G_OBJECT(scale)); | 5053 g_object_unref(G_OBJECT(scale)); |
5062 GtkWidget *menuitem, *submenu; | 5074 GtkWidget *menuitem, *submenu; |
5063 GaimPlugin *plugin = NULL; | 5075 GaimPlugin *plugin = NULL; |
5064 GList *l; | 5076 GList *l; |
5065 int count = 0; | 5077 int count = 0; |
5066 | 5078 |
5067 if (! pluginmenu) | 5079 if (pluginmenu == NULL) |
5068 return; | 5080 return; |
5069 | 5081 |
5082 /* Clear the old Account Actions menu */ | |
5070 for (l = gtk_container_get_children(GTK_CONTAINER(pluginmenu)); l; l = l->next) { | 5083 for (l = gtk_container_get_children(GTK_CONTAINER(pluginmenu)); l; l = l->next) { |
5071 GaimPluginAction *action; | 5084 GaimPluginAction *action; |
5072 | 5085 |
5073 menuitem = l->data; | 5086 menuitem = l->data; |
5074 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); | 5087 action = g_object_get_data(G_OBJECT(menuitem), "plugin_action"); |
5075 g_free(action); | 5088 g_free(action); |
5076 | 5089 |
5077 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(menuitem)); | 5090 gtk_container_remove(GTK_CONTAINER(pluginmenu), GTK_WIDGET(menuitem)); |
5078 } | 5091 } |
5079 | 5092 |
5093 /* Count the number of plugins with actions */ | |
5080 for (l = gaim_plugins_get_loaded(); l; l = l->next) { | 5094 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
5081 plugin = (GaimPlugin *) l->data; | 5095 plugin = (GaimPlugin *) l->data; |
5082 | 5096 |
5083 if( !GAIM_IS_PROTOCOL_PLUGIN(plugin) && | 5097 if (!GAIM_IS_PROTOCOL_PLUGIN(plugin) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) |
5084 GAIM_PLUGIN_HAS_ACTIONS(plugin) && count++) | 5098 count++; |
5099 | |
5100 /* no need to count past 2, so don't */ | |
5101 if (count > 1) | |
5085 break; | 5102 break; |
5086 } | 5103 } |
5087 | 5104 |
5088 if (count == 0) { | 5105 if (count == 0) { |
5089 menuitem = gtk_menu_item_new_with_label(_("No actions available")); | 5106 menuitem = gtk_menu_item_new_with_label(_("No actions available")); |
5090 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); | 5107 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); |
5091 gtk_widget_set_sensitive(menuitem, FALSE); | 5108 gtk_widget_set_sensitive(menuitem, FALSE); |
5092 gtk_widget_show(menuitem); | 5109 gtk_widget_show(menuitem); |
5093 | 5110 } |
5094 } | 5111 |
5095 else | 5112 else if (count == 1) { |
5096 if (count == 1) { | 5113 /* Find the one plugin that has actions */ |
5097 /* plugin is already set */ | 5114 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
5115 plugin = (GaimPlugin *) l->data; | |
5116 | |
5117 if (!GAIM_IS_PROTOCOL_PLUGIN(plugin) && GAIM_PLUGIN_HAS_ACTIONS(plugin)) | |
5118 break; | |
5119 } | |
5120 | |
5098 build_plugin_actions(pluginmenu, plugin, NULL); | 5121 build_plugin_actions(pluginmenu, plugin, NULL); |
5099 } | 5122 } |
5123 | |
5100 else { | 5124 else { |
5101 for (l = gaim_plugins_get_loaded(); l; l = l->next) { | 5125 for (l = gaim_plugins_get_loaded(); l; l = l->next) { |
5102 plugin = (GaimPlugin *) l->data; | 5126 plugin = (GaimPlugin *) l->data; |
5103 | 5127 |
5104 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) | 5128 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) |
5105 continue; | 5129 continue; |
5106 | 5130 |
5107 if (! GAIM_PLUGIN_HAS_ACTIONS(plugin)) | 5131 if (!GAIM_PLUGIN_HAS_ACTIONS(plugin)) |
5108 continue; | 5132 continue; |
5109 | 5133 |
5110 menuitem = gtk_image_menu_item_new_with_label(plugin->info->name); | 5134 menuitem = gtk_image_menu_item_new_with_label(plugin->info->name); |
5111 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); | 5135 gtk_menu_shell_append(GTK_MENU_SHELL(pluginmenu), menuitem); |
5112 gtk_widget_show(menuitem); | 5136 gtk_widget_show(menuitem); |
5117 | 5141 |
5118 build_plugin_actions(submenu, plugin, NULL); | 5142 build_plugin_actions(submenu, plugin, NULL); |
5119 } | 5143 } |
5120 } | 5144 } |
5121 } | 5145 } |
5122 |