Revision: 2191 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2191&view=re... Author: cesspit Date: 2011-09-03 20:16:45 +0000 (Sat, 03 Sep 2011) Log Message: ----------- debugger: breaks tree layout change
Modified Paths: -------------- trunk/geany-plugins/debugger/src/bptree.c trunk/geany-plugins/debugger/src/bptree.h trunk/geany-plugins/debugger/src/breakpoints.c trunk/geany-plugins/debugger/src/dconfig.c trunk/geany-plugins/debugger/src/dconfig.h trunk/geany-plugins/debugger/src/stree.c
Modified: trunk/geany-plugins/debugger/src/bptree.c =================================================================== --- trunk/geany-plugins/debugger/src/bptree.c 2011-09-01 17:57:49 UTC (rev 2190) +++ trunk/geany-plugins/debugger/src/bptree.c 2011-09-03 20:16:45 UTC (rev 2191) @@ -39,22 +39,27 @@ #include "breakpoints.h" #include "bptree.h" #include "utils.h" +#include "dconfig.h"
+#include "xpm/breakpoint.xpm" +#include "xpm/breakpoint_disabled.xpm" +#include "xpm/breakpoint_condition.xpm" + /* columns minumum width in characters */ -#define MW_ENABLED 3 -#define MW_HITSCOUNT 3 #define MW_CONDITION 20 -#define MW_FILE 0 -#define MW_LINE 4 +#define MW_FILE 20
+#define ICON_PADDING 10 + /* Tree view columns */ enum { - ENABLED, + ICON, + FILEPATH, + CONDITION, HITSCOUNT, - CONDITION, - FILEPATH, LINE, + ENABLED, N_COLUMNS };
@@ -62,7 +67,7 @@ static GtkWidget *scrolled_window = NULL; static GtkWidget *tree = NULL; static GtkTreeModel *model = NULL; -static GtkListStore *store = NULL; +static GtkTreeStore *store = NULL;
/* column cell renderes */ static GtkCellRenderer *enable_renderer; @@ -72,18 +77,110 @@ /* tells to checkbox click handler whether page is in readonly mode (debug running) */ static gboolean readonly = FALSE;
+/* hash table to keep file nodes in the tree */ +static GHashTable *files; + +/* pixbufers */ +GdkPixbuf *file_pixbuf = NULL; +GdkPixbuf *break_pixbuf = NULL; +GdkPixbuf *break_disabled_pixbuf = NULL; +GdkPixbuf *break_condition_pixbuf = NULL; + /* callback handler */ move_to_line_cb on_break_clicked = NULL;
/* + * traversed comparing functions + */ +static gboolean compare_path_references(gpointer key, gpointer value, gpointer user_data) +{ + GtkTreeRowReference *being_clicked = (GtkTreeRowReference*)user_data; + GtkTreeRowReference *compared = (GtkTreeRowReference*)value; + + return !gtk_tree_path_compare ( + gtk_tree_row_reference_get_path(being_clicked), + gtk_tree_row_reference_get_path(compared) + ); + +} + +/* + * checks file ENABLED column if all childs are enabled and unchecks otherwise + */ +static void update_file_node(GtkTreeIter *file_iter) +{ + GtkTreeIter child; + gboolean check = TRUE; + if(gtk_tree_model_iter_children(model, &child, file_iter)) + { + do + { + gboolean enabled; + gtk_tree_model_get ( + model, + &child, + ENABLED, &enabled, + -1); + + if (!enabled) + { + check = FALSE; + break; + } + } + while(gtk_tree_model_iter_next(model, &child)); + } + + gtk_tree_store_set(store, file_iter, ENABLED, check, -1); +} + +/* + * GtkTreeView cell renderer functions that do not render and make ineditable file rows + */ +void on_render(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, + GtkTreeIter *iter, gpointer data) +{ + GtkTreePath *path = gtk_tree_model_get_path(model, iter); + if (data) + { + if (gtk_tree_path_get_depth(path) == 1) + { + g_object_set(cell, "text", "", NULL); + g_object_set(cell, "editable", FALSE, NULL); + } + else + { + g_object_set(cell, "editable", TRUE, NULL); + } + } + else + { + if (gtk_tree_path_get_depth(path) == 1) + { + g_object_set(cell, "visible", FALSE, NULL); + } + else + { + g_object_set(cell, "visible", TRUE, NULL); + } + } + gtk_tree_path_free(path); +} + +/* * GtkTreeView event handlers */
/* * double click */ -void on_row_double_click(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) +static void on_row_double_click(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data) { + if (1 == gtk_tree_path_get_depth(path)) + { + return; + } + GtkTreeIter iter; gtk_tree_model_get_iter ( model, @@ -92,10 +189,19 @@
gchar *file; int line; + + GtkTreeIter parent_iter; + gtk_tree_model_iter_parent(model, &parent_iter, &iter); + gtk_tree_model_get ( model, + &parent_iter, + FILEPATH, &file, + -1); + + gtk_tree_model_get ( + model, &iter, - FILEPATH, &file, LINE, &line, -1);
@@ -118,14 +224,22 @@ &iter, tree_path); - gchar *file; + GtkTreeIter parent_iter; + gtk_tree_model_iter_parent(model, &parent_iter, &iter); + + gchar *file; + gtk_tree_model_get ( + model, + &parent_iter, + FILEPATH, &file, + -1); + int line; gchar* oldcondition; gtk_tree_model_get ( model, &iter, CONDITION, &oldcondition, - FILEPATH, &file, LINE, &line, -1);
@@ -154,14 +268,22 @@ &iter, tree_path);
- gchar *file; + GtkTreeIter parent_iter; + gtk_tree_model_iter_parent(model, &parent_iter, &iter); + + gchar *file; + gtk_tree_model_get ( + model, + &parent_iter, + FILEPATH, &file, + -1); + int line; gint oldcount; gtk_tree_model_get ( model, &iter, HITSCOUNT, &oldcount, - FILEPATH, &file, LINE, &line, -1);
@@ -183,25 +305,95 @@ GtkTreeIter iter; GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); - + gtk_tree_model_get_iter ( - model, - &iter, - tree_path); - - gchar *file; - int line; - gtk_tree_model_get ( model, &iter, - FILEPATH, &file, - LINE, &line, - -1); - - breaks_switch(file, line); - + tree_path); + + gboolean current_state = gtk_cell_renderer_toggle_get_active(cell_renderer); + + /* check if this is a file row */ + GtkTreeRowReference *path_reference = gtk_tree_row_reference_new(model, tree_path); + if(g_hash_table_find(files, compare_path_references, (gpointer)path_reference)) + { + GtkTreeIter child; + gtk_tree_model_iter_children(model, &child, &iter); + + gchar *file; + gtk_tree_model_get ( + model, + &iter, + FILEPATH, &file, + -1); + + dconfig_set_modifyable(FALSE); + do + { + gboolean enabled; + gtk_tree_model_get ( + model, + &child, + ENABLED, &enabled, + -1); + + if (!current_state ^ enabled) + { + int line; + gtk_tree_model_get ( + model, + &child, + LINE, &line, + -1); + breaks_switch(file, line); + } + } + while(gtk_tree_model_iter_next(model, &child)); + + gtk_tree_store_set(store, &iter, ENABLED, !current_state, -1); + + g_free(file); + + dconfig_set_modifyable(TRUE); + dconfig_set_changed(); + } + else + { + GtkTreeIter parent_iter; + gtk_tree_model_iter_parent(model, &parent_iter, &iter); + + gchar *file; + int line; + gboolean parent_enabed; + + gtk_tree_model_get ( + model, + &parent_iter, + FILEPATH, &file, + ENABLED, &parent_enabed, + -1); + + gtk_tree_model_get ( + model, + &iter, + LINE, &line, + -1); + + breaks_switch(file, line); + + if (current_state && parent_enabed) + { + gtk_tree_store_set(store, &parent_iter, ENABLED, FALSE, -1); + } + else if (!current_state && !parent_enabed) + { + update_file_node(&parent_iter); + } + + g_free(file); + } + gtk_tree_path_free(tree_path); - g_free(file); }
/* @@ -211,17 +403,17 @@ { guint keyval = ((GdkEventKey*)event)->keyval;
- if (keyval == GDK_Delete) + /* get selected rows */ + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); + GList *rows = gtk_tree_selection_get_selected_rows(selection, &model); + + if (keyval == GDK_Delete && rows && g_list_length(rows)) { /* "delete selected rows" */
/* path to select after deleteing finishes */ GtkTreeRowReference *reference_to_select = NULL;
- /* get selected rows */ - GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget)); - GList *rows = gtk_tree_selection_get_selected_rows(selection, &model); - /* get references to rows to keep references actual when altering model */ GList *references = NULL; GList *iter = rows; @@ -229,22 +421,11 @@ { GtkTreePath *path = (GtkTreePath*)iter->data; references = g_list_append(references, gtk_tree_row_reference_new(model, path)); - - /* - * set reference to select after deletion - upper sibling of the - * first row to delete that has upper sibling - */ - if (!reference_to_select && gtk_tree_path_prev(path)) - reference_to_select = gtk_tree_row_reference_new(model, path); - iter = iter->next; } - - /* free rows list */ - g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); - g_list_free (rows); - - /* iterate through references removing them */ + + /* remove break rows leaving file rowa for the next step */ + dconfig_set_modifyable(FALSE); iter = references; while (iter) { @@ -252,18 +433,23 @@ if (gtk_tree_row_reference_valid(reference)) { GtkTreePath *path = gtk_tree_row_reference_get_path(reference); - if (1 == gtk_tree_path_get_depth(path)) + if (gtk_tree_path_get_depth(path) > 1) { - GtkTreeIter titer; + GtkTreeIter titer, piter; gtk_tree_model_get_iter(model, &titer, path); + gtk_tree_model_iter_parent(model, &piter, &titer); gchar *filename = NULL; + gtk_tree_model_get ( + model, + &piter, + FILEPATH, &filename, + -1); + gint line; - gtk_tree_model_get ( model, &titer, - FILEPATH, &filename, LINE, &line, -1);
@@ -275,9 +461,27 @@ iter = iter->next; } + + /* remove file rows and children if exist */ + iter = references; + while (iter) + { + GtkTreePath *path = (GtkTreePath*)iter->data; + if (FALSE)//1 == gtk_tree_path_get_depth(path)) + { + } + iter = iter->next; + }
+ /* free rows list */ + g_list_foreach (references, (GFunc)gtk_tree_row_reference_free, NULL); + g_list_free (references); + + dconfig_set_modifyable(TRUE); + dconfig_set_changed(TRUE); + /* get path to select */ - GtkTreePath *path = NULL; + /*GtkTreePath *path = NULL; if (reference_to_select) path = gtk_tree_row_reference_get_path(reference_to_select); else @@ -285,26 +489,53 @@ GtkTreeIter tree_iter; gtk_tree_model_get_iter_first(model, &tree_iter); path = gtk_tree_model_get_path(model, &tree_iter); - } + }*/ /* set selection if any */ - if (path) + /*if (path) { gtk_tree_selection_select_path(selection, path); gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(widget), path, NULL, TRUE, 0.5, 0.5); gtk_tree_path_free(path); - } + }*/
/* free references list */ g_list_foreach (references, (GFunc)gtk_tree_row_reference_free, NULL); g_list_free (references); }
+ /* free rows list */ + g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL); + g_list_free (rows);
return FALSE; }
/* + * update existing breakpoint icon + * arguments: + * bp - breakpoint to update + */ +void bptree_update_break_icon(breakpoint* bp) +{ + GdkPixbuf *pixbuf; + if (!bp->enabled) + { + pixbuf = break_disabled_pixbuf; + } + else if (bp->hitscount || strlen(bp->condition)) + { + pixbuf = break_condition_pixbuf; + } + else + { + pixbuf = break_pixbuf; + } + + gtk_tree_store_set (store, &bp->iter, ICON, pixbuf, -1); +} + +/* * Interface functions */
@@ -318,14 +549,28 @@ /* save double click callback */ on_break_clicked = cb; + /* crete hash table for file nodes */ + files = g_hash_table_new_full( + g_str_hash, + g_str_equal, + (GDestroyNotify)g_free, + (GDestroyNotify)gtk_tree_row_reference_free + ); + + file_pixbuf = gdk_pixbuf_new_from_xpm_data(breakpoint_xpm); + break_pixbuf = gdk_pixbuf_new_from_xpm_data(breakpoint_xpm); + break_disabled_pixbuf = gdk_pixbuf_new_from_xpm_data(breakpoint_disabled_xpm); + break_condition_pixbuf = gdk_pixbuf_new_from_xpm_data(breakpoint_condition_xpm); + /* create tree view */ - store = gtk_list_store_new ( + store = gtk_tree_store_new ( N_COLUMNS, - G_TYPE_BOOLEAN, - G_TYPE_INT, + GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INT); + G_TYPE_INT, + G_TYPE_INT, + G_TYPE_BOOLEAN); model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (model); @@ -334,8 +579,6 @@ /* multiple selection */ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); - /* interlaced rows colors */ - g_object_set(tree, "rules-hint", TRUE, NULL); /* connect signals */ g_signal_connect(G_OBJECT(tree), "key-press-event", G_CALLBACK (on_key_pressed), NULL); @@ -347,51 +590,68 @@ int char_width = get_char_width(tree);
- /* enabled */ - header = _("Enabled"); - enable_renderer = gtk_cell_renderer_toggle_new (); - g_signal_connect (G_OBJECT(enable_renderer), "toggled", G_CALLBACK(on_activeness_changed), NULL); - column = create_column(header, enable_renderer, FALSE, - get_header_string_width(header, MW_ENABLED, char_width), - "active", ENABLED); + /* icon, file */ + header = _("File"); + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new(); + + gtk_tree_view_column_pack_end(column, renderer, TRUE); + gtk_tree_view_column_set_attributes(column, renderer, "text", FILEPATH, NULL); + + GtkCellRenderer *icon_renderer = gtk_cell_renderer_pixbuf_new (); + g_object_set(icon_renderer, "follow-state", TRUE, NULL); + gtk_tree_view_column_pack_end(column, icon_renderer, FALSE); + gtk_tree_view_column_set_attributes(column, icon_renderer, "pixbuf", ICON, NULL); + gtk_tree_view_column_set_cell_data_func(column, icon_renderer, on_render, NULL, NULL); + + gtk_tree_view_column_set_spacing(column, char_width); + gtk_tree_view_column_set_expand(column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); + + /* condition */ + header = _("Condition"); + condition_renderer = gtk_cell_renderer_text_new (); + g_object_set (condition_renderer, "editable", TRUE, NULL); + g_signal_connect (G_OBJECT (condition_renderer), "edited", G_CALLBACK (on_condition_changed), NULL); + column = create_column(header, condition_renderer, TRUE, + get_header_string_width(header, MW_CONDITION, char_width), + "text", CONDITION); + gtk_tree_view_column_set_cell_data_func(column, condition_renderer, on_render, (gpointer)TRUE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); + /* hits count */ header = _("Hit count"); hcount_renderer = gtk_cell_renderer_spin_new (); GtkAdjustment* adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100000.0, 1.0, 2.0, 2.0)); g_object_set (hcount_renderer, - "editable", TRUE, "adjustment", adj, "digits", 0, NULL); g_signal_connect (G_OBJECT (hcount_renderer), "edited", G_CALLBACK (on_hitscount_changed), NULL); column = create_column(header, hcount_renderer, FALSE, - get_header_string_width(header, MW_HITSCOUNT, char_width), + 0, "text", HITSCOUNT); + gtk_tree_view_column_set_cell_data_func(column, hcount_renderer, on_render, (gpointer)TRUE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); - /* condition */ - header = _("Condition"); - condition_renderer = gtk_cell_renderer_text_new (); - g_object_set (condition_renderer, "editable", TRUE, NULL); - g_signal_connect (G_OBJECT (condition_renderer), "edited", G_CALLBACK (on_condition_changed), NULL); - column = create_column(header, condition_renderer, FALSE, - get_header_string_width(header, MW_CONDITION, char_width), - "text", CONDITION); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); - /* file */ - header = _("File"); - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - column = create_column(header, renderer, TRUE, - get_header_string_width(header, MW_FILE, char_width), - "text", FILEPATH); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); + /* line */ header = _("Line"); renderer = gtk_cell_renderer_text_new (); column = create_column(header, renderer, FALSE, - get_header_string_width(header, MW_LINE, char_width), + 0, "text", LINE); + gtk_tree_view_column_set_visible(column, FALSE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+ /* enabled */ + header = _("Enabled"); + enable_renderer = gtk_cell_renderer_toggle_new (); + g_signal_connect (G_OBJECT(enable_renderer), "toggled", G_CALLBACK(on_activeness_changed), NULL); + column = create_column(header, enable_renderer, FALSE, + 0, + "active", ENABLED); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolled_window); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -403,36 +663,50 @@ }
/* + * destroy breaks tree and associated data + * arguments: + */ +void bptree_destroy() +{ + g_hash_table_destroy(files); + + g_object_unref(file_pixbuf); + g_object_unref(break_pixbuf); + g_object_unref(break_disabled_pixbuf); + g_object_unref(break_condition_pixbuf); +} + +/* * enable/disable break * arguments: - * iter - tree view iterator - * enabled - value + * bp - breakpoint */ -void bptree_set_enabled(GtkTreeIter iter, gboolean enabled) +void bptree_set_enabled(breakpoint *bp) { - gtk_list_store_set(store, &iter, ENABLED, enabled, -1); + gtk_tree_store_set(store, &(bp->iter), ENABLED, bp->enabled, -1); + bptree_update_break_icon(bp); }
/* * set breaks hits count * arguments: - * iter - tree view iterator - * hitscount - value + * bp - breakpoint */ -void bptree_set_hitscount(GtkTreeIter iter, int hitscount) +void bptree_set_hitscount(breakpoint *bp) { - gtk_list_store_set(store, &iter, HITSCOUNT, hitscount, -1); + gtk_tree_store_set(store, &(bp->iter), HITSCOUNT, bp->hitscount, -1); + bptree_update_break_icon(bp); }
/* * set breaks condition * arguments: - * iter - tree view iterator - * condition - value + * bp - breakpoint */ -void bptree_set_condition(GtkTreeIter iter, gchar* condition) +void bptree_set_condition(breakpoint* bp) { - gtk_list_store_set(store, &iter, CONDITION, condition, -1); + gtk_tree_store_set(store, &(bp->iter), CONDITION, bp->condition, -1); + bptree_update_break_icon(bp); }
/* @@ -441,12 +715,12 @@ * iter - tree view iterator * return value - breaks condition */ -gchar* bptree_get_condition(GtkTreeIter iter) +gchar* bptree_get_condition(breakpoint *bp) { gchar *condition; gtk_tree_model_get ( model, - &iter, + &(bp->iter), CONDITION, &condition, -1);
@@ -481,16 +755,52 @@ */ void bptree_add_breakpoint(breakpoint* bp) { + GtkTreeIter file_iter; + GtkTreeRowReference *file_reference = (GtkTreeRowReference*)g_hash_table_lookup(files, bp->file); + if (!file_reference) + { + gtk_tree_store_prepend (store, &file_iter, NULL); + gtk_tree_store_set (store, &file_iter, + FILEPATH, bp->file, + -1); + + GtkTreePath *file_path = gtk_tree_model_get_path(model, &file_iter); + file_reference = gtk_tree_row_reference_new(model, file_path); + gtk_tree_path_free(file_path); + + g_hash_table_insert(files, (gpointer)g_strdup(bp->file),(gpointer)file_reference); + } + else + { + gtk_tree_model_get_iter(model, &file_iter, gtk_tree_row_reference_get_path(file_reference)); + } + + /* lookup where to insert new row */ + GtkTreeIter child, *sibling = NULL; + if(gtk_tree_model_iter_children(model, &child, &file_iter)) + { + do + { + int line; + gtk_tree_model_get ( + model, + &child, + LINE, &line, + -1); + if (line > bp->line) + { + sibling = &child; + break; + } + } + while(gtk_tree_model_iter_next(model, &child)); + } + GtkTreeIter iter; - gtk_list_store_prepend (store, &iter); - gtk_list_store_set (store, &iter, - ENABLED, bp->enabled, - HITSCOUNT, bp->hitscount, - CONDITION, bp->condition, - FILEPATH, bp->file, - LINE, bp->line, - -1); + gtk_tree_store_insert_before(store, &iter, &file_iter, sibling); bp->iter = iter; + + bptree_update_breakpoint(bp); }
/* @@ -500,15 +810,19 @@ */ void bptree_update_breakpoint(breakpoint* bp) { - char file_and_line[FILENAME_MAX + 10]; - sprintf(file_and_line, "%s:%i", bp->file, bp->line); - gtk_list_store_set (store, &bp->iter, + gchar *location = g_strdup_printf(_("line %i"), bp->line); + + gtk_tree_store_set (store, &bp->iter, ENABLED, bp->enabled, HITSCOUNT, bp->hitscount, CONDITION, bp->condition, - FILEPATH, bp->file, + FILEPATH, location, LINE, bp->line, -1); + + bptree_update_break_icon(bp); + + g_free(location); }
/* @@ -518,5 +832,30 @@ */ void bptree_remove_breakpoint(breakpoint* bp) { - gtk_list_store_remove(store, &(bp->iter)); + GtkTreeIter file; + gtk_tree_model_iter_parent(model, &file, &(bp->iter)); + + gtk_tree_store_remove(store, &(bp->iter)); + + if (!gtk_tree_model_iter_n_children(model, &file)) + { + gtk_tree_store_remove(store, &file); + } } + +/* + * updates all file ENABLED checkboxes base on theit children states + * arguments: + */ +void bptree_update_file_nodes() +{ + GtkTreeIter file; + if(gtk_tree_model_iter_children(model, &file, NULL)) + { + do + { + update_file_node(&file); + } + while(gtk_tree_model_iter_next(model, &file)); + } +}
Modified: trunk/geany-plugins/debugger/src/bptree.h =================================================================== --- trunk/geany-plugins/debugger/src/bptree.h 2011-09-01 17:57:49 UTC (rev 2190) +++ trunk/geany-plugins/debugger/src/bptree.h 2011-09-03 20:16:45 UTC (rev 2191) @@ -20,12 +20,14 @@ */
gboolean bptree_init(move_to_line_cb callback); +void bptree_destroy(); GtkWidget* bptree_get_widget(); void bptree_add_breakpoint(breakpoint* bp); void bptree_update_breakpoint(breakpoint* bp); void bptree_remove_breakpoint(breakpoint* bp); -void bptree_set_condition(GtkTreeIter iter, gchar* condition); -void bptree_set_hitscount(GtkTreeIter iter, int hitscount); -void bptree_set_enabled(GtkTreeIter iter, gboolean enabled); -gchar* bptree_get_condition(GtkTreeIter iter); +void bptree_set_condition(breakpoint* bp); +void bptree_set_hitscount(breakpoint* bp); +void bptree_set_enabled(breakpoint* bp); +gchar* bptree_get_condition(breakpoint* bp); void bptree_set_readonly(gboolean readonly); +void bptree_update_file_nodes();
Modified: trunk/geany-plugins/debugger/src/breakpoints.c =================================================================== --- trunk/geany-plugins/debugger/src/breakpoints.c 2011-09-01 17:57:49 UTC (rev 2190) +++ trunk/geany-plugins/debugger/src/breakpoints.c 2011-09-03 20:16:45 UTC (rev 2191) @@ -191,7 +191,7 @@ { if (success) { - bptree_set_hitscount(bp->iter, bp->hitscount); + bptree_set_hitscount(bp); markers_remove_breakpoint(bp); markers_add_breakpoint(bp); /* mark config for saving */ @@ -212,7 +212,7 @@ if (success) { /* set condition in breaks tree */ - bptree_set_condition(bp->iter, bp->condition); + bptree_set_condition(bp); markers_remove_breakpoint(bp); markers_add_breakpoint(bp); /* mark config for saving */ @@ -221,7 +221,7 @@ else { /* revert to old condition (taken from tree) */ - gchar* oldcondition = bptree_get_condition(bp->iter); + gchar* oldcondition = bptree_get_condition(bp); strcpy(bp->condition, oldcondition); g_free(oldcondition); /* show error message */ @@ -242,7 +242,7 @@ markers_add_breakpoint(bp);
/* set checkbox in breaks tree */ - bptree_set_enabled(bp->iter, bp->enabled); + bptree_set_enabled(bp);
/* mark config for saving */ dconfig_set_changed(); @@ -316,6 +316,9 @@ /* free storage */ g_hash_table_destroy(files); + + /* destroy breaks tree data */ + bptree_destroy(); }
/*
Modified: trunk/geany-plugins/debugger/src/dconfig.c =================================================================== --- trunk/geany-plugins/debugger/src/dconfig.c 2011-09-01 17:57:49 UTC (rev 2190) +++ trunk/geany-plugins/debugger/src/dconfig.c 2011-09-03 20:16:45 UTC (rev 2191) @@ -38,6 +38,7 @@ #include "wtree.h" #include "breakpoints.h" #include "tpage.h" +#include "bptree.h"
#define CONFIG_NAME ".debugger"
@@ -57,7 +58,7 @@ static GCond *cond; static GThread *saving_thread; static gboolean config_changed = FALSE; -static gboolean loading_or_cleaning = FALSE; +static gboolean modifyable = FALSE;
/* the folder, config has been loaded from */ static gchar *current_folder = NULL; @@ -109,11 +110,19 @@ }
/* + * set "modifyable" flag that shows that a background thread have to save config + */ +void dconfig_set_modifyable(gboolean newstate) +{ + modifyable = newstate; +} + +/* * set "changed" flag to save it on "saving_thread" thread */ void dconfig_set_changed() { - if (!loading_or_cleaning) + if (!modifyable) { g_mutex_lock(change_config_mutex); config_changed = TRUE; @@ -167,7 +176,7 @@ */ gboolean dconfig_load(gchar *folder) { - loading_or_cleaning = TRUE; + modifyable = TRUE; g_mutex_lock(change_config_mutex);
tpage_clear(); @@ -186,7 +195,7 @@ { config_changed = FALSE;
- loading_or_cleaning = FALSE; + modifyable = FALSE; g_mutex_unlock(change_config_mutex);
return FALSE; @@ -265,10 +274,12 @@ } } } + + bptree_update_file_nodes();
config_changed = FALSE;
- loading_or_cleaning = FALSE; + modifyable = FALSE; g_mutex_unlock(change_config_mutex); return TRUE;
Modified: trunk/geany-plugins/debugger/src/dconfig.h =================================================================== --- trunk/geany-plugins/debugger/src/dconfig.h 2011-09-01 17:57:49 UTC (rev 2190) +++ trunk/geany-plugins/debugger/src/dconfig.h 2011-09-03 20:16:45 UTC (rev 2191) @@ -26,5 +26,6 @@ gboolean dconfig_load(gchar *folder);
void dconfig_set_changed(); +void dconfig_set_modifyable(gboolean newstate);
Modified: trunk/geany-plugins/debugger/src/stree.c =================================================================== --- trunk/geany-plugins/debugger/src/stree.c 2011-09-01 17:57:49 UTC (rev 2190) +++ trunk/geany-plugins/debugger/src/stree.c 2011-09-03 20:16:45 UTC (rev 2191) @@ -36,10 +36,6 @@
#include "xpm/frame_current.xpm"
-#include "geanyplugin.h" -extern GeanyFunctions *geany_functions; -extern GeanyPlugin *geany_plugin; - /* columns minumum width in characters */ #define MW_ADRESS 10 #define MW_FUNCTION 10
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.