static void docinfo_real (CeditDocument *doc, DocInfoDialog *dialog) { GtkTextIter start, end; gint words = 0; gint chars = 0; gint white_chars = 0; gint lines = 0; gint bytes = 0; gchar *tmp_str; gchar *doc_name; cedit_debug (DEBUG_PLUGINS); gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), &start, &end); lines = gtk_text_buffer_get_line_count (GTK_TEXT_BUFFER (doc)); calculate_info (doc, &start, &end, &chars, &words, &white_chars, &bytes); if (chars == 0) lines = 0; cedit_debug_message (DEBUG_PLUGINS, "Chars: %d", chars); cedit_debug_message (DEBUG_PLUGINS, "Lines: %d", lines); cedit_debug_message (DEBUG_PLUGINS, "Words: %d", words); cedit_debug_message (DEBUG_PLUGINS, "Chars non-space: %d", chars - white_chars); cedit_debug_message (DEBUG_PLUGINS, "Bytes: %d", bytes); doc_name = cedit_document_get_short_name_for_display (doc); tmp_str = g_strdup_printf ("<span weight=\"bold\">%s</span>", doc_name); gtk_label_set_markup (GTK_LABEL (dialog->file_name_label), tmp_str); g_free (doc_name); g_free (tmp_str); tmp_str = g_strdup_printf("%d", lines); gtk_label_set_text (GTK_LABEL (dialog->lines_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", words); gtk_label_set_text (GTK_LABEL (dialog->words_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", chars); gtk_label_set_text (GTK_LABEL (dialog->chars_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", chars - white_chars); gtk_label_set_text (GTK_LABEL (dialog->chars_ns_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", bytes); gtk_label_set_text (GTK_LABEL (dialog->bytes_label), tmp_str); g_free (tmp_str); }
/*********** * Put a packet into the jitterbuffers * Only the timestamps of voicepackets are put in the history * this because the jitterbuffer only works for voicepackets * don't put packets twice in history and queue (e.g. transmitting every frame twice) * keep track of statistics */ void jb_put(jitterbuffer *jb, void *data, int type, long ms, long ts, long now, int codec) { long pointer, max_index; if (jb == NULL) { jb_err("no jitterbuffer in jb_put()\n"); return; } jb->info.frames_received++; if (type == JB_TYPE_CONTROL) { //put the packet into the contol-queue of the jitterbuffer jb_dbg("pC"); put_control(jb,data,type,ts); } else if (type == JB_TYPE_VOICE) { // only add voice that aren't already in the buffer max_index = (jb->hist_pointer < JB_HISTORY_SIZE) ? jb->hist_pointer : JB_HISTORY_SIZE-1; pointer = find_pointer(&jb->hist_sorted_timestamp[0], max_index, ts); if (jb->hist_sorted_timestamp[pointer]==ts) { //timestamp already in queue jb_dbg("pT"); free(data); jb->info.frames_dropped_twice++; } else { //add jb_dbg("pV"); /* add voicepacket to history */ put_history(jb,ts,now,ms,codec); /*calculate jitterbuffer size*/ calculate_info(jb, ts, now, codec); /*put the packet into the queue of the jitterbuffer*/ put_voice(jb,data,type,ms,ts,codec); } } else if (type == JB_TYPE_SILENCE){ //silence jb_dbg("pS"); put_voice(jb,data,type,ms,ts,codec); } else {//should NEVER happen jb_err("jb_put(): type not known\n"); free(data); } }
static void selectioninfo_real (CeditDocument *doc, DocInfoDialog *dialog) { gboolean sel; GtkTextIter start, end; gint words = 0; gint chars = 0; gint white_chars = 0; gint lines = 0; gint bytes = 0; gchar *tmp_str; cedit_debug (DEBUG_PLUGINS); sel = gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc), &start, &end); if (sel) { lines = gtk_text_iter_get_line (&end) - gtk_text_iter_get_line (&start) + 1; calculate_info (doc, &start, &end, &chars, &words, &white_chars, &bytes); cedit_debug_message (DEBUG_PLUGINS, "Selected chars: %d", chars); cedit_debug_message (DEBUG_PLUGINS, "Selected lines: %d", lines); cedit_debug_message (DEBUG_PLUGINS, "Selected words: %d", words); cedit_debug_message (DEBUG_PLUGINS, "Selected chars non-space: %d", chars - white_chars); cedit_debug_message (DEBUG_PLUGINS, "Selected bytes: %d", bytes); gtk_widget_set_sensitive (dialog->selection_vbox, TRUE); } else { gtk_widget_set_sensitive (dialog->selection_vbox, FALSE); cedit_debug_message (DEBUG_PLUGINS, "Selection empty"); } if (chars == 0) lines = 0; tmp_str = g_strdup_printf("%d", lines); gtk_label_set_text (GTK_LABEL (dialog->selected_lines_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", words); gtk_label_set_text (GTK_LABEL (dialog->selected_words_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", chars); gtk_label_set_text (GTK_LABEL (dialog->selected_chars_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", chars - white_chars); gtk_label_set_text (GTK_LABEL (dialog->selected_chars_ns_label), tmp_str); g_free (tmp_str); tmp_str = g_strdup_printf("%d", bytes); gtk_label_set_text (GTK_LABEL (dialog->selected_bytes_label), tmp_str); g_free (tmp_str); }