static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer)
{
    static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">"
        "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>"
        "<script>document.getSelection().collapse();\n"
        "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n"
        "</script></body></html>";

    g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));

    test->loadHtml(selectedSpanHTML, 0);
    test->waitUntilLoadFinished();

    g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));

    test->copyClipboard();
    GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));

    // Initially only the subspan is selected.
    g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");

    webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL);
    test->copyClipboard();
    clipboardText.reset(gtk_clipboard_wait_for_text(test->m_clipboard));

    // The mainspan should be selected after calling SELECT_ALL.
    g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy.");
}
static void
clipman_clicked_not_separated (GtkWidget     *menu,
                               ClipmanPlugin *clipman)
{
    gchar         *priClip, *defClip;
    guint          i;
    ClipmanAction *action = NULL;
    ClipmanClip   *clip;
    GtkWidget     *mi;
    
    priClip = gtk_clipboard_wait_for_text (primaryClip);
    defClip = gtk_clipboard_wait_for_text (defaultClip);
    
    for (i = clipman->clips->len; i--;)
    {
        clip = g_ptr_array_index (clipman->clips, i);
        
        action = g_new0 (ClipmanAction, 1);
        action->clipman = clipman;
        action->clip = clip;
        
        if (defClip != NULL               && 
            G_LIKELY (clip->text != NULL) && 
            strcmp(clip->text, defClip) == 0)
        {
            mi = clipman_create_menuitem (action, clipman->clips->len-i, TRUE);
            defClip = NULL;
        }
        else if (priClip != NULL               && 
                 G_LIKELY (clip->text != NULL) && 
                 strcmp(clip->text, priClip) == 0)
        {
            mi = clipman_create_menuitem (action, clipman->clips->len-i, TRUE);
            priClip = NULL;
        }
        else
        {
            mi = clipman_create_menuitem (action, clipman->clips->len-i, FALSE);
        }
        
        g_signal_connect (G_OBJECT(mi), "button_release_event",
                G_CALLBACK(clipman_item_clicked), action);
        
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
    }
    
    g_free (priClip);
    g_free (defClip);
    
    mi = gtk_separator_menu_item_new ();
    gtk_widget_set_sensitive (mi, FALSE);
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
    
    mi = gtk_menu_item_new_with_label (_("Clear History"));
    gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
        
    g_signal_connect (G_OBJECT (mi), "button_release_event",
        G_CALLBACK (clipman_clear), clipman);
}
static gboolean
clipman_check (ClipmanPlugin *clipman)
{
    gchar           *txt;
    GdkModifierType  state;
    
    /* We ignore the selection clipboard entirely if you've activated this in the options dialog */
    if (!clipman->IgnoreSelect)
    {
	/* Get mouse button information */
	gdk_window_get_pointer(NULL, NULL, NULL, &state);
	
        txt = gtk_clipboard_wait_for_text (primaryClip);
        
        if (clipman->PreventEmpty && G_UNLIKELY (txt == NULL))
        {
            clipman_restore_empty (clipman, PRIMARY);
        }
        else if (txt != NULL &&
                 !(state & GDK_BUTTON1_MASK) && 
                 !clipman_exists (clipman, txt, PRIMARY)
                )
        {
            DBG("Item added from primary clipboard");
            clipman_add_clip (clipman, txt, PRIMARY);
            clipman_check_array_len (clipman);
        }
        
        g_free (txt);
        txt = NULL;
    }
    
    txt = gtk_clipboard_wait_for_text (defaultClip);

    /* Check default clipboard */
    if (clipman->PreventEmpty && 
        G_UNLIKELY (txt == NULL)
       )
    {
        clipman_restore_empty (clipman, DEFAULT);
    }
    else if (G_LIKELY (txt != NULL))
    {
        if (!clipman_exists (clipman, txt, DEFAULT))
        {
            DBG("Item added from default clipboard");
            clipman_add_clip (clipman, txt, DEFAULT);
            clipman_check_array_len (clipman);
        }
    }

    g_free (txt);
    
    return TRUE;
}
Beispiel #4
0
/* Called during the daemon loop to protect primary/clipboard contents */
static void daemon_check()
{
	/* Get current primary/clipboard contents */
	gchar *primary_temp = gtk_clipboard_wait_for_text(primary);
	gchar *clipboard_temp = gtk_clipboard_wait_for_text(clipboard);
	/* Check if primary contents were lost */
	if ((primary_temp == NULL) && (primary_text != NULL))
	{
		/* Check contents */
		gint count;
		GdkAtom *targets;
		gboolean contents = gtk_clipboard_wait_for_targets(primary, &targets, &count);
		g_free(targets);
		/* Only recover lost contents if there isn't any other type of content in the clipboard */
		if (!contents)
			gtk_clipboard_set_text(primary, primary_text, -1);
	}
	else
	{
		/* Get the button state to check if the mouse button is being held */
		GdkModifierType button_state;
		gdk_window_get_pointer(NULL, NULL, NULL, &button_state);
		if ((primary_temp != NULL) && !(button_state & GDK_BUTTON1_MASK))
		{
			g_free(primary_text);
			primary_text = g_strdup(primary_temp);
		}
	}

	/* Check if clipboard contents were lost */
	if ((clipboard_temp == NULL) && (clipboard_text != NULL))
	{
		/* Check contents */
		gint count;
		GdkAtom *targets;
		gboolean contents = gtk_clipboard_wait_for_targets(clipboard, &targets, &count);
		g_free(targets);
		/* Only recover lost contents if there isn't any other type of content in the clipboard */
		if (!contents)
			gtk_clipboard_set_text(clipboard, clipboard_text, -1);
	}
	else
	{
		g_free(clipboard_text);
		clipboard_text = g_strdup(clipboard_temp);
	}
	g_free(primary_temp);
	g_free(clipboard_temp);
}
Beispiel #5
0
/**
 * Core asks front end for clipboard contents.
 *
 * \param  buffer  UTF-8 text, allocated by front end, ownership yeilded to core
 * \param  length  Byte length of UTF-8 text in buffer
 */
static void gui_get_clipboard(char **buffer, size_t *length)
{
	gchar *gtext;

	*buffer = NULL;
	*length = 0;

	/* get clipboard contents from gtk */
	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
	gtext = gtk_clipboard_wait_for_text(clipboard); /* conv to utf-8 */

	if (gtext == NULL)
		return;

	*length = strlen(gtext);
	*buffer = malloc(*length);
	if (*buffer == NULL) {
		*length = 0;
		g_free(gtext);
		return;
	}

	memcpy(*buffer, gtext, *length);

	g_free(gtext);
}
Beispiel #6
0
static VALUE
rg_wait_for_text(VALUE self)
{
    gchar *str;
    str = gtk_clipboard_wait_for_text(_SELF(self));
    return str ? CSTR2RVAL(str) : Qnil;
}
Beispiel #7
0
//カーソルのある行を削除する
void kill_line(void)
{
    int delete_flag = 0;
    GtkTextIter start, end;
    GtkClipboard *clipboard = gtk_widget_get_clipboard(view, GDK_SELECTION_CLIPBOARD);
    
    buf[0] = '\0';
    if (kill_flag == 1) {
        char *text = gtk_clipboard_wait_for_text(clipboard);
        strcat(buf, text);
        free(text);
    }
    
    gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(buffer), &start, gtk_text_buffer_get_insert(GTK_TEXT_BUFFER(buffer)));
    end = start;
    gtk_text_iter_forward_line(&end);
    if (!gtk_text_iter_starts_line(&start) && !gtk_text_iter_ends_line(&start) && !gtk_text_iter_is_end(&end) && kill_flag == 0) gtk_text_iter_backward_char(&end);
    
    char *text = gtk_text_buffer_get_text(GTK_TEXT_BUFFER(buffer), &start, &end, TRUE);
    strcat(buf, text);
    free(text);
    
    if (buf[0] != '\0') delete_flag = 1;
    
    gtk_clipboard_set_text(clipboard, buf, -1);
    gtk_text_buffer_delete(GTK_TEXT_BUFFER(buffer), &start, &end);
    
    kill_flag = delete_flag;
}
Beispiel #8
0
gint copy_clipboard_win(gpointer data){
	gchar *str=NULL;
	GtkClipboard* clipboard;

	LOG(LOG_DEBUG, "IN : copy_clipboard()");

#ifdef __WIN32__
	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
#else
	clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
#endif

	str = gtk_clipboard_wait_for_text(clipboard);
	if(str == NULL){
		goto END;
	}

	remove_space(str);
	search_selected(str);
	g_free(str);

 END:
	if(selection_mode != SELECTION_DO_NOTHING){
		auto_lookup_start();
	}

	LOG(LOG_DEBUG, "OUT : copy_clipboard()");
	return (FALSE);
}
Beispiel #9
0
static gint console_paste_text (GtkWidget *cview, GdkAtom atom)
{
    GtkClipboard *cb = gtk_clipboard_get(atom);
    gchar *src = gtk_clipboard_wait_for_text(cb);

    if (src != NULL) {
	GtkTextBuffer *buf;
	GtkTextIter iter;
	char *p;

	p = strchr(src, '\n');
	if (p != NULL) {
	    /* no newlines allowed! */
	    *p = '\0';
	}

	buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(cview));
	gtk_text_buffer_get_end_iter(buf, &iter);
	gtk_text_buffer_insert(buf, &iter, src, -1);

	g_free(src);
    }

    return TRUE;
}
Beispiel #10
0
void sc_focus_inputbar(Browser *b, const Arg *arg)
{
	char *data, *clipboard_text;

	if (arg->data) {
		if (arg->n == APPEND_URL) {
			asprintf(&data, "%s%s", arg->data, webkit_web_view_get_uri(b->UI.view));
		} else {
			data = strdup(arg->data);
		}
		browser_notify(b, DEFAULT, data);
		free(data);

		/* save primary selection - will be overwritten on grab_focus */
		clipboard_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));

		gtk_widget_grab_focus(GTK_WIDGET(b->UI.inputbar));
		gtk_editable_set_position(GTK_EDITABLE(b->UI.inputbar), -1);

		if (clipboard_text) {
			/* restore primary selection */
			gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), clipboard_text, -1);
			free(clipboard_text);
		}
	} else if (!gtk_widget_is_focus(GTK_WIDGET(b->UI.inputbar))) {
		gtk_widget_grab_focus(GTK_WIDGET(b->UI.inputbar));
	}
	
	if (!gtk_widget_get_visible(GTK_WIDGET(b->UI.inputbar))) {
		gtk_widget_show(GTK_WIDGET(b->UI.inputbar));
	}
}
Beispiel #11
0
/* Returns a string from X selection.
 * \param L The Lua VM state.
 * \return The number of elements pushed on stack (1).
 */
