Branch: refs/heads/master Author: Alexander Petukhov devel@apetukhov.ru Committer: Frank Lanitz frank@frank.uvena.de Date: Fri, 10 Feb 2012 15:28:35 Commit: b90ee233da25c14a689a5f046942fbd9c974d075 https://github.com/geany/geany-plugins/commit/b90ee233da25c14a689a5f046942fb...
Log Message: ----------- file paths in stack and breaks are truncated to file names, full paths are shown in the tooltips
Modified Paths: -------------- debugger/ChangeLog debugger/TODO debugger/src/bptree.c debugger/src/stree.c
Modified: debugger/ChangeLog 4 files changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -1,3 +1,7 @@ +10-02-2012 Alexander Petukhov devel@apetukhov.ru + + * file paths in stack and breaks are truncated to file names, full paths are shown in the tooltips + 09-02-2012 Alexander Petukhov devel@apetukhov.ru
* switch break in the break window through clicking a break icon, all breaks for a file - by a file checkbox(moved to the left)
Modified: debugger/TODO 2 files changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -10,7 +10,6 @@ FEATURES: - jump to a frame (change frame that affects locals, watch etc., caused by clicking a frame in the stack trace tab/margin stack marker) - geany menu integration - toolbar buttons -- ellipsize file names at the left in stack and breaks windows (buttons to switch full path or file names mode) - margin context menu - step back - tree views column width/autowidth @@ -19,3 +18,4 @@ FEATURES: - bashdb support - windows support - gdb backend step speed +- threads: integrate into existing stack window, add threads callbacks to dbm interface
Modified: debugger/src/bptree.c 63 files changed, 62 insertions(+), 1 deletions(-) =================================================================== @@ -150,6 +150,65 @@ static void update_file_node(GtkTreeIter *file_iter) }
/* + * shows a tooltip for a file name + */ +static gboolean on_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data) +{ + gboolean show = FALSE; + int bx, by; + gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(widget), x, y, &bx, &by); + + GtkTreePath *tpath = NULL; + GtkTreeViewColumn *column = NULL; + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bx, by, &tpath, &column, NULL, NULL)) + { + if (1 == gtk_tree_path_get_depth(tpath) && column == gtk_tree_view_get_column(GTK_TREE_VIEW(widget), FILEPATH)) + { + GtkTreeIter iter; + gtk_tree_model_get_iter(model, &iter, tpath); + + gchar *path = NULL; + gtk_tree_model_get(model, &iter, FILEPATH, &path, -1); + + gtk_tooltip_set_text(tooltip, path); + + gtk_tree_view_set_tooltip_row(GTK_TREE_VIEW(widget), tooltip, tpath); + + show = TRUE; + } + gtk_tree_path_free(tpath); + } + + return show; +} + +/* + * shows only the file name instead of a full path + */ +static void on_render_filename(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, + GtkTreeIter *iter, gpointer data) +{ + gchar *path = NULL; + gtk_tree_model_get(model, iter, FILEPATH, &path, -1); + + GtkTreePath *tpath = gtk_tree_model_get_path(model, iter); + if (1 != gtk_tree_path_get_depth(tpath)) + { + g_object_set(cell, "text", path, NULL); + } + else + { + const gchar *name = g_basename(path); + g_object_set(cell, "text", name ? name : path, NULL); + } + + if (path) + { + g_free(path); + } +} + +/* * hides file checkbox for breaks rows */ void on_render_enable_for_file(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, @@ -560,6 +619,7 @@ gboolean bptree_init(move_to_line_cb cb) /* set tree view properties */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), 1); + gtk_widget_set_has_tooltip(GTK_WIDGET(tree), TRUE); /* multiple selection */ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); @@ -567,6 +627,7 @@ gboolean bptree_init(move_to_line_cb cb) /* connect signals */ g_signal_connect(G_OBJECT(tree), "key-press-event", G_CALLBACK (on_key_pressed), NULL); g_signal_connect(G_OBJECT(tree), "row-activated", G_CALLBACK (on_row_double_click), NULL); + g_signal_connect(G_OBJECT(tree), "query-tooltip", G_CALLBACK (on_query_tooltip), NULL);
/* creating columns */ GtkTreeViewColumn *column; @@ -575,7 +636,7 @@ gboolean bptree_init(move_to_line_cb cb) 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); + gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_filename, NULL, NULL); /* enable for file */ GtkCellRenderer *file_enable_renderer = cell_renderer_toggle_new ();
Modified: debugger/src/stree.c 60 files changed, 56 insertions(+), 4 deletions(-) =================================================================== @@ -66,6 +66,56 @@ enum /* flag to indicate whether to handle selection change */ static gboolean handle_selection = TRUE;
+/* + * shows a tooltip for a file name + */ +static gboolean on_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer user_data) +{ + gboolean show = FALSE; + int bx, by; + gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(widget), x, y, &bx, &by); + + GtkTreePath *tpath = NULL; + GtkTreeViewColumn *column = NULL; + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bx, by, &tpath, &column, NULL, NULL)) + { + if (column == gtk_tree_view_get_column(GTK_TREE_VIEW(widget), S_FILEPATH)) + { + GtkTreeIter iter; + gtk_tree_model_get_iter(model, &iter, tpath); + + gchar *path = NULL; + gtk_tree_model_get(model, &iter, S_FILEPATH, &path, -1); + + gtk_tooltip_set_text(tooltip, path); + + gtk_tree_view_set_tooltip_row(GTK_TREE_VIEW(widget), tooltip, tpath); + + show = TRUE; + } + gtk_tree_path_free(tpath); + } + + return show; +} + +/* + * shows only the file name instead of a full path + */ +static void on_render_filename(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, + GtkTreeIter *iter, gpointer data) +{ + gchar *path = NULL; + gtk_tree_model_get(model, iter, S_FILEPATH, &path, -1); + const gchar *name = g_basename(path); + g_object_set(cell, "text", name ? name : path, NULL); + + if (path) + { + g_free(path); + } +} + /* * Handles same tree row click to open frame position */ @@ -173,10 +223,11 @@ void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_data) /* set tree view properties */ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), 1); - + gtk_widget_set_has_tooltip(GTK_WIDGET(tree), TRUE); + /* connect signals */ - g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree))), "changed", - G_CALLBACK (on_selection_changed), NULL); + g_signal_connect(G_OBJECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree))), "changed", G_CALLBACK (on_selection_changed), NULL); + g_signal_connect(G_OBJECT(tree), "query-tooltip", G_CALLBACK (on_query_tooltip), NULL);
/* for clicking on already selected frame */ g_signal_connect(tree, "button-press-event", @@ -205,9 +256,10 @@ void on_selection_changed(GtkTreeSelection *treeselection, gpointer user_data) /* file */ renderer_file = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("File"), renderer_file, "text", S_FILEPATH, NULL); + column = gtk_tree_view_column_new_with_attributes (_("File"), renderer_file, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); + gtk_tree_view_column_set_cell_data_func(column, renderer_file, on_render_filename, NULL, NULL); /* line */ renderer_line = gtk_cell_renderer_text_new ();
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
plugins-commits@lists.geany.org