Example #1
0
static void
gimp_operation_tool_unlink_chains (GimpOperationTool *op_tool)
{
  GObject *options_gui = g_weak_ref_get (&op_tool->options_gui_ref);
  GList   *chains;

  g_return_if_fail (options_gui != NULL);

  chains = g_object_get_data (options_gui, "chains");

  while (chains)
    {
      GimpChainButton *chain = chains->data;
      gboolean         active;

      active = gimp_chain_button_get_active (chain);

      g_object_set_data (G_OBJECT (chain), "was-active",
                         GINT_TO_POINTER (active));

      if (active)
        {
          gimp_chain_button_set_active (chain, FALSE);

          g_signal_emit_by_name (chain, "toggled");
        }

      chains = chains->next;
    }

  g_object_unref (options_gui);
}
Example #2
0
static void
gimp_prop_table_chain_toggled (GimpChainButton *chain,
                               GtkAdjustment   *x_adj)
{
  GtkAdjustment *y_adj;

  y_adj = g_object_get_data (G_OBJECT (x_adj), "y-adjustment");

  if (gimp_chain_button_get_active (chain))
    {
      GBinding *binding;

      binding = g_object_bind_property (x_adj, "value",
                                        y_adj,   "value",
                                        G_BINDING_BIDIRECTIONAL);

      g_object_set_data (G_OBJECT (chain), "binding", binding);
    }
  else
    {
      GBinding *binding;

      binding = g_object_get_data (G_OBJECT (chain), "binding");

      g_object_unref (binding);
      g_object_set_data (G_OBJECT (chain), "binding", NULL);
    }
}
Example #3
0
static void
entry_callback (GtkWidget *widget,
                gpointer   data)
{
  static gdouble x = -1.0;
  static gdouble y = -1.0;
  gdouble new_x;
  gdouble new_y;

  new_x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
  new_y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);

  if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (data)))
    {
      if (new_x != x)
        {
          y = new_y = x = new_x;
          gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, y);
        }
      if (new_y != y)
        {
          x = new_x = y = new_y;
          gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, x);
        }
    }
  else
    {
      x = new_x;
      y = new_y;
    }
}
Example #4
0
static void
top_changed_cb(GtkWidget *widget, gpointer data)
{
   GridDialog_t *dialog = (GridDialog_t*) data;

   grid_assign_value(widget, data, &grid_top);
   if (gimp_chain_button_get_active(
          GIMP_CHAIN_BUTTON(dialog->chain_left_top))) {
      gint value = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
      gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->left), value);
   }
}
Example #5
0
static void
x_changed_cb(GtkWidget *widget, gpointer data)
{
   RectangleProperties_t *props = (RectangleProperties_t*) data;
   Object_t *obj = props->obj;
   gint x = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));

   if (gimp_chain_button_get_active(GIMP_CHAIN_BUTTON(props->chain_button)))
      gtk_spin_button_set_value(GTK_SPIN_BUTTON(props->y), x);

   ObjectToRectangle(obj)->x = x;
   edit_area_info_dialog_emit_geometry_signal(obj->class->info_dialog);
}
Example #6
0
static void
gimp_coordinates_chainbutton_toggled (GimpChainButton *button,
                                      GimpSizeEntry   *entry)
{
  if (gimp_chain_button_get_active (button))
    {
      GimpCoordinatesData *data;

      data = g_object_get_data (G_OBJECT (entry), "coordinates-data");

      data->orig_x = gimp_size_entry_get_refval (entry, 0);
      data->orig_y = gimp_size_entry_get_refval (entry, 1);
    }
}
Example #7
0
static void
color_callback (GtkWidget *widget,
                gpointer   data)
{
  if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (data)))
    {
      GimpRGB  color;

      gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);

      if (widget == vcolor_button)
        gimp_color_button_set_color (GIMP_COLOR_BUTTON (hcolor_button), &color);
      else if (widget == hcolor_button)
        gimp_color_button_set_color (GIMP_COLOR_BUTTON (vcolor_button), &color);
    }
}
Example #8
0
static void
load_dialog_ratio_callback (GtkAdjustment *adj,
                            gpointer       data)
{
  gdouble x = gtk_adjustment_get_value (GTK_ADJUSTMENT (xadj));
  gdouble y = gtk_adjustment_get_value (GTK_ADJUSTMENT (yadj));

  if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (constrain)))
    {
      if (x != ratio_x)
        y = x;
      else
        x = y;
    }

  load_dialog_set_ratio (x, y);
}
Example #9
0
static void
load_dialog_size_callback (GtkWidget *widget,
                           gpointer   data)
{
  if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (constrain)))
    {
      gdouble x = gimp_size_entry_get_refval (size, 0) / (gdouble) wmf_width;
      gdouble y = gimp_size_entry_get_refval (size, 1) / (gdouble) wmf_height;

      if (x != ratio_x)
        {
          load_dialog_set_ratio (x, x);
        }
      else if (y != ratio_y)
        {
          load_dialog_set_ratio (y, y);
        }
    }
}
Example #10
0
/* -----------------------------
 * p_ratio_callback
 * -----------------------------
 */
static void
p_ratio_callback(GtkWidget *w, gpointer   data)
{
  GapResizePrivateType *res_private;
  gdouble        width;
  gdouble        height;
  gdouble        ratio_x;
  gdouble        ratio_y;

  res_private  = (GapResizePrivateType *) data;
  if(res_private == NULL) {return;}
  if(res_private->in_call) {return;}

  width  = GTK_ADJUSTMENT (res_private->width_adj)->value;
  height = GTK_ADJUSTMENT (res_private->height_adj)->value;

  ratio_x = GTK_ADJUSTMENT (res_private->ratio_x_adj)->value;
  ratio_y = GTK_ADJUSTMENT (res_private->ratio_y_adj)->value;

  if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (res_private->constrain)))
  {
    if (ratio_x != res_private->ratio_x)
    {
          ratio_y = ratio_x;
    }
    else
    {
          ratio_x = ratio_y;
    }
  }

  width  = CLAMP (res_private->orig_width * ratio_x,
                  GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
  height = CLAMP (res_private->orig_height * ratio_y,
                  GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);

  p_size_update (res_private, width, height, ratio_x, ratio_y);

}  /* end p_ratio_callback */
Example #11
0
static void
glasstile_chain_toggled (GtkWidget *widget,
                         gboolean  *value)
{
  *value = gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (widget));
}
Example #12
0
gboolean
dialog (gint32              image_ID,
	GimpDrawable       *drawable,
	PlugInVals         *vals,
	PlugInImageVals    *image_vals,
	PlugInDrawableVals *drawable_vals,
	PlugInUIVals       *ui_vals)
{
#if 1
    // quarl 2007-03-03
    //     No dialog for now.  Shouldn't be called.
    abort();
#else
  GtkWidget *dlg;
  GtkWidget *main_vbox;
  GtkWidget *frame;
  GtkWidget *table;
  GtkWidget *hbox;
  GtkWidget *hbox2;
  GtkWidget *coordinates;
  GtkWidget *combo;
  GtkObject *adj;
  gint       row;
  gboolean   run = FALSE;
  GimpUnit   unit;
  gdouble    xres, yres;

  ui_state = ui_vals;

  gimp_ui_init (PLUGIN_NAME, TRUE);

  dlg = gimp_dialog_new (_("Deskew"), PLUGIN_NAME,
                         NULL, 0,
			 gimp_standard_help_func, "gimp-deskew-plug-in",

			 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			 GTK_STOCK_OK,     GTK_RESPONSE_OK,

			 NULL);

  main_vbox = gtk_vbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dlg)->vbox), main_vbox);

  /*  gimp_scale_entry_new() examples  */

  frame = gimp_frame_new (_("ScaleEntry Examples"));
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (3, 3, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  row = 0;

  adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
			      _("Dummy 1:"), SCALE_WIDTH, SPIN_BUTTON_WIDTH,
			      vals->dummy1, 0, 100, 1, 10, 0,
			      TRUE, 0, 0,
			      _("Dummy scale entry 1"), NULL);
  g_signal_connect (adj, "value_changed",
                    G_CALLBACK (gimp_int_adjustment_update),
                    &vals->dummy1);

  adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
			      _("Dummy 2:"), SCALE_WIDTH, SPIN_BUTTON_WIDTH,
			      vals->dummy2, 0, 200, 1, 10, 0,
			      TRUE, 0, 0,
			      _("Dummy scale entry 2"), NULL);
  g_signal_connect (adj, "value_changed",
                    G_CALLBACK (gimp_int_adjustment_update),
                    &vals->dummy2);

  adj = gimp_scale_entry_new (GTK_TABLE (table), 0, row++,
			      _("Dummy 3:"), SCALE_WIDTH, SPIN_BUTTON_WIDTH,
			      vals->dummy3, -100, 100, 1, 10, 0,
			      TRUE, 0, 0,
			      _("Dummy scale entry 3"), NULL);
  g_signal_connect (adj, "value_changed",
                    G_CALLBACK (gimp_int_adjustment_update),
                    &vals->dummy3);

  /*  gimp_random_seed_new() example  */

  frame = gimp_frame_new (_("A Random Seed Entry"));
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);
  hbox = gtk_hbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (frame), hbox);
  gtk_widget_show (hbox);

  hbox2 = gimp_random_seed_new (&vals->seed, &vals->random_seed);
  gtk_widget_set_size_request (GTK_WIDGET (GIMP_RANDOM_SEED_SPINBUTTON (hbox2)),
                               RANDOM_SEED_WIDTH, -1);
  gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
  gtk_widget_show (hbox2);

  /*  gimp_coordinates_new() example  */

  frame = gimp_frame_new (_("A GimpCoordinates Widget\n"
			   "Initialized with the Drawable's Size"));
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  hbox = gtk_hbox_new (FALSE, 4);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
  gtk_container_add (GTK_CONTAINER (frame), hbox);
  gtk_widget_show (hbox);

  unit = gimp_image_get_unit (image_ID);
  gimp_image_get_resolution (image_ID, &xres, &yres);

  coordinates = gimp_coordinates_new (unit, "%p", TRUE, TRUE, SPIN_BUTTON_WIDTH,
				      GIMP_SIZE_ENTRY_UPDATE_SIZE,

				      ui_vals->chain_active, TRUE,

				      _("Width:"), drawable->width, xres,
				      1, GIMP_MAX_IMAGE_SIZE,
				      0, drawable->width,

				      _("Height:"), drawable->height, yres,
				      1, GIMP_MAX_IMAGE_SIZE,
				      0, drawable->height);
  gtk_box_pack_start (GTK_BOX (hbox), coordinates, FALSE, FALSE, 0);
  gtk_widget_show (coordinates);

  /*  Image and drawable menus  */

  frame = gimp_frame_new (_("Image and Drawable Menu Examples"));
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  table = gtk_table_new (3, 2, FALSE);
  gtk_container_set_border_width (GTK_CONTAINER (table), 4);
  gtk_table_set_col_spacings (GTK_TABLE (table), 4);
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
  gtk_container_add (GTK_CONTAINER (frame), table);
  gtk_widget_show (table);

  row = 0;

  combo = gimp_layer_combo_box_new (NULL, NULL);
  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), drawable->drawable_id,
                              G_CALLBACK (gimp_int_combo_box_get_active),
                              &drawable_vals->drawable_id);

  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
			     _("Layers:"), 0.0, 0.5, combo, 1, FALSE);

  combo = gimp_image_combo_box_new (dialog_image_constraint_func, NULL);
  gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), image_ID,
                              G_CALLBACK (gimp_int_combo_box_get_active),
                              &image_vals->image_id);

  gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
			     _("RGB Images:"), 0.0, 0.5, combo, 1, FALSE);

  /*  Show the main containers  */

  gtk_widget_show (main_vbox);
  gtk_widget_show (dlg);

  run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);

  if (run)
    {
      /*  Save ui values  */
      ui_state->chain_active =
        gimp_chain_button_get_active (GIMP_COORDINATES_CHAINBUTTON (coordinates));
    }

  gtk_widget_destroy (dlg);

  return run;
#endif
}
Example #13
0
static void
print_size_info_set_page_setup (PrintSizeInfo *info)
{
  GtkPageSetup *setup;
  PrintData    *data = info->data;
  gdouble       page_width;
  gdouble       page_height;
  gdouble       x;
  gdouble       y;

  setup = gtk_print_operation_get_default_page_setup (data->operation);

  print_size_info_get_page_dimensions (info,
                                       &page_width, &page_height,
                                       GTK_UNIT_INCH);

  page_width  *= gimp_unit_get_factor (data->unit);
  page_height *= gimp_unit_get_factor (data->unit);

  if (info->area_label)
    {
      gchar *format;
      gchar *text;

      format = g_strdup_printf ("%%.%df x %%.%df %s",
                                gimp_unit_get_digits (data->unit),
                                gimp_unit_get_digits (data->unit),
                                gimp_unit_get_plural (data->unit));
      text = g_strdup_printf (format, page_width, page_height);
      g_free (format);

      gtk_label_set_text (GTK_LABEL (info->area_label), text);
      g_free (text);
    }

  x = page_width;
  y = page_height;

  if (info->chain && gimp_chain_button_get_active (info->chain))
    {
      gdouble ratio_x = page_width  / (gdouble) info->image_width;
      gdouble ratio_y = page_height / (gdouble) info->image_height;

      if (ratio_x < ratio_y)
        y = (gdouble) info->image_height * ratio_x;
      else
        x = (gdouble) info->image_width  * ratio_y;
    }

  gimp_size_entry_set_value_boundaries (info->size_entry, WIDTH,
                                        page_width  / 100.0, x);
  gimp_size_entry_set_value_boundaries (info->size_entry, HEIGHT,
                                        page_height / 100.0, y);

  print_size_info_get_page_dimensions (info,
                                       &page_width, &page_height,
                                       GTK_UNIT_POINTS);

  x = (gdouble) info->image_width  / page_width  * 72.0;
  y = (gdouble) info->image_height / page_height * 72.0;

  if (info->chain && gimp_chain_button_get_active (info->chain))
    {
      gdouble max = MAX (x, y);

      x = y = max;
    }

  gimp_size_entry_set_refval_boundaries (info->resolution_entry, 0,
                                         x, GIMP_MAX_RESOLUTION);
  gimp_size_entry_set_refval_boundaries (info->resolution_entry, 1,
                                         y, GIMP_MAX_RESOLUTION);
}
gint
dialog_I (PlugInImageVals * image_vals,
          PlugInDrawableVals * drawable_vals,
          PlugInVals * vals,
          PlugInUIVals * ui_vals,
          PlugInColVals * col_vals,
          PlugInDialogVals * dialog_vals)
{
    gint32 image_ID;
    gint32 layer_ID;
    gint orig_width, orig_height;
    GtkWidget *main_hbox;
    GtkWidget *vbox;
    GtkWidget *vbox2;
    GtkWidget *vbox3;
    GtkWidget *hbox;
    GtkWidget *hbox2;
    GtkWidget *frame;

    GtkWidget *filler;
    GtkWidget *pres_use_image;
    GtkWidget *disc_use_image;
    GtkWidget *rigmask_use_image;
    //GtkWidget *noninter_button;
    GtkWidget *resetvalues_event_box;
    GtkWidget *resetvalues_button;
    GtkWidget *resetvalues_icon;

    GtkWidget *flatten_event_box;
    GtkWidget *flatten_button;
    GtkWidget *flatten_icon;
    GtkWidget *show_info_event_box;
    GtkWidget *show_info_button;
    GtkWidget *show_info_icon;
    GtkWidget *dump_event_box;
    GtkWidget *dump_button;
    GtkWidget *dump_icon;
    //GtkWidget *lastvalues_event_box;
    //GtkWidget *lastvalues_button;
    //GtkWidget *lastvalues_icon;
    gboolean has_mask = FALSE;
    GimpUnit unit;
    gdouble xres, yres;
    GtkWidget * v_separator;
    GtkWidget *info_title_label;
    GtkWidget * info_label;

    CarverData * carver_data;

    image_ID = image_vals->image_ID;
    layer_ID = drawable_vals->layer_ID;

    state = g_new (PlugInVals, 1);
    memcpy (state, vals, sizeof (PlugInVals));

    ui_state = g_new (PlugInUIVals, 1);
    memcpy (ui_state, ui_vals, sizeof (PlugInUIVals));

    dialog_state = dialog_vals;

    orig_width = gimp_drawable_width (layer_ID);
    orig_height = gimp_drawable_height (layer_ID);

    g_assert (gimp_drawable_is_layer (layer_ID) == TRUE);

    interface_I_data.orig_width = orig_width;
    interface_I_data.orig_height = orig_height;
    interface_I_data.col_vals = col_vals;
    interface_I_data.vmap_layer_ID = -1;

    reader_go = TRUE;

    if (gimp_layer_get_mask (layer_ID) != -1)
    {
        has_mask = TRUE;
    }

    dlg = gtk_dialog_new_with_buttons (_("GIMP LiquidRescale Plug-In"),
                                       NULL, 0,
                                       //GIMP_STOCK_RESET, RESPONSE_RESET,
                                       //GTK_STOCK_REFRESH, RESPONSE_REFRESH,
                                       GTK_STOCK_GO_BACK, RESPONSE_NONINTERACTIVE,
                                       GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL);

    gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE);

    gtk_window_set_keep_above(GTK_WINDOW (dlg), TRUE);

    if (dialog_state->has_pos)
    {
        //printf("move window, x,y=%i,%i\n", dialog_state->x, dialog_state->y); fflush(stdout);
        gtk_window_move (GTK_WINDOW(dlg), dialog_state->x, dialog_state->y);
        dialog_state->has_pos = FALSE;
    }

    g_signal_connect (dlg, "response", G_CALLBACK (callback_dialog_I_response),
                      (gpointer) (NULL));

    /* dlg_tips = gtk_tooltips_new (); */

    main_hbox = gtk_hbox_new (FALSE, 12);
    gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12);
    gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area(GTK_DIALOG (dlg))), main_hbox);

    vbox = gtk_vbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (main_hbox), vbox, TRUE, TRUE, 0);
    gtk_widget_show (vbox);

    /*  New size  */

    frame = gimp_frame_new (_("Set width and height"));
    gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
    gtk_widget_show (frame);

    hbox = gtk_hbox_new (FALSE, 4);
    gtk_container_add (GTK_CONTAINER (frame), hbox);
    gtk_widget_show (hbox);

    vbox3 = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (hbox), vbox3, FALSE, FALSE, 0);
    gtk_widget_show (vbox3);

    unit = gimp_image_get_unit (image_ID);
    gimp_image_get_resolution (image_ID, &xres, &yres);

    coordinates =
        alt_coordinates_new (unit, "%p", TRUE, TRUE, SPIN_BUTTON_WIDTH,
                             ALT_SIZE_ENTRY_UPDATE_SIZE, ui_state->chain_active,
                             TRUE, _("Width:"), state->new_width, xres, 2,
                             GIMP_MAX_IMAGE_SIZE, 0, orig_width,
                             _("Height:"), state->new_height, yres, 2,
                             GIMP_MAX_IMAGE_SIZE, 0, orig_height);

    interface_I_data.coordinates = coordinates;

    g_signal_connect (ALT_SIZE_ENTRY (coordinates), "value-changed",
                      G_CALLBACK (callback_size_changed),
                      (gpointer) & interface_I_data);

    g_signal_connect (ALT_SIZE_ENTRY (coordinates), "refval-changed",
                      G_CALLBACK (callback_size_changed),
                      (gpointer) & interface_I_data);

    g_signal_connect (ALT_SIZE_ENTRY (coordinates), "coordinates-alarm",
                      G_CALLBACK (callback_alarm_triggered),
                      (gpointer) & interface_I_data);

    gtk_box_pack_start (GTK_BOX (vbox3), coordinates, FALSE, FALSE, 0);
    gtk_widget_show (coordinates);

    /* Aux layer usage icons */

    hbox2 = gtk_hbox_new (FALSE, 10);
    gtk_container_set_border_width (GTK_CONTAINER (hbox2), 4);
    gtk_box_pack_start (GTK_BOX (vbox3), hbox2, FALSE, FALSE, 0);
    gtk_widget_show (hbox2);

    filler = gtk_image_new ();
    gtk_box_pack_start (GTK_BOX (hbox2), filler, TRUE, TRUE, 0);
    gtk_widget_show (filler);
    filler = gtk_image_new ();
    gtk_box_pack_end (GTK_BOX (hbox2), filler, TRUE, TRUE, 0);
    gtk_widget_show (filler);

    pres_use_image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_GREEN,
                     GTK_ICON_SIZE_MENU);

    gtk_box_pack_start (GTK_BOX (hbox2), pres_use_image, FALSE, FALSE, 0);

    gtk_widget_show (pres_use_image);

    disc_use_image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_RED,
                     GTK_ICON_SIZE_MENU);

    gtk_box_pack_start (GTK_BOX (hbox2), disc_use_image, FALSE, FALSE, 0);

    gtk_widget_show (disc_use_image);

    rigmask_use_image = gtk_image_new_from_stock (GIMP_STOCK_CHANNEL_BLUE,
                        GTK_ICON_SIZE_MENU);

    gtk_widget_show (rigmask_use_image);

    gtk_box_pack_start (GTK_BOX (hbox2), rigmask_use_image, FALSE, FALSE, 0);

    update_info_aux_use_icons(vals, ui_vals, pres_use_image, disc_use_image, rigmask_use_image);


    /* Reset size button */

    vbox2 = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_end (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
    gtk_widget_show (vbox2);

    resetvalues_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), resetvalues_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (resetvalues_event_box);

    gimp_help_set_help_data (resetvalues_event_box,
                             _
                             ("Reset width and height to their original values"),
                             NULL);

    resetvalues_button = gtk_button_new ();
    resetvalues_icon =
        gtk_image_new_from_stock (GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (resetvalues_button), resetvalues_icon);
    gtk_widget_show (resetvalues_icon);
    gtk_container_add (GTK_CONTAINER (resetvalues_event_box),
                       resetvalues_button);
    gtk_widget_show (resetvalues_button);

    g_signal_connect (resetvalues_button, "clicked",
                      G_CALLBACK (callback_resetvalues_button),
                      (gpointer) & interface_I_data);

    /* Map info */

    v_separator = gtk_vseparator_new();
    gtk_box_pack_start (GTK_BOX (main_hbox), v_separator, TRUE, TRUE, 0);
    gtk_widget_show(v_separator);

    vbox = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
    gtk_widget_show (vbox);

    hbox2 = gtk_hbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
    gtk_widget_show (hbox2);

    info_title_label = gtk_label_new ("");
    /* Please keep the <b> and </b> tags in translations */
    gtk_label_set_markup(GTK_LABEL(info_title_label), _("<b>Map</b>"));
    gtk_box_pack_start (GTK_BOX (hbox2), info_title_label, FALSE, FALSE, 0);
    gtk_widget_show (info_title_label);

    hbox = gtk_hbox_new (FALSE, 12);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    vbox2 = gtk_vbox_new (FALSE, 4);
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
    gtk_widget_show (vbox2);

    show_info_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), show_info_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (show_info_event_box);

    gimp_help_set_help_data (show_info_event_box,
                             _
                             ("Show/hide internal map information"),
                             NULL);

    show_info_button = gtk_toggle_button_new ();
    show_info_icon =
        gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (show_info_button), show_info_icon);
    gtk_widget_show (show_info_icon);
    gtk_container_add (GTK_CONTAINER (show_info_event_box),
                       show_info_button);
    gtk_widget_show (show_info_button);

    g_signal_connect (show_info_button, "toggled",
                      G_CALLBACK (callback_show_info_button),
                      (gpointer) & interface_I_data);


    flatten_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), flatten_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (flatten_event_box);

    gimp_help_set_help_data (flatten_event_box,
                             _
                             ("Reset the internal map"),
                             NULL);

    flatten_button = gtk_button_new ();
    flatten_icon =
        gtk_image_new_from_stock (GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (flatten_button), flatten_icon);
    gtk_widget_show (flatten_icon);
    gtk_container_add (GTK_CONTAINER (flatten_event_box),
                       flatten_button);
    gtk_widget_show (flatten_button);

    g_signal_connect (flatten_button, "clicked",
                      G_CALLBACK (callback_flatten_button),
                      (gpointer) & interface_I_data);

    dump_event_box = gtk_event_box_new ();
    gtk_box_pack_start (GTK_BOX (vbox2), dump_event_box, FALSE, FALSE,
                        0);
    gtk_widget_show (dump_event_box);

    gimp_help_set_help_data (dump_event_box,
                             _
                             ("Dump the internal map on a new layer (RGB images only)"),
                             NULL);

    dump_button = gtk_button_new ();
    dump_icon =
        gtk_image_new_from_stock (GIMP_STOCK_VISIBLE, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (dump_button), dump_icon);
    gtk_widget_show (dump_icon);
    gtk_container_add (GTK_CONTAINER (dump_event_box),
                       dump_button);
    gtk_widget_show (dump_button);

    g_signal_connect (dump_button, "clicked",
                      G_CALLBACK (callback_dump_button),
                      (gpointer) & interface_I_data);

    gtk_widget_set_sensitive(dump_button, FALSE);
    interface_I_data.dump_button = dump_button;

    info_label = gtk_label_new("");
    //set_info_label_text (info_label, orig_width, orig_height, 0, 0, state->enl_step / 100);
    gtk_label_set_selectable(GTK_LABEL(info_label), TRUE);
    //gtk_container_add (GTK_CONTAINER (info_frame), info_label);
    gtk_box_pack_start (GTK_BOX (hbox), info_label, TRUE, TRUE, 0);
    gtk_label_set_justify(GTK_LABEL (info_label), GTK_JUSTIFY_LEFT);
    gtk_widget_show (info_label);

    //interface_I_data.info_frame = info_frame;
    interface_I_data.info_label = info_label;

    callback_show_info_button(show_info_button, (gpointer) &interface_I_data);


    /*
    noninter_button = gtk_button_new_with_mnemonic ("_Non-interactive");

    g_signal_connect (GTK_BUTTON (noninter_button), "clicked",
                      G_CALLBACK (callback_noninter_button), (gpointer) dlg);

    gtk_box_pack_start (GTK_BOX (vbox2), noninter_button, FALSE, FALSE, 0);
    gtk_widget_show (noninter_button);
    */

    /* Initialize the carver */

    AUX_LAYER_STATUS(state->pres_layer_ID, ui_state->pres_status);
    AUX_LAYER_STATUS(state->disc_layer_ID, ui_state->disc_status);
    AUX_LAYER_STATUS(state->rigmask_layer_ID, ui_state->rigmask_status);
    gimp_image_undo_group_start(image_ID);
    carver_data = render_init_carver(image_vals, drawable_vals, state, TRUE);
    gimp_image_undo_group_end(image_ID);
    if (carver_data == NULL)
    {
        return RESPONSE_FATAL;
    }
    interface_I_data.carver_data = carver_data;

    image_vals->image_ID = carver_data->image_ID;
    drawable_vals->layer_ID = carver_data->layer_ID;

    set_info_label_text (&interface_I_data);

    //set_alarm (ALARM_DELAY);
    size_changed = 1;

    /* register size reader */

    g_timeout_add (READER_INTERVAL, check_size_changes, NULL);

    /*  Show the main containers  */

    gtk_widget_show (main_hbox);
    gtk_widget_show (dlg);
    gtk_main ();


    lqr_carver_destroy (carver_data->carver);

    switch (dialog_I_response)
    {
    case RESPONSE_NONINTERACTIVE:
        switch (state->output_target)
        {
        case OUTPUT_TARGET_NEW_LAYER:
        case OUTPUT_TARGET_NEW_IMAGE:
            state->output_target = OUTPUT_TARGET_SAME_LAYER;
            break;
        case OUTPUT_TARGET_SAME_LAYER:
        default:
            break;
        }
    case GTK_RESPONSE_OK:
        /*  Save ui values  */
        ui_state->chain_active =
            gimp_chain_button_get_active (GIMP_COORDINATES_CHAINBUTTON
                                          (coordinates));

        /* save all */
        memcpy (vals, state, sizeof (PlugInVals));
        memcpy (ui_vals, ui_state, sizeof (PlugInUIVals));
        break;
    default:
        break;
    }

    gtk_widget_destroy (dlg);

    reader_go = FALSE;

    return dialog_I_response;
}
Example #15
0
static void
gimp_coordinates_callback (GtkWidget           *widget,
                           GimpCoordinatesData *data)
{
  gdouble new_x;
  gdouble new_y;

  new_x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
  new_y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);

  if (gimp_chain_button_get_active (data->chainbutton))
    {
      if (data->chain_constrains_ratio)
        {
          if ((data->orig_x != 0) && (data->orig_y != 0))
            {
              if (ROUND (new_x) != ROUND (data->last_x))
                {
                  data->last_x = new_x;
                  new_y = (new_x * data->orig_y) / data->orig_x;

                  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1,
                                              new_y);
                  data->last_y
                    = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
                }
              else if (ROUND (new_y) != ROUND (data->last_y))
                {
                  data->last_y = new_y;
                  new_x = (new_y * data->orig_x) / data->orig_y;

                  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0,
                                              new_x);
                  data->last_x
                    = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
                }
            }
        }
      else
        {
          if (new_x != data->last_x)
            {
              new_y = new_x;

              gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, new_x);
              data->last_y = data->last_x
                = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
            }
          else if (new_y != data->last_y)
            {
              new_x = new_y;

              gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, new_y);
              data->last_x = data->last_y
                = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
            }
        }
    }
  else
    {
      if (new_x != data->last_x)
        data->last_x = new_x;
      if (new_y != data->last_y)
        data->last_y = new_y;
    }
}
Example #16
0
static gboolean
tile_dialog (gint32 image_ID,
             gint32 drawable_ID)
{
  GtkWidget *dlg;
  GtkWidget *vbox;
  GtkWidget *frame;
  GtkWidget *sizeentry;
  GtkWidget *chainbutton;
  GtkWidget *toggle;
  gint       width;
  gint       height;
  gdouble    xres;
  gdouble    yres;
  GimpUnit   unit;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, FALSE);

  width  = gimp_drawable_width (drawable_ID);
  height = gimp_drawable_height (drawable_ID);
  unit   = gimp_image_get_unit (image_ID);
  gimp_image_get_resolution (image_ID, &xres, &yres);

  tvals.new_width  = width;
  tvals.new_height = height;

  dlg = gimp_dialog_new (_("Tile"), PLUG_IN_BINARY,
                         NULL, 0,
                         gimp_standard_help_func, PLUG_IN_PROC,

                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                         GTK_STOCK_OK,     GTK_RESPONSE_OK,

                         NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dlg),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dlg));

  vbox = gtk_vbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
                      vbox, TRUE, TRUE, 0);
  gtk_widget_show (vbox);

  frame = gimp_frame_new (_("Tile to New Size"));
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  sizeentry = gimp_coordinates_new (unit, "%a", TRUE, TRUE, 8,
                                    GIMP_SIZE_ENTRY_UPDATE_SIZE,

                                    tvals.constrain, TRUE,

                                    _("_Width:"), width, xres,
                                    1, GIMP_MAX_IMAGE_SIZE,
                                    0, width,

                                    _("_Height:"), height, yres,
                                    1, GIMP_MAX_IMAGE_SIZE,
                                    0, height);
  gtk_container_add (GTK_CONTAINER (frame), sizeentry);
  gtk_table_set_row_spacing (GTK_TABLE (sizeentry), 1, 6);
  gtk_widget_show (sizeentry);

  chainbutton = GTK_WIDGET (GIMP_COORDINATES_CHAINBUTTON (sizeentry));

  toggle = gtk_check_button_new_with_mnemonic (_("C_reate new image"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), tvals.new_image);
  gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
  gtk_widget_show (toggle);

  g_signal_connect (toggle, "toggled",
                    G_CALLBACK (gimp_toggle_button_update),
                    &tvals.new_image);

  gtk_widget_show (dlg);

  run = (gimp_dialog_run (GIMP_DIALOG (dlg)) == GTK_RESPONSE_OK);

  if (run)
    {
      tvals.new_width =
        RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (sizeentry), 0));
      tvals.new_height =
        RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (sizeentry), 1));

      tvals.constrain =
        gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (chainbutton));
    }

  gtk_widget_destroy (dlg);

  return run;
}
Example #17
0
static void
print_size_info_set_resolution (PrintSizeInfo *info,
                                gdouble        xres,
                                gdouble        yres)
{
  PrintData    *data = info->data;
  gdouble       offset_x;
  gdouble       offset_y;
  gdouble       offset_x_max;
  gdouble       offset_y_max;

  if (info->chain && gimp_chain_button_get_active (info->chain))
    {
      if (xres != data->xres)
          yres = xres;
      else
          xres = yres;
    }

  data->xres = xres;
  data->yres = yres;

  g_signal_handlers_block_by_func (info->resolution_entry,
                                   print_size_info_resolution_changed,
                                   NULL);

  gimp_size_entry_set_refval (info->resolution_entry, 0, xres);
  gimp_size_entry_set_refval (info->resolution_entry, 1, yres);

  g_signal_handlers_unblock_by_func (info->resolution_entry,
                                     print_size_info_resolution_changed,
                                     NULL);

  g_signal_handlers_block_by_func (info->size_entry,
                                   print_size_info_size_changed,
                                   NULL);

  gimp_size_entry_set_value (info->size_entry, WIDTH,
                             info->image_width *
                             gimp_unit_get_factor (data->unit) / xres);
  gimp_size_entry_set_value (info->size_entry, HEIGHT,
                             info->image_height *
                             gimp_unit_get_factor (data->unit) / yres);

  g_signal_handlers_unblock_by_func (info->size_entry,
                                     print_size_info_size_changed,
                                     NULL);

  gimp_size_info_get_max_offsets (&offset_x_max, &offset_y_max);

  offset_x = gimp_size_entry_get_refval (info->size_entry, LEFT);
  offset_y = gimp_size_entry_get_refval (info->size_entry, TOP);

  offset_x = CLAMP (offset_x, 0, offset_x_max);
  offset_y = CLAMP (offset_y, 0, offset_y_max);

  data->offset_x = offset_x;
  data->offset_y = offset_y;

  print_size_info_update_offsets ();

  print_preview_set_image_dpi (PRINT_PREVIEW (info->preview),
                               data->xres, data->yres);
  print_preview_set_image_offsets (PRINT_PREVIEW (info->preview),
                                   data->offset_x, data->offset_y);
  print_preview_set_image_offsets_max (PRINT_PREVIEW (info->preview),
                                       offset_x_max, offset_y_max);
}