Branch: refs/heads/master Author: Alexander Petukhov devel@apetukhov.ru Committer: Alexander Petukhov devel@apetukhov.ru Date: Wed, 08 Feb 2012 21:11:26 Commit: c6339e52cd681af322dfd1c71910d738cb566197 https://github.com/geany/geany-plugins/commit/c6339e52cd681af322dfd1c71910d7...
Log Message: ----------- switch break in the break window through clicking a break icon (enabled column removed)
Modified Paths: -------------- debugger/ChangeLog debugger/TODO debugger/src/Makefile.am debugger/src/bptree.c debugger/src/cell_renderers/cellrendererbreakicon.c debugger/src/cell_renderers/cellrendererbreakicon.h debugger/src/cell_renderers/cellrenderertoggle.c debugger/src/cell_renderers/cellrenderertoggle.h
Modified: debugger/ChangeLog 7 files changed, 5 insertions(+), 2 deletions(-) =================================================================== @@ -1,8 +1,11 @@ -15-10-2011 Alexander Petukhov devel@apetukhov.ru +09-02-2012 Alexander Petukhov devel@apetukhov.ru
- * first release + * switch break in the break window through clicking a break icon, all breaks for a file - by a file checkbox(moved to the left)
08-02-2012 Alexander Petukhov devel@apetukhov.ru
* fixed a bug: double clicking on a row in watches and autos sometimes caused crash because of wrong args list governor
+15-10-2011 Alexander Petukhov devel@apetukhov.ru + + * first release
Modified: debugger/TODO 1 files changed, 0 insertions(+), 1 deletions(-) =================================================================== @@ -11,7 +11,6 @@ FEATURES: - 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) -- switch break in the break window through clicking a break icon (add icon for a file) - margin context menu - step back - tree views column width/autowidth
Modified: debugger/src/Makefile.am 7 files changed, 6 insertions(+), 1 deletions(-) =================================================================== @@ -59,7 +59,12 @@ debugger_la_SOURCES = \ watch_model.c \ watch_model.h \ wtree.c \ - wtree.h + wtree.h \ + cell_renderers/cellrendererbreakicon.c \ + cell_renderers/cellrendererbreakicon.h \ + cell_renderers/cellrenderertoggle.c \ + cell_renderers/cellrenderertoggle.h +
debugger_la_LIBADD = $(COMMONLIBS) $(VTE_LIBS) -lutil debugger_la_CFLAGS = $(AM_CFLAGS) $(VTE_CFLAGS) -DDBGPLUG_DATA_DIR="$(plugindatadir)" -DPLUGIN_NAME="$(plugin)"
Modified: debugger/src/bptree.c 145 files changed, 78 insertions(+), 67 deletions(-) =================================================================== @@ -45,10 +45,12 @@ #include "tabs.h" #include "pixbuf.h"
+#include "cell_renderers/cellrendererbreakicon.h" +#include "cell_renderers/cellrenderertoggle.h" + /* Tree view columns */ enum { - ICON, FILEPATH, CONDITION, HITSCOUNT, @@ -64,7 +66,6 @@ enum static GtkTreeStore *store = NULL;
/* column cell renderes */ -static GtkCellRenderer *enable_renderer; static GtkCellRenderer *hcount_renderer; static GtkCellRenderer *condition_renderer;
@@ -149,34 +150,42 @@ static void update_file_node(GtkTreeIter *file_iter) }
/* - * GtkTreeView cell renderer functions that do not render and make ineditable file rows + * hides file checkbox for breaks rows + */ +void on_render_enable_for_file(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, + GtkTreeIter *iter, gpointer data) +{ + GtkTreePath *path = gtk_tree_model_get_path(model, iter); + g_object_set(cell, "visible", 1 == gtk_tree_path_get_depth(path), NULL); + gtk_tree_path_free(path); +} + +/* + * hides break pixbuf for file rows + */ +void on_render_enable_break(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, + GtkTreeIter *iter, gpointer data) +{ + GtkTreePath *path = gtk_tree_model_get_path(model, iter); + g_object_set(cell, "visible", 1 != gtk_tree_path_get_depth(path), NULL); + gtk_tree_path_free(path); +} + +/* + * makes condition and hitscount uneditable and empty for 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) { - 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); - } + g_object_set(cell, "text", "", NULL); + g_object_set(cell, "editable", FALSE, 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); - } + g_object_set(cell, "editable", TRUE, NULL); } gtk_tree_path_free(path); } @@ -309,9 +318,9 @@ void on_hitscount_changed(GtkCellRendererText *renderer, gchar *path, gchar *new }
/* - * "Enabled" checkbox has been clicked + * enable / disable all breaks for a file when it's checkbox icon has been clicked */ -void on_activeness_changed(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data) +void on_enable_for_file(GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data) { /* do not process event is page is readonly (debug is running) */ if (readonly) @@ -341,7 +350,29 @@ void on_activeness_changed(GtkCellRendererToggle *cell_renderer, gchar *path, gp
g_free(file); } - else + + gtk_tree_path_free(tree_path); +} + +/* + * enable / disable particulary break when it's icon has been clicked + */ +void on_enable_break(CellRendererBreakIcon *cell_renderer, gchar *path, gpointer user_data) +{ + /* do not process event is page is readonly (debug is running) */ + if (readonly) + return; + + GtkTreeIter iter; + GtkTreePath *tree_path = gtk_tree_path_new_from_string (path); + + gtk_tree_model_get_iter ( + model, + &iter, + tree_path); + + /* check if this is not a file row */ + if(1 != gtk_tree_path_get_depth(tree_path)) { GtkTreeIter parent_iter; gtk_tree_model_iter_parent(model, &parent_iter, &iter); @@ -494,30 +525,6 @@ static gboolean on_key_pressed(GtkWidget *widget, GdkEvent *event, gpointer user }
/* - * 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 */
@@ -542,7 +549,6 @@ gboolean bptree_init(move_to_line_cb cb) /* create tree view */ store = gtk_tree_store_new ( N_COLUMNS, - GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, @@ -569,13 +575,29 @@ 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); - 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_attributes(column, renderer, "text", FILEPATH, NULL); + + /* enable for file */ + GtkCellRenderer *file_enable_renderer = cell_renderer_toggle_new (); + g_signal_connect (G_OBJECT(file_enable_renderer), "toggled", G_CALLBACK(on_enable_for_file), NULL); + gtk_tree_view_column_pack_end(column, file_enable_renderer, FALSE); + gtk_tree_view_column_set_attributes(column, file_enable_renderer, "active", ENABLED, NULL); + gtk_tree_view_column_set_cell_data_func(column, file_enable_renderer, on_render_enable_for_file, NULL, NULL); + + /* enable breakpoint */ + GtkCellRenderer *break_enable_renderer = cell_renderer_break_icon_new (); + g_signal_connect (G_OBJECT(break_enable_renderer), "clicked", G_CALLBACK(on_enable_break), NULL); + + g_object_set(break_enable_renderer, "pixbuf_enabled", (gpointer)break_pixbuf, NULL); + g_object_set(break_enable_renderer, "pixbuf_disabled", (gpointer)break_disabled_pixbuf, NULL); + g_object_set(break_enable_renderer, "pixbuf_conditional", (gpointer)break_condition_pixbuf, NULL); + g_object_set(break_enable_renderer, "pixbuf_file", (gpointer)break_pixbuf, NULL); + + gtk_tree_view_column_pack_end(column, break_enable_renderer, FALSE); + gtk_tree_view_column_set_attributes(column, break_enable_renderer, "enabled", ENABLED, "condition", CONDITION, "hitscount", HITSCOUNT, NULL); + gtk_tree_view_column_set_cell_data_func(column, break_enable_renderer, on_render_enable_break, NULL, 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_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
@@ -585,7 +607,7 @@ gboolean bptree_init(move_to_line_cb cb) 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 = 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_cell_data_func(column, condition_renderer, on_render, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); @@ -606,12 +628,6 @@ gboolean bptree_init(move_to_line_cb cb) gtk_tree_view_column_set_visible(column, FALSE); gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
- /* enabled */ - enable_renderer = gtk_cell_renderer_toggle_new (); - g_signal_connect (G_OBJECT(enable_renderer), "toggled", G_CALLBACK(on_activeness_changed), NULL); - column = gtk_tree_view_column_new_with_attributes (_("Enabled"), enable_renderer, "active", ENABLED, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column); - /* Last invisible column */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ("", renderer, "text", LAST_VISIBLE, NULL); @@ -644,7 +660,6 @@ void bptree_destroy() void bptree_set_enabled(breakpoint *bp) { gtk_tree_store_set(store, &(bp->iter), ENABLED, bp->enabled, -1); - bptree_update_break_icon(bp);
GtkTreeIter parent; gtk_tree_model_iter_parent(model, &parent, &(bp->iter)); @@ -659,7 +674,6 @@ void bptree_set_enabled(breakpoint *bp) void bptree_set_hitscount(breakpoint *bp) { gtk_tree_store_set(store, &(bp->iter), HITSCOUNT, bp->hitscount, -1); - bptree_update_break_icon(bp); }
/* @@ -670,7 +684,6 @@ void bptree_set_hitscount(breakpoint *bp) void bptree_set_condition(breakpoint* bp) { gtk_tree_store_set(store, &(bp->iter), CONDITION, bp->condition, -1); - bptree_update_break_icon(bp); }
/* @@ -776,8 +789,6 @@ void bptree_update_breakpoint(breakpoint* bp) LINE, bp->line, -1); - bptree_update_break_icon(bp); - g_free(location); }
Modified: debugger/src/cell_renderers/cellrendererbreakicon.c 443 files changed, 443 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,443 @@ +/* + * cellrendererbreakicon.c + * + * Copyright 2012 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. + */ + +/* + * cell renderer class that renders breakpoint icon, that in turn depends on a hitscount,condition and whether + * a breakpoint is enabled or disabled + */ + +#include <string.h> +#include <geanyplugin.h> + +#include "cellrendererbreakicon.h" + +enum { + PROP_0, + PROP_PIXBUF_ENABLED, + PROP_PIXBUF_DISABLED, + PROP_PIXBUF_CONDITIONAL, + PROP_PIXBUF_FILE, + PROP_ENABLED, + PROP_CONDITION, + PROP_HITSCOUNT +}; + +static gpointer parent_class; +static guint clicked_signal; + +/* + * property getter + */ +static void cell_renderer_break_icon_get_property(GObject *object, guint param_id, GValue *value, GParamSpec *pspec) +{ + CellRendererBreakIcon *cellbreakpoint = CELL_RENDERER_BREAK_ICON(object); + switch (param_id) + { + case PROP_PIXBUF_ENABLED: + g_value_set_object (value, cellbreakpoint->pixbuf_enabled); + break; + case PROP_PIXBUF_DISABLED: + g_value_set_object (value, cellbreakpoint->pixbuf_disabled); + break; + case PROP_PIXBUF_CONDITIONAL: + g_value_set_object (value, cellbreakpoint->pixbuf_conditional); + break; + case PROP_PIXBUF_FILE: + g_value_set_object (value, cellbreakpoint->pixbuf_file); + break; + case PROP_ENABLED: + g_value_set_boolean(value, cellbreakpoint->enabled); + break; + case PROP_CONDITION: + g_value_set_string(value, cellbreakpoint->condition); + break; + case PROP_HITSCOUNT: + g_value_set_int(value, cellbreakpoint->hitscount); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); + break; + } +} + +/* + * property setter + */ +static void cell_renderer_break_icon_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) +{ + CellRendererBreakIcon *cellbreakpoint = CELL_RENDERER_BREAK_ICON(object); + switch (param_id) + { + case PROP_PIXBUF_ENABLED: + if (cellbreakpoint->pixbuf_enabled) + { + g_object_unref(cellbreakpoint->pixbuf_enabled); + } + cellbreakpoint->pixbuf_enabled = (GdkPixbuf*)g_value_dup_object(value); + break; + case PROP_PIXBUF_DISABLED: + if (cellbreakpoint->pixbuf_disabled) + { + g_object_unref(cellbreakpoint->pixbuf_disabled); + } + cellbreakpoint->pixbuf_disabled = (GdkPixbuf*)g_value_dup_object(value); + break; + case PROP_PIXBUF_CONDITIONAL: + if (cellbreakpoint->pixbuf_conditional) + { + g_object_unref(cellbreakpoint->pixbuf_conditional); + } + cellbreakpoint->pixbuf_conditional = (GdkPixbuf*)g_value_dup_object(value); + break; + case PROP_PIXBUF_FILE: + if (cellbreakpoint->pixbuf_file) + { + g_object_unref(cellbreakpoint->pixbuf_file); + } + cellbreakpoint->pixbuf_file = (GdkPixbuf*)g_value_dup_object(value); + break; + case PROP_ENABLED: + cellbreakpoint->enabled = g_value_get_boolean(value); + break; + case PROP_CONDITION: + cellbreakpoint->condition = g_value_get_string(value); + if (cellbreakpoint->condition) + { + cellbreakpoint->condition = g_strdup(cellbreakpoint->condition); + } + break; + case PROP_HITSCOUNT: + cellbreakpoint->hitscount = g_value_get_int(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); + break; + } +} + +/* + * get size of a cell + */ +static void cell_renderer_break_icon_get_size(GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, + gint *x_offset, gint *y_offset, gint *width, gint *height) +{ + CellRendererBreakIcon *cellbreakpoint = (CellRendererBreakIcon *) cell; + gint pixbuf_width = 0; + gint pixbuf_height = 0; + gint calc_width; + gint calc_height; + + if (cellbreakpoint->pixbuf_enabled) + { + pixbuf_width = gdk_pixbuf_get_width (cellbreakpoint->pixbuf_enabled); + pixbuf_height = gdk_pixbuf_get_height (cellbreakpoint->pixbuf_enabled); + } + if (cellbreakpoint->pixbuf_disabled) + { + pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellbreakpoint->pixbuf_disabled)); + pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellbreakpoint->pixbuf_disabled)); + } + if (cellbreakpoint->pixbuf_conditional) + { + pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellbreakpoint->pixbuf_conditional)); + pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellbreakpoint->pixbuf_conditional)); + } + if (cellbreakpoint->pixbuf_file) + { + pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellbreakpoint->pixbuf_file)); + pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellbreakpoint->pixbuf_file)); + } + + calc_width = (gint) cell->xpad * 2 + pixbuf_width; + calc_height = (gint) cell->ypad * 2 + pixbuf_height; + + if (cell_area && pixbuf_width > 0 && pixbuf_height > 0) + { + if (x_offset) + { + *x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? + (1.0 - cell->xalign) : cell->xalign) * + (cell_area->width - calc_width)); + *x_offset = MAX (*x_offset, 0); + } + if (y_offset) + { + *y_offset = (cell->yalign * (cell_area->height - calc_height)); + *y_offset = MAX (*y_offset, 0); + } + } + else + { + if (x_offset) *x_offset = 0; + if (y_offset) *y_offset = 0; + } + + if (width) + *width = calc_width; + + if (height) + *height = calc_height; +} + +/* + * render a cell + */ +static void cell_renderer_break_icon_render(GtkCellRenderer *cell, GdkDrawable *window, GtkWidget *widget, + GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) +{ + CellRendererBreakIcon *cellbreakpoint = (CellRendererBreakIcon*) cell; + + GdkPixbuf *pixbuf; + + GdkRectangle pix_rect; + GdkRectangle draw_rect; + cairo_t *cr; + + cell_renderer_break_icon_get_size (cell, widget, cell_area, + &pix_rect.x, + &pix_rect.y, + &pix_rect.width, + &pix_rect.height); + + pix_rect.x += cell_area->x + cell->xpad; + pix_rect.y += cell_area->y + cell->ypad; + pix_rect.width -= cell->xpad * 2; + pix_rect.height -= cell->ypad * 2; + + if (!gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect) || + !gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect)) + return; + + if (cell->is_expander) + { + pixbuf = cellbreakpoint->pixbuf_file; + } + else if (!cellbreakpoint->enabled) + { + pixbuf = cellbreakpoint->pixbuf_disabled; + } + else if ((cellbreakpoint->condition && strlen(cellbreakpoint->condition)) || cellbreakpoint->hitscount) + { + pixbuf = cellbreakpoint->pixbuf_conditional; + } + else + { + pixbuf = cellbreakpoint->pixbuf_enabled; + } + + if (!pixbuf) + return; + + cr = gdk_cairo_create (window); + + gdk_cairo_set_source_pixbuf (cr, pixbuf, pix_rect.x, pix_rect.y); + gdk_cairo_rectangle (cr, &draw_rect); + cairo_fill (cr); + + cairo_destroy (cr); +} + +/* + * activate callback + */ +static gint cell_renderer_break_icon_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, + GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) +{ + if (event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width)) + { + g_signal_emit (cell, clicked_signal, 0, path); + } + return TRUE; +} + +/* + * init instance + */ +static void cell_renderer_break_icon_init (CellRendererBreakIcon *cell) +{ + cell->enabled = TRUE; + cell->condition = NULL; + cell->hitscount = 0; + + GtkCellRenderer *cell_renderer = (GtkCellRenderer*)cell; + + cell_renderer->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; + + cell->pixbuf_enabled = cell->pixbuf_disabled = cell->pixbuf_conditional = cell->pixbuf_file = 0; +} + +/* + * finalizes an instance (frees pixbuffers) + */ +static void cell_renderer_break_icon_finalize (GObject *object) +{ + CellRendererBreakIcon *cell = (CellRendererBreakIcon*)object; + + GdkPixbuf *pixbufs[] = { cell->pixbuf_enabled, cell->pixbuf_disabled, cell->pixbuf_conditional, cell->pixbuf_file }; + int i; + for(i = 0; i < 4; i++) + { + if (pixbufs[i]) + { + g_object_unref(pixbufs[i]); + } + } + if (cell->condition) + { + g_free((void*)cell->condition); + } + + (*G_OBJECT_CLASS (parent_class)->finalize) (object); +} + +/* + * init class + */ +static void cell_renderer_break_icon_class_init (CellRendererBreakIconClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS(class); + GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class); + + parent_class = g_type_class_peek_parent(class); + + object_class->get_property = cell_renderer_break_icon_get_property; + object_class->set_property = cell_renderer_break_icon_set_property; + + object_class->finalize = cell_renderer_break_icon_finalize; + + cell_class->get_size = cell_renderer_break_icon_get_size; + cell_class->render = cell_renderer_break_icon_render; + + cell_class->activate = cell_renderer_break_icon_activate; + + g_object_class_install_property (object_class, + PROP_PIXBUF_ENABLED, + g_param_spec_object ( + "pixbuf_enabled", + "Pixbuf Object", + "Enabled break image", + GDK_TYPE_PIXBUF, + G_PARAM_READWRITE) + ); + + g_object_class_install_property (object_class, + PROP_PIXBUF_DISABLED, + g_param_spec_object ( + "pixbuf_disabled", + "Pixbuf Object", + "Disabled break image", + GDK_TYPE_PIXBUF, + G_PARAM_READWRITE) + ); + + g_object_class_install_property (object_class, + PROP_PIXBUF_CONDITIONAL, + g_param_spec_object ( + "pixbuf_conditional", + "Pixbuf Object", + "Conditional break image", + GDK_TYPE_PIXBUF, + G_PARAM_READWRITE) + ); + + g_object_class_install_property (object_class, + PROP_PIXBUF_FILE, + g_param_spec_object ( + "pixbuf_file", + "Pixbuf Object", + "File image", + GDK_TYPE_PIXBUF, + G_PARAM_READWRITE) + ); + + g_object_class_install_property (object_class, + PROP_ENABLED, + g_param_spec_boolean ("enabled", "Activeness", "The active state of the breakpoint", FALSE, G_PARAM_READWRITE) + ); + + g_object_class_install_property (object_class, + PROP_CONDITION, + g_param_spec_string ("condition", "Breakpoint condition", "Whether a brealpoint has a condition", FALSE, G_PARAM_READWRITE) + ); + + g_object_class_install_property (object_class, + PROP_HITSCOUNT, + g_param_spec_int ( + "hitscount", + "Breakpoint hitscount", + "Number of passes to wait until stop at a breakpoint", + G_MININT, + G_MAXINT, + 0, + G_PARAM_READWRITE + ) + ); + + clicked_signal = g_signal_new ("clicked", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CellRendererBreakIconClass, clicked), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); +} + +/* + * registers a type + */ +GType cell_renderer_break_icon_get_type(void) +{ + static GType cell_break_icon_type = 0; + + if(0 == cell_break_icon_type) + { + static const GTypeInfo cell_break_icon_info = + { + sizeof (CellRendererBreakIconClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) cell_renderer_break_icon_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CellRendererBreakIcon), + 0, /* n_preallocs */ + (GInstanceInitFunc) cell_renderer_break_icon_init, + }; + + /* Derive from GtkCellRenderer */ + cell_break_icon_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, + "CellRendererBreakIcon", + &cell_break_icon_info, + 0); + } + + return cell_break_icon_type; +} + +/* + * creates new renderer + */ +GtkCellRenderer* cell_renderer_break_icon_new() +{ + return g_object_new(TYPE_CELL_RENDERER_BREAK_ICON, NULL); +}
Modified: debugger/src/cell_renderers/cellrendererbreakicon.h 65 files changed, 65 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,65 @@ +/* + * cellrendererbreakicon.h + * + * Copyright 2012 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. + */ + +#ifndef __CELL_RENDERER_BREAK_ICON_H__ +#define __CELL_RENDERER_BREAK_ICON_H__ + +#include <gtk/gtkcellrenderer.h> + +G_BEGIN_DECLS + +#define TYPE_CELL_RENDERER_BREAK_ICON (cell_renderer_break_icon_get_type ()) +#define CELL_RENDERER_BREAK_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CELL_RENDERER_BREAK_ICON, CellRendererBreakIcon)) +#define CELL_RENDERER_BREAK_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CELL_RENDERER_BREAK_ICON, CellRendererBreakIconClass)) +#define IS_CELL_RENDERER_BREAK_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CELL_RENDERER_BREAK_ICON)) +#define IS_CELL_RENDERER_BREAK_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CELL_RENDERER_BREAK_ICON)) +#define CELL_RENDERER_BREAK_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CELL_RENDERER_BREAK_ICON, CellRendererBreakIconClass)) + +typedef struct _CellRendererBreakIcon CellRendererBreakIcon; +typedef struct _CellRendererBreakIconClass CellRendererBreakIconClass; + +struct _CellRendererBreakIcon +{ + GtkCellRenderer parent; + + guint GSEAL (enabled); + const gchar* GSEAL(condition); + guint GSEAL (hitscount); + + GdkPixbuf *GSEAL (pixbuf_enabled); + GdkPixbuf *GSEAL (pixbuf_disabled); + GdkPixbuf *GSEAL (pixbuf_conditional); + GdkPixbuf *GSEAL (pixbuf_file); +}; + +struct _CellRendererBreakIconClass +{ + GtkCellRendererClass parent_class; + + void (*clicked)(GtkCellRendererToggle *cell_renderer_toggle, const gchar *path); +}; + +GType cell_renderer_break_icon_get_type(void); +GtkCellRenderer* cell_renderer_break_icon_new (void); + +G_END_DECLS + +#endif /* __CELL_RENDERER_BREAK_ICON_H__ */
Modified: debugger/src/cell_renderers/cellrenderertoggle.c 102 files changed, 102 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,102 @@ +/* + * gtkcellrendererfile.c + * + * Copyright 2012 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. + */ + +/* + * cell renderer that inherits from toggle + * the only difference - checks for a x position in "activate" signal + * to ensure the "toggled" signal is sent only when clicked on a particulary cell renderer + */ + +#include <geanyplugin.h> + +#include "cellrenderertoggle.h" + +/* + * handles an activation and sends a toggle signal is its cell renderer has been clicked + */ +static gint cell_renderer_toggle_activate(GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, + GdkRectangle *background_area, GdkRectangle *cell_area, GtkCellRendererState flags) +{ + if (event->button.x >= cell_area->x && + event->button.x < (cell_area->x + cell_area->width)) + { + g_signal_emit_by_name(cell, "toggled", path); + } + return TRUE; +} + +/* + * instance init + */ +static void cell_renderer_toggle_init (CellRendererToggle *cell) +{ + GtkCellRenderer *cell_renderer = (GtkCellRenderer*)cell; + cell_renderer->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; +} + +/* + * class init + */ +static void cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class) +{ + GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class); + cell_class->activate = cell_renderer_toggle_activate; +} + +/* + * registers a type + */ +GType cell_renderer_toggle_get_type(void) +{ + static GType cell_brekpoint_type = 0; + + if(0 == cell_brekpoint_type) + { + static const GTypeInfo cell_file_info = + { + sizeof (CellRendererToggleClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) cell_renderer_toggle_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (CellRendererToggle), + 0, /* n_preallocs */ + (GInstanceInitFunc) cell_renderer_toggle_init, + }; + + /* Derive from GtkToggleCellRenderer */ + cell_brekpoint_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TOGGLE, + "CellRendererToggle", + &cell_file_info, + 0); + } + + return cell_brekpoint_type; +} + +/* + * creates new renderer + */ +GtkCellRenderer* cell_renderer_toggle_new() +{ + return g_object_new(TYPE_CELL_RENDERER_TOGGLE, NULL); +}
Modified: debugger/src/cell_renderers/cellrenderertoggle.h 54 files changed, 54 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,54 @@ +/* + * cellrenderertoggle.h + * + * Copyright 2012 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. + */ + +#ifndef __CELL_RENDERER_TOGGLE_H__ +#define __CELL_RENDERER_TOGGLE_H__ + +#include <gtk/gtkcellrenderertoggle.h> + +G_BEGIN_DECLS + +#define TYPE_CELL_RENDERER_TOGGLE (cell_renderer_toggle_get_type ()) +#define CELL_RENDERER_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CELL_RENDERER_TOGGLE, CellRendererToggle)) +#define CELL_RENDERER_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CELL_RENDERER_TOGGLE, CellRendererToggleClass)) +#define IS_CELL_RENDERER_TOGGLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CELL_RENDERER_TOGGLE)) +#define IS_CELL_RENDERER_TOGGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CELL_RENDERER_TOGGLE)) +#define CELL_RENDERER_TOGGLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CELL_RENDERER_TOGGLE, CellRendererToggleClass)) + +typedef struct _CellRendererToggle CellRendererToggle; +typedef struct _CellRendererToggleClass CellRendererToggleClass; + +struct _CellRendererToggle +{ + GtkCellRendererToggle parent; +}; + +struct _CellRendererToggleClass +{ + GtkCellRendererToggleClass parent_class; +}; + +GType cell_renderer_toggle_get_type(void); +GtkCellRenderer* cell_renderer_toggle_new (void); + +G_END_DECLS + +#endif /* __CELL_RENDERER_TOGGLE_H__ */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).