コード例 #1
0
ファイル: gimpfontselect.c プロジェクト: Amerekanets/gimp
static GObject *
gimp_font_select_constructor (GType                  type,
                              guint                  n_params,
                              GObjectConstructParam *params)
{
  GObject       *object;
  GimpPdbDialog *dialog;

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

  dialog = GIMP_PDB_DIALOG (object);

  dialog->view = gimp_font_view_new (GIMP_VIEW_TYPE_LIST,
                                     dialog->context->gimp->fonts,
                                     dialog->context,
                                     GIMP_VIEW_SIZE_MEDIUM, 1,
                                     dialog->menu_factory);

  gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
                                       6 * (GIMP_VIEW_SIZE_MEDIUM + 2),
                                       6 * (GIMP_VIEW_SIZE_MEDIUM + 2));

  gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->view);
  gtk_widget_show (dialog->view);

  return object;
}
コード例 #2
0
void
documents_raise_or_open_cmd_callback (GtkAction *action,
                                      gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      RaiseClosure closure;

      closure.name  = gimp_object_get_name (imagefile);
      closure.found = FALSE;

      gimp_container_foreach (context->gimp->displays,
                              (GFunc) documents_raise_display,
                              &closure);

      if (! closure.found)
        documents_open_image (GTK_WIDGET (editor), context, imagefile);
    }
}
コード例 #3
0
void
documents_recreate_preview_cmd_callback (GtkAction *action,
                                         gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      GError *error = NULL;

      if (! gimp_imagefile_create_thumbnail (imagefile,
                                             context, NULL,
                                             context->gimp->config->thumbnail_size,
                                             FALSE, &error))
        {
          gimp_message_literal (context->gimp,
                                NULL , GIMP_MESSAGE_ERROR,
                                error->message);
          g_clear_error (&error);
        }
    }
}
コード例 #4
0
void
documents_show_in_file_manager_cmd_callback (GtkAction *action,
                                             gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  imagefile = gimp_context_get_imagefile (context);

  if (imagefile)
    {
      GFile  *file  = g_file_new_for_uri (gimp_object_get_name (imagefile));
      GError *error = NULL;

      if (! gimp_file_show_in_file_manager (file, &error))
        {
          gimp_message (context->gimp, G_OBJECT (editor),
                        GIMP_MESSAGE_ERROR,
                        _("Can't show file in file manager: %s"),
                        error->message);
          g_clear_error (&error);
        }

      g_object_unref (file);
    }
}
コード例 #5
0
static gboolean
gimp_container_editor_get_show_button_bar (GimpDocked *docked)
{
    GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);

    return gimp_docked_get_show_button_bar (GIMP_DOCKED (editor->view));
}
コード例 #6
0
ファイル: images-commands.c プロジェクト: 1ynx/gimp
void
images_raise_views_cmd_callback (GtkAction *action,
                                 gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;
  GimpContext         *context;
  GimpImage           *image;

  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);

  image = gimp_context_get_image (context);

  if (image && gimp_container_have (container, GIMP_OBJECT (image)))
    {
      GList *list;

      for (list = gimp_get_display_iter (image->gimp);
           list;
           list = g_list_next (list))
        {
          GimpDisplay *display = list->data;

          if (gimp_display_get_image (display) == image)
            gimp_display_shell_present (gimp_display_get_shell (display));
        }
    }
}
コード例 #7
0
ファイル: buffers-commands.c プロジェクト: 1ynx/gimp
void
buffers_paste_as_new_cmd_callback (GtkAction *action,
                                   gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;
  GimpContext         *context;
  GimpBuffer          *buffer;

  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);

  buffer = gimp_context_get_buffer (context);

  if (buffer && gimp_container_have (container, GIMP_OBJECT (buffer)))
    {
      GimpImage *image = gimp_context_get_image (context);

      if (image)
        {
          GimpImage *new_image;

          new_image = gimp_image_new_from_buffer (image->gimp, image, buffer);
          gimp_create_display (image->gimp, new_image,
                               GIMP_UNIT_PIXEL, 1.0);
          g_object_unref (new_image);
        }
    }
}
コード例 #8
0
void
tool_presets_save_cmd_callback (GtkAction *action,
                                gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpToolPreset      *preset;
  GimpToolInfo        *tool_info;

  context = gimp_container_view_get_context (editor->view);

  preset    = gimp_context_get_tool_preset (context);
  tool_info = gimp_context_get_tool (gimp_get_user_context (context->gimp));

  if (tool_info && preset)
    {
      GimpToolInfo *preset_tool;

      preset_tool =  gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));

      if (tool_info != preset_tool)
        {
          gimp_message (context->gimp,
                        G_OBJECT (editor), GIMP_MESSAGE_WARNING,
                        _("Can't save '%s' tool options to an "
                          "existing '%s' tool preset."),
                        tool_info->blurb,
                        preset_tool->blurb);
          return;
        }

      gimp_config_sync (G_OBJECT (tool_info->tool_options),
                        G_OBJECT (preset->tool_options), 0);
    }
}
コード例 #9
0
static void
gimp_pattern_select_constructed (GObject *object)
{
  GimpPdbDialog *dialog = GIMP_PDB_DIALOG (object);
  GtkWidget     *content_area;

  if (G_OBJECT_CLASS (parent_class)->constructed)
    G_OBJECT_CLASS (parent_class)->constructed (object);

  dialog->view =
    gimp_pattern_factory_view_new (GIMP_VIEW_TYPE_GRID,
                                   dialog->context->gimp->pattern_factory,
                                   dialog->context,
                                   GIMP_VIEW_SIZE_MEDIUM, 1,
                                   dialog->menu_factory);

  gimp_container_box_set_size_request (GIMP_CONTAINER_BOX (GIMP_CONTAINER_EDITOR (dialog->view)->view),
                                       6 * (GIMP_VIEW_SIZE_MEDIUM + 2),
                                       6 * (GIMP_VIEW_SIZE_MEDIUM + 2));

  gtk_container_set_border_width (GTK_CONTAINER (dialog->view), 12);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_box_pack_start (GTK_BOX (content_area), dialog->view, TRUE, TRUE, 0);
  gtk_widget_show (dialog->view);
}
コード例 #10
0
static void
gimp_container_editor_set_context (GimpDocked  *docked,
                                   GimpContext *context)
{
    GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);

    gimp_docked_set_context (GIMP_DOCKED (editor->view), context);
}
コード例 #11
0
static void
gimp_container_editor_set_show_button_bar (GimpDocked *docked,
        gboolean    show)
{
    GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);

    gimp_docked_set_show_button_bar (GIMP_DOCKED (editor->view), show);
}
コード例 #12
0
ファイル: buffers-commands.c プロジェクト: 1ynx/gimp
void
buffers_delete_cmd_callback (GtkAction *action,
                             gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);

  gimp_container_view_remove_active (editor->view);
}
コード例 #13
0
static GimpUIManager *
gimp_container_editor_get_menu (GimpDocked   *docked,
                                const gchar **ui_path,
                                gpointer     *popup_data)
{
    GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);

    return gimp_docked_get_menu (GIMP_DOCKED (editor->view), ui_path, popup_data);
}
コード例 #14
0
static GtkWidget *
gimp_container_editor_get_preview (GimpDocked   *docked,
                                   GimpContext  *context,
                                   GtkIconSize   size)
{
    GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);

    return gimp_docked_get_preview (GIMP_DOCKED (editor->view),
                                    context, size);
}
コード例 #15
0
void
documents_remove_dangling_cmd_callback (GtkAction *action,
                                        gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;

  container = gimp_container_view_get_container (editor->view);

  gimp_container_foreach (container,
                          (GFunc) documents_remove_dangling_foreach,
                          container);
}
コード例 #16
0
void
documents_reload_previews_cmd_callback (GtkAction *action,
                                        gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;

  container = gimp_container_view_get_container (editor->view);

  gimp_container_foreach (container,
                          (GFunc) gimp_imagefile_update,
                          editor->view);
}
コード例 #17
0
ファイル: gimptemplateview.c プロジェクト: WilfR/Gimp-Matting
static void
gimp_template_view_tree_name_edited (GtkCellRendererText *cell,
                                     const gchar         *path_str,
                                     const gchar         *new_name,
                                     GimpTemplateView    *view)
{
  GimpContainerTreeView *tree_view;
  GtkTreePath           *path;
  GtkTreeIter            iter;

  tree_view = GIMP_CONTAINER_TREE_VIEW (GIMP_CONTAINER_EDITOR (view)->view);

  path = gtk_tree_path_new_from_string (path_str);

  if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
    {
      GimpViewRenderer *renderer;
      GimpObject       *object;
      const gchar      *old_name;

      gtk_tree_model_get (tree_view->model, &iter,
                          GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &renderer,
                          -1);

      object = GIMP_OBJECT (renderer->viewable);

      old_name = gimp_object_get_name (object);

      if (! old_name) old_name = "";
      if (! new_name) new_name = "";

      if (strcmp (old_name, new_name))
        {
          gimp_object_set_name (object, new_name);
        }
      else
        {
          gchar *name = gimp_viewable_get_description (renderer->viewable,
                                                       NULL);

          gtk_tree_store_set (GTK_TREE_STORE (tree_view->model), &iter,
                              GIMP_CONTAINER_TREE_STORE_COLUMN_NAME, name,
                              -1);
          g_free (name);
        }

      g_object_unref (renderer);
    }

  gtk_tree_path_free (path);
}
コード例 #18
0
static void
gimp_data_factory_view_tree_name_edited (GtkCellRendererText *cell,
                                         const gchar         *path_str,
                                         const gchar         *new_name,
                                         GimpDataFactoryView *view)
{
  GimpContainerTreeView *tree_view;
  GtkTreePath           *path;
  GtkTreeIter            iter;

  tree_view = GIMP_CONTAINER_TREE_VIEW (GIMP_CONTAINER_EDITOR (view)->view);

  path = gtk_tree_path_new_from_string (path_str);

  if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
    {
      GimpViewRenderer *renderer;
      GimpData         *data;
      gchar            *name;

      gtk_tree_model_get (tree_view->model, &iter,
                          tree_view->model_column_renderer, &renderer,
                          -1);

      data = GIMP_DATA (renderer->viewable);

      if (! new_name)
        new_name = "";

      name = g_strstrip (g_strdup (new_name));

      if (data->writable && strlen (name))
        {
          gimp_object_take_name (GIMP_OBJECT (data), name);
        }
      else
        {
          g_free (name);

          name = gimp_viewable_get_description (renderer->viewable, NULL);
          gtk_list_store_set (GTK_LIST_STORE (tree_view->model), &iter,
                              tree_view->model_column_name, name,
                              -1);
          g_free (name);
        }

      g_object_unref (renderer);
    }

  gtk_tree_path_free (path);
}
コード例 #19
0
ファイル: actions.c プロジェクト: jiapei100/gimp
gint
action_data_sel_count (gpointer data)
{
  if (GIMP_IS_CONTAINER_EDITOR (data))
    {
      GimpContainerEditor  *editor;

      editor = GIMP_CONTAINER_EDITOR (data);
      return gimp_container_view_get_selected (editor->view, NULL);
    }
  else
    {
      return 0;
    }
}
コード例 #20
0
void
documents_copy_location_cmd_callback (GtkAction *action,
                                      gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  imagefile = gimp_context_get_imagefile (context);

  if (imagefile)
    gimp_clipboard_set_text (context->gimp,
                             gimp_object_get_name (imagefile));
}
コード例 #21
0
void
documents_remove_cmd_callback (GtkAction *action,
                               gpointer   data)
{
  GimpContainerEditor *editor  = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context = gimp_container_view_get_context (editor->view);
  GimpImagefile       *imagefile = gimp_context_get_imagefile (context);
  const gchar         *uri;

  uri = gimp_object_get_name (imagefile);

  gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, NULL);

  gimp_container_view_remove_active (editor->view);
}
コード例 #22
0
void
tool_presets_restore_cmd_callback (GtkAction *action,
                                   gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpToolPreset      *preset;

  context = gimp_container_view_get_context (editor->view);

  preset = gimp_context_get_tool_preset (context);

  if (preset)
    gimp_context_tool_preset_changed (gimp_get_user_context (context->gimp));
}
コード例 #23
0
ファイル: gimptoolview.c プロジェクト: Amerekanets/gimp
static void
gimp_tool_view_destroy (GtkObject *object)
{
  GimpToolView *tool_view = GIMP_TOOL_VIEW (object);

  if (tool_view->visible_handler_id)
    {
      GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (tool_view);
      GimpContainerView   *view   = GIMP_CONTAINER_VIEW (editor->view);

      gimp_container_remove_handler (gimp_container_view_get_container (view),
                                     tool_view->visible_handler_id);
      tool_view->visible_handler_id = 0;
    }

  GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
コード例 #24
0
ファイル: gimpfontview.c プロジェクト: Amerekanets/gimp-1
GtkWidget *
gimp_font_view_new (GimpViewType     view_type,
                    GimpContainer   *container,
                    GimpContext     *context,
                    gint             view_size,
                    gint             view_border_width,
                    GimpMenuFactory *menu_factory)
{
  GimpFontView        *font_view;
  GimpContainerEditor *editor;

  g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (view_size > 0 &&
                        view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
  g_return_val_if_fail (view_border_width >= 0 &&
                        view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
                        NULL);
  g_return_val_if_fail (menu_factory == NULL ||
                        GIMP_IS_MENU_FACTORY (menu_factory), NULL);

  font_view = g_object_new (GIMP_TYPE_FONT_VIEW,
                            "view-type",         view_type,
                            "container",         container,
                            "context",           context,
                            "view-size",         view_size,
                            "view-border-width", view_border_width,
                            "menu-factory",      menu_factory,
                            "menu-identifier",   "<Fonts>",
                            "ui-path",           "/fonts-popup",
                            NULL);

  editor = GIMP_CONTAINER_EDITOR (font_view);

  gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view),
                                       FALSE);

  font_view->refresh_button =
    gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "fonts",
                                   "fonts-refresh", NULL);

  gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)),
                          editor);

  return GTK_WIDGET (font_view);
}
コード例 #25
0
ファイル: buffers-commands.c プロジェクト: 1ynx/gimp
static void
buffers_paste (GimpBufferView *view,
               gboolean        paste_into)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (view);
  GimpContainer       *container;
  GimpContext         *context;
  GimpBuffer          *buffer;

  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);

  buffer = gimp_context_get_buffer (context);

  if (buffer && gimp_container_have (container, GIMP_OBJECT (buffer)))
    {
      GimpDisplay *display = gimp_context_get_display (context);
      GimpImage   *image   = NULL;
      gint         x       = -1;
      gint         y       = -1;
      gint         width   = -1;
      gint         height  = -1;

      if (display)
        {
          GimpDisplayShell *shell = gimp_display_get_shell (display);

          gimp_display_shell_untransform_viewport (shell,
                                                   &x, &y, &width, &height);

          image = gimp_display_get_image (display);
        }
      else
        {
          image = gimp_context_get_image (context);
        }

      if (image)
        {
          gimp_edit_paste (image, gimp_image_get_active_drawable (image),
                           buffer, paste_into, x, y, width, height);

          gimp_image_flush (image);
        }
    }
}
コード例 #26
0
void
palettes_merge_cmd_callback (GtkAction *action,
                             gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GtkWidget           *dialog;

  dialog = gimp_query_string_box (_("Merge Palette"),
                                  GTK_WIDGET (editor),
                                  gimp_standard_help_func,
                                  GIMP_HELP_PALETTE_MERGE,
                                  _("Enter a name for the merged palette"),
                                  NULL,
                                  G_OBJECT (editor), "destroy",
                                  palettes_merge_callback,
                                  editor);
  gtk_widget_show (dialog);
}
コード例 #27
0
ファイル: images-commands.c プロジェクト: 1ynx/gimp
void
images_new_view_cmd_callback (GtkAction *action,
                              gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;
  GimpContext         *context;
  GimpImage           *image;

  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);

  image = gimp_context_get_image (context);

  if (image && gimp_container_have (container, GIMP_OBJECT (image)))
    {
      gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
    }
}
コード例 #28
0
ファイル: images-commands.c プロジェクト: 1ynx/gimp
void
images_delete_image_cmd_callback (GtkAction *action,
                                  gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;
  GimpContext         *context;
  GimpImage           *image;

  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);

  image = gimp_context_get_image (context);

  if (image && gimp_container_have (container, GIMP_OBJECT (image)))
    {
      if (gimp_image_get_display_count (image) == 0)
        g_object_unref (image);
    }
}
コード例 #29
0
void
documents_file_open_dialog_cmd_callback (GtkAction *action,
                                         gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      file_file_open_dialog (context->gimp,
                             gimp_imagefile_get_file (imagefile),
                             GTK_WIDGET (editor));
    }
}
コード例 #30
0
ファイル: documents-commands.c プロジェクト: 1ynx/gimp
void
documents_recreate_preview_cmd_callback (GtkAction *action,
                                         gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      gimp_imagefile_create_thumbnail (imagefile,
                                       context, NULL,
                                       context->gimp->config->thumbnail_size,
                                       FALSE);
    }
}