static void encrypt_received (GtkClipboard *board, const gchar *text, SeahorseApplet *sapplet) { gchar *signer = NULL; gchar *enctext = NULL; gchar **keys = NULL; gboolean ret; GError *err = NULL; /* No text on clipboard */ if (!text) return; /* Get the recipient list */ if (cryptui_keyset_get_count (dbus_keyset) == 0) cryptui_need_to_get_keys (); else keys = cryptui_prompt_recipients (dbus_keyset, _("Choose Recipient Keys"), &signer); /* User may have cancelled */ if (keys && *keys) { ret = dbus_g_proxy_call (dbus_crypto_proxy, "EncryptText", &err, G_TYPE_STRV, keys, G_TYPE_STRING, signer, G_TYPE_INT, 0, G_TYPE_STRING, text, G_TYPE_INVALID, G_TYPE_STRING, &enctext, G_TYPE_INVALID); if (ret) { /* And finish up */ gtk_clipboard_set_text (board, enctext, strlen (enctext)); detect_received (board, enctext, sapplet); if (seahorse_gconf_get_boolean (DISPLAY_CLIPBOARD_ENC_KEY) == TRUE) display_text (_("Encrypted Text"), enctext, FALSE); } else { notification_error (_("Encryption Failed"), _("The clipboard could not be encrypted."), sapplet, err); g_clear_error (&err); } g_strfreev(keys); g_free (signer); g_free (enctext); } }
static gboolean ide_terminal_copy_link_address (IdeTerminal *self) { IdeTerminalPrivate *priv = ide_terminal_get_instance_private (self); g_assert (IDE_IS_TERMINAL (self)); g_assert (priv->url != NULL); if (dzl_str_empty0 (priv->url)) return FALSE; gtk_clipboard_set_text (gtk_widget_get_clipboard (GTK_WIDGET (self), GDK_SELECTION_CLIPBOARD), priv->url, strlen (priv->url)); return TRUE; }
void remmina_rdp_cliprdr_set_clipboard_content(RemminaProtocolWidget* gp, RemminaPluginRdpUiObject* ui) { TRACE_CALL(__func__); GtkClipboard* gtkClipboard; rfContext* rfi = GET_PLUGIN_DATA(gp); gtkClipboard = gtk_widget_get_clipboard(rfi->drawing_area, GDK_SELECTION_CLIPBOARD); if (ui->clipboard.format == CB_FORMAT_PNG || ui->clipboard.format == CF_DIB || ui->clipboard.format == CF_DIBV5 || ui->clipboard.format == CB_FORMAT_JPEG) { gtk_clipboard_set_image( gtkClipboard, ui->clipboard.data ); g_object_unref(ui->clipboard.data); }else { gtk_clipboard_set_text( gtkClipboard, ui->clipboard.data, -1 ); free(ui->clipboard.data); } }
void copy_button_clicked (GtkWidget *button, gpointer user_data) { GtkWidget *entry; GtkClipboard *clipboard; entry = GTK_WIDGET (user_data); /* Get the clipboard object */ clipboard = gtk_widget_get_clipboard (entry, GDK_SELECTION_CLIPBOARD); /* Set clipboard text */ gtk_clipboard_set_text (clipboard, gtk_entry_get_text (GTK_ENTRY (entry)), -1); }
/** Append text to clipboard (primary and default). */ static void clipboard_append(const char *jobinfo){ GdkAtom atoms[2]={GDK_SELECTION_CLIPBOARD, GDK_SELECTION_PRIMARY}; for(int iatom=0; iatom<2; iatom++){ GtkClipboard *clip=gtk_clipboard_get(atoms[iatom]); if(!clip) continue; gchar *old=gtk_clipboard_wait_for_text(clip); gchar *newer=NULL; if(old){ newer=stradd(old, jobinfo, "\n", NULL); g_free(old); }else{ newer=stradd(jobinfo, "\n", NULL); } gtk_clipboard_set_text(clip, newer, -1); free(newer); } }
static void sign_received (GtkClipboard *board, const gchar *text, SeahorseApplet *sapplet) { gchar *signer = NULL; gchar *enctext = NULL; gboolean ret; GError *err = NULL; /* No text on clipboard */ if (!text) return; if (cryptui_keyset_get_count (dbus_keyset) == 0) cryptui_need_to_get_keys (dbus_keyset); else signer = cryptui_prompt_signer (dbus_keyset, _("Choose Key to Sign with")); if (signer == NULL) return; /* Perform the signing */ ret = dbus_g_proxy_call (dbus_crypto_proxy, "SignText", &err, G_TYPE_STRING, signer, G_TYPE_INT, 0, G_TYPE_STRING, text, G_TYPE_INVALID, G_TYPE_STRING, &enctext, G_TYPE_INVALID); if (ret) { /* And finish up */ gtk_clipboard_set_text (board, enctext, strlen (enctext)); detect_received (board, enctext, sapplet); if (seahorse_gconf_get_boolean (DISPLAY_CLIPBOARD_ENC_KEY) == TRUE) display_text (_("Signed Text"), enctext, FALSE); } else { notification_error (_("Signing Failed"), _("The clipboard could not be Signed."), sapplet, err); g_clear_error (&err); } g_free (signer); g_free (enctext); }
/* Copy on clipboard */ void ping_copy_to_clipboard (Netinfo * netinfo, gpointer user_data) { GString *result, *content; const gchar *min, *avg, *max; const gchar *pkt_transmitted, *pkt_received, *pkt_success; g_return_if_fail (netinfo != NULL); /* The ping output in text format: Bytes received, Address Source, Number of Sequence, Round Trip Time (Time), Units of Time. It's a tabular output, and these belongs to the column titles */ result = g_string_new (_("Bytes\tSource\tSeq\tTime\tUnits\n")); content = util_tree_model_to_string (GTK_TREE_VIEW (netinfo->output)); g_string_append_printf (result, "%s", content->str); min = gtk_label_get_text (GTK_LABEL (netinfo->min)); avg = gtk_label_get_text (GTK_LABEL (netinfo->avg)); max = gtk_label_get_text (GTK_LABEL (netinfo->max)); pkt_transmitted = gtk_label_get_text (GTK_LABEL (netinfo->packets_transmitted)); pkt_received = gtk_label_get_text (GTK_LABEL (netinfo->packets_received)); pkt_success = gtk_label_get_text (GTK_LABEL (netinfo->packets_success)); /* The ping output in a text format (to copy on clipboard) */ g_string_append_printf (result, _("Time minimum:\t%s ms\n"), min); g_string_append_printf (result, _("Time average:\t%s ms\n"), avg); g_string_append_printf (result, _("Time maximum:\t%s ms\n"), max); g_string_append_printf (result, _("Packets transmitted:\t%s\n"), pkt_transmitted); g_string_append_printf (result, _("Packets received:\t%s\n"), pkt_received); g_string_append_printf (result, _("Successful packets:\t%s\n"), pkt_success); gtk_clipboard_set_text (gtk_clipboard_get (GDK_NONE), result->str, result->len); g_string_free (content, TRUE); g_string_free (result, TRUE); }
static gboolean bar_pane_exif_copy_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { const gchar *value; GtkClipboard *clipboard; ExifEntry *ee; if (bevent->button == MOUSE_BUTTON_LEFT) { ee = g_object_get_data(G_OBJECT(widget), "entry_data"); value = gtk_label_get_text(GTK_LABEL(ee->value_widget)); clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); gtk_clipboard_set_text(clipboard, value, -1); return TRUE; } return FALSE; }
void copy_timestamp (GSimpleAction *action, GVariant *parameter, gpointer user_data) { PtWindow *win; win = PT_WINDOW (user_data); GtkClipboard *clip; const gchar *timestamp = NULL; timestamp = pt_player_get_timestamp (win->priv->player); if (timestamp) { clip = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text (clip, timestamp, -1); } }
static void copy_location_callback (GtkAction *action, gpointer data) { WebKitWebFrame *frame; const gchar *uri; frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view)); uri = webkit_web_frame_get_uri (frame); if (uri) { GtkClipboard *clipboard; clipboard = gtk_clipboard_get_for_display (gtk_widget_get_display (view), GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text (clipboard, uri, -1); } }
static gint gtk_anim_label_button_press(GtkWidget * widget, GdkEventButton * event ) { GtkAnimLabel *anim_label; g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(GTK_IS_ANIM_LABEL(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); anim_label = GTK_ANIM_LABEL(widget); if (anim_label->txt) { char *plain = (char *) pango_layout_get_text(anim_label->layout); gtk_clipboard_set_text(gtk_widget_get_clipboard(GTK_WIDGET(anim_label), GDK_SELECTION_CLIPBOARD), plain, -1); } return FALSE; }
// Clipboard support requires GTK+ // TODO: GTK+ uses UTF-8. We don't, so some conversions would be appropriate. void I_PutInClipboard (const char *str) { #ifndef NO_GTK if (GtkAvailable) { GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); if (clipboard != NULL) { gtk_clipboard_set_text(clipboard, str, -1); } /* Should I? I don't know. It's not actually a selection. clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); if (clipboard != NULL) { gtk_clipboard_set_text(clipboard, str, -1); } */ } #endif }
void menu_copy(GtkTreeSelection *selection, const MenuItem *menu_item) { ScpTreeStore *store; GtkTreeIter iter; const gchar *name, *display; const char *value; GString *string; scp_tree_selection_get_selected(selection, &store, &iter); scp_tree_store_get(store, &iter, COLUMN_NAME, &name, COLUMN_DISPLAY, &display, COLUMN_VALUE, &value, -1); string = g_string_new(name); if (value) g_string_append_printf(string, " = %s", display); gtk_clipboard_set_text(gtk_widget_get_clipboard(menu_item->widget, GDK_SELECTION_CLIPBOARD), string->str, string->len); g_string_free(string, TRUE); }
void cb_copy_to_clipboard() { ShellModuleEntry *entry = shell_get_main_shell()->selected; if (entry) { gchar *data = module_entry_function(entry); GtkClipboard *clip = gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)); ReportContext *ctx = report_context_text_new(NULL); ctx->entry = entry; report_header(ctx); report_table(ctx, data); report_footer(ctx); gtk_clipboard_set_text(clip, ctx->output, -1); g_free(data); report_context_free(ctx); } }
void set_output_buffer_bak_to_clipboard() { char *text, *utf8_gbtext=NULL; if (gb_output) { trad2sim(output_buffer_raw_bak, strlen(output_buffer_raw_bak), &utf8_gbtext); text = utf8_gbtext; } else text = output_buffer_raw_bak; #if UNIX && 0 GtkClipboard *pclipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); #else GtkClipboard *pclipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); #endif gtk_clipboard_set_text(pclipboard, text, -1); free(utf8_gbtext); }
static void on_compiler_treeview_copy_activate(GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *tv = NULL; GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; gint str_idx = COMPILER_COL_STRING; switch (GPOINTER_TO_INT(user_data)) { case MSG_STATUS: tv = msgwindow.tree_status; str_idx = 0; break; case MSG_COMPILER: tv = msgwindow.tree_compiler; break; case MSG_MESSAGE: tv = msgwindow.tree_msg; str_idx = MSG_COL_STRING; break; } selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); if (gtk_tree_selection_get_selected(selection, &model, &iter)) { gchar *string; gtk_tree_model_get(model, &iter, str_idx, &string, -1); if (!EMPTY(string)) { gtk_clipboard_set_text(gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)), string, -1); } g_free(string); } }
static void debug_dialog_menu_copy_activate_cb (GtkMenuItem *menu_item, EmpathyDebugDialog *debug_dialog) { EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); GtkTreePath *path; GtkTreeViewColumn *focus_column; GtkTreeIter iter; gchar *message; GtkClipboard *clipboard; gtk_tree_view_get_cursor (GTK_TREE_VIEW (priv->view), &path, &focus_column); if (path == NULL) { DEBUG ("No row is in focus"); return; } gtk_tree_model_get_iter (priv->store_filter, &iter, path); gtk_tree_model_get (priv->store_filter, &iter, COL_DEBUG_MESSAGE, &message, -1); if (EMP_STR_EMPTY (message)) { DEBUG ("Log message is empty"); return; } clipboard = gtk_clipboard_get_for_display ( gtk_widget_get_display (GTK_WIDGET (menu_item)), GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text (clipboard, message, -1); g_free (message); }
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 cb_page_widget_text_selected(ZathuraPage* page, const char* text, void* data) { g_return_if_fail(page != NULL); g_return_if_fail(text != NULL); g_return_if_fail(data != NULL); zathura_t* zathura = data; girara_mode_t mode = girara_mode_get(zathura->ui.session); if (mode != zathura->modes.normal && mode != zathura->modes.fullscreen) { return; } GdkAtom* selection = get_selection(zathura); /* copy to clipboard */ if (selection != NULL) { gtk_clipboard_set_text(gtk_clipboard_get(*selection), text, -1); bool notification = true; girara_setting_get(zathura->ui.session, "selection-notification", ¬ification); if (notification == true) { char* target = NULL; girara_setting_get(zathura->ui.session, "selection-clipboard", &target); char* stripped_text = g_strdelimit(g_strdup(text), "\n\t\r\n", ' '); char* escaped_text = g_markup_printf_escaped( _("Copied selected text to selection %s: %s"), target, stripped_text); g_free(target); g_free(stripped_text); girara_notify(zathura->ui.session, GIRARA_INFO, "%s", escaped_text); g_free(escaped_text); } } g_free(selection); }
/* Copy on clipboard */ void scan_copy_to_clipboard (Netinfo * netinfo, gpointer user_data) { GString *result, *content; g_return_if_fail (netinfo != NULL); /* The portscan output in text format: Port, State, Service. It's a tabular output, and these belongs to the column titles */ result = g_string_new (_("Port\tState\tService\n")); content = util_tree_model_to_string (GTK_TREE_VIEW (netinfo->output)); g_string_append_printf (result, "%s", content->str); gtk_clipboard_set_text (gtk_clipboard_get (GDK_NONE), result->str, result->len); g_string_free (content, TRUE); g_string_free (result, TRUE); }
gboolean mouse_freq(GtkWidget *widget, GdkEvent *event, gpointer nothing) { const gchar *freq_text = gtk_label_get_text(GTK_LABEL(ui.l_freq)); const gchar *pi_text = gtk_label_get_text(GTK_LABEL(ui.l_pi)); gchar buff[30]; gchar *ps; if(tuner.rds_ps_avail) { if(conf.replace_spaces) { ps = replace_spaces(tuner.rds_ps); g_snprintf(buff, sizeof(buff), "%s %s %s", freq_text, pi_text, ps); g_free(ps); } else { g_snprintf(buff, sizeof(buff), "%s %s %s", freq_text, pi_text, tuner.rds_ps); } } else if(tuner.rds_pi >= 0) { g_snprintf(buff, sizeof(buff), "%s %s", freq_text, pi_text); } else { g_snprintf(buff, sizeof(buff), "%s", freq_text); } gtk_clipboard_set_text(gtk_widget_get_clipboard(ui.window, GDK_SELECTION_CLIPBOARD), buff, -1); return TRUE; }
static void debug_dialog_copy_clicked_cb (GtkToolButton *tool_button, EmpathyDebugDialog *debug_dialog) { EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); GtkClipboard *clipboard; gchar *text; text = g_strdup (""); gtk_tree_model_foreach (priv->store_filter, debug_dialog_copy_model_foreach, &text); clipboard = gtk_clipboard_get_for_display ( gtk_widget_get_display (GTK_WIDGET (tool_button)), GDK_SELECTION_CLIPBOARD); DEBUG ("Copying text to clipboard (length: %" G_GSIZE_FORMAT ")", strlen (text)); gtk_clipboard_set_text (clipboard, text, -1); g_free (text); }
void entry_text_changes ( GtkEntry *entry, gpointer data ) { g_return_if_fail(data != NULL); GtkClipboard *clipboard = (GtkClipboard*)data; gtk_clipboard_set_text( clipboard, gtk_entry_get_text( entry ), -1 ); }
/* This is Sparta! */ int main(int argc, char **argv) { bindtextdomain(GETTEXT_PACKAGE, CLIPITLOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); /* Initiate GTK+ */ gtk_init(&argc, &argv); /* Parse options and exit if returns TRUE */ if (argc > 1) { if (parse_options(argc, argv)) return 0; } /* Read input from stdin (if any) */ else { /* Check if stdin is piped */ if (!isatty(fileno(stdin))) { GString* piped_string = g_string_new(NULL); /* Append stdin to string */ while (1) { gchar* buffer = (gchar*)g_malloc(256); if (fgets(buffer, 256, stdin) == NULL) { g_free(buffer); break; } g_string_append(piped_string, buffer); g_free(buffer); } /* Check if anything was piped in */ if (piped_string->len > 0) { /* Truncate new line character */ /* g_string_truncate(piped_string, (piped_string->len - 1)); */ /* Copy to clipboard */ GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text(clip, piped_string->str, -1); gtk_clipboard_store(clip); /* Exit */ return 0; } g_string_free(piped_string, TRUE); } } /* Init ClipIt */ clipit_init(); /* Run GTK+ loop */ gtk_main(); /* Unbind keys */ keybinder_unbind(prefs.history_key, history_hotkey); keybinder_unbind(prefs.actions_key, actions_hotkey); keybinder_unbind(prefs.menu_key, menu_hotkey); keybinder_unbind(prefs.search_key, search_hotkey); keybinder_unbind(prefs.offline_key, offline_hotkey); /* Cleanup */ g_free(prefs.history_key); g_free(prefs.actions_key); g_free(prefs.menu_key); g_free(prefs.search_key); g_free(prefs.offline_key); g_list_foreach(history, (GFunc)g_free, NULL); g_list_free(history); g_free(primary_text); g_free(clipboard_text); g_free(synchronized_text); /* Exit */ return 0; }
/* Called every CHECK_INTERVAL seconds to check for new items */ static gboolean item_check(gpointer data) { /* Immediately return in offline mode */ if (prefs.offline_mode) return TRUE; /* Grab the current primary and clipboard text */ gchar* primary_temp = gtk_clipboard_wait_for_text(primary); gchar* clipboard_temp = gtk_clipboard_wait_for_text(clipboard); /* What follows is an extremely confusing system of tests and crap... */ /* 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) { if(prefs.use_primary) { /* if use_primary is enabled, we restore from primary */ gtk_clipboard_set_text(primary, primary_text, -1); } /* else * { * // else, we restore from history * GList* element = g_list_nth(history, 0); * gtk_clipboard_set_text(primary, (gchar*)element->data, -1); * } */ } } else { GdkModifierType button_state; gdk_window_get_pointer(NULL, NULL, NULL, &button_state); /* Proceed if mouse button not being held */ if ((primary_temp != NULL) && !(button_state & GDK_BUTTON1_MASK)) { /* Check if primary is the same as the last entry */ if (g_strcmp0(primary_temp, primary_text) != 0) { /* New primary entry */ g_free(primary_text); primary_text = g_strdup(primary_temp); /* Check if primary option is enabled and if there's text to add */ if (prefs.use_primary && primary_text) { check_and_append(primary_text); } } } } /* 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) { g_print("Clipboard is null, recovering ...\n"); gtk_clipboard_set_text(clipboard, clipboard_text, -1); } } else { /* Check if clipboard is the same as the last entry */ if (g_strcmp0(clipboard_temp, clipboard_text) != 0) { /* New clipboard entry */ g_free(clipboard_text); clipboard_text = g_strdup(clipboard_temp); /* Check if clipboard option is enabled and if there's text to add */ if (prefs.use_copy && clipboard_text) { check_and_append(clipboard_text); } } } /* Synchronization */ if (prefs.synchronize) { if (g_strcmp0(synchronized_text, primary_text) != 0) { g_free(synchronized_text); synchronized_text = g_strdup(primary_text); gtk_clipboard_set_text(clipboard, primary_text, -1); } else if (g_strcmp0(synchronized_text, clipboard_text) != 0) { g_free(synchronized_text); synchronized_text = g_strdup(clipboard_text); gtk_clipboard_set_text(primary, clipboard_text, -1); } } /* Cleanup */ g_free(primary_temp); g_free(clipboard_temp); return TRUE; }
bool sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* UNUSED(event), unsigned int UNUSED(t)) { g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session->gtk.inputbar_entry != NULL, false); g_return_val_if_fail(session->global.data != NULL, false); zathura_t* zathura = session->global.data; g_return_val_if_fail(argument != NULL, false); zathura_document_set_adjust_mode(zathura->document, ZATHURA_ADJUST_INPUTBAR); if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.inputbar)) == false) { gtk_widget_show(GTK_WIDGET(session->gtk.inputbar)); } if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.notification_area)) == true) { gtk_widget_hide(GTK_WIDGET(session->gtk.notification_area)); } gtk_widget_grab_focus(GTK_WIDGET(session->gtk.inputbar_entry)); if (argument->data != NULL) { gtk_entry_set_text(session->gtk.inputbar_entry, (char*) argument->data); /* append filepath */ if (argument->n == APPEND_FILEPATH && zathura->document != NULL) { const char* file_path = zathura_document_get_path(zathura->document); if (file_path == NULL) { return false; } char* path = g_path_get_dirname(file_path); char* escaped = girara_escape_string(path); char* tmp = g_strdup_printf("%s%s/", (char*) argument->data, (g_strcmp0(path, "/") == 0) ? "" : escaped); g_free(path); g_free(escaped); gtk_entry_set_text(session->gtk.inputbar_entry, tmp); g_free(tmp); } GdkAtom* selection = get_selection(zathura); /* we save the X clipboard that will be clear by "grab_focus" */ gchar* x_clipboard_text = NULL; if (selection != NULL) { x_clipboard_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(*selection)); } gtk_editable_set_position(GTK_EDITABLE(session->gtk.inputbar_entry), -1); if (x_clipboard_text != NULL && selection != NULL) { /* we reset the X clipboard with saved text */ gtk_clipboard_set_text(gtk_clipboard_get(*selection), x_clipboard_text, -1); g_free(x_clipboard_text); } g_free(selection); } return true; }
static gboolean term_key_event (GtkWidget * widget, GdkEventKey * event, gpointer user_data) { terms_t *terms = (terms_t *) user_data; bind_t *cur; guint state = event->state; GtkClipboard *clipboard; gchar *text; state &= 0xED; // fprintf (stderr, "%s: keyval: %d, state: 0x%x\n", __func__, event->keyval, state); for (cur = terms->keys; cur; cur = cur->next) { if ((event->keyval >= cur->key_min) && (event->keyval <= cur->key_max)) { if (state == cur->state) { switch (cur->action) { case BIND_ACT_SWITCH: term_switch (terms, cur->base + (event->keyval - cur->key_min), cur->cmd); break; case BIND_ACT_CUT: widget = gtk_notebook_get_nth_page(terms->notebook, gtk_notebook_get_current_page(terms->notebook)); if (GTK_WIDGET_REALIZED(widget)) { clipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(widget), GDK_SELECTION_CLIPBOARD); } else { clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* wing it */ } text = temu_terminal_get_selection_text(widget); // printf("cut: '%s'\n", text); gtk_clipboard_set_text(clipboard, text, strlen(text)); break; case BIND_ACT_PASTE: widget = gtk_notebook_get_nth_page(terms->notebook, gtk_notebook_get_current_page(terms->notebook)); if (GTK_WIDGET_REALIZED(widget)) { clipboard = gtk_clipboard_get_for_display(gtk_widget_get_display(widget), GDK_SELECTION_CLIPBOARD); } else { clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* wing it */ } text = gtk_clipboard_wait_for_text(clipboard); if (text) { //printf("paste: '%s'\n", text); temu_terminal_insert_text(widget, text); g_free(text); } else { // Oh boy, this is going to be 'Fun'. GtkSelectionData *data; data = gtk_clipboard_wait_for_contents(clipboard, gdk_atom_intern_static_string("STRING")); if (data) { //printf("paste; len: %d, '%s'\n", data->length, data->data); { char buf[data->length + 1]; memset(buf, '\0', data->length + 1); memcpy(buf, data->data, data->length); temu_terminal_insert_text(widget, buf); } gtk_selection_data_free(data); } } break; } return TRUE; } } } return FALSE; }
static void handle_copy_to_clipboard(GtkStatusIcon *status_icon, gpointer user_data) { GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text(clipboard, url, -1); gtk_clipboard_store(clipboard); }
static void _cd_copy_location (GtkMenuItem *pMenuItem, gpointer data) { GtkClipboard *pClipBoard; pClipBoard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); // GDK_SELECTION_PRIMARY gtk_clipboard_set_text (pClipBoard, myData.cCurrentUri, -1); }
//__________________________________________________________________________________ void PlaceStringInClipboard (_String& res,Ptr ) { gtk_clipboard_set_text (gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),res.sData,res.sLength); }