[gnome-control-center/wip/rancell/g-define-type] phase 2
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/rancell/g-define-type] phase 2
- Date: Mon, 4 Sep 2017 04:35:32 +0000 (UTC)
commit 1115949ff3b6437ca9e3a24af17a24b9be5d2e8f
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Sep 4 16:35:20 2017 +1200
phase 2
panels/display/scrollarea.c | 273 +++++++++++++++++------------------
panels/display/scrollarea.h | 53 ++-----
panels/wacom/cc-wacom-button-row.c | 55 +++-----
panels/wacom/cc-wacom-button-row.h | 23 +---
panels/wacom/cc-wacom-page.c | 265 ++++++++++++++--------------------
panels/wacom/cc-wacom-page.h | 38 +-----
panels/wacom/cc-wacom-stylus-page.c | 115 +++++++---------
panels/wacom/cc-wacom-stylus-page.h | 38 +-----
8 files changed, 334 insertions(+), 526 deletions(-)
---
diff --git a/panels/display/scrollarea.c b/panels/display/scrollarea.c
index e71d2ec..7373643 100644
--- a/panels/display/scrollarea.c
+++ b/panels/display/scrollarea.c
@@ -18,9 +18,6 @@
#include <gdk/gdk.h>
-G_DEFINE_TYPE_WITH_CODE (FooScrollArea, foo_scroll_area, GTK_TYPE_CONTAINER,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL));
-
static GtkWidgetClass *parent_class;
typedef struct BackingStore BackingStore;
@@ -63,8 +60,10 @@ struct AutoScrollInfo
GTimer *timer;
};
-struct FooScrollAreaPrivate
+struct _FooScrollArea
{
+ GtkContainer parent_instance;
+
GdkWindow *input_window;
int width;
@@ -99,6 +98,9 @@ struct FooScrollAreaPrivate
cairo_region_t *update_region; /* In canvas coordinates */
};
+G_DEFINE_TYPE_WITH_CODE (FooScrollArea, foo_scroll_area, GTK_TYPE_CONTAINER,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL));
+
enum
{
VIEWPORT_CHANGED,
@@ -149,8 +151,8 @@ foo_scroll_area_map (GtkWidget *widget)
GTK_WIDGET_CLASS (parent_class)->map (widget);
- if (area->priv->input_window)
- gdk_window_show (area->priv->input_window);
+ if (area->input_window)
+ gdk_window_show (area->input_window);
}
static void
@@ -158,8 +160,8 @@ foo_scroll_area_unmap (GtkWidget *widget)
{
FooScrollArea *area = FOO_SCROLL_AREA (widget);
- if (area->priv->input_window)
- gdk_window_hide (area->priv->input_window);
+ if (area->input_window)
+ gdk_window_hide (area->input_window);
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
}
@@ -169,12 +171,12 @@ foo_scroll_area_finalize (GObject *object)
{
FooScrollArea *scroll_area = FOO_SCROLL_AREA (object);
- g_object_unref (scroll_area->priv->hadj);
- g_object_unref (scroll_area->priv->vadj);
+ g_object_unref (scroll_area->hadj);
+ g_object_unref (scroll_area->vadj);
- g_ptr_array_free (scroll_area->priv->input_regions, TRUE);
+ g_ptr_array_free (scroll_area->input_regions, TRUE);
- g_free (scroll_area->priv);
+ g_free (scroll_area);
G_OBJECT_CLASS (foo_scroll_area_parent_class)->finalize (object);
}
@@ -190,16 +192,16 @@ foo_scroll_area_get_property (GObject *object,
switch (property_id)
{
case PROP_VADJUSTMENT:
- g_value_set_object (value, &scroll_area->priv->vadj);
+ g_value_set_object (value, &scroll_area->vadj);
break;
case PROP_HADJUSTMENT:
- g_value_set_object (value, &scroll_area->priv->hadj);
+ g_value_set_object (value, &scroll_area->hadj);
break;
case PROP_HSCROLL_POLICY:
- g_value_set_enum (value, scroll_area->priv->hscroll_policy);
+ g_value_set_enum (value, scroll_area->hscroll_policy);
break;
case PROP_VSCROLL_POLICY:
- g_value_set_enum (value, scroll_area->priv->vscroll_policy);
+ g_value_set_enum (value, scroll_area->vscroll_policy);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -222,10 +224,10 @@ foo_scroll_area_set_property (GObject *object,
foo_scroll_area_set_hadjustment (FOO_SCROLL_AREA (object), g_value_get_object (value));
break;
case PROP_HSCROLL_POLICY:
- scroll_area->priv->hscroll_policy = g_value_get_enum (value);
+ scroll_area->hscroll_policy = g_value_get_enum (value);
break;
case PROP_VSCROLL_POLICY:
- scroll_area->priv->vscroll_policy = g_value_get_enum (value);
+ scroll_area->vscroll_policy = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -266,8 +268,7 @@ foo_scroll_area_class_init (FooScrollAreaClass *class)
g_signal_new ("viewport_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (FooScrollAreaClass,
- viewport_changed),
+ 0,
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 2,
@@ -278,8 +279,7 @@ foo_scroll_area_class_init (FooScrollAreaClass *class)
g_signal_new ("paint",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (FooScrollAreaClass,
- paint),
+ 0,
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE, 1,
@@ -302,19 +302,18 @@ foo_scroll_area_init (FooScrollArea *scroll_area)
gtk_widget_set_has_window (widget, FALSE);
gtk_widget_set_redraw_on_allocate (widget, FALSE);
- scroll_area->priv = g_new0 (FooScrollAreaPrivate, 1);
- scroll_area->priv->width = 0;
- scroll_area->priv->height = 0;
- scroll_area->priv->hadj = g_object_ref_sink (new_adjustment());
- scroll_area->priv->vadj = g_object_ref_sink (new_adjustment());
- scroll_area->priv->x_offset = 0.0;
- scroll_area->priv->y_offset = 0.0;
- scroll_area->priv->min_width = 0;
- scroll_area->priv->min_height = 0;
- scroll_area->priv->auto_scroll_info = NULL;
- scroll_area->priv->input_regions = g_ptr_array_new ();
- scroll_area->priv->surface = NULL;
- scroll_area->priv->update_region = cairo_region_create ();
+ scroll_area->width = 0;
+ scroll_area->height = 0;
+ scroll_area->hadj = g_object_ref_sink (new_adjustment());
+ scroll_area->vadj = g_object_ref_sink (new_adjustment());
+ scroll_area->x_offset = 0.0;
+ scroll_area->y_offset = 0.0;
+ scroll_area->min_width = 0;
+ scroll_area->min_height = 0;
+ scroll_area->auto_scroll_info = NULL;
+ scroll_area->input_regions = g_ptr_array_new ();
+ scroll_area->surface = NULL;
+ scroll_area->update_region = cairo_region_create ();
}
typedef struct
@@ -351,8 +350,8 @@ get_viewport (FooScrollArea *scroll_area,
gtk_widget_get_allocation (widget, &allocation);
- viewport->x = scroll_area->priv->x_offset;
- viewport->y = scroll_area->priv->y_offset;
+ viewport->x = scroll_area->x_offset;
+ viewport->y = scroll_area->y_offset;
viewport->width = allocation.width;
viewport->height = allocation.height;
}
@@ -362,8 +361,8 @@ allocation_to_canvas (FooScrollArea *area,
int *x,
int *y)
{
- *x += area->priv->x_offset;
- *y += area->priv->y_offset;
+ *x += area->x_offset;
+ *y += area->y_offset;
}
static void
@@ -382,16 +381,16 @@ clear_exposed_input_region (FooScrollArea *area,
viewport = cairo_region_create_rectangle (&allocation);
cairo_region_subtract (viewport, exposed);
- for (i = 0; i < area->priv->input_regions->len; ++i)
+ for (i = 0; i < area->input_regions->len; ++i)
{
- InputRegion *region = area->priv->input_regions->pdata[i];
+ InputRegion *region = area->input_regions->pdata[i];
cairo_region_intersect (region->region, viewport);
if (cairo_region_is_empty (region->region))
{
input_region_free (region);
- g_ptr_array_remove_index_fast (area->priv->input_regions, i--);
+ g_ptr_array_remove_index_fast (area->input_regions, i--);
}
}
@@ -449,27 +448,27 @@ foo_scroll_area_draw (GtkWidget *widget,
*/
/* Setup input areas */
- clear_exposed_input_region (scroll_area, scroll_area->priv->update_region);
+ clear_exposed_input_region (scroll_area, scroll_area->update_region);
- scroll_area->priv->current_input = g_new0 (InputRegion, 1);
- scroll_area->priv->current_input->region = cairo_region_copy (scroll_area->priv->update_region);
- scroll_area->priv->current_input->paths = NULL;
- g_ptr_array_add (scroll_area->priv->input_regions,
- scroll_area->priv->current_input);
+ scroll_area->current_input = g_new0 (InputRegion, 1);
+ scroll_area->current_input->region = cairo_region_copy (scroll_area->update_region);
+ scroll_area->current_input->paths = NULL;
+ g_ptr_array_add (scroll_area->input_regions,
+ scroll_area->current_input);
- region = scroll_area->priv->update_region;
- scroll_area->priv->update_region = cairo_region_create ();
+ region = scroll_area->update_region;
+ scroll_area->update_region = cairo_region_create ();
initialize_background (widget, cr);
g_signal_emit (widget, signals[PAINT], 0, cr);
- scroll_area->priv->current_input = NULL;
+ scroll_area->current_input = NULL;
gtk_widget_get_allocation (widget, &widget_allocation);
/* Finally draw the backing surface */
- cairo_set_source_surface (cr, scroll_area->priv->surface,
+ cairo_set_source_surface (cr, scroll_area->surface,
widget_allocation.x, widget_allocation.y);
cairo_fill (cr);
@@ -505,10 +504,10 @@ emit_viewport_changed (FooScrollArea *scroll_area,
g_signal_emit (scroll_area, signals[VIEWPORT_CHANGED], 0,
new_viewport, old_viewport);
- if (scroll_area->priv->input_window == NULL)
+ if (scroll_area->input_window == NULL)
return;
- gdk_window_get_device_position (scroll_area->priv->input_window,
+ gdk_window_get_device_position (scroll_area->input_window,
gdk_device_manager_get_client_pointer (gdk_display_get_device_manager
(gdk_display_get_default ())),
&px, &py, NULL);
@@ -537,8 +536,8 @@ set_adjustment_values (FooScrollArea *scroll_area)
{
GtkAllocation allocation;
- GtkAdjustment *hadj = scroll_area->priv->hadj;
- GtkAdjustment *vadj = scroll_area->priv->vadj;
+ GtkAdjustment *hadj = scroll_area->hadj;
+ GtkAdjustment *vadj = scroll_area->vadj;
/* Horizontal */
gtk_widget_get_allocation (GTK_WIDGET (scroll_area), &allocation);
@@ -547,7 +546,7 @@ set_adjustment_values (FooScrollArea *scroll_area)
gtk_adjustment_set_step_increment (hadj, 0.1 * allocation.width);
gtk_adjustment_set_page_increment (hadj, 0.9 * allocation.width);
gtk_adjustment_set_lower (hadj, 0.0);
- gtk_adjustment_set_upper (hadj, scroll_area->priv->width);
+ gtk_adjustment_set_upper (hadj, scroll_area->width);
g_object_thaw_notify (G_OBJECT (hadj));
/* Vertical */
@@ -556,7 +555,7 @@ set_adjustment_values (FooScrollArea *scroll_area)
gtk_adjustment_set_step_increment (vadj, 0.1 * allocation.height);
gtk_adjustment_set_page_increment (vadj, 0.9 * allocation.height);
gtk_adjustment_set_lower (vadj, 0.0);
- gtk_adjustment_set_upper (vadj, scroll_area->priv->height);
+ gtk_adjustment_set_upper (vadj, scroll_area->height);
g_object_thaw_notify (G_OBJECT (vadj));
clamp_adjustment (hadj);
@@ -600,17 +599,17 @@ foo_scroll_area_realize (GtkWidget *widget)
gtk_widget_set_window (widget, window);
g_object_ref (window);
- area->priv->input_window = gdk_window_new (window,
+ area->input_window = gdk_window_new (window,
&attributes, attributes_mask);
cr = gdk_cairo_create (gtk_widget_get_window (widget));
- area->priv->surface = cairo_surface_create_similar (cairo_get_target (cr),
+ area->surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR,
widget_allocation.width,
widget_allocation.height);
cairo_destroy (cr);
- gdk_window_set_user_data (area->priv->input_window, area);
+ gdk_window_set_user_data (area->input_window, area);
}
static void
@@ -618,11 +617,11 @@ foo_scroll_area_unrealize (GtkWidget *widget)
{
FooScrollArea *area = FOO_SCROLL_AREA (widget);
- if (area->priv->input_window)
+ if (area->input_window)
{
- gdk_window_set_user_data (area->priv->input_window, NULL);
- gdk_window_destroy (area->priv->input_window);
- area->priv->input_window = NULL;
+ gdk_window_set_user_data (area->input_window, NULL);
+ gdk_window_destroy (area->input_window);
+ area->input_window = NULL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
@@ -664,7 +663,7 @@ static void
allocation_to_canvas_region (FooScrollArea *area,
cairo_region_t *region)
{
- cairo_region_translate (region, area->priv->x_offset, area->priv->y_offset);
+ cairo_region_translate (region, area->x_offset, area->y_offset);
}
static void
@@ -713,18 +712,18 @@ foo_scroll_area_size_allocate (GtkWidget *widget,
gtk_widget_set_allocation (widget, allocation);
- if (scroll_area->priv->input_window)
+ if (scroll_area->input_window)
{
cairo_surface_t *new_surface;
- gdk_window_move_resize (scroll_area->priv->input_window,
+ gdk_window_move_resize (scroll_area->input_window,
allocation->x, allocation->y,
allocation->width, allocation->height);
- new_surface = create_new_surface (widget, scroll_area->priv->surface);
- cairo_surface_destroy (scroll_area->priv->surface);
+ new_surface = create_new_surface (widget, scroll_area->surface);
+ cairo_surface_destroy (scroll_area->surface);
- scroll_area->priv->surface = new_surface;
+ scroll_area->surface = new_surface;
}
get_viewport (scroll_area, &new_viewport);
@@ -763,20 +762,20 @@ process_event (FooScrollArea *scroll_area,
allocation_to_canvas (scroll_area, &x, &y);
- if (scroll_area->priv->grabbed)
+ if (scroll_area->grabbed)
{
emit_input (scroll_area, input_type, x, y,
- scroll_area->priv->grab_func,
- scroll_area->priv->grab_data);
+ scroll_area->grab_func,
+ scroll_area->grab_data);
}
#if 0
- g_print ("number of input regions: %d\n", scroll_area->priv->input_regions->len);
+ g_print ("number of input regions: %d\n", scroll_area->input_regions->len);
#endif
- for (i = 0; i < scroll_area->priv->input_regions->len; ++i)
+ for (i = 0; i < scroll_area->input_regions->len; ++i)
{
- InputRegion *region = scroll_area->priv->input_regions->pdata[i];
+ InputRegion *region = scroll_area->input_regions->pdata[i];
#if 0
g_print ("region %d (looking for %d,%d) ", i, x, y);
@@ -806,7 +805,7 @@ process_event (FooScrollArea *scroll_area,
if (inside)
{
- if (scroll_area->priv->grabbed)
+ if (scroll_area->grabbed)
{
emit_input (scroll_area, FOO_DRAG_HOVER,
x, y,
@@ -895,17 +894,17 @@ foo_scroll_area_set_size_fixed_y (FooScrollArea *scroll_area,
int old_y,
int new_y)
{
- scroll_area->priv->width = width;
- scroll_area->priv->height = height;
+ scroll_area->width = width;
+ scroll_area->height = height;
#if 0
g_print ("diff: %d\n", new_y - old_y);
#endif
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
- gtk_adjustment_set_value (scroll_area->priv->vadj, new_y);
+ g_object_thaw_notify (G_OBJECT (scroll_area->vadj));
+ gtk_adjustment_set_value (scroll_area->vadj, new_y);
set_adjustment_values (scroll_area);
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
+ g_object_thaw_notify (G_OBJECT (scroll_area->vadj));
}
void
@@ -930,8 +929,8 @@ foo_scroll_area_set_size (FooScrollArea *scroll_area,
* fixed points?
*/
- scroll_area->priv->width = width;
- scroll_area->priv->height = height;
+ scroll_area->width = width;
+ scroll_area->height = height;
set_adjustment_values (scroll_area);
}
@@ -944,10 +943,10 @@ foo_scroll_area_get_preferred_width (GtkWidget *widget,
FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
if (minimum != NULL) {
- *minimum = scroll_area->priv->min_width;
+ *minimum = scroll_area->min_width;
}
if (natural != NULL) {
- *natural = scroll_area->priv->min_width;
+ *natural = scroll_area->min_width;
}
}
@@ -959,10 +958,10 @@ foo_scroll_area_get_preferred_height (GtkWidget *widget,
FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget);
if (minimum != NULL) {
- *minimum = scroll_area->priv->min_height;
+ *minimum = scroll_area->min_height;
}
if (natural != NULL) {
- *natural = scroll_area->priv->min_height;
+ *natural = scroll_area->min_height;
}
}
@@ -997,7 +996,7 @@ foo_scroll_area_scroll (FooScrollArea *area,
move_area.width, move_area.height,
dx, dy);
#endif
- cr = cairo_create (area->priv->surface);
+ cr = cairo_create (area->surface);
/* Cairo doesn't allow self-copies, so we do this little trick instead:
* 1) Clip so the group size is small.
@@ -1007,7 +1006,7 @@ foo_scroll_area_scroll (FooScrollArea *area,
cairo_clip (cr);
cairo_push_group (cr);
- cairo_set_source_surface (cr, area->priv->surface, dx, dy);
+ cairo_set_source_surface (cr, area->surface, dx, dy);
gdk_cairo_rectangle (cr, &move_area);
cairo_fill (cr);
@@ -1042,18 +1041,18 @@ foo_scrollbar_adjustment_changed (GtkAdjustment *adj,
get_viewport (scroll_area, &old_viewport);
- if (adj == scroll_area->priv->hadj)
+ if (adj == scroll_area->hadj)
{
/* FIXME: do we treat the offset as int or double, and,
* if int, how do we round?
*/
- dx = (int)gtk_adjustment_get_value (adj) - scroll_area->priv->x_offset;
- scroll_area->priv->x_offset = gtk_adjustment_get_value (adj);
+ dx = (int)gtk_adjustment_get_value (adj) - scroll_area->x_offset;
+ scroll_area->x_offset = gtk_adjustment_get_value (adj);
}
- else if (adj == scroll_area->priv->vadj)
+ else if (adj == scroll_area->vadj)
{
- dy = (int)gtk_adjustment_get_value (adj) - scroll_area->priv->y_offset;
- scroll_area->priv->y_offset = gtk_adjustment_get_value (adj);
+ dy = (int)gtk_adjustment_get_value (adj) - scroll_area->y_offset;
+ scroll_area->y_offset = gtk_adjustment_get_value (adj);
}
else
{
@@ -1109,7 +1108,7 @@ static void
foo_scroll_area_set_hadjustment (FooScrollArea *scroll_area,
GtkAdjustment *hadjustment)
{
- set_one_adjustment (scroll_area, hadjustment, &scroll_area->priv->hadj);
+ set_one_adjustment (scroll_area, hadjustment, &scroll_area->hadj);
set_adjustment_values (scroll_area);
}
@@ -1118,7 +1117,7 @@ static void
foo_scroll_area_set_vadjustment (FooScrollArea *scroll_area,
GtkAdjustment *vadjustment)
{
- set_one_adjustment (scroll_area, vadjustment, &scroll_area->priv->vadj);
+ set_one_adjustment (scroll_area, vadjustment, &scroll_area->vadj);
set_adjustment_values (scroll_area);
}
@@ -1134,8 +1133,8 @@ foo_scroll_area_set_min_size (FooScrollArea *scroll_area,
int min_width,
int min_height)
{
- scroll_area->priv->min_width = min_width;
- scroll_area->priv->min_height = min_height;
+ scroll_area->min_width = min_width;
+ scroll_area->min_height = min_height;
/* FIXME: think through invalidation.
*
@@ -1161,8 +1160,8 @@ make_path (FooScrollArea *area,
path->path = cairo_copy_path (cr);
path->func = func;
path->data = data;
- path->next = area->priv->current_input->paths;
- area->priv->current_input->paths = path;
+ path->next = area->current_input->paths;
+ area->current_input->paths = path;
return path;
}
@@ -1181,7 +1180,7 @@ foo_scroll_area_add_input_from_fill (FooScrollArea *scroll_area,
{
g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
g_return_if_fail (cr != NULL);
- g_return_if_fail (scroll_area->priv->current_input);
+ g_return_if_fail (scroll_area->current_input);
make_path (scroll_area, cr, FALSE, func, data);
}
@@ -1194,7 +1193,7 @@ foo_scroll_area_add_input_from_stroke (FooScrollArea *scroll_area,
{
g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
g_return_if_fail (cr != NULL);
- g_return_if_fail (scroll_area->priv->current_input);
+ g_return_if_fail (scroll_area->current_input);
make_path (scroll_area, cr, TRUE, func, data);
}
@@ -1207,7 +1206,7 @@ foo_scroll_area_invalidate (FooScrollArea *scroll_area)
gtk_widget_get_allocation (widget, &allocation);
foo_scroll_area_invalidate_rect (scroll_area,
- scroll_area->priv->x_offset, scroll_area->priv->y_offset,
+ scroll_area->x_offset, scroll_area->y_offset,
allocation.width,
allocation.height);
}
@@ -1221,8 +1220,8 @@ canvas_to_window (FooScrollArea *area,
gtk_widget_get_allocation (widget, &allocation);
cairo_region_translate (region,
- -area->priv->x_offset + allocation.x,
- -area->priv->y_offset + allocation.y);
+ -area->x_offset + allocation.x,
+ -area->y_offset + allocation.y);
}
static void
@@ -1234,8 +1233,8 @@ window_to_canvas (FooScrollArea *area,
gtk_widget_get_allocation (widget, &allocation);
cairo_region_translate (region,
- area->priv->x_offset - allocation.x,
- area->priv->y_offset - allocation.y);
+ area->x_offset - allocation.x,
+ area->y_offset - allocation.y);
}
void
@@ -1248,7 +1247,7 @@ foo_scroll_area_invalidate_region (FooScrollArea *area,
widget = GTK_WIDGET (area);
- cairo_region_union (area->priv->update_region, region);
+ cairo_region_union (area->update_region, region);
if (gtk_widget_get_realized (widget))
{
@@ -1286,11 +1285,11 @@ foo_scroll_area_begin_grab (FooScrollArea *scroll_area,
gpointer input_data)
{
g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- g_return_if_fail (!scroll_area->priv->grabbed);
+ g_return_if_fail (!scroll_area->grabbed);
- scroll_area->priv->grabbed = TRUE;
- scroll_area->priv->grab_func = func;
- scroll_area->priv->grab_data = input_data;
+ scroll_area->grabbed = TRUE;
+ scroll_area->grab_func = func;
+ scroll_area->grab_data = input_data;
/* FIXME: we should probably take a server grab */
/* Also, maybe there should be support for setting the grab cursor */
@@ -1302,9 +1301,9 @@ foo_scroll_area_end_grab (FooScrollArea *scroll_area,
{
g_return_if_fail (FOO_IS_SCROLL_AREA (scroll_area));
- scroll_area->priv->grabbed = FALSE;
- scroll_area->priv->grab_func = NULL;
- scroll_area->priv->grab_data = NULL;
+ scroll_area->grabbed = FALSE;
+ scroll_area->grab_func = NULL;
+ scroll_area->grab_data = NULL;
if (event != NULL)
process_event (scroll_area, FOO_DROP, event->x, event->y);
@@ -1313,7 +1312,7 @@ foo_scroll_area_end_grab (FooScrollArea *scroll_area,
gboolean
foo_scroll_area_is_grabbed (FooScrollArea *scroll_area)
{
- return scroll_area->priv->grabbed;
+ return scroll_area->grabbed;
}
void
@@ -1321,14 +1320,14 @@ foo_scroll_area_set_viewport_pos (FooScrollArea *scroll_area,
int x,
int y)
{
- g_object_freeze_notify (G_OBJECT (scroll_area->priv->hadj));
- g_object_freeze_notify (G_OBJECT (scroll_area->priv->vadj));
- gtk_adjustment_set_value (scroll_area->priv->hadj, x);
- gtk_adjustment_set_value (scroll_area->priv->vadj, y);
+ g_object_freeze_notify (G_OBJECT (scroll_area->hadj));
+ g_object_freeze_notify (G_OBJECT (scroll_area->vadj));
+ gtk_adjustment_set_value (scroll_area->hadj, x);
+ gtk_adjustment_set_value (scroll_area->vadj, y);
set_adjustment_values (scroll_area);
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->hadj));
- g_object_thaw_notify (G_OBJECT (scroll_area->priv->vadj));
+ g_object_thaw_notify (G_OBJECT (scroll_area->hadj));
+ g_object_thaw_notify (G_OBJECT (scroll_area->vadj));
}
static gboolean
@@ -1346,13 +1345,13 @@ stop_scrolling (FooScrollArea *area)
#if 0
g_print ("stop scrolling\n");
#endif
- if (area->priv->auto_scroll_info)
+ if (area->auto_scroll_info)
{
- g_source_remove (area->priv->auto_scroll_info->timeout_id);
- g_timer_destroy (area->priv->auto_scroll_info->timer);
- g_free (area->priv->auto_scroll_info);
+ g_source_remove (area->auto_scroll_info->timeout_id);
+ g_timer_destroy (area->auto_scroll_info->timer);
+ g_free (area->auto_scroll_info);
- area->priv->auto_scroll_info = NULL;
+ area->auto_scroll_info = NULL;
}
}
@@ -1361,7 +1360,7 @@ scroll_idle (gpointer data)
{
GdkRectangle viewport, new_viewport;
FooScrollArea *area = data;
- AutoScrollInfo *info = area->priv->auto_scroll_info;
+ AutoScrollInfo *info = area->auto_scroll_info;
int new_x, new_y;
double elapsed;
@@ -1426,15 +1425,15 @@ ensure_scrolling (FooScrollArea *area,
int dx,
int dy)
{
- if (!area->priv->auto_scroll_info)
+ if (!area->auto_scroll_info)
{
#if 0
g_print ("start scrolling\n");
#endif
- area->priv->auto_scroll_info = g_new0 (AutoScrollInfo, 1);
- area->priv->auto_scroll_info->timeout_id =
+ area->auto_scroll_info = g_new0 (AutoScrollInfo, 1);
+ area->auto_scroll_info->timeout_id =
g_idle_add (scroll_idle, area);
- area->priv->auto_scroll_info->timer = g_timer_new ();
+ area->auto_scroll_info->timer = g_timer_new ();
}
#if 0
@@ -1445,8 +1444,8 @@ ensure_scrolling (FooScrollArea *area,
g_print ("dx, dy: %d %d\n", dx, dy);
#endif
- area->priv->auto_scroll_info->dx = dx;
- area->priv->auto_scroll_info->dy = dy;
+ area->auto_scroll_info->dx = dx;
+ area->auto_scroll_info->dy = dy;
}
void
diff --git a/panels/display/scrollarea.h b/panels/display/scrollarea.h
index b097d3d..1422024 100644
--- a/panels/display/scrollarea.h
+++ b/panels/display/scrollarea.h
@@ -13,20 +13,18 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+
+#ifndef _SCROLLAREA_H
+#define _SCROLLAREA_H
+
#include <cairo.h>
#include <gtk/gtk.h>
-#define FOO_TYPE_SCROLL_AREA (foo_scroll_area_get_type ())
-#define FOO_SCROLL_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOO_TYPE_SCROLL_AREA,
FooScrollArea))
-#define FOO_SCROLL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOO_TYPE_SCROLL_AREA,
FooScrollAreaClass))
-#define FOO_IS_SCROLL_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOO_TYPE_SCROLL_AREA))
-#define FOO_IS_SCROLL_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FOO_TYPE_SCROLL_AREA))
-#define FOO_SCROLL_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), FOO_TYPE_SCROLL_AREA,
FooScrollAreaClass))
+G_BEGIN_DECLS
-typedef struct FooScrollArea FooScrollArea;
-typedef struct FooScrollAreaClass FooScrollAreaClass;
-typedef struct FooScrollAreaPrivate FooScrollAreaPrivate;
-typedef struct FooScrollAreaEvent FooScrollAreaEvent;
+#define FOO_TYPE_SCROLL_AREA foo_scroll_area_get_type ()
+
+G_DECLARE_FINAL_TYPE (FooScrollArea, foo_scroll_area, FOO, SCROLL_AREA, GtkContainer)
typedef enum
{
@@ -37,44 +35,17 @@ typedef enum
FOO_MOTION
} FooScrollAreaEventType;
-struct FooScrollAreaEvent
+typedef struct
{
FooScrollAreaEventType type;
int x;
int y;
-};
+} FooScrollAreaEvent;
typedef void (* FooScrollAreaEventFunc) (FooScrollArea *area,
FooScrollAreaEvent *event,
gpointer data);
-struct FooScrollArea
-{
- GtkContainer parent_instance;
-
- FooScrollAreaPrivate *priv;
-};
-
-struct FooScrollAreaClass
-{
- GtkContainerClass parent_class;
-
- void (*set_scroll_adjustments) (FooScrollArea *scroll_area,
- GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment);
-
- void (*viewport_changed) (FooScrollArea *scroll_area,
- GdkRectangle *old_viewport,
- GdkRectangle *new_viewport);
-
- void (*paint) (FooScrollArea *scroll_area,
- cairo_t *cr,
- GdkRectangle *extents,
- cairo_region_t *region);
-};
-
-GType foo_scroll_area_get_type (void);
-
FooScrollArea *foo_scroll_area_new (void);
/* Set the requisition for the widget. */
@@ -123,3 +94,7 @@ void foo_scroll_area_begin_auto_scroll (FooScrollArea *scroll_area);
void foo_scroll_area_auto_scroll (FooScrollArea *scroll_area,
FooScrollAreaEvent *event);
void foo_scroll_area_end_auto_scroll (FooScrollArea *scroll_area);
+
+G_END_DECLS
+
+#endif /* _SCROLLAREA_H */
diff --git a/panels/wacom/cc-wacom-button-row.c b/panels/wacom/cc-wacom-button-row.c
index 52b1d00..c897d7d 100644
--- a/panels/wacom/cc-wacom-button-row.c
+++ b/panels/wacom/cc-wacom-button-row.c
@@ -23,8 +23,6 @@
#include "gsd-wacom-key-shortcut-button.h"
#include "cc-wacom-button-row.h"
-G_DEFINE_TYPE (CcWacomButtonRow, cc_wacom_button_row, GTK_TYPE_LIST_BOX_ROW)
-
#define ACTION_KEY "action"
#define KEYBINDING_KEY "keybinding"
@@ -36,7 +34,8 @@ enum {
ACTION_N_COLUMNS
};
-struct _CcWacomButtonRowPrivate {
+struct _CcWacomButtonRow {
+ GtkListBoxRow parent_instance;
guint button;
GSettings *settings;
GtkDirectionType direction;
@@ -44,6 +43,8 @@ struct _CcWacomButtonRowPrivate {
GsdWacomKeyShortcutButton *key_shortcut_button;
};
+G_DEFINE_TYPE (CcWacomButtonRow, cc_wacom_button_row, GTK_TYPE_LIST_BOX_ROW)
+
static GtkWidget *
create_actions_combo (void)
{
@@ -78,7 +79,6 @@ static void
cc_wacom_button_row_update_shortcut (CcWacomButtonRow *row,
GDesktopPadButtonAction action_type)
{
- CcWacomButtonRowPrivate *priv;
guint keyval;
GdkModifierType mask;
char *shortcut;
@@ -86,14 +86,13 @@ cc_wacom_button_row_update_shortcut (CcWacomButtonRow *row,
if (action_type != G_DESKTOP_PAD_BUTTON_ACTION_KEYBINDING)
return;
- priv = row->priv;
- shortcut = g_settings_get_string (row->priv->settings, KEYBINDING_KEY);
+ shortcut = g_settings_get_string (row->settings, KEYBINDING_KEY);
if (shortcut != NULL)
{
gtk_accelerator_parse (shortcut, &keyval, &mask);
- g_object_set (priv->key_shortcut_button,
+ g_object_set (row->key_shortcut_button,
"key-value", keyval,
"key-mods", mask,
NULL);
@@ -106,15 +105,12 @@ static void
cc_wacom_button_row_update_action (CcWacomButtonRow *row,
GDesktopPadButtonAction action_type)
{
- CcWacomButtonRowPrivate *priv;
GtkTreeIter iter;
gboolean iter_valid;
GDesktopPadButtonAction current_action_type, real_action_type;
GtkTreeModel *model;
- priv = row->priv;
-
- model = gtk_combo_box_get_model (priv->action_combo);
+ model = gtk_combo_box_get_model (row->action_combo);
real_action_type = action_type;
for (iter_valid = gtk_tree_model_get_iter_first (model, &iter); iter_valid;
@@ -126,7 +122,7 @@ cc_wacom_button_row_update_action (CcWacomButtonRow *row,
if (current_action_type == real_action_type)
{
- gtk_combo_box_set_active_iter (priv->action_combo, &iter);
+ gtk_combo_box_set_active_iter (row->action_combo, &iter);
break;
}
}
@@ -135,18 +131,15 @@ cc_wacom_button_row_update_action (CcWacomButtonRow *row,
static void
cc_wacom_button_row_update (CcWacomButtonRow *row)
{
- CcWacomButtonRowPrivate *priv;
GDesktopPadButtonAction current_action_type;
- priv = row->priv;
-
- current_action_type = g_settings_get_enum (priv->settings, ACTION_KEY);
+ current_action_type = g_settings_get_enum (row->settings, ACTION_KEY);
cc_wacom_button_row_update_shortcut (row, current_action_type);
cc_wacom_button_row_update_action (row, current_action_type);
- gtk_widget_set_sensitive (GTK_WIDGET (row->priv->key_shortcut_button),
+ gtk_widget_set_sensitive (GTK_WIDGET (row->key_shortcut_button),
current_action_type == G_DESKTOP_PAD_BUTTON_ACTION_KEYBINDING);
}
@@ -154,8 +147,8 @@ static void
change_button_action_type (CcWacomButtonRow *row,
GDesktopPadButtonAction type)
{
- g_settings_set_enum (row->priv->settings, ACTION_KEY, type);
- gtk_widget_set_sensitive (GTK_WIDGET (row->priv->key_shortcut_button),
+ g_settings_set_enum (row->settings, ACTION_KEY, type);
+ gtk_widget_set_sensitive (GTK_WIDGET (row->key_shortcut_button),
type == G_DESKTOP_PAD_BUTTON_ACTION_KEYBINDING);
}
@@ -169,7 +162,7 @@ on_key_shortcut_edited (GsdWacomKeyShortcutButton *shortcut_button,
change_button_action_type (row, G_DESKTOP_PAD_BUTTON_ACTION_KEYBINDING);
- g_object_get (row->priv->key_shortcut_button,
+ g_object_get (row->key_shortcut_button,
"key-value", &keyval,
"key-mods", &mask,
NULL);
@@ -178,7 +171,7 @@ on_key_shortcut_edited (GsdWacomKeyShortcutButton *shortcut_button,
custom_key = gtk_accelerator_name (keyval, mask);
- g_settings_set_string (row->priv->settings, KEYBINDING_KEY, custom_key);
+ g_settings_set_string (row->settings, KEYBINDING_KEY, custom_key);
g_free (custom_key);
}
@@ -232,31 +225,25 @@ on_key_shortcut_button_press_event (GsdWacomKeyShortcutButton *button,
static void
cc_wacom_button_row_class_init (CcWacomButtonRowClass *button_row_class)
{
- g_type_class_add_private (button_row_class, sizeof (CcWacomButtonRowPrivate));
}
static void
cc_wacom_button_row_init (CcWacomButtonRow *button_row)
{
- button_row->priv = G_TYPE_INSTANCE_GET_PRIVATE (button_row,
- CC_WACOM_TYPE_BUTTON_ROW,
- CcWacomButtonRowPrivate);
}
GtkWidget *
cc_wacom_button_row_new (guint button,
GSettings *settings)
{
- GtkWidget *row;
+ CcWacomButtonRow *row;
GtkWidget *grid, *combo, *label, *shortcut_button;
- CcWacomButtonRowPrivate *priv;
char *name = NULL;
- row = g_object_new (CC_WACOM_TYPE_BUTTON_ROW, NULL);
- priv = CC_WACOM_BUTTON_ROW (row)->priv;
+ row = CC_WACOM_BUTTON_ROW (g_object_new (CC_WACOM_TYPE_BUTTON_ROW, NULL));
- priv->button = button;
- priv->settings = g_object_ref (settings);
+ row->button = button;
+ row->settings = g_object_ref (settings);
grid = gtk_grid_new ();
gtk_widget_show (grid);
@@ -272,7 +259,7 @@ cc_wacom_button_row_new (guint button,
combo = create_actions_combo ();
gtk_grid_attach (GTK_GRID (grid), combo, 1, 0, 1, 1);
gtk_widget_show (combo);
- priv->action_combo = GTK_COMBO_BOX (combo);
+ row->action_combo = GTK_COMBO_BOX (combo);
g_signal_connect (combo, "changed",
G_CALLBACK (on_row_action_combo_box_changed), row);
@@ -280,7 +267,7 @@ cc_wacom_button_row_new (guint button,
g_object_set (shortcut_button, "mode", GSD_WACOM_KEY_SHORTCUT_BUTTON_MODE_ALL, NULL);
gtk_grid_attach (GTK_GRID (grid), shortcut_button, 2, 0, 1, 1);
gtk_widget_show (shortcut_button);
- priv->key_shortcut_button = GSD_WACOM_KEY_SHORTCUT_BUTTON (shortcut_button);
+ row->key_shortcut_button = GSD_WACOM_KEY_SHORTCUT_BUTTON (shortcut_button);
g_signal_connect (shortcut_button, "key-shortcut-cleared",
G_CALLBACK (on_key_shortcut_cleared),
row);
@@ -297,5 +284,5 @@ cc_wacom_button_row_new (guint button,
g_free (name);
- return row;
+ return GTK_WIDGET (row);
}
diff --git a/panels/wacom/cc-wacom-button-row.h b/panels/wacom/cc-wacom-button-row.h
index ee6ecbb..dcad166 100644
--- a/panels/wacom/cc-wacom-button-row.h
+++ b/panels/wacom/cc-wacom-button-row.h
@@ -25,26 +25,9 @@
G_BEGIN_DECLS
-#define CC_WACOM_TYPE_BUTTON_ROW (cc_wacom_button_row_get_type ())
-#define CC_WACOM_BUTTON_ROW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_WACOM_TYPE_BUTTON_ROW,
CcWacomButtonRow))
-#define CC_WACOM_BUTTON_ROW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GTK_TYPE_WACOM_BUTTON_ROW,
CcWacomButtonRowClass))
-#define CC_WACOM_IS_BUTTON_ROW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_WACOM_TYPE_BUTTON_ROW))
-#define CC_WACOM_IS_BUTTON_ROW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CC_WACOM_TYPE_BUTTON_ROW))
-#define CC_WACOM_BUTTON_ROW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_WACOM_TYPE_BUTTON_ROW,
CcWacomButtonRowClass))
+#define CC_WACOM_TYPE_BUTTON_ROW cc_wacom_button_row_get_type ()
-typedef struct _CcWacomButtonRow CcWacomButtonRow;
-typedef struct _CcWacomButtonRowClass CcWacomButtonRowClass;
-typedef struct _CcWacomButtonRowPrivate CcWacomButtonRowPrivate;
-
-struct _CcWacomButtonRow {
- GtkListBoxRow parent;
-
- CcWacomButtonRowPrivate *priv;
-};
-
-struct _CcWacomButtonRowClass {
- GtkListBoxRowClass parent_class;
-};
+G_DECLARE_FINAL_TYPE (CcWacomButtonRow, cc_wacom_button_row, CC, WACOM_BUTTON_ROW, GtkListBoxRow)
static struct {
GDesktopPadButtonAction action_type;
@@ -56,8 +39,6 @@ static struct {
{ G_DESKTOP_PAD_BUTTON_ACTION_HELP, NC_("Wacom action-type", "Show On-Screen Help") }
};
-GType cc_wacom_button_row_get_type (void);
-
GtkWidget * cc_wacom_button_row_new (guint button,
GSettings *settings);
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index b16d74f..a2f07a0 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -47,14 +47,9 @@
#include <string.h>
-#define WID(x) (GtkWidget *) gtk_builder_get_object (priv->builder, x)
-#define CWID(x) (GtkContainer *) gtk_builder_get_object (priv->builder, x)
-#define MWID(x) (GtkWidget *) gtk_builder_get_object (priv->mapping_builder, x)
-
-G_DEFINE_TYPE (CcWacomPage, cc_wacom_page, GTK_TYPE_BOX)
-
-#define WACOM_PAGE_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_WACOM_PAGE, CcWacomPagePrivate))
+#define WID(x) (GtkWidget *) gtk_builder_get_object (page->builder, x)
+#define CWID(x) (GtkContainer *) gtk_builder_get_object (page->builder, x)
+#define MWID(x) (GtkWidget *) gtk_builder_get_object (page->mapping_builder, x)
#define THRESHOLD_MISCLICK 15
#define THRESHOLD_DOUBLECLICK 7
@@ -67,8 +62,10 @@ enum {
MAPPING_N_COLUMNS
};
-struct _CcWacomPagePrivate
+struct _CcWacomPage
{
+ GtkBox parent_instance;
+
CcWacomPanel *panel;
CcWacomDevice *stylus;
CcWacomDevice *pad;
@@ -92,6 +89,8 @@ struct _CcWacomPagePrivate
GCancellable *cancellable;
};
+G_DEFINE_TYPE (CcWacomPage, cc_wacom_page, GTK_TYPE_BOX)
+
/* Button combo box storage columns */
enum {
BUTTONNUMBER_COLUMN,
@@ -179,7 +178,6 @@ finish_calibration (CalibArea *area,
gpointer user_data)
{
CcWacomPage *page = (CcWacomPage *) user_data;
- CcWacomPagePrivate *priv = page->priv;
XYinfo axis;
gdouble cal[4];
gint display_width, display_height;
@@ -193,21 +191,21 @@ finish_calibration (CalibArea *area,
calib_area_get_display_size (area, &display_width, &display_height);
- set_calibration (page->priv->stylus,
+ set_calibration (page->stylus,
display_width,
display_height,
- cal, 4, priv->wacom_settings);
+ cal, 4, page->wacom_settings);
} else {
/* Reset the old values */
GVariant *old_calibration;
old_calibration = g_object_get_data (G_OBJECT (page), "old-calibration");
- g_settings_set_value (page->priv->wacom_settings, "area", old_calibration);
+ g_settings_set_value (page->wacom_settings, "area", old_calibration);
g_object_set_data (G_OBJECT (page), "old-calibration", NULL);
}
calib_area_free (area);
- priv->area = NULL;
+ page->area = NULL;
gtk_widget_set_sensitive (WID ("button-calibrate"), TRUE);
}
@@ -220,7 +218,7 @@ cc_wacom_page_get_gdk_device (CcWacomPage *page)
GdkDisplay *display;
GList *slaves, *l;
- gsd_device = cc_wacom_device_get_device (page->priv->stylus);
+ gsd_device = cc_wacom_device_get_device (page->stylus);
g_return_val_if_fail (GSD_IS_DEVICE (gsd_device), NULL);
display = gtk_widget_get_display (GTK_WIDGET (page));
@@ -259,13 +257,9 @@ run_calibration (CcWacomPage *page,
gdouble *cal,
gint monitor)
{
- CcWacomPagePrivate *priv;
-
- g_assert (page->priv->area == NULL);
-
- priv = page->priv;
+ g_assert (page->area == NULL);
- priv->area = calib_area_new (NULL,
+ page->area = calib_area_new (NULL,
monitor,
cc_wacom_page_get_gdk_device (page),
finish_calibration,
@@ -284,7 +278,6 @@ run_calibration (CcWacomPage *page,
static void
calibrate (CcWacomPage *page)
{
- CcWacomPagePrivate *priv;
int i;
GVariant *old_calibration, **tmp, *array;
gdouble *calibration;
@@ -296,8 +289,6 @@ calibrate (CcWacomPage *page)
GError *error = NULL;
gint x, y;
- priv = page->priv;
-
screen = gdk_screen_get_default ();
rr_screen = gnome_rr_screen_new (screen, &error);
if (error) {
@@ -306,7 +297,7 @@ calibrate (CcWacomPage *page)
return;
}
- output = cc_wacom_device_get_output (page->priv->stylus, rr_screen);
+ output = cc_wacom_device_get_output (page->stylus, rr_screen);
gnome_rr_output_get_position (output, &x, &y);
monitor = gdk_screen_get_monitor_at_point (screen, x, y);
@@ -318,7 +309,7 @@ calibrate (CcWacomPage *page)
return;
}
- old_calibration = g_settings_get_value (page->priv->wacom_settings, "area");
+ old_calibration = g_settings_get_value (page->wacom_settings, "area");
g_variant_get_fixed_array (old_calibration, &ncal, sizeof (gdouble));
if (ncal != 4) {
@@ -337,7 +328,7 @@ calibrate (CcWacomPage *page)
}
array = g_variant_new_array (G_VARIANT_TYPE_DOUBLE, tmp, ncal);
- g_settings_set_value (page->priv->wacom_settings, "area", array);
+ g_settings_set_value (page->wacom_settings, "area", array);
g_free (tmp);
run_calibration (page, old_calibration, calibration, monitor);
@@ -380,17 +371,16 @@ create_row_from_button (GtkWidget *list_box,
static void
setup_button_mapping (CcWacomPage *page)
{
- CcWacomPagePrivate *priv = page->priv;
GDesktopPadButtonAction action;
GtkWidget *list_box;
guint i, n_buttons;
GSettings *settings;
list_box = MWID ("shortcuts_list");
- n_buttons = cc_wacom_device_get_num_buttons (priv->pad);
+ n_buttons = cc_wacom_device_get_num_buttons (page->pad);
for (i = 0; i < n_buttons; i++) {
- settings = cc_wacom_device_get_button_settings (priv->pad, i);
+ settings = cc_wacom_device_get_button_settings (page->pad, i);
if (!settings)
continue;
@@ -407,12 +397,9 @@ button_mapping_dialog_closed (GtkDialog *dialog,
int response_id,
CcWacomPage *page)
{
- CcWacomPagePrivate *priv;
-
- priv = page->priv;
gtk_widget_destroy (MWID ("button-mapping-dialog"));
- g_object_unref (priv->mapping_builder);
- priv->mapping_builder = NULL;
+ g_object_unref (page->mapping_builder);
+ page->mapping_builder = NULL;
}
static void
@@ -421,20 +408,17 @@ show_button_mapping_dialog (CcWacomPage *page)
GtkWidget *toplevel;
GError *error = NULL;
GtkWidget *dialog;
- CcWacomPagePrivate *priv;
- priv = page->priv;
-
- g_assert (priv->mapping_builder == NULL);
- priv->mapping_builder = gtk_builder_new ();
- gtk_builder_add_from_resource (priv->mapping_builder,
+ g_assert (page->mapping_builder == NULL);
+ page->mapping_builder = gtk_builder_new ();
+ gtk_builder_add_from_resource (page->mapping_builder,
"/org/gnome/control-center/wacom/button-mapping.ui",
&error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
- g_object_unref (priv->mapping_builder);
- priv->mapping_builder = NULL;
+ g_object_unref (page->mapping_builder);
+ page->mapping_builder = NULL;
g_error_free (error);
return;
}
@@ -450,8 +434,8 @@ show_button_mapping_dialog (CcWacomPage *page)
gtk_widget_show (dialog);
- priv->button_map = dialog;
- g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &priv->button_map);
+ page->button_map = dialog;
+ g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *) &page->button_map);
}
static void
@@ -482,14 +466,12 @@ set_osd_visibility_cb (GObject *source_object,
static void
set_osd_visibility (CcWacomPage *page)
{
- CcWacomPagePrivate *priv;
GDBusProxy *proxy;
GsdDevice *gsd_device;
const gchar *device_path;
- priv = page->priv;
- proxy = cc_wacom_panel_get_gsd_wacom_bus_proxy (priv->panel);
- gsd_device = cc_wacom_device_get_device (priv->pad);
+ proxy = cc_wacom_panel_get_gsd_wacom_bus_proxy (page->panel);
+ gsd_device = cc_wacom_device_get_device (page->pad);
device_path = gsd_device_get_device_file (gsd_device);
@@ -503,7 +485,7 @@ set_osd_visibility (CcWacomPage *page)
g_variant_new ("(ob)", device_path, TRUE),
G_DBUS_CALL_FLAGS_NONE,
-1,
- priv->cancellable,
+ page->cancellable,
set_osd_visibility_cb,
page);
}
@@ -520,14 +502,12 @@ display_mapping_dialog_closed (GtkDialog *dialog,
int response_id,
CcWacomPage *page)
{
- CcWacomPagePrivate *priv;
int layout;
- priv = page->priv;
- gtk_widget_destroy (priv->dialog);
- priv->dialog = NULL;
- priv->mapping = NULL;
- layout = get_layout_type (priv->stylus);
+ gtk_widget_destroy (page->dialog);
+ page->dialog = NULL;
+ page->mapping = NULL;
+ layout = get_layout_type (page->stylus);
update_tablet_ui (page, layout);
}
@@ -535,34 +515,30 @@ static void
display_mapping_button_clicked_cb (GtkButton *button,
CcWacomPage *page)
{
- CcWacomPagePrivate *priv;
-
- priv = page->priv;
-
- g_assert (priv->mapping == NULL);
+ g_assert (page->mapping == NULL);
- priv->dialog = gtk_dialog_new_with_buttons (_("Display Mapping"),
+ page->dialog = gtk_dialog_new_with_buttons (_("Display Mapping"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page))),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
_("_Close"),
GTK_RESPONSE_ACCEPT,
NULL);
- priv->mapping = cc_wacom_mapping_panel_new ();
- cc_wacom_mapping_panel_set_device (CC_WACOM_MAPPING_PANEL (priv->mapping),
- priv->stylus);
- gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (priv->dialog))),
- priv->mapping);
- g_signal_connect (G_OBJECT (priv->dialog), "response",
+ page->mapping = cc_wacom_mapping_panel_new ();
+ cc_wacom_mapping_panel_set_device (CC_WACOM_MAPPING_PANEL (page->mapping),
+ page->stylus);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (page->dialog))),
+ page->mapping);
+ g_signal_connect (G_OBJECT (page->dialog), "response",
G_CALLBACK (display_mapping_dialog_closed), page);
- gtk_widget_show_all (priv->dialog);
+ gtk_widget_show_all (page->dialog);
- g_object_add_weak_pointer (G_OBJECT (priv->mapping), (gpointer *) &priv->dialog);
+ g_object_add_weak_pointer (G_OBJECT (page->mapping), (gpointer *) &page->dialog);
}
static void
tabletmode_changed_cb (GtkComboBox *combo, gpointer user_data)
{
- CcWacomPagePrivate *priv = CC_WACOM_PAGE (user_data)->priv;
+ CcWacomPage *page = CC_WACOM_PAGE (user_data);
GtkListStore *liststore;
GtkTreeIter iter;
gint mode;
@@ -575,26 +551,25 @@ tabletmode_changed_cb (GtkComboBox *combo, gpointer user_data)
MODENUMBER_COLUMN, &mode,
-1);
- g_settings_set_enum (priv->wacom_settings, "mapping", mode);
+ g_settings_set_enum (page->wacom_settings, "mapping", mode);
}
static void
left_handed_toggled_cb (GtkSwitch *sw, GParamSpec *pspec, gpointer *user_data)
{
- CcWacomPagePrivate *priv = CC_WACOM_PAGE (user_data)->priv;
+ CcWacomPage *page = CC_WACOM_PAGE (user_data);
gboolean left_handed;
left_handed = gtk_switch_get_active (sw);
- g_settings_set_boolean (priv->wacom_settings, "left-handed", left_handed);
+ g_settings_set_boolean (page->wacom_settings, "left-handed", left_handed);
}
static void
set_left_handed_from_gsettings (CcWacomPage *page)
{
- CcWacomPagePrivate *priv = CC_WACOM_PAGE (page)->priv;
gboolean left_handed;
- left_handed = g_settings_get_boolean (priv->wacom_settings, "left-handed");
+ left_handed = g_settings_get_boolean (page->wacom_settings, "left-handed");
gtk_switch_set_active (GTK_SWITCH (WID ("switch-left-handed")), left_handed);
}
@@ -602,10 +577,9 @@ static void
set_mode_from_gsettings (GtkComboBox *combo,
CcWacomPage *page)
{
- CcWacomPagePrivate *priv = page->priv;
GDesktopTabletMapping mapping;
- mapping = g_settings_get_enum (priv->wacom_settings, "mapping");
+ mapping = g_settings_get_enum (page->wacom_settings, "mapping");
/* this must be kept in sync with the .ui file */
gtk_combo_box_set_active (combo, mapping);
@@ -626,7 +600,7 @@ static gboolean
display_clicked_cb (GtkButton *button,
CcWacomPage *page)
{
- cc_wacom_panel_switch_to_panel (page->priv->panel, "display");
+ cc_wacom_panel_switch_to_panel (page->panel, "display");
return TRUE;
}
@@ -634,7 +608,7 @@ static gboolean
mouse_clicked_cb (GtkButton *button,
CcWacomPage *page)
{
- cc_wacom_panel_switch_to_panel (page->priv->panel, "mouse");
+ cc_wacom_panel_switch_to_panel (page->panel, "mouse");
return TRUE;
}
@@ -669,40 +643,40 @@ cc_wacom_page_set_property (GObject *object,
static void
cc_wacom_page_dispose (GObject *object)
{
- CcWacomPagePrivate *priv = CC_WACOM_PAGE (object)->priv;
+ CcWacomPage *self = CC_WACOM_PAGE (object);
- if (priv->cancellable) {
- g_cancellable_cancel (priv->cancellable);
- g_clear_object (&priv->cancellable);
+ if (self->cancellable) {
+ g_cancellable_cancel (self->cancellable);
+ g_clear_object (&self->cancellable);
}
- if (priv->area) {
- calib_area_free (priv->area);
- priv->area = NULL;
+ if (self->area) {
+ calib_area_free (self->area);
+ self->area = NULL;
}
- if (priv->button_map) {
- gtk_widget_destroy (priv->button_map);
- priv->button_map = NULL;
+ if (self->button_map) {
+ gtk_widget_destroy (self->button_map);
+ self->button_map = NULL;
}
- if (priv->dialog) {
- gtk_widget_destroy (priv->dialog);
- priv->dialog = NULL;
+ if (self->dialog) {
+ gtk_widget_destroy (self->dialog);
+ self->dialog = NULL;
}
- if (priv->builder) {
- g_object_unref (priv->builder);
- priv->builder = NULL;
+ if (self->builder) {
+ g_object_unref (self->builder);
+ self->builder = NULL;
}
- if (priv->header_group) {
- g_object_unref (priv->header_group);
- priv->header_group = NULL;
+ if (self->header_group) {
+ g_object_unref (self->header_group);
+ self->header_group = NULL;
}
- priv->panel = NULL;
+ self->panel = NULL;
G_OBJECT_CLASS (cc_wacom_page_parent_class)->dispose (object);
}
@@ -712,17 +686,14 @@ cc_wacom_page_class_init (CcWacomPageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CcWacomPagePrivate));
-
object_class->get_property = cc_wacom_page_get_property;
object_class->set_property = cc_wacom_page_set_property;
object_class->dispose = cc_wacom_page_dispose;
}
static void
-cc_wacom_page_init (CcWacomPage *self)
+cc_wacom_page_init (CcWacomPage *page)
{
- CcWacomPagePrivate *priv;
GError *error = NULL;
GtkComboBox *combo;
GtkWidget *box;
@@ -736,55 +707,53 @@ cc_wacom_page_init (CcWacomPage *self)
NULL
};
- priv = self->priv = WACOM_PAGE_PRIVATE (self);
-
- priv->builder = gtk_builder_new ();
+ page->builder = gtk_builder_new ();
- gtk_builder_add_objects_from_resource (priv->builder,
+ gtk_builder_add_objects_from_resource (page->builder,
"/org/gnome/control-center/wacom/gnome-wacom-properties.ui",
objects,
&error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
- g_object_unref (priv->builder);
+ g_object_unref (page->builder);
g_error_free (error);
return;
}
box = WID ("main-grid");
- gtk_container_add (GTK_CONTAINER (self), box);
+ gtk_container_add (GTK_CONTAINER (page), box);
gtk_widget_set_vexpand (GTK_WIDGET (box), TRUE);
g_signal_connect (WID ("button-calibrate"), "clicked",
- G_CALLBACK (calibrate_button_clicked_cb), self);
+ G_CALLBACK (calibrate_button_clicked_cb), page);
g_signal_connect (WID ("map-buttons-button"), "clicked",
- G_CALLBACK (map_buttons_button_clicked_cb), self);
+ G_CALLBACK (map_buttons_button_clicked_cb), page);
combo = GTK_COMBO_BOX (WID ("combo-tabletmode"));
combobox_text_cellrenderer (combo, MODELABEL_COLUMN);
g_signal_connect (G_OBJECT (combo), "changed",
- G_CALLBACK (tabletmode_changed_cb), self);
+ G_CALLBACK (tabletmode_changed_cb), page);
sw = GTK_SWITCH (WID ("switch-left-handed"));
g_signal_connect (G_OBJECT (sw), "notify::active",
- G_CALLBACK (left_handed_toggled_cb), self);
+ G_CALLBACK (left_handed_toggled_cb), page);
g_signal_connect (G_OBJECT (WID ("display-link")), "activate-link",
- G_CALLBACK (display_clicked_cb), self);
+ G_CALLBACK (display_clicked_cb), page);
g_signal_connect (G_OBJECT (WID ("mouse-link")), "activate-link",
- G_CALLBACK (mouse_clicked_cb), self);
+ G_CALLBACK (mouse_clicked_cb), page);
g_signal_connect (G_OBJECT (WID ("display-mapping-button")), "clicked",
- G_CALLBACK (display_mapping_button_clicked_cb), self);
+ G_CALLBACK (display_mapping_button_clicked_cb), page);
- priv->nav = cc_wacom_nav_button_new ();
- gtk_widget_set_halign (priv->nav, GTK_ALIGN_END);
- gtk_widget_set_margin_start (priv->nav, 10);
- gtk_widget_show (priv->nav);
- gtk_container_add (CWID ("navigation-placeholder"), priv->nav);
+ page->nav = cc_wacom_nav_button_new ();
+ gtk_widget_set_halign (page->nav, GTK_ALIGN_END);
+ gtk_widget_set_margin_start (page->nav, 10);
+ gtk_widget_show (page->nav);
+ gtk_container_add (CWID ("navigation-placeholder"), page->nav);
- priv->cancellable = g_cancellable_new ();
+ page->cancellable = g_cancellable_new ();
}
static void
@@ -792,25 +761,22 @@ set_icon_name (CcWacomPage *page,
const char *widget_name,
const char *icon_name)
{
- CcWacomPagePrivate *priv;
char *resource;
- priv = page->priv;
-
resource = g_strdup_printf ("/org/gnome/control-center/wacom/%s.svg", icon_name);
gtk_image_set_from_resource (GTK_IMAGE (WID (widget_name)), resource);
g_free (resource);
}
static void
-remove_left_handed (CcWacomPagePrivate *priv)
+remove_left_handed (CcWacomPage *page)
{
gtk_widget_destroy (WID ("label-left-handed"));
gtk_widget_destroy (WID ("switch-left-handed"));
}
static void
-remove_display_link (CcWacomPagePrivate *priv)
+remove_display_link (CcWacomPage *page)
{
gtk_widget_destroy (WID ("display-link"));
@@ -820,7 +786,7 @@ remove_display_link (CcWacomPagePrivate *priv)
}
static void
-remove_mouse_link (CcWacomPagePrivate *priv)
+remove_mouse_link (CcWacomPage *page)
{
gtk_widget_destroy (WID ("mouse-link"));
@@ -833,10 +799,8 @@ static gboolean
has_monitor (CcWacomPage *page)
{
WacomIntegrationFlags integration_flags;
- CcWacomPagePrivate *priv;
- priv = page->priv;
- integration_flags = cc_wacom_device_get_integration_flags (priv->stylus);
+ integration_flags = cc_wacom_device_get_integration_flags (page->stylus);
return ((integration_flags &
(WACOM_DEVICE_INTEGRATED_DISPLAY | WACOM_DEVICE_INTEGRATED_SYSTEM)) != 0);
@@ -847,31 +811,28 @@ update_tablet_ui (CcWacomPage *page,
int layout)
{
WacomIntegrationFlags integration_flags;
- CcWacomPagePrivate *priv;
-
- priv = page->priv;
- integration_flags = cc_wacom_device_get_integration_flags (priv->stylus);
+ integration_flags = cc_wacom_device_get_integration_flags (page->stylus);
if ((integration_flags &
(WACOM_DEVICE_INTEGRATED_DISPLAY | WACOM_DEVICE_INTEGRATED_SYSTEM)) != 0) {
/* FIXME: Check we've got a puck, or a corresponding touchpad device */
- remove_mouse_link (priv);
+ remove_mouse_link (page);
}
/* Hide the pad buttons if no pad is present */
- gtk_widget_set_visible (WID ("map-buttons-button"), priv->pad != NULL);
+ gtk_widget_set_visible (WID ("map-buttons-button"), page->pad != NULL);
switch (layout) {
case LAYOUT_NORMAL:
- remove_left_handed (priv);
- remove_display_link (priv);
+ remove_left_handed (page);
+ remove_display_link (page);
break;
case LAYOUT_REVERSIBLE:
- remove_display_link (priv);
+ remove_display_link (page);
break;
case LAYOUT_SCREEN:
- remove_left_handed (priv);
+ remove_left_handed (page);
gtk_widget_destroy (WID ("combo-tabletmode"));
gtk_widget_destroy (WID ("label-trackingmode"));
@@ -898,20 +859,18 @@ cc_wacom_page_update_tools (CcWacomPage *page,
CcWacomDevice *stylus,
CcWacomDevice *pad)
{
- CcWacomPagePrivate *priv;
int layout;
gboolean changed;
/* Type of layout */
layout = get_layout_type (stylus);
- priv = page->priv;
- changed = (priv->stylus != stylus || priv->pad != pad);
+ changed = (page->stylus != stylus || page->pad != pad);
if (!changed)
return FALSE;
- priv->stylus = stylus;
- priv->pad = pad;
+ page->stylus = stylus;
+ page->pad = pad;
update_tablet_ui (CC_WACOM_PAGE (page), layout);
@@ -924,20 +883,18 @@ cc_wacom_page_new (CcWacomPanel *panel,
CcWacomDevice *pad)
{
CcWacomPage *page;
- CcWacomPagePrivate *priv;
g_return_val_if_fail (CC_IS_WACOM_DEVICE (stylus), NULL);
g_return_val_if_fail (!pad || CC_IS_WACOM_DEVICE (pad), NULL);
page = g_object_new (CC_TYPE_WACOM_PAGE, NULL);
- priv = page->priv;
- priv->panel = panel;
+ page->panel = panel;
cc_wacom_page_update_tools (page, stylus, pad);
/* FIXME move this to construct */
- priv->wacom_settings = cc_wacom_device_get_settings (stylus);
+ page->wacom_settings = cc_wacom_device_get_settings (stylus);
set_mode_from_gsettings (GTK_COMBO_BOX (WID ("combo-tabletmode")), page);
/* Tablet name */
@@ -958,13 +915,9 @@ cc_wacom_page_set_navigation (CcWacomPage *page,
GtkNotebook *notebook,
gboolean ignore_first_page)
{
- CcWacomPagePrivate *priv;
-
g_return_if_fail (CC_IS_WACOM_PAGE (page));
- priv = page->priv;
-
- g_object_set (G_OBJECT (priv->nav),
+ g_object_set (G_OBJECT (page->nav),
"notebook", notebook,
"ignore-first", ignore_first_page,
NULL);
diff --git a/panels/wacom/cc-wacom-page.h b/panels/wacom/cc-wacom-page.h
index 65cd12b..76a27dd 100644
--- a/panels/wacom/cc-wacom-page.h
+++ b/panels/wacom/cc-wacom-page.h
@@ -30,43 +30,7 @@ G_BEGIN_DECLS
#define CC_TYPE_WACOM_PAGE cc_wacom_page_get_type()
-#define CC_WACOM_PAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- CC_TYPE_WACOM_PAGE, CcWacomPage))
-
-#define CC_WACOM_PAGE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- CC_TYPE_WACOM_PAGE, CcWacomPageClass))
-
-#define CC_IS_WACOM_PAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- CC_TYPE_WACOM_PAGE))
-
-#define CC_IS_WACOM_PAGE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- CC_TYPE_WACOM_PAGE))
-
-#define CC_WACOM_PAGE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- CC_TYPE_WACOM_PAGE, CcWacomPageClass))
-
-typedef struct _CcWacomPage CcWacomPage;
-typedef struct _CcWacomPageClass CcWacomPageClass;
-typedef struct _CcWacomPagePrivate CcWacomPagePrivate;
-
-struct _CcWacomPage
-{
- GtkBox parent;
-
- CcWacomPagePrivate *priv;
-};
-
-struct _CcWacomPageClass
-{
- GtkBoxClass parent_class;
-};
-
-GType cc_wacom_page_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (CcWacomPage, cc_wacom_page, CC, WACOM_PAGE, GtkBox)
GtkWidget * cc_wacom_page_new (CcWacomPanel *panel,
CcWacomDevice *stylus,
diff --git a/panels/wacom/cc-wacom-stylus-page.c b/panels/wacom/cc-wacom-stylus-page.c
index c382945..6cbc1b7 100644
--- a/panels/wacom/cc-wacom-stylus-page.c
+++ b/panels/wacom/cc-wacom-stylus-page.c
@@ -29,22 +29,21 @@
#include <string.h>
-#define WID(x) (GtkWidget *) gtk_builder_get_object (priv->builder, x)
-#define CWID(x) (GtkContainer *) gtk_builder_get_object (priv->builder, x)
+#define WID(x) (GtkWidget *) gtk_builder_get_object (page->builder, x)
+#define CWID(x) (GtkContainer *) gtk_builder_get_object (page->builder, x)
-G_DEFINE_TYPE (CcWacomStylusPage, cc_wacom_stylus_page, GTK_TYPE_BOX)
-
-#define WACOM_STYLUS_PAGE_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPagePrivate))
-
-struct _CcWacomStylusPagePrivate
+struct _CcWacomStylusPage
{
+ GtkBox parent_instance;
+
CcWacomTool *stylus;
GtkBuilder *builder;
GtkWidget *nav;
GSettings *stylus_settings;
};
+G_DEFINE_TYPE (CcWacomStylusPage, cc_wacom_stylus_page, GTK_TYPE_BOX)
+
/* Button combo box storage columns */
enum {
BUTTONNUMBER_COLUMN,
@@ -86,13 +85,15 @@ set_pressurecurve (GtkRange *range, GSettings *settings, const gchar *key)
static void
tip_feel_value_changed_cb (GtkRange *range, gpointer user_data)
{
- set_pressurecurve (range, CC_WACOM_STYLUS_PAGE(user_data)->priv->stylus_settings, "pressure-curve");
+ CcWacomStylusPage *page = CC_WACOM_STYLUS_PAGE(user_data);
+ set_pressurecurve (range, page->stylus_settings, "pressure-curve");
}
static void
eraser_feel_value_changed_cb (GtkRange *range, gpointer user_data)
{
- set_pressurecurve (range, CC_WACOM_STYLUS_PAGE(user_data)->priv->stylus_settings,
"eraser-pressure-curve");
+ CcWacomStylusPage *page = CC_WACOM_STYLUS_PAGE(user_data);
+ set_pressurecurve (range, page->stylus_settings, "eraser-pressure-curve");
}
static void
@@ -156,7 +157,7 @@ set_button_mapping_from_gsettings (GtkComboBox *combo, GSettings* settings, cons
static void
button_changed_cb (GtkComboBox *combo, gpointer user_data)
{
- CcWacomStylusPagePrivate *priv = CC_WACOM_STYLUS_PAGE(user_data)->priv;
+ CcWacomStylusPage *page = CC_WACOM_STYLUS_PAGE(user_data);
GtkTreeIter iter;
GtkListStore *liststore;
gint mapping_b2,
@@ -170,7 +171,7 @@ button_changed_cb (GtkComboBox *combo, gpointer user_data)
BUTTONNUMBER_COLUMN, &mapping_b2,
-1);
- if (cc_wacom_tool_get_num_buttons (priv->stylus) > 1) {
+ if (cc_wacom_tool_get_num_buttons (page->stylus) > 1) {
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("combo-topbutton")), &iter))
return;
@@ -181,8 +182,8 @@ button_changed_cb (GtkComboBox *combo, gpointer user_data)
mapping_b3 = 0;
}
- g_settings_set_enum (priv->stylus_settings, "button-action", mapping_b2);
- g_settings_set_enum (priv->stylus_settings, "secondary-button-action", mapping_b3);
+ g_settings_set_enum (page->stylus_settings, "button-action", mapping_b2);
+ g_settings_set_enum (page->stylus_settings, "secondary-button-action", mapping_b3);
}
static void
@@ -227,11 +228,11 @@ cc_wacom_stylus_page_set_property (GObject *object,
static void
cc_wacom_stylus_page_dispose (GObject *object)
{
- CcWacomStylusPagePrivate *priv = CC_WACOM_STYLUS_PAGE (object)->priv;
+ CcWacomStylusPage *page = CC_WACOM_STYLUS_PAGE (object);
- if (priv->builder) {
- g_object_unref (priv->builder);
- priv->builder = NULL;
+ if (page->builder) {
+ g_object_unref (page->builder);
+ page->builder = NULL;
}
@@ -243,17 +244,14 @@ cc_wacom_stylus_page_class_init (CcWacomStylusPageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CcWacomStylusPagePrivate));
-
object_class->get_property = cc_wacom_stylus_page_get_property;
object_class->set_property = cc_wacom_stylus_page_set_property;
object_class->dispose = cc_wacom_stylus_page_dispose;
}
static void
-cc_wacom_stylus_page_init (CcWacomStylusPage *self)
+cc_wacom_stylus_page_init (CcWacomStylusPage *page)
{
- CcWacomStylusPagePrivate *priv;
GError *error = NULL;
GtkComboBox *combo;
GtkWidget *box;
@@ -265,45 +263,43 @@ cc_wacom_stylus_page_init (CcWacomStylusPage *self)
NULL
};
- priv = self->priv = WACOM_STYLUS_PAGE_PRIVATE (self);
-
- priv->builder = gtk_builder_new ();
+ page->builder = gtk_builder_new ();
- gtk_builder_add_objects_from_resource (priv->builder,
+ gtk_builder_add_objects_from_resource (page->builder,
"/org/gnome/control-center/wacom/wacom-stylus-page.ui",
objects,
&error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
- g_object_unref (priv->builder);
+ g_object_unref (page->builder);
g_error_free (error);
return;
}
box = WID ("stylus-grid");
- gtk_container_add (GTK_CONTAINER (self), box);
+ gtk_container_add (GTK_CONTAINER (page), box);
gtk_widget_set_vexpand (GTK_WIDGET (box), TRUE);
g_signal_connect (WID ("scale-tip-feel"), "value-changed",
- G_CALLBACK (tip_feel_value_changed_cb), self);
+ G_CALLBACK (tip_feel_value_changed_cb), page);
g_signal_connect (WID ("scale-eraser-feel"), "value-changed",
- G_CALLBACK (eraser_feel_value_changed_cb), self);
+ G_CALLBACK (eraser_feel_value_changed_cb), page);
combo = GTK_COMBO_BOX (WID ("combo-topbutton"));
combobox_text_cellrenderer (combo, BUTTONNAME_COLUMN);
g_signal_connect (G_OBJECT (combo), "changed",
- G_CALLBACK (button_changed_cb), self);
+ G_CALLBACK (button_changed_cb), page);
combo = GTK_COMBO_BOX (WID ("combo-bottombutton"));
combobox_text_cellrenderer (combo, BUTTONNAME_COLUMN);
g_signal_connect (G_OBJECT (combo), "changed",
- G_CALLBACK (button_changed_cb), self);
+ G_CALLBACK (button_changed_cb), page);
- priv->nav = cc_wacom_nav_button_new ();
- gtk_widget_set_halign (priv->nav, GTK_ALIGN_END);
- gtk_widget_set_margin_start (priv->nav, 10);
- gtk_widget_show (priv->nav);
- gtk_container_add (CWID ("navigation-placeholder"), priv->nav);
+ page->nav = cc_wacom_nav_button_new ();
+ gtk_widget_set_halign (page->nav, GTK_ALIGN_END);
+ gtk_widget_set_margin_start (page->nav, 10);
+ gtk_widget_show (page->nav);
+ gtk_container_add (CWID ("navigation-placeholder"), page->nav);
}
static void
@@ -311,11 +307,8 @@ set_icon_name (CcWacomStylusPage *page,
const char *widget_name,
const char *icon_name)
{
- CcWacomStylusPagePrivate *priv;
char *resource;
- priv = page->priv;
-
resource = g_strdup_printf ("/org/gnome/control-center/wacom/%s.svg", icon_name);
gtk_image_set_from_resource (GTK_IMAGE (WID (widget_name)), resource);
g_free (resource);
@@ -331,7 +324,7 @@ enum {
};
static void
-remove_buttons (CcWacomStylusPagePrivate *priv)
+remove_buttons (CcWacomStylusPage *page)
{
gtk_widget_destroy (WID ("combo-topbutton"));
gtk_widget_destroy (WID ("combo-bottombutton"));
@@ -340,7 +333,7 @@ remove_buttons (CcWacomStylusPagePrivate *priv)
}
static void
-remove_button (CcWacomStylusPagePrivate *priv)
+remove_button (CcWacomStylusPage *page)
{
gtk_widget_destroy (WID ("combo-topbutton"));
gtk_widget_destroy (WID ("label-top-button"));
@@ -348,7 +341,7 @@ remove_button (CcWacomStylusPagePrivate *priv)
}
static void
-remove_eraser (CcWacomStylusPagePrivate *priv)
+remove_eraser (CcWacomStylusPage *page)
{
gtk_widget_destroy (WID ("eraser-box"));
gtk_widget_destroy (WID ("label-eraser-feel"));
@@ -358,15 +351,13 @@ static void
update_stylus_ui (CcWacomStylusPage *page,
int layout)
{
- CcWacomStylusPagePrivate *priv = page->priv;
-
switch (layout) {
case LAYOUT_NORMAL:
/* easy! */
break;
case LAYOUT_INKING:
- remove_buttons (page->priv);
- remove_eraser (page->priv);
+ remove_buttons (page);
+ remove_eraser (page);
gtk_container_child_set (CWID ("stylus-controls-grid"),
WID ("label-tip-feel"),
"top_attach", 0, NULL);
@@ -375,7 +366,7 @@ update_stylus_ui (CcWacomStylusPage *page,
"top_attach", 0, NULL);
break;
case LAYOUT_AIRBRUSH:
- remove_button (page->priv);
+ remove_button (page);
gtk_container_child_set (CWID ("stylus-controls-grid"),
WID ("label-lower-button"),
"top_attach", 1, NULL);
@@ -390,7 +381,7 @@ update_stylus_ui (CcWacomStylusPage *page,
"top_attach", 2, NULL);
break;
case LAYOUT_GENERIC_2_BUTTONS_NO_ERASER:
- remove_eraser (page->priv);
+ remove_eraser (page);
break;
case LAYOUT_OTHER:
/* We already warn about it in cc_wacom_stylus_page_new () */
@@ -402,7 +393,6 @@ GtkWidget *
cc_wacom_stylus_page_new (CcWacomTool *stylus)
{
CcWacomStylusPage *page;
- CcWacomStylusPagePrivate *priv;
guint num_buttons;
int layout;
gboolean has_eraser;
@@ -411,14 +401,13 @@ cc_wacom_stylus_page_new (CcWacomTool *stylus)
page = g_object_new (CC_TYPE_WACOM_STYLUS_PAGE, NULL);
- priv = page->priv;
- priv->stylus = stylus;
+ page->stylus = stylus;
/* Icon */
set_icon_name (page, "image-stylus", cc_wacom_tool_get_icon_name (stylus));
/* Settings */
- priv->stylus_settings = cc_wacom_tool_get_settings (stylus);
+ page->stylus_settings = cc_wacom_tool_get_settings (stylus);
has_eraser = cc_wacom_tool_get_has_eraser (stylus);
/* Stylus name */
@@ -436,9 +425,9 @@ cc_wacom_stylus_page_new (CcWacomTool *stylus)
else {
layout = LAYOUT_OTHER;
if (num_buttons == 0)
- remove_buttons (priv);
+ remove_buttons (page);
else if (num_buttons == 1)
- remove_button (priv);
+ remove_button (page);
/* Gray out eraser if not available */
gtk_widget_set_sensitive (WID ("eraser-box"), has_eraser);
@@ -452,16 +441,16 @@ cc_wacom_stylus_page_new (CcWacomTool *stylus)
if (num_buttons == 2)
set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-topbutton")),
- priv->stylus_settings, "secondary-button-action");
+ page->stylus_settings, "secondary-button-action");
if (num_buttons >= 1)
set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-bottombutton")),
- priv->stylus_settings, "button-action");
+ page->stylus_settings, "button-action");
set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-tip-feel")),
- priv->stylus_settings, "pressure-curve");
+ page->stylus_settings, "pressure-curve");
if (has_eraser)
set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-eraser-feel")),
- priv->stylus_settings, "eraser-pressure-curve");
+ page->stylus_settings, "eraser-pressure-curve");
return GTK_WIDGET (page);
}
@@ -469,20 +458,16 @@ cc_wacom_stylus_page_new (CcWacomTool *stylus)
CcWacomTool *
cc_wacom_stylus_page_get_tool (CcWacomStylusPage *page)
{
- return page->priv->stylus;
+ return page->stylus;
}
void
cc_wacom_stylus_page_set_navigation (CcWacomStylusPage *page,
GtkNotebook *notebook)
{
- CcWacomStylusPagePrivate *priv;
-
g_return_if_fail (CC_IS_WACOM_STYLUS_PAGE (page));
- priv = page->priv;
-
- g_object_set (G_OBJECT (priv->nav),
+ g_object_set (G_OBJECT (page->nav),
"notebook", notebook,
"ignore-first", TRUE,
NULL);
diff --git a/panels/wacom/cc-wacom-stylus-page.h b/panels/wacom/cc-wacom-stylus-page.h
index 19d3a07..42e0726 100644
--- a/panels/wacom/cc-wacom-stylus-page.h
+++ b/panels/wacom/cc-wacom-stylus-page.h
@@ -29,43 +29,7 @@ G_BEGIN_DECLS
#define CC_TYPE_WACOM_STYLUS_PAGE cc_wacom_stylus_page_get_type()
-#define CC_WACOM_STYLUS_PAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPage))
-
-#define CC_WACOM_STYLUS_PAGE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPageClass))
-
-#define CC_IS_WACOM_STYLUS_PAGE(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- CC_TYPE_WACOM_STYLUS_PAGE))
-
-#define CC_IS_WACOM_STYLUS_PAGE_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- CC_TYPE_WACOM_STYLUS_PAGE))
-
-#define CC_WACOM_STYLUS_PAGE_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPageClass))
-
-typedef struct _CcWacomStylusPage CcWacomStylusPage;
-typedef struct _CcWacomStylusPageClass CcWacomStylusPageClass;
-typedef struct _CcWacomStylusPagePrivate CcWacomStylusPagePrivate;
-
-struct _CcWacomStylusPage
-{
- GtkBox parent;
-
- CcWacomStylusPagePrivate *priv;
-};
-
-struct _CcWacomStylusPageClass
-{
- GtkBoxClass parent_class;
-};
-
-GType cc_wacom_stylus_page_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (CcWacomStylusPage, cc_wacom_stylus_page, CC, WACOM_STYLUS_PAGE, GtkBox)
GtkWidget * cc_wacom_stylus_page_new (CcWacomTool *stylus);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]