Esempio n. 1
0
File: main.c Progetto: 4179e1/misc
/*
Called when the user clicks the 'Paste' menu. 
*/
void on_paste_menu_item_activate (GtkMenuItem *menuitem, TutorialTextEditor *editor)
{
        GtkTextBuffer           *buffer;
        GtkClipboard            *clipboard;
        
        clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->text_view));
        gtk_text_buffer_paste_clipboard (buffer, clipboard, NULL, TRUE);
}
Esempio n. 2
0
static void gtkhash_properties_on_menuitem_copy_activate(struct page_s *page)
{
	GtkClipboard *clipboard = gtk_clipboard_get(GDK_NONE);
	char *digest = gtkhash_properties_list_get_selected_digest(page);

	gtk_clipboard_set_text(clipboard, digest, -1);

	g_free(digest);
}
/*
 * copy the selected text to the clipboard and remove it from the buffer
 * That is called cut.
 */
static void cut_clicked( GtkButton *cut, GtkTextView *textview ) {
  GtkClipboard *clipboard = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD );
  GtkTextBuffer *buffer = gtk_text_view_get_buffer( textview );

  /* real implementors */
  /* true -- cut the embedded object like image as well */
  /* false -- count out of objects like image */
  gtk_text_buffer_cut_clipboard( buffer, clipboard, TRUE );
}
Esempio n. 4
0
void
on_popup_copy_URL_clipboard (void)
{
	itemPtr         item;

	item = itemlist_get_selected ();
	if (item) {
		gchar *link = item_make_link (item);

		gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY), link, -1);
		gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), link, -1);

		g_free (link);
		item_unload (item);
	} else {
		liferea_shell_set_important_status_bar (_("No item has been selected"));
	}
}
Esempio n. 5
0
/* \brief Initialises system clipboard support
 * \par Function Description
 * Registers a signal handler to detect if the clipboard has changed
 * and update the menu item sensitivity if necessary.
 */
void
x_clipboard_init (GSCHEM_TOPLEVEL *w_current)
{
  GtkClipboard *cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
  g_signal_connect (G_OBJECT (cb),
                    "owner-change",
                    G_CALLBACK (clip_handle_owner_change),
                    w_current);
}
void EvalCcRqSETCLIPBOARDTEXT (CrossCallInfo *pcci)		/* textptr; no result. */
{
	const gchar *text = (const gchar *) pcci->p1;

	gtk_clipboard_set_text (gtk_clipboard_get(GDK_NONE),
                            text, strlen(text));

	MakeReturn0Cci (pcci);
}
Esempio n. 7
0
void sys_set_clipboard_text(void *user, const char *text)
{
    GtkClipboard *cb;
    gtk_init_check(NULL, NULL);
    cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
    gtk_clipboard_set_can_store(cb, NULL, 0);
    gtk_clipboard_set_text(cb, text, -1);
    gtk_clipboard_store(cb);
}
Esempio n. 8
0
void playlist_copy (void)
{
    gchar * text = audgui_urilist_create_from_selected (aud_playlist_get_active ());
    if (! text)
        return;

    gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), text, -1);
    g_free (text);
}
Esempio n. 9
0
static void handle_copy_button(GtkButton * button, gpointer data) {
    GtkEntry * value_field = GTK_ENTRY(data);
    GdkAtom atom = gdk_atom_intern_static_string("CLIPBOARD");

    const char * value = gtk_entry_get_text(value_field);
    GtkClipboard * clipboard = gtk_clipboard_get(atom);
    gtk_clipboard_set_text(clipboard, value, -1);
    gtk_clipboard_store(clipboard);
}
void EvalCcRqGETCLIPBOARDCOUNT (CrossCallInfo *pcci)
{
    gint* targets;
    printf("EvalCcRqGETCLIPBOARDTEXT\n");

    gtk_clipboard_wait_for_targets(gtk_clipboard_get(GDK_NONE), NULL, targets);

    MakeReturn1Cci (pcci, (int64_t) *targets);
}
Esempio n. 11
0
static void on_menuitem_treeview_copy_activate(struct hash_func_s *func)
{
	char *digest = list_get_selected_digest(func->id);
	g_assert(digest);

	gtk_clipboard_set_text(gtk_clipboard_get(GDK_NONE), digest, -1);

	g_free(digest);
}
Esempio n. 12
0
nsresult
nsClipboard::Store(void)
{
    // Ask the clipboard manager to store the current clipboard content
    if (mGlobalTransferable) {
        GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
        gtk_clipboard_store(clipboard);
    }
    return NS_OK;
}
Esempio n. 13
0
const char *sys_get_clipboard_text(void* user)
{
    GtkClipboard *cb;
    static gchar *text = NULL;
    gtk_init_check(NULL, NULL);
    g_free(text);
    cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
    text = gtk_clipboard_wait_for_text(cb);
    return text;
}
Esempio n. 14
0
/**
 * a_clipboard_type:
 *
 * Return the type of data held in the clipboard if any
 */
