static void
photos_zoom_controls_update_buttons (PhotosZoomControls *self)
{
  GtkWidget *image;
  gboolean zoom_best_fit_enabled;
  gboolean zoom_out_enabled;
  const gchar *icon_name;

  zoom_best_fit_enabled = g_action_get_enabled (self->zoom_best_fit_action);
  zoom_out_enabled = g_action_get_enabled (self->zoom_out_action);
  g_return_if_fail (zoom_best_fit_enabled == zoom_out_enabled);

  gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), zoom_out_enabled);

  gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), NULL);
  gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->zoom_toggle_button), NULL);

  if (zoom_out_enabled)
    {
      gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), "app.zoom-best-fit");
    }
  else
    {
      GVariant *target_value = NULL;

      target_value = photos_utils_create_zoom_target_value (1.0, PHOTOS_ZOOM_EVENT_MOUSE_CLICK);
      gtk_actionable_set_action_target_value (GTK_ACTIONABLE (self->zoom_toggle_button), target_value);
      gtk_actionable_set_action_name (GTK_ACTIONABLE (self->zoom_toggle_button), "app.zoom-in");
    }

  icon_name = zoom_out_enabled ? "zoom-fit-best-symbolic" : "zoom-in-symbolic";
  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_INVALID);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
  gtk_button_set_image (GTK_BUTTON (self->zoom_toggle_button), image);
}
Example #2
0
gchar *
photos_utils_print_zoom_action_detailed_name (const gchar *action_name, gdouble delta, PhotosZoomEvent event)
{
  g_autoptr (GVariant) target_value = NULL;
  gchar *ret_val = NULL;

  g_return_val_if_fail (action_name != NULL && action_name[0] != '\0', NULL);
  g_return_val_if_fail (delta >= 0.0, NULL);
  g_return_val_if_fail (event != PHOTOS_ZOOM_EVENT_NONE, NULL);

  target_value = photos_utils_create_zoom_target_value (delta, event);
  target_value = g_variant_ref_sink (target_value);

  ret_val = g_action_print_detailed_name (action_name, target_value);

  return ret_val;
}