[gnome-photos] print-setup: Make it a final class
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] print-setup: Make it a final class
- Date: Mon, 18 Sep 2017 13:23:00 +0000 (UTC)
commit e5e0520405a57407086f6c658ece97950ca1912f
Author: Debarshi Ray <debarshir gnome org>
Date: Mon Sep 18 15:17:38 2017 +0200
print-setup: Make it a final class
src/photos-print-setup.c | 377 +++++++++++++++++++++-------------------------
src/photos-print-setup.h | 28 +---
2 files changed, 177 insertions(+), 228 deletions(-)
---
diff --git a/src/photos-print-setup.c b/src/photos-print-setup.c
index 0e24cbd..83c45ed 100644
--- a/src/photos-print-setup.c
+++ b/src/photos-print-setup.c
@@ -38,8 +38,9 @@
#include "photos-print-preview.h"
-struct _PhotosPrintSetupPrivate
+struct _PhotosPrintSetup
{
+ GtkGrid parent_instance;
GeglNode *node;
GtkPageSetup *page_setup;
GtkWidget *left;
@@ -55,6 +56,10 @@ struct _PhotosPrintSetupPrivate
GtkUnit current_unit;
};
+struct _PhotosPrintSetupClass
+{
+ GtkGridClass parent_class;
+};
enum
{
@@ -64,7 +69,7 @@ enum
};
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosPrintSetup, photos_print_setup, GTK_TYPE_GRID);
+G_DEFINE_TYPE (PhotosPrintSetup, photos_print_setup, GTK_TYPE_GRID);
enum
@@ -106,28 +111,24 @@ static void on_height_value_changed (GtkSpinButton *spinbutton, gpointer user_da
static void
photos_print_setup_block_handlers (PhotosPrintSetup *self)
{
- PhotosPrintSetupPrivate *priv = self->priv;
-
- g_signal_handlers_block_by_func (priv->left, on_left_value_changed, self);
- g_signal_handlers_block_by_func (priv->right, on_right_value_changed, self);
- g_signal_handlers_block_by_func (priv->width, on_width_value_changed, self);
- g_signal_handlers_block_by_func (priv->top, on_top_value_changed, self);
- g_signal_handlers_block_by_func (priv->bottom, on_bottom_value_changed, self);
- g_signal_handlers_block_by_func (priv->height, on_height_value_changed, self);
+ g_signal_handlers_block_by_func (self->left, on_left_value_changed, self);
+ g_signal_handlers_block_by_func (self->right, on_right_value_changed, self);
+ g_signal_handlers_block_by_func (self->width, on_width_value_changed, self);
+ g_signal_handlers_block_by_func (self->top, on_top_value_changed, self);
+ g_signal_handlers_block_by_func (self->bottom, on_bottom_value_changed, self);
+ g_signal_handlers_block_by_func (self->height, on_height_value_changed, self);
}
static void
photos_print_setup_unblock_handlers (PhotosPrintSetup *self)
{
- PhotosPrintSetupPrivate *priv = self->priv;
-
- g_signal_handlers_unblock_by_func (priv->left, on_left_value_changed, self);
- g_signal_handlers_unblock_by_func (priv->right, on_right_value_changed, self);
- g_signal_handlers_unblock_by_func (priv->width, on_width_value_changed, self);
- g_signal_handlers_unblock_by_func (priv->top, on_top_value_changed, self);
- g_signal_handlers_unblock_by_func (priv->bottom, on_bottom_value_changed, self);
- g_signal_handlers_unblock_by_func (priv->height, on_height_value_changed, self);
+ g_signal_handlers_unblock_by_func (self->left, on_left_value_changed, self);
+ g_signal_handlers_unblock_by_func (self->right, on_right_value_changed, self);
+ g_signal_handlers_unblock_by_func (self->width, on_width_value_changed, self);
+ g_signal_handlers_unblock_by_func (self->top, on_top_value_changed, self);
+ g_signal_handlers_unblock_by_func (self->bottom, on_bottom_value_changed, self);
+ g_signal_handlers_unblock_by_func (self->height, on_height_value_changed, self);
}
@@ -136,7 +137,7 @@ get_scale_to_px_factor (PhotosPrintSetup *self)
{
gdouble factor = 0.;
- switch (self->priv->current_unit)
+ switch (self->current_unit)
{
case GTK_UNIT_MM:
factor = FACTOR_MM_TO_PIXEL;
@@ -159,7 +160,6 @@ get_scale_to_px_factor (PhotosPrintSetup *self)
static gdouble
photos_print_setup_get_max_percentage (PhotosPrintSetup *self)
{
- PhotosPrintSetupPrivate *priv = self->priv;
GeglRectangle bbox;
gdouble height;
gdouble page_height;
@@ -167,9 +167,9 @@ photos_print_setup_get_max_percentage (PhotosPrintSetup *self)
gdouble width;
gdouble perc;
- page_width = gtk_page_setup_get_page_width (priv->page_setup, GTK_UNIT_INCH);
- page_height = gtk_page_setup_get_page_height (priv->page_setup, GTK_UNIT_INCH);
- bbox = gegl_node_get_bounding_box (priv->node);
+ page_width = gtk_page_setup_get_page_width (self->page_setup, GTK_UNIT_INCH);
+ page_height = gtk_page_setup_get_page_height (self->page_setup, GTK_UNIT_INCH);
+ bbox = gegl_node_get_bounding_box (self->node);
width = (gdouble) bbox.width / FACTOR_INCH_TO_PIXEL;
height = (gdouble) bbox.height / FACTOR_INCH_TO_PIXEL;
@@ -200,7 +200,6 @@ static void
on_center_changed (GtkComboBox *combobox, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
gint active;
active = gtk_combo_box_get_active (combobox);
@@ -208,28 +207,28 @@ on_center_changed (GtkComboBox *combobox, gpointer user_data)
switch (active)
{
case CENTER_HORIZONTAL:
- photos_print_setup_center (gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit),
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->width)),
- GTK_SPIN_BUTTON (priv->left),
- GTK_SPIN_BUTTON (priv->right));
+ photos_print_setup_center (gtk_page_setup_get_page_width (self->page_setup, self->current_unit),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->width)),
+ GTK_SPIN_BUTTON (self->left),
+ GTK_SPIN_BUTTON (self->right));
break;
case CENTER_VERTICAL:
- photos_print_setup_center (gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit),
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->height)),
- GTK_SPIN_BUTTON (priv->top),
- GTK_SPIN_BUTTON (priv->bottom));
+ photos_print_setup_center (gtk_page_setup_get_page_height (self->page_setup, self->current_unit),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->height)),
+ GTK_SPIN_BUTTON (self->top),
+ GTK_SPIN_BUTTON (self->bottom));
break;
case CENTER_BOTH:
- photos_print_setup_center (gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit),
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->width)),
- GTK_SPIN_BUTTON (priv->left),
- GTK_SPIN_BUTTON (priv->right));
- photos_print_setup_center (gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit),
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->height)),
- GTK_SPIN_BUTTON (priv->top),
- GTK_SPIN_BUTTON (priv->bottom));
+ photos_print_setup_center (gtk_page_setup_get_page_width (self->page_setup, self->current_unit),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->width)),
+ GTK_SPIN_BUTTON (self->left),
+ GTK_SPIN_BUTTON (self->right));
+ photos_print_setup_center (gtk_page_setup_get_page_height (self->page_setup, self->current_unit),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->height)),
+ GTK_SPIN_BUTTON (self->top),
+ GTK_SPIN_BUTTON (self->bottom));
break;
case CENTER_NONE:
@@ -248,12 +247,10 @@ update_image_pos_ranges (PhotosPrintSetup *self,
gdouble width,
gdouble height)
{
- PhotosPrintSetupPrivate *priv = self->priv;
-
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->left), 0, page_width - width);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->right), 0, page_width - width);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->top), 0, page_height - height);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->bottom), 0, page_height - height);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (self->left), 0, page_width - width);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (self->right), 0, page_width - width);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (self->top), 0, page_height - height);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (self->bottom), 0, page_height - height);
}
@@ -261,7 +258,6 @@ static void
on_scale_changed (GtkRange *range, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
GeglRectangle bbox;
gdouble height;
gdouble scale;
@@ -270,36 +266,36 @@ on_scale_changed (GtkRange *range, gpointer user_data)
gdouble page_width, page_height;
gdouble factor;
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->center), CENTER_NONE);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->center), CENTER_NONE);
- bbox = gegl_node_get_bounding_box (priv->node);
+ bbox = gegl_node_get_bounding_box (self->node);
factor = get_scale_to_px_factor (self);
width = (gdouble) bbox.width / factor;
height = (gdouble) bbox.height / factor;
- left = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->left));
- top = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->top));
+ left = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->left));
+ top = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->top));
scale = CLAMP (0.01 * gtk_range_get_value (range), 0, photos_print_setup_get_max_percentage (self));
- photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (priv->preview), scale);
+ photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (self->preview), scale);
width *= scale;
height *= scale;
- page_width = gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit);
- page_height = gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit);
+ page_width = gtk_page_setup_get_page_width (self->page_setup, self->current_unit);
+ page_height = gtk_page_setup_get_page_height (self->page_setup, self->current_unit);
update_image_pos_ranges (self, page_width, page_height, width, height);
right = page_width - left - width;
bottom = page_height - top - height;
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->width), width);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->height), height);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->right), right);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->bottom), bottom);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->width), width);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->height), height);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->right), right);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->bottom), bottom);
}
@@ -318,7 +314,6 @@ photos_print_setup_position_values_changed (PhotosPrintSetup *self,
gdouble total_size,
gint change)
{
- PhotosPrintSetupPrivate *priv = self->priv;
gdouble changed, to_update, size;
gdouble pos;
@@ -327,22 +322,22 @@ photos_print_setup_position_values_changed (PhotosPrintSetup *self,
to_update = total_size - changed - size;
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w_to_update), to_update);
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->center), CENTER_NONE);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->center), CENTER_NONE);
switch (change)
{
case CHANGE_HORIZ:
- pos = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->left));
- if (priv->current_unit == GTK_UNIT_MM)
+ pos = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->left));
+ if (self->current_unit == GTK_UNIT_MM)
pos *= FACTOR_MM_TO_INCH;
- photos_print_preview_set_image_position (PHOTOS_PRINT_PREVIEW (priv->preview), pos, -1);
+ photos_print_preview_set_image_position (PHOTOS_PRINT_PREVIEW (self->preview), pos, -1);
break;
case CHANGE_VERT:
- pos = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->top));
- if (priv->current_unit == GTK_UNIT_MM)
+ pos = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->top));
+ if (self->current_unit == GTK_UNIT_MM)
pos *= FACTOR_MM_TO_INCH;
- photos_print_preview_set_image_position (PHOTOS_PRINT_PREVIEW (priv->preview), -1, pos);
+ photos_print_preview_set_image_position (PHOTOS_PRINT_PREVIEW (self->preview), -1, pos);
break;
default:
@@ -356,14 +351,13 @@ static void
on_left_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
photos_print_setup_position_values_changed (self,
- priv->left,
- priv->right,
- priv->width,
- gtk_page_setup_get_page_width (priv->page_setup,
- priv->current_unit),
+ self->left,
+ self->right,
+ self->width,
+ gtk_page_setup_get_page_width (self->page_setup,
+ self->current_unit),
CHANGE_HORIZ);
}
@@ -372,14 +366,13 @@ static void
on_right_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
photos_print_setup_position_values_changed (self,
- priv->right,
- priv->left,
- priv->width,
- gtk_page_setup_get_page_width (priv->page_setup,
- priv->current_unit),
+ self->right,
+ self->left,
+ self->width,
+ gtk_page_setup_get_page_width (self->page_setup,
+ self->current_unit),
CHANGE_HORIZ);
}
@@ -389,14 +382,13 @@ on_top_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
photos_print_setup_position_values_changed (self,
- priv->top,
- priv->bottom,
- priv->height,
- gtk_page_setup_get_page_height (priv->page_setup,
- priv->current_unit),
+ self->top,
+ self->bottom,
+ self->height,
+ gtk_page_setup_get_page_height (self->page_setup,
+ self->current_unit),
CHANGE_VERT);
}
@@ -405,14 +397,13 @@ static void
on_bottom_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
photos_print_setup_position_values_changed (self,
- priv->bottom,
- priv->top,
- priv->height,
- gtk_page_setup_get_page_height (priv->page_setup,
- priv->current_unit),
+ self->bottom,
+ self->top,
+ self->height,
+ gtk_page_setup_get_page_height (self->page_setup,
+ self->current_unit),
CHANGE_VERT);
}
@@ -429,7 +420,6 @@ photos_print_setup_size_changed (PhotosPrintSetup *self,
gdouble page_size_y,
gint change)
{
- PhotosPrintSetupPrivate *priv = self->priv;
GeglRectangle bbox;
gdouble margin_x_1, margin_x_2;
gdouble margin_y_1, margin_y_2;
@@ -441,7 +431,7 @@ photos_print_setup_size_changed (PhotosPrintSetup *self,
margin_x_1 = gtk_spin_button_get_value (GTK_SPIN_BUTTON (w_margin_x_1));
margin_y_1 = gtk_spin_button_get_value (GTK_SPIN_BUTTON (w_margin_y_1));
- bbox = gegl_node_get_bounding_box (priv->node);
+ bbox = gegl_node_get_bounding_box (self->node);
factor = get_scale_to_px_factor (self);
switch (change)
@@ -468,7 +458,7 @@ photos_print_setup_size_changed (PhotosPrintSetup *self,
margin_x_2 = page_size_x - margin_x_1 - size_x;
margin_y_2 = page_size_y - margin_y_1 - size_y;
- photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (priv->preview), scale);
+ photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (self->preview), scale);
switch (change)
{
@@ -485,30 +475,29 @@ photos_print_setup_size_changed (PhotosPrintSetup *self,
break;
}
- gtk_range_set_value (GTK_RANGE (priv->scaling), 100*scale);
+ gtk_range_set_value (GTK_RANGE (self->scaling), 100*scale);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w_margin_x_2), margin_x_2);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w_size_y), size_y);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (w_margin_y_2), margin_y_2);
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->center), CENTER_NONE);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->center), CENTER_NONE);
}
static void
on_width_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
photos_print_setup_size_changed (self,
- priv->width,
- priv->height,
- priv->left,
- priv->right,
- priv->top,
- priv->bottom,
- gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit),
- gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit),
+ self->width,
+ self->height,
+ self->left,
+ self->right,
+ self->top,
+ self->bottom,
+ gtk_page_setup_get_page_width (self->page_setup, self->current_unit),
+ gtk_page_setup_get_page_height (self->page_setup, self->current_unit),
CHANGE_HORIZ);
}
@@ -517,17 +506,16 @@ static void
on_height_value_changed (GtkSpinButton *spinbutton, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
photos_print_setup_size_changed (self,
- priv->height,
- priv->width,
- priv->top,
- priv->bottom,
- priv->left,
- priv->right,
- gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit),
- gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit),
+ self->height,
+ self->width,
+ self->top,
+ self->bottom,
+ self->left,
+ self->right,
+ gtk_page_setup_get_page_height (self->page_setup, self->current_unit),
+ gtk_page_setup_get_page_width (self->page_setup, self->current_unit),
CHANGE_VERT);
}
@@ -554,12 +542,11 @@ change_unit (GtkSpinButton *spinbutton, gdouble factor, gint digits, gdouble ste
static void
photos_print_setup_set_scale_unit (PhotosPrintSetup *self, GtkUnit unit)
{
- PhotosPrintSetupPrivate *priv = self->priv;
gdouble factor;
gdouble step, page;
gint digits;
- if (G_UNLIKELY (priv->current_unit == unit))
+ if (G_UNLIKELY (self->current_unit == unit))
return;
switch (unit)
@@ -586,16 +573,16 @@ photos_print_setup_set_scale_unit (PhotosPrintSetup *self, GtkUnit unit)
photos_print_setup_block_handlers (self);
- change_unit (GTK_SPIN_BUTTON (priv->width), factor, digits, step, page);
- change_unit (GTK_SPIN_BUTTON (priv->height), factor, digits, step, page);
- change_unit (GTK_SPIN_BUTTON (priv->left), factor, digits, step, page);
- change_unit (GTK_SPIN_BUTTON (priv->right), factor, digits, step, page);
- change_unit (GTK_SPIN_BUTTON (priv->top), factor, digits, step, page);
- change_unit (GTK_SPIN_BUTTON (priv->bottom), factor, digits, step, page);
+ change_unit (GTK_SPIN_BUTTON (self->width), factor, digits, step, page);
+ change_unit (GTK_SPIN_BUTTON (self->height), factor, digits, step, page);
+ change_unit (GTK_SPIN_BUTTON (self->left), factor, digits, step, page);
+ change_unit (GTK_SPIN_BUTTON (self->right), factor, digits, step, page);
+ change_unit (GTK_SPIN_BUTTON (self->top), factor, digits, step, page);
+ change_unit (GTK_SPIN_BUTTON (self->bottom), factor, digits, step, page);
photos_print_setup_unblock_handlers (self);
- priv->current_unit = unit;
+ self->current_unit = unit;
}
@@ -626,20 +613,19 @@ static void
on_preview_pixbuf_moved (PhotosPrintPreview *preview, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
gdouble x;
gdouble y;
photos_print_preview_get_image_position (preview, &x, &y);
- if (priv->current_unit == GTK_UNIT_MM)
+ if (self->current_unit == GTK_UNIT_MM)
{
x *= FACTOR_INCH_TO_MM;
y *= FACTOR_INCH_TO_MM;
}
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->left), x);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->top), y);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->left), x);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->top), y);
}
@@ -647,7 +633,6 @@ static gboolean
on_preview_image_scrolled (GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
PhotosPrintPreview *preview = PHOTOS_PRINT_PREVIEW (widget);
gfloat scale;
@@ -676,7 +661,7 @@ on_preview_image_scrolled (GtkWidget *widget, GdkEventScroll *event, gpointer us
break;
}
- gtk_range_set_value (GTK_RANGE (priv->scaling), 100*scale);
+ gtk_range_set_value (GTK_RANGE (self->scaling), 100*scale);
return TRUE;
}
@@ -686,7 +671,6 @@ static gboolean
on_preview_image_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (user_data);
- PhotosPrintSetupPrivate *priv = self->priv;
PhotosPrintPreview *preview = PHOTOS_PRINT_PREVIEW (widget);
gfloat scale;
@@ -711,7 +695,7 @@ on_preview_image_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer us
break;
}
- gtk_range_set_value (GTK_RANGE (priv->scaling), 100 * scale);
+ gtk_range_set_value (GTK_RANGE (self->scaling), 100 * scale);
return TRUE;
}
@@ -770,7 +754,6 @@ grid_attach_spin_button_with_label (GtkWidget *grid, const gchar* text_label, gi
static void
photos_print_setup_set_initial_values (PhotosPrintSetup *self)
{
- PhotosPrintSetupPrivate *priv = self->priv;
GeglRectangle bbox;
gdouble page_height;
gdouble page_width;
@@ -781,7 +764,7 @@ photos_print_setup_set_initial_values (PhotosPrintSetup *self)
factor = get_scale_to_px_factor (self);
- bbox = gegl_node_get_bounding_box (priv->node);
+ bbox = gegl_node_get_bounding_box (self->node);
width = (gdouble) bbox.width/factor;
height = (gdouble) bbox.height/factor;
@@ -790,27 +773,27 @@ photos_print_setup_set_initial_values (PhotosPrintSetup *self)
width *= max_perc;
height *= max_perc;
- gtk_range_set_range (GTK_RANGE (priv->scaling), 1, 100 * max_perc);
- gtk_range_set_increments (GTK_RANGE (priv->scaling), max_perc, 10 * max_perc);
- gtk_range_set_value (GTK_RANGE (priv->scaling), 100 * max_perc);
+ gtk_range_set_range (GTK_RANGE (self->scaling), 1, 100 * max_perc);
+ gtk_range_set_increments (GTK_RANGE (self->scaling), max_perc, 10 * max_perc);
+ gtk_range_set_value (GTK_RANGE (self->scaling), 100 * max_perc);
- photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (priv->preview), max_perc);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->width), 0, width);
- gtk_spin_button_set_range (GTK_SPIN_BUTTON (priv->height), 0, height);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->width), width);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->height), height);
+ photos_print_preview_set_scale (PHOTOS_PRINT_PREVIEW (self->preview), max_perc);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (self->width), 0, width);
+ gtk_spin_button_set_range (GTK_SPIN_BUTTON (self->height), 0, height);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->width), width);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->height), height);
- gtk_combo_box_set_active (GTK_COMBO_BOX (priv->center), CENTER_BOTH);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->center), CENTER_BOTH);
- photos_print_setup_center (gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit),
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->width)),
- GTK_SPIN_BUTTON (priv->left), GTK_SPIN_BUTTON (priv->right));
- photos_print_setup_center (gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit),
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->height)),
- GTK_SPIN_BUTTON (priv->top), GTK_SPIN_BUTTON (priv->bottom));
+ photos_print_setup_center (gtk_page_setup_get_page_width (self->page_setup, self->current_unit),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->width)),
+ GTK_SPIN_BUTTON (self->left), GTK_SPIN_BUTTON (self->right));
+ photos_print_setup_center (gtk_page_setup_get_page_height (self->page_setup, self->current_unit),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->height)),
+ GTK_SPIN_BUTTON (self->top), GTK_SPIN_BUTTON (self->bottom));
- page_width = gtk_page_setup_get_page_width (priv->page_setup, priv->current_unit);
- page_height = gtk_page_setup_get_page_height (priv->page_setup, priv->current_unit);
+ page_width = gtk_page_setup_get_page_width (self->page_setup, self->current_unit);
+ page_height = gtk_page_setup_get_page_height (self->page_setup, self->current_unit);
update_image_pos_ranges (self, page_width, page_height, width, height);
}
@@ -820,24 +803,23 @@ static void
photos_print_setup_constructed (GObject *object)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (object);
- PhotosPrintSetupPrivate *priv = self->priv;
G_OBJECT_CLASS (photos_print_setup_parent_class)->constructed (object);
photos_print_setup_set_initial_values (self);
- photos_print_preview_set_from_page_setup (PHOTOS_PRINT_PREVIEW (priv->preview), priv->page_setup);
-
- g_signal_connect (priv->left, "value-changed", G_CALLBACK (on_left_value_changed), self);
- g_signal_connect (priv->right, "value-changed", G_CALLBACK (on_right_value_changed), self);
- g_signal_connect (priv->top, "value-changed", G_CALLBACK (on_top_value_changed), self);
- g_signal_connect (priv->bottom, "value-changed", G_CALLBACK (on_bottom_value_changed), self);
- g_signal_connect (priv->width, "value-changed", G_CALLBACK (on_width_value_changed), self);
- g_signal_connect (priv->height, "value-changed", G_CALLBACK (on_height_value_changed), self);
- g_signal_connect (priv->scaling, "value-changed", G_CALLBACK (on_scale_changed), self);
- g_signal_connect (priv->scaling, "format-value", G_CALLBACK (on_scale_format_value), NULL);
- g_signal_connect (priv->preview, "pixbuf-moved", G_CALLBACK (on_preview_pixbuf_moved), self);
- g_signal_connect (priv->preview, "scroll-event", G_CALLBACK (on_preview_image_scrolled), self);
- g_signal_connect (priv->preview, "key-press-event", G_CALLBACK (on_preview_image_key_pressed), self);
+ photos_print_preview_set_from_page_setup (PHOTOS_PRINT_PREVIEW (self->preview), self->page_setup);
+
+ g_signal_connect (self->left, "value-changed", G_CALLBACK (on_left_value_changed), self);
+ g_signal_connect (self->right, "value-changed", G_CALLBACK (on_right_value_changed), self);
+ g_signal_connect (self->top, "value-changed", G_CALLBACK (on_top_value_changed), self);
+ g_signal_connect (self->bottom, "value-changed", G_CALLBACK (on_bottom_value_changed), self);
+ g_signal_connect (self->width, "value-changed", G_CALLBACK (on_width_value_changed), self);
+ g_signal_connect (self->height, "value-changed", G_CALLBACK (on_height_value_changed), self);
+ g_signal_connect (self->scaling, "value-changed", G_CALLBACK (on_scale_changed), self);
+ g_signal_connect (self->scaling, "format-value", G_CALLBACK (on_scale_format_value), NULL);
+ g_signal_connect (self->preview, "pixbuf-moved", G_CALLBACK (on_preview_pixbuf_moved), self);
+ g_signal_connect (self->preview, "scroll-event", G_CALLBACK (on_preview_image_scrolled), self);
+ g_signal_connect (self->preview, "key-press-event", G_CALLBACK (on_preview_image_key_pressed), self);
}
@@ -845,10 +827,9 @@ static void
photos_print_setup_dispose (GObject *object)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (object);
- PhotosPrintSetupPrivate *priv = self->priv;
- g_clear_object (&priv->node);
- g_clear_object (&priv->page_setup);
+ g_clear_object (&self->node);
+ g_clear_object (&self->page_setup);
G_OBJECT_CLASS (photos_print_setup_parent_class)->dispose (object);
}
@@ -858,7 +839,6 @@ static void
photos_print_setup_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
PhotosPrintSetup *self = PHOTOS_PRINT_SETUP (object);
- PhotosPrintSetupPrivate *priv = self->priv;
switch (prop_id)
{
@@ -866,18 +846,18 @@ photos_print_setup_set_property (GObject *object, guint prop_id, const GValue *v
{
GdkPixbuf *pixbuf;
- priv->node = GEGL_NODE (g_value_dup_object (value));
- pixbuf = photos_gegl_create_pixbuf_from_node (priv->node);
+ self->node = GEGL_NODE (g_value_dup_object (value));
+ pixbuf = photos_gegl_create_pixbuf_from_node (self->node);
if (pixbuf != NULL)
{
- g_object_set (priv->preview, "pixbuf", pixbuf, NULL);
+ g_object_set (self->preview, "pixbuf", pixbuf, NULL);
g_object_unref (pixbuf);
}
}
break;
case PROP_PAGE_SETUP:
- priv->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
+ self->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
break;
default:
@@ -894,15 +874,11 @@ photos_print_setup_init (PhotosPrintSetup *self)
GtkWidget *label;
GtkWidget *hscale;
GtkWidget *combobox;
- PhotosPrintSetupPrivate *priv;
#ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
gchar *locale_scale = NULL;
#endif
- self->priv = photos_print_setup_get_instance_private (self);
- priv = self->priv;
-
gtk_container_set_border_width (GTK_CONTAINER (self), 12);
gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
gtk_grid_set_column_spacing (GTK_GRID (self), 18);
@@ -914,10 +890,10 @@ photos_print_setup_init (PhotosPrintSetup *self)
frame = photos_print_setup_wrap_in_frame (_("Position"), grid);
gtk_grid_attach (GTK_GRID (self), frame, 0, 0, 1, 1);
- priv->left = grid_attach_spin_button_with_label (grid, _("_Left:"), 0, 0);
- priv->right = grid_attach_spin_button_with_label (grid,_("_Right:"), 0, 1);
- priv->top = grid_attach_spin_button_with_label (grid, _("_Top:"), 2, 0);
- priv->bottom = grid_attach_spin_button_with_label (grid, _("_Bottom:"), 2, 1);
+ self->left = grid_attach_spin_button_with_label (grid, _("_Left:"), 0, 0);
+ self->right = grid_attach_spin_button_with_label (grid,_("_Right:"), 0, 1);
+ self->top = grid_attach_spin_button_with_label (grid, _("_Top:"), 2, 0);
+ self->bottom = grid_attach_spin_button_with_label (grid, _("_Bottom:"), 2, 1);
label = gtk_label_new_with_mnemonic (_("C_enter:"));
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
@@ -929,11 +905,11 @@ photos_print_setup_init (PhotosPrintSetup *self)
gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (combobox), CENTER_BOTH, _("Both"));
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), CENTER_NONE);
/* Attach combobox below right margin spinbutton and span until end */
- gtk_grid_attach_next_to (GTK_GRID (grid), combobox, priv->right, GTK_POS_BOTTOM, 3, 1);
+ gtk_grid_attach_next_to (GTK_GRID (grid), combobox, self->right, GTK_POS_BOTTOM, 3, 1);
/* Attach the label to the left of the combobox */
gtk_grid_attach_next_to (GTK_GRID (grid), label, combobox, GTK_POS_LEFT, 1, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combobox);
- priv->center = combobox;
+ self->center = combobox;
g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (on_center_changed), self);
grid = gtk_grid_new ();
@@ -942,17 +918,17 @@ photos_print_setup_init (PhotosPrintSetup *self)
frame = photos_print_setup_wrap_in_frame (_("Size"), grid);
gtk_grid_attach (GTK_GRID (self), frame, 0, 1, 1, 1);
- priv->width = grid_attach_spin_button_with_label (grid, _("_Width:"), 0, 0);
- priv->height = grid_attach_spin_button_with_label (grid, _("_Height:"), 2, 0);
+ self->width = grid_attach_spin_button_with_label (grid, _("_Width:"), 0, 0);
+ self->height = grid_attach_spin_button_with_label (grid, _("_Height:"), 2, 0);
label = gtk_label_new_with_mnemonic (_("_Scaling:"));
hscale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 1, 100, 1);
gtk_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_RIGHT);
gtk_range_set_value (GTK_RANGE (hscale), 100);
- gtk_grid_attach_next_to (GTK_GRID (grid), hscale, priv->width, GTK_POS_BOTTOM, 3, 1);
+ gtk_grid_attach_next_to (GTK_GRID (grid), hscale, self->width, GTK_POS_BOTTOM, 3, 1);
gtk_grid_attach_next_to (GTK_GRID (grid), label, hscale, GTK_POS_LEFT, 1, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), hscale);
- priv->scaling = hscale;
+ self->scaling = hscale;
label = gtk_label_new_with_mnemonic (_("_Unit:"));
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
@@ -979,15 +955,15 @@ photos_print_setup_init (PhotosPrintSetup *self)
gtk_grid_attach_next_to (GTK_GRID (grid), label, combobox, GTK_POS_LEFT, 1, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combobox);
- priv->unit = combobox;
+ self->unit = combobox;
g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (on_unit_changed), self);
- priv->preview = photos_print_preview_new ();
+ self->preview = photos_print_preview_new ();
/* FIXME: This shouldn't be set by hand */
- gtk_widget_set_size_request (priv->preview, 250, 250);
+ gtk_widget_set_size_request (self->preview, 250, 250);
- frame = photos_print_setup_wrap_in_frame (_("Preview"), priv->preview);
+ frame = photos_print_setup_wrap_in_frame (_("Preview"), self->preview);
/* The preview widget needs to span the whole grid height */
gtk_grid_attach (GTK_GRID (self), frame, 1, 0, 1, 2);
@@ -1038,34 +1014,31 @@ photos_print_setup_get_options (PhotosPrintSetup *self,
gdouble *scale,
GtkUnit *unit)
{
- PhotosPrintSetupPrivate *priv = self->priv;
-
- *left = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->left));
- *top = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->top));
- *scale = gtk_range_get_value (GTK_RANGE (priv->scaling));
- *unit = priv->current_unit;
+ *left = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->left));
+ *top = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->top));
+ *scale = gtk_range_get_value (GTK_RANGE (self->scaling));
+ *unit = self->current_unit;
}
void
photos_print_setup_update (PhotosPrintSetup *self, GtkPageSetup *page_setup)
{
- PhotosPrintSetupPrivate *priv = self->priv;
gdouble pos_x;
gdouble pos_y;
- priv->page_setup = gtk_page_setup_copy (page_setup);
+ self->page_setup = gtk_page_setup_copy (page_setup);
photos_print_setup_set_initial_values (PHOTOS_PRINT_SETUP (self));
- photos_print_preview_set_from_page_setup (PHOTOS_PRINT_PREVIEW (priv->preview), priv->page_setup);
+ photos_print_preview_set_from_page_setup (PHOTOS_PRINT_PREVIEW (self->preview), self->page_setup);
- pos_x = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->left));
- pos_y = gtk_spin_button_get_value (GTK_SPIN_BUTTON (priv->top));
- if (priv->current_unit == GTK_UNIT_MM)
+ pos_x = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->left));
+ pos_y = gtk_spin_button_get_value (GTK_SPIN_BUTTON (self->top));
+ if (self->current_unit == GTK_UNIT_MM)
{
pos_x *= FACTOR_MM_TO_INCH;
pos_y *= FACTOR_MM_TO_INCH;
}
- photos_print_preview_set_image_position (PHOTOS_PRINT_PREVIEW (priv->preview), pos_x, pos_y);
+ photos_print_preview_set_image_position (PHOTOS_PRINT_PREVIEW (self->preview), pos_x, pos_y);
}
diff --git a/src/photos-print-setup.h b/src/photos-print-setup.h
index 5361c3e..1ab74e6 100644
--- a/src/photos-print-setup.h
+++ b/src/photos-print-setup.h
@@ -37,36 +37,12 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
PHOTOS_TYPE_PRINT_SETUP, PhotosPrintSetup))
-#define PHOTOS_PRINT_SETUP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- PHOTOS_TYPE_PRINT_SETUP, PhotosPrintSetupClass))
-
#define PHOTOS_IS_PRINT_SETUP(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
PHOTOS_TYPE_PRINT_SETUP))
-#define PHOTOS_IS_PRINT_SETUP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- PHOTOS_TYPE_PRINT_SETUP))
-
-#define PHOTOS_PRINT_SETUP_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- PHOTOS_TYPE_PRINT_SETUP, PhotosPrintSetupClass))
-
-typedef struct _PhotosPrintSetup PhotosPrintSetup;
-typedef struct _PhotosPrintSetupClass PhotosPrintSetupClass;
-typedef struct _PhotosPrintSetupPrivate PhotosPrintSetupPrivate;
-
-struct _PhotosPrintSetup
-{
- GtkGrid parent_instance;
- PhotosPrintSetupPrivate *priv;
-};
-
-struct _PhotosPrintSetupClass
-{
- GtkGridClass parent_class;
-};
+typedef struct _PhotosPrintSetup PhotosPrintSetup;
+typedef struct _PhotosPrintSetupClass PhotosPrintSetupClass;
GType photos_print_setup_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]