VikClipboardDataType a_clipboard_type ( )
{
  GtkClipboard *c = gtk_clipboard_get ( GDK_SELECTION_CLIPBOARD );
  VikClipboardDataType *vcdt = g_malloc ( sizeof (VikClipboardDataType) );

  gtk_clipboard_request_targets ( c, clip_determine_type, vcdt );
  gint answer = *vcdt;
  g_free ( vcdt );
  return answer;
}
Esempio n. 15
0
// Paste the text from the clipboard or the primary selection
StdStrBuf C4AbstractApp::Paste(bool fClipboard)
{
	char * r = gtk_clipboard_wait_for_text(gtk_clipboard_get(fClipboard ? GDK_SELECTION_CLIPBOARD : GDK_SELECTION_PRIMARY));
//	gtk_clipboard_request_text(gtk_clipboard_get(fClipboard ? GDK_SELECTION_CLIPBOARD : GDK_SELECTION_PRIMARY),
//	                           GtkClipboardTextReceivedFunc callback, gpointer user_data);
	StdStrBuf rbuf;
	rbuf.Copy(r);
	g_free(r);
	return rbuf;
}
Esempio n. 16
0
static void 
copy_callback (GtkWidget *w)
{
  if (kselected.d[0] || kselected.d[1])
    {
      gchar *string_utf = utf8_for_char (kselected);
      gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), string_utf, -1);
      g_free (string_utf);
    }
}
Esempio n. 17
0
void iscreenshot_save_to_clipboard(GtkWidget *widget,GdkPixbuf *pixbuf)
{
	GtkClipboard *clip;

	clip=gtk_clipboard_get(gdk_atom_intern_static_string("CLIPBOARD"));
	gtk_clipboard_clear(clip);
	gtk_clipboard_set_image(clip,pixbuf);

	gtk_main_quit();
}
Esempio n. 18
0
void
selection_changed_cb(WebKitWebView *webkitwebview, gpointer ud) {
    (void)ud;
    gchar *tmp;

    webkit_web_view_copy_clipboard(webkitwebview);
    tmp = gtk_clipboard_wait_for_text(gtk_clipboard_get (GDK_SELECTION_CLIPBOARD));
    send_event(SELECTION_CHANGED, NULL, TYPE_STR, tmp ? tmp : "", NULL);
    g_free(tmp);
}
Esempio n. 19
0
TILP_EXPORT void on_scdbox_button5_clicked(GtkButton * button, gpointer user_data)
{
	GdkPixbuf *pixbuf;
	GtkClipboard *clipboard;

	pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(scrn_img));

	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
	gtk_clipboard_set_image(clipboard, pixbuf);
}
Esempio n. 20
0
int main(int argc, char **argv) {
    int ret = EXIT_FAILURE;
    GtkClipboard *cb = NULL;
    GdkPixbuf *image = NULL;
    GError *e = NULL;
    GOptionContext *opt_ctx = NULL;
    char *help = NULL;
    static int timeout;
    static const GOptionEntry entries[] = {
        { "timeout", 't', 0, G_OPTION_ARG_INT, &timeout, "Timeout", "secs" }, 
        { NULL, 0, 0, 0, NULL, NULL, NULL }
    };

    opt_ctx = g_option_context_new("<file>");

    g_option_context_add_main_entries(opt_ctx, entries, NULL);
    if (!g_option_context_parse(opt_ctx, &argc, &argv, &e)) {
        fprintf(stderr, "%s\n", e->message);
        goto error_out;
    }

    if (argc == 1 || !g_file_test(argv[1], G_FILE_TEST_EXISTS)) {
        help = g_option_context_get_help(opt_ctx, TRUE, NULL);
        fprintf(stderr, "%s", help);
        g_free(help);
        goto error_out;
    }

    image = gdk_pixbuf_new_from_file(argv[1], &e);
    if (image == NULL) {
        fprintf(stderr, "%s\n", e->message);
        goto error_out;
    }

    gtk_init(&argc, &argv);

    cb = gtk_clipboard_get(GDK_NONE);
    gtk_clipboard_set_image(cb, image);
    g_signal_connect(G_OBJECT(cb), "owner-change", G_CALLBACK(on_owner_change), NULL);

    if (timeout > 0) {
        g_timeout_add_seconds(timeout, (GSourceFunc)on_timeout_expired, NULL);
    }

    gtk_main();

    g_object_unref(image);

    ret = EXIT_SUCCESS;

error_out: 
    g_option_context_free(opt_ctx);

    return ret;
}
Esempio n. 21
0
// ----------------------------------------------------------------------------
void MMSapEvents::OnKillFocusEvent( wxFocusEvent& event )
// ----------------------------------------------------------------------------
{
    //For GTK, we copy the selected text to the PRIMARY clipboard
    // when we lose the focus

    #if not defined(__WXGTK__)
        event.Skip(); return;
    #endif

    // If selected text, copy to clipboard

    //remember event window pointer
    wxObject* pEvtObject = event.GetEventObject();

    cbStyledTextCtrl* pControl = 0;
    cbEditor* ed = 0;
    wxString selectedText = wxEmptyString;
    if ( ((wxWindow*)pEvtObject)->GetName().Lower() == _T("sciwindow") )
    {   ed = (cbEditor*)((wxWindow*)pEvtObject)->GetParent();
        pControl = (cbStyledTextCtrl*)pEvtObject;
    }

    if ( ed ) do
    {
        if ( not MouseSap::pMouseSap->IsAttachedTo( pControl ) )
            break;

        selectedText = pControl->GetSelectedText();
        if ( selectedText.IsEmpty() )
            break;

        #if defined(__WXGTK__)
            gtk_clipboard_set_text(
                gtk_clipboard_get(GDK_SELECTION_PRIMARY),
                selectedText.mb_str(wxConvUTF8),
                selectedText.Length() );
        #else //__WXMSW__ //testing
                if (wxTheClipboard->Open())
                {
                    wxTheClipboard->AddData(new wxTextDataObject(selectedText));
                    wxTheClipboard->Close();
                }
        #endif

        #if defined(LOGGING)
            DumpClipboard();
            if (ed && pControl && (not selectedText.IsEmpty()))
            LOGIT( _T("OnKillFocus[%s][%s]"), ed->GetTitle().c_str(),selectedText.c_str());
        #endif
    }while(false);

    event.Skip();

} // end of OnGPM
Esempio n. 22
0
static void
debug_logger_copy_clicked(GtkWidget *widget, DebugLogger *logger)
{
    GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
    GList *selected_rows = NULL, *entry;
    GtkTreeView *view;
    GtkTreeModel *model;
    GtkTreeSelection *selection;
    gint current_page;
    GString *copy_data;

    g_return_if_fail(IS_DEBUG_LOGGER(logger));

    if (gtk_notebook_get_n_pages(logger->priv->notebook) == 0)
        return;

    copy_data = g_string_new(NULL);

    current_page = gtk_notebook_get_current_page(logger->priv->notebook);

    view =
        GTK_TREE_VIEW(gtk_bin_get_child(
                GTK_BIN(gtk_notebook_get_nth_page(
                        GTK_NOTEBOOK(logger->priv->notebook),
                        current_page))));

    model = gtk_tree_view_get_model(view);
    selection = gtk_tree_view_get_selection(view);

    selected_rows =
        gtk_tree_selection_get_selected_rows(selection, &model);

    for(entry = selected_rows; entry != NULL; entry = g_list_next(entry))
    {
        GtkTreeIter iter;
        gchar *message;

        gtk_tree_model_get_iter(model, &iter, entry->data);
        gtk_tree_model_get(model, &iter, MSG_COLUMN, &message, -1);

        copy_data = g_string_append(copy_data, message);
        copy_data = g_string_append_c(copy_data, '\n');

        g_free(message);
    }

    /* Don't clobber clipboard if we have nothing to add to it. */
    if(copy_data->len != 0)
        gtk_clipboard_set_text(clipboard, copy_data->str, copy_data->len);

    g_string_free(copy_data, TRUE);

    g_list_foreach(selected_rows, (GFunc)gtk_tree_path_free, NULL);
    g_list_free(selected_rows);
}
Esempio n. 23
0
/*
 * get clipboard content - partialy inspired by Downloader for X
 */
gboolean
my_get_xselection(GtkWidget *window, GdkEvent *event)
{
	GdkAtom		atom;
	gint		format;
	size_t		length;
	gchar		*content = NULL;

	/* previous clipboard content */
	static size_t	old_content_len = 0;
	static gchar	*old_content = "";


	begin_func("my_get_xselection");

	gtk_clipboard_request_text(gtk_clipboard_get(clipboard),
			my_get_selection_text, NULL);

	return_val(TRUE);

	length = (size_t) gdk_selection_property_get(gtk_widget_get_window(window),
			(guchar **) &content, &atom, &format);

	if (length > 0) {
		if ((length != old_content_len ||
				memcmp(content, old_content, length) != 0) &&
		    !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore))) {
			/* new data in clipboard */
			/* store new content for future comparation */
			if (old_content_len > 0)
				g_free(old_content);
			old_content = content;
			old_content_len = length;

			/* process item */
			/* process_item(content, length, 0, TRUE); */
		} else {
			/* no new data */
			g_free(content);
		}

		/* when clipboard is locked, set selection owener to myself */
		    if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)) ||
			gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_lock))) {
			if (gtk_selection_owner_set(dock_app,
						clipboard,
						GDK_CURRENT_TIME) == 0)
				selected = NULL;
		}

	}

	return_val(TRUE);
}
Esempio n. 24
0
gchar* get_clipboard_text (void)
{
  GtkClipboard *c = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
  if (! c)
     return NULL; 

  if (! gtk_clipboard_wait_is_text_available (c))
     return NULL;

  return gtk_clipboard_wait_for_text (c); 
}  
Esempio n. 25
0
void
fm__gth_browser_realize_cb (GthBrowser *browser)
{
	GtkClipboard *clipboard;

	clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
	g_signal_connect (clipboard,
	                  "owner_change",
	                  G_CALLBACK (clipboard_owner_change_cb),
	                  browser);
}
static void
empathy_webkit_copy_address_cb (GtkMenuItem *menuitem,
    gpointer     user_data)
{
  WebKitHitTestResult   *hit_test_result = WEBKIT_HIT_TEST_RESULT (user_data);
  gchar                 *uri;
  GtkClipboard          *clipboard;

  g_object_get (G_OBJECT (hit_test_result),
      "link-uri", &uri,
      NULL);

  clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
  gtk_clipboard_set_text (clipboard, uri, -1);

  clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
  gtk_clipboard_set_text (clipboard, uri, -1);

  g_free (uri);
}
Esempio n. 27
0
void playlist_paste (void)
{
    gchar * text = gtk_clipboard_wait_for_text (gtk_clipboard_get
     (GDK_SELECTION_CLIPBOARD));
    if (! text)
        return;

    gint list = aud_playlist_get_active ();
    audgui_urilist_insert (list, playlist_get_focus (list), text);
    g_free (text);
}
Esempio n. 28
0
/*
 * get clipboard content - partialy inspired by Downloader for X
 */
gboolean
my_get_xselection(GtkWidget *window, GdkEvent *event)
{

	begin_func("my_get_xselection");

	gtk_clipboard_request_text(gtk_clipboard_get(clipboard),
			my_get_selection_text, NULL);

	return_val(TRUE);
}
Esempio n. 29
0
gboolean Copy_activate(GtkWidget *widget, gpointer data)
{
  gchar *hostname;
  GtkTreePath *path = (GtkTreePath*)data;
	
  hostname = getSelectedHost(path);
  if (hostname != NULL) {
    GtkClipboard *clipboard;

    clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
    gtk_clipboard_set_text(clipboard, hostname, -1);

    clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
    gtk_clipboard_set_text(clipboard, hostname, -1);

    g_free(hostname);
  }

  return TRUE;
}
void EvalCcRqGETCLIPBOARDTEXT (CrossCallInfo *pcci)			/* no params; string result. */
{
    gchar *text, *result;
    printf("EvalCcRqGETCLIPBOARDTEXT\n");

    text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_NONE));
    result = g_strdup(text);
    g_free(text);

    MakeReturn1Cci (pcci, (int64_t) result);
}