static void update_type_list (AnjutaShell *shell, IAnjutaIterable *iter, const gchar *name) { gchar *list = NULL; GValue value = {0,}; if (iter) { ianjuta_iterable_first (iter, NULL); if (ianjuta_iterable_get_length (iter, NULL) > 0) { GString *s = g_string_sized_new(ianjuta_iterable_get_length (iter, NULL) * 10); do { IAnjutaSymbol *symbol = IANJUTA_SYMBOL (iter); const gchar *sname = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL); g_string_append(s, sname); g_string_append_c(s, ' '); } while (ianjuta_iterable_next (iter, NULL)); list = g_string_free(s, FALSE); } } anjuta_shell_get_value (shell, name, &value, NULL); if (G_VALUE_HOLDS_STRING(&value)) { const gchar *value_list = g_value_get_string (&value); if (list == NULL) { anjuta_shell_remove_value (shell, name, NULL); } else if (strcmp (list, value_list) == 0) { g_free (list); } else { g_value_take_string (&value, list); anjuta_shell_add_value (shell, name, &value, NULL); } } else { if (list != NULL) { g_value_init (&value, G_TYPE_STRING); g_value_take_string (&value, list); anjuta_shell_add_value (shell, name, &value, NULL); } } if (G_IS_VALUE (&value)) g_value_unset (&value); }
static void on_cls_inherit_update (IAnjutaSymbolQuery *query, IAnjutaIterable *iter, AnjutaClassInheritance *plugin) { IAnjutaSymbol *symbol; ClsNode *cls_node; GError *err = NULL; /* Mark all nodes for deletion. Selectively, they will be unmarked below */ g_hash_table_foreach (plugin->nodes, (GHFunc) on_cls_node_mark_for_deletion, NULL); if (!iter) { DEBUG_PRINT ("%s", "cls_inherit_update_graph (): search returned no items."); goto cleanup; } ianjuta_iterable_first (iter, NULL); if (ianjuta_iterable_get_length (iter, NULL) <= 0) { g_object_unref (iter); goto cleanup; } do { gint klass_id; IAnjutaIterable *parents; /* a symbol representing a class */ symbol = IANJUTA_SYMBOL (iter); /* get parents of the current class */ parents = ianjuta_symbol_query_search_class_parents (plugin->query_parents, symbol, &err); if (err) { g_warning ("Class parents query failed: %s", err->message); g_error_free (err); err = NULL; } /* if no parents are found then continue */ if (parents == NULL || ianjuta_iterable_get_length (parents, NULL) <= 0) { /*DEBUG_PRINT ("ClassInheritance: no parents found for class %s", ianjuta_symbol_get_name (symbol, NULL));*/ continue; } if ((klass_id = ianjuta_symbol_get_int (symbol, IANJUTA_SYMBOL_FIELD_ID, NULL)) <= 0) { /*DEBUG_PRINT ("%s", "ClassInheritance: klass_id cannot be <= 0");*/ continue; } cls_node = g_hash_table_lookup (plugin->nodes, GINT_TO_POINTER (klass_id)); if (!cls_node) { cls_node = cls_inherit_create_node (plugin, symbol); g_hash_table_insert (plugin->nodes, GINT_TO_POINTER (klass_id), cls_node); } cls_node->marked_for_deletion = FALSE; /* Get parents */ do { gint parent_id; ClsNode *parent_node; IAnjutaSymbol *parent_symbol; parent_symbol = IANJUTA_SYMBOL (parents); parent_id = ianjuta_symbol_get_int (parent_symbol, IANJUTA_SYMBOL_FIELD_ID, NULL); parent_node = g_hash_table_lookup (plugin->nodes, GINT_TO_POINTER (parent_id)); if (!parent_node) { parent_node = cls_inherit_create_node (plugin, parent_symbol); g_hash_table_insert (plugin->nodes, GINT_TO_POINTER (parent_id), parent_node); } parent_node->marked_for_deletion = FALSE; cls_node_add_edge (parent_node, cls_node); } while (ianjuta_iterable_next (parents, NULL) == TRUE); g_object_unref (parents); } while (ianjuta_iterable_next (iter, NULL) == TRUE); cleanup: /* Delete all marked nodes that did not get unmarked above. */ g_hash_table_foreach_remove (plugin->nodes, (GHRFunc) on_cls_node_delete_marked, NULL); cls_inherit_draw (plugin); }
gboolean cls_node_expand (ClsNode *cls_node, ClsNodeExpansionType expansion_type) { Agsym_t *sym; GString *label; gint max_label_items = 0; gint real_items_length = 0; gint var_order = -1000; gint method_order = 0; IAnjutaSymbol *node_sym; IAnjutaIterable *iter; GError *err = NULL; if (cls_node->expansion_status == expansion_type || expansion_type == CLS_NODE_COLLAPSED) return FALSE; node_sym = IANJUTA_SYMBOL (ianjuta_symbol_query_search_id (cls_node->plugin->query_id, cls_node->klass_id, &err)); if (err) { g_warning ("Symbol ID query failed: %s", err->message); g_error_free (err); err = NULL; } if (!node_sym) return FALSE; if (!(sym = agfindattr(cls_node->graph->proto->n, "shape"))) sym = agnodeattr(cls_node->graph, "shape", ""); agxset (cls_node->agnode, sym->index, "record"); if (!(sym = agfindattr(cls_node->graph->proto->n, "label"))) sym = agnodeattr(cls_node->graph, "label", ""); label = g_string_new (""); g_string_printf (label, "{%s", cls_node->sym_name); /* get members from the passed symbol node */ iter = ianjuta_symbol_query_search_members (cls_node->plugin->query_members, node_sym, &err); if (err) { g_warning ("Class members query failed: %s", err->message); g_error_free (err); err = NULL; } real_items_length = ianjuta_iterable_get_length (iter, NULL); /* set the max number of items to draw */ if (real_items_length <= NODE_HALF_DISPLAY_ELEM_NUM || expansion_type == CLS_NODE_FULL_EXPANDED) { max_label_items = real_items_length; cls_node->expansion_status = CLS_NODE_FULL_EXPANDED; } else { max_label_items = NODE_HALF_DISPLAY_ELEM_NUM; cls_node->expansion_status = CLS_NODE_SEMI_EXPANDED; } g_hash_table_remove_all (cls_node->members); if (iter && real_items_length > 0) { gint i = 0; /* First member variables */ do { const gchar *name, *args, *type_name; IAnjutaSymbol *symbol; GdkPixbuf *icon; symbol = IANJUTA_SYMBOL (iter); name = g_strdup (ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_NAME, NULL)); args = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_SIGNATURE, NULL); icon = (GdkPixbuf*) ianjuta_symbol_get_icon (symbol, NULL); if (!args) /* Member variables */ { ClsNodeItem *cls_item = g_new0 (ClsNodeItem, 1); type_name = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_TYPE_NAME, NULL); cls_item->cls_node = cls_node; cls_item->label = g_strconcat (name, " : ", type_name, NULL); cls_item->order = var_order++; if (icon) g_object_ref (icon); cls_item->icon = icon; g_hash_table_insert (cls_node->members, g_strdup (cls_item->label), cls_item); g_string_append_printf (label, "|%s", cls_item->label); /* Setup file and line */ cls_item->type_name = g_strdup (type_name); cls_item->line = ianjuta_symbol_get_int (symbol, IANJUTA_SYMBOL_FIELD_FILE_POS, NULL); cls_item->file = ianjuta_symbol_get_file (symbol, NULL); } else /* Member methods */ { ClsNodeItem *cls_item; gchar *method_key = g_strconcat (name, args, NULL); cls_item = g_hash_table_lookup (cls_node->members, method_key); if (cls_item) /* We found an entry for this method */ { IAnjutaSymbolType sym_type = ianjuta_symbol_get_sym_type (symbol, NULL); if (!(sym_type & IANJUTA_SYMBOL_TYPE_PROTOTYPE)) { /* This one is method, so take this one instead */ g_free (cls_item->args); cls_item->args = g_strdup (args); if (cls_item->file) g_object_unref (cls_item->file); cls_item->file = NULL; /* Setup file and line */ cls_item->line = ianjuta_symbol_get_int (symbol, IANJUTA_SYMBOL_FIELD_FILE_POS, NULL); cls_item->file = ianjuta_symbol_get_file (symbol, NULL); } } else /* We did not find a member entry, create a new one */ { ClsNodeItem *cls_item = g_new0 (ClsNodeItem, 1); type_name = ianjuta_symbol_get_string (symbol, IANJUTA_SYMBOL_FIELD_RETURNTYPE, NULL); cls_item->cls_node = cls_node; if (type_name) { if (strlen (args) > 2) cls_item->label = g_strconcat (name, "(...)", " : ", type_name, NULL); else cls_item->label = g_strconcat (name, "()", " : ", type_name, NULL); } else { if (strlen (args) > 2) cls_item->label = g_strconcat (name, "(...)", NULL); else cls_item->label = g_strconcat (name, "()", NULL); } cls_item->args = g_strdup (args); cls_item->type_name = g_strdup (type_name); cls_item->order = method_order++; if (icon) g_object_ref (icon); cls_item->icon = icon; g_string_append_printf (label, "|%s", cls_item->label); g_hash_table_insert (cls_node->members, method_key, cls_item); /* Setup file and line */ cls_item->line = ianjuta_symbol_get_int (symbol, IANJUTA_SYMBOL_FIELD_FILE_POS, NULL); cls_item->file = ianjuta_symbol_get_file (symbol, NULL); } } i++; } while (ianjuta_iterable_next (iter, NULL) && i < max_label_items); } if (iter) g_object_unref (iter); if (cls_node->expansion_status == CLS_NODE_SEMI_EXPANDED && real_items_length > NODE_HALF_DISPLAY_ELEM_NUM) { g_string_append_printf (label, "|%s", NODE_SHOW_ALL_MEMBERS_STR); } g_string_append_printf (label, "}"); agxset(cls_node->agnode, sym->index, label->str); /* set the margin for icons */ if (!(sym = agfindattr(cls_node->graph->proto->n, "margin"))) sym = agnodeattr(cls_node->graph, "margin", "0.11,0.055"); agxset(cls_node->agnode, sym->index, "0.3,0.03"); g_string_free (label, TRUE); return TRUE; }