예제 #1
0
GtkWidget *
gimp_toolbox_color_area_create (GimpToolbox *toolbox,
                                gint         width,
                                gint         height)
{
  GimpContext *context;

  g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);

  context = gimp_toolbox_get_context (toolbox);

  color_area = gimp_fg_bg_editor_new (context);
  gtk_widget_set_size_request (color_area, width, height);
  gtk_widget_add_events (color_area,
                         GDK_ENTER_NOTIFY_MASK |
                         GDK_LEAVE_NOTIFY_MASK);

  gimp_help_set_help_data
    (color_area, _("Foreground & background colors.\n"
                   "The black and white squares reset colors.\n"
                   "The arrows swap colors.\n"
                   "Click to open the color selection dialog."), NULL);

  g_signal_connect (color_area, "color-clicked",
                    G_CALLBACK (color_area_color_clicked),
                    context);

  return color_area;
}
예제 #2
0
GtkWidget *
gimp_toolbox_image_area_create (GimpToolbox *toolbox,
                                gint         width,
                                gint         height)
{
  GimpContext *context;
  GtkWidget   *image_view;
  gchar       *tooltip;

  g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);

  context = gimp_toolbox_get_context (toolbox);

  image_view = gimp_view_new_full_by_types (context,
                                            GIMP_TYPE_VIEW, GIMP_TYPE_IMAGE,
                                            width, height, 0,
                                            FALSE, TRUE, TRUE);

  g_signal_connect (image_view, "set-viewable",
                    G_CALLBACK (image_preview_set_viewable),
                    NULL);

  gimp_view_set_viewable (GIMP_VIEW (image_view),
                          GIMP_VIEWABLE (gimp_context_get_image (context)));

  gtk_widget_show (image_view);

#ifdef GDK_WINDOWING_X11
  tooltip = g_strdup_printf ("%s\n%s",
                             _("The active image.\n"
                               "Click to open the Image Dialog."),
                             _("Drag to an XDS enabled file-manager to "
                               "save the image."));
#else
  tooltip = g_strdup (_("The active image.\n"
                        "Click to open the Image Dialog."));
#endif

  gimp_help_set_help_data (image_view, tooltip,
                           GIMP_HELP_TOOLBOX_IMAGE_AREA);
  g_free (tooltip);

  g_signal_connect_object (context, "image-changed",
                           G_CALLBACK (gimp_view_set_viewable),
                           image_view, G_CONNECT_SWAPPED);

  g_signal_connect (image_view, "clicked",
                    G_CALLBACK (image_preview_clicked),
                    toolbox);

  gimp_dnd_viewable_dest_add (image_view,
                              GIMP_TYPE_IMAGE,
                              image_preview_drop_image,
                              context);

  return image_view;
}
예제 #3
0
static void
image_preview_clicked (GtkWidget       *widget,
                       GdkModifierType  state,
                       GimpToolbox     *toolbox)
{
  GimpContext *context = gimp_toolbox_get_context (toolbox);

  gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (context->gimp)),
                                             context->gimp,
                                             gimp_dock_get_dialog_factory (GIMP_DOCK (toolbox)),
                                             gimp_widget_get_monitor (widget),
                                             "gimp-image-list|gimp-image-grid");
}
예제 #4
0
void
gimp_toolbox_dnd_init (GimpToolbox *toolbox,
                       GtkWidget   *vbox)
{
  GimpContext *context = NULL;

  g_return_if_fail (GIMP_IS_TOOLBOX (toolbox));
  g_return_if_fail (GTK_IS_BOX (vbox));

  context = gimp_toolbox_get_context (toolbox);

  /* Before caling any dnd helper functions, setup the drag
   * destination manually since we want to handle all drag events
   * manually, otherwise we would not be able to give the drag handler
   * a chance to handle drag events
   */
  gtk_drag_dest_set (vbox,
                     0, NULL, 0,
                     GDK_ACTION_COPY | GDK_ACTION_MOVE);

  gimp_dnd_viewable_dest_add  (vbox,
                               GIMP_TYPE_LAYER,
                               gimp_toolbox_drop_drawable,
                               context);
  gimp_dnd_viewable_dest_add  (vbox,
                               GIMP_TYPE_LAYER_MASK,
                               gimp_toolbox_drop_drawable,
                               context);
  gimp_dnd_viewable_dest_add  (vbox,
                               GIMP_TYPE_CHANNEL,
                               gimp_toolbox_drop_drawable,
                               context);
  gimp_dnd_viewable_dest_add  (vbox,
                               GIMP_TYPE_TOOL_INFO,
                               gimp_toolbox_drop_tool,
                               context);
  gimp_dnd_viewable_dest_add  (vbox,
                               GIMP_TYPE_BUFFER,
                               gimp_toolbox_drop_buffer,
                               context);
  gimp_dnd_component_dest_add (vbox,
                               gimp_toolbox_drop_component,
                               context);
  gimp_dnd_uri_list_dest_add  (vbox,
                               gimp_toolbox_drop_uri_list,
                               context);
  gimp_dnd_pixbuf_dest_add    (vbox,
                               gimp_toolbox_drop_pixbuf,
                               context);
}