Esempio n. 1
0
static gboolean clipboard_request(SpiceMainChannel *main, guint selection,
                                  guint type, gpointer user_data)
{
    g_return_val_if_fail(SPICE_IS_GTK_SESSION(user_data), FALSE);

    SpiceGtkSession *self = user_data;
    SpiceGtkSessionPrivate *s = self->priv;
    GdkAtom atom;
    GtkClipboard* cb;
    int m;

    if (read_only(self))
        return FALSE;

    cb = get_clipboard_from_selection(s, selection);
    g_return_val_if_fail(cb != NULL, FALSE);

    for (m = 0; m < SPICE_N_ELEMENTS(atom2agent); m++) {
        if (atom2agent[m].vdagent == type)
            break;
    }

    g_return_val_if_fail(m < SPICE_N_ELEMENTS(atom2agent), FALSE);

    atom = gdk_atom_intern_static_string(atom2agent[m].xatom);
    gtk_clipboard_request_contents(cb, atom, clipboard_received_cb,
                                   weak_ref(G_OBJECT(self)));

    return TRUE;
}
/**
 * thunar_clipboard_manager_paste_files:
 * @manager           : a #XfdesktopClipboardManager.
 * @target_file       : the #GFile of the folder to which the contents on the clipboard
 *                      should be pasted.
 * @widget            : a #GtkWidget, on which to perform the paste or %NULL if no widget is
 *                      known.
 * @new_files_closure : a #GClosure to connect to the job's "new-files" signal,
 *                      which will be emitted when the job finishes with the
 *                      list of #GFile<!---->s created by the job, or
 *                      %NULL if you're not interested in the signal.
 *
 * Pastes the contents from the clipboard associated with @manager to the directory
 * referenced by @target_file.
 * Code copied and adapted from thunar-clipboard-manager.c
 * Copyright (c) 2005-2006 Benedikt Meurer <*****@*****.**>
 * Copyright (c) 2009-2011 Jannis Pohlmann <*****@*****.**>
 **/
void
xfdesktop_clipboard_manager_paste_files (XfdesktopClipboardManager *manager,
                                      GFile                  *target_file,
                                      GtkWidget              *widget,
                                      GClosure               *new_files_closure)
{
  XfdesktopClipboardPasteRequest *request;

  g_return_if_fail (XFDESKTOP_IS_CLIPBOARD_MANAGER (manager));
  g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));

  /* prepare the paste request */
  request = g_slice_new0 (XfdesktopClipboardPasteRequest);
  request->manager = g_object_ref (G_OBJECT (manager));
  request->target_file = g_object_ref (target_file);
  request->widget = widget;

  /* take a reference on the closure (if any) */
  if (G_LIKELY (new_files_closure != NULL))
    {
      request->new_files_closure = new_files_closure;
      g_closure_ref (new_files_closure);
      g_closure_sink (new_files_closure);
    }

  /* get notified when the widget is destroyed prior to
   * completing the clipboard contents retrieval
   */
  if (G_LIKELY (request->widget != NULL))
    g_object_add_weak_pointer (G_OBJECT (request->widget), (gpointer) &request->widget);

  /* schedule the request */
  gtk_clipboard_request_contents (manager->clipboard, manager->x_special_gnome_copied_files,
                                  xfdesktop_clipboard_manager_contents_received, request);
}
Esempio n. 3
0
File: ml_gtk.c Progetto: CRogers/obc
CAMLprim value ml_gtk_clipboard_request_contents (value c, value a, value f)
{
  void *f_p = ml_global_root_new (f);
  gtk_clipboard_request_contents (GtkClipboard_val(c), GdkAtom_val(a),
                                  clipboard_received_func, f_p);
  return Val_unit;
}
Esempio n. 4
0
/**
 * @sa clipboard_copy
 */
void clipboard_paste (ClipboardPasteFunc paste)
{
	GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);

	g_clipboardPasteFunc = paste;
	gtk_clipboard_request_contents(clipboard, gdk_atom_intern(clipboard_targets.target, FALSE), clipboard_received,
			&g_clipboardPasteFunc);
}
Esempio n. 5
0
static VALUE
rg_request_contents(VALUE self, VALUE target)
{
    VALUE func = rb_block_proc();
    G_RELATIVE(self, func);
    gtk_clipboard_request_contents(_SELF(self), RVAL2ATOM(target),
                                   (GtkClipboardReceivedFunc)clipboard_received_func,
                                   (gpointer)func);
    return self;
}
Esempio n. 6
0
static void clip_determine_type ( GtkClipboard *c, GdkAtom *a, gint n, gpointer p )
{
  gint i;
  for (i=0; i<n; i++) {
    // g_print("  ""%s""\n", gdk_atom_name(a[i]));
    if (!strcmp(gdk_atom_name(a[i]), "application/viking")) {
      gtk_clipboard_request_contents ( c, gdk_atom_intern("application/viking", TRUE), clip_determine_viking_type, p );
      break;
    }
  }
}
Esempio n. 7
0
void
psppire_data_editor_clip_paste (PsppireDataEditor *de)
{
  GdkDisplay *display = gtk_widget_get_display ( GTK_WIDGET (de));
  GtkClipboard *clipboard =
    gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD);

  gtk_clipboard_request_contents (clipboard,
				  gdk_atom_intern ("UTF8_STRING", TRUE),
				  data_sheet_contents_received_callback,
				  de);
}
Esempio n. 8
0
/**
 * clip_receive_targets:
 *
 * Deal with various data types a clipboard may hold.
 */
