[gnome-control-center/wip/gbsneto/new-keyboard-panel: 3/12] keyboard: remove boilerplate code
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/new-keyboard-panel: 3/12] keyboard: remove boilerplate code
- Date: Wed, 13 Jul 2016 17:46:13 +0000 (UTC)
commit fdc4debb349e206754da2b673423ec4f25b348c5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jun 14 14:57:06 2016 -0300
keyboard: remove boilerplate code
After introducing the autocleanup function to
CcPanel, it is now possible to remove a lot of
boilerplate code from the panels.
This commit ports CcKeyboardPanel to be a final
type, removing all the old boilerplate code in
the proccess.
panels/keyboard/cc-keyboard-panel.c | 38 +++++++++++++--------------------
panels/keyboard/cc-keyboard-panel.h | 40 +---------------------------------
2 files changed, 17 insertions(+), 61 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-panel.c b/panels/keyboard/cc-keyboard-panel.c
index df2ef98..38fe4ba 100644
--- a/panels/keyboard/cc-keyboard-panel.c
+++ b/panels/keyboard/cc-keyboard-panel.c
@@ -23,16 +23,15 @@
#include "keyboard-shortcuts.h"
-CC_PANEL_REGISTER (CcKeyboardPanel, cc_keyboard_panel)
-
-#define KEYBOARD_PANEL_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelPrivate))
-
-struct _CcKeyboardPanelPrivate
+struct _CcKeyboardPanel
{
- GtkBuilder *builder;
+ CcPanel parent;
+
+ GtkBuilder *builder;
};
+CC_PANEL_REGISTER (CcKeyboardPanel, cc_keyboard_panel)
+
enum {
PROP_0,
PROP_PARAMETERS
@@ -60,7 +59,7 @@ cc_keyboard_panel_set_page (CcKeyboardPanel *panel,
return;
}
- notebook = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "keyboard_notebook"));
+ notebook = GTK_WIDGET (gtk_builder_get_object (panel->builder, "keyboard_notebook"));
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
if (page_num == SHORTCUTS_PAGE &&
@@ -120,18 +119,15 @@ cc_keyboard_panel_constructor (GType gtype,
{
GObject *obj;
CcKeyboardPanel *self;
- CcKeyboardPanelPrivate *priv;
GtkWidget *widget;
obj = G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->constructor (gtype, n_properties, properties);
self = CC_KEYBOARD_PANEL (obj);
- priv = self->priv;
- keyboard_shortcuts_init (CC_PANEL (self), priv->builder);
+ keyboard_shortcuts_init (CC_PANEL (self), self->builder);
- widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
- "shortcuts_page");
+ widget = (GtkWidget *) gtk_builder_get_object (self->builder, "shortcuts_page");
gtk_container_add (GTK_CONTAINER (self), widget);
@@ -157,8 +153,8 @@ cc_keyboard_panel_finalize (GObject *object)
{
CcKeyboardPanel *panel = CC_KEYBOARD_PANEL (object);
- if (panel->priv->builder)
- g_object_unref (panel->priv->builder);
+ if (panel->builder)
+ g_object_unref (panel->builder);
G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->finalize (object);
}
@@ -169,8 +165,6 @@ cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
- g_type_class_add_private (klass, sizeof (CcKeyboardPanelPrivate));
-
panel_class->get_help_uri = cc_keyboard_panel_get_help_uri;
object_class->constructor = cc_keyboard_panel_constructor;
@@ -184,21 +178,19 @@ cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass)
static void
cc_keyboard_panel_init (CcKeyboardPanel *self)
{
- CcKeyboardPanelPrivate *priv;
GError *error = NULL;
- priv = self->priv = KEYBOARD_PANEL_PRIVATE (self);
g_resources_register (cc_keyboard_get_resource ());
- priv->builder = gtk_builder_new ();
+ self->builder = gtk_builder_new ();
- if (gtk_builder_add_from_resource (priv->builder,
+ if (gtk_builder_add_from_resource (self->builder,
"/org/gnome/control-center/keyboard/gnome-keyboard-panel.ui",
&error) == 0)
{
g_warning ("Could not load UI: %s", error->message);
g_clear_error (&error);
- g_object_unref (priv->builder);
- priv->builder = NULL;
+ g_object_unref (self->builder);
+ self->builder = NULL;
}
}
diff --git a/panels/keyboard/cc-keyboard-panel.h b/panels/keyboard/cc-keyboard-panel.h
index faf347d..2276c3f 100644
--- a/panels/keyboard/cc-keyboard-panel.h
+++ b/panels/keyboard/cc-keyboard-panel.h
@@ -26,45 +26,9 @@
G_BEGIN_DECLS
-#define CC_TYPE_KEYBOARD_PANEL cc_keyboard_panel_get_type()
+#define CC_TYPE_KEYBOARD_PANEL (cc_keyboard_panel_get_type())
-#define CC_KEYBOARD_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanel))
-
-#define CC_KEYBOARD_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelClass))
-
-#define CC_IS_KEYBOARD_PANEL(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- CC_TYPE_KEYBOARD_PANEL))
-
-#define CC_IS_KEYBOARD_PANEL_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- CC_TYPE_KEYBOARD_PANEL))
-
-#define CC_KEYBOARD_PANEL_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelClass))
-
-typedef struct _CcKeyboardPanel CcKeyboardPanel;
-typedef struct _CcKeyboardPanelClass CcKeyboardPanelClass;
-typedef struct _CcKeyboardPanelPrivate CcKeyboardPanelPrivate;
-
-struct _CcKeyboardPanel
-{
- CcPanel parent;
-
- CcKeyboardPanelPrivate *priv;
-};
-
-struct _CcKeyboardPanelClass
-{
- CcPanelClass parent_class;
-};
-
-GType cc_keyboard_panel_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC, KEYBOARD_PANEL, CcPanel)
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]