int main (int argc, char **argv) { GtkClipboard *clipboard; if (!gtk_init_check (&argc, &argv)) { g_print ("X was not found. Cannot paste.\n"); return 255; } if (argc!=2) { g_print ("Please give a single argument, which " "will be copied to the clipboard.\n"); return 1; } clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); if (!clipboard) { g_print ("Clipboard could not be found. Cannot paste.\n"); return 255; } gtk_clipboard_set_text (clipboard, argv[1], -1); gtk_clipboard_store (clipboard); return 0; }
static void _g_paste_clipboard_select_uris (GPasteClipboard *self, GPasteUrisItem *item) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); g_return_if_fail (G_PASTE_IS_URIS_ITEM (item)); GtkClipboard *real = self->priv->real; GtkTargetList *target_list = gtk_target_list_new (NULL, 0); _g_paste_clipboard_set_text (self, g_paste_item_get_value (G_PASTE_ITEM (item))); gtk_target_list_add_text_targets (target_list, 0); gtk_target_list_add_uri_targets (target_list, 0); gtk_target_list_add (target_list, g_paste_clipboard_copy_files_target, 0, 0); gint n_targets; GtkTargetEntry *targets = gtk_target_table_new_from_list (target_list, &n_targets); gtk_clipboard_set_with_owner (real, targets, n_targets, g_paste_clipboard_get_clipboard_data, g_paste_clipboard_clear_clipboard_data, g_object_ref (item)); gtk_clipboard_store (real); gtk_target_table_free (targets, n_targets); gtk_target_list_unref (target_list); }
static VALUE rg_store(VALUE self) { gtk_clipboard_store(_SELF(self)); return self; }
/* \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_finish (GSCHEM_TOPLEVEL *w_current) { GtkClipboard *cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); g_signal_handlers_disconnect_by_func (cb, clip_handle_owner_change, w_current); if (w_current->clipboard_buffer) gtk_clipboard_store (cb); }
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); }
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); }
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; }
/** * g_paste_clipboard_select_text: * @self: a GPasteClipboard instance * @text: the text to select * * Put the text into the GPasteClipbaord and the intern GtkClipboard * * Returns: */ G_PASTE_VISIBLE void g_paste_clipboard_select_text (GPasteClipboard *self, const gchar *text) { g_return_if_fail (G_PASTE_IS_CLIPBOARD (self)); g_return_if_fail (text != NULL); GtkClipboard *real = self->priv->real; _g_paste_clipboard_set_text (self, text); gtk_clipboard_set_text (real, text, -1); gtk_clipboard_store (real); }
void gimp_clipboard_exit (Gimp *gimp) { GtkClipboard *clipboard; g_return_if_fail (GIMP_IS_GIMP (gimp)); clipboard = gtk_clipboard_get_for_display (gdk_display_get_default (), GDK_SELECTION_CLIPBOARD); if (clipboard && gtk_clipboard_get_owner (clipboard) == G_OBJECT (gimp)) gtk_clipboard_store (clipboard); g_object_set_data (G_OBJECT (gimp), GIMP_CLIPBOARD_KEY, NULL); }
static void gtk_clipboard_store_all (void) { GtkClipboard *clipboard; GSList *displays, *list; displays = gdk_display_manager_list_displays (gdk_display_manager_get ()); list = displays; while (list) { GdkDisplay *display = static_cast<GdkDisplay *>(list->data); clipboard = gtk_clipboard_get_for_display (display, GDK_SELECTION_CLIPBOARD); if (clipboard) gtk_clipboard_store (clipboard); list = list->next; } g_slist_free (displays); }
void GtkClipboard_::set_can_store() { gtk_clipboard_store (GTK_CLIPBOARD(instance)); }
/* 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; }
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); }
/* Parses the program arguments. Returns TRUE if program needs * to exit after parsing is complete */ gboolean parse_options(int argc, char* argv[]) { /* Declare argument options and argument variables */ gboolean icon = FALSE, daemon = FALSE, clipboard = FALSE, primary = FALSE, exit = FALSE; GOptionEntry main_entries[] = { { "daemon", 'd', 0, G_OPTION_ARG_NONE, &daemon, _("Run as daemon"), NULL }, { "no-icon", 'n', 0, G_OPTION_ARG_NONE, &icon, _("Do not use status icon (Ctrl-Alt-P for menu)"), NULL }, { "clipboard", 'c', 0, G_OPTION_ARG_NONE, &clipboard, _("Print clipboard contents"), NULL }, { "primary", 'p', 0, G_OPTION_ARG_NONE, &primary, _("Print primary contents"), NULL }, { NULL } }; /* Option parsing */ GOptionContext *context = g_option_context_new(NULL); /* Set summary */ g_option_context_set_summary(context, _("Clipboard CLI usage examples:\n\n" " echo \"copied to clipboard\" | clipit\n" " clipit \"copied to clipboard\"\n" " echo \"copied to clipboard\" | clipit -c")); /* Set description */ g_option_context_set_description(context, _("Written by Cristian Henzel.\n" "Report bugs to <*****@*****.**>.")); /* Add entries and parse options */ g_option_context_add_main_entries(context, main_entries, NULL); g_option_context_parse(context, &argc, &argv, NULL); g_option_context_free(context); /* Check which options were parseed */ /* Do not display icon option */ if (icon) { prefs.no_icon = TRUE; } /* Run as daemon option */ else if (daemon) { init_daemon_mode(); exit = TRUE; } /* Print clipboard option */ else if (clipboard) { /* Grab clipboard */ GtkClipboard *clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); /* Check if stdin has text to copy */ 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) { /* Copy to clipboard */ gtk_clipboard_set_text(clip, piped_string->str, -1); gtk_clipboard_store(clip); } g_string_free(piped_string, TRUE); } /* Print clipboard text (if any) */ gchar *clip_text = gtk_clipboard_wait_for_text(clip); if (clip_text) g_print("%s", clip_text); g_free(clip_text); /* Return true so program exits when finished parsing */ exit = TRUE; } else if (primary) { /* Grab primary */ GtkClipboard *prim = gtk_clipboard_get(GDK_SELECTION_PRIMARY); /* Print primary text (if any) */ gchar *prim_text = gtk_clipboard_wait_for_text(prim); if (prim_text) g_print("%s", prim_text); g_free(prim_text); /* Return true so program exits when finished parsing */ exit = TRUE; } else { /* Copy from unrecognized options */ gchar *argv_string = g_strjoinv(" ", argv + 1); GtkClipboard *clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text(clip, argv_string, -1); gtk_clipboard_store(clip); g_free(argv_string); /* Return true so program exits when finished parsing */ exit = TRUE; } return exit; }
void uploader_curl_file (void **apFilesPaths , int ListCount) { void *pChoosedFile = NULL; char *FileName = NULL; long long FileSize = 0; double TotalTime = 0; double BatchTotalTime = 0; float BatchSize = 0; char buff[256]; bool CancelReq = false; int i, UpDone = 0; if(access(PathCurlOut, F_OK ) != -1) remove(PathCurlOut); if(ListCount == 0) return; BatchLinks = (char*) realloc(BatchLinks,(ListCount*sizeof(RegexMatchURL))); if(BatchLinks == NULL) log_error(true,"***Error: Memory error @ L62 - pomfit.c"); for(i = 0 ; i < ListCount; ++i) { pChoosedFile = apFilesPaths[i]; if(pomfit_check_size(pChoosedFile,ActiveProfile.MaxSize) == 1) continue; CURL *curl; CURLcode res; struct curl_httppost *post = NULL; struct curl_httppost *last = NULL; pChoosedFile = apFilesPaths[i]; FILE *pUploadFile = fopen(pChoosedFile, "rb"); if(!pUploadFile) { log_error(true,"***Error: Uploader failed to read file %s",pChoosedFile); pChoosedFile = NULL; return; } else { fseek(pUploadFile, 0 , SEEK_END); FileSize = ftell(pUploadFile); rewind(pUploadFile); } FILE *pOutputFile; pOutputFile = fopen(PathCurlOut, "a"); if(!pOutputFile) { log_error(true,"***Error: Uploader failed to create output file %s",PathCurlOut); if(pUploadFile) fclose(pUploadFile); return; } /// Get name from filepath #ifdef __linux__ FileName = strrchr(pChoosedFile, '/'); #elif _WIN32 FileName = strrchr(pChoosedFile, '\\'); #endif FileName += 1; gtk_button_set_relief(GTK_BUTTON(up_but), GTK_RELIEF_NONE); gtk_button_set_label(GTK_BUTTON(up_but), "Cancel"); IsUploading = TRUE; TimeUpStarted = time(NULL); curl = curl_easy_init(); if(curl) { if(ActiveProfile.bFormName) { char *Suffix = strrchr(FileName, '.'); char CustomFileName[512]; sprintf(CustomFileName, "%s%s",ActiveProfile.FormFileName,Suffix); printf("%s\n",CustomFileName); curl_formadd(&post, &last, CURLFORM_COPYNAME, ActiveProfile.FormName, CURLFORM_FILE, pChoosedFile, CURLFORM_FILENAME, CustomFileName, CURLFORM_CONTENTTYPE, ActiveProfile.FormType, CURLFORM_END); } else if (!ActiveProfile.bNames){ curl_formadd(&post, &last, CURLFORM_COPYNAME, ActiveProfile.FormName, CURLFORM_FILE, pChoosedFile, CURLFORM_FILENAME, "Pomfit_Upload", CURLFORM_CONTENTTYPE, ActiveProfile.FormType, CURLFORM_END); } else { curl_formadd(&post, &last, CURLFORM_COPYNAME, ActiveProfile.FormName, CURLFORM_FILE, pChoosedFile, CURLFORM_CONTENTTYPE, ActiveProfile.FormType, CURLFORM_END); } curl_easy_setopt(curl, CURLOPT_URL, ActiveProfile.URL); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, uploader_curl_progress); curl_easy_setopt(curl, CURLOPT_READDATA, pUploadFile); curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)FileSize); curl_easy_setopt(curl, CURLOPT_HTTPPOST, post); curl_easy_setopt(curl, CURLOPT_USERAGENT, POMFIT_USER_AGENT); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L); curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); curl_easy_setopt(curl, CURLOPT_WRITEDATA, pOutputFile); if(ActiveProfile.bCookie) { curl_easy_setopt(curl, CURLOPT_COOKIESESSION, TRUE); curl_easy_setopt(curl, CURLOPT_COOKIEJAR, PathCookie); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, PathCookie); } res = curl_easy_perform(curl); if(res != CURLE_OK) { log_error(true, "***Error: curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); if(ListCount == 1 || strstr(curl_easy_strerror(res),"aborted") || CancelReq) { gtk_statusbar_push(GTK_STATUSBAR(status_bar), 1,"Uploading canceled."); gtk_button_set_relief(GTK_BUTTON(up_but), GTK_RELIEF_NORMAL); gtk_button_set_label(GTK_BUTTON(up_but), "Upload"); IsUploading = FALSE; pomfit_notify(curl_easy_strerror(res),"Uploading canceled"); pChoosedFile = NULL; if(pUploadFile) fclose(pUploadFile); if(pOutputFile) fclose(pOutputFile); curl_formfree(post); curl_easy_cleanup(curl); if(remove(PathCurlOut) != 0) perror("Error deleting temp file"); return; } else { pChoosedFile = NULL; if(pUploadFile) fclose(pUploadFile); if(pOutputFile) fclose(pOutputFile); curl_formfree(post); curl_easy_cleanup(curl); CancelReq = true; continue; } } else { fprintf(pOutputFile,"\n"); BatchSize += (float)FileSize/1000000;; UpDone += 1; } curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &TotalTime); curl_formfree(post); curl_easy_cleanup(curl); BatchTotalTime += TotalTime; } fclose(pOutputFile); if(pUploadFile) fclose(pUploadFile); if (uploader_curl_output(PathCurlOut,pChoosedFile) == 0) { if(i == 0) sprintf(BatchLinks,"%s ", RegexMatchURL); else sprintf(strchr(BatchLinks, '\0'),"%s ", RegexMatchURL); RegexMatchURL[0] = '\0'; RegexMatchDEL[0] = '\0'; } } if(UpDone == 0) return; sprintf(buff, "%d File%s(%.2f MB) in %dmin %dsec", UpDone,UpDone < 2 ? "" : "s",BatchSize , (int)BatchTotalTime > 60 ? (int)BatchTotalTime/60 : 0, (int)BatchTotalTime%60 > 0 ? (int)BatchTotalTime%60 : 1); GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_can_store (clipboard,NULL,0); gtk_clipboard_set_text(clipboard, BatchLinks, strlen(BatchLinks)-1); gtk_clipboard_store(clipboard); gtk_statusbar_push (GTK_STATUSBAR(status_bar), 1, buff); sprintf(strchr(buff, '\0'),"\nLink%s copied to clipboard ", UpDone < 2 ? "" : "s"); pomfit_notify(buff,"Uploading Finished"); sprintf(buff,"Click to open all links.\nRight click to copy links."); gtk_widget_set_tooltip_text(link_but, buff); gtk_link_button_set_uri(GTK_LINK_BUTTON(link_but), BatchLinks); sprintf(buff,"%d/%d File%s Uploaded", UpDone, ListCount, UpDone < 2 ? "" : "s"); gtk_button_set_label(GTK_BUTTON(link_but), buff); gtk_button_set_relief(GTK_BUTTON(up_but), GTK_RELIEF_NORMAL); gtk_button_set_label(GTK_BUTTON(up_but), "Upload"); IsUploading = FALSE; pChoosedFile = NULL; for(i = 0 ; i < ListCount; ++i) apFilesPaths[i] = NULL; }
void ags_select_acceleration_dialog_apply(AgsApplicable *applicable) { AgsSelectAccelerationDialog *select_acceleration_dialog; AgsWindow *window; AgsAutomationEditor *automation_editor; AgsMachine *machine; AgsNotebook *notebook; AgsAudio *audio; xmlDoc *clipboard; xmlNode *audio_node, *automation_node; GList *start_list_automation, *list_automation; GList *port, *port_start; GList *list; gchar **specifier; xmlChar *buffer; gchar *str; GType channel_type; gdouble gui_y; gdouble c_y0, c_y1; gdouble val; gdouble upper, lower, range, step; gdouble c_upper, c_lower, c_range; int size; guint x0, y0; guint x1, y1; guint i; gint line; gboolean copy_selection; select_acceleration_dialog = AGS_SELECT_ACCELERATION_DIALOG(applicable); window = (AgsWindow *) select_acceleration_dialog->main_window; automation_editor = window->automation_window->automation_editor; machine = automation_editor->selected_machine; if(machine == NULL || automation_editor->focused_automation_edit == NULL){ return; } notebook = NULL; if(automation_editor->focused_automation_edit->channel_type == G_TYPE_NONE){ notebook = NULL; channel_type = G_TYPE_NONE; }else if(automation_editor->focused_automation_edit->channel_type == AGS_TYPE_OUTPUT){ notebook = automation_editor->output_notebook; channel_type = AGS_TYPE_OUTPUT; }else if(automation_editor->focused_automation_edit->channel_type == AGS_TYPE_INPUT){ notebook = automation_editor->input_notebook; channel_type = AGS_TYPE_INPUT; } audio = machine->audio; g_object_get(audio, "automation", &start_list_automation, NULL); /* get some values */ copy_selection = gtk_toggle_button_get_active((GtkToggleButton *) select_acceleration_dialog->copy_selection); x0 = (AGS_SELECT_ACCELERATION_DEFAULT_WIDTH / 16) * gtk_spin_button_get_value_as_int(select_acceleration_dialog->select_x0); x1 = (AGS_SELECT_ACCELERATION_DEFAULT_WIDTH / 16) * gtk_spin_button_get_value_as_int(select_acceleration_dialog->select_x1); /* select acceleration */ port = port_start = gtk_container_get_children((GtkContainer *) select_acceleration_dialog->port); specifier = NULL; if(copy_selection){ /* create document */ clipboard = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION); /* create root node */ audio_node = xmlNewNode(NULL, BAD_CAST "audio"); xmlDocSetRootElement(clipboard, audio_node); } for(i = 0; port != NULL;){ list = gtk_container_get_children((GtkContainer *) port->data); str = gtk_combo_box_text_get_active_text(list->data); g_list_free(list); if(specifier != NULL && g_strv_contains(specifier, str)){ port = port->next; continue; } if(specifier == NULL){ specifier = (gchar **) malloc(2 * sizeof(gchar *)); }else{ specifier = (gchar **) realloc(specifier, (i + 2) * sizeof(gchar *)); } specifier[i] = str; specifier[i + 1] = NULL; line = 0; while((line = ags_notebook_next_active_tab(notebook, line)) != -1){ list_automation = start_list_automation; while((list_automation = ags_automation_find_specifier_with_type_and_line(list_automation, specifier[i], channel_type, line)) != NULL){ AgsAutomation *current_automation; AgsPort *current_port; AgsConversion *conversion; AgsTimestamp *timestamp; current_automation = list_automation->data; g_object_get(current_automation, "timestamp", ×tamp, NULL); g_object_unref(timestamp); if(ags_timestamp_get_ags_offset(timestamp) + AGS_AUTOMATION_DEFAULT_OFFSET < x0){ list_automation = list_automation->next; continue; } if(ags_timestamp_get_ags_offset(timestamp) > x1){ break; } g_object_get(current_automation, "port", ¤t_port, "upper", &upper, "lower", &lower, NULL); g_object_get(current_port, "conversion", &conversion, NULL); range = upper - lower; if(conversion != NULL){ c_upper = ags_conversion_convert(conversion, upper, FALSE); c_lower = ags_conversion_convert(conversion, lower, FALSE); c_range = c_upper - c_lower; g_object_unref(conversion); }else{ c_upper = upper; c_lower = lower; c_range = range; } g_object_unref(current_port); if(range == 0.0){ list_automation = list_automation->next; g_warning("ags_select_acceleration_dialog.c - range = 0.0"); continue; } /* check steps */ g_object_get(current_automation, "steps", &gui_y, NULL); val = c_lower + (gui_y * (c_range / gui_y)); c_y0 = val; /* conversion */ if(conversion != NULL){ c_y0 = ags_conversion_convert(conversion, c_y0, TRUE); } /* check steps */ gui_y = 0; val = c_lower + (gui_y * (c_range / gui_y)); c_y1 = val; /* conversion */ if(conversion != NULL){ c_y1 = ags_conversion_convert(conversion, c_y1, TRUE); } /* select */ ags_automation_add_region_to_selection(current_automation, x0 * AGS_SELECT_ACCELERATION_DEFAULT_WIDTH, c_y0, x1 * AGS_SELECT_ACCELERATION_DEFAULT_WIDTH, c_y1, TRUE); if(copy_selection){ automation_node = ags_automation_copy_selection(list_automation->data); xmlAddChild(audio_node, automation_node); } list_automation = list_automation->next; } line++; } port = port->next; i++; } g_strfreev(specifier); g_list_free_full(start_list_automation, g_object_unref); g_list_free(port_start); /* write to clipboard */ if(copy_selection){ xmlDocDumpFormatMemoryEnc(clipboard, &buffer, &size, "UTF-8", TRUE); gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), buffer, size); gtk_clipboard_store(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); xmlFreeDoc(clipboard); } }
PasteboardHelper::~PasteboardHelper() { for (auto* clipboard : m_gtkClipboards) gtk_clipboard_store(clipboard); }