void clip_receive_targets ( GtkClipboard *c, GdkAtom *a, gint n, gpointer p )
{
  VikLayersPanel *vlp = p;
  gint i;

  for (i=0; i<n; i++) {
    // g_print("  ""%s""\n", gdk_atom_name(a[i]));
    if (!strcmp(gdk_atom_name(a[i]), "text/html")) {
      gtk_clipboard_request_contents ( c, gdk_atom_intern("text/html", TRUE), clip_receive_html, vlp );
      break;
    }
    if (a[i] == GDK_TARGET_STRING) {
      gtk_clipboard_request_text ( c, clip_receive_text, vlp );
      break;
    }
    if (!strcmp(gdk_atom_name(a[i]), "application/viking")) {
      gtk_clipboard_request_contents ( c, gdk_atom_intern("application/viking", TRUE), clip_receive_viking, vlp );
      break;
    }
  }
}
static void
set_paste_sensitive_if_clipboard_contains_data (GtkActionGroup *action_group)
{
	GtkAction *action;
	if (gdk_display_supports_selection_notification (gdk_display_get_default ())) {
		gtk_clipboard_request_contents (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
						gdk_atom_intern ("TARGETS", FALSE),
						received_clipboard_contents,
						g_object_ref (action_group));
	} else {
		/* If selection notification isn't supported, always activate Paste */
		action = gtk_action_group_get_action (action_group,
						      "Paste");
		gtk_action_set_sensitive (action, TRUE);
	}
}
Esempio n. 10
0
static void
glide_window_paste_targets_received (GtkClipboard *clipboard,
				     GdkAtom *atoms,
				     gint n_atoms,
				     gpointer data)
{
  GlideWindow *w = (GlideWindow *)data;
  gboolean has_text = FALSE;

  if (gtk_targets_include_text (atoms, n_atoms))
    has_text = TRUE;
  if (has_text)
    {
      gtk_clipboard_request_contents (clipboard, gdk_atom_intern ("TEXT", TRUE), glide_window_paste_contents_text_received, w);
    }
}
static void
xfdesktop_clipboard_manager_owner_changed (GtkClipboard           *clipboard,
                                           GdkEventOwnerChange    *event,
                                           XfdesktopClipboardManager *manager)
{
  g_return_if_fail (GTK_IS_CLIPBOARD (clipboard));
  g_return_if_fail (XFDESKTOP_IS_CLIPBOARD_MANAGER (manager));
  g_return_if_fail (manager->clipboard == clipboard);

  /* need to take a reference on the manager, because the clipboards
   * "targets received callback" mechanism is not cancellable.
   */
  g_object_ref (G_OBJECT (manager));

  /* request the list of supported targets from the new owner */
  gtk_clipboard_request_contents (clipboard, gdk_atom_intern ("TARGETS", FALSE),
                                  xfdesktop_clipboard_manager_targets_received, manager);
}
Esempio n. 12
0
static GtkSelectionData *
wait_for_contents(GtkClipboard *clipboard, GdkAtom target)
{
    retrieval_context *context = new retrieval_context();
    gtk_clipboard_request_contents(clipboard, target,
                                   clipboard_contents_received,
                                   context);

    if (!wait_for_retrieval(clipboard, context)) {
        // Don't delete |context|; the callback will when it eventually
        // comes back.
        return nsnull;
    }

    GtkSelectionData *result = static_cast<GtkSelectionData *>(context->data);
    delete context;
    return result;
}
Esempio n. 13
0
static void
ide_terminal_do_popup (IdeTerminal    *self,
                       const GdkEvent *event)
{
  PopupInfo *popup_info;
  GtkClipboard *clipboard;

  g_assert (IDE_IS_TERMINAL (self));

  popup_info = g_slice_new0 (PopupInfo);
  popup_info->event = event ? gdk_event_copy (event) : gtk_get_current_event ();
  popup_info->terminal = g_object_ref (self);

  clipboard = gtk_widget_get_clipboard (GTK_WIDGET (self), GDK_SELECTION_CLIPBOARD);

  gtk_clipboard_request_contents (clipboard,
                                  gdk_atom_intern_static_string ("TARGETS"),
                                  popup_targets_received,
                                  popup_info);
}
Esempio n. 14
0
void
gth_browser_activate_edit_paste (GSimpleAction *action,
			         GVariant      *parameter,
			         gpointer       user_data)
{
	GthBrowser *browser = GTH_BROWSER (user_data);
	GtkWidget  *focused_widget;
	PasteData  *paste_data;

	focused_widget = gtk_window_get_focus (GTK_WINDOW (browser));
	if ((focused_widget != NULL) && GTK_IS_EDITABLE (focused_widget))
		return;

	paste_data = g_new0 (PasteData, 1);
	paste_data->browser = g_object_ref (browser);
	paste_data->destination = g_object_ref (gth_browser_get_location_data (browser));

	gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (browser), GDK_SELECTION_CLIPBOARD),
					GNOME_COPIED_FILES,
					clipboard_received_cb,
					paste_data);
}
Esempio n. 15
0
void
gth_browser_activate_folder_context_paste_into_folder (GSimpleAction *action,
						       GVariant      *parameter,
						       gpointer       user_data)
{
	GthBrowser  *browser = GTH_BROWSER (user_data);
	GthFileData *file_data;
	PasteData   *paste_data;

	file_data = gth_browser_get_folder_popup_file_data (browser);
	if (file_data == NULL)
		return;

	paste_data = g_new0 (PasteData, 1);
	paste_data->browser = g_object_ref (browser);
	paste_data->destination = gth_file_data_dup (file_data);

	gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (browser), GDK_SELECTION_CLIPBOARD),
					GNOME_COPIED_FILES,
					clipboard_received_cb,
					paste_data);

	g_object_unref (file_data);
}