diff options
author | Kristian Rietveld <kris@gtk.org> | 2002-11-26 21:28:01 +0000 |
---|---|---|
committer | Kristian Rietveld <kristian@src.gnome.org> | 2002-11-26 21:28:01 +0000 |
commit | a09f497c3694a96fa545249260f617a55f8a12bd (patch) | |
tree | f909a123a98e370a2bf848ef9f87d3387628f48e /gtk | |
parent | 621ae3a60c074d1c91c20a866e2dcc1cbd015259 (diff) | |
download | gtk+-a09f497c3694a96fa545249260f617a55f8a12bd.tar.gz |
add a gtk_list_store_sort_iter_changed line for some special case ...
Tue Nov 26 22:26:04 2002 Kristian Rietveld <kris@gtk.org>
* gtk/gtk{tree,list}store.c (gtk_{tree,list}_store_real_set_value):
add a gtk_list_store_sort_iter_changed line for some special
case ... (#96647 (issue 1), testcases from Soeren Sandmann and
Daniel Elstner).
Tue Nov 26 22:18:06 2002 Kristian Rietveld <kris@gtk.org>
Inconsistent state for toggle renderers, requested by Paolo Bacchilega
in #88130.
* gtk/gtktreeprivate.h: move GtkCellRendererInfo here.
* gtk/gtkcellrenderer.c: moved GtkCellRendererInfo away,
fix some indentation issues.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_class_init),
(gtk_cell_renderer_toggle_set_property),
(gtk_cell_renderer_toggle_get_property),
(gtk_cell_renderer_toggle_render): add an inconsistent property.
* gtk/gtkstyle.c (gtk_default_draw_check),
(gtk_default_draw_option): support drawing inconsistent
options/checks for cells.
Tue Nov 26 22:14:14 2002 Kristian Rietveld <kris@gtk.org>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done),
(gtk_cell_renderer_text_start_editing): add a focus_out_id to avoid
calling _editing_done twice (which has nasty side-effects). (#96647,
(issue 2) testcase from Soeren Sandmann).
Tue Nov 26 22:12:21 2002 Kristian Rietveld <kris@gtk.org>
#82739, patch from Padraig O'Briain.
* gtk/gtktreeviewcolumn.[ch]: add
gtk_tree_view_column_cell_get_position()
Tue Nov 26 22:06:29 2002 Kristian Rietveld <kris@gtk.org>
Yes, this chunk breaks ABI compatibility. Owen knows about it and
agreed with it. It doesn't break ABI that bad though, things will
still work. Please keep it silent :P.
This patch fixes some keynav issues reported by Narayana Pattipati
in #81633. (Also mentioned in #92037 (Sun tracking bug)).
* gtk/gtkmarshalers.list: add two silly marshalers
* gtk/gtktreeview.[ch] (gtk_tree_view_real_select_all),
(gtk_tree_view_real_unselect_all),
(gtk_tree_view_real_select_cursor_row),
(gtk_tree_view_real_toggle_cursor_row),
(gtk_tree_view_real_expand_collapse_cursor_row),
(gtk_tree_view_real_start_interactive_search): change the return
type from void to gboolean, update prototypes, functions, signals and
entries in GtkTreeViewClass,
(gtk_tree_view_class_init): add select_cursor_row binding for
enter key,
(gtk_tree_view_key_press): only navigate the header button if the
header is also visible ...
Tue Nov 26 22:05:48 2002 Kristian Rietveld <kris@gtk.org>
API bit of #75745, reported by Richard Hult.
* gtk/gtkcellrenderer.h (GtkCellRendererState): add
GTK_CELL_RENDERER_FOCUSED, rest of this bug fix will follow later.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcellrenderer.c | 27 | ||||
-rw-r--r-- | gtk/gtkcellrenderer.h | 3 | ||||
-rw-r--r-- | gtk/gtkcellrenderertext.c | 21 | ||||
-rw-r--r-- | gtk/gtkcellrenderertoggle.c | 46 | ||||
-rw-r--r-- | gtk/gtkliststore.c | 3 | ||||
-rw-r--r-- | gtk/gtkmarshalers.list | 2 | ||||
-rw-r--r-- | gtk/gtkstyle.c | 9 | ||||
-rw-r--r-- | gtk/gtktreeprivate.h | 15 | ||||
-rw-r--r-- | gtk/gtktreestore.c | 2 | ||||
-rw-r--r-- | gtk/gtktreeview.c | 127 | ||||
-rw-r--r-- | gtk/gtktreeview.h | 14 | ||||
-rw-r--r-- | gtk/gtktreeviewcolumn.c | 34 | ||||
-rw-r--r-- | gtk/gtktreeviewcolumn.h | 5 |
13 files changed, 227 insertions, 81 deletions
diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index 0efcef43a6..4505727dac 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -19,6 +19,7 @@ #include "gtkcellrenderer.h" #include "gtkintl.h" +#include "gtktreeprivate.h" static void gtk_cell_renderer_init (GtkCellRenderer *cell); static void gtk_cell_renderer_class_init (GtkCellRendererClass *class); @@ -51,14 +52,6 @@ enum { PROP_CELL_BACKGROUND_SET }; -#define CELLINFO_KEY "gtk-cell-renderer-info" - -typedef struct _GtkCellRendererInfo GtkCellRendererInfo; -struct _GtkCellRendererInfo -{ - GdkColor cell_background; -}; - GType gtk_cell_renderer_get_type (void) { @@ -102,7 +95,8 @@ gtk_cell_renderer_init (GtkCellRenderer *cell) cell->ypad = 0; cellinfo = g_new0 (GtkCellRendererInfo, 1); - g_object_set_data_full (G_OBJECT (cell), CELLINFO_KEY, cellinfo, g_free); + g_object_set_data_full (G_OBJECT (cell), + GTK_CELL_RENDERER_INFO_KEY, cellinfo, g_free); } static void @@ -251,7 +245,10 @@ gtk_cell_renderer_get_property (GObject *object, GParamSpec *pspec) { GtkCellRenderer *cell = GTK_CELL_RENDERER (object); - GtkCellRendererInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY); + GtkCellRendererInfo *cellinfo; + + cellinfo = g_object_get_data (object, + GTK_CELL_RENDERER_INFO_KEY); switch (param_id) { @@ -377,7 +374,10 @@ static void set_cell_bg_color (GtkCellRenderer *cell, GdkColor *color) { - GtkCellRendererInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY); + GtkCellRendererInfo *cellinfo; + + cellinfo = g_object_get_data (G_OBJECT (cell), + GTK_CELL_RENDERER_INFO_KEY); if (color) { @@ -482,7 +482,10 @@ gtk_cell_renderer_render (GtkCellRenderer *cell, GtkCellRendererState flags) { gboolean selected = FALSE; - GtkCellRendererInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY); + GtkCellRendererInfo *cellinfo; + + cellinfo = g_object_get_data (G_OBJECT (cell), + GTK_CELL_RENDERER_INFO_KEY); g_return_if_fail (GTK_IS_CELL_RENDERER (cell)); g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL); diff --git a/gtk/gtkcellrenderer.h b/gtk/gtkcellrenderer.h index 487c86fcba..7b693e7c7f 100644 --- a/gtk/gtkcellrenderer.h +++ b/gtk/gtkcellrenderer.h @@ -32,7 +32,8 @@ typedef enum GTK_CELL_RENDERER_PRELIT = 1 << 1, GTK_CELL_RENDERER_INSENSITIVE = 1 << 2, /* this flag means the cell is in the sort column/row */ - GTK_CELL_RENDERER_SORTED = 1 << 3 + GTK_CELL_RENDERER_SORTED = 1 << 3, + GTK_CELL_RENDERER_FOCUSED = 1 << 4 } GtkCellRendererState; typedef enum diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index a7490317a0..6b44447b57 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -23,6 +23,7 @@ #include "gtkentry.h" #include "gtkmarshalers.h" #include "gtkintl.h" +#include "gtktreeprivate.h" static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext); static void gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class); @@ -1328,6 +1329,16 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry, { const gchar *path; const gchar *new_text; + GtkCellRendererInfo *info; + + info = g_object_get_data (G_OBJECT (data), + GTK_CELL_RENDERER_INFO_KEY); + + if (info->focus_out_id > 0) + { + g_signal_handler_disconnect (entry, info->focus_out_id); + info->focus_out_id = 0; + } if (GTK_ENTRY (entry)->editing_canceled) return; @@ -1360,6 +1371,7 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell, { GtkCellRendererText *celltext; GtkWidget *entry; + GtkCellRendererInfo *info; celltext = GTK_CELL_RENDERER_TEXT (cell); @@ -1377,14 +1389,17 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell, gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); + info = g_object_get_data (G_OBJECT (cell), + GTK_CELL_RENDERER_INFO_KEY); + gtk_widget_show (entry); g_signal_connect (entry, "editing_done", G_CALLBACK (gtk_cell_renderer_text_editing_done), celltext); - g_signal_connect (entry, "focus_out_event", - G_CALLBACK (gtk_cell_renderer_text_focus_out_event), - celltext); + info->focus_out_id = g_signal_connect (entry, "focus_out_event", + G_CALLBACK (gtk_cell_renderer_text_focus_out_event), + celltext); return GTK_CELL_EDITABLE (entry); diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c index 617c69381f..330a2e54e7 100644 --- a/gtk/gtkcellrenderertoggle.c +++ b/gtk/gtkcellrenderertoggle.c @@ -21,6 +21,7 @@ #include <gtk/gtkcellrenderertoggle.h> #include "gtkintl.h" #include "gtkmarshalers.h" +#include "gtktreeprivate.h" static void gtk_cell_renderer_toggle_get_property (GObject *object, guint param_id, @@ -64,10 +65,10 @@ enum { PROP_ZERO, PROP_ACTIVATABLE, PROP_ACTIVE, - PROP_RADIO + PROP_RADIO, + PROP_INCONSISTENT }; - #define TOGGLE_WIDTH 12 static guint toggle_cell_signals[LAST_SIGNAL] = { 0 }; @@ -133,6 +134,15 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class) FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_INCONSISTENT, + g_param_spec_boolean ("inconsistent", + _("Inconsistent state"), + _("The inconsistent stae of the button"), + FALSE, + G_PARAM_READABLE | + G_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_ACTIVATABLE, @@ -177,6 +187,18 @@ gtk_cell_renderer_toggle_get_property (GObject *object, case PROP_ACTIVE: g_value_set_boolean (value, celltoggle->active); break; + case PROP_INCONSISTENT: + { + /* Move out of here when more properties start to use the info + * thing. I put it here to not affect performance, this property + * is not going to be used much. + */ + GtkCellRendererInfo *cellinfo; + cellinfo = g_object_get_data (object, GTK_CELL_RENDERER_INFO_KEY); + + g_value_set_boolean (value, cellinfo->inconsistent); + } + break; case PROP_ACTIVATABLE: g_value_set_boolean (value, celltoggle->activatable); break; @@ -204,6 +226,16 @@ gtk_cell_renderer_toggle_set_property (GObject *object, celltoggle->active = g_value_get_boolean (value); g_object_notify (G_OBJECT(object), "active"); break; + case PROP_INCONSISTENT: + { + /* read comment in _get_property */ + GtkCellRendererInfo *cellinfo; + cellinfo = g_object_get_data (object, GTK_CELL_RENDERER_INFO_KEY); + + cellinfo->inconsistent = g_value_get_boolean (value); + g_object_notify (G_OBJECT (object), "inconsistent"); + } + break; case PROP_ACTIVATABLE: celltoggle->activatable = g_value_get_boolean (value); g_object_notify (G_OBJECT(object), "activatable"); @@ -283,11 +315,12 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell, GtkCellRendererState flags) { GtkCellRendererToggle *celltoggle = (GtkCellRendererToggle *) cell; + GtkCellRendererInfo *cellinfo; gint width, height; gint x_offset, y_offset; GtkShadowType shadow; GtkStateType state = 0; - + gtk_cell_renderer_toggle_get_size (cell, widget, cell_area, &x_offset, &y_offset, &width, &height); @@ -297,7 +330,12 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell, if (width <= 0 || height <= 0) return; - shadow = celltoggle->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT; + cellinfo = g_object_get_data (G_OBJECT (cell), GTK_CELL_RENDERER_INFO_KEY); + + if (cellinfo->inconsistent) + shadow = GTK_SHADOW_ETCHED_IN; + else + shadow = celltoggle->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT; if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED) { diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c index 538cbe67c2..a8d5b43b79 100644 --- a/gtk/gtkliststore.c +++ b/gtk/gtkliststore.c @@ -717,6 +717,8 @@ gtk_list_store_real_set_value (GtkListStore *list_store, retval = TRUE; if (converted) g_value_unset (&real_value); + if (sort && GTK_LIST_STORE_IS_SORTED (list_store)) + gtk_list_store_sort_iter_changed (list_store, iter, old_column); return retval; } @@ -2266,7 +2268,6 @@ gtk_list_store_sort_iter_changed (GtkListStore *list_store, gtk_tree_model_rows_reordered (GTK_TREE_MODEL (list_store), tmp_path, NULL, new_order); - gtk_tree_path_free (tmp_path); g_free (new_order); } diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list index b0fa87862d..a719713dc3 100644 --- a/gtk/gtkmarshalers.list +++ b/gtk/gtkmarshalers.list @@ -32,6 +32,8 @@ BOOLEAN:OBJECT,BOXED,BOXED BOOLEAN:INT,INT BOOLEAN:VOID BOOLEAN:BOOLEAN +BOOLEAN:NONE +BOOLEAN:BOOLEAN,BOOLEAN,BOOLEAN ENUM:ENUM INT:POINTER NONE:BOOLEAN diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index d36ad10bf4..8c9fd1b39a 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -3623,6 +3623,10 @@ gtk_default_draw_check (GtkStyle *style, draw_part (window, style->text_gc[state_type], area, x, y, CHECK_TEXT); draw_part (window, style->text_aa_gc[state_type], area, x, y, CHECK_AA); } + else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ + { + draw_part (window, style->text_gc[state_type], area, x, y, CHECK_INCONSISTENT_TEXT); + } } else { @@ -3712,6 +3716,11 @@ gtk_default_draw_option (GtkStyle *style, height - 4, 0, 360*64); } + else if (shadow_type == GTK_SHADOW_ETCHED_IN) /* inconsistent */ + { + draw_part (window, widget->style->fg_gc[state_type], + area, x, y, CHECK_INCONSISTENT_TEXT); + } } else { diff --git a/gtk/gtktreeprivate.h b/gtk/gtktreeprivate.h index d289d59d59..dea5568ec7 100644 --- a/gtk/gtktreeprivate.h +++ b/gtk/gtktreeprivate.h @@ -195,6 +195,21 @@ struct _GtkTreeViewPrivate GtkDestroyNotify search_destroy; }; +/* cool ABI compat hack */ +#define GTK_CELL_RENDERER_INFO_KEY "gtk-cell-renderer-info" + +typedef struct _GtkCellRendererInfo GtkCellRendererInfo; +struct _GtkCellRendererInfo +{ + GdkColor cell_background; + + /* text renderer */ + gulong focus_out_id; + + /* toggle renderer */ + gboolean inconsistent :1; +}; + #ifdef __GNUC__ #define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \ diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index d2bc74246f..d322e95c07 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -839,6 +839,8 @@ gtk_tree_store_real_set_value (GtkTreeStore *tree_store, retval = TRUE; if (converted) g_value_unset (&real_value); + if (sort && GTK_TREE_STORE_IS_SORTED (tree_store)) + gtk_tree_store_sort_iter_changed (tree_store, iter, old_column); return retval; } diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index d7d0865270..5377e901e1 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -223,16 +223,16 @@ static void gtk_tree_view_set_adjustments (GtkTreeView *tree static gboolean gtk_tree_view_real_move_cursor (GtkTreeView *tree_view, GtkMovementStep step, gint count); -static void gtk_tree_view_real_select_all (GtkTreeView *tree_view); -static void gtk_tree_view_real_unselect_all (GtkTreeView *tree_view); -static void gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, +static gboolean gtk_tree_view_real_select_all (GtkTreeView *tree_view); +static gboolean gtk_tree_view_real_unselect_all (GtkTreeView *tree_view); +static gboolean gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, gboolean start_editing); -static void gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view); -static void gtk_tree_view_real_expand_collapse_cursor_row (GtkTreeView *tree_view, - gboolean logical, - gboolean expand, - gboolean open_all); -static void gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view); +static gboolean gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view); +static gboolean gtk_tree_view_real_expand_collapse_cursor_row (GtkTreeView *tree_view, + gboolean logical, + gboolean expand, + gboolean open_all); +static gboolean gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view); static void gtk_tree_view_row_changed (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, @@ -401,7 +401,7 @@ static void gtk_tree_view_real_start_editing (GtkTreeView *tree_view, guint flags); static void gtk_tree_view_stop_editing (GtkTreeView *tree_view, gboolean cancel_editing); -static void gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view); +static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view); static GtkTreeViewColumn *gtk_tree_view_get_drop_column (GtkTreeView *tree_view, GtkTreeViewColumn *column, gint drop_position); @@ -755,8 +755,8 @@ G_PARAM_READABLE)); G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkTreeViewClass, select_all), NULL, NULL, - _gtk_marshal_NONE__NONE, - G_TYPE_NONE, 0); + _gtk_marshal_BOOLEAN__NONE, + G_TYPE_BOOLEAN, 0); tree_view_signals[UNSELECT_ALL] = g_signal_new ("unselect_all", @@ -764,8 +764,8 @@ G_PARAM_READABLE)); G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkTreeViewClass, unselect_all), NULL, NULL, - _gtk_marshal_NONE__NONE, - G_TYPE_NONE, 0); + _gtk_marshal_BOOLEAN__NONE, + G_TYPE_BOOLEAN, 0); tree_view_signals[SELECT_CURSOR_ROW] = g_signal_new ("select_cursor_row", @@ -773,8 +773,8 @@ G_PARAM_READABLE)); G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_row), NULL, NULL, - _gtk_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 1, + _gtk_marshal_BOOLEAN__BOOLEAN, + G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN); tree_view_signals[TOGGLE_CURSOR_ROW] = @@ -783,8 +783,8 @@ G_PARAM_READABLE)); G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkTreeViewClass, toggle_cursor_row), NULL, NULL, - _gtk_marshal_NONE__NONE, - G_TYPE_NONE, 0); + _gtk_marshal_BOOLEAN__NONE, + G_TYPE_BOOLEAN, 0); tree_view_signals[EXPAND_COLLAPSE_CURSOR_ROW] = g_signal_new ("expand_collapse_cursor_row", @@ -792,8 +792,8 @@ G_PARAM_READABLE)); G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkTreeViewClass, expand_collapse_cursor_row), NULL, NULL, - _gtk_marshal_VOID__BOOLEAN_BOOLEAN_BOOLEAN, - G_TYPE_NONE, 3, + _gtk_marshal_BOOLEAN__BOOLEAN_BOOLEAN_BOOLEAN, + G_TYPE_BOOLEAN, 3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); @@ -804,8 +804,8 @@ G_PARAM_READABLE)); G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkTreeViewClass, select_cursor_parent), NULL, NULL, - _gtk_marshal_NONE__NONE, - G_TYPE_NONE, 0); + _gtk_marshal_BOOLEAN__NONE, + G_TYPE_BOOLEAN, 0); tree_view_signals[START_INTERACTIVE_SEARCH] = g_signal_new ("start_interactive_search", @@ -813,8 +813,8 @@ G_PARAM_READABLE)); G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GtkTreeViewClass, start_interactive_search), NULL, NULL, - _gtk_marshal_NONE__NONE, - G_TYPE_NONE, 0); + _gtk_marshal_BOOLEAN__NONE, + G_TYPE_BOOLEAN, 0); /* Key bindings */ gtk_tree_view_add_move_binding (binding_set, GDK_Up, 0, @@ -878,6 +878,12 @@ G_PARAM_READABLE)); gtk_binding_entry_add_signal (binding_set, GDK_space, 0, "select_cursor_row", 1, G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "select_cursor_row", 1, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_ISO_Enter, 0, "select_cursor_row", 1, + G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "select_cursor_row", 1, + G_TYPE_BOOLEAN, TRUE); /* expand and collapse rows */ gtk_binding_entry_add_signal (binding_set, GDK_plus, 0, "expand_collapse_cursor_row", 3, @@ -3606,6 +3612,7 @@ gtk_tree_view_key_press (GtkWidget *widget, /* FIXME: this is prolly broken when we go bidi */ if (tree_view->priv->columns && + GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_HEADERS_VISIBLE) && (event->keyval == GDK_Left || event->keyval == GDK_Right)) { gint width = 0; @@ -7369,29 +7376,35 @@ gtk_tree_view_move_cursor_start_end (GtkTreeView *tree_view, gtk_tree_path_free (path); } -static void +static gboolean gtk_tree_view_real_select_all (GtkTreeView *tree_view) { if (! GTK_WIDGET_HAS_FOCUS (tree_view)) - return; + return FALSE; if (tree_view->priv->selection->type != GTK_SELECTION_MULTIPLE) - return; + return FALSE; + gtk_tree_selection_select_all (tree_view->priv->selection); + + return TRUE; } -static void +static gboolean gtk_tree_view_real_unselect_all (GtkTreeView *tree_view) { if (! GTK_WIDGET_HAS_FOCUS (tree_view)) - return; + return FALSE; if (tree_view->priv->selection->type != GTK_SELECTION_MULTIPLE) - return; + return FALSE; + gtk_tree_selection_unselect_all (tree_view->priv->selection); + + return TRUE; } -static void +static gboolean gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, gboolean start_editing) { @@ -7402,13 +7415,13 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, cursor_path = NULL; if (! GTK_WIDGET_HAS_FOCUS (tree_view)) - return; + return FALSE; if (tree_view->priv->cursor) cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor); if (cursor_path == NULL) - return; + return FALSE; _gtk_tree_view_find_node (tree_view, cursor_path, &cursor_tree, &cursor_node); @@ -7416,7 +7429,7 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, if (cursor_tree == NULL) { gtk_tree_path_free (cursor_path); - return; + return FALSE; } gtk_get_current_event_state (&state); @@ -7428,7 +7441,7 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, if (gtk_tree_view_start_editing (tree_view, cursor_path)) { gtk_tree_path_free (cursor_path); - return; + return FALSE; } } _gtk_tree_selection_internal_select_node (tree_view->priv->selection, @@ -7447,9 +7460,11 @@ gtk_tree_view_real_select_cursor_row (GtkTreeView *tree_view, gtk_tree_view_row_activated (tree_view, cursor_path, tree_view->priv->focus_column); gtk_tree_path_free (cursor_path); + + return TRUE; } -static void +static gboolean gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view) { GtkRBTree *cursor_tree = NULL; @@ -7457,21 +7472,21 @@ gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view) GtkTreePath *cursor_path = NULL; if (! GTK_WIDGET_HAS_FOCUS (tree_view)) - return; + return FALSE; cursor_path = NULL; if (tree_view->priv->cursor) cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor); if (cursor_path == NULL) - return; + return FALSE; _gtk_tree_view_find_node (tree_view, cursor_path, &cursor_tree, &cursor_node); if (cursor_tree == NULL) { gtk_tree_path_free (cursor_path); - return; + return FALSE; } _gtk_tree_selection_internal_select_node (tree_view->priv->selection, @@ -7486,11 +7501,11 @@ gtk_tree_view_real_toggle_cursor_row (GtkTreeView *tree_view) gtk_widget_grab_focus (GTK_WIDGET (tree_view)); gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL); gtk_tree_path_free (cursor_path); -} - + return TRUE; +} -static void +static gboolean gtk_tree_view_real_expand_collapse_cursor_row (GtkTreeView *tree_view, gboolean logical, gboolean expand, @@ -7501,17 +7516,17 @@ gtk_tree_view_real_expand_collapse_cursor_row (GtkTreeView *tree_view, GtkRBNode *node; if (! GTK_WIDGET_HAS_FOCUS (tree_view)) - return; + return FALSE; cursor_path = NULL; if (tree_view->priv->cursor) cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor); if (cursor_path == NULL) - return; + return FALSE; if (_gtk_tree_view_find_node (tree_view, cursor_path, &tree, &node)) - return; + return FALSE; gtk_widget_grab_focus (GTK_WIDGET (tree_view)); gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL); @@ -7522,9 +7537,11 @@ gtk_tree_view_real_expand_collapse_cursor_row (GtkTreeView *tree_view, gtk_tree_view_real_collapse_row (tree_view, cursor_path, tree, node, TRUE); gtk_tree_path_free (cursor_path); + + return TRUE; } -static void +static gboolean gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view) { GtkRBTree *cursor_tree = NULL; @@ -7532,21 +7549,21 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view) GtkTreePath *cursor_path = NULL; if (! GTK_WIDGET_HAS_FOCUS (tree_view)) - return; + return FALSE; cursor_path = NULL; if (tree_view->priv->cursor) cursor_path = gtk_tree_row_reference_get_path (tree_view->priv->cursor); if (cursor_path == NULL) - return; + return FALSE; _gtk_tree_view_find_node (tree_view, cursor_path, &cursor_tree, &cursor_node); if (cursor_tree == NULL) { gtk_tree_path_free (cursor_path); - return; + return FALSE; } if (cursor_tree->parent_node) @@ -7571,6 +7588,8 @@ gtk_tree_view_real_select_cursor_parent (GtkTreeView *tree_view) gtk_widget_grab_focus (GTK_WIDGET (tree_view)); gtk_tree_view_queue_draw_path (tree_view, cursor_path, NULL); gtk_tree_path_free (cursor_path); + + return TRUE; } /* Cut and paste from gtkwindow.c */ @@ -7599,7 +7618,7 @@ send_focus_change (GtkWidget *widget, gdk_event_free (fevent); } -static void +static gboolean gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view) { GtkWidget *window; @@ -7607,16 +7626,16 @@ gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view) GtkWidget *search_dialog; if (! GTK_WIDGET_HAS_FOCUS (tree_view)) - return; + return FALSE; if (tree_view->priv->enable_search == FALSE || tree_view->priv->search_column < 0) - return; + return FALSE; search_dialog = g_object_get_data (G_OBJECT (tree_view), GTK_TREE_VIEW_SEARCH_DIALOG_KEY); if (search_dialog) - return; + return FALSE; /* set up window */ window = gtk_window_new (GTK_WINDOW_POPUP); @@ -7662,6 +7681,8 @@ gtk_tree_view_real_start_interactive_search (GtkTreeView *tree_view) /* search first matching iter */ gtk_tree_view_search_init (entry, tree_view); + + return TRUE; } /* this function returns the new width of the column being resized given diff --git a/gtk/gtktreeview.h b/gtk/gtktreeview.h index 68221c8f26..e473f741e6 100644 --- a/gtk/gtktreeview.h +++ b/gtk/gtktreeview.h @@ -90,17 +90,17 @@ struct _GtkTreeViewClass gboolean (* move_cursor) (GtkTreeView *tree_view, GtkMovementStep step, gint count); - void (* select_all) (GtkTreeView *tree_view); - void (* unselect_all) (GtkTreeView *tree_view); - void (* select_cursor_row) (GtkTreeView *tree_view, + gboolean (* select_all) (GtkTreeView *tree_view); + gboolean (* unselect_all) (GtkTreeView *tree_view); + gboolean (* select_cursor_row) (GtkTreeView *tree_view, gboolean start_editing); - void (* toggle_cursor_row) (GtkTreeView *tree_view); - void (* expand_collapse_cursor_row) (GtkTreeView *tree_view, + gboolean (* toggle_cursor_row) (GtkTreeView *tree_view); + gboolean (* expand_collapse_cursor_row) (GtkTreeView *tree_view, gboolean logical, gboolean expand, gboolean open_all); - void (* select_cursor_parent) (GtkTreeView *tree_view); - void (* start_interactive_search) (GtkTreeView *tree_view); + gboolean (* select_cursor_parent) (GtkTreeView *tree_view); + gboolean (* start_interactive_search) (GtkTreeView *tree_view); /* Padding for future expansion */ void (*_gtk_reserved0) (void); diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index d237feefed..9bfd446621 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -3267,3 +3267,37 @@ _gtk_tree_view_column_get_neighbor_sizes (GtkTreeViewColumn *column, } } } + +gboolean +gtk_tree_view_column_cell_get_position (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell_renderer, + gint *start_pos, + gint *width) +{ + GList *list; + gint current_x = 0; + gboolean found_cell = FALSE; + GtkTreeViewColumnCellInfo *cellinfo; + + list = gtk_tree_view_column_cell_first (tree_column); + for (; list; list = gtk_tree_view_column_cell_next (tree_column, list)) + { + cellinfo = list->data; + if (cellinfo->cell == cell_renderer) + { + found_cell = TRUE; + break; + } + current_x += cellinfo->real_width; + } + + if (found_cell) + { + if (start_pos) + *start_pos = current_x; + if (width) + *width = cellinfo->real_width; + } + + return found_cell; +} diff --git a/gtk/gtktreeviewcolumn.h b/gtk/gtktreeviewcolumn.h index 863202279d..83caa8ad2c 100644 --- a/gtk/gtktreeviewcolumn.h +++ b/gtk/gtktreeviewcolumn.h @@ -222,6 +222,11 @@ void gtk_tree_view_column_cell_get_size (GtkTreeViewCol gboolean gtk_tree_view_column_cell_is_visible (GtkTreeViewColumn *tree_column); void gtk_tree_view_column_focus_cell (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell); +gboolean gtk_tree_view_column_cell_get_position (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell_renderer, + gint *start_pos, + gint *width); + #ifdef __cplusplus } |