[buoh/cleanups: 12/31] Rewrite add-comic-dialog to use G_DECLARE_FINAL_TYPE
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buoh/cleanups: 12/31] Rewrite add-comic-dialog to use G_DECLARE_FINAL_TYPE
- Date: Wed, 23 Jan 2019 11:20:29 +0000 (UTC)
commit 0616fd88c784ef71ab18aef79cd6e972ed0a76d9
Author: Jan Tojnar <jtojnar gmail com>
Date: Tue Sep 25 16:44:48 2018 +0200
Rewrite add-comic-dialog to use G_DECLARE_FINAL_TYPE
src/buoh-add-comic-dialog.c | 36 ++++++++++++++++++------------------
src/buoh-add-comic-dialog.h | 17 ++---------------
2 files changed, 20 insertions(+), 33 deletions(-)
---
diff --git a/src/buoh-add-comic-dialog.c b/src/buoh-add-comic-dialog.c
index aafecaf..922aa95 100644
--- a/src/buoh-add-comic-dialog.c
+++ b/src/buoh-add-comic-dialog.c
@@ -29,7 +29,9 @@
#include "buoh-add-comic-dialog.h"
#include "buoh.h"
-struct _BuohAddComicDialogPrivate {
+struct _BuohAddComicDialog {
+ GtkDialog parent;
+
GtkTreeModel *model;
GtkWidget *selected_label;
GtkWidget *tree_view;
@@ -45,21 +47,19 @@ static void buoh_add_comic_toggled_cb (GtkCellRendererToggle *render
gchar *path,
gpointer gdata);
-G_DEFINE_TYPE_WITH_PRIVATE (BuohAddComicDialog, buoh_add_comic_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE(BuohAddComicDialog, buoh_add_comic_dialog, GTK_TYPE_DIALOG)
static void
buoh_add_comic_dialog_init (BuohAddComicDialog *dialog)
{
- dialog->priv = buoh_add_comic_dialog_get_instance_private (dialog);
-
gtk_widget_init_template (GTK_WIDGET (dialog));
- dialog->priv->model = buoh_get_comics_model (BUOH);
+ dialog->model = buoh_get_comics_model (BUOH);
- gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->priv->tree_view), dialog->priv->model);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree_view), dialog->model);
/* Counter */
- dialog->priv->n_selected = buoh_add_comic_dialog_get_n_selected (dialog);
+ dialog->n_selected = buoh_add_comic_dialog_get_n_selected (dialog);
buoh_comic_add_dialog_update_selected (dialog);
}
@@ -70,8 +70,8 @@ buoh_add_comic_dialog_class_init (BuohAddComicDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/buoh/ui/add-comic-dialog.ui");
- gtk_widget_class_bind_template_child_private (widget_class, BuohAddComicDialog, selected_label);
- gtk_widget_class_bind_template_child_private (widget_class, BuohAddComicDialog, tree_view);
+ gtk_widget_class_bind_template_child (widget_class, BuohAddComicDialog, selected_label);
+ gtk_widget_class_bind_template_child (widget_class, BuohAddComicDialog, tree_view);
gtk_widget_class_bind_template_callback (widget_class, buoh_add_comic_toggled_cb);
}
@@ -84,16 +84,16 @@ buoh_add_comic_dialog_get_n_selected (BuohAddComicDialog *dialog)
gboolean active;
gint count = 0;
- valid = gtk_tree_model_get_iter_first (dialog->priv->model, &iter);
+ valid = gtk_tree_model_get_iter_first (dialog->model, &iter);
while (valid) {
- gtk_tree_model_get (dialog->priv->model, &iter,
+ gtk_tree_model_get (dialog->model, &iter,
COMIC_LIST_VISIBLE, &active,
-1);
if (active) {
count ++;
}
- valid = gtk_tree_model_iter_next (dialog->priv->model, &iter);
+ valid = gtk_tree_model_iter_next (dialog->model, &iter);
}
return count;
@@ -104,8 +104,8 @@ buoh_comic_add_dialog_update_selected (BuohAddComicDialog *dialog)
{
gchar *text;
- text = g_strdup_printf (_("Comics selected: %d"), dialog->priv->n_selected);
- gtk_label_set_text (GTK_LABEL (dialog->priv->selected_label), text);
+ text = g_strdup_printf (_("Comics selected: %d"), dialog->n_selected);
+ gtk_label_set_text (GTK_LABEL (dialog->selected_label), text);
g_free (text);
}
@@ -119,16 +119,16 @@ buoh_add_comic_toggled_cb (GtkCellRendererToggle *renderer,
active = gtk_cell_renderer_toggle_get_active (renderer);
- gtk_tree_model_get_iter_from_string (dialog->priv->model, &iter, path);
- gtk_list_store_set (GTK_LIST_STORE (dialog->priv->model),
+ gtk_tree_model_get_iter_from_string (dialog->model, &iter, path);
+ gtk_list_store_set (GTK_LIST_STORE (dialog->model),
&iter,
COMIC_LIST_VISIBLE, !active,
-1);
if (active) {
- dialog->priv->n_selected --;
+ dialog->n_selected --;
} else {
- dialog->priv->n_selected ++;
+ dialog->n_selected ++;
}
buoh_comic_add_dialog_update_selected (dialog);
diff --git a/src/buoh-add-comic-dialog.h b/src/buoh-add-comic-dialog.h
index 94c8d12..317dc8e 100644
--- a/src/buoh-add-comic-dialog.h
+++ b/src/buoh-add-comic-dialog.h
@@ -24,21 +24,8 @@
G_BEGIN_DECLS
-typedef struct _BuohAddComicDialog BuohAddComicDialog;
-typedef struct _BuohAddComicDialogClass BuohAddComicDialogClass;
-typedef struct _BuohAddComicDialogPrivate BuohAddComicDialogPrivate;
-
-#define BUOH_TYPE_ADD_COMIC_DIALOG (buoh_add_comic_dialog_get_type())
-#define BUOH_ADD_COMIC_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST((object),
BUOH_TYPE_ADD_COMIC_DIALOG, BuohAddComicDialog))
-#define BUOH_ADD_COMIC_DIALOG_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass),
BUOH_TYPE_ADD_COMIC_DIALOG, BuohAddComicDialogClass))
-#define BUOH_IS_ADD_COMIC_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE((object),
BUOH_TYPE_ADD_COMIC_DIALOG))
-#define BUOH_IS_ADD_COMIC_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),
BUOH_TYPE_ADD_COMIC_DIALOG))
-#define BUOH_ADD_COMIC_DIALOG_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object),
BUOH_TYPE_ADD_COMIC_DIALOG, BuohAddComicDialogClass))
-
-struct _BuohAddComicDialog {
- GtkDialog parent;
- BuohAddComicDialogPrivate *priv;
-};
+#define BUOH_TYPE_ADD_COMIC_DIALOG buoh_add_comic_dialog_get_type ()
+G_DECLARE_FINAL_TYPE (BuohAddComicDialog, buoh_add_comic_dialog, BUOH, ADD_COMIC_DIALOG, GtkDialog)
struct _BuohAddComicDialogClass {
GtkDialogClass parent_class;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]