static gint
luaH_luakit_get_selection(lua_State *L)
{
    int n = lua_gettop(L);
    GdkAtom atom = GDK_SELECTION_PRIMARY;

    if (n) {
        const gchar *arg = luaL_checkstring(L, 1);
        /* Follow xclip(1) behavior: check only the first character of argument */
        switch (arg[0]) {
          case 'p':
            break;
          case 's':
            atom = GDK_SELECTION_SECONDARY;
            break;
          case 'c':
            atom = GDK_SELECTION_CLIPBOARD;
            break;
          default:
            luaL_argerror(L, 1, "should be 'primary', 'secondary' or 'clipboard'");
            break;
        }
    }
    GtkClipboard *selection = gtk_clipboard_get(atom);
    gchar *text = gtk_clipboard_wait_for_text(selection);
    lua_pushstring(L, text);
    g_free(text);
    return 1;
}
static void testWebViewEditorCutCopyPasteNonEditable(EditorTest* test, gconstpointer)
{
    static const char* selectedSpanHTML = "<html><body contentEditable=\"false\">"
        "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>"
        "<script>document.getSelection().collapse();\n"
        "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n"
        "</script></body></html>";

    // Nothing loaded yet.
    g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
    g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
    g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));

    test->loadHtml(selectedSpanHTML, 0);
    test->waitUntilLoadFinished();

    g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
    // It's not possible to cut and paste when content is not editable
    // even if there's a selection.
    g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
    g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));

    test->copyClipboard();
    GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard));
    g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull");
}
gboolean
e_composer_paste_text (EMsgComposer *composer,
                       GtkClipboard *clipboard)
{
	EHTMLEditor *editor;
	EHTMLEditorView *view;
	EHTMLEditorSelection *editor_selection;
	gchar *text;

	g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
	g_return_val_if_fail (GTK_IS_CLIPBOARD (clipboard), FALSE);

	if (!(text = gtk_clipboard_wait_for_text (clipboard)))
		return FALSE;

	editor = e_msg_composer_get_editor (composer);
	view = e_html_editor_get_view (editor);
	editor_selection = e_html_editor_view_get_selection (view);
	/* If WebView doesn't have focus, focus it */
	if (!gtk_widget_has_focus (GTK_WIDGET (view)))
		gtk_widget_grab_focus (GTK_WIDGET (view));

	e_html_editor_selection_insert_text (editor_selection, text);

	g_free (text);

	return TRUE;
}
Beispiel #14
0
void PasteboardHelper::getClipboardContents(GtkClipboard* clipboard)
{
    DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
    ASSERT(dataObject);

    if (gtk_clipboard_wait_is_text_available(clipboard)) {
        GOwnPtr<gchar> textData(gtk_clipboard_wait_for_text(clipboard));
        if (textData)
            dataObject->setText(String::fromUTF8(textData.get()));
    }

    if (gtk_clipboard_wait_is_target_available(clipboard, markupAtom)) {
        if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, markupAtom)) {
            String markup(selectionDataToUTF8String(data));
            removeMarkupPrefix(markup);
            dataObject->setMarkup(markup);
            gtk_selection_data_free(data);
        }
    }

    if (gtk_clipboard_wait_is_target_available(clipboard, uriListAtom)) {
        if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, uriListAtom)) {
            dataObject->setURIList(selectionDataToUTF8String(data));
            gtk_selection_data_free(data);
        }
    }
}
Beispiel #15
0
static void load_status_cb(WebKitWebView* webView, GParamSpec* spec, gpointer data)
{
    CopyAndPasteFixture* fixture = (CopyAndPasteFixture*)data;
    WebKitLoadStatus status = webkit_web_view_get_load_status(webView);
    if (status != WEBKIT_LOAD_FINISHED)
        return;

    GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
    gtk_clipboard_clear(clipboard);

    webkit_web_view_copy_clipboard(webView);

    gchar* text = gtk_clipboard_wait_for_text(clipboard);
    g_assert(text || !fixture->info->expectedContent);
    g_assert(!text || !strcmp(text, fixture->info->expectedContent));
    g_free(text);

    // Verify that the markup starts with the proper content-type meta tag prefix.
    GtkSelectionData* selectionData = gtk_clipboard_wait_for_contents(clipboard, gdk_atom_intern("text/html", FALSE));
    if (selectionData) {
        static const char* markupPrefix = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">";
        char* markup = g_strndup((const char*) gtk_selection_data_get_data(selectionData),
            gtk_selection_data_get_length(selectionData));
        g_assert(strlen(markupPrefix) <= strlen(markup));
        g_assert(!strncmp(markupPrefix, markup, strlen(markupPrefix)));
        g_free(markup);
    }

    g_assert(!gtk_clipboard_wait_is_uris_available(clipboard));
    g_assert(!gtk_clipboard_wait_is_image_available(clipboard));

    g_main_loop_quit(fixture->loop);
}
Beispiel #16
0
static void fm_path_entry_paste_and_go(GtkMenuItem *menuitem, GtkEntry *entry)
{
    GtkClipboard* clipboard = gtk_clipboard_get_for_display(
        gtk_widget_get_display (GTK_WIDGET (menuitem)),GDK_SELECTION_CLIPBOARD);

    gchar* full_path = gtk_clipboard_wait_for_text(clipboard);

    if (full_path)
    {

        FmPathEntryPrivate *priv  = FM_PATH_ENTRY_GET_PRIVATE(entry);

        if(priv->path)
            fm_path_unref(priv->path);

        /* special handling for home dir */
        if(full_path[0] == '~' && full_path[1] == G_DIR_SEPARATOR)
            priv->path = fm_path_new_relative(fm_path_get_home(), full_path + 2);
        else if(full_path[0] == '~' && full_path[1] == 0)
            priv->path = fm_path_ref(fm_path_get_home());
        else
            priv->path = fm_path_new_for_str(full_path);

        gchar * disp_name = fm_path_display_name(priv->path, FALSE);
        gtk_entry_set_text(entry, disp_name);
        g_free(disp_name);

        gtk_editable_set_position(GTK_EDITABLE(entry), -1);

        g_free(full_path);

        fm_path_entry_activate(FM_PATH_ENTRY(entry));
    }
}
gint main ( gint argc, gchar* argv[] )
{
    gtk_init( &argc, &argv );

    GtkWidget *window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    gtk_window_set_title( GTK_WINDOW(window), "Clipboard Demonstration" );
    g_object_set( window, "window-position", GTK_WIN_POS_CENTER, "border-width", 10, NULL );
    gtk_window_set_default_size( GTK_WINDOW(window), 350, 70 );
    g_signal_connect ( GTK_WIDGET(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);

    GtkWidget *entry = gtk_entry_new();

    gtk_container_add( GTK_CONTAINER(window), entry );
    gtk_widget_show_all( GTK_WIDGET( window ) );

    GdkDisplay *display = gtk_widget_get_display( window );
    GtkClipboard *clipboard = gtk_clipboard_get_for_display( display, GDK_SELECTION_CLIPBOARD );

    gchar *text = gtk_clipboard_wait_for_text( clipboard );
    if ( !text ) {
        text = g_strdup("");
    }
    gtk_entry_set_text( GTK_ENTRY(entry), text );

    g_signal_connect( entry, "changed", G_CALLBACK(entry_text_changes), (gpointer)clipboard);

    gtk_main();

    g_free( text );

    return 0;

}
Beispiel #18
0
static void
prepopulate_fields(LinkDialog *ld, char *bufsel) {
	GtkClipboard *clipboard; 
	char *clipsel, *url = NULL;

	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
	clipsel = gtk_clipboard_wait_for_text(clipboard);

	if (bufsel && has_url(bufsel)) {
		url = bufsel;
	} else if (clipsel && has_url(clipsel)) {
		url = clipsel;
	}
	
	if (bufsel)
		gtk_entry_set_text(GTK_ENTRY(ld->etext), bufsel);
	if (url) {
		char *niceurl;
		if (g_str_has_prefix(url, "http://") ||
		    g_str_has_prefix(url, "ftp://")) {
			niceurl = url;
		} else {
			niceurl = g_strdup_printf("http://%s", url);
		}
		gtk_entry_set_text(GTK_ENTRY(ld->eurl), niceurl);
		if (niceurl != url)
			g_free(niceurl);
	}

	g_free(clipsel);
}
Beispiel #19
0
void clipChanged(GtkClipboard* clipboard,gpointer user_data)
{
	char*	texthold;
	char*	label;


	if (manual==true)
		{
			manual=false;
			return;
		}

	if (gtk_clipboard_wait_is_text_available(mainClipboard)==true)
		{
			setCurrentClip();
			if(clip[currentClip].text != NULL)
				free(clip[currentClip].text);
			clip[currentClip].text=gtk_clipboard_wait_for_text(clipboard);

			texthold=g_strescape(clip[currentClip].text,NULL);
			texthold=g_strstrip(texthold);

			if(strlen(clip[currentClip].text)>MAXCLIPMENULEN)
				{
					sinkInt=asprintf(&label,"%." CLIPENDLENSTR "s...%s",texthold,(char*)&texthold[strlen(texthold)-CLIPENDLEN]);
					gtk_menu_item_set_label((GtkMenuItem*)clip[currentClip].menuItem,label);
					free(label);
				}
			else
				gtk_menu_item_set_label((GtkMenuItem*)clip[currentClip].menuItem,texthold);

			free(texthold);
			gtk_widget_show_all(menuPlug);
		}
}
Beispiel #20
0
PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context,
                                                          bool allowPlainText, bool& chosePlainText)
{
    GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
    GtkClipboard* clipboard = m_helper->getCurrentTarget(frame);
    chosePlainText = false;

    if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, textHtml)) {
        ASSERT(data->data);
        String html = String::fromUTF8(reinterpret_cast<gchar*>(data->data), data->length * data->format / 8);
        gtk_selection_data_free(data);

        if (!html.isEmpty()) {
            RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "");
            if (fragment)
                return fragment.release();
        }
    }

    if (!allowPlainText)
        return 0;

    if (gchar* utf8 = gtk_clipboard_wait_for_text(clipboard)) {
        String text = String::fromUTF8(utf8);
        g_free(utf8);

        chosePlainText = true;
        RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), text);
        if (fragment)
            return fragment.release();
    }

    return 0;
}
static gboolean
clipman_item_clicked (GtkWidget      *mi,
                      GdkEventButton *ev,
                      ClipmanAction  *action)
{
    if (ev->button == 1 && action->clipman->Behaviour == STRICTLY)
    {
        DBG("Clip copied to his own clipboard (STRICTLY)");
        
        if (action->clip->fromtype == DEFAULT)
            gtk_clipboard_set_text(defaultClip, action->clip->text, -1);
        
        if (action->clip->fromtype == PRIMARY)
            gtk_clipboard_set_text(primaryClip, action->clip->text, -1);
    }
    else if (ev->button == 1)
    {
        DBG("Clip copied to both clipboards");
        
        gtk_clipboard_set_text(defaultClip, action->clip->text, -1);
        gtk_clipboard_set_text(primaryClip, action->clip->text, -1);
    }
    else if (ev->button == 3)
    {
        if (xfce_confirm (_("Are you sure you want to remove this clip from the history?"), 
	              "gtk-yes", 
                      NULL))
        {
            DBG ("Removed the selected clip from the History");
        
            if (gtk_clipboard_wait_for_text (defaultClip) &&
                !strcmp(gtk_clipboard_wait_for_text (defaultClip), action->clip->text)
               )
                gtk_clipboard_set_text(defaultClip, "", -1);
        
            if (gtk_clipboard_wait_for_text (primaryClip) &&
                !strcmp(gtk_clipboard_wait_for_text (primaryClip), action->clip->text)
               )
                gtk_clipboard_set_text(primaryClip, "", -1);

            g_ptr_array_remove (action->clipman->clips, action->clip);
            clipman_free_clip (action->clip);
        }
    }
    
    return FALSE;
}
void EvalCcRqGETCLIPBOARDTEXT (CrossCallInfo *pcci)			/* no params; string result. */
{
	gchar *text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_NONE));
	char *result = g_strdup(text);
	g_free(text);

	MakeReturn1Cci (pcci, (int) result);
}
Beispiel #23
0
 bool cClipboardHandler::PasteTextFromClipboard(string_t& sText) const
 {
   const char* szText = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
   if (szText == nullptr) return false;
   sText = string::ToString(szText);
   g_free(szText);
   return true;
 }
static const char* ImGui_ImplGtk3Cogl_GetClipboardText(void* user_data)
{
    static char *last_clipboard = NULL;

    g_clear_pointer(&last_clipboard, g_free);
    last_clipboard = gtk_clipboard_wait_for_text(GTK_CLIPBOARD(user_data));
    return last_clipboard;
}
Beispiel #25
0
dlle___ void cb_get_text__(char** addr_ret) {
	GtkClipboard *cb = cb__();
	if(!cb)
		return;
	const char* s = gtk_clipboard_wait_for_text(cb);
	if(!s)
		return;
	*addr_ret = dup__(s);
}
Beispiel #26
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);
}
Beispiel #27
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;
}
static jobject get_data_text(JNIEnv *env)
{
    gchar *data = gtk_clipboard_wait_for_text(get_clipboard());
    if (data == NULL) {
        return NULL;
    }
    jstring jdata = env->NewStringUTF(data);
    g_free(data);
    return jdata;
}
Beispiel #29
0
gboolean command_yank(const Arg *arg, char buf)
{
    static char *tmpl = "Yanked: %s";

    if (arg->i == COMMAND_YANK_SELECTION) {
        char *text = NULL;
        /* copy current selection to clipboard */
        webkit_web_view_copy_clipboard(vb.gui.webview);
        text = gtk_clipboard_wait_for_text(PRIMARY_CLIPBOARD());
        if (!text) {
            text = gtk_clipboard_wait_for_text(SECONDARY_CLIPBOARD());
        }
        if (text) {
            /* put the text into the yank buffer */
            vb_register_add(buf, text);
            vb_echo(VB_MSG_NORMAL, false, tmpl, text);
            g_free(text);

            return true;
        }

        return false;
    }

    Arg a = {VB_CLIPBOARD_PRIMARY|VB_CLIPBOARD_SECONDARY};
    if (arg->i == COMMAND_YANK_URI) {
        /* yank current uri */
        a.s = vb.state.uri;
    } else {
        /* use current arg.s as new clipboard content */
        a.s = arg->s;
    }
    if (a.s) {
        /* put the text into the yank buffer */
        vb_set_clipboard(&a);
        vb_register_add(buf, a.s);
        vb_echo(VB_MSG_NORMAL, false, tmpl, a.s);

        return true;
    }

    return false;
}
Beispiel #30
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;
}