Mercurial > pidgin
comparison src/gtkblist.c @ 14035:8bda65b88e49
[gaim-migrate @ 16638]
A bunch of small changes. Mostly remove "if not null" checks before
calling g_free, g_list_free, g_slist_free and g_strdup. Also use
g_list_foreach() to call g_free to free strings in an array. And
some whitespace changes here and there.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 05 Aug 2006 08:27:39 +0000 |
parents | 6fc412e59214 |
children | 36bb845aa622 |
comparison
equal
deleted
inserted
replaced
14034:0839a7b71325 | 14035:8bda65b88e49 |
---|---|
551 { | 551 { |
552 gtk_container_remove(GTK_CONTAINER(data->entries_box), | 552 gtk_container_remove(GTK_CONTAINER(data->entries_box), |
553 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); | 553 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
554 } | 554 } |
555 | 555 |
556 if (data->entries != NULL) | 556 g_list_free(data->entries); |
557 g_list_free(data->entries); | |
558 | |
559 data->entries = NULL; | 557 data->entries = NULL; |
560 | 558 |
561 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) | 559 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
562 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | 560 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); |
563 | 561 |
1517 g_free(temp_vcard); | 1515 g_free(temp_vcard); |
1518 | 1516 |
1519 if (aims == NULL && icqs == NULL && yahoos == NULL && | 1517 if (aims == NULL && icqs == NULL && yahoos == NULL && |
1520 msns == NULL && jabbers == NULL) | 1518 msns == NULL && jabbers == NULL) |
1521 { | 1519 { |
1522 if (alias != NULL) | 1520 g_free(alias); |
1523 g_free(alias); | |
1524 | 1521 |
1525 return FALSE; | 1522 return FALSE; |
1526 } | 1523 } |
1527 | 1524 |
1528 add_buddies_from_vcard("prpl-oscar", group, aims, alias); | 1525 add_buddies_from_vcard("prpl-oscar", group, aims, alias); |
1529 add_buddies_from_vcard("prpl-oscar", group, icqs, alias); | 1526 add_buddies_from_vcard("prpl-oscar", group, icqs, alias); |
1530 add_buddies_from_vcard("prpl-yahoo", group, yahoos, alias); | 1527 add_buddies_from_vcard("prpl-yahoo", group, yahoos, alias); |
1531 add_buddies_from_vcard("prpl-msn", group, msns, alias); | 1528 add_buddies_from_vcard("prpl-msn", group, msns, alias); |
1532 add_buddies_from_vcard("prpl-jabber", group, jabbers, alias); | 1529 add_buddies_from_vcard("prpl-jabber", group, jabbers, alias); |
1533 | 1530 |
1534 if (alias != NULL) | 1531 g_free(alias); |
1535 g_free(alias); | |
1536 | 1532 |
1537 return TRUE; | 1533 return TRUE; |
1538 } | 1534 } |
1539 | 1535 |
1540 #ifdef _WIN32 | 1536 #ifdef _WIN32 |
1592 GaimBuddy *buddy; | 1588 GaimBuddy *buddy; |
1593 GaimConnection *gc; | 1589 GaimConnection *gc; |
1594 GValue val; | 1590 GValue val; |
1595 GString *str; | 1591 GString *str; |
1596 const char *protocol; | 1592 const char *protocol; |
1597 char *mime_str; | |
1598 | 1593 |
1599 ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); | 1594 ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); |
1600 sourcerow = gtk_tree_row_reference_get_path(ref); | 1595 sourcerow = gtk_tree_row_reference_get_path(ref); |
1601 | 1596 |
1602 if (!sourcerow) | 1597 if (!sourcerow) |
1652 buddy->alias); | 1647 buddy->alias); |
1653 } | 1648 } |
1654 | 1649 |
1655 str = g_string_append(str, "\r\n"); | 1650 str = g_string_append(str, "\r\n"); |
1656 | 1651 |
1657 mime_str = g_string_free(str, FALSE); | |
1658 | |
1659 gtk_selection_data_set(data, | 1652 gtk_selection_data_set(data, |
1660 gdk_atom_intern("application/x-im-contact", FALSE), | 1653 gdk_atom_intern("application/x-im-contact", FALSE), |
1661 8, /* bits */ | 1654 8, /* bits */ |
1662 (const guchar *)mime_str, | 1655 (const guchar *)str->str, |
1663 strlen(mime_str) + 1); | 1656 strlen(str->str) + 1); |
1664 | 1657 |
1665 g_free(mime_str); | 1658 g_string_free(str, TRUE); |
1666 gtk_tree_path_free(sourcerow); | 1659 gtk_tree_path_free(sourcerow); |
1667 } | 1660 } |
1668 } | 1661 } |
1669 | 1662 |
1670 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | 1663 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
1876 (group ? group->name : NULL), | 1869 (group ? group->name : NULL), |
1877 alias); | 1870 alias); |
1878 } | 1871 } |
1879 } | 1872 } |
1880 | 1873 |
1881 if (username != NULL) g_free(username); | 1874 g_free(username); |
1882 if (protocol != NULL) g_free(protocol); | 1875 g_free(protocol); |
1883 if (alias != NULL) g_free(alias); | 1876 g_free(alias); |
1884 | 1877 |
1885 if (path != NULL) | 1878 if (path != NULL) |
1886 gtk_tree_path_free(path); | 1879 gtk_tree_path_free(path); |
1887 | 1880 |
1888 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | 1881 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2964 | 2957 |
2965 if(!gaim_presence_is_online(presence) && !statustext) | 2958 if(!gaim_presence_is_online(presence) && !statustext) |
2966 statustext = g_strdup(_("Offline")); | 2959 statustext = g_strdup(_("Offline")); |
2967 else if (!statustext) | 2960 else if (!statustext) |
2968 text = g_strdup(esc); | 2961 text = g_strdup(esc); |
2969 | 2962 |
2970 if (gaim_presence_is_idle(presence)) { | 2963 if (gaim_presence_is_idle(presence)) { |
2971 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")) { | 2964 if (gaim_prefs_get_bool("/gaim/gtk/blist/show_idle_time")) { |
2972 time_t idle_secs = gaim_presence_get_idle_time(presence); | 2965 time_t idle_secs = gaim_presence_get_idle_time(presence); |
2973 | 2966 |
2974 if (idle_secs > 0) { | 2967 if (idle_secs > 0) { |
3015 (idletime != NULL && statustext != NULL) ? " - " : "", | 3008 (idletime != NULL && statustext != NULL) ? " - " : "", |
3016 statustext != NULL ? statustext : ""); | 3009 statustext != NULL ? statustext : ""); |
3017 } | 3010 } |
3018 | 3011 |
3019 /* It is selected. */ | 3012 /* It is selected. */ |
3020 if ((selected && !text) || (selected && idletime)) | 3013 if ((selected && !text) || (selected && idletime)) |
3021 text = g_strdup_printf("%s\n" | 3014 text = g_strdup_printf("%s\n" |
3022 "<span size='smaller'>%s%s%s</span>", | 3015 "<span size='smaller'>%s%s%s</span>", |
3023 esc, | 3016 esc, |
3024 idletime != NULL ? idletime : "", | 3017 idletime != NULL ? idletime : "", |
3025 (idletime != NULL && statustext != NULL) ? " - " : "", | 3018 (idletime != NULL && statustext != NULL) ? " - " : "", |
3070 { | 3063 { |
3071 GaimBlistNode *gnode, *cnode; | 3064 GaimBlistNode *gnode, *cnode; |
3072 | 3065 |
3073 if (gtk_blist_obscured || !GTK_WIDGET_VISIBLE(gtkblist->window)) | 3066 if (gtk_blist_obscured || !GTK_WIDGET_VISIBLE(gtkblist->window)) |
3074 return TRUE; | 3067 return TRUE; |
3075 | 3068 |
3076 for(gnode = list->root; gnode; gnode = gnode->next) { | 3069 for(gnode = list->root; gnode; gnode = gnode->next) { |
3077 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | 3070 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
3078 continue; | 3071 continue; |
3079 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 3072 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3080 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { | 3073 if(GAIM_BLIST_NODE_IS_CONTACT(cnode)) { |
3082 | 3075 |
3083 buddy = gaim_contact_get_priority_buddy((GaimContact*)cnode); | 3076 buddy = gaim_contact_get_priority_buddy((GaimContact*)cnode); |
3084 | 3077 |
3085 if (buddy && | 3078 if (buddy && |
3086 gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) | 3079 gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) |
3087 gaim_gtk_blist_update_contact(list, (GaimBlistNode*)buddy); | 3080 gaim_gtk_blist_update_contact(list, (GaimBlistNode*)buddy); |
3088 } | 3081 } |
3089 } | 3082 } |
3090 } | 3083 } |
3091 | 3084 |
3092 /* keep on going */ | 3085 /* keep on going */ |
4244 else | 4237 else |
4245 gaim_gtk_blist_update_group(list, cnode->parent); | 4238 gaim_gtk_blist_update_group(list, cnode->parent); |
4246 | 4239 |
4247 contact = (GaimContact*)cnode; | 4240 contact = (GaimContact*)cnode; |
4248 buddy = gaim_contact_get_priority_buddy(contact); | 4241 buddy = gaim_contact_get_priority_buddy(contact); |
4249 | 4242 |
4250 if (buddy_is_displayable(buddy)) | 4243 if (buddy_is_displayable(buddy)) |
4251 { | 4244 { |
4252 GtkTreeIter iter; | 4245 GtkTreeIter iter; |
4253 | 4246 |
4254 if(!insert_node(list, cnode, &iter)) | 4247 if(!insert_node(list, cnode, &iter)) |
4292 struct _gaim_gtk_blist_node *gtkparentnode; | 4285 struct _gaim_gtk_blist_node *gtkparentnode; |
4293 | 4286 |
4294 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | 4287 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
4295 | 4288 |
4296 if (node->parent == NULL) | 4289 if (node->parent == NULL) |
4297 return; | 4290 return; |
4298 | 4291 |
4299 buddy = (GaimBuddy*)node; | 4292 buddy = (GaimBuddy*)node; |
4300 | 4293 |
4301 /* First things first, update the contact */ | 4294 /* First things first, update the contact */ |
4302 gaim_gtk_blist_update_contact(list, node); | 4295 gaim_gtk_blist_update_contact(list, node); |
4303 | 4296 |
4304 gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; | 4297 gtkparentnode = (struct _gaim_gtk_blist_node *)node->parent->ui_data; |
4305 | 4298 |
4798 { | 4791 { |
4799 gtk_container_remove(GTK_CONTAINER(data->entries_box), | 4792 gtk_container_remove(GTK_CONTAINER(data->entries_box), |
4800 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); | 4793 ((GtkBoxChild *)GTK_BOX(data->entries_box)->children->data)->widget); |
4801 } | 4794 } |
4802 | 4795 |
4803 if (data->entries != NULL) | 4796 g_list_free(data->entries); |
4804 g_list_free(data->entries); | |
4805 | 4797 |
4806 data->entries = NULL; | 4798 data->entries = NULL; |
4807 | 4799 |
4808 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) | 4800 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
4809 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); | 4801 list = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info(gc); |
5831 plugin_submenus = g_list_append(plugin_submenus, menuitem); | 5823 plugin_submenus = g_list_append(plugin_submenus, menuitem); |
5832 | 5824 |
5833 submenu = gtk_menu_new(); | 5825 submenu = gtk_menu_new(); |
5834 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | 5826 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
5835 gtk_widget_show(submenu); | 5827 gtk_widget_show(submenu); |
5836 | 5828 |
5837 gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group); | 5829 gtk_menu_set_accel_group(GTK_MENU(submenu), accel_group); |
5838 path = g_strdup_printf("%s/Tools/%s", gtkblist->ift->path, plugin->info->name); | 5830 path = g_strdup_printf("%s/Tools/%s", gtkblist->ift->path, plugin->info->name); |
5839 gtk_menu_set_accel_path(GTK_MENU(submenu), path); | 5831 gtk_menu_set_accel_path(GTK_MENU(submenu), path); |
5840 g_free(path); | 5832 g_free(path); |
5841 | 5833 |