Revision: 2194 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=2194&view=re... Author: cesspit Date: 2011-09-10 18:27:49 +0000 (Sat, 10 Sep 2011) Log Message: ----------- debugger: two panels mode
Modified Paths: -------------- trunk/geany-plugins/debugger/src/Makefile.am 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/breakpoints.h trunk/geany-plugins/debugger/src/btnpanel.c trunk/geany-plugins/debugger/src/btnpanel.h trunk/geany-plugins/debugger/src/callbacks.c trunk/geany-plugins/debugger/src/debug.c trunk/geany-plugins/debugger/src/debug.h trunk/geany-plugins/debugger/src/plugin.c trunk/geany-plugins/debugger/src/stree.c trunk/geany-plugins/debugger/src/stree.h trunk/geany-plugins/debugger/src/tpage.c trunk/geany-plugins/debugger/src/tpage.h trunk/geany-plugins/debugger/src/utils.c trunk/geany-plugins/debugger/src/utils.h trunk/geany-plugins/debugger/src/vtree.c trunk/geany-plugins/po/POTFILES.in
Added Paths: ----------- trunk/geany-plugins/debugger/src/dpaned.c trunk/geany-plugins/debugger/src/dpaned.h trunk/geany-plugins/debugger/src/tabs.c trunk/geany-plugins/debugger/src/tabs.h
Modified: trunk/geany-plugins/debugger/src/Makefile.am =================================================================== --- trunk/geany-plugins/debugger/src/Makefile.am 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/Makefile.am 2011-09-10 18:27:49 UTC (rev 2194) @@ -29,6 +29,8 @@ debug.h \ debug_module.c \ debug_module.h \ + dpaned.c \ + dpaned.h \ gui.h \ gui.c \ keys.c \ @@ -40,6 +42,8 @@ plugin.c \ stree.c \ stree.h \ + tabs.c \ + tabs.h \ tpage.c \ tpage.h \ utils.c \
Modified: trunk/geany-plugins/debugger/src/bptree.c =================================================================== --- trunk/geany-plugins/debugger/src/bptree.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/bptree.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -40,17 +40,12 @@ #include "bptree.h" #include "utils.h" #include "dconfig.h" +#include "tabs.h"
#include "xpm/breakpoint.xpm" #include "xpm/breakpoint_disabled.xpm" #include "xpm/breakpoint_condition.xpm"
-/* columns minumum width in characters */ -#define MW_CONDITION 20 -#define MW_FILE 20 - -#define ICON_PADDING 10 - /* Tree view columns */ enum { @@ -60,11 +55,11 @@ HITSCOUNT, LINE, ENABLED, + LAST_VISIBLE, N_COLUMNS };
/* tree view and store handles */ -static GtkWidget *scrolled_window = NULL; static GtkWidget *tree = NULL; static GtkTreeModel *model = NULL; static GtkTreeStore *store = NULL; @@ -655,7 +650,8 @@ G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, - G_TYPE_BOOLEAN); + G_TYPE_BOOLEAN, + G_TYPE_STRING); model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (model); @@ -671,81 +667,66 @@
/* creating columns */ GtkTreeViewColumn *column; - const gchar *header; - - int char_width = get_char_width(tree);
/* icon, file */ - header = _("File"); GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); 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_title(column, _("Location")); 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_column_set_resizable (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_object_set (condition_renderer, "ellipsize", PANGO_ELLIPSIZE_END, 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); + column = gtk_tree_view_column_new_with_attributes (_("Condition"), condition_renderer, "text", CONDITION, NULL); gtk_tree_view_column_set_cell_data_func(column, condition_renderer, on_render, (gpointer)TRUE, NULL); + gtk_tree_view_column_set_resizable (column, TRUE); 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, "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, - 0, - "text", HITSCOUNT); + column = gtk_tree_view_column_new_with_attributes (_("Hit count"), hcount_renderer, "text", HITSCOUNT, NULL); 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); /* line */ - header = _("Line"); renderer = gtk_cell_renderer_text_new (); - column = create_column(header, renderer, FALSE, - 0, - "text", LINE); + column = gtk_tree_view_column_new_with_attributes (_("Line"), renderer, "text", LINE, NULL); 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); + column = gtk_tree_view_column_new_with_attributes (_("Enabled"), enable_renderer, "active", ENABLED, NULL); 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); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_NONE); + /* Last invisible column */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", LAST_VISIBLE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
- gtk_container_add (GTK_CONTAINER (scrolled_window), tree); + tab_breaks = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_show (tab_breaks); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tab_breaks), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (tab_breaks), GTK_SHADOW_NONE);
+ gtk_container_add (GTK_CONTAINER (tab_breaks), tree); + return TRUE; }
@@ -831,15 +812,6 @@ }
/* - * get tree view widget - * return value - tree view widget - */ -GtkWidget* bptree_get_widget() -{ - return scrolled_window; -} - -/* * add new breakpoint to the tree view * arguments: * bp - breakpoint to add
Modified: trunk/geany-plugins/debugger/src/bptree.h =================================================================== --- trunk/geany-plugins/debugger/src/bptree.h 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/bptree.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -21,7 +21,6 @@
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);
Modified: trunk/geany-plugins/debugger/src/breakpoints.c =================================================================== --- trunk/geany-plugins/debugger/src/breakpoints.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/breakpoints.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -567,11 +567,3 @@ g_hash_table_foreach(files, hash_table_foreach_add_to_list, &breaks); return breaks; } - -/* - * Get breakpoints widget - */ -GtkWidget* breaks_get_widget() -{ - return bptree_get_widget(); -}
Modified: trunk/geany-plugins/debugger/src/breakpoints.h =================================================================== --- trunk/geany-plugins/debugger/src/breakpoints.h 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/breakpoints.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -37,7 +37,6 @@ void breaks_set_condition(char* file, int line, char* condition); void breaks_move_to_line(char* file, int line_from, int line_to); break_state breaks_get_state(const char* file, int line); -GtkWidget* breaks_get_widget(); GList* breaks_get_for_document(const char* file); GList* breaks_get_all();
Modified: trunk/geany-plugins/debugger/src/btnpanel.c =================================================================== --- trunk/geany-plugins/debugger/src/btnpanel.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/btnpanel.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -37,6 +37,7 @@ #include "breakpoints.h" #include "watch_model.h" #include "wtree.h" +#include "dpaned.h" #include "btnpanel.h"
#define CP_BUTTONS_PAD 5 @@ -118,7 +119,7 @@ /* * create and initialize buttons panel */ -GtkWidget* btnpanel_create() +GtkWidget* btnpanel_create(on_toggle cb) { GtkWidget *vbox = gtk_vbox_new(FALSE, CP_BUTTONS_PAD); gtk_container_set_border_width (GTK_CONTAINER (vbox), 7); @@ -179,6 +180,8 @@
vbutton_box = gtk_vbox_new(TRUE, CP_BUTTONS_PAD); tabbtn = create_toggle_button("tabs.gif", _("Tabs")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tabbtn), dpaned_get_tabbed()); + g_signal_connect(G_OBJECT(tabbtn), "toggled", G_CALLBACK(cb), NULL); gtk_box_pack_start(GTK_BOX(vbox), tabbtn, FALSE, FALSE, 0);
optbtn = create_stock_button(GTK_STOCK_PREFERENCES, "Настройки");
Modified: trunk/geany-plugins/debugger/src/btnpanel.h =================================================================== --- trunk/geany-plugins/debugger/src/btnpanel.h 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/btnpanel.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -19,7 +19,9 @@ * MA 02110-1301, USA. */
-GtkWidget* btnpanel_create(); +typedef void (*on_toggle)(GtkToggleButton *button, gpointer user_data); + +GtkWidget* btnpanel_create(on_toggle cb); void btnpanel_on_document_close(); void btnpanel_on_document_activate(GeanyDocument *doc);
Modified: trunk/geany-plugins/debugger/src/callbacks.c =================================================================== --- trunk/geany-plugins/debugger/src/callbacks.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/callbacks.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -38,6 +38,7 @@ #include "bptree.h" #include "btnpanel.h" #include "dconfig.h" +#include "tabs.h"
extern GeanyFunctions *geany_functions;
@@ -358,9 +359,9 @@ if (DBS_STOPPED == debug_get_state() && debug_current_instruction_have_sources()) { debug_jump_to_current_instruction(); - gtk_widget_set_sensitive(stree_get_widget(), FALSE); + gtk_widget_set_sensitive(tab_call_stack, FALSE); stree_select_first(); - gtk_widget_set_sensitive(stree_get_widget(), TRUE); + gtk_widget_set_sensitive(tab_call_stack, TRUE); } } }
Modified: trunk/geany-plugins/debugger/src/debug.c =================================================================== --- trunk/geany-plugins/debugger/src/debug.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/debug.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -60,6 +60,7 @@ #include "bptree.h" #include "btnpanel.h" #include "dconfig.h" +#include "tabs.h"
/* * calltip size @@ -110,9 +111,6 @@ /* debug terminal widget */ GtkWidget *terminal = NULL;
-/* pointer to the debug notebook widget */ -static GtkWidget* debug_notebook = NULL; - /* GtkTextView to put debugger messages */ static GtkWidget *debugger_messages_textview = NULL;
@@ -867,12 +865,9 @@ /* * init debug related GUI (watch tree view) * arguments: - * nb - GtkNotebook to add watch page */ -void debug_init(GtkWidget* nb) +void debug_init() { - debug_notebook = nb; - /* create watch page */ wtree = wtree_init(on_watch_expanded_callback, on_watch_dragged_callback, @@ -882,47 +877,37 @@ wmodel = gtk_tree_view_get_model(GTK_TREE_VIEW(wtree)); wstore = GTK_TREE_STORE(wmodel); - GtkWidget *sview = gtk_scrolled_window_new( + tab_watch = gtk_scrolled_window_new( gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(wtree)), gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(wtree)) ); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sview), + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_watch), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sview), wtree); - gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook), - sview, - gtk_label_new(_("Watch"))); + gtk_container_add(GTK_CONTAINER(tab_watch), wtree);
/* create locals page */ ltree = ltree_init(on_watch_expanded_callback, on_watch_button_pressed_callback); - sview = gtk_scrolled_window_new( + tab_locals = gtk_scrolled_window_new( gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(ltree)), gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(ltree)) ); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sview), + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_locals), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sview), ltree); - gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook), - sview, - gtk_label_new(_("Locals"))); - + gtk_container_add(GTK_CONTAINER(tab_locals), ltree); + /* create stack trace page */ - stree_init(editor_open_position); - stree = stree_get_widget(); - sview = gtk_scrolled_window_new( + stree = stree_init(editor_open_position); + tab_call_stack = gtk_scrolled_window_new( gtk_tree_view_get_hadjustment(GTK_TREE_VIEW(stree )), gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(stree )) ); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sview), + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_call_stack), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(sview), stree); - gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook), - sview, - gtk_label_new(_("Call Stack"))); - + gtk_container_add(GTK_CONTAINER(tab_call_stack), stree); + /* create debug terminal page */ terminal = vte_terminal_new(); /* create PTY */ @@ -934,10 +919,10 @@ vte_terminal_set_pty(VTE_TERMINAL(terminal), pty_master); GtkWidget *scrollbar = gtk_vscrollbar_new(GTK_ADJUSTMENT(VTE_TERMINAL(terminal)->adjustment)); GTK_WIDGET_UNSET_FLAGS(scrollbar, GTK_CAN_FOCUS); - GtkWidget *_frame = gtk_frame_new(NULL); - gtk_frame_set_shadow_type (GTK_FRAME(_frame), GTK_SHADOW_NONE); + tab_terminal = gtk_frame_new(NULL); + gtk_frame_set_shadow_type (GTK_FRAME(tab_terminal), GTK_SHADOW_NONE); GtkWidget *hbox = gtk_hbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(_frame), hbox); + gtk_container_add(GTK_CONTAINER(tab_terminal), hbox); gtk_box_pack_start(GTK_BOX(hbox), terminal, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0); /* set the default widget size first to prevent VTE expanding too much, @@ -950,26 +935,20 @@ g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL); gchar *font = utils_get_setting_string(config, "VTE", "font", "Monospace 10"); vte_terminal_set_font_from_string (VTE_TERMINAL(terminal), font); - gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook), - _frame, - gtk_label_new(_("Debug terminal"))); /* debug messages page */ - sview = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sview), + tab_messages = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tab_messages), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(sview)); - vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sview)); + hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(tab_messages)); + vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(tab_messages)); debugger_messages_textview = gtk_text_view_new(); gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(debugger_messages_textview), GTK_WRAP_CHAR); gtk_text_view_set_editable (GTK_TEXT_VIEW (debugger_messages_textview), FALSE); - gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sview), debugger_messages_textview); - gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook), - sview, - gtk_label_new(_("Debugger messages"))); - + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tab_messages), debugger_messages_textview); + /* create tex tags */ GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(debugger_messages_textview)); gtk_text_buffer_create_tag(buffer, "black", "foreground", "#000000", NULL); @@ -980,8 +959,6 @@ gtk_text_buffer_create_tag(buffer, "yellow", "foreground", "#FFFF00", NULL); gtk_text_buffer_create_tag(buffer, "brown", "foreground", "#BB8915", NULL); gtk_text_buffer_create_tag(buffer, "rose", "foreground", "#BA92B7", NULL); - - gtk_widget_show_all(debug_notebook); }
/*
Modified: trunk/geany-plugins/debugger/src/debug.h =================================================================== --- trunk/geany-plugins/debugger/src/debug.h 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/debug.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -34,8 +34,8 @@ /* function type to execute on interrupt */ typedef void (*bs_callback)(breakpoint*, break_set_activity);
-void debug_init(GtkWidget* nb); -enum dbs debug_get_state(); +void debug_init(); +enum dbs debug_get_state(); void debug_run(); void debug_stop(); void debug_step_over();
Added: trunk/geany-plugins/debugger/src/dpaned.c =================================================================== --- trunk/geany-plugins/debugger/src/dpaned.c (rev 0) +++ trunk/geany-plugins/debugger/src/dpaned.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -0,0 +1,456 @@ +/* + * + * dpaned.c + * + * Copyright 2010 Alexander Petukhov <devel(at)apetukhov.ru> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +/* + * Working with debug paned. + */ + +#include <sys/stat.h> + +#include <memory.h> +#include <string.h> + +#include "geanyplugin.h" +extern GeanyFunctions *geany_functions; +extern GeanyData *geany_data; + +#include "tabs.h" +#include "breakpoint.h" +#include "breakpoints.h" +#include "debug.h" +#include "btnpanel.h" +#include "stree.h" + +#define NOTEBOOK_GROUP 438948394 +#define HPANED_BORDER_WIDTH 4 + +#define CONNECT_PAGE_SIGNALS(X) \ + swicth_left_handler_id = g_signal_connect(G_OBJECT(debug_notebook_left), "switch-page", G_CALLBACK(on_change_current_page), NULL); \ + swicth_right_handler_id = g_signal_connect(G_OBJECT(debug_notebook_right), "switch-page", G_CALLBACK(on_change_current_page), NULL); \ + g_signal_connect(G_OBJECT(debug_notebook_left), "page-reordered", G_CALLBACK(on_page_reordered), NULL); \ + g_signal_connect(G_OBJECT(debug_notebook_right), "page-reordered", G_CALLBACK(on_page_reordered), NULL); \ + add_left_handler_id = g_signal_connect(G_OBJECT(debug_notebook_left), "page-added", G_CALLBACK(on_page_added), NULL); \ + add_right_handler_id = g_signal_connect(G_OBJECT(debug_notebook_right), "page-added", G_CALLBACK(on_page_added), NULL); \ + remove_left_handler_id = g_signal_connect(G_OBJECT(debug_notebook_left), "page-removed", G_CALLBACK(on_page_removed), NULL); \ + remove_right_handler_id = g_signal_connect(G_OBJECT(debug_notebook_right), "page-removed", G_CALLBACK(on_page_removed), NULL); + +#define DISCONNECT_PAGE_SIGNALS(X) \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_left), swicth_left_handler_id); \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_right), swicth_right_handler_id); \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_left), reorder_left_handler_id); \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_right), reorder_right_handler_id); \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_left), add_left_handler_id); \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_right), add_right_handler_id); \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_left), remove_left_handler_id); \ + g_signal_handler_disconnect(G_OBJECT(debug_notebook_right), remove_right_handler_id); + +#define CONNECT_ALLOCATED_PAGE_SIGNALS(X) \ + allocate_handler_id = g_signal_connect(G_OBJECT(hpaned), "size-allocate", G_CALLBACK(on_size_allocate), NULL); + +#define DISCONNECT_ALLOCATED_PAGE_SIGNALS(X) \ + g_signal_handler_disconnect(G_OBJECT(hpaned), allocate_handler_id); \ + +/* config file path */ +static gchar *config_path = NULL; + +/* config GKeyFile */ +static GKeyFile *key_file = NULL; + +/* pane */ +static GtkWidget *hpaned = NULL; + +/* left and right notebooks */ +static GtkWidget *debug_notebook_left = NULL; +static GtkWidget *debug_notebook_right = NULL; + + +/* notebook signal handler ids */ + +static gulong allocate_handler_id; + +static gulong swicth_left_handler_id; +static gulong swicth_right_handler_id; + +static gulong reorder_left_handler_id; +static gulong reorder_right_handler_id; + +static gulong add_left_handler_id; +static gulong add_right_handler_id; + +static gulong remove_left_handler_id; +static gulong remove_right_handler_id; + +/* keeps current tabbed mode */ +static gboolean is_tabbed; + +/* + * save config to a file + */ +static void save_config() +{ + gchar *data = g_key_file_to_data(key_file, NULL, NULL); + g_file_set_contents(config_path, data, -1, NULL); + g_free(data); +} + +/* + * first allocation handler to properly set paned position + */ +void on_size_allocate(GtkWidget *widget,GdkRectangle *allocation, gpointer user_data) +{ + DISCONNECT_ALLOCATED_PAGE_SIGNALS(); + + int position = (allocation->width - 2 * HPANED_BORDER_WIDTH) * 0.5; + gtk_paned_set_position(GTK_PANED(hpaned), position); +} + +/* + * page added event handler + */ +static void on_page_added(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) +{ + gboolean left = (GTK_NOTEBOOK(debug_notebook_left) == notebook); + + const gchar *group = is_tabbed ? "two_panels_mode" : "one_panel_mode"; + const gchar *tabs_key = is_tabbed ? (left ? "left_tabs" : "right_tabs") : "tabs"; + + gsize length; + int *tabs = g_key_file_get_integer_list(key_file, group, tabs_key, &length, NULL); + + int *new_tabs = g_malloc((length + 1) * sizeof(int)); + memcpy(new_tabs, tabs, length * sizeof(int)); + memmove(new_tabs + page_num + 1, new_tabs + page_num, (length - page_num) * sizeof(int)); + + GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(left ? debug_notebook_left : debug_notebook_right), page_num); + tab_id id = tabs_get_tab_id(page); + new_tabs[page_num] = id; + + g_key_file_set_integer_list(key_file, group, tabs_key, new_tabs, length + 1); + + save_config(); + + g_free(tabs); + g_free(new_tabs); +} + +/* + * page reordered event handler + */ +static void on_page_reordered(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) +{ + gboolean left = (GTK_NOTEBOOK(debug_notebook_left) == notebook); + + const gchar *group = is_tabbed ? "two_panels_mode" : "one_panel_mode"; + const gchar *tabs_key = is_tabbed ? (left ? "left_tabs" : "right_tabs") : "tabs"; + const gchar *selected_key = is_tabbed ? (left ? "left_selected_tab_index" : "right_selected_tab_index") : "selected_tab_index"; + + gsize length; + int *tabs = g_key_file_get_integer_list(key_file, group, tabs_key, &length, NULL); + + int prev_index; + GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(left ? debug_notebook_left : debug_notebook_right), page_num); + tab_id id = tabs_get_tab_id(page); + for (prev_index = 0; prev_index < length; prev_index++) + { + if (id == tabs[prev_index]) + { + break; + } + } + + int i, min = MIN(prev_index, page_num), max = MAX(prev_index, page_num); + for (i = min; i < max; i++) + { + int tmp = tabs[i]; + tabs[i] = tabs[i + 1]; + tabs[i + 1] = tmp; + } + + g_key_file_set_integer_list(key_file, group, tabs_key, tabs, length); + g_key_file_set_integer(key_file, group, selected_key, page_num); + + save_config(); + + g_free(tabs); +} + +/* + * page removed event handler + */ +static void on_page_removed(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data) +{ + gboolean left = (GTK_NOTEBOOK(debug_notebook_left) == notebook); + + const gchar *group = is_tabbed ? "two_panels_mode" : "one_panel_mode"; + const gchar *tabs_key = is_tabbed ? (left ? "left_tabs" : "right_tabs") : "tabs"; + + gsize length; + int *tabs = g_key_file_get_integer_list(key_file, group, tabs_key, &length, NULL); + memmove(tabs + page_num, tabs + page_num + 1, (length - page_num - 1) * sizeof(int)); + + g_key_file_set_integer_list(key_file, group, tabs_key, tabs, length - 1); + + save_config(); + + g_free(tabs); +} + +/* + * active page changed event handler + */ +static gboolean on_change_current_page(GtkNotebook *notebook, gpointer arg1, guint arg2, gpointer user_data) +{ + gboolean left = (GTK_NOTEBOOK(debug_notebook_left) == notebook); + + const gchar *group = is_tabbed ? "two_panels_mode" : "one_panel_mode"; + const gchar *selected_key = is_tabbed ? (left ? "left_selected_tab_index" : "right_selected_tab_index") : "selected_tab_index"; + + g_key_file_set_integer(key_file, group, selected_key, arg2); + + save_config(); + + return TRUE; +} + +/* + * set default values in the GKeyFile + */ +void dpaned_set_defaults(GKeyFile *kf) +{ + g_key_file_set_boolean(key_file, "tabbed_mode", "enabled", FALSE); + + int all_tabs[] = { TID_TARGET, TID_BREAKS, TID_LOCALS, TID_WATCH, TID_STACK, TID_TERMINAL, TID_MESSAGES }; + g_key_file_set_integer_list(key_file, "one_panel_mode", "tabs", all_tabs, sizeof(all_tabs) / sizeof(int)); + g_key_file_set_integer(key_file, "one_panel_mode", "selected_tab_index", 0); + + int left_tabs[] = { TID_TARGET, TID_BREAKS, TID_LOCALS, TID_WATCH }; + g_key_file_set_integer_list(key_file, "two_panels_mode", "left_tabs", left_tabs, sizeof(left_tabs) / sizeof(int)); + g_key_file_set_integer(key_file, "two_panels_mode", "left_selected_tab_index", 0); + int right_tabs[] = { TID_STACK, TID_TERMINAL, TID_MESSAGES }; + g_key_file_set_integer_list(key_file, "two_panels_mode", "right_tabs", right_tabs, sizeof(right_tabs) / sizeof(int)); + g_key_file_set_integer(key_file, "two_panels_mode", "right_selected_tab_index", 0); +} + +/* + * create GUI and check config + */ +void dpaned_init() +{ + /* create paned */ + hpaned = gtk_hpaned_new(); + gtk_container_set_border_width(GTK_CONTAINER(hpaned), HPANED_BORDER_WIDTH); + + /* create notebooks */ + debug_notebook_left = gtk_notebook_new (); + debug_notebook_right = gtk_notebook_new (); + + /* setup notebooks */ + gtk_notebook_set_scrollable(GTK_NOTEBOOK(debug_notebook_left), TRUE); + gtk_notebook_set_scrollable(GTK_NOTEBOOK(debug_notebook_right), TRUE); + gtk_notebook_set_group_id(GTK_NOTEBOOK(debug_notebook_left), NOTEBOOK_GROUP); + gtk_notebook_set_group_id (GTK_NOTEBOOK(debug_notebook_right), NOTEBOOK_GROUP); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(debug_notebook_left), GTK_POS_TOP); + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(debug_notebook_right), GTK_POS_TOP); + + /* add notebooks */ + gtk_paned_add1(GTK_PANED(hpaned), debug_notebook_left); + gtk_paned_add2(GTK_PANED(hpaned), debug_notebook_right); + + /* read config */ + gchar *config_dir = g_build_path(G_DIR_SEPARATOR_S, geany_data->app->configdir, "plugins", "debugger", NULL); + config_path = g_build_path(G_DIR_SEPARATOR_S, config_dir, "debugger.conf", NULL); + + g_mkdir_with_parents(config_dir, S_IRUSR | S_IWUSR | S_IXUSR); + + key_file = g_key_file_new(); + if (!g_key_file_load_from_file(key_file, config_path, G_KEY_FILE_NONE, NULL)) + { + dpaned_set_defaults(key_file); + gchar *data = g_key_file_to_data(key_file, NULL, NULL); + g_file_set_contents(config_path, data, -1, NULL); + g_free(data); + } + + is_tabbed = g_key_file_get_boolean(key_file, "tabbed_mode", "enabled", NULL); + if (is_tabbed) + { + gsize length; + int *tab_ids, i; + + /* left */ + tab_ids = g_key_file_get_integer_list(key_file, "two_panels_mode", "left_tabs", &length, NULL); + for (i = 0; i < length; i++) + { + GtkWidget *tab = tabs_get_tab((tab_id)tab_ids[i]); + gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook_left), + tab, + gtk_label_new(tabs_get_label(tab_ids[i]))); + gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(debug_notebook_left), tab, TRUE); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(debug_notebook_left), tab, TRUE); + } + g_free(tab_ids); + + /* right */ + tab_ids = g_key_file_get_integer_list(key_file, "two_panels_mode", "right_tabs", &length, NULL); + for (i = 0; i < length; i++) + { + GtkWidget *tab = tabs_get_tab((tab_id)tab_ids[i]); + gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook_right), + tab, + gtk_label_new(tabs_get_label(tab_ids[i]))); + gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(debug_notebook_right), tab, TRUE); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(debug_notebook_right), tab, TRUE); + } + g_free(tab_ids); + + gtk_widget_show_all(hpaned); + + gtk_notebook_set_current_page(GTK_NOTEBOOK(debug_notebook_left), + g_key_file_get_integer(key_file, "two_panels_mode", "left_selected_tab_index", NULL)); + gtk_notebook_set_current_page(GTK_NOTEBOOK(debug_notebook_right), + g_key_file_get_integer(key_file, "two_panels_mode", "right_selected_tab_index", NULL)); + } + else + { + g_object_ref(debug_notebook_right); + gtk_container_remove(GTK_CONTAINER(hpaned), debug_notebook_right); + + gsize length; + int *tab_ids = g_key_file_get_integer_list(key_file, "one_panel_mode", "tabs", &length, NULL); + int i; + for (i = 0; i < length; i++) + { + GtkWidget *tab = tabs_get_tab((tab_id)tab_ids[i]); + gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook_left), + tab, + gtk_label_new(tabs_get_label(tab_ids[i]))); + gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(debug_notebook_left), tab, TRUE); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(debug_notebook_left), tab, TRUE); + } + + gtk_widget_show_all(hpaned); + gtk_notebook_set_current_page(GTK_NOTEBOOK(debug_notebook_left), + g_key_file_get_integer(key_file, "one_panel_mode", "selected_tab_index", NULL)); + } + + g_free(config_dir); + + CONNECT_PAGE_SIGNALS(); + CONNECT_ALLOCATED_PAGE_SIGNALS(); +} + +/* + * free local data, disconnect signals + */ +void dpaned_destroy() +{ + g_key_file_free(key_file); + g_free(config_path); + + DISCONNECT_PAGE_SIGNALS(); +} + +/* + * gets widget + */ +GtkWidget* dpaned_get_paned() +{ + return hpaned; +} + +/* + * sets tabs mode + */ +void dpaned_set_tabbed(gboolean tabbed) +{ + is_tabbed = tabbed; + + DISCONNECT_PAGE_SIGNALS(); + + if (!tabbed) + { + g_object_ref(debug_notebook_right); + gtk_container_remove(GTK_CONTAINER(hpaned), debug_notebook_right); + + gsize length; + int *tab_ids = g_key_file_get_integer_list(key_file, "one_panel_mode", "tabs", &length, NULL); + int i; + for (i = 0; i < length; i++) + { + GtkWidget *tab = tabs_get_tab((tab_id)tab_ids[i]); + if (-1 == gtk_notebook_page_num(GTK_NOTEBOOK(debug_notebook_left), tab)) + { + g_object_ref(tab); + gtk_container_remove(GTK_CONTAINER(debug_notebook_right), tab); + gtk_notebook_insert_page(GTK_NOTEBOOK(debug_notebook_left), tab, gtk_label_new(tabs_get_label(tab_ids[i])), i); + g_object_unref(tab); + gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(debug_notebook_left), tab, TRUE); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(debug_notebook_left), tab, TRUE); + } + } + + gtk_notebook_set_current_page(GTK_NOTEBOOK(debug_notebook_left), + g_key_file_get_integer(key_file, "one_panel_mode", "selected_tab_index", NULL)); + + gtk_widget_show_all(hpaned); + } + else + { + gtk_paned_add2(GTK_PANED(hpaned), debug_notebook_right); + g_object_unref(debug_notebook_right); + + gsize length; + int *tab_ids = g_key_file_get_integer_list(key_file, "two_panels_mode", "right_tabs", &length, NULL); + int i; + for (i = 0; i < length; i++) + { + GtkWidget *tab = tabs_get_tab((tab_id)tab_ids[i]); + g_object_ref(tab); + gtk_container_remove(GTK_CONTAINER(debug_notebook_left), tab); + gtk_notebook_insert_page(GTK_NOTEBOOK(debug_notebook_right), tab, gtk_label_new(tabs_get_label(tab_ids[i])), i); + g_object_unref(tab); + gtk_notebook_set_tab_detachable(GTK_NOTEBOOK(debug_notebook_right), tab, TRUE); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(debug_notebook_right), tab, TRUE); + } + + gtk_notebook_set_current_page(GTK_NOTEBOOK(debug_notebook_left), + g_key_file_get_integer(key_file, "two_panels_mode", "left_selected_tab_index", NULL)); + gtk_notebook_set_current_page(GTK_NOTEBOOK(debug_notebook_right), + g_key_file_get_integer(key_file, "two_panels_mode", "right_selected_tab_index", NULL)); + + gtk_widget_show_all(hpaned); + } + + CONNECT_PAGE_SIGNALS(); + + g_key_file_set_boolean(key_file, "tabbed_mode", "enabled", is_tabbed); + + save_config(); +} + +/* + * gets tabbed mode state + */ +gboolean dpaned_get_tabbed() +{ + return is_tabbed; +}
Added: trunk/geany-plugins/debugger/src/dpaned.h =================================================================== --- trunk/geany-plugins/debugger/src/dpaned.h (rev 0) +++ trunk/geany-plugins/debugger/src/dpaned.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -0,0 +1,27 @@ +/* + * + * dpaned.c + * + * Copyright 2010 Alexander Petukhov <devel(at)apetukhov.ru> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +void dpaned_init(); +void dpaned_destroy(); +GtkWidget* dpaned_get_paned(); +void dpaned_set_tabbed(gboolean paned); +gboolean dpaned_get_tabbed();
Modified: trunk/geany-plugins/debugger/src/plugin.c =================================================================== --- trunk/geany-plugins/debugger/src/plugin.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/plugin.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -37,6 +37,8 @@ #include "btnpanel.h" #include "keys.h" #include "dconfig.h" +#include "dpaned.h" +#include "tabs.h"
/* These items are set by Geany before plugin_init() is called. */ GeanyPlugin *geany_plugin; @@ -74,6 +76,12 @@ { NULL, NULL, FALSE, NULL } };
+void on_paned_mode_changed(GtkToggleButton *button, gpointer user_data) +{ + gboolean state = gtk_toggle_button_get_active(button); + dpaned_set_tabbed(state); +} + /* Called by Geany to initialize the plugin. * Note: data is the same as geany_data. */ void plugin_init(GeanyData *data) @@ -84,37 +92,27 @@
/* main box */ hbox = gtk_hbox_new(FALSE, 0); - - GtkWidget *debug_notebook = gtk_notebook_new (); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(debug_notebook), GTK_POS_TOP);
/* add target page */ tpage_init(); - gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook), - tpage_get_widget(), - gtk_label_new(_("Target"))); - gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(debug_notebook), tpage_get_widget(), TRUE); /* init brekpoints */ breaks_init(editor_open_position); - gtk_notebook_append_page(GTK_NOTEBOOK(debug_notebook), - breaks_get_widget(), - gtk_label_new(_("Breakpoints"))); - gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(debug_notebook), breaks_get_widget(), TRUE); - + /* init markers */ markers_init();
/* init debug */ - debug_init(debug_notebook); + debug_init();
- gtk_widget_show_all(debug_notebook); + /* init paned */ + dpaned_init();
- GtkWidget* vbox = btnpanel_create(); + GtkWidget* vbox = btnpanel_create(on_paned_mode_changed);
- gtk_box_pack_start(GTK_BOX(hbox), debug_notebook, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), dpaned_get_paned(), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); - + gtk_widget_show_all(hbox); gtk_notebook_append_page( @@ -164,6 +162,9 @@ /* clears config */ dconfig_destroy();
+ /* clears debug paned data */ + dpaned_destroy(); + /* release other allocated strings and objects */ gtk_widget_destroy(hbox); }
Modified: trunk/geany-plugins/debugger/src/stree.c =================================================================== --- trunk/geany-plugins/debugger/src/stree.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/stree.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -36,14 +36,8 @@
#include "xpm/frame_current.xpm"
-/* columns minumum width in characters */ -#define MW_ADRESS 10 -#define MW_FUNCTION 10 -#define MW_FILE 0 -#define MW_LINE 4 +#define ARROW_PADDING 7
-#define ARROW_PADDING 10 - /* Tree view columns */ enum { @@ -52,6 +46,7 @@ S_FUNCTION, S_FILEPATH, S_LINE, + S_LAST_VISIBLE, S_N_COLUMNS };
@@ -66,6 +61,8 @@ static GtkTreeModel* model = NULL; static GtkListStore* store = NULL;
+static GtkCellRenderer *renderer_arrow, *renderer_address, *renderer_funtion, *renderer_file, *renderer_line, *renderer_last; + /* flag to indicate whether to handle selection change */ static gboolean handle_selection = TRUE;
@@ -160,7 +157,7 @@ * arguments: * cb - callback to call on double click */ -gboolean stree_init(move_to_line_cb cb) +GtkWidget* stree_init(move_to_line_cb cb) { callback = cb; @@ -173,7 +170,9 @@ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INT); + G_TYPE_INT, + G_TYPE_STRING); + model = GTK_TREE_MODEL(store); tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store)); @@ -190,51 +189,43 @@ G_CALLBACK(on_msgwin_button_press), NULL);
/* creating columns */ - GtkCellRenderer *renderer; GtkTreeViewColumn *column; - const gchar *header; - - int char_width = get_char_width(tree);
/* arrow */ - renderer = gtk_cell_renderer_pixbuf_new (); - column = create_column("", renderer, FALSE, - gdk_pixbuf_get_width(arrow_pixbuf) + 2 * ARROW_PADDING, - "pixbuf", S_ARROW); + renderer_arrow = gtk_cell_renderer_pixbuf_new (); + column = gtk_tree_view_column_new_with_attributes ("", renderer_arrow, "pixbuf", S_ARROW, NULL); + gtk_tree_view_column_set_min_width(column, gdk_pixbuf_get_width(arrow_pixbuf) + 2 * ARROW_PADDING); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
- /* adress */ - header = _("Address"); - renderer = gtk_cell_renderer_text_new (); - column = create_column(header, renderer, FALSE, - get_header_string_width(header, MW_ADRESS, char_width), - "text", S_ADRESS); + /* address */ + renderer_address = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Address"), renderer_address, "text", S_ADRESS, NULL); + gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* function */ - header = _("Function"); - renderer = gtk_cell_renderer_text_new (); - column = create_column(header, renderer, FALSE, - get_header_string_width(header, MW_FUNCTION, char_width), - "text", S_FUNCTION); + renderer_funtion = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Function"), renderer_funtion, "text", S_FUNCTION, NULL); + gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); /* file */ - header = _("File"); - renderer = gtk_cell_renderer_text_new (); - column = create_column(header, renderer, TRUE, - get_header_string_width(header, MW_FILE, char_width), - "text", S_FILEPATH); + renderer_file = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("File"), renderer_file, "text", S_FILEPATH, NULL); + gtk_tree_view_column_set_resizable (column, TRUE); 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), - "text", S_LINE); + renderer_line = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Line"), renderer_line, "text", S_LINE, NULL); + gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+ /* Last invisible column */ + renderer_last = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("", renderer_last, "text", S_LAST_VISIBLE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); + /* create frames hash table */ frames = g_hash_table_new_full( g_str_hash, @@ -242,14 +233,6 @@ (GDestroyNotify)g_free, NULL); - return TRUE; -} - -/* - * get stack trace tree view - */ -GtkWidget* stree_get_widget() -{ return tree; }
Modified: trunk/geany-plugins/debugger/src/stree.h =================================================================== --- trunk/geany-plugins/debugger/src/stree.h 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/stree.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -19,10 +19,9 @@ * MA 02110-1301, USA. */
-gboolean stree_init(move_to_line_cb cb); -void stree_destroy(); -GtkWidget* stree_get_widget(); -void stree_add(frame *f, gboolean first); -void stree_clear(); -void stree_select_first(); +GtkWidget* stree_init(move_to_line_cb cb); +void stree_destroy(); +void stree_add(frame *f, gboolean first); +void stree_clear(); +void stree_select_first();
Added: trunk/geany-plugins/debugger/src/tabs.c =================================================================== --- trunk/geany-plugins/debugger/src/tabs.c (rev 0) +++ trunk/geany-plugins/debugger/src/tabs.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -0,0 +1,150 @@ +/* + * + * tabs.c + * + * Copyright 2010 Alexander Petukhov <devel(at)apetukhov.ru> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +/* + * tabs widgets + */ + +#include "geanyplugin.h" +extern GeanyFunctions *geany_functions; +extern GeanyData *geany_data; + +#include "tabs.h" + +/* tab widgets */ +GtkWidget *tab_target = NULL; +GtkWidget *tab_breaks = NULL; +GtkWidget *tab_watch = NULL; +GtkWidget *tab_locals = NULL; +GtkWidget *tab_call_stack = NULL; +GtkWidget *tab_terminal = NULL; +GtkWidget *tab_messages = NULL; + +/* + * searches ID for a given widget + * arguments: + * tab - widget to search an id for + */ +tab_id tabs_get_tab_id(GtkWidget* tab) +{ + tab_id id; + if (tab_target == tab) + { + id = TID_TARGET; + } + else if (tab_breaks == tab) + { + id = TID_BREAKS; + } + else if (tab_watch == tab) + { + id = TID_WATCH; + } + else if (tab_locals == tab) + { + id = TID_LOCALS; + } + else if (tab_call_stack == tab) + { + id = TID_STACK; + } + else if (tab_terminal == tab) + { + id = TID_TERMINAL; + } + else if (tab_messages == tab) + { + id = TID_MESSAGES; + } + + return id; +} + +/* + * searches a widget for a given ID + * arguments: + * id - ID to search a widget for + */ +GtkWidget* tabs_get_tab(tab_id id) +{ + GtkWidget *tab = NULL; + switch(id) + { + case TID_TARGET: + tab = tab_target; + break; + case TID_BREAKS: + tab = tab_breaks; + break; + case TID_WATCH: + tab = tab_watch; + break; + case TID_LOCALS: + tab = tab_locals; + break; + case TID_STACK: + tab = tab_call_stack; + break; + case TID_TERMINAL: + tab = tab_terminal; + break; + case TID_MESSAGES: + tab = tab_messages; + break; + } + return tab; +} + +/* + * searches a label for a given ID + * arguments: + * id - ID to search a label for + */ +const gchar* tabs_get_label(tab_id id) +{ + const gchar *label = NULL; + switch(id) + { + case TID_TARGET: + label = _("Target"); + break; + case TID_BREAKS: + label = _("Breakpoints"); + break; + case TID_WATCH: + label = _("Watch"); + break; + case TID_LOCALS: + label = _("Locals"); + break; + case TID_STACK: + label = _("Call Stack"); + break; + case TID_TERMINAL: + label = _("Debug terminal"); + break; + case TID_MESSAGES: + label = _("Debugger messages"); + break; + } + return label; +}
Added: trunk/geany-plugins/debugger/src/tabs.h =================================================================== --- trunk/geany-plugins/debugger/src/tabs.h (rev 0) +++ trunk/geany-plugins/debugger/src/tabs.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -0,0 +1,45 @@ +/* + * + * tabs.c + * + * Copyright 2010 Alexander Petukhov <devel(at)apetukhov.ru> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +typedef enum _tab_id +{ + TID_TARGET, + TID_BREAKS, + TID_WATCH, + TID_LOCALS, + TID_STACK, + TID_TERMINAL, + TID_MESSAGES +} tab_id; + +extern GtkWidget *tab_target; +extern GtkWidget *tab_breaks; +extern GtkWidget *tab_watch; +extern GtkWidget *tab_locals; +extern GtkWidget *tab_call_stack; +extern GtkWidget *tab_terminal; +extern GtkWidget *tab_messages; + +GtkWidget* tabs_get_tab(tab_id id); +tab_id tabs_get_tab_id(GtkWidget* tab); +const gchar* tabs_get_label(tab_id id); +
Modified: trunk/geany-plugins/debugger/src/tpage.c =================================================================== --- trunk/geany-plugins/debugger/src/tpage.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/tpage.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -41,6 +41,7 @@ #include "debug.h" #include "dconfig.h" #include "tpage.h" +#include "tabs.h"
/* boxes margins */ #define SPACING 5 @@ -54,6 +55,7 @@ { NAME, VALUE, + LAST_VISIBLE, N_COLUMNS };
@@ -66,9 +68,6 @@ /* reference to the env tree view empty row */ static GtkTreeRowReference *empty_row = NULL;
-/* page widget */ -static GtkWidget *page = NULL; - /* target name textentry */ static GtkWidget *targetname = NULL;
@@ -585,7 +584,7 @@ */ void tpage_init() { - page = gtk_hbox_new(FALSE, 0); + tab_target = gtk_hbox_new(FALSE, 0); GtkWidget *lbox = gtk_vbox_new(FALSE, SPACING); GtkWidget *mbox = gtk_vbox_new(FALSE, SPACING); @@ -667,36 +666,34 @@ store = gtk_list_store_new ( N_COLUMNS, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_STRING); + model = GTK_TREE_MODEL(store); envtree = gtk_tree_view_new_with_model (model); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(envtree), TRUE); g_object_set(envtree, "rules-hint", TRUE, NULL); g_signal_connect(G_OBJECT(envtree), "key-press-event", G_CALLBACK (on_envtree_keypressed), NULL);
- const gchar *header; - int char_width = get_char_width(envtree); - - header = _("Name"); renderer_name = gtk_cell_renderer_text_new (); g_object_set (renderer_name, "editable", TRUE, NULL); g_signal_connect (G_OBJECT (renderer_name), "edited", G_CALLBACK (on_name_changed), NULL); - column_name = create_column(header, renderer_name, FALSE, - get_header_string_width(header, MW_NAME, char_width), - "text", NAME); + column_name = gtk_tree_view_column_new_with_attributes (_("Name"), renderer_name, "text", NAME, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (envtree), column_name);
- header = _("Value"); renderer_value = gtk_cell_renderer_text_new (); - column_value = create_column(header, renderer_value, TRUE, - get_header_string_width(header, MW_VALUE, char_width), - "text", VALUE); + column_name = gtk_tree_view_column_new_with_attributes (_("Value"), renderer_name, "text", VALUE, NULL); g_signal_connect (G_OBJECT (renderer_value), "edited", G_CALLBACK (on_value_changed), NULL); g_signal_connect (G_OBJECT (renderer_value), "editing-started", G_CALLBACK (on_value_editing_started), NULL); g_signal_connect (G_OBJECT (renderer_value), "editing-canceled", G_CALLBACK (on_value_editing_cancelled), NULL); gtk_tree_view_column_set_cell_data_func(column_value, renderer_value, on_render_value, NULL, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (envtree), column_value);
+ /* Last invisible column */ + GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); + GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", LAST_VISIBLE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (envtree), column); + /* add empty row */ add_empty_row();
@@ -711,18 +708,10 @@
gtk_box_pack_start(GTK_BOX(hombox), lbox, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hombox), mbox, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(page), hombox, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(tab_target), hombox, TRUE, TRUE, 0); }
/* - * get page widget - */ -GtkWidget* tpage_get_widget() -{ - return page; -} - -/* * set the page readonly */ void tpage_set_readonly(gboolean readonly)
Modified: trunk/geany-plugins/debugger/src/tpage.h =================================================================== --- trunk/geany-plugins/debugger/src/tpage.h 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/tpage.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -20,7 +20,6 @@ */
void tpage_init(); -GtkWidget* tpage_get_widget();
gchar* tpage_get_target(); void tpage_set_target(const gchar *newvalue);
Modified: trunk/geany-plugins/debugger/src/utils.c =================================================================== --- trunk/geany-plugins/debugger/src/utils.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/utils.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -35,53 +35,7 @@ #include "geanyplugin.h" extern GeanyFunctions *geany_functions;
-/* character to calculate width */ -#define CHAR_TESTED "W" - /* - * get character width in a widget - */ -int get_char_width(GtkWidget *widget) -{ - PangoLayout *playout = pango_layout_new(gtk_widget_get_pango_context(widget)); - - int width, height; - - pango_layout_set_text(playout, CHAR_TESTED, -1); - pango_layout_get_pixel_size (playout, &width, &height); - - g_object_unref(playout); - - return width; -} - -/* - * get string width if string length is bigger than minwidth or minwidth * char_width - */ -int get_header_string_width(const gchar *header, int minchars, int char_width) -{ - int header_length = strlen(header); - int width = (header_length > minchars ? header_length : minchars) * char_width; - return width; -} - -/* - * create tree view column - */ -GtkTreeViewColumn *create_column(const gchar *name, GtkCellRenderer *renderer, gboolean expandable, gint minwidth, const char *arg, int value) -{ - GtkTreeViewColumn *column = - gtk_tree_view_column_new_with_attributes (name, renderer, arg, value, NULL); - - if (expandable) - gtk_tree_view_column_set_expand(column, expandable); - else if (minwidth) - gtk_tree_view_column_set_min_width(column, minwidth); - - return column; -} - -/* * opens position in a editor */ void editor_open_position(char* file, int line)
Modified: trunk/geany-plugins/debugger/src/utils.h =================================================================== --- trunk/geany-plugins/debugger/src/utils.h 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/utils.h 2011-09-10 18:27:49 UTC (rev 2194) @@ -20,7 +20,4 @@ */
void editor_open_position(char* file, int line); -int get_char_width(GtkWidget *widget); -int get_header_string_width(const gchar *header, int minchars, int char_width); -GtkTreeViewColumn* create_column(const gchar *name, GtkCellRenderer *renderer, gboolean expandable, gint minwidth, const char *arg, int value); GString* get_word_at_position(ScintillaObject *sci, int position);
Modified: trunk/geany-plugins/debugger/src/vtree.c =================================================================== --- trunk/geany-plugins/debugger/src/vtree.c 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/debugger/src/vtree.c 2011-09-10 18:27:49 UTC (rev 2194) @@ -116,17 +116,10 @@ /* create columns */ GtkCellRenderer *renderer; GtkTreeViewColumn *column; - const gchar *header; - int min_column_with = MIN_COLUMN_CHARS * get_char_width(tree); - /* Name */ - header = _("Name"); renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - column = create_column(header, renderer, FALSE, - min_column_with, - "text", W_NAME); + column = gtk_tree_view_column_new_with_attributes (_("Name"), renderer, "text", W_NAME, NULL); gtk_tree_view_column_set_resizable (column, TRUE); if (on_render_name) gtk_tree_view_column_set_cell_data_func(column, renderer, on_render_name, NULL, NULL); @@ -138,33 +131,22 @@ gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Value */ - header = _("Value"); renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - column = create_column(header, renderer, TRUE, - min_column_with, - "text", W_VALUE); + column = gtk_tree_view_column_new_with_attributes (_("Value"), renderer, "text", W_VALUE, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, render_value, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Type */ - header = _("Type"); renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); - column = create_column(header, renderer, FALSE, - min_column_with, - "text", W_TYPE); + column = gtk_tree_view_column_new_with_attributes (_("Type"), renderer, "text", W_TYPE, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Last invisible column */ - header = _(""); renderer = gtk_cell_renderer_text_new (); - column = create_column(header, renderer, FALSE, - 0, - "text", W_LAST_VISIBLE); + column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", W_LAST_VISIBLE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
/* Internal (unvisible column) */
Modified: trunk/geany-plugins/po/POTFILES.in =================================================================== --- trunk/geany-plugins/po/POTFILES.in 2011-09-04 11:16:10 UTC (rev 2193) +++ trunk/geany-plugins/po/POTFILES.in 2011-09-10 18:27:49 UTC (rev 2194) @@ -30,6 +30,7 @@ debugger/src/ltree.c debugger/src/utils.c debugger/src/stree.c +debugger/src/tabs.c debugger/src/keys.c debugger/src/markers.c debugger/src/watch_model.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org