Exemplo n.º 1
0
static GObject *
gimp_dialog_constructor (GType                  type,
                         guint                  n_params,
                         GObjectConstructParam *params)
{
  GObject      *object;
  GimpHelpFunc  help_func;
  const gchar  *help_id;

  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);

  help_func = g_object_get_data (object, "gimp-dialog-help-func");
  help_id   = g_object_get_data (object, "gimp-dialog-help-id");

  if (help_func)
    gimp_help_connect (GTK_WIDGET (object), help_func, help_id, object);

  if (show_help_button && help_func && help_id)
    {
      GtkDialog *dialog = GTK_DIALOG (object);
      GtkWidget *button = gtk_button_new_from_stock (GTK_STOCK_HELP);

      gtk_box_pack_end (GTK_BOX (dialog->action_area), button, FALSE, TRUE, 0);
      gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (dialog->action_area),
                                          button, TRUE);
      gtk_widget_show (button);

      g_signal_connect_object (button, "clicked",
                               G_CALLBACK (gimp_dialog_help),
                               dialog, G_CONNECT_SWAPPED);

      g_object_set_data (object, "gimp-dialog-help-button", button);
    }

  return object;
}
Exemplo n.º 2
0
void
gradients_save_as_pov_ray_cmd_callback (GtkAction *action,
                                        gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpGradient        *gradient;
  GtkWidget           *dialog;

  context  = gimp_container_view_get_context (editor->view);
  gradient = gimp_context_get_gradient (context);

  if (! gradient)
    return;

#define SAVE_AS_POV_DIALOG_KEY "gimp-save-as-pov-ray-dialog"

  dialog = dialogs_get_dialog (G_OBJECT (gradient), SAVE_AS_POV_DIALOG_KEY);

  if (! dialog)
    {
      gchar *title = g_strdup_printf (_("Save '%s' as POV-Ray"),
                                      gimp_object_get_name (gradient));

      dialog = gtk_file_chooser_dialog_new (title, NULL,
                                            GTK_FILE_CHOOSER_ACTION_SAVE,

                                            _("_Cancel"), GTK_RESPONSE_CANCEL,
                                            _("_Save"),   GTK_RESPONSE_OK,

                                            NULL);

      g_free (title);

      gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
      gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                               GTK_RESPONSE_OK,
                                               GTK_RESPONSE_CANCEL,
                                               -1);

      g_object_set_data (G_OBJECT (dialog), "gimp", context->gimp);

      gtk_window_set_screen (GTK_WINDOW (dialog),
                             gtk_widget_get_screen (GTK_WIDGET (editor)));
      gtk_window_set_role (GTK_WINDOW (dialog), "gimp-gradient-save-pov");
      gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);

      gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
                                                      TRUE);

      g_signal_connect (dialog, "response",
                        G_CALLBACK (gradients_save_as_pov_ray_response),
                        gradient);
      g_signal_connect (dialog, "delete-event",
                        G_CALLBACK (gtk_true),
                        NULL);

      g_signal_connect_object (dialog, "destroy",
                               G_CALLBACK (g_object_unref),
                               g_object_ref (gradient),
                               G_CONNECT_SWAPPED);

      gimp_help_connect (dialog, gimp_standard_help_func,
                         GIMP_HELP_GRADIENT_SAVE_AS_POV, NULL);

      dialogs_attach_dialog (G_OBJECT (gradient),
                             SAVE_AS_POV_DIALOG_KEY, dialog);
    }

  gtk_window_present (GTK_WINDOW (dialog));
}
Exemplo n.º 3
0
void
error_console_save_cmd_callback (GtkAction *action,
                                 gint       value,
                                 gpointer   data)
{
  GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
  GtkFileChooser   *chooser;

  if (value && ! gtk_text_buffer_get_selection_bounds (console->text_buffer,
                                                       NULL, NULL))
    {
      gimp_message (console->gimp, G_OBJECT (console), GIMP_MESSAGE_WARNING,
                    _("Cannot save. Nothing is selected."));
      return;
    }

  if (console->file_dialog)
    {
      gtk_window_present (GTK_WINDOW (console->file_dialog));
      return;
    }

  console->file_dialog =
    gtk_file_chooser_dialog_new (_("Save Error Log to File"), NULL,
                                 GTK_FILE_CHOOSER_ACTION_SAVE,

                                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                 GTK_STOCK_SAVE,   GTK_RESPONSE_OK,

                                 NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (console->file_dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  console->save_selection = value;

  g_object_add_weak_pointer (G_OBJECT (console->file_dialog),
                             (gpointer) &console->file_dialog);

  chooser = GTK_FILE_CHOOSER (console->file_dialog);

  gtk_window_set_screen (GTK_WINDOW (chooser),
                         gtk_widget_get_screen (GTK_WIDGET (console)));

  gtk_window_set_position (GTK_WINDOW (chooser), GTK_WIN_POS_MOUSE);
  gtk_window_set_role (GTK_WINDOW (chooser), "gimp-save-errors");

  gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_OK);
  gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);

  g_signal_connect (chooser, "response",
                    G_CALLBACK (error_console_save_response),
                    console);
  g_signal_connect (chooser, "delete-event",
                    G_CALLBACK (gtk_true),
                    NULL);

  gimp_help_connect (GTK_WIDGET (chooser), gimp_standard_help_func,
                     GIMP_HELP_ERRORS_DIALOG, NULL);

  gtk_widget_show (GTK_WIDGET (chooser));
}
Exemplo n.º 4
0
GtkWidget *
print_page_layout_gui (PrintData   *data,
                       const gchar *help_id)
{
  GtkWidget    *main_hbox;
  GtkWidget    *main_vbox;
  GtkWidget    *button;
  GtkWidget    *frame;
  GtkPageSetup *setup;
  GtkSizeGroup *label_group;
  GtkSizeGroup *entry_group;

  memset (&info, 0, sizeof (PrintSizeInfo));

  info.data         = data;
  info.image_width  = gimp_drawable_width (data->drawable_id);
  info.image_height = gimp_drawable_height (data->drawable_id);

  setup = gtk_print_operation_get_default_page_setup (data->operation);
  if (! setup)
    {
      setup = gtk_page_setup_new ();
      gtk_print_operation_set_default_page_setup (data->operation, setup);
    }

  /*  main hbox  */
  main_hbox = gtk_hbox_new (FALSE, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12);

  /*  main vbox  */
  main_vbox = gtk_vbox_new (FALSE, 12);
  gtk_box_pack_start (GTK_BOX (main_hbox), main_vbox, FALSE, FALSE, 0);
  gtk_widget_show (main_vbox);

  label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
  entry_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  /* size entry area for the image's print size */

  frame = print_size_frame (data, label_group, entry_group);
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  /* offset entry area for the image's offset position */

  frame = print_offset_frame (data, label_group, entry_group);
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  g_object_unref (label_group);
  g_object_unref (entry_group);

  button = gtk_check_button_new_with_mnemonic (_("Ignore Page _Margins"));

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                data->use_full_page);
  gtk_box_pack_start (GTK_BOX (main_vbox), button, FALSE, FALSE, 0);
  g_signal_connect (button, "toggled",
                    G_CALLBACK (print_size_info_use_full_page_toggled),
                    NULL);
  gtk_widget_show (button);

  /* preview */
  frame = gimp_frame_new (_("Preview"));
  gtk_box_pack_start (GTK_BOX (main_hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

  info.preview = print_preview_new (setup, data->drawable_id);
  print_preview_set_use_full_page (PRINT_PREVIEW (info.preview),
                                   data->use_full_page);
  gtk_container_add (GTK_CONTAINER (frame), info.preview);
  gtk_widget_show (info.preview);

  g_signal_connect (info.preview, "offsets-changed",
                    G_CALLBACK (print_size_info_preview_offset_changed),
                    NULL);

  print_size_info_set_page_setup (&info);

  g_signal_connect_object (data->operation, "notify::default-page-setup",
                           G_CALLBACK (print_page_setup_notify),
                           main_hbox, 0);

  gimp_help_connect (main_hbox, gimp_standard_help_func, help_id, NULL);

  return main_hbox;
}
Exemplo n.º 5
0
GtkWidget *
gimp_file_dialog_new (Gimp                 *gimp,
                      GtkFileChooserAction  action,
                      const gchar          *title,
                      const gchar          *role,
                      const gchar          *stock_id,
                      const gchar          *help_id)
{
  GimpFileDialog *dialog;
  GSList         *file_procs;
  const gchar    *automatic;
  const gchar    *automatic_help_id;
  const gchar    *pictures;
  gboolean        local_only;

  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
  g_return_val_if_fail (title != NULL, NULL);
  g_return_val_if_fail (role != NULL, NULL);
  g_return_val_if_fail (stock_id != NULL, NULL);
  g_return_val_if_fail (help_id != NULL, NULL);

  switch (action)
    {
    case GTK_FILE_CHOOSER_ACTION_OPEN:
      file_procs = gimp->plug_in_manager->load_procs;
      automatic  = _("Automatically Detected");
      automatic_help_id = GIMP_HELP_FILE_OPEN_BY_EXTENSION;

      /* FIXME */
      local_only = (gimp_pdb_lookup_procedure (gimp->pdb,
                                               "file-uri-load") == NULL);
      break;

    case GTK_FILE_CHOOSER_ACTION_SAVE:
      file_procs = gimp->plug_in_manager->save_procs;
      automatic  = _("By Extension");
      automatic_help_id = GIMP_HELP_FILE_SAVE_BY_EXTENSION;

      /* FIXME */
      local_only = (gimp_pdb_lookup_procedure (gimp->pdb,
                                               "file-uri-save") == NULL);
      break;

    default:
      g_return_val_if_reached (NULL);
      return NULL;
    }

  dialog = g_object_new (GIMP_TYPE_FILE_DIALOG,
                         "title",                     title,
                         "role",                      role,
                         "action",                    action,
                         "local-only",                local_only,
                         "do-overwrite-confirmation", TRUE,
                         NULL);

  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                          stock_id,         GTK_RESPONSE_OK,
                          NULL);

  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_help_connect (GTK_WIDGET (dialog),
                     gimp_file_dialog_help_func, help_id, dialog);

  if (GIMP_GUI_CONFIG (gimp->config)->show_help_button && help_id)
    {
      GtkWidget *action_area = GTK_DIALOG (dialog)->action_area;
      GtkWidget *button      = gtk_button_new_from_stock (GTK_STOCK_HELP);

      gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0);
      gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area),
                                          button, TRUE);
      gtk_widget_show (button);

      g_object_set_data_full (G_OBJECT (dialog), "gimp-dialog-help-id",
                              g_strdup (help_id),
                              (GDestroyNotify) g_free);

      g_signal_connect (button, "clicked",
                        G_CALLBACK (gimp_file_dialog_help_clicked),
                        dialog);

      g_object_set_data (G_OBJECT (dialog), "gimp-dialog-help-button", button);
    }

  pictures = gimp_user_directory (GIMP_USER_DIRECTORY_PICTURES);

  if (pictures)
    gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
                                          pictures, NULL);

  gimp_file_dialog_add_preview (dialog, gimp);

  gimp_file_dialog_add_filters (dialog, gimp, file_procs);

  gimp_file_dialog_add_proc_selection (dialog, gimp, file_procs, automatic,
                                       automatic_help_id);

  dialog->progress = gimp_progress_box_new ();
  gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox), dialog->progress,
                    FALSE, FALSE, 0);

  return GTK_WIDGET (dialog);
}