Commit 6ad8c740 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/actions/data-commands.c app/actions/documents-commands.c moved text

2005-11-01  Sven Neumann  <sven@gimp.org>

	* app/actions/data-commands.c
	* app/actions/documents-commands.c
	* app/widgets/gimpclipboard.[ch]: moved text clipboard handling to
	utility function to avoid code duplication.
parent c4e37430
2005-11-01 Sven Neumann <sven@gimp.org>
* app/actions/data-commands.c
* app/actions/documents-commands.c
* app/widgets/gimpclipboard.[ch]: moved text clipboard handling to
utility function to avoid code duplication.
2005-11-01 Sven Neumann <sven@gimp.org>
* app/plug-in/plug-ins.c: formatting.
......
......@@ -32,6 +32,7 @@
#include "file/file-open.h"
#include "file/file-utils.h"
#include "widgets/gimpclipboard.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpdataeditor.h"
#include "widgets/gimpdatafactoryview.h"
......@@ -188,16 +189,7 @@ data_copy_location_cmd_callback (GtkAction *action,
if (uri)
{
GtkClipboard *clipboard;
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, uri, -1);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_PRIMARY);
gtk_clipboard_set_text (clipboard, uri, -1);
gimp_clipboard_set_text (uri);
g_free (uri);
}
}
......
......@@ -38,6 +38,7 @@
#include "file/file-open.h"
#include "file/file-utils.h"
#include "widgets/gimpclipboard.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpdocumentview.h"
#include "widgets/gimpmessagebox.h"
......@@ -159,20 +160,7 @@ documents_copy_location_cmd_callback (GtkAction *action,
imagefile = gimp_context_get_imagefile (context);
if (imagefile)
{
GtkClipboard *clipboard;
const gchar *uri;
uri = gimp_object_get_name (GIMP_OBJECT (imagefile));
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, uri, -1);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_PRIMARY);
gtk_clipboard_set_text (clipboard, uri, -1);
}
gimp_clipboard_set_text (gimp_object_get_name (GIMP_OBJECT (imagefile)));
}
void
......
......@@ -199,7 +199,6 @@ gimp_clipboard_has_buffer (Gimp *gimp)
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
gimp_clip = gimp_clipboard_get (gimp);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
......@@ -210,6 +209,8 @@ gimp_clipboard_has_buffer (Gimp *gimp)
return TRUE;
}
gimp_clip = gimp_clipboard_get (gimp);
return (gimp_clip->buffer != NULL);
}
......@@ -231,7 +232,6 @@ gimp_clipboard_has_svg (Gimp *gimp)
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
gimp_clip = gimp_clipboard_get (gimp);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
......@@ -242,6 +242,8 @@ gimp_clipboard_has_svg (Gimp *gimp)
return TRUE;
}
gimp_clip = gimp_clipboard_get (gimp);
return (gimp_clip->svg != NULL);
}
......@@ -268,7 +270,6 @@ gimp_clipboard_get_buffer (Gimp *gimp)
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
gimp_clip = gimp_clipboard_get (gimp);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
......@@ -298,6 +299,8 @@ gimp_clipboard_get_buffer (Gimp *gimp)
gimp_unset_busy (gimp);
}
gimp_clip = gimp_clipboard_get (gimp);
if (! buffer && gimp_clip->buffer)
buffer = g_object_ref (gimp_clip->buffer);
......@@ -329,7 +332,6 @@ gimp_clipboard_get_svg (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (svg_length != NULL, NULL);
gimp_clip = gimp_clipboard_get (gimp);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
......@@ -358,6 +360,8 @@ gimp_clipboard_get_svg (Gimp *gimp,
gimp_unset_busy (gimp);
}
gimp_clip = gimp_clipboard_get (gimp);
if (! svg && gimp_clip->svg)
{
svg = g_strdup (gimp_clip->svg);
......@@ -384,12 +388,13 @@ gimp_clipboard_set_buffer (Gimp *gimp,
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (buffer == NULL || GIMP_IS_BUFFER (buffer));
gimp_clip = gimp_clipboard_get (gimp);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
if (! clipboard)
return;
gimp_clip = gimp_clipboard_get (gimp);
if (gimp_clip->buffer)
{
g_object_unref (gimp_clip->buffer);
......@@ -430,20 +435,21 @@ gimp_clipboard_set_buffer (Gimp *gimp,
* Offers SVG data in %GDK_SELECTION_CLIPBOARD.
**/
void
gimp_clipboard_set_svg (Gimp *gimp,
gchar *svg)
gimp_clipboard_set_svg (Gimp *gimp,
const gchar *svg)
{
GimpClipboard *gimp_clip;
GtkClipboard *clipboard;
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_clip = gimp_clipboard_get (gimp);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
if (! clipboard)
return;
gimp_clip = gimp_clipboard_get (gimp);
if (gimp_clip->buffer)
{
g_object_unref (gimp_clip->buffer);
......@@ -476,6 +482,28 @@ gimp_clipboard_set_svg (Gimp *gimp,
}
}
/**
* gimp_clipboard_set_text:
* @text: a %NULL-terminated string in UTF-8 encoding
*
* Offers @text in %GDK_SELECTION_CLIPBOARD and GDK_SELECTION_PRIMARY.
**/
void
gimp_clipboard_set_text (const gchar *text)
{
GtkClipboard *clipboard;
g_return_if_fail (text != NULL);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clipboard, text, -1);
clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (),
GDK_SELECTION_PRIMARY);
gtk_clipboard_set_text (clipboard, text, -1);
}
/* private functions */
......@@ -691,7 +719,7 @@ gimp_clipboard_send_svg (GtkClipboard *clipboard,
gimp_clip->svg_target_entries[info].target);
gimp_selection_data_set_stream (selection_data,
gimp_clip->svg,
(const guchar *) gimp_clip->svg,
strlen (gimp_clip->svg));
}
......
......@@ -20,20 +20,22 @@
#define __GIMP_CLIPBOARD_H__
void gimp_clipboard_init (Gimp *gimp);
void gimp_clipboard_exit (Gimp *gimp);
void gimp_clipboard_init (Gimp *gimp);
void gimp_clipboard_exit (Gimp *gimp);
gboolean gimp_clipboard_has_buffer (Gimp *gimp);
gboolean gimp_clipboard_has_svg (Gimp *gimp);
gboolean gimp_clipboard_has_buffer (Gimp *gimp);
gboolean gimp_clipboard_has_svg (Gimp *gimp);
GimpBuffer * gimp_clipboard_get_buffer (Gimp *gimp);
gchar * gimp_clipboard_get_svg (Gimp *gimp,
gsize *svg_length);
GimpBuffer * gimp_clipboard_get_buffer (Gimp *gimp);
gchar * gimp_clipboard_get_svg (Gimp *gimp,
gsize *svg_length);
void gimp_clipboard_set_buffer (Gimp *gimp,
GimpBuffer *buffer);
void gimp_clipboard_set_svg (Gimp *gimp,
gchar *svg);
void gimp_clipboard_set_buffer (Gimp *gimp,
GimpBuffer *buffer);
void gimp_clipboard_set_svg (Gimp *gimp,
const gchar *svg);
void gimp_clipboard_set_text (const gchar *text);
#endif /* __GIMP_CLIPBOARD_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment