summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-09-06 12:35:12 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-09-06 17:11:37 -0400
commitc60362ab100af06c60c55a07e77cc91b4b016d20 (patch)
tree4783550cc7e4c9681049d8e2c629c6d3788d0981 /gtk
parent3077a7e025dd57071bdddaacd17c0a4d5fb06295 (diff)
downloadgtk+-c60362ab100af06c60c55a07e77cc91b4b016d20.tar.gz
tree view column: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktreeviewcolumn.c345
1 files changed, 166 insertions, 179 deletions
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index f3d50ccc0f..7b154bd10e 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -196,7 +196,8 @@ enum
PROP_SORT_INDICATOR,
PROP_SORT_ORDER,
PROP_SORT_COLUMN_ID,
- PROP_CELL_AREA
+ PROP_CELL_AREA,
+ LAST_PROP
};
enum
@@ -206,6 +207,7 @@ enum
};
static guint tree_column_signals[LAST_SIGNAL] = { 0 };
+static GParamSpec *tree_column_props[LAST_PROP] = { NULL, };
G_DEFINE_TYPE_WITH_CODE (GtkTreeViewColumn, gtk_tree_view_column, G_TYPE_INITIALLY_UNOWNED,
G_ADD_PRIVATE (GtkTreeViewColumn)
@@ -239,148 +241,132 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- g_object_class_install_property (object_class,
- PROP_VISIBLE,
- g_param_spec_boolean ("visible",
- P_("Visible"),
- P_("Whether to display the column"),
- TRUE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_RESIZABLE,
- g_param_spec_boolean ("resizable",
- P_("Resizable"),
- P_("Column is user-resizable"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_X_OFFSET,
- g_param_spec_int ("x-offset",
- P_("X position"),
- P_("Current X position of the column"),
- -G_MAXINT,
- G_MAXINT,
- 0,
- GTK_PARAM_READABLE));
-
- g_object_class_install_property (object_class,
- PROP_WIDTH,
- g_param_spec_int ("width",
- P_("Width"),
- P_("Current width of the column"),
- 0,
- G_MAXINT,
- 0,
- GTK_PARAM_READABLE));
- g_object_class_install_property (object_class,
- PROP_SPACING,
- g_param_spec_int ("spacing",
- P_("Spacing"),
- P_("Space which is inserted between cells"),
- 0,
- G_MAXINT,
- 0,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
- g_object_class_install_property (object_class,
- PROP_SIZING,
- g_param_spec_enum ("sizing",
- P_("Sizing"),
- P_("Resize mode of the column"),
- GTK_TYPE_TREE_VIEW_COLUMN_SIZING,
- GTK_TREE_VIEW_COLUMN_GROW_ONLY,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_FIXED_WIDTH,
- g_param_spec_int ("fixed-width",
- P_("Fixed Width"),
- P_("Current fixed width of the column"),
- -1, G_MAXINT, -1,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_MIN_WIDTH,
- g_param_spec_int ("min-width",
- P_("Minimum Width"),
- P_("Minimum allowed width of the column"),
- -1, G_MAXINT, -1,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_MAX_WIDTH,
- g_param_spec_int ("max-width",
- P_("Maximum Width"),
- P_("Maximum allowed width of the column"),
- -1, G_MAXINT, -1,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_TITLE,
- g_param_spec_string ("title",
- P_("Title"),
- P_("Title to appear in column header"),
- "",
- GTK_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_EXPAND,
- g_param_spec_boolean ("expand",
- P_("Expand"),
- P_("Column gets share of extra width allocated to the widget"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_CLICKABLE,
- g_param_spec_boolean ("clickable",
- P_("Clickable"),
- P_("Whether the header can be clicked"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
-
- g_object_class_install_property (object_class,
- PROP_WIDGET,
- g_param_spec_object ("widget",
- P_("Widget"),
- P_("Widget to put in column header button instead of column title"),
- GTK_TYPE_WIDGET,
- GTK_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_ALIGNMENT,
- g_param_spec_float ("alignment",
- P_("Alignment"),
- P_("X Alignment of the column header text or widget"),
- 0.0, 1.0, 0.0,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_REORDERABLE,
- g_param_spec_boolean ("reorderable",
- P_("Reorderable"),
- P_("Whether the column can be reordered around the headers"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_SORT_INDICATOR,
- g_param_spec_boolean ("sort-indicator",
- P_("Sort indicator"),
- P_("Whether to show a sort indicator"),
- FALSE,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
- g_object_class_install_property (object_class,
- PROP_SORT_ORDER,
- g_param_spec_enum ("sort-order",
- P_("Sort order"),
- P_("Sort direction the sort indicator should indicate"),
- GTK_TYPE_SORT_TYPE,
- GTK_SORT_ASCENDING,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+ tree_column_props[PROP_VISIBLE] =
+ g_param_spec_boolean ("visible",
+ P_("Visible"),
+ P_("Whether to display the column"),
+ TRUE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_RESIZABLE] =
+ g_param_spec_boolean ("resizable",
+ P_("Resizable"),
+ P_("Column is user-resizable"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_X_OFFSET] =
+ g_param_spec_int ("x-offset",
+ P_("X position"),
+ P_("Current X position of the column"),
+ -G_MAXINT, G_MAXINT,
+ 0,
+ GTK_PARAM_READABLE);
+
+ tree_column_props[PROP_WIDTH] =
+ g_param_spec_int ("width",
+ P_("Width"),
+ P_("Current width of the column"),
+ 0, G_MAXINT,
+ 0,
+ GTK_PARAM_READABLE);
+
+ tree_column_props[PROP_SPACING] =
+ g_param_spec_int ("spacing",
+ P_("Spacing"),
+ P_("Space which is inserted between cells"),
+ 0, G_MAXINT,
+ 0,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_SIZING] =
+ g_param_spec_enum ("sizing",
+ P_("Sizing"),
+ P_("Resize mode of the column"),
+ GTK_TYPE_TREE_VIEW_COLUMN_SIZING,
+ GTK_TREE_VIEW_COLUMN_GROW_ONLY,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_FIXED_WIDTH] =
+ g_param_spec_int ("fixed-width",
+ P_("Fixed Width"),
+ P_("Current fixed width of the column"),
+ -1, G_MAXINT,
+ -1,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_MIN_WIDTH] =
+ g_param_spec_int ("min-width",
+ P_("Minimum Width"),
+ P_("Minimum allowed width of the column"),
+ -1, G_MAXINT,
+ -1,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_MAX_WIDTH] =
+ g_param_spec_int ("max-width",
+ P_("Maximum Width"),
+ P_("Maximum allowed width of the column"),
+ -1, G_MAXINT,
+ -1,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_TITLE] =
+ g_param_spec_string ("title",
+ P_("Title"),
+ P_("Title to appear in column header"),
+ "",
+ GTK_PARAM_READWRITE);
+
+ tree_column_props[PROP_EXPAND] =
+ g_param_spec_boolean ("expand",
+ P_("Expand"),
+ P_("Column gets share of extra width allocated to the widget"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_CLICKABLE] =
+ g_param_spec_boolean ("clickable",
+ P_("Clickable"),
+ P_("Whether the header can be clicked"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_WIDGET] =
+ g_param_spec_object ("widget",
+ P_("Widget"),
+ P_("Widget to put in column header button instead of column title"),
+ GTK_TYPE_WIDGET,
+ GTK_PARAM_READWRITE);
+
+ tree_column_props[PROP_ALIGNMENT] =
+ g_param_spec_float ("alignment",
+ P_("Alignment"),
+ P_("X Alignment of the column header text or widget"),
+ 0.0, 1.0, 0.0,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_REORDERABLE] =
+ g_param_spec_boolean ("reorderable",
+ P_("Reorderable"),
+ P_("Whether the column can be reordered around the headers"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_SORT_INDICATOR] =
+ g_param_spec_boolean ("sort-indicator",
+ P_("Sort indicator"),
+ P_("Whether to show a sort indicator"),
+ FALSE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+
+ tree_column_props[PROP_SORT_ORDER] =
+ g_param_spec_enum ("sort-order",
+ P_("Sort order"),
+ P_("Sort direction the sort indicator should indicate"),
+ GTK_TYPE_SORT_TYPE,
+ GTK_SORT_ASCENDING,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkTreeViewColumn:sort-column-id:
@@ -390,13 +376,13 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
*
* Since: 2.18
**/
- g_object_class_install_property (object_class,
- PROP_SORT_COLUMN_ID,
- g_param_spec_int ("sort-column-id",
- P_("Sort column ID"),
- P_("Logical sort column ID this column sorts on when selected for sorting"),
- -1, G_MAXINT, -1,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+ tree_column_props[PROP_SORT_COLUMN_ID] =
+ g_param_spec_int ("sort-column-id",
+ P_("Sort column ID"),
+ P_("Logical sort column ID this column sorts on when selected for sorting"),
+ -1, G_MAXINT,
+ -1,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkTreeViewColumn:cell-area:
@@ -408,13 +394,14 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class)
*
* Since: 3.0
*/
- g_object_class_install_property (object_class,
- PROP_CELL_AREA,
- g_param_spec_object ("cell-area",
- P_("Cell Area"),
- P_("The GtkCellArea used to layout cells"),
- GTK_TYPE_CELL_AREA,
- GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ tree_column_props[PROP_CELL_AREA] =
+ g_param_spec_object ("cell-area",
+ P_("Cell Area"),
+ P_("The GtkCellArea used to layout cells"),
+ GTK_TYPE_CELL_AREA,
+ GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY);
+
+ g_object_class_install_properties (object_class, LAST_PROP, tree_column_props);
}
static void
@@ -1857,7 +1844,7 @@ gtk_tree_view_column_set_spacing (GtkTreeViewColumn *tree_column,
gtk_cell_area_box_set_spacing (GTK_CELL_AREA_BOX (priv->cell_area), spacing);
if (priv->tree_view)
_gtk_tree_view_column_cell_set_dirty (tree_column, TRUE);
- g_object_notify (G_OBJECT (tree_column), "spacing");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_SPACING]);
}
}
@@ -1917,7 +1904,7 @@ gtk_tree_view_column_set_visible (GtkTreeViewColumn *tree_column,
}
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "visible");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_VISIBLE]);
}
/**
@@ -1968,7 +1955,7 @@ gtk_tree_view_column_set_resizable (GtkTreeViewColumn *tree_column,
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "resizable");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_RESIZABLE]);
}
/**
@@ -2015,7 +2002,7 @@ gtk_tree_view_column_set_sizing (GtkTreeViewColumn *tree_column,
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "sizing");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_SIZING]);
}
/**
@@ -2152,8 +2139,8 @@ _gtk_tree_view_column_allocate (GtkTreeViewColumn *tree_column,
TREE_VIEW_DRAG_WIDTH, allocation.height);
}
- g_object_notify (G_OBJECT (tree_column), "x-offset");
- g_object_notify (G_OBJECT (tree_column), "width");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_X_OFFSET]);
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_WIDTH]);
}
/**
@@ -2192,7 +2179,7 @@ gtk_tree_view_column_set_fixed_width (GtkTreeViewColumn *tree_column,
gtk_widget_get_realized (priv->tree_view))
gtk_widget_queue_resize (priv->tree_view);
- g_object_notify (G_OBJECT (tree_column), "fixed-width");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_FIXED_WIDTH]);
}
}
@@ -2248,9 +2235,9 @@ gtk_tree_view_column_set_min_width (GtkTreeViewColumn *tree_column,
if (priv->max_width != -1 && priv->max_width < min_width)
{
priv->max_width = min_width;
- g_object_notify (G_OBJECT (tree_column), "max-width");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_MAX_WIDTH]);
}
- g_object_notify (G_OBJECT (tree_column), "min-width");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_MIN_WIDTH]);
g_object_thaw_notify (G_OBJECT (tree_column));
if (priv->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE && priv->tree_view)
@@ -2312,9 +2299,9 @@ gtk_tree_view_column_set_max_width (GtkTreeViewColumn *tree_column,
if (max_width != -1 && max_width < priv->min_width)
{
priv->min_width = max_width;
- g_object_notify (G_OBJECT (tree_column), "min-width");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_MIN_WIDTH]);
}
- g_object_notify (G_OBJECT (tree_column), "max-width");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_MAX_WIDTH]);
g_object_thaw_notify (G_OBJECT (tree_column));
if (priv->column_type == GTK_TREE_VIEW_COLUMN_AUTOSIZE && priv->tree_view)
@@ -2385,7 +2372,7 @@ gtk_tree_view_column_set_title (GtkTreeViewColumn *tree_column,
priv->title = new_title;
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "title");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_TITLE]);
}
/**
@@ -2442,7 +2429,7 @@ gtk_tree_view_column_set_expand (GtkTreeViewColumn *tree_column,
gtk_widget_queue_resize (priv->tree_view);
}
- g_object_notify (G_OBJECT (tree_column), "expand");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_EXPAND]);
}
/**
@@ -2487,7 +2474,7 @@ gtk_tree_view_column_set_clickable (GtkTreeViewColumn *tree_column,
priv->clickable = clickable;
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "clickable");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_CLICKABLE]);
}
/**
@@ -2528,12 +2515,12 @@ gtk_tree_view_column_set_widget (GtkTreeViewColumn *tree_column,
if (widget)
g_object_ref_sink (widget);
- if (priv->child)
+ if (priv->child)
g_object_unref (priv->child);
priv->child = widget;
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "widget");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_WIDGET]);
}
/**
@@ -2580,7 +2567,7 @@ gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,
priv->xalign = xalign;
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "alignment");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_ALIGNMENT]);
}
/**
@@ -2626,7 +2613,7 @@ gtk_tree_view_column_set_reorderable (GtkTreeViewColumn *tree_column,
priv->reorderable = (reorderable?TRUE:FALSE);
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "reorderable");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_REORDERABLE]);
}
/**
@@ -2690,7 +2677,7 @@ gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
gtk_tree_view_column_set_sort_order (tree_column, GTK_SORT_ASCENDING);
gtk_tree_view_column_set_sort_indicator (tree_column, FALSE);
gtk_tree_view_column_set_clickable (tree_column, FALSE);
- g_object_notify (G_OBJECT (tree_column), "sort-column-id");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_SORT_COLUMN_ID]);
return;
}
@@ -2703,7 +2690,7 @@ gtk_tree_view_column_set_sort_column_id (GtkTreeViewColumn *tree_column,
NULL);
gtk_tree_view_column_setup_sort_column_id_callback (tree_column);
- g_object_notify (G_OBJECT (tree_column), "sort-column-id");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_SORT_COLUMN_ID]);
}
/**
@@ -2749,7 +2736,7 @@ gtk_tree_view_column_set_sort_indicator (GtkTreeViewColumn *tree_column,
tree_column->priv->show_sort_indicator = setting;
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "sort-indicator");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_SORT_INDICATOR]);
}
/**
@@ -2796,7 +2783,7 @@ gtk_tree_view_column_set_sort_order (GtkTreeViewColumn *tree_column,
tree_column->priv->sort_order = order;
gtk_tree_view_column_update_button (tree_column);
- g_object_notify (G_OBJECT (tree_column), "sort-order");
+ g_object_notify_by_pspec (G_OBJECT (tree_column), tree_column_props[PROP_SORT_ORDER]);
}
/**