summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>2001-08-17 16:33:04 +0000
committerTim Janik <timj@src.gnome.org>2001-08-17 16:33:04 +0000
commitad9d2daf4a3156ed3a828e7547d383c0d7dbce75 (patch)
tree5b57562e4b3e971ae64480071278874ee7311713 /gtk
parentaa9932da2704b070a18e13074746b56c4c3a4f9d (diff)
downloadgtk+-ad9d2daf4a3156ed3a828e7547d383c0d7dbce75.tar.gz
const correct string parameter.
Fri Aug 17 17:30:34 2001 Tim Janik <timj@gtk.org> * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): const correct string parameter. * gtk/gtkoptionmenu.c (gtk_option_menu_set_menu): connect to GtkMenuShell::selection_done, now that we have it, instead of ::deactivate so we're not tearing the menu apart and notify the user prematurely. Thu Aug 16 05:22:01 2001 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c (gtk_window_move_resize): if we actually move our window, clear window->need_default_position to avoid infinite loops. some comment fixups and GTK_RESIZE_IMMEDIATE fixups. Wed Aug 15 12:36:55 2001 Tim Janik <timj@gtk.org> * gtk/gtktreeview.c (gtk_tree_view_set_model): move all model setup code into this place. get rid of GTK_TREE_VIEW_MODEL_SETUP usage. (gtk_tree_view_set_property): don't cast possible NULL objects. (gtk_tree_view_destroy): reset the model to NULL. * gtk/gtktreeselection.c (gtk_tree_selection_finalize): chain parent_class handler.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkoptionmenu.c12
-rw-r--r--gtk/gtktreemodel.c8
-rw-r--r--gtk/gtktreemodel.h2
-rw-r--r--gtk/gtktreeselection.c3
-rw-r--r--gtk/gtktreeview.c161
-rw-r--r--gtk/gtkwindow.c82
6 files changed, 109 insertions, 159 deletions
diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c
index fac72c9127..3af74664ad 100644
--- a/gtk/gtkoptionmenu.c
+++ b/gtk/gtkoptionmenu.c
@@ -67,7 +67,7 @@ static gint gtk_option_menu_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_option_menu_key_press (GtkWidget *widget,
GdkEventKey *event);
-static void gtk_option_menu_deactivate (GtkMenuShell *menu_shell,
+static void gtk_option_menu_selection_done (GtkMenuShell *menu_shell,
GtkOptionMenu *option_menu);
static void gtk_option_menu_update_contents (GtkOptionMenu *option_menu);
static void gtk_option_menu_remove_contents (GtkOptionMenu *option_menu);
@@ -234,9 +234,9 @@ gtk_option_menu_set_menu (GtkOptionMenu *option_menu,
gtk_option_menu_calc_size (option_menu);
- gtk_signal_connect (GTK_OBJECT (option_menu->menu), "deactivate",
- (GtkSignalFunc) gtk_option_menu_deactivate,
- option_menu);
+ gtk_signal_connect_after (GTK_OBJECT (option_menu->menu), "selection_done",
+ G_CALLBACK (gtk_option_menu_selection_done),
+ option_menu);
gtk_signal_connect_object (GTK_OBJECT (option_menu->menu), "size_request",
(GtkSignalFunc) gtk_option_menu_calc_size,
GTK_OBJECT (option_menu));
@@ -611,8 +611,8 @@ gtk_option_menu_key_press (GtkWidget *widget,
}
static void
-gtk_option_menu_deactivate (GtkMenuShell *menu_shell,
- GtkOptionMenu *option_menu)
+gtk_option_menu_selection_done (GtkMenuShell *menu_shell,
+ GtkOptionMenu *option_menu)
{
g_return_if_fail (menu_shell != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (option_menu));
diff --git a/gtk/gtktreemodel.c b/gtk/gtktreemodel.c
index 043d7544f5..3f35087a95 100644
--- a/gtk/gtktreemodel.c
+++ b/gtk/gtktreemodel.c
@@ -154,10 +154,10 @@ gtk_tree_path_new (void)
* Return value: A newly created #GtkTreePath, or NULL
**/
GtkTreePath *
-gtk_tree_path_new_from_string (gchar *path)
+gtk_tree_path_new_from_string (const gchar *path)
{
GtkTreePath *retval;
- gchar *orig_path = path;
+ const gchar *orig_path = path;
gchar *ptr;
gint i;
@@ -173,7 +173,7 @@ gtk_tree_path_new_from_string (gchar *path)
if (i < 0)
{
- g_warning (G_STRLOC"Negative numbers in path %s passed to gtk_tree_path_new_from_string", orig_path);
+ g_warning (G_STRLOC ": Negative numbers in path %s passed to gtk_tree_path_new_from_string", orig_path);
gtk_tree_path_free (retval);
return NULL;
}
@@ -181,7 +181,7 @@ gtk_tree_path_new_from_string (gchar *path)
break;
if (ptr == path || *ptr != ':')
{
- g_warning (G_STRLOC"Invalid path %s passed to gtk_tree_path_new_from_string", orig_path);
+ g_warning (G_STRLOC ": Invalid path %s passed to gtk_tree_path_new_from_string", orig_path);
gtk_tree_path_free (retval);
return NULL;
}
diff --git a/gtk/gtktreemodel.h b/gtk/gtktreemodel.h
index 0742aa837b..f9b3977da5 100644
--- a/gtk/gtktreemodel.h
+++ b/gtk/gtktreemodel.h
@@ -116,7 +116,7 @@ struct _GtkTreeModelIface
/* GtkTreePath operations */
GtkTreePath *gtk_tree_path_new (void);
-GtkTreePath *gtk_tree_path_new_from_string (gchar *path);
+GtkTreePath *gtk_tree_path_new_from_string (const gchar *path);
gchar *gtk_tree_path_to_string (GtkTreePath *path);
GtkTreePath *gtk_tree_path_new_root (void);
void gtk_tree_path_append_index (GtkTreePath *path,
diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c
index d23d5d132f..338b76e8d6 100644
--- a/gtk/gtktreeselection.c
+++ b/gtk/gtktreeselection.c
@@ -99,6 +99,9 @@ gtk_tree_selection_finalize (GObject *object)
{
if (GTK_TREE_SELECTION (object)->destroy)
(* GTK_TREE_SELECTION (object)->destroy) (GTK_TREE_SELECTION (object)->user_data);
+
+ /* chain parent_class' handler */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 0752da9ce9..556ed7d659 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -853,13 +853,13 @@ gtk_tree_view_set_property (GObject *object,
switch (prop_id)
{
case PROP_MODEL:
- gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (g_value_get_object (value)));
+ gtk_tree_view_set_model (tree_view, g_value_get_object (value));
break;
case PROP_HADJUSTMENT:
- gtk_tree_view_set_hadjustment (tree_view, GTK_ADJUSTMENT (g_value_get_object (value)));
+ gtk_tree_view_set_hadjustment (tree_view, g_value_get_object (value));
break;
case PROP_VADJUSTMENT:
- gtk_tree_view_set_vadjustment (tree_view, GTK_ADJUSTMENT (g_value_get_object (value)));
+ gtk_tree_view_set_vadjustment (tree_view, g_value_get_object (value));
break;
case PROP_HEADERS_VISIBLE:
gtk_tree_view_set_headers_visible (tree_view, g_value_get_boolean (value));
@@ -868,7 +868,7 @@ gtk_tree_view_set_property (GObject *object,
gtk_tree_view_set_headers_clickable (tree_view, g_value_get_boolean (value));
break;
case PROP_EXPANDER_COLUMN:
- gtk_tree_view_set_expander_column (tree_view, GTK_TREE_VIEW_COLUMN (g_value_get_object (value)));
+ gtk_tree_view_set_expander_column (tree_view, g_value_get_object (value));
break;
case PROP_REORDERABLE:
gtk_tree_view_set_reorderable (tree_view, g_value_get_boolean (value));
@@ -939,9 +939,10 @@ gtk_tree_view_finalize (GObject *object)
static void
gtk_tree_view_destroy (GtkObject *object)
{
- GtkTreeView *tree_view = (GtkTreeView *) object;
+ GtkTreeView *tree_view = GTK_TREE_VIEW (object);
GList *list;
+ gtk_tree_view_set_model (tree_view, NULL);
if (tree_view->priv->tree != NULL)
{
@@ -1273,7 +1274,7 @@ gtk_tree_view_size_request_buttons (GtkTreeView *tree_view)
tree_view->priv->header_height = 1;
- if (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_MODEL_SETUP))
+ if (tree_view->priv->model)
{
for (list = tree_view->priv->columns; list; list = list->next)
{
@@ -4701,53 +4702,6 @@ gtk_tree_view_get_arrow_xrange (GtkTreeView *tree_view,
}
}
-static void
-gtk_tree_view_setup_model (GtkTreeView *tree_view)
-{
- GtkTreePath *path;
- GtkTreeIter iter;
-
- tree_view->priv->tree = NULL;
-
- g_signal_connect (tree_view->priv->model,
- "range_changed",
- (GCallback) gtk_tree_view_range_changed,
- tree_view);
- g_signal_connect (tree_view->priv->model,
- "inserted",
- (GCallback) gtk_tree_view_inserted,
- tree_view);
- g_signal_connect (tree_view->priv->model,
- "has_child_toggled",
- (GCallback) gtk_tree_view_has_child_toggled,
- tree_view);
- g_signal_connect (tree_view->priv->model,
- "deleted",
- (GCallback) gtk_tree_view_deleted,
- tree_view);
- g_signal_connect (tree_view->priv->model,
- "reordered",
- (GCallback) gtk_tree_view_reordered,
- tree_view);
-
- if (tree_view->priv->columns == NULL)
- return;
-
- path = gtk_tree_path_new_root ();
-
- if (gtk_tree_model_get_iter (tree_view->priv->model, &iter, path))
- {
- tree_view->priv->tree = _gtk_rbtree_new ();
- gtk_tree_view_build_tree (tree_view, tree_view->priv->tree, &iter, 1, FALSE, GTK_WIDGET_REALIZED (tree_view));
- }
-
- gtk_tree_path_free (path);
-
- /* FIXME: do I need to do this? gtk_tree_view_create_buttons (tree_view); */
-
- GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_MODEL_SETUP);
-}
-
static gint
gtk_tree_view_insert_iter_height (GtkTreeView *tree_view,
GtkRBTree *tree,
@@ -5012,10 +4966,6 @@ gtk_tree_view_check_dirty (GtkTreeView *tree_view)
GtkTreeViewColumn *column;
GtkTreeIter iter;
- if (!GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_MODEL_SETUP) &&
- tree_view->priv->model)
- gtk_tree_view_setup_model (tree_view);
-
for (list = tree_view->priv->columns; list; list = list->next)
{
column = list->data;
@@ -6160,58 +6110,73 @@ gtk_tree_view_set_model (GtkTreeView *tree_view,
if (model == tree_view->priv->model)
return;
- if (model != NULL)
- g_object_ref (model);
-
- if (tree_view->priv->model != NULL)
- {
- if (GTK_TREE_VIEW_FLAG_SET (tree_view, GTK_TREE_VIEW_MODEL_SETUP))
+ if (tree_view->priv->model)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT (tree_view->priv->model),
+ gtk_tree_view_range_changed, tree_view);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (tree_view->priv->model),
+ gtk_tree_view_inserted, tree_view);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (tree_view->priv->model),
+ gtk_tree_view_has_child_toggled, tree_view);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (tree_view->priv->model),
+ gtk_tree_view_deleted, tree_view);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (tree_view->priv->model),
+ gtk_tree_view_reordered, tree_view);
+ if (tree_view->priv->tree)
{
- g_signal_handlers_disconnect_matched (G_OBJECT (tree_view->priv->model),
- G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
- 0, 0, NULL,
- gtk_tree_view_range_changed, tree_view);
- g_signal_handlers_disconnect_matched (G_OBJECT (tree_view->priv->model),
- G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
- 0, 0, NULL,
- gtk_tree_view_inserted, tree_view);
- g_signal_handlers_disconnect_matched (G_OBJECT (tree_view->priv->model),
- G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
- 0, 0, NULL,
- gtk_tree_view_has_child_toggled, tree_view);
- g_signal_handlers_disconnect_matched (G_OBJECT (tree_view->priv->model),
- G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
- 0, 0, NULL,
- gtk_tree_view_deleted, tree_view);
- g_signal_handlers_disconnect_matched (G_OBJECT (tree_view->priv->model),
- G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
- 0, 0, NULL,
- gtk_tree_view_reordered, tree_view);
- if (tree_view->priv->tree)
- _gtk_rbtree_free (tree_view->priv->tree);
+ _gtk_rbtree_free (tree_view->priv->tree);
+ tree_view->priv->tree = NULL;
}
-
if (tree_view->priv->drag_dest_row)
- gtk_tree_row_reference_free (tree_view->priv->drag_dest_row);
-
- GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_MODEL_SETUP);
+ {
+ gtk_tree_row_reference_free (tree_view->priv->drag_dest_row);
+ tree_view->priv->drag_dest_row = NULL;
+ }
g_object_unref (tree_view->priv->model);
}
tree_view->priv->model = model;
- if (model == NULL)
+ if (tree_view->priv->model)
{
- tree_view->priv->tree = NULL;
- if (GTK_WIDGET_REALIZED (tree_view))
- _gtk_tree_view_update_size (tree_view);
- }
- else if (GTK_WIDGET_REALIZED (tree_view))
- {
- gtk_tree_view_setup_model (tree_view);
- _gtk_tree_view_update_size (tree_view);
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ g_object_ref (tree_view->priv->model);
+ g_signal_connect (tree_view->priv->model,
+ "range_changed",
+ G_CALLBACK (gtk_tree_view_range_changed),
+ tree_view);
+ g_signal_connect (tree_view->priv->model,
+ "inserted",
+ G_CALLBACK (gtk_tree_view_inserted),
+ tree_view);
+ g_signal_connect (tree_view->priv->model,
+ "has_child_toggled",
+ G_CALLBACK (gtk_tree_view_has_child_toggled),
+ tree_view);
+ g_signal_connect (tree_view->priv->model,
+ "deleted",
+ G_CALLBACK (gtk_tree_view_deleted),
+ tree_view);
+ g_signal_connect (tree_view->priv->model,
+ "reordered",
+ G_CALLBACK (gtk_tree_view_reordered),
+ tree_view);
+
+ path = gtk_tree_path_new_root ();
+ if (gtk_tree_model_get_iter (tree_view->priv->model, &iter, path))
+ {
+ tree_view->priv->tree = _gtk_rbtree_new ();
+ gtk_tree_view_build_tree (tree_view, tree_view->priv->tree, &iter, 1, FALSE, GTK_WIDGET_REALIZED (tree_view));
+ }
+ gtk_tree_path_free (path);
+
+ /* FIXME: do I need to do this? gtk_tree_view_create_buttons (tree_view); */
}
+ if (GTK_WIDGET_REALIZED (tree_view))
+ _gtk_tree_view_update_size (tree_view);
g_object_notify (G_OBJECT (tree_view), "model");
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index a22fa4b823..a708a0e1be 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1318,8 +1318,6 @@ _gtk_window_reposition (GtkWindow *window,
gint x,
gint y)
{
- GtkWindowGeometryInfo *info;
-
g_return_if_fail (GTK_IS_WINDOW (window));
gtk_window_move (window, x, y);
@@ -3484,8 +3482,7 @@ gtk_window_move_resize (GtkWindow *window)
widget->allocation.height != new_request.height))
configure_request_size_changed = TRUE;
- /*
- * Position Constraints
+ /* Position Constraints
* ====================
*
* POS_CENTER_ALWAYS is conceptually a constraint rather than
@@ -3619,7 +3616,9 @@ gtk_window_move_resize (GtkWindow *window)
gdk_window_set_geometry_hints (widget->window,
&new_geometry,
new_flags);
-
+
+ /* handle resizing/moving and widget tree allocation
+ */
if (window->configure_notify_received)
{
GtkAllocation allocation;
@@ -3635,12 +3634,10 @@ gtk_window_move_resize (GtkWindow *window)
* (one per configure request), as an optimization.
*
*/
-
window->configure_notify_received = FALSE;
/* gtk_window_configure_event() filled in widget->allocation */
allocation = widget->allocation;
-
gtk_widget_size_allocate (widget, &allocation);
gtk_widget_queue_draw (widget);
@@ -3648,8 +3645,7 @@ gtk_window_move_resize (GtkWindow *window)
* we either:
* 1) coincidentally changed hints or widget properties
* impacting the configure request before getting
- * a configure notify
- * or
+ * a configure notify, or
* 2) some broken widget is changing its size request
* during size allocation, resulting in
* a false appearance of changed configure request.
@@ -3670,7 +3666,6 @@ gtk_window_move_resize (GtkWindow *window)
* hurt us too badly, since it is what would have
* happened if we had gotten the configure event before
* the new size had been set.
- *
*/
if (configure_request_size_changed ||
@@ -3680,42 +3675,32 @@ gtk_window_move_resize (GtkWindow *window)
* haven't actually updated to the new info yet - we decided
* to postpone our configure request until later.
*/
-
info->last = saved_last_info;
- gtk_widget_queue_resize (widget);
+ gtk_widget_queue_resize (widget); /* migth recurse for GTK_RESIZE_IMMEDIATE */
}
}
else if (configure_request_pos_changed ||
configure_request_size_changed ||
hints_changed)
{
- /* We are in one of the following situations with
- * respect to the window size:
- *
+ /* We are in one of the following situations:
* A. configure_request_size_changed
- * our requisition has changed and we need a different window size,
- * so we request it from the window manager.
- *
+ * our requisition has changed and we need a different window size,
+ * so we request it from the window manager.
* B. !configure_request_size_changed
- * the window manager wouldn't assign us the size we requested, in this
- * case we don't try to request a new size with every resize.
- *
+ * the window manager wouldn't assign us the size we requested, in this
+ * case we don't try to request a new size with every resize.
* C. !configure_request_size_changed && hints_changed
- * the window manager rejects our size, but we have just changed the
- * window manager hints, so there's a certain chance our request will
- * be honoured this time, so we try again.
+ * the window manager rejects our size, but we have just changed the
+ * window manager hints, so there's a certain chance our request will
+ * be honoured this time, so we try again.
+ * D. configure_request_pos_changed
+ * we need to move to a new position, in which case we can also request
+ * a new size since any of A-C might also apply.
*/
- /* Compress case C into case A */
- if (hints_changed)
- configure_request_size_changed = TRUE;
-
- g_assert (configure_request_size_changed ||
- configure_request_pos_changed);
-
/* Now send the configure request */
-
if (configure_request_pos_changed)
{
if (window->frame)
@@ -3733,15 +3718,12 @@ gtk_window_move_resize (GtkWindow *window)
new_request.x, new_request.y,
new_request.width, new_request.height);
}
- else
+ else /* only size changed */
{
- /* only size changed */
-
if (window->frame)
gdk_window_resize (window->frame,
new_request.width + window->frame_left + window->frame_right,
new_request.height + window->frame_top + window->frame_bottom);
-
gdk_window_resize (widget->window,
new_request.width, new_request.height);
}
@@ -3750,13 +3732,17 @@ gtk_window_move_resize (GtkWindow *window)
window->configure_request_count += 1;
/* We have now sent a request since the last position constraint
- * change
+ * change and definitely don't need a an initial size again (not
+ * resetting this here can lead to infinite loops for
+ * GTK_RESIZE_IMMEDIATE containers)
*/
info->position_constraints_changed = FALSE;
-
- /* we are now awaiting the new configure notify event in response to our
- * resizing request. the configure event will cause a new resize
- * with ->configure_notify_received=TRUE.
+ window->need_default_position = FALSE;
+
+ /* for GTK_RESIZE_QUEUE toplevels, we are now awaiting a new
+ * configure event in response to our resizing request.
+ * the configure event will cause a new resize with
+ * ->configure_notify_received=TRUE.
* until then, we want to
* - discard expose events
* - coalesce resizes for our children
@@ -3766,17 +3752,13 @@ gtk_window_move_resize (GtkWindow *window)
* idle handler but when the configure event arrives.
*
* FIXME: we should also dequeue the pending redraws here, since
- * we handle those ourselves in ->configure_notify_received==TRUE.
- *
- * FIXME: not sure the above FIXME is correct, because we only
- * queue draw in size allocate if the size actually changes,
- * so if the update area for the window contains stuff
- * unrelated to sizing (should be rare actually) then we
- * might lose that info.
+ * we handle those ourselves upon ->configure_notify_received==TRUE.
*/
- gtk_widget_queue_resize (widget);
if (container->resize_mode == GTK_RESIZE_QUEUE)
- _gtk_container_dequeue_resize_handler (container);
+ {
+ gtk_widget_queue_resize (widget);
+ _gtk_container_dequeue_resize_handler (container);
+ }
}
else
{