};
/* GObject vfuncs */
-static void gtk_icon_view_class_init (GtkIconViewClass *klass);
static void gtk_icon_view_cell_layout_init (GtkCellLayoutIface *iface);
static void gtk_icon_view_finalize (GObject *object);
static void gtk_icon_view_set_property (GObject *object,
/* GtkWidget vfuncs */
static void gtk_icon_view_realize (GtkWidget *widget);
static void gtk_icon_view_unrealize (GtkWidget *widget);
+static void gtk_icon_view_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
+static void gtk_icon_view_state_changed (GtkWidget *widget,
+ GtkStateType previous_state);
static void gtk_icon_view_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_icon_view_size_allocate (GtkWidget *widget,
G_DEFINE_TYPE_WITH_CODE (GtkIconView, gtk_icon_view, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
- gtk_icon_view_cell_layout_init));
+ gtk_icon_view_cell_layout_init))
static void
gtk_icon_view_class_init (GtkIconViewClass *klass)
widget_class->realize = gtk_icon_view_realize;
widget_class->unrealize = gtk_icon_view_unrealize;
+ widget_class->style_set = gtk_icon_view_style_set;
+ widget_class->get_accessible = gtk_icon_view_get_accessible;
widget_class->size_request = gtk_icon_view_size_request;
widget_class->size_allocate = gtk_icon_view_size_allocate;
widget_class->expose_event = gtk_icon_view_expose;
widget_class->drag_motion = gtk_icon_view_drag_motion;
widget_class->drag_drop = gtk_icon_view_drag_drop;
widget_class->drag_data_received = gtk_icon_view_drag_data_received;
- widget_class->get_accessible = gtk_icon_view_get_accessible;
+ widget_class->state_changed = gtk_icon_view_state_changed;
container_class->remove = gtk_icon_view_remove;
container_class->forall = gtk_icon_view_forall;
/**
- * GtkIconView::item-width:
+ * GtkIconView:item-width:
*
* The item-width property specifies the width to use for each item.
* If it is set to -1, the icon view will automatically determine a
GTK_PARAM_READWRITE));
/**
- * GtkIconView::spacing:
+ * GtkIconView:spacing:
*
* The spacing property specifies the space which is inserted between
* the cells (i.e. the icon and the text) of an item.
GTK_PARAM_READWRITE));
/**
- * GtkIconView::row-spacing:
+ * GtkIconView:row-spacing:
*
* The row-spacing property specifies the space which is inserted between
* the rows of the icon view.
GTK_PARAM_READWRITE));
/**
- * GtkIconView::column-spacing:
+ * GtkIconView:column-spacing:
*
* The column-spacing property specifies the space which is inserted between
* the columns of the icon view.
GTK_PARAM_READWRITE));
/**
- * GtkIconView::margin:
+ * GtkIconView:margin:
*
* The margin property specifies the space which is inserted
* at the edges of the icon view.
/**
- * GtkIconView::orientation:
+ * GtkIconView:orientation:
*
* The orientation property specifies how the cells (i.e. the icon and
* the text) of the item are positioned relative to each other.
GTK_TYPE_TREE_PATH);
icon_view_signals[SELECTION_CHANGED] =
- g_signal_new (I_("selection_changed"),
+ g_signal_new (I_("selection-changed"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkIconViewClass, selection_changed),
}
remove_scroll_timeout (icon_view);
+
+ if (icon_view->priv->hadjustment != NULL)
+ {
+ g_object_unref (icon_view->priv->hadjustment);
+ icon_view->priv->hadjustment = NULL;
+ }
+
+ if (icon_view->priv->vadjustment != NULL)
+ {
+ g_object_unref (icon_view->priv->vadjustment);
+ icon_view->priv->vadjustment = NULL;
+ }
(* GTK_OBJECT_CLASS (gtk_icon_view_parent_class)->destroy) (object);
}
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
+ gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
gdk_window_set_user_data (widget->window, widget);
/* Make the window for the icon view */
widget->style = gtk_style_attach (widget->style, widget->window);
gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
- gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
gdk_window_show (icon_view->priv->bin_window);
}
(* GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->unrealize) (widget);
}
+static void
+gtk_icon_view_state_changed (GtkWidget *widget,
+ GtkStateType previous_state)
+{
+ GtkIconView *icon_view = GTK_ICON_VIEW (widget);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
+ gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
+ }
+
+ gtk_widget_queue_draw (widget);
+}
+
+static void
+gtk_icon_view_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ GtkIconView *icon_view;
+
+ g_return_if_fail (GTK_IS_ICON_VIEW (widget));
+
+ icon_view = GTK_ICON_VIEW (widget);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
+ gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
+ }
+
+ gtk_widget_queue_resize (widget);
+}
+
static void
gtk_icon_view_size_request (GtkWidget *widget,
GtkRequisition *requisition)
GtkIconView *icon_view;
gdouble value;
- GDK_THREADS_ENTER ();
-
icon_view = data;
value = MIN (icon_view->priv->vadjustment->value +
gtk_icon_view_update_rubberband (icon_view);
- GDK_THREADS_LEAVE ();
-
return TRUE;
}
icon_view->priv->event_last_y = event->y;
if (icon_view->priv->scroll_timeout_id == 0)
- icon_view->priv->scroll_timeout_id = g_timeout_add (30, rubberband_scroll_timeout,
+ icon_view->priv->scroll_timeout_id = gdk_threads_add_timeout (30, rubberband_scroll_timeout,
icon_view);
}
else
/* FIXME ugly special case */
if (GTK_IS_ENTRY (editable) || GTK_IS_COMBO_BOX (editable))
- g_object_set (editable, "has_frame", TRUE, NULL);
+ g_object_set (editable, "has-frame", TRUE, NULL);
/* the rest corresponds to tree_view_real_start_editing... */
icon_view->priv->edited_item = item;
* gtk_icon_view_set_cursor:
* @icon_view: A #GtkIconView
* @path: A #GtkTreePath
- * @cell: A #GtkCellRenderer or %NULL
+ * @cell: One of the cell renderers of @icon_view, or %NULL
* @start_editing: %TRUE if the specified cell should start being edited.
*
* Sets the current keyboard focus to be at @path, and selects it. This is
if (!item)
return;
-
+
cell_pos = -1;
for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
{
info = l->data;
-
+
if (info->cell == cell)
{
cell_pos = i;
break;
}
-
+
info = NULL;
}
+
+ g_return_if_fail (cell == NULL || info != NULL);
gtk_icon_view_set_cursor_item (icon_view, item, cell_pos);
- if (FALSE && GTK_WIDGET_REALIZED (icon_view))
- gtk_icon_view_scroll_to_item (icon_view, item);
- else
- gtk_icon_view_scroll_to_path (icon_view, path,
- FALSE, 0.0, 0.0);
-
- if (start_editing)
+ gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
+
+ if (info && start_editing)
gtk_icon_view_start_editing (icon_view, item, info, NULL);
}
{
GtkIconView *icon_view;
- GDK_THREADS_ENTER ();
-
icon_view = GTK_ICON_VIEW (user_data);
icon_view->priv->layout_idle_id = 0;
gtk_icon_view_layout (icon_view);
- GDK_THREADS_LEAVE();
-
return FALSE;
}
if (icon_view->priv->layout_idle_id != 0)
return;
- icon_view->priv->layout_idle_id = g_idle_add (layout_callback, icon_view);
+ icon_view->priv->layout_idle_id = gdk_threads_add_idle (layout_callback, icon_view);
}
static void
}
if (!item)
- return;
+ {
+ gtk_widget_error_bell (GTK_WIDGET (icon_view));
+ return;
+ }
if (icon_view->priv->ctrl_pressed ||
!icon_view->priv->shift_pressed ||
icon_view->priv->cursor_item,
count);
+ if (item == icon_view->priv->cursor_item)
+ gtk_widget_error_bell (GTK_WIDGET (icon_view));
+
if (!item)
return;
}
if (!item)
- return;
+ {
+ gtk_widget_error_bell (GTK_WIDGET (icon_view));
+ return;
+ }
if (icon_view->priv->ctrl_pressed ||
!icon_view->priv->shift_pressed ||
item = list ? list->data : NULL;
+ if (item == icon_view->priv->cursor_item)
+ gtk_widget_error_bell (GTK_WIDGET (icon_view));
+
if (!item)
return;
* @col_align: The horizontal alignment of the item specified by @path.
*
* Moves the alignments of @icon_view to the position specified by @path.
- * @row_align determines where the row is placed, and @col_align determines where
- * @column is placed. Both are expected to be between 0.0 and 1.0.
- * 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.
+ * @row_align determines where the row is placed, and @col_align determines
+ * where @column is placed. Both are expected to be between 0.0 and 1.0.
+ * 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means
+ * center.
*
* If @use_align is %FALSE, then the alignment arguments are ignored, and the
* tree does the minimum amount of work to scroll the item onto the screen.
* This means that the item will be scrolled to the edge closest to its current
* position. If the item is currently visible on the screen, nothing is done.
*
- * This function only works if the model is set, and @path is a valid row on the
- * model. If the model changes before the @icon_view is realized, the centered
- * path will be modified to reflect this change.
+ * This function only works if the model is set, and @path is a valid row on
+ * the model. If the model changes before the @icon_view is realized, the
+ * centered path will be modified to reflect this change.
*
* Since: 2.8
**/
if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
g_object_set (info->cell,
- "wrap_mode", PANGO_WRAP_CHAR,
- "wrap_width", icon_view->priv->item_width,
+ "wrap-mode", PANGO_WRAP_CHAR,
+ "wrap-width", icon_view->priv->item_width,
"xalign", 0.5,
"yalign", 0.0,
NULL);
else
g_object_set (info->cell,
- "wrap_mode", PANGO_WRAP_CHAR,
- "wrap_width", icon_view->priv->item_width,
+ "wrap-mode", PANGO_WRAP_CHAR,
+ "wrap-width", icon_view->priv->item_width,
"xalign", 0.0,
"yalign", 0.0,
NULL);
if (icon_view->priv->orientation == GTK_ORIENTATION_VERTICAL)
g_object_set (info->cell,
- "follow_state", TRUE,
+ "follow-state", TRUE,
"xalign", 0.5,
"yalign", 1.0,
NULL);
else
g_object_set (info->cell,
- "follow_state", TRUE,
+ "follow-state", TRUE,
"xalign", 0.0,
"yalign", 0.0,
NULL);
* @path: A #GtkTreePath to check selection on.
*
* Returns %TRUE if the icon pointed to by @path is currently
- * selected. If @icon does not point to a valid location, %FALSE is returned.
+ * selected. If @path does not point to a valid location, %FALSE is returned.
*
* Return value: %TRUE if @path is selected.
*
{
GtkIconView *icon_view = GTK_ICON_VIEW (data);
- GDK_THREADS_ENTER ();
-
gtk_icon_view_autoscroll (icon_view);
- GDK_THREADS_LEAVE ();
-
return TRUE;
}
if (icon_view->priv->scroll_timeout_id == 0)
{
icon_view->priv->scroll_timeout_id =
- g_timeout_add (50, drag_scroll_timeout, icon_view);
+ gdk_threads_add_timeout (50, drag_scroll_timeout, icon_view);
}
if (target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
* @icon_view: a #GtkIconView
* @targets: the table of targets that the drag will support
* @n_targets: the number of items in @targets
- * @actions: the bitmask of possible actions for a drag from this
+ * @actions: the bitmask of possible actions for a drag to this
* widget
*
* Turns @icon_view into a drop destination for automatic DND.
GtkIconView *icon_view;
GtkTreePath *path;
- GDK_THREADS_ENTER ();
-
item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (data);
item->action_idle_handler = 0;
gtk_tree_path_free (path);
}
- GDK_THREADS_LEAVE ();
-
return FALSE;
}
{
case ACTION_ACTIVATE:
if (!item->action_idle_handler)
- item->action_idle_handler = g_idle_add (gtk_icon_view_item_accessible_idle_do_action, item);
+ item->action_idle_handler = gdk_threads_add_idle (gtk_icon_view_item_accessible_idle_do_action, item);
break;
default:
g_assert_not_reached ();
if (!type)
{
- static const GTypeInfo tinfo =
+ const GTypeInfo tinfo =
{
sizeof (GtkIconViewItemAccessibleClass),
(GBaseInitFunc) NULL, /* base init */
AtkObject *atk_obj;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
- g_signal_emit_by_name (atk_obj, "visible-data-changed");
+ g_signal_emit_by_name (atk_obj, "visible_data_changed");
return;
}
{
GtkIconViewAccessiblePrivate *priv;
GtkIconViewItemAccessibleInfo *info;
- GtkIconViewAccessible *view;
GtkIconView *icon_view;
GtkIconViewItemAccessible *item;
GList *items;
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
icon_view = GTK_ICON_VIEW (user_data);
- view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj);
priv = gtk_icon_view_accessible_get_priv (atk_obj);
items = priv->items;
GObject *obj;
obj = G_OBJECT (icon_view->priv->model);
- g_signal_connect_data (obj, "row-changed",
+ g_signal_connect_data (obj, "row_changed",
(GCallback) gtk_icon_view_accessible_model_row_changed,
icon_view, NULL, 0);
- g_signal_connect_data (obj, "row-inserted",
+ g_signal_connect_data (obj, "row_inserted",
(GCallback) gtk_icon_view_accessible_model_row_inserted,
icon_view, NULL, G_CONNECT_AFTER);
- g_signal_connect_data (obj, "row-deleted",
+ g_signal_connect_data (obj, "row_deleted",
(GCallback) gtk_icon_view_accessible_model_row_deleted,
icon_view, NULL, G_CONNECT_AFTER);
- g_signal_connect_data (obj, "rows-reordered",
+ g_signal_connect_data (obj, "rows_reordered",
(GCallback) gtk_icon_view_accessible_model_rows_reordered,
icon_view, NULL, G_CONNECT_AFTER);
}
GtkWidget *widget;
GtkIconView *icon_view;
GtkIconViewItem *item;
- GList *l;
widget = GTK_ACCESSIBLE (selection)->widget;
if (widget == NULL)
if (!type)
{
- static const GTypeInfo tinfo =
+ const GTypeInfo tinfo =
{
sizeof (AtkObjectFactoryClass),
NULL, /* base_init */