[gnome-photos/wip/rishi/zoom: 2/9] organize-collection-view: Make it a final class
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/zoom: 2/9] organize-collection-view: Make it a final class
- Date: Wed, 14 Jun 2017 19:08:26 +0000 (UTC)
commit b7d7ba0fca39af30f360966e0ed022d63a876beb
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Jun 14 20:49:27 2017 +0200
organize-collection-view: Make it a final class
src/photos-organize-collection-view.c | 134 +++++++++++++++-----------------
src/photos-organize-collection-view.h | 28 +-------
2 files changed, 65 insertions(+), 97 deletions(-)
---
diff --git a/src/photos-organize-collection-view.c b/src/photos-organize-collection-view.c
index a654c10..6070770 100644
--- a/src/photos-organize-collection-view.c
+++ b/src/photos-organize-collection-view.c
@@ -41,8 +41,9 @@
#include "photos-utils.h"
-struct _PhotosOrganizeCollectionViewPrivate
+struct _PhotosOrganizeCollectionView
{
+ GtkTreeView parent_instance;
GCancellable *cancellable;
GtkCellRenderer *renderer_check;
GtkCellRenderer *renderer_detail;
@@ -54,8 +55,13 @@ struct _PhotosOrganizeCollectionViewPrivate
gboolean choice_confirmed;
};
+struct _PhotosOrganizeCollectionViewClass
+{
+ GtkTreeViewClass parent_class;
+};
+
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosOrganizeCollectionView, photos_organize_collection_view,
GTK_TYPE_TREE_VIEW);
+G_DEFINE_TYPE (PhotosOrganizeCollectionView, photos_organize_collection_view, GTK_TYPE_TREE_VIEW);
static void
@@ -84,7 +90,7 @@ photos_organize_collection_view_set_collection_executed (gpointer user_data)
{
PhotosOrganizeCollectionView *self = PHOTOS_ORGANIZE_COLLECTION_VIEW (user_data);
- photos_organize_collection_model_refresh_collection_state (PHOTOS_ORGANIZE_COLLECTION_MODEL
(self->priv->model));
+ photos_organize_collection_model_refresh_collection_state (PHOTOS_ORGANIZE_COLLECTION_MODEL (self->model));
g_object_unref (self);
}
@@ -92,7 +98,6 @@ photos_organize_collection_view_set_collection_executed (gpointer user_data)
static void
photos_organize_collection_view_check_toggled (PhotosOrganizeCollectionView *self, gchar *path)
{
- PhotosOrganizeCollectionViewPrivate *priv = self->priv;
GtkTreeIter iter;
GtkTreePath *tree_path;
PhotosSetCollectionJob *job;
@@ -100,9 +105,9 @@ photos_organize_collection_view_check_toggled (PhotosOrganizeCollectionView *sel
gchar *coll_urn;
tree_path = gtk_tree_path_new_from_string (path);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, tree_path);
- gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter, PHOTOS_ORGANIZE_MODEL_ID, &coll_urn, -1);
- state = gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (priv->renderer_check));
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (self->model), &iter, tree_path);
+ gtk_tree_model_get (GTK_TREE_MODEL (self->model), &iter, PHOTOS_ORGANIZE_MODEL_ID, &coll_urn, -1);
+ state = gtk_cell_renderer_toggle_get_active (GTK_CELL_RENDERER_TOGGLE (self->renderer_check));
job = photos_set_collection_job_new (coll_urn, !state);
photos_set_collection_job_run (job, photos_organize_collection_view_set_collection_executed, g_object_ref
(self));
@@ -116,7 +121,6 @@ static void
photos_organize_collection_view_create_collection_executed (GObject *source_object, GAsyncResult *res,
gpointer user_data)
{
PhotosOrganizeCollectionView *self;
- PhotosOrganizeCollectionViewPrivate *priv;
PhotosCreateCollectionJob *col_job = PHOTOS_CREATE_COLLECTION_JOB (source_object);
PhotosSetCollectionJob *set_job = NULL;
GError *error;
@@ -141,20 +145,19 @@ photos_organize_collection_view_create_collection_executed (GObject *source_obje
}
self = PHOTOS_ORGANIZE_COLLECTION_VIEW (user_data);
- priv = self->priv;
if (created_urn == NULL)
{
- photos_organize_collection_model_remove_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (priv->model));
+ photos_organize_collection_model_remove_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (self->model));
goto out;
}
- path = photos_organize_collection_model_get_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (priv->model),
TRUE);
+ path = photos_organize_collection_model_get_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (self->model),
TRUE);
if (path == NULL)
goto out;
- gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path);
- gtk_list_store_set (priv->model, &iter, PHOTOS_ORGANIZE_MODEL_ID, created_urn, -1);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (self->model), &iter, path);
+ gtk_list_store_set (self->model, &iter, PHOTOS_ORGANIZE_MODEL_ID, created_urn, -1);
set_job = photos_set_collection_job_new (created_urn, TRUE);
photos_set_collection_job_run (set_job, NULL, NULL);
@@ -173,13 +176,12 @@ photos_organize_collection_view_detail_cell (GtkTreeViewColumn *tree_column,
gpointer user_data)
{
PhotosOrganizeCollectionView *self = PHOTOS_ORGANIZE_COLLECTION_VIEW (user_data);
- PhotosOrganizeCollectionViewPrivate *priv = self->priv;
GObject *object;
const gchar *identifier = NULL;
gchar *id;
- gtk_tree_model_get (GTK_TREE_MODEL (priv->model), iter, PHOTOS_ORGANIZE_MODEL_ID, &id, -1);
- object = photos_base_manager_get_object_by_id (priv->item_mngr, id);
+ gtk_tree_model_get (GTK_TREE_MODEL (self->model), iter, PHOTOS_ORGANIZE_MODEL_ID, &id, -1);
+ object = photos_base_manager_get_object_by_id (self->item_mngr, id);
if (object != NULL)
identifier = photos_base_item_get_identifier (PHOTOS_BASE_ITEM (object));
@@ -191,7 +193,7 @@ photos_organize_collection_view_detail_cell (GtkTreeViewColumn *tree_column,
const gchar *resource_urn;
resource_urn = photos_base_item_get_resource_urn (PHOTOS_BASE_ITEM (object));
- source = PHOTOS_SOURCE (photos_base_manager_get_object_by_id (priv->src_mngr, resource_urn));
+ source = PHOTOS_SOURCE (photos_base_manager_get_object_by_id (self->src_mngr, resource_urn));
name = photos_source_get_name (source);
g_object_set (cell_renderer, "text", name, NULL);
gtk_cell_renderer_set_visible (cell_renderer, TRUE);
@@ -212,7 +214,6 @@ photos_organize_collection_view_text_edited_real (PhotosOrganizeCollectionView *
GtkTreePath *path,
const gchar *new_text)
{
- PhotosOrganizeCollectionViewPrivate *priv = self->priv;
GtkTreeIter iter;
PhotosCreateCollectionJob *job;
@@ -221,16 +222,16 @@ photos_organize_collection_view_text_edited_real (PhotosOrganizeCollectionView *
if (new_text == NULL || new_text[0] == '\0')
{
/* Don't insert collections with empty names. */
- photos_organize_collection_model_remove_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (priv->model));
+ photos_organize_collection_model_remove_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (self->model));
return;
}
- gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path);
- gtk_list_store_set (priv->model, &iter, PHOTOS_ORGANIZE_MODEL_NAME, new_text, -1);
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (self->model), &iter, path);
+ gtk_list_store_set (self->model, &iter, PHOTOS_ORGANIZE_MODEL_NAME, new_text, -1);
job = photos_create_collection_job_new (new_text);
photos_create_collection_job_run (job,
- priv->cancellable,
+ self->cancellable,
photos_organize_collection_view_create_collection_executed,
self);
g_object_unref (job);
@@ -240,12 +241,11 @@ photos_organize_collection_view_text_edited_real (PhotosOrganizeCollectionView *
static void
photos_organize_collection_view_text_edited (PhotosOrganizeCollectionView *self, gchar *path, gchar
*new_text)
{
- PhotosOrganizeCollectionViewPrivate *priv = self->priv;
GtkTreePath *tree_path;
tree_path = gtk_tree_path_new_from_string (path);
photos_organize_collection_view_text_edited_real (self,
- GTK_CELL_RENDERER_TEXT (priv->renderer_text),
+ GTK_CELL_RENDERER_TEXT (self->renderer_text),
tree_path,
new_text);
gtk_tree_path_free (tree_path);
@@ -255,21 +255,19 @@ photos_organize_collection_view_text_edited (PhotosOrganizeCollectionView *self,
static void
photos_organize_collection_view_text_editing_canceled (PhotosOrganizeCollectionView *self)
{
- PhotosOrganizeCollectionViewPrivate *priv = self->priv;
-
- if (priv->choice_confirmed)
+ if (self->choice_confirmed)
{
GtkCellArea *cell_area;
GtkCellEditable *entry;
GtkTreePath *path;
- priv->choice_confirmed = FALSE;
+ self->choice_confirmed = FALSE;
- g_object_get (priv->view_col, "cell-area", &cell_area, NULL);
+ g_object_get (self->view_col, "cell-area", &cell_area, NULL);
entry = gtk_cell_area_get_edit_widget (cell_area);
g_object_unref (cell_area);
- path = photos_organize_collection_model_get_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL
(priv->model),
+ path = photos_organize_collection_model_get_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL
(self->model),
FALSE);
if (entry != NULL && path != NULL)
@@ -278,7 +276,7 @@ photos_organize_collection_view_text_editing_canceled (PhotosOrganizeCollectionV
text = gtk_entry_get_text (GTK_ENTRY (entry));
photos_organize_collection_view_text_edited_real (self,
- GTK_CELL_RENDERER_TEXT (priv->renderer_text),
+ GTK_CELL_RENDERER_TEXT (self->renderer_text),
path,
text);
}
@@ -286,7 +284,7 @@ photos_organize_collection_view_text_editing_canceled (PhotosOrganizeCollectionV
gtk_tree_path_free (path);
}
else
- photos_organize_collection_model_remove_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (priv->model));
+ photos_organize_collection_model_remove_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (self->model));
}
@@ -294,17 +292,16 @@ static void
photos_organize_collection_view_dispose (GObject *object)
{
PhotosOrganizeCollectionView *self = PHOTOS_ORGANIZE_COLLECTION_VIEW (object);
- PhotosOrganizeCollectionViewPrivate *priv = self->priv;
- if (priv->cancellable != NULL)
+ if (self->cancellable != NULL)
{
- g_cancellable_cancel (priv->cancellable);
- g_clear_object (&priv->cancellable);
+ g_cancellable_cancel (self->cancellable);
+ g_clear_object (&self->cancellable);
}
- g_clear_object (&priv->model);
- g_clear_object (&priv->item_mngr);
- g_clear_object (&priv->src_mngr);
+ g_clear_object (&self->model);
+ g_clear_object (&self->item_mngr);
+ g_clear_object (&self->src_mngr);
G_OBJECT_CLASS (photos_organize_collection_view_parent_class)->dispose (object);
}
@@ -313,60 +310,56 @@ photos_organize_collection_view_dispose (GObject *object)
static void
photos_organize_collection_view_init (PhotosOrganizeCollectionView *self)
{
- PhotosOrganizeCollectionViewPrivate *priv;
GApplication *app;
PhotosSearchContextState *state;
- self->priv = photos_organize_collection_view_get_instance_private (self);
- priv = self->priv;
-
app = g_application_get_default ();
state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
- priv->cancellable = g_cancellable_new ();
+ self->cancellable = g_cancellable_new ();
- priv->model = photos_organize_collection_model_new ();
- gtk_tree_view_set_model (GTK_TREE_VIEW (self), GTK_TREE_MODEL (priv->model));
+ self->model = photos_organize_collection_model_new ();
+ gtk_tree_view_set_model (GTK_TREE_VIEW (self), GTK_TREE_MODEL (self->model));
- priv->view_col = gtk_tree_view_column_new ();
- gtk_tree_view_append_column (GTK_TREE_VIEW (self), priv->view_col);
+ self->view_col = gtk_tree_view_column_new ();
+ gtk_tree_view_append_column (GTK_TREE_VIEW (self), self->view_col);
- priv->renderer_check = gtk_cell_renderer_toggle_new ();
- gtk_tree_view_column_pack_start (priv->view_col, priv->renderer_check, FALSE);
- gtk_tree_view_column_set_cell_data_func (priv->view_col,
- priv->renderer_check,
+ self->renderer_check = gtk_cell_renderer_toggle_new ();
+ gtk_tree_view_column_pack_start (self->view_col, self->renderer_check, FALSE);
+ gtk_tree_view_column_set_cell_data_func (self->view_col,
+ self->renderer_check,
photos_organize_collection_view_check_cell,
self,
NULL);
- g_signal_connect_swapped (priv->renderer_check,
+ g_signal_connect_swapped (self->renderer_check,
"toggled",
G_CALLBACK (photos_organize_collection_view_check_toggled),
self);
- priv->renderer_text = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (priv->view_col, priv->renderer_text, TRUE);
- gtk_tree_view_column_add_attribute (priv->view_col, priv->renderer_text, "text",
PHOTOS_ORGANIZE_MODEL_NAME);
- g_signal_connect_swapped (priv->renderer_text,
+ self->renderer_text = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (self->view_col, self->renderer_text, TRUE);
+ gtk_tree_view_column_add_attribute (self->view_col, self->renderer_text, "text",
PHOTOS_ORGANIZE_MODEL_NAME);
+ g_signal_connect_swapped (self->renderer_text,
"edited",
G_CALLBACK (photos_organize_collection_view_text_edited),
self);
- g_signal_connect_swapped (priv->renderer_text,
+ g_signal_connect_swapped (self->renderer_text,
"editing-canceled",
G_CALLBACK (photos_organize_collection_view_text_editing_canceled),
self);
- priv->renderer_detail = gd_styled_text_renderer_new ();
- gtk_cell_renderer_set_padding (priv->renderer_detail, 16, 0);
- gd_styled_text_renderer_add_class (GD_STYLED_TEXT_RENDERER (priv->renderer_detail), "dim-label");
- gtk_tree_view_column_pack_start (priv->view_col, priv->renderer_detail, FALSE);
- gtk_tree_view_column_set_cell_data_func (priv->view_col,
- priv->renderer_detail,
+ self->renderer_detail = gd_styled_text_renderer_new ();
+ gtk_cell_renderer_set_padding (self->renderer_detail, 16, 0);
+ gd_styled_text_renderer_add_class (GD_STYLED_TEXT_RENDERER (self->renderer_detail), "dim-label");
+ gtk_tree_view_column_pack_start (self->view_col, self->renderer_detail, FALSE);
+ gtk_tree_view_column_set_cell_data_func (self->view_col,
+ self->renderer_detail,
photos_organize_collection_view_detail_cell,
self,
NULL);
- priv->item_mngr = g_object_ref (state->item_mngr);
- priv->src_mngr = g_object_ref (state->src_mngr);
+ self->item_mngr = g_object_ref (state->item_mngr);
+ self->src_mngr = g_object_ref (state->src_mngr);
gtk_widget_show (GTK_WIDGET (self));
}
@@ -395,20 +388,19 @@ photos_organize_collection_view_new (void)
void
photos_organize_collection_view_add_collection (PhotosOrganizeCollectionView *self)
{
- PhotosOrganizeCollectionViewPrivate *priv = self->priv;
GtkTreePath *path;
- path = photos_organize_collection_model_add_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (priv->model));
+ path = photos_organize_collection_model_add_placeholder (PHOTOS_ORGANIZE_COLLECTION_MODEL (self->model));
if (path == NULL)
return;
- g_object_set (priv->renderer_text, "editable", TRUE, NULL);
- gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (self), path, priv->view_col, priv->renderer_text, TRUE);
+ g_object_set (self->renderer_text, "editable", TRUE, NULL);
+ gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (self), path, self->view_col, self->renderer_text, TRUE);
}
void
photos_organize_collection_view_confirmed_choice (PhotosOrganizeCollectionView *self)
{
- self->priv->choice_confirmed = TRUE;
+ self->choice_confirmed = TRUE;
}
diff --git a/src/photos-organize-collection-view.h b/src/photos-organize-collection-view.h
index af28007..1a2e5ed 100644
--- a/src/photos-organize-collection-view.h
+++ b/src/photos-organize-collection-view.h
@@ -35,36 +35,12 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
PHOTOS_TYPE_ORGANIZE_COLLECTION_VIEW, PhotosOrganizeCollectionView))
-#define PHOTOS_ORGANIZE_COLLECTION_VIEW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- PHOTOS_TYPE_ORGANIZE_COLLECTION_VIEW, PhotosOrganizeCollectionViewClass))
-
#define PHOTOS_IS_ORGANIZE_COLLECTION_VIEW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
PHOTOS_TYPE_ORGANIZE_COLLECTION_VIEW))
-#define PHOTOS_IS_ORGANIZE_COLLECTION_VIEW_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- PHOTOS_TYPE_ORGANIZE_COLLECTION_VIEW))
-
-#define PHOTOS_ORGANIZE_COLLECTION_VIEW_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- PHOTOS_TYPE_ORGANIZE_COLLECTION_VIEW, PhotosOrganizeCollectionViewClass))
-
-typedef struct _PhotosOrganizeCollectionView PhotosOrganizeCollectionView;
-typedef struct _PhotosOrganizeCollectionViewClass PhotosOrganizeCollectionViewClass;
-typedef struct _PhotosOrganizeCollectionViewPrivate PhotosOrganizeCollectionViewPrivate;
-
-struct _PhotosOrganizeCollectionView
-{
- GtkTreeView parent_instance;
- PhotosOrganizeCollectionViewPrivate *priv;
-};
-
-struct _PhotosOrganizeCollectionViewClass
-{
- GtkTreeViewClass parent_class;
-};
+typedef struct _PhotosOrganizeCollectionView PhotosOrganizeCollectionView;
+typedef struct _PhotosOrganizeCollectionViewClass PhotosOrganizeCollectionViewClass;
GType photos_organize_collection_view_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]