[gnome-control-center] wacom: Replace GObject boilerplate with G_DECLARE_TYPE
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wacom: Replace GObject boilerplate with G_DECLARE_TYPE
- Date: Thu, 2 Aug 2018 23:05:56 +0000 (UTC)
commit aeca65c729e83bde85fa0c9e8a5e3a695dac97c2
Author: Robert Ancell <robert ancell canonical com>
Date: Sun Jun 3 09:42:43 2018 +0400
wacom: Replace GObject boilerplate with G_DECLARE_TYPE
panels/wacom/calibrator/cc-clock-actor.c | 7 +
panels/wacom/calibrator/cc-clock-actor.h | 26 +--
panels/wacom/calibrator/cc-target-actor.c | 30 +--
panels/wacom/calibrator/cc-target-actor.h | 28 +--
panels/wacom/cc-drawing-area.h | 7 +-
panels/wacom/cc-tablet-tool-map.h | 1 -
panels/wacom/cc-wacom-button-row.c | 55 +++---
panels/wacom/cc-wacom-button-row.h | 24 +--
panels/wacom/cc-wacom-device.h | 1 -
panels/wacom/cc-wacom-mapping-panel.c | 130 +++++++------
panels/wacom/cc-wacom-mapping-panel.h | 42 +----
panels/wacom/cc-wacom-nav-button.c | 120 ++++++------
panels/wacom/cc-wacom-nav-button.h | 41 +---
panels/wacom/cc-wacom-page.c | 264 +++++++++++---------------
panels/wacom/cc-wacom-page.h | 41 +---
panels/wacom/cc-wacom-panel.c | 267 ++++++++++++---------------
panels/wacom/cc-wacom-panel.h | 41 +---
panels/wacom/cc-wacom-stylus-page.c | 127 ++++++-------
panels/wacom/cc-wacom-stylus-page.h | 41 +---
panels/wacom/cc-wacom-tool.h | 1 -
panels/wacom/gsd-wacom-key-shortcut-button.c | 128 ++++++-------
panels/wacom/gsd-wacom-key-shortcut-button.h | 32 +---
22 files changed, 522 insertions(+), 932 deletions(-)
---
diff --git a/panels/wacom/calibrator/cc-clock-actor.c b/panels/wacom/calibrator/cc-clock-actor.c
index afe2d9d72..c84fb5bc4 100644
--- a/panels/wacom/calibrator/cc-clock-actor.c
+++ b/panels/wacom/calibrator/cc-clock-actor.c
@@ -27,6 +27,13 @@
#define ANGLE "angle"
#define EXTRA_SPACE 2
+struct _CcClockActor
+{
+ ClutterActor parent_instance;
+
+ gfloat angle;
+};
+
G_DEFINE_TYPE (CcClockActor, cc_clock_actor, CLUTTER_TYPE_ACTOR);
enum {
diff --git a/panels/wacom/calibrator/cc-clock-actor.h b/panels/wacom/calibrator/cc-clock-actor.h
index 5ba1a818c..f6e2b2e97 100644
--- a/panels/wacom/calibrator/cc-clock-actor.h
+++ b/panels/wacom/calibrator/cc-clock-actor.h
@@ -25,31 +25,11 @@
G_BEGIN_DECLS
-#define CC_CLOCK_ACTOR_TYPE (cc_clock_actor_get_type ())
-#define CC_CLOCK_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_CLOCK_ACTOR_TYPE,
CcClockActor))
-#define CC_IS_CLOCK_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_CLOCK_ACTOR_TYPE))
-#define CC_CLOCK_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_CLOCK_ACTOR_TYPE,
CcClockActorClass))
-#define CC_IS_CLOCK_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_CLOCK_ACTOR_TYPE))
-#define CC_CLOCK_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_CLOCK_ACTOR_TYPE,
CcClockActorClass))
-
-typedef struct _CcClockActor CcClockActor;
-typedef struct _CcClockActorClass CcClockActorClass;
-
-struct _CcClockActor
-{
- ClutterActor parent_instance;
-
- /*< private >*/
- gfloat angle;
-};
-
-struct _CcClockActorClass
-{
- ClutterActorClass parent_class;
-};
+#define CC_CLOCK_ACTOR_TYPE (cc_clock_actor_get_type ())
+G_DECLARE_FINAL_TYPE (CcClockActor, cc_clock_actor, CC, CLOCK_ACTOR, ClutterActor)
ClutterActor * cc_clock_actor_new (void);
-GType cc_clock_actor_get_type (void);
+G_END_DECLS
#endif /* __CC_CLOCK_ACTOR_H__ */
diff --git a/panels/wacom/calibrator/cc-target-actor.c b/panels/wacom/calibrator/cc-target-actor.c
index 34fa1e3ee..b75d877a2 100644
--- a/panels/wacom/calibrator/cc-target-actor.c
+++ b/panels/wacom/calibrator/cc-target-actor.c
@@ -20,8 +20,6 @@
#include <math.h>
#include "cc-target-actor.h"
-#define CC_TARGET_ACTOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TARGET_ACTOR_TYPE,
CcTargetActorPrivate))
-
#define CROSS_LINES 47
#define TARGET_DIMENSION (CROSS_LINES * 2)
#define CROSS_CIRCLE 7
@@ -29,8 +27,10 @@
#define TARGET_SHOW_ANIMATION_DURATION 500
#define TARGET_HIDE_ANIMATION_DURATION 200
-struct _CcTargetActorPrivate
+struct _CcTargetActor
{
+ ClutterActor parent_instance;
+
gdouble pos_x;
gdouble pos_y;
};
@@ -87,13 +87,10 @@ static void
on_target_animation_complete (ClutterTimeline *timeline,
CcTargetActor *self)
{
- CcTargetActorPrivate *priv;
- priv = CC_TARGET_ACTOR_GET_PRIVATE (self);
-
clutter_actor_show (CLUTTER_ACTOR (self));
clutter_actor_set_position (CLUTTER_ACTOR (self),
- priv->pos_x,
- priv->pos_y);
+ self->pos_x,
+ self->pos_y);
show_target (self);
}
@@ -132,11 +129,9 @@ cc_target_actor_init (CcTargetActor *self)
{
ClutterContent *content;
ClutterPoint anchor;
- CcTargetActorPrivate *priv;
- priv = CC_TARGET_ACTOR_GET_PRIVATE (self);
- priv->pos_x = .0;
- priv->pos_y = .0;
+ self->pos_x = .0;
+ self->pos_y = .0;
content = clutter_canvas_new ();
clutter_actor_set_content (CLUTTER_ACTOR (self), content);
@@ -185,8 +180,6 @@ cc_target_actor_class_init (CcTargetActorClass *klass)
clutter_actor_class->get_preferred_width = cc_target_actor_get_preferred_width;
clutter_actor_class->get_preferred_height = cc_target_actor_get_preferred_height;
-
- g_type_class_add_private (klass, sizeof (CcTargetActorPrivate));
}
@@ -196,14 +189,11 @@ cc_target_actor_move_center (CcTargetActor *self, gdouble x, gdouble y)
{
g_return_if_fail (CC_IS_TARGET_ACTOR (self));
- CcTargetActorPrivate *priv;
ClutterTransition *transition;
gboolean target_visible;
- priv = CC_TARGET_ACTOR_GET_PRIVATE (self);
-
- priv->pos_x = x - (TARGET_DIMENSION / 2);
- priv->pos_y = y - (TARGET_DIMENSION / 2);
+ self->pos_x = x - (TARGET_DIMENSION / 2);
+ self->pos_y = y - (TARGET_DIMENSION / 2);
g_object_get (self, "visible", &target_visible, NULL);
@@ -223,7 +213,7 @@ cc_target_actor_move_center (CcTargetActor *self, gdouble x, gdouble y)
{
clutter_actor_show (CLUTTER_ACTOR (self));
- clutter_actor_set_position (CLUTTER_ACTOR (self), priv->pos_x, priv->pos_y);
+ clutter_actor_set_position (CLUTTER_ACTOR (self), self->pos_x, self->pos_y);
show_target (self);
}
diff --git a/panels/wacom/calibrator/cc-target-actor.h b/panels/wacom/calibrator/cc-target-actor.h
index 891f48cc1..9ac7c2f58 100644
--- a/panels/wacom/calibrator/cc-target-actor.h
+++ b/panels/wacom/calibrator/cc-target-actor.h
@@ -25,35 +25,15 @@
G_BEGIN_DECLS
-#define CC_TARGET_ACTOR_TYPE (cc_target_actor_get_type ())
-#define CC_TARGET_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TARGET_ACTOR_TYPE,
CcTargetActor))
-#define CC_IS_TARGET_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TARGET_ACTOR_TYPE))
-#define CC_TARGET_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TARGET_ACTOR_TYPE,
CcTargetActorClass))
-#define CC_IS_TARGET_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TARGET_ACTOR_TYPE))
-#define CC_TARGET_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TARGET_ACTOR_TYPE,
CcTargetActorClass))
-
-typedef struct _CcTargetActor CcTargetActor;
-typedef struct _CcTargetActorClass CcTargetActorClass;
-typedef struct _CcTargetActorPrivate CcTargetActorPrivate;
-
-struct _CcTargetActor
-{
- ClutterActor parent_instance;
-
- /*< private >*/
- CcTargetActorPrivate *priv;
-};
-
-struct _CcTargetActorClass
-{
- ClutterActorClass parent_class;
-};
+#define CC_TARGET_ACTOR_TYPE (cc_target_actor_get_type ())
+G_DECLARE_FINAL_TYPE (CcTargetActor, cc_target_actor, CC, TARGET_ACTOR, ClutterActor)
ClutterActor * cc_target_actor_new (void);
+
void cc_target_actor_move_center (CcTargetActor *target,
gdouble x,
gdouble y);
-GType cc_target_actor_get_type (void);
+G_END_DECLS
#endif /* __CC_TARGET_ACTOR_H__ */
diff --git a/panels/wacom/cc-drawing-area.h b/panels/wacom/cc-drawing-area.h
index a994f48c2..936716350 100644
--- a/panels/wacom/cc-drawing-area.h
+++ b/panels/wacom/cc-drawing-area.h
@@ -24,13 +24,10 @@
G_BEGIN_DECLS
-#define CC_TYPE_DRAWING_AREA cc_drawing_area_get_type()
-
+#define CC_TYPE_DRAWING_AREA (cc_drawing_area_get_type ())
G_DECLARE_FINAL_TYPE (CcDrawingArea, cc_drawing_area, CC, DRAWING_AREA, GtkEventBox)
-GType cc_drawing_area_get_type (void) G_GNUC_CONST;
-
-GtkWidget *cc_drawing_area_new (void);
+GtkWidget *cc_drawing_area_new (void);
G_END_DECLS
diff --git a/panels/wacom/cc-tablet-tool-map.h b/panels/wacom/cc-tablet-tool-map.h
index 24632021a..5e542a826 100644
--- a/panels/wacom/cc-tablet-tool-map.h
+++ b/panels/wacom/cc-tablet-tool-map.h
@@ -29,7 +29,6 @@
G_BEGIN_DECLS
#define CC_TYPE_TABLET_TOOL_MAP (cc_tablet_tool_map_get_type ())
-
G_DECLARE_FINAL_TYPE (CcTabletToolMap, cc_tablet_tool_map, CC, TABLET_TOOL_MAP, GObject)
CcTabletToolMap * cc_tablet_tool_map_new (void);
diff --git a/panels/wacom/cc-wacom-button-row.c b/panels/wacom/cc-wacom-button-row.c
index 52b1d00aa..c897d7d6c 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 ee6ecbb67..91cb17e4d 100644
--- a/panels/wacom/cc-wacom-button-row.h
+++ b/panels/wacom/cc-wacom-button-row.h
@@ -25,26 +25,8 @@
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))
-
-typedef struct _CcWacomButtonRow CcWacomButtonRow;
-typedef struct _CcWacomButtonRowClass CcWacomButtonRowClass;
-typedef struct _CcWacomButtonRowPrivate CcWacomButtonRowPrivate;
-
-struct _CcWacomButtonRow {
- GtkListBoxRow parent;
-
- CcWacomButtonRowPrivate *priv;
-};
-
-struct _CcWacomButtonRowClass {
- GtkListBoxRowClass parent_class;
-};
+#define CC_WACOM_TYPE_BUTTON_ROW (cc_wacom_button_row_get_type ())
+G_DECLARE_FINAL_TYPE (CcWacomButtonRow, cc_wacom_button_row, CC, WACOM_BUTTON_ROW, GtkListBoxRow)
static struct {
GDesktopPadButtonAction action_type;
@@ -56,8 +38,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-device.h b/panels/wacom/cc-wacom-device.h
index 856065b4c..ffc46f61b 100644
--- a/panels/wacom/cc-wacom-device.h
+++ b/panels/wacom/cc-wacom-device.h
@@ -30,7 +30,6 @@
#include <libgnome-desktop/gnome-rr.h>
#define CC_TYPE_WACOM_DEVICE (cc_wacom_device_get_type ())
-
G_DECLARE_FINAL_TYPE (CcWacomDevice, cc_wacom_device, CC, WACOM_DEVICE, GObject)
WacomDeviceDatabase *
diff --git a/panels/wacom/cc-wacom-mapping-panel.c b/panels/wacom/cc-wacom-mapping-panel.c
index 506a4e873..60664d331 100644
--- a/panels/wacom/cc-wacom-mapping-panel.c
+++ b/panels/wacom/cc-wacom-mapping-panel.c
@@ -31,13 +31,10 @@
#include "cc-wacom-device.h"
#include "cc-wacom-mapping-panel.h"
-G_DEFINE_TYPE (CcWacomMappingPanel, cc_wacom_mapping_panel, GTK_TYPE_BOX)
-
-#define WACOM_MAPPING_PANEL_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_WACOM_MAPPING_PANEL, CcWacomMappingPanelPrivate))
-
-struct _CcWacomMappingPanelPrivate
+struct _CcWacomMappingPanel
{
+ GtkBox parent_instance;
+
CcWacomDevice *device;
GtkWidget *label;
GtkWidget *combobox;
@@ -48,6 +45,8 @@ struct _CcWacomMappingPanelPrivate
GnomeRRScreen *rr_screen;
};
+G_DEFINE_TYPE (CcWacomMappingPanel, cc_wacom_mapping_panel, GTK_TYPE_BOX)
+
enum {
MONITOR_NAME_COLUMN,
MONITOR_PTR_COLUMN,
@@ -62,10 +61,10 @@ static void
set_combobox_sensitive (CcWacomMappingPanel *self,
gboolean sensitive)
{
- gtk_widget_set_sensitive (GTK_WIDGET(self->priv->combobox), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET(self->priv->label), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET(self->priv->aspectswitch), sensitive);
- gtk_widget_set_sensitive (GTK_WIDGET(self->priv->aspectlabel), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET(self->combobox), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET(self->label), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET(self->aspectswitch), sensitive);
+ gtk_widget_set_sensitive (GTK_WIDGET(self->aspectlabel), sensitive);
}
/* Update the display of available monitors based on the latest
@@ -85,32 +84,32 @@ update_monitor_chooser (CcWacomMappingPanel *self)
guint i;
store = gtk_list_store_new (MONITOR_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
- gtk_combo_box_set_model (GTK_COMBO_BOX(self->priv->combobox), GTK_TREE_MODEL(store));
+ gtk_combo_box_set_model (GTK_COMBO_BOX(self->combobox), GTK_TREE_MODEL(store));
- if (self->priv->device == NULL) {
+ if (self->device == NULL) {
set_combobox_sensitive (self, FALSE);
g_object_unref (store);
return;
}
- settings = cc_wacom_device_get_settings (self->priv->device);
- cur_output = cc_wacom_device_get_output (self->priv->device,
- self->priv->rr_screen);
+ settings = cc_wacom_device_get_settings (self->device);
+ cur_output = cc_wacom_device_get_output (self->device,
+ self->rr_screen);
- g_signal_handlers_block_by_func (G_OBJECT (self->priv->checkbutton), checkbutton_toggled_cb, self);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(self->priv->checkbutton), cur_output != NULL);
- g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->checkbutton), checkbutton_toggled_cb, self);
+ g_signal_handlers_block_by_func (G_OBJECT (self->checkbutton), checkbutton_toggled_cb, self);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(self->checkbutton), cur_output != NULL);
+ g_signal_handlers_unblock_by_func (G_OBJECT (self->checkbutton), checkbutton_toggled_cb, self);
- g_signal_handlers_block_by_func (G_OBJECT (self->priv->aspectswitch), aspectswitch_toggled_cb, self);
- gtk_switch_set_active (GTK_SWITCH(self->priv->aspectswitch), g_settings_get_boolean (settings,
"keep-aspect"));
- g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->aspectswitch), aspectswitch_toggled_cb,
self);
+ g_signal_handlers_block_by_func (G_OBJECT (self->aspectswitch), aspectswitch_toggled_cb, self);
+ gtk_switch_set_active (GTK_SWITCH(self->aspectswitch), g_settings_get_boolean (settings,
"keep-aspect"));
+ g_signal_handlers_unblock_by_func (G_OBJECT (self->aspectswitch), aspectswitch_toggled_cb, self);
- if (!self->priv->rr_screen) {
+ if (!self->rr_screen) {
cur_output = NULL;
goto bail;
}
- outputs = gnome_rr_screen_list_outputs (self->priv->rr_screen);
+ outputs = gnome_rr_screen_list_outputs (self->rr_screen);
for (i = 0; outputs[i] != NULL; i++) {
GnomeRROutput *output = outputs[i];
@@ -130,9 +129,9 @@ update_monitor_chooser (CcWacomMappingPanel *self)
gtk_list_store_set (store, &iter, MONITOR_NAME_COLUMN, text, MONITOR_PTR_COLUMN,
output, -1);
if (i == 0 || output == cur_output) {
- g_signal_handlers_block_by_func (G_OBJECT (self->priv->combobox),
combobox_changed_cb, self);
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX(self->priv->combobox), &iter);
- g_signal_handlers_unblock_by_func (G_OBJECT (self->priv->combobox),
combobox_changed_cb, self);
+ g_signal_handlers_block_by_func (G_OBJECT (self->combobox),
combobox_changed_cb, self);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX(self->combobox), &iter);
+ g_signal_handlers_unblock_by_func (G_OBJECT (self->combobox),
combobox_changed_cb, self);
}
g_free (text);
@@ -147,18 +146,18 @@ bail:
static void
update_ui (CcWacomMappingPanel *self)
{
- if (self->priv->device == NULL) {
- gtk_widget_set_sensitive (GTK_WIDGET(self->priv->checkbutton), FALSE);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON(self->priv->checkbutton), TRUE);
+ if (self->device == NULL) {
+ gtk_widget_set_sensitive (GTK_WIDGET(self->checkbutton), FALSE);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON(self->checkbutton), TRUE);
} else {
gboolean is_screen_tablet;
is_screen_tablet =
- cc_wacom_device_get_integration_flags (self->priv->device) &
+ cc_wacom_device_get_integration_flags (self->device) &
WACOM_DEVICE_INTEGRATED_DISPLAY;
- gtk_widget_set_sensitive (GTK_WIDGET(self->priv->checkbutton), !is_screen_tablet);
- gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON(self->priv->checkbutton), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET(self->checkbutton), !is_screen_tablet);
+ gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON(self->checkbutton), FALSE);
}
update_monitor_chooser (self);
@@ -169,13 +168,13 @@ update_mapping (CcWacomMappingPanel *self)
{
GnomeRROutput *output = NULL;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->checkbutton))) {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->checkbutton))) {
GtkTreeIter iter;
GtkTreeModel *model;
char *name;
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->priv->combobox));
- if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->priv->combobox), &iter)) {
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (self->combobox));
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->combobox), &iter)) {
g_warning ("Map to single monitor checked, but no screen selected.");
return;
}
@@ -183,14 +182,14 @@ update_mapping (CcWacomMappingPanel *self)
gtk_tree_model_get (model, &iter, MONITOR_NAME_COLUMN, &name, MONITOR_PTR_COLUMN, &output,
-1);
}
- cc_wacom_device_set_output (self->priv->device, output);
+ cc_wacom_device_set_output (self->device, output);
}
void
cc_wacom_mapping_panel_set_device (CcWacomMappingPanel *self,
CcWacomDevice *device)
{
- self->priv->device = device;
+ self->device = device;
update_ui (self);
}
@@ -203,7 +202,7 @@ checkbutton_toggled_cb (GtkWidget *widget,
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
set_combobox_sensitive (self, active);
if (!active)
- gtk_switch_set_active (GTK_SWITCH(self->priv->aspectswitch), FALSE);
+ gtk_switch_set_active (GTK_SWITCH(self->aspectswitch), FALSE);
update_mapping (self);
}
@@ -214,7 +213,7 @@ aspectswitch_toggled_cb (GtkWidget *widget,
{
GSettings *settings;
- settings = cc_wacom_device_get_settings (self->priv->device);
+ settings = cc_wacom_device_get_settings (self->device);
g_settings_set_boolean (settings,
"keep-aspect",
gtk_switch_get_active (GTK_SWITCH (widget)));
@@ -230,21 +229,18 @@ combobox_changed_cb (GtkWidget *widget,
static void
cc_wacom_mapping_panel_init (CcWacomMappingPanel *self)
{
- CcWacomMappingPanelPrivate *priv;
GtkWidget *vbox, *grid;
GtkCellRenderer *renderer;
GError *error = NULL;
- priv = self->priv = WACOM_MAPPING_PANEL_PRIVATE (self);
-
- priv->rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
+ self->rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), &error);
if (error) {
g_warning ("Could not get RR screen: %s", error->message);
g_error_free (error);
}
- g_signal_connect_swapped (priv->rr_screen, "changed",
+ g_signal_connect_swapped (self->rr_screen, "changed",
G_CALLBACK (update_monitor_chooser), self);
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
@@ -257,35 +253,35 @@ cc_wacom_mapping_panel_init (CcWacomMappingPanel *self)
grid = gtk_grid_new();
gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
gtk_grid_set_column_spacing (GTK_GRID (grid), 10);
- priv->label = gtk_label_new (_("Output:"));
- gtk_widget_set_halign (priv->label, GTK_ALIGN_END);
- priv->combobox = gtk_combo_box_new ();
- g_signal_connect (G_OBJECT (priv->combobox), "changed",
+ self->label = gtk_label_new (_("Output:"));
+ gtk_widget_set_halign (self->label, GTK_ALIGN_END);
+ self->combobox = gtk_combo_box_new ();
+ g_signal_connect (G_OBJECT (self->combobox), "changed",
G_CALLBACK (combobox_changed_cb), self);
renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(priv->combobox), renderer, TRUE);
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(priv->combobox), renderer, "text", 0);
- gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->label), 0, 0, 1, 1);
- gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->combobox), 1, 0, 1, 1);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(self->combobox), renderer, TRUE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT(self->combobox), renderer, "text", 0);
+ gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(self->label), 0, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(self->combobox), 1, 0, 1, 1);
/* Keep ratio switch */
- priv->aspectlabel = gtk_label_new (_("Keep aspect ratio (letterbox):"));
- gtk_widget_set_halign (priv->aspectlabel, GTK_ALIGN_END);
- priv->aspectswitch = gtk_switch_new ();
- gtk_widget_set_halign (priv->aspectswitch, GTK_ALIGN_START);
- gtk_switch_set_active (GTK_SWITCH (priv->aspectswitch), FALSE);
- g_signal_connect (GTK_SWITCH (priv->aspectswitch), "notify::active",
+ self->aspectlabel = gtk_label_new (_("Keep aspect ratio (letterbox):"));
+ gtk_widget_set_halign (self->aspectlabel, GTK_ALIGN_END);
+ self->aspectswitch = gtk_switch_new ();
+ gtk_widget_set_halign (self->aspectswitch, GTK_ALIGN_START);
+ gtk_switch_set_active (GTK_SWITCH (self->aspectswitch), FALSE);
+ g_signal_connect (GTK_SWITCH (self->aspectswitch), "notify::active",
G_CALLBACK (aspectswitch_toggled_cb), self);
- gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->aspectlabel), 0, 1, 1, 1);
- gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(priv->aspectswitch), 1, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(self->aspectlabel), 0, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID(grid), GTK_WIDGET(self->aspectswitch), 1, 1, 1, 1);
/* Whole-desktop checkbox */
- priv->checkbutton = gtk_check_button_new_with_label (_("Map to single monitor"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->checkbutton), FALSE);
- g_signal_connect (G_OBJECT (priv->checkbutton), "toggled",
+ self->checkbutton = gtk_check_button_new_with_label (_("Map to single monitor"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbutton), FALSE);
+ g_signal_connect (G_OBJECT (self->checkbutton), "toggled",
G_CALLBACK (checkbutton_toggled_cb), self);
- gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(priv->checkbutton),
+ gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(self->checkbutton),
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET(grid),
FALSE, FALSE, 8);
@@ -301,7 +297,7 @@ cc_wacom_mapping_panel_new (void)
CcWacomMappingPanel *panel;
panel = CC_WACOM_MAPPING_PANEL(g_object_new (CC_TYPE_WACOM_MAPPING_PANEL, NULL));
- panel->priv->device = NULL;
+ panel->device = NULL;
return GTK_WIDGET(panel);
}
@@ -337,7 +333,7 @@ cc_wacom_mapping_panel_dispose (GObject *object)
{
CcWacomMappingPanel *self = CC_WACOM_MAPPING_PANEL (object);
- g_clear_object (&self->priv->rr_screen);
+ g_clear_object (&self->rr_screen);
G_OBJECT_CLASS (cc_wacom_mapping_panel_parent_class)->dispose (object);
}
@@ -347,8 +343,6 @@ cc_wacom_mapping_panel_class_init (CcWacomMappingPanelClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CcWacomMappingPanelPrivate));
-
object_class->get_property = cc_wacom_mapping_panel_get_property;
object_class->set_property = cc_wacom_mapping_panel_set_property;
object_class->dispose = cc_wacom_mapping_panel_dispose;
diff --git a/panels/wacom/cc-wacom-mapping-panel.h b/panels/wacom/cc-wacom-mapping-panel.h
index ae9dabb73..211126761 100644
--- a/panels/wacom/cc-wacom-mapping-panel.h
+++ b/panels/wacom/cc-wacom-mapping-panel.h
@@ -26,49 +26,11 @@
G_BEGIN_DECLS
-#define CC_TYPE_WACOM_MAPPING_PANEL cc_wacom_mapping_panel_get_type()
-
-#define CC_WACOM_MAPPING_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- CC_TYPE_WACOM_MAPPING_PANEL, CcWacomMappingPanel))
-
-#define CC_WACOM_MAPPING_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- CC_TYPE_WACOM_MAPPING_PANEL, CcWacomMappignPanelClass))
-
-#define CC_IS_WACOM_MAPPING_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- CC_TYPE_WACOM_MAPPING_PANEL))
-
-#define CC_IS_WACOM_MAPPING_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- CC_TYPE_WACOM_MAPPING_PANEL))
-
-#define CC_WACOM_MAPPING_PANEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- CC_TYPE_WACOM_MAPPING_PANEL, CcWacomMappingPanelClass))
-
-typedef struct _CcWacomMappingPanel CcWacomMappingPanel;
-typedef struct _CcWacomMappingPanelClass CcWacomMappingPanelClass;
-typedef struct _CcWacomMappingPanelPrivate CcWacomMappingPanelPrivate;
-
-struct _CcWacomMappingPanel
-{
- GtkBox parent;
-
- CcWacomMappingPanelPrivate *priv;
-};
-
-struct _CcWacomMappingPanelClass
-{
- GtkBoxClass parent_class;
-};
-
-GType cc_wacom_mapping_panel_get_type (void) G_GNUC_CONST;
+#define CC_TYPE_WACOM_MAPPING_PANEL (cc_wacom_mapping_panel_get_type ())
+G_DECLARE_FINAL_TYPE (CcWacomMappingPanel, cc_wacom_mapping_panel, CC, WACOM_MAPPING_PANEL, GtkBox)
GtkWidget * cc_wacom_mapping_panel_new (void);
-
void cc_wacom_mapping_panel_set_device (CcWacomMappingPanel *self,
CcWacomDevice *device);
diff --git a/panels/wacom/cc-wacom-nav-button.c b/panels/wacom/cc-wacom-nav-button.c
index ae7a89d50..938f79f6a 100644
--- a/panels/wacom/cc-wacom-nav-button.c
+++ b/panels/wacom/cc-wacom-nav-button.c
@@ -25,13 +25,10 @@
#include "cc-wacom-nav-button.h"
-G_DEFINE_TYPE (CcWacomNavButton, cc_wacom_nav_button, GTK_TYPE_BOX)
-
-#define WACOM_NAV_BUTTON_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_WACOM_NAV_BUTTON, CcWacomNavButtonPrivate))
-
-struct _CcWacomNavButtonPrivate
+struct _CcWacomNavButton
{
+ GtkBox parent_instance;
+
GtkNotebook *notebook;
GtkWidget *label;
GtkWidget *prev;
@@ -42,6 +39,8 @@ struct _CcWacomNavButtonPrivate
gboolean ignore_first_page;
};
+G_DEFINE_TYPE (CcWacomNavButton, cc_wacom_nav_button, GTK_TYPE_BOX)
+
enum {
PROP_0,
PROP_NOTEBOOK,
@@ -51,23 +50,22 @@ enum {
static void
cc_wacom_nav_button_update (CcWacomNavButton *nav)
{
- CcWacomNavButtonPrivate *priv = nav->priv;
int num_pages;
int current_page;
char *text;
- if (priv->notebook == NULL) {
+ if (nav->notebook == NULL) {
gtk_widget_hide (GTK_WIDGET (nav));
return;
}
- num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+ num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nav->notebook));
if (num_pages == 0)
return;
- if (priv->ignore_first_page && num_pages == 1)
+ if (nav->ignore_first_page && num_pages == 1)
return;
- if (priv->ignore_first_page)
+ if (nav->ignore_first_page)
num_pages--;
g_assert (num_pages >= 1);
@@ -75,18 +73,18 @@ cc_wacom_nav_button_update (CcWacomNavButton *nav)
gtk_revealer_set_reveal_child (GTK_REVEALER (gtk_widget_get_parent (GTK_WIDGET (nav))),
num_pages > 1);
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
+ current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (nav->notebook));
if (current_page < 0)
return;
- if (priv->ignore_first_page)
+ if (nav->ignore_first_page)
current_page--;
- gtk_widget_set_sensitive (priv->prev, current_page == 0 ? FALSE : TRUE);
- gtk_widget_set_sensitive (priv->next, current_page + 1 == num_pages ? FALSE : TRUE);
+ gtk_widget_set_sensitive (nav->prev, current_page == 0 ? FALSE : TRUE);
+ gtk_widget_set_sensitive (nav->next, current_page + 1 == num_pages ? FALSE : TRUE);
text = g_strdup_printf (_("%d of %d"),
current_page + 1,
num_pages);
- gtk_label_set_text (GTK_LABEL (priv->label), text);
+ gtk_label_set_text (GTK_LABEL (nav->label), text);
}
static void
@@ -112,9 +110,9 @@ next_clicked (GtkButton *button,
{
int current_page;
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (nav->priv->notebook));
+ current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (nav->notebook));
current_page++;
- gtk_notebook_set_current_page (GTK_NOTEBOOK (nav->priv->notebook), current_page);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (nav->notebook), current_page);
}
static void
@@ -123,9 +121,9 @@ prev_clicked (GtkButton *button,
{
int current_page;
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (nav->priv->notebook));
+ current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (nav->notebook));
current_page--;
- gtk_notebook_set_current_page (GTK_NOTEBOOK (nav->priv->notebook), current_page--);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (nav->notebook), current_page--);
}
static void
@@ -135,27 +133,26 @@ cc_wacom_nav_button_set_property (GObject *object,
GParamSpec *pspec)
{
CcWacomNavButton *nav = CC_WACOM_NAV_BUTTON (object);
- CcWacomNavButtonPrivate *priv = nav->priv;
switch (property_id) {
case PROP_NOTEBOOK:
- if (priv->notebook) {
- g_signal_handler_disconnect (priv->notebook, priv->page_added_id);
- g_signal_handler_disconnect (priv->notebook, priv->page_removed_id);
- g_signal_handler_disconnect (priv->notebook, priv->page_switched_id);
- g_object_unref (priv->notebook);
+ if (nav->notebook) {
+ g_signal_handler_disconnect (nav->notebook, nav->page_added_id);
+ g_signal_handler_disconnect (nav->notebook, nav->page_removed_id);
+ g_signal_handler_disconnect (nav->notebook, nav->page_switched_id);
+ g_object_unref (nav->notebook);
}
- priv->notebook = g_value_dup_object (value);
- priv->page_added_id = g_signal_connect (G_OBJECT (priv->notebook), "page-added",
- G_CALLBACK (pages_changed), nav);
- priv->page_removed_id = g_signal_connect (G_OBJECT (priv->notebook), "page-removed",
- G_CALLBACK (pages_changed), nav);
- priv->page_switched_id = g_signal_connect (G_OBJECT (priv->notebook), "notify::page",
- G_CALLBACK (page_switched), nav);
+ nav->notebook = g_value_dup_object (value);
+ nav->page_added_id = g_signal_connect (G_OBJECT (nav->notebook), "page-added",
+ G_CALLBACK (pages_changed), nav);
+ nav->page_removed_id = g_signal_connect (G_OBJECT (nav->notebook), "page-removed",
+ G_CALLBACK (pages_changed), nav);
+ nav->page_switched_id = g_signal_connect (G_OBJECT (nav->notebook), "notify::page",
+ G_CALLBACK (page_switched), nav);
cc_wacom_nav_button_update (nav);
break;
case PROP_IGNORE_FIRST:
- priv->ignore_first_page = g_value_get_boolean (value);
+ nav->ignore_first_page = g_value_get_boolean (value);
cc_wacom_nav_button_update (nav);
break;
default:
@@ -166,17 +163,17 @@ cc_wacom_nav_button_set_property (GObject *object,
static void
cc_wacom_nav_button_dispose (GObject *object)
{
- CcWacomNavButtonPrivate *priv = CC_WACOM_NAV_BUTTON (object)->priv;
-
- if (priv->notebook) {
- g_signal_handler_disconnect (priv->notebook, priv->page_added_id);
- priv->page_added_id = 0;
- g_signal_handler_disconnect (priv->notebook, priv->page_removed_id);
- priv->page_removed_id = 0;
- g_signal_handler_disconnect (priv->notebook, priv->page_switched_id);
- priv->page_switched_id = 0;
- g_object_unref (priv->notebook);
- priv->notebook = NULL;
+ CcWacomNavButton *self = CC_WACOM_NAV_BUTTON (object);
+
+ if (self->notebook) {
+ g_signal_handler_disconnect (self->notebook, self->page_added_id);
+ self->page_added_id = 0;
+ g_signal_handler_disconnect (self->notebook, self->page_removed_id);
+ self->page_removed_id = 0;
+ g_signal_handler_disconnect (self->notebook, self->page_switched_id);
+ self->page_switched_id = 0;
+ g_object_unref (self->notebook);
+ self->notebook = NULL;
}
G_OBJECT_CLASS (cc_wacom_nav_button_parent_class)->dispose (object);
@@ -187,8 +184,6 @@ cc_wacom_nav_button_class_init (CcWacomNavButtonClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CcWacomNavButtonPrivate));
-
object_class->set_property = cc_wacom_nav_button_set_property;
object_class->dispose = cc_wacom_nav_button_dispose;
@@ -205,16 +200,13 @@ cc_wacom_nav_button_class_init (CcWacomNavButtonClass *klass)
static void
cc_wacom_nav_button_init (CcWacomNavButton *self)
{
- CcWacomNavButtonPrivate *priv;
GtkStyleContext *context;
GtkWidget *image, *box;
- priv = self->priv = WACOM_NAV_BUTTON_PRIVATE (self);
-
/* Label */
- priv->label = gtk_label_new (NULL);
- gtk_style_context_add_class (gtk_widget_get_style_context (priv->label), "dim-label");
- gtk_box_pack_start (GTK_BOX (self), priv->label,
+ self->label = gtk_label_new (NULL);
+ gtk_style_context_add_class (gtk_widget_get_style_context (self->label), "dim-label");
+ gtk_box_pack_start (GTK_BOX (self), self->label,
FALSE, FALSE, 8);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -224,27 +216,27 @@ cc_wacom_nav_button_init (CcWacomNavButton *self)
FALSE, FALSE, 0);
/* Prev button */
- priv->prev = gtk_button_new ();
+ self->prev = gtk_button_new ();
image = gtk_image_new_from_icon_name ("go-previous-symbolic", GTK_ICON_SIZE_MENU);
- gtk_container_add (GTK_CONTAINER (priv->prev), image);
- g_signal_connect (G_OBJECT (priv->prev), "clicked",
+ gtk_container_add (GTK_CONTAINER (self->prev), image);
+ g_signal_connect (G_OBJECT (self->prev), "clicked",
G_CALLBACK (prev_clicked), self);
- gtk_widget_set_valign (priv->prev, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (self->prev, GTK_ALIGN_CENTER);
/* Next button */
- priv->next = gtk_button_new ();
+ self->next = gtk_button_new ();
image = gtk_image_new_from_icon_name ("go-next-symbolic", GTK_ICON_SIZE_MENU);
- gtk_container_add (GTK_CONTAINER (priv->next), image);
- g_signal_connect (G_OBJECT (priv->next), "clicked",
+ gtk_container_add (GTK_CONTAINER (self->next), image);
+ g_signal_connect (G_OBJECT (self->next), "clicked",
G_CALLBACK (next_clicked), self);
- gtk_widget_set_valign (priv->next, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (self->next, GTK_ALIGN_CENTER);
- gtk_box_pack_start (GTK_BOX (box), priv->prev,
+ gtk_box_pack_start (GTK_BOX (box), self->prev,
FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (box), priv->next,
+ gtk_box_pack_start (GTK_BOX (box), self->next,
FALSE, FALSE, 0);
- gtk_widget_show (priv->label);
+ gtk_widget_show (self->label);
gtk_widget_show_all (box);
}
diff --git a/panels/wacom/cc-wacom-nav-button.h b/panels/wacom/cc-wacom-nav-button.h
index 325a5eb36..74c0a1453 100644
--- a/panels/wacom/cc-wacom-nav-button.h
+++ b/panels/wacom/cc-wacom-nav-button.h
@@ -25,45 +25,8 @@
G_BEGIN_DECLS
-#define CC_TYPE_WACOM_NAV_BUTTON cc_wacom_nav_button_get_type()
-
-#define CC_WACOM_NAV_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- CC_TYPE_WACOM_NAV_BUTTON, CcWacomNavButton))
-
-#define CC_WACOM_NAV_BUTTON_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- CC_TYPE_WACOM_NAV_BUTTON, CcWacomNavButtonClass))
-
-#define CC_IS_WACOM_NAV_BUTTON(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- CC_TYPE_WACOM_NAV_BUTTON))
-
-#define CC_IS_WACOM_NAV_BUTTON_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- CC_TYPE_WACOM_NAV_BUTTON))
-
-#define CC_WACOM_NAV_BUTTON_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- CC_TYPE_WACOM_NAV_BUTTON, CcWacomNavButtonClass))
-
-typedef struct _CcWacomNavButton CcWacomNavButton;
-typedef struct _CcWacomNavButtonClass CcWacomNavButtonClass;
-typedef struct _CcWacomNavButtonPrivate CcWacomNavButtonPrivate;
-
-struct _CcWacomNavButton
-{
- GtkBox parent;
-
- CcWacomNavButtonPrivate *priv;
-};
-
-struct _CcWacomNavButtonClass
-{
- GtkBoxClass parent_class;
-};
-
-GType cc_wacom_nav_button_get_type (void) G_GNUC_CONST;
+#define CC_TYPE_WACOM_NAV_BUTTON (cc_wacom_nav_button_get_type ())
+G_DECLARE_FINAL_TYPE (CcWacomNavButton, cc_wacom_nav_button, CC, WACOM_NAV_BUTTON, GtkBox)
GtkWidget * cc_wacom_nav_button_new (void);
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index ea3f5b70c..ca858c921 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)
GdkSeat *seat;
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));
@@ -260,12 +258,9 @@ run_calibration (CcWacomPage *page,
GdkMonitor *monitor)
{
GdkDisplay *display = gdk_monitor_get_display (monitor);
- CcWacomPagePrivate *priv;
gint i, n_monitor = 0;
- g_assert (page->priv->area == NULL);
-
- priv = page->priv;
+ g_assert (page->area == NULL);
for (i = 0; i < gdk_display_get_n_monitors (display); i++) {
if (monitor == gdk_display_get_monitor (display, i)) {
@@ -274,7 +269,7 @@ run_calibration (CcWacomPage *page,
}
}
- priv->area = calib_area_new (NULL,
+ page->area = calib_area_new (NULL,
n_monitor,
cc_wacom_page_get_gdk_device (page),
finish_calibration,
@@ -293,7 +288,6 @@ run_calibration (CcWacomPage *page,
static void
calibrate (CcWacomPage *page)
{
- CcWacomPagePrivate *priv;
int i;
GVariant *old_calibration, **tmp, *array;
gdouble *calibration;
@@ -305,8 +299,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) {
@@ -315,7 +307,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_display_get_monitor_at_point (gdk_screen_get_display (screen), x, y);
@@ -327,7 +319,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) {
@@ -346,7 +338,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);
@@ -389,17 +381,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;
@@ -416,12 +407,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
@@ -430,20 +418,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;
}
@@ -459,8 +444,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
@@ -491,14 +476,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);
@@ -512,7 +495,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);
}
@@ -529,14 +512,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);
}
@@ -544,34 +525,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;
@@ -584,26 +561,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);
}
@@ -611,10 +587,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);
@@ -635,7 +610,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;
}
@@ -643,7 +618,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;
}
@@ -678,40 +653,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);
}
@@ -721,17 +696,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;
@@ -745,55 +717,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
@@ -801,25 +771,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"));
@@ -829,7 +796,7 @@ remove_display_link (CcWacomPagePrivate *priv)
}
static void
-remove_mouse_link (CcWacomPagePrivate *priv)
+remove_mouse_link (CcWacomPage *page)
{
gtk_widget_destroy (WID ("mouse-link"));
@@ -842,10 +809,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);
@@ -856,31 +821,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"));
@@ -907,20 +869,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);
@@ -933,20 +893,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 */
@@ -967,13 +925,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 65cd12bcf..50c242a3c 100644
--- a/panels/wacom/cc-wacom-page.h
+++ b/panels/wacom/cc-wacom-page.h
@@ -28,45 +28,8 @@
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;
+#define CC_TYPE_WACOM_PAGE (cc_wacom_page_get_type ())
+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-panel.c b/panels/wacom/cc-wacom-panel.c
index 82caf9ab0..0cb2f424e 100644
--- a/panels/wacom/cc-wacom-panel.c
+++ b/panels/wacom/cc-wacom-panel.c
@@ -39,15 +39,12 @@
#include <gdk/gdkwayland.h>
#endif
-#define WID(x) (GtkWidget *) gtk_builder_get_object (priv->builder, x)
+#define WID(x) (GtkWidget *) gtk_builder_get_object (self->builder, x)
-CC_PANEL_REGISTER (CcWacomPanel, cc_wacom_panel)
-
-#define WACOM_PANEL_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_WACOM_PANEL, CcWacomPanelPrivate))
-
-struct _CcWacomPanelPrivate
+struct _CcWacomPanel
{
+ CcPanel parent_instance;
+
GtkBuilder *builder;
GtkWidget *stack;
GtkWidget *switcher;
@@ -69,6 +66,8 @@ struct _CcWacomPanelPrivate
GDBusProxy *proxy;
};
+CC_PANEL_REGISTER (CcWacomPanel, cc_wacom_panel)
+
typedef struct {
const char *name;
CcWacomDevice *stylus;
@@ -123,25 +122,22 @@ cc_wacom_panel_static_init_func (void)
static CcWacomPage *
set_device_page (CcWacomPanel *self, const gchar *device_name)
{
- CcWacomPanelPrivate *priv;
CcWacomPage *page;
gint current;
- priv = self->priv;
-
if (device_name == NULL)
return NULL;
/* Choose correct device */
- page = g_hash_table_lookup (priv->pages, device_name);
+ page = g_hash_table_lookup (self->pages, device_name);
if (page == NULL) {
g_warning ("Failed to find device '%s', supplied in the command line.", device_name);
return page;
}
- current = gtk_notebook_page_num (GTK_NOTEBOOK (priv->tablet_notebook), GTK_WIDGET (page));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->tablet_notebook), current);
+ current = gtk_notebook_page_num (GTK_NOTEBOOK (self->tablet_notebook), GTK_WIDGET (page));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (self->tablet_notebook), current);
return page;
}
@@ -249,40 +245,40 @@ cc_wacom_panel_set_property (GObject *object,
static void
cc_wacom_panel_dispose (GObject *object)
{
- CcWacomPanelPrivate *priv = CC_WACOM_PANEL (object)->priv;
+ CcWacomPanel *self = CC_WACOM_PANEL (object);
- if (priv->builder)
+ if (self->builder)
{
- g_object_unref (priv->builder);
- priv->builder = NULL;
+ g_object_unref (self->builder);
+ self->builder = NULL;
}
- if (priv->manager)
+ if (self->manager)
{
- g_signal_handler_disconnect (priv->manager, priv->device_added_id);
- g_signal_handler_disconnect (priv->manager, priv->device_removed_id);
- priv->manager = NULL;
+ g_signal_handler_disconnect (self->manager, self->device_added_id);
+ g_signal_handler_disconnect (self->manager, self->device_removed_id);
+ self->manager = NULL;
}
- if (priv->devices)
+ if (self->devices)
{
- g_hash_table_destroy (priv->devices);
- priv->devices = NULL;
+ g_hash_table_destroy (self->devices);
+ self->devices = NULL;
}
- g_clear_object (&priv->cancellable);
- g_clear_object (&priv->proxy);
+ g_clear_object (&self->cancellable);
+ g_clear_object (&self->proxy);
- if (priv->pages)
+ if (self->pages)
{
- g_hash_table_destroy (priv->pages);
- priv->pages = NULL;
+ g_hash_table_destroy (self->pages);
+ self->pages = NULL;
}
- if (priv->stylus_pages)
+ if (self->stylus_pages)
{
- g_hash_table_destroy (priv->stylus_pages);
- priv->stylus_pages = NULL;
+ g_hash_table_destroy (self->stylus_pages);
+ self->stylus_pages = NULL;
}
G_OBJECT_CLASS (cc_wacom_panel_parent_class)->dispose (object);
@@ -291,26 +287,23 @@ cc_wacom_panel_dispose (GObject *object)
static void
check_remove_stylus_pages (CcWacomPanel *self)
{
- CcWacomPanelPrivate *priv;
GHashTableIter iter;
CcWacomDevice *device;
CcWacomTool *tool;
GtkWidget *page;
GList *tools, *total = NULL;
- priv = self->priv;
-
/* First. Iterate known devices and get the tools */
- g_hash_table_iter_init (&iter, priv->devices);
+ g_hash_table_iter_init (&iter, self->devices);
while (g_hash_table_iter_next (&iter, NULL, (gpointer*) &device)) {
- tools = cc_tablet_tool_map_list_tools (priv->tablet_tool_map, device);
+ tools = cc_tablet_tool_map_list_tools (self->tablet_tool_map, device);
total = g_list_concat (total, tools);
}
/* Second. Iterate through stylus pages and remove the ones whose
* tool is no longer in the list.
*/
- g_hash_table_iter_init (&iter, priv->stylus_pages);
+ g_hash_table_iter_init (&iter, self->stylus_pages);
while (g_hash_table_iter_next (&iter, (gpointer*) &tool, (gpointer*) &page)) {
if (g_list_find (total, tool))
continue;
@@ -325,23 +318,20 @@ static gboolean
add_stylus (CcWacomPanel *self,
CcWacomTool *tool)
{
- CcWacomPanelPrivate *priv;
GtkWidget *page;
- priv = self->priv;
-
- if (g_hash_table_lookup (priv->stylus_pages, tool))
+ if (g_hash_table_lookup (self->stylus_pages, tool))
return FALSE;
page = cc_wacom_stylus_page_new (tool);
cc_wacom_stylus_page_set_navigation (CC_WACOM_STYLUS_PAGE (page),
- GTK_NOTEBOOK (priv->stylus_notebook));
+ GTK_NOTEBOOK (self->stylus_notebook));
gtk_widget_show (page);
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->stylus_notebook), page, NULL);
- g_hash_table_insert (priv->stylus_pages, tool, page);
+ gtk_notebook_append_page (GTK_NOTEBOOK (self->stylus_notebook), page, NULL);
+ g_hash_table_insert (self->stylus_pages, tool, page);
- if (gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->stylus_notebook)) == 0)
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->stylus_notebook), 1);
+ if (gtk_notebook_get_current_page (GTK_NOTEBOOK (self->stylus_notebook)) == 0)
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (self->stylus_notebook), 1);
return TRUE;
}
@@ -351,7 +341,6 @@ update_current_tool (CcWacomPanel *panel,
GdkDevice *device,
GdkDeviceTool *tool)
{
- CcWacomPanelPrivate *priv = panel->priv;;
GsdDeviceManager *device_manager;
CcWacomDevice *wacom_device;
CcWacomTool *stylus;
@@ -368,13 +357,13 @@ update_current_tool (CcWacomPanel *panel,
if (!gsd_device)
return;
- wacom_device = g_hash_table_lookup (priv->devices, gsd_device);
+ wacom_device = g_hash_table_lookup (panel->devices, gsd_device);
if (!wacom_device)
return;
/* Check whether we already know this tool, nothing to do then */
serial = gdk_device_tool_get_serial (tool);
- stylus = cc_tablet_tool_map_lookup_tool (priv->tablet_tool_map,
+ stylus = cc_tablet_tool_map_lookup_tool (panel->tablet_tool_map,
wacom_device, serial);
if (!stylus) {
@@ -388,24 +377,24 @@ update_current_tool (CcWacomPanel *panel,
added = add_stylus (panel, stylus);
if (added) {
- if (priv->stylus_notebook ==
- gtk_stack_get_visible_child (GTK_STACK (priv->stack))) {
+ if (panel->stylus_notebook ==
+ gtk_stack_get_visible_child (GTK_STACK (panel->stack))) {
GtkWidget *widget;
gint page;
- widget = g_hash_table_lookup (priv->stylus_pages, stylus);
- page = gtk_notebook_page_num (GTK_NOTEBOOK (priv->stylus_notebook), widget);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->stylus_notebook), page);
+ widget = g_hash_table_lookup (panel->stylus_pages, stylus);
+ page = gtk_notebook_page_num (GTK_NOTEBOOK (panel->stylus_notebook), widget);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (panel->stylus_notebook), page);
} else {
- gtk_container_child_set (GTK_CONTAINER (priv->stack),
- priv->stylus_notebook,
+ gtk_container_child_set (GTK_CONTAINER (panel->stack),
+ panel->stylus_notebook,
"needs-attention", TRUE,
NULL);
}
}
}
- cc_tablet_tool_map_add_relation (priv->tablet_tool_map,
+ cc_tablet_tool_map_add_relation (panel->tablet_tool_map,
wacom_device, stylus);
}
@@ -427,7 +416,6 @@ static void
cc_wacom_panel_constructed (GObject *object)
{
CcWacomPanel *self = CC_WACOM_PANEL (object);
- CcWacomPanelPrivate *priv = self->priv;
GtkWidget *button;
CcShell *shell;
@@ -444,17 +432,17 @@ cc_wacom_panel_constructed (GObject *object)
cc_shell_embed_widget_in_header (shell, button);
- priv->test_popover = gtk_popover_new (button);
- gtk_container_set_border_width (GTK_CONTAINER (priv->test_popover), 6);
+ self->test_popover = gtk_popover_new (button);
+ gtk_container_set_border_width (GTK_CONTAINER (self->test_popover), 6);
- priv->test_draw_area = cc_drawing_area_new ();
- gtk_widget_set_size_request (priv->test_draw_area, 400, 300);
- gtk_container_add (GTK_CONTAINER (priv->test_popover),
- priv->test_draw_area);
- gtk_widget_show (priv->test_draw_area);
+ self->test_draw_area = cc_drawing_area_new ();
+ gtk_widget_set_size_request (self->test_draw_area, 400, 300);
+ gtk_container_add (GTK_CONTAINER (self->test_popover),
+ self->test_draw_area);
+ gtk_widget_show (self->test_draw_area);
g_object_bind_property (button, "active",
- priv->test_popover, "visible",
+ self->test_popover, "visible",
G_BINDING_BIDIRECTIONAL);
g_signal_connect_object (shell, "event",
@@ -470,9 +458,9 @@ cc_wacom_panel_get_help_uri (CcPanel *panel)
static GtkWidget *
cc_wacom_panel_get_title_widget (CcPanel *panel)
{
- CcWacomPanelPrivate *priv = CC_WACOM_PANEL (panel)->priv;
+ CcWacomPanel *self = CC_WACOM_PANEL (panel);
- return priv->switcher;
+ return self->switcher;
}
static void
@@ -481,8 +469,6 @@ cc_wacom_panel_class_init (CcWacomPanelClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CcWacomPanelPrivate));
-
object_class->get_property = cc_wacom_panel_get_property;
object_class->set_property = cc_wacom_panel_set_property;
object_class->dispose = cc_wacom_panel_dispose;
@@ -517,12 +503,10 @@ update_current_page (CcWacomPanel *self,
GHashTable *ht;
GList *tablets, *l;
gboolean changed;
- CcWacomPanelPrivate *priv;
GHashTableIter iter;
GsdDevice *gsd_device;
CcWacomDevice *device;
- priv = self->priv;
changed = FALSE;
ht = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
@@ -533,7 +517,7 @@ update_current_page (CcWacomPanel *self,
g_hash_table_insert (ht, (gpointer) tablet->name, tablet);
}
- g_hash_table_iter_init (&iter, priv->devices);
+ g_hash_table_iter_init (&iter, self->devices);
while (g_hash_table_iter_next (&iter, (gpointer*) &gsd_device,
(gpointer*) &device)) {
@@ -564,23 +548,23 @@ update_current_page (CcWacomPanel *self,
tablet = l->data;
if (tablet->stylus == NULL) {
- page = g_hash_table_lookup (priv->pages, tablet->name);
+ page = g_hash_table_lookup (self->pages, tablet->name);
if (page != NULL) {
- remove_page (GTK_NOTEBOOK (priv->tablet_notebook), page);
- g_hash_table_remove (priv->pages, tablet->name);
+ remove_page (GTK_NOTEBOOK (self->tablet_notebook), page);
+ g_hash_table_remove (self->pages, tablet->name);
changed = TRUE;
}
continue;
}
/* this code is called once the stylus is set up, but the pad does not exist yet */
- page = g_hash_table_lookup (priv->pages, tablet->name);
+ page = g_hash_table_lookup (self->pages, tablet->name);
if (page == NULL) {
page = cc_wacom_page_new (self, tablet->stylus, tablet->pad);
- cc_wacom_page_set_navigation (CC_WACOM_PAGE (page), GTK_NOTEBOOK
(priv->tablet_notebook), TRUE);
+ cc_wacom_page_set_navigation (CC_WACOM_PAGE (page), GTK_NOTEBOOK
(self->tablet_notebook), TRUE);
gtk_widget_show (page);
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->tablet_notebook), page, NULL);
- g_hash_table_insert (priv->pages, g_strdup (tablet->name), page);
+ gtk_notebook_append_page (GTK_NOTEBOOK (self->tablet_notebook), page, NULL);
+ g_hash_table_insert (self->pages, g_strdup (tablet->name), page);
changed = TRUE;
} else {
@@ -594,9 +578,9 @@ update_current_page (CcWacomPanel *self,
if (changed == TRUE) {
int num_pages;
- num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->tablet_notebook));
+ num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->tablet_notebook));
if (num_pages > 1)
- gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->tablet_notebook), 1);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (self->tablet_notebook), 1);
}
}
@@ -604,12 +588,10 @@ static void
add_known_device (CcWacomPanel *self,
GsdDevice *gsd_device)
{
- CcWacomPanelPrivate *priv;
CcWacomDevice *device;
GsdDeviceType device_type;
GList *tools, *l;
- priv = self->priv;
device_type = gsd_device_get_device_type (gsd_device);
if ((device_type & GSD_DEVICE_TYPE_TABLET) == 0)
@@ -624,11 +606,11 @@ add_known_device (CcWacomPanel *self,
if (!device)
return;
- g_hash_table_insert (priv->devices, gsd_device, device);
+ g_hash_table_insert (self->devices, gsd_device, device);
/* Only trigger tool lookup on pen devices */
if ((device_type & GSD_DEVICE_TYPE_TABLET) != 0) {
- tools = cc_tablet_tool_map_list_tools (priv->tablet_tool_map, device);
+ tools = cc_tablet_tool_map_list_tools (self->tablet_tool_map, device);
for (l = tools; l != NULL; l = l->next) {
add_stylus (self, l->data);
@@ -645,11 +627,11 @@ device_removed_cb (GsdDeviceManager *manager,
{
CcWacomDevice *device;
- device = g_hash_table_lookup (self->priv->devices, gsd_device);
+ device = g_hash_table_lookup (self->devices, gsd_device);
if (!device)
return;
- g_hash_table_steal (self->priv->devices, gsd_device);
+ g_hash_table_steal (self->devices, gsd_device);
update_current_page (self, device);
check_remove_stylus_pages (self);
g_object_unref (device);
@@ -696,15 +678,13 @@ got_osd_proxy_cb (GObject *source_object,
{
GError *error = NULL;
CcWacomPanel *self;
- CcWacomPanelPrivate *priv;
self = CC_WACOM_PANEL (data);
- priv = self->priv;
- priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+ self->proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
- g_clear_object (&priv->cancellable);
+ g_clear_object (&self->cancellable);
- if (priv->proxy == NULL) {
+ if (self->proxy == NULL) {
g_printerr ("Error creating proxy: %s\n", error->message);
g_error_free (error);
return;
@@ -728,14 +708,13 @@ on_stack_visible_child_notify_cb (GObject *object,
GParamSpec *pspec,
CcWacomPanel *panel)
{
- CcWacomPanelPrivate *priv = panel->priv;
GtkWidget *child;
child = gtk_stack_get_visible_child (GTK_STACK (object));
- if (child == priv->stylus_notebook) {
- gtk_container_child_set (GTK_CONTAINER (priv->stack),
- priv->stylus_notebook,
+ if (child == panel->stylus_notebook) {
+ gtk_container_child_set (GTK_CONTAINER (panel->stack),
+ panel->stylus_notebook,
"needs-attention", FALSE,
NULL);
}
@@ -744,7 +723,6 @@ on_stack_visible_child_notify_cb (GObject *object,
static void
cc_wacom_panel_init (CcWacomPanel *self)
{
- CcWacomPanelPrivate *priv;
GtkWidget *widget;
GList *devices, *l;
GError *error = NULL;
@@ -754,30 +732,29 @@ cc_wacom_panel_init (CcWacomPanel *self)
NULL
};
- priv = self->priv = WACOM_PANEL_PRIVATE (self);
g_resources_register (cc_wacom_get_resource ());
- priv->builder = gtk_builder_new ();
+ self->builder = gtk_builder_new ();
- gtk_builder_add_objects_from_resource (priv->builder,
+ gtk_builder_add_objects_from_resource (self->builder,
"/org/gnome/control-center/wacom/gnome-wacom-properties.ui",
objects,
&error);
- gtk_builder_add_objects_from_resource (priv->builder,
+ gtk_builder_add_objects_from_resource (self->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 (self->builder);
g_error_free (error);
return;
}
- priv->tablet_tool_map = cc_tablet_tool_map_new ();
+ self->tablet_tool_map = cc_tablet_tool_map_new ();
- priv->cancellable = g_cancellable_new ();
+ self->cancellable = g_cancellable_new ();
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
@@ -785,74 +762,74 @@ cc_wacom_panel_init (CcWacomPanel *self)
"org.gnome.Shell",
"/org/gnome/Shell/Wacom",
"org.gnome.Shell.Wacom.PadOsd",
- priv->cancellable,
+ self->cancellable,
got_osd_proxy_cb,
self);
/* Stack + Switcher */
- priv->stack = gtk_stack_new ();
- g_object_set (G_OBJECT (priv->stack),
+ self->stack = gtk_stack_new ();
+ g_object_set (G_OBJECT (self->stack),
"margin-top", 30,
"margin-end", 30,
"margin-start", 30,
"margin-bottom", 30,
NULL);
- g_signal_connect (priv->stack, "notify::visible-child",
+ g_signal_connect (self->stack, "notify::visible-child",
G_CALLBACK (on_stack_visible_child_notify_cb), self);
- priv->switcher = gtk_stack_switcher_new ();
- gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (priv->switcher),
- GTK_STACK (priv->stack));
- gtk_widget_show (priv->switcher);
-
- gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->stack));
- gtk_widget_show (priv->stack);
-
- priv->tablet_notebook = gtk_notebook_new ();
- gtk_widget_show (priv->tablet_notebook);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->tablet_notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->tablet_notebook), FALSE);
- gtk_widget_set_vexpand (priv->tablet_notebook, TRUE);
-
- priv->stylus_notebook = gtk_notebook_new ();
- gtk_widget_show (priv->stylus_notebook);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->stylus_notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->stylus_notebook), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (priv->stylus_notebook), 0);
- gtk_widget_set_vexpand (priv->stylus_notebook, TRUE);
-
- gtk_stack_add_titled (GTK_STACK (priv->stack),
- priv->stylus_notebook, "stylus",
+ self->switcher = gtk_stack_switcher_new ();
+ gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (self->switcher),
+ GTK_STACK (self->stack));
+ gtk_widget_show (self->switcher);
+
+ gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->stack));
+ gtk_widget_show (self->stack);
+
+ self->tablet_notebook = gtk_notebook_new ();
+ gtk_widget_show (self->tablet_notebook);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self->tablet_notebook), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (self->tablet_notebook), FALSE);
+ gtk_widget_set_vexpand (self->tablet_notebook, TRUE);
+
+ self->stylus_notebook = gtk_notebook_new ();
+ gtk_widget_show (self->stylus_notebook);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self->stylus_notebook), FALSE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (self->stylus_notebook), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (self->stylus_notebook), 0);
+ gtk_widget_set_vexpand (self->stylus_notebook, TRUE);
+
+ gtk_stack_add_titled (GTK_STACK (self->stack),
+ self->stylus_notebook, "stylus",
_("Stylus"));
- gtk_stack_add_titled (GTK_STACK (priv->stack),
- priv->tablet_notebook, "tablet",
+ gtk_stack_add_titled (GTK_STACK (self->stack),
+ self->tablet_notebook, "tablet",
_("Tablet"));
/* No styli page */
widget = WID ("no-stylus-page");
enbiggen_label (GTK_LABEL (WID ("no-stylus-label1")));
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->stylus_notebook), widget, NULL);
+ gtk_notebook_append_page (GTK_NOTEBOOK (self->stylus_notebook), widget, NULL);
/* No tablets page */
widget = WID ("main-box");
enbiggen_label (GTK_LABEL (WID ("advice-label1")));
- gtk_notebook_append_page (GTK_NOTEBOOK (priv->tablet_notebook), widget, NULL);
+ gtk_notebook_append_page (GTK_NOTEBOOK (self->tablet_notebook), widget, NULL);
g_signal_connect (G_OBJECT (WID ("linkbutton")), "activate-link",
G_CALLBACK (link_activated), self);
- priv->devices = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
- priv->pages = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- priv->stylus_pages = g_hash_table_new (NULL, NULL);
+ self->devices = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
+ self->pages = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ self->stylus_pages = g_hash_table_new (NULL, NULL);
- priv->manager = gsd_device_manager_get ();
- priv->device_added_id = g_signal_connect (G_OBJECT (priv->manager), "device-added",
+ self->manager = gsd_device_manager_get ();
+ self->device_added_id = g_signal_connect (G_OBJECT (self->manager), "device-added",
G_CALLBACK (device_added_cb), self);
- priv->device_removed_id = g_signal_connect (G_OBJECT (priv->manager), "device-removed",
+ self->device_removed_id = g_signal_connect (G_OBJECT (self->manager), "device-removed",
G_CALLBACK (device_removed_cb), self);
- devices = gsd_device_manager_list_devices (priv->manager,
+ devices = gsd_device_manager_list_devices (self->manager,
GSD_DEVICE_TYPE_TABLET);
for (l = devices; l ; l = l->next)
add_known_device (self, l->data);
@@ -866,5 +843,5 @@ cc_wacom_panel_get_gsd_wacom_bus_proxy (CcWacomPanel *self)
{
g_return_val_if_fail (CC_IS_WACOM_PANEL (self), NULL);
- return self->priv->proxy;
+ return self->proxy;
}
diff --git a/panels/wacom/cc-wacom-panel.h b/panels/wacom/cc-wacom-panel.h
index a5b1e758b..b85bac4c9 100644
--- a/panels/wacom/cc-wacom-panel.h
+++ b/panels/wacom/cc-wacom-panel.h
@@ -26,48 +26,11 @@
G_BEGIN_DECLS
-#define CC_TYPE_WACOM_PANEL cc_wacom_panel_get_type()
-
-#define CC_WACOM_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- CC_TYPE_WACOM_PANEL, CcWacomPanel))
-
-#define CC_WACOM_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- CC_TYPE_WACOM_PANEL, CcWacomPanelClass))
-
-#define CC_IS_WACOM_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- CC_TYPE_WACOM_PANEL))
-
-#define CC_IS_WACOM_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- CC_TYPE_WACOM_PANEL))
-
-#define CC_WACOM_PANEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- CC_TYPE_WACOM_PANEL, CcWacomPanelClass))
-
-typedef struct _CcWacomPanel CcWacomPanel;
-typedef struct _CcWacomPanelClass CcWacomPanelClass;
-typedef struct _CcWacomPanelPrivate CcWacomPanelPrivate;
-
-struct _CcWacomPanel
-{
- CcPanel parent;
-
- CcWacomPanelPrivate *priv;
-};
-
-struct _CcWacomPanelClass
-{
- CcPanelClass parent_class;
-};
+#define CC_TYPE_WACOM_PANEL (cc_wacom_panel_get_type ())
+G_DECLARE_FINAL_TYPE (CcWacomPanel, cc_wacom_panel, CC, WACOM_PANEL, CcPanel)
void cc_wacom_panel_static_init_func (void);
-GType cc_wacom_panel_get_type (void) G_GNUC_CONST;
-
void cc_wacom_panel_switch_to_panel (CcWacomPanel *self,
const char *panel);
diff --git a/panels/wacom/cc-wacom-stylus-page.c b/panels/wacom/cc-wacom-stylus-page.c
index 56aeeef3a..6eb57b14d 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,
@@ -171,7 +172,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;
@@ -182,7 +183,7 @@ button_changed_cb (GtkComboBox *combo, gpointer user_data)
mapping_b3 = 0;
}
- if (cc_wacom_tool_get_num_buttons (priv->stylus) > 2) {
+ if (cc_wacom_tool_get_num_buttons (page->stylus) > 2) {
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("combo-thirdbutton")), &iter))
return;
@@ -193,9 +194,9 @@ button_changed_cb (GtkComboBox *combo, gpointer user_data)
mapping_b4 = 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 (priv->stylus_settings, "tertiary-button-action", mapping_b4);
+ g_settings_set_enum (page->stylus_settings, "button-action", mapping_b2);
+ g_settings_set_enum (page->stylus_settings, "secondary-button-action", mapping_b3);
+ g_settings_set_enum (page->stylus_settings, "tertiary-button-action", mapping_b4);
}
static void
@@ -240,11 +241,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;
}
@@ -256,17 +257,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;
@@ -278,50 +276,48 @@ 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);
combo = GTK_COMBO_BOX (WID ("combo-thirdbutton"));
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
@@ -329,11 +325,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);
@@ -350,7 +343,7 @@ enum {
};
static void
-remove_buttons (CcWacomStylusPagePrivate *priv, int n)
+remove_buttons (CcWacomStylusPage *page, int n)
{
if (n < 3) {
gtk_widget_destroy (WID ("combo-thirdbutton"));
@@ -368,7 +361,7 @@ remove_buttons (CcWacomStylusPagePrivate *priv, int n)
}
static void
-remove_eraser (CcWacomStylusPagePrivate *priv)
+remove_eraser (CcWacomStylusPage *page)
{
gtk_widget_destroy (WID ("eraser-box"));
gtk_widget_destroy (WID ("label-eraser-feel"));
@@ -378,15 +371,13 @@ static void
update_stylus_ui (CcWacomStylusPage *page,
int layout)
{
- CcWacomStylusPagePrivate *priv = page->priv;
-
switch (layout) {
case LAYOUT_NORMAL:
- remove_buttons (page->priv, 2);
+ remove_buttons (page, 2);
break;
case LAYOUT_INKING:
- remove_buttons (page->priv, 0);
- remove_eraser (page->priv);
+ remove_buttons (page, 0);
+ remove_eraser (page);
gtk_container_child_set (CWID ("stylus-controls-grid"),
WID ("label-tip-feel"),
"top_attach", 0, NULL);
@@ -395,7 +386,7 @@ update_stylus_ui (CcWacomStylusPage *page,
"top_attach", 0, NULL);
break;
case LAYOUT_AIRBRUSH:
- remove_buttons (page->priv, 1);
+ remove_buttons (page, 1);
gtk_container_child_set (CWID ("stylus-controls-grid"),
WID ("label-lower-button"),
"top_attach", 1, NULL);
@@ -410,12 +401,12 @@ update_stylus_ui (CcWacomStylusPage *page,
"top_attach", 2, NULL);
break;
case LAYOUT_GENERIC_2_BUTTONS_NO_ERASER:
- remove_buttons (page->priv, 2);
- remove_eraser (page->priv);
+ remove_buttons (page, 2);
+ remove_eraser (page);
break;
case LAYOUT_3DPEN:
- remove_buttons (page->priv, 3);
- remove_eraser (page->priv);
+ remove_buttons (page, 3);
+ remove_eraser (page);
break;
case LAYOUT_OTHER:
/* We already warn about it in cc_wacom_stylus_page_new () */
@@ -427,7 +418,6 @@ GtkWidget *
cc_wacom_stylus_page_new (CcWacomTool *stylus)
{
CcWacomStylusPage *page;
- CcWacomStylusPagePrivate *priv;
guint num_buttons;
int layout;
gboolean has_eraser;
@@ -436,14 +426,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 */
@@ -462,7 +451,7 @@ cc_wacom_stylus_page_new (CcWacomTool *stylus)
layout = LAYOUT_3DPEN;
else {
layout = LAYOUT_OTHER;
- remove_buttons (priv, num_buttons);
+ remove_buttons (page, num_buttons);
/* Gray out eraser if not available */
gtk_widget_set_sensitive (WID ("eraser-box"), has_eraser);
@@ -476,19 +465,19 @@ cc_wacom_stylus_page_new (CcWacomTool *stylus)
if (num_buttons >= 3)
set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-thirdbutton")),
- priv->stylus_settings, "tertiary-button-action");
+ page->stylus_settings, "tertiary-button-action");
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);
}
@@ -496,20 +485,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 19d3a07e3..05ec2910b 100644
--- a/panels/wacom/cc-wacom-stylus-page.h
+++ b/panels/wacom/cc-wacom-stylus-page.h
@@ -27,45 +27,8 @@
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;
+#define CC_TYPE_WACOM_STYLUS_PAGE (cc_wacom_stylus_page_get_type ())
+G_DECLARE_FINAL_TYPE (CcWacomStylusPage, cc_wacom_stylus_page, CC, WACOM_STYLUS_PAGE, GtkBox)
GtkWidget * cc_wacom_stylus_page_new (CcWacomTool *stylus);
diff --git a/panels/wacom/cc-wacom-tool.h b/panels/wacom/cc-wacom-tool.h
index e366c2e23..a7da46818 100644
--- a/panels/wacom/cc-wacom-tool.h
+++ b/panels/wacom/cc-wacom-tool.h
@@ -27,7 +27,6 @@
#include <glib.h>
#define CC_TYPE_WACOM_TOOL (cc_wacom_tool_get_type ())
-
G_DECLARE_FINAL_TYPE (CcWacomTool, cc_wacom_tool, CC, WACOM_TOOL, GObject)
CcWacomTool * cc_wacom_tool_new (guint64 serial,
diff --git a/panels/wacom/gsd-wacom-key-shortcut-button.c b/panels/wacom/gsd-wacom-key-shortcut-button.c
index 6079dcbf7..2e7464116 100644
--- a/panels/wacom/gsd-wacom-key-shortcut-button.c
+++ b/panels/wacom/gsd-wacom-key-shortcut-button.c
@@ -38,10 +38,6 @@
#define DEFAULT_CANCEL_KEY GDK_KEY_Escape
#define DEFAULT_CLEAR_KEY GDK_KEY_BackSpace
-#define GSD_WACOM_KEY_SHORTCUT_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON, GsdWacomKeyShortcutButtonPrivate))
-
-G_DEFINE_TYPE (GsdWacomKeyShortcutButton, gsd_wacom_key_shortcut_button, GTK_TYPE_BUTTON);
-
enum {
KEY_SHORTCUT_EDITED,
KEY_SHORTCUT_CLEARED,
@@ -58,8 +54,10 @@ enum {
N_PROPERTIES
};
-struct _GsdWacomKeyShortcutButtonPrivate
+struct _GsdWacomKeyShortcutButton
{
+ GtkButton parent_instance;
+
gboolean editing_mode;
GdkSeat *grab_seat;
@@ -80,6 +78,8 @@ struct _GsdWacomKeyShortcutButtonPrivate
guint clear_keyval;
};
+G_DEFINE_TYPE (GsdWacomKeyShortcutButton, gsd_wacom_key_shortcut_button, GTK_TYPE_BUTTON);
+
static guint signals[LAST_SIGNAL] = { 0 };
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
@@ -98,25 +98,25 @@ gsd_wacom_key_shortcut_button_set_property (GObject *object,
switch (property_id)
{
case PROP_SHORTCUT_KEY_VAL:
- self->priv->keyval = g_value_get_uint (value);
+ self->keyval = g_value_get_uint (value);
changed = TRUE;
break;
case PROP_SHORTCUT_KEY_MODS:
- self->priv->mods = g_value_get_uint (value);
+ self->mods = g_value_get_uint (value);
changed = TRUE;
break;
case PROP_SHORTCUT_MODE:
- self->priv->mode = g_value_get_enum (value);
+ self->mode = g_value_get_enum (value);
break;
case PROP_SHORTCUT_CANCEL_KEY:
- self->priv->cancel_keyval = g_value_get_uint (value);
+ self->cancel_keyval = g_value_get_uint (value);
break;
case PROP_SHORTCUT_CLEAR_KEY:
- self->priv->clear_keyval = g_value_get_uint (value);
+ self->clear_keyval = g_value_get_uint (value);
break;
default:
@@ -139,23 +139,23 @@ gsd_wacom_key_shortcut_button_get_property (GObject *object,
switch (property_id)
{
case PROP_SHORTCUT_KEY_VAL:
- g_value_set_uint (value, self->priv->keyval);
+ g_value_set_uint (value, self->keyval);
break;
case PROP_SHORTCUT_KEY_MODS:
- g_value_set_uint (value, self->priv->mods);
+ g_value_set_uint (value, self->mods);
break;
case PROP_SHORTCUT_MODE:
- g_value_set_enum (value, self->priv->mode);
+ g_value_set_enum (value, self->mode);
break;
case PROP_SHORTCUT_CANCEL_KEY:
- g_value_set_uint (value, self->priv->cancel_keyval);
+ g_value_set_uint (value, self->cancel_keyval);
break;
case PROP_SHORTCUT_CLEAR_KEY:
- g_value_set_uint (value, self->priv->clear_keyval);
+ g_value_set_uint (value, self->clear_keyval);
break;
default:
@@ -168,13 +168,10 @@ static void
gsd_wacom_key_shortcut_set_editing_mode (GsdWacomKeyShortcutButton *self,
GdkEvent *event)
{
- GsdWacomKeyShortcutButtonPrivate *priv;
GdkWindow *window;
GdkSeat *seat;
- priv = GSD_WACOM_KEY_SHORTCUT_BUTTON (self)->priv;
-
- priv->editing_mode = TRUE;
+ self->editing_mode = TRUE;
gsd_wacom_key_shortcut_button_changed (self);
window = gtk_widget_get_window (GTK_WIDGET (self));
@@ -189,27 +186,25 @@ gsd_wacom_key_shortcut_set_editing_mode (GsdWacomKeyShortcutButton *self,
gtk_widget_grab_focus (GTK_WIDGET (self));
- priv->grab_seat = seat;
+ self->grab_seat = seat;
}
static void
gsd_wacom_key_shortcut_remove_editing_mode (GsdWacomKeyShortcutButton *self)
{
- GsdWacomKeyShortcutButtonPrivate *priv;
-
- priv = GSD_WACOM_KEY_SHORTCUT_BUTTON (self)->priv;
+ self->editing_mode = FALSE;
- priv->editing_mode = FALSE;
+ self->editing_mode = FALSE;
- if (priv->grab_seat)
+ if (self->grab_seat)
{
- gdk_seat_ungrab (priv->grab_seat);
- priv->grab_seat = NULL;
+ gdk_seat_ungrab (self->grab_seat);
+ self->grab_seat = NULL;
}
- priv->tmp_shortcut_keyval = 0;
- priv->tmp_shortcut_mods = 0;
- priv->tmp_shortcut_time = 0;
+ self->tmp_shortcut_keyval = 0;
+ self->tmp_shortcut_mods = 0;
+ self->tmp_shortcut_time = 0;
}
static void
@@ -217,7 +212,7 @@ gsd_wacom_key_shortcut_button_changed (GsdWacomKeyShortcutButton *self)
{
gchar *text;
- if (self->priv->editing_mode)
+ if (self->editing_mode)
{
gtk_button_set_label (GTK_BUTTON (self), _("New shortcut…"));
@@ -228,13 +223,13 @@ gsd_wacom_key_shortcut_button_changed (GsdWacomKeyShortcutButton *self)
return;
}
- if (self->priv->keyval == 0 && self->priv->mods == 0)
+ if (self->keyval == 0 && self->mods == 0)
{
gtk_button_set_label (GTK_BUTTON (self), "");
return;
}
- text = gtk_accelerator_get_label (self->priv->keyval, self->priv->mods);
+ text = gtk_accelerator_get_label (self->keyval, self->mods);
gtk_button_set_label (GTK_BUTTON (self), text);
g_free (text);
}
@@ -250,24 +245,20 @@ gsd_wacom_key_shortcut_button_activate (GtkButton *self)
static void
gsd_wacom_key_shortcut_button_init (GsdWacomKeyShortcutButton *self)
{
- self->priv = GSD_WACOM_KEY_SHORTCUT_BUTTON_GET_PRIVATE (self);
-
gtk_button_set_relief (GTK_BUTTON (self), GTK_RELIEF_NONE);
- self->priv->cancel_keyval = DEFAULT_CANCEL_KEY;
- self->priv->clear_keyval = DEFAULT_CLEAR_KEY;
+ self->cancel_keyval = DEFAULT_CANCEL_KEY;
+ self->clear_keyval = DEFAULT_CLEAR_KEY;
}
static void
key_shortcut_finished_editing (GsdWacomKeyShortcutButton *self,
guint32 time)
{
- GsdWacomKeyShortcutButtonPrivate *priv = self->priv;
-
- gdk_seat_ungrab (priv->grab_seat);
- priv->grab_seat = NULL;
+ gdk_seat_ungrab (self->grab_seat);
+ self->grab_seat = NULL;
- priv->editing_mode = FALSE;
+ self->editing_mode = FALSE;
gsd_wacom_key_shortcut_remove_editing_mode (self);
@@ -279,19 +270,18 @@ gsd_wacom_key_shortcut_button_key_release (GtkWidget *widget,
GdkEventKey *event)
{
GsdWacomKeyShortcutButton *self = GSD_WACOM_KEY_SHORTCUT_BUTTON (widget);
- GsdWacomKeyShortcutButtonPrivate *priv = self->priv;
- if (priv->tmp_shortcut_keyval == 0)
+ if (self->tmp_shortcut_keyval == 0)
{
GTK_WIDGET_CLASS (gsd_wacom_key_shortcut_button_parent_class)->key_release_event (widget, event);
return FALSE;
}
- priv->keyval = priv->tmp_shortcut_keyval;
- priv->mods = priv->tmp_shortcut_mods;
+ self->keyval = self->tmp_shortcut_keyval;
+ self->mods = self->tmp_shortcut_mods;
- key_shortcut_finished_editing (self, priv->tmp_shortcut_time);
+ key_shortcut_finished_editing (self, self->tmp_shortcut_time);
g_signal_emit (self, signals[KEY_SHORTCUT_EDITED], 0);
@@ -303,22 +293,18 @@ gsd_wacom_key_shortcut_button_key_press (GtkWidget *widget,
GdkEventKey *event)
{
/* This code is based on the gtk_cell_renderer_accel_start_editing */
- GsdWacomKeyShortcutButton *self;
- GsdWacomKeyShortcutButtonPrivate *priv;
+ GsdWacomKeyShortcutButton *self = GSD_WACOM_KEY_SHORTCUT_BUTTON (widget);
GdkModifierType mods = 0;
guint shortcut_keyval;
guint keyval;
gboolean edited;
gboolean cleared;
- self = GSD_WACOM_KEY_SHORTCUT_BUTTON (widget);
- priv = self->priv;
-
/* GTK and OTHER modes don't allow modifier keyvals */
- if (event->is_modifier && priv->mode != GSD_WACOM_KEY_SHORTCUT_BUTTON_MODE_ALL)
+ if (event->is_modifier && self->mode != GSD_WACOM_KEY_SHORTCUT_BUTTON_MODE_ALL)
return TRUE;
- if (!priv->editing_mode)
+ if (!self->editing_mode)
{
GTK_WIDGET_CLASS (gsd_wacom_key_shortcut_button_parent_class)->key_press_event (widget, event);
@@ -354,12 +340,12 @@ gsd_wacom_key_shortcut_button_key_press (GtkWidget *widget,
if (mods == 0)
{
- if (keyval == priv->cancel_keyval)
+ if (keyval == self->cancel_keyval)
{
/* cancel the edition */
goto out;
}
- else if (keyval == priv->clear_keyval)
+ else if (keyval == self->clear_keyval)
{
/* clear the current shortcut */
cleared = TRUE;
@@ -367,9 +353,9 @@ gsd_wacom_key_shortcut_button_key_press (GtkWidget *widget,
}
}
- priv->tmp_shortcut_keyval = 0;
- priv->tmp_shortcut_mods = 0;
- priv->tmp_shortcut_time = 0;
+ self->tmp_shortcut_keyval = 0;
+ self->tmp_shortcut_mods = 0;
+ self->tmp_shortcut_time = 0;
if (event->is_modifier)
{
@@ -379,9 +365,9 @@ gsd_wacom_key_shortcut_button_key_press (GtkWidget *widget,
* key because the user might assign e.g. Alt, Alt+Ctrl, Alt+Ctrl+Shift, etc.
* So, we keep track of the pressed shortcut's (keyval, mods and time) if
* it is a modifier shortcut and assign them when a key-release happens */
- priv->tmp_shortcut_keyval = shortcut_keyval;
- priv->tmp_shortcut_mods = mods;
- priv->tmp_shortcut_time = event->time;
+ self->tmp_shortcut_keyval = shortcut_keyval;
+ self->tmp_shortcut_mods = mods;
+ self->tmp_shortcut_time = event->time;
return TRUE;
}
@@ -392,14 +378,14 @@ gsd_wacom_key_shortcut_button_key_press (GtkWidget *widget,
if (edited)
{
- priv->keyval = shortcut_keyval;
- priv->mods = mods;
+ self->keyval = shortcut_keyval;
+ self->mods = mods;
}
if (cleared)
{
- priv->keyval = 0;
- priv->mods = 0;
+ self->keyval = 0;
+ self->mods = 0;
}
key_shortcut_finished_editing (GSD_WACOM_KEY_SHORTCUT_BUTTON (widget), event->time);
@@ -420,7 +406,7 @@ gsd_wacom_key_shortcut_button_button_press (GtkWidget *widget,
self = GSD_WACOM_KEY_SHORTCUT_BUTTON (widget);
- if (self->priv->editing_mode)
+ if (self->editing_mode)
return TRUE;
gsd_wacom_key_shortcut_set_editing_mode (self, NULL);
@@ -533,8 +519,7 @@ gsd_wacom_key_shortcut_button_class_init (GsdWacomKeyShortcutButtonClass *klass)
signals[KEY_SHORTCUT_EDITED] = g_signal_new ("key-shortcut-edited",
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsdWacomKeyShortcutButtonClass,
- key_shortcut_edited),
+ 0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
@@ -548,13 +533,10 @@ gsd_wacom_key_shortcut_button_class_init (GsdWacomKeyShortcutButtonClass *klass)
signals[KEY_SHORTCUT_CLEARED] = g_signal_new ("key-shortcut-cleared",
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON,
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsdWacomKeyShortcutButtonClass,
- key_shortcut_cleared),
+ 0,
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
- g_type_class_add_private (klass, sizeof (GsdWacomKeyShortcutButtonPrivate));
}
/**
diff --git a/panels/wacom/gsd-wacom-key-shortcut-button.h b/panels/wacom/gsd-wacom-key-shortcut-button.h
index eebae0f97..444d52718 100644
--- a/panels/wacom/gsd-wacom-key-shortcut-button.h
+++ b/panels/wacom/gsd-wacom-key-shortcut-button.h
@@ -26,19 +26,11 @@
G_BEGIN_DECLS
-#define GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON (gsd_wacom_key_shortcut_button_get_type ())
-#define GSD_WACOM_KEY_SHORTCUT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON, GsdWacomKeyShortcutButton))
-#define GSD_WACOM_IS_KEY_SHORTCUT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON))
-#define GSD_WACOM_KEY_SHORTCUT_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON, GsdWacomKeyShortcutButtonClass))
-#define GSD_WACOM_IS_KEY_SHORTCUT_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON))
-#define GSD_WACOM_KEY_SHORTCUT_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON, GsdWacomKeyShortcutButtonClass))
-
-typedef struct _GsdWacomKeyShortcutButton GsdWacomKeyShortcutButton;
-typedef struct _GsdWacomKeyShortcutButtonClass GsdWacomKeyShortcutButtonClass;
-typedef struct _GsdWacomKeyShortcutButtonPrivate GsdWacomKeyShortcutButtonPrivate;
+#define GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON (gsd_wacom_key_shortcut_button_get_type ())
+G_DECLARE_FINAL_TYPE (GsdWacomKeyShortcutButton, gsd_wacom_key_shortcut_button, GSD,
WACOM_KEY_SHORTCUT_BUTTON, GtkButton)
GType gsd_wacom_key_shortcut_button_mode_type (void) G_GNUC_CONST;
-#define GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON_MODE (gsd_wacom_key_shortcut_button_mode_type())
+#define GSD_WACOM_TYPE_KEY_SHORTCUT_BUTTON_MODE (gsd_wacom_key_shortcut_button_mode_type ())
typedef enum
{
@@ -46,24 +38,6 @@ typedef enum
GSD_WACOM_KEY_SHORTCUT_BUTTON_MODE_ALL
} GsdWacomKeyShortcutButtonMode;
-struct _GsdWacomKeyShortcutButton
-{
- GtkButton parent_instance;
-
- /*< private >*/
- GsdWacomKeyShortcutButtonPrivate *priv;
-};
-
-struct _GsdWacomKeyShortcutButtonClass
-{
- GtkButtonClass parent_class;
-
- void (* key_shortcut_edited) (GsdWacomKeyShortcutButton *key_shortcut_button);
-
- void (* key_shortcut_cleared) (GsdWacomKeyShortcutButton *key_shortcut_button);
-};
-
-GType gsd_wacom_key_shortcut_button_get_type (void) G_GNUC_CONST;
GtkWidget * gsd_wacom_key_shortcut_button_new (void);
#endif /* __GSD_WACOM_KEY_SHORTCUT_BUTTON_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]