[gnome-photos] application, tool-colors, tool-crop: Simplify code



commit e95a53f3d4510507c4094512c9d74f091297d439
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Dec 3 14:13:30 2017 +0100

    application, tool-colors, tool-crop: Simplify code

 src/photos-application.c |   13 +++----------
 src/photos-tool-colors.c |   10 ++--------
 src/photos-tool-crop.c   |    6 +-----
 3 files changed, 6 insertions(+), 23 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 26c8f66..3a43de6 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1804,7 +1804,6 @@ photos_application_startup (GApplication *application)
   GtkIconTheme *icon_theme;
   GtkSettings *settings;
   GVariant *state;
-  GVariantType *parameter_type;
   const gchar *delete_accels[3] = {"Delete", "KP_Delete", NULL};
   const gchar *edit_accels[2] = {"<Primary>e", NULL};
   const gchar *fullscreen_accels[2] = {"F11", NULL};
@@ -1883,20 +1882,14 @@ photos_application_startup (GApplication *application)
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
   g_object_unref (action);
 
-  parameter_type = g_variant_type_new ("a{sd}");
-  self->blacks_exposure_action = g_simple_action_new ("blacks-exposure-current", parameter_type);
+  self->blacks_exposure_action = g_simple_action_new ("blacks-exposure-current", G_VARIANT_TYPE ("a{sd}"));
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->blacks_exposure_action));
-  g_variant_type_free (parameter_type);
 
-  parameter_type = g_variant_type_new ("a{sd}");
-  self->brightness_contrast_action = g_simple_action_new ("brightness-contrast-current", parameter_type);
+  self->brightness_contrast_action = g_simple_action_new ("brightness-contrast-current", G_VARIANT_TYPE 
("a{sd}"));
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->brightness_contrast_action));
-  g_variant_type_free (parameter_type);
 
-  parameter_type = g_variant_type_new ("a{sd}");
-  self->crop_action = g_simple_action_new ("crop-current", parameter_type);
+  self->crop_action = g_simple_action_new ("crop-current", G_VARIANT_TYPE ("a{sd}"));
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->crop_action));
-  g_variant_type_free (parameter_type);
 
   self->delete_action = g_simple_action_new ("delete", NULL);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->delete_action));
diff --git a/src/photos-tool-colors.c b/src/photos-tool-colors.c
index d2b37f7..89c5af9 100644
--- a/src/photos-tool-colors.c
+++ b/src/photos-tool-colors.c
@@ -87,20 +87,17 @@ photos_tool_colors_blacks_exposure_value_changed_timeout (gpointer user_data)
 {
   PhotosToolColors *self = PHOTOS_TOOL_COLORS (user_data);
   GVariantBuilder parameter;
-  GVariantType *parameter_type;
   gdouble blacks;
   gdouble exposure;
 
   blacks = gtk_range_get_value (GTK_RANGE (self->blacks_scale));
   exposure = gtk_range_get_value (GTK_RANGE (self->exposure_scale));
 
-  parameter_type = g_variant_type_new ("a{sd}");
-  g_variant_builder_init (&parameter, parameter_type);
+  g_variant_builder_init (&parameter, G_VARIANT_TYPE ("a{sd}"));
   g_variant_builder_add (&parameter, "{sd}", "blacks", blacks);
   g_variant_builder_add (&parameter, "{sd}", "exposure", exposure);
   g_action_activate (self->blacks_exposure, g_variant_builder_end (&parameter));
 
-  g_variant_type_free (parameter_type);
   self->blacks_exposure_value_changed_id = 0;
   return G_SOURCE_REMOVE;
 }
@@ -111,7 +108,6 @@ photos_tool_colors_brightness_contrast_value_changed_timeout (gpointer user_data
 {
   PhotosToolColors *self = PHOTOS_TOOL_COLORS (user_data);
   GVariantBuilder parameter;
-  GVariantType *parameter_type;
   gdouble brightness;
   gdouble contrast;
   gdouble contrast_real;
@@ -120,13 +116,11 @@ photos_tool_colors_brightness_contrast_value_changed_timeout (gpointer user_data
   contrast = gtk_range_get_value (GTK_RANGE (self->contrast_scale));
 
   contrast_real = pow (2.0, contrast);
-  parameter_type = g_variant_type_new ("a{sd}");
-  g_variant_builder_init (&parameter, parameter_type);
+  g_variant_builder_init (&parameter, G_VARIANT_TYPE ("a{sd}"));
   g_variant_builder_add (&parameter, "{sd}", "brightness", brightness);
   g_variant_builder_add (&parameter, "{sd}", "contrast", contrast_real);
   g_action_activate (self->brightness_contrast, g_variant_builder_end (&parameter));
 
-  g_variant_type_free (parameter_type);
   self->brightness_contrast_value_changed_id = 0;
   return G_SOURCE_REMOVE;
 }
diff --git a/src/photos-tool-crop.c b/src/photos-tool-crop.c
index dff3387..576e779 100644
--- a/src/photos-tool-crop.c
+++ b/src/photos-tool-crop.c
@@ -1111,7 +1111,6 @@ photos_tool_crop_deactivate (PhotosTool *tool)
   if (!self->reset)
     {
       GVariantBuilder parameter;
-      GVariantType *parameter_type;
       gdouble zoom;
 
       zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (self->view));
@@ -1122,15 +1121,12 @@ photos_tool_crop_deactivate (PhotosTool *tool)
        * factor will cancel itself in the numerator and denominator,
        * so, in practice, the conversion is unnecessary.
        */
-      parameter_type = g_variant_type_new ("a{sd}");
-      g_variant_builder_init (&parameter, parameter_type);
+      g_variant_builder_init (&parameter, G_VARIANT_TYPE ("a{sd}"));
       g_variant_builder_add (&parameter, "{sd}", "height", self->crop_height / zoom);
       g_variant_builder_add (&parameter, "{sd}", "width", self->crop_width / zoom);
       g_variant_builder_add (&parameter, "{sd}", "x", self->crop_x / zoom);
       g_variant_builder_add (&parameter, "{sd}", "y", self->crop_y / zoom);
       g_action_activate (self->crop, g_variant_builder_end (&parameter));
-
-      g_variant_type_free (parameter_type);
     }
 
   if (self->size_allocate_id != 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]