예제 #1
0
static void
ide_source_snippet_dispose (GObject *object)
{
  IdeSourceSnippet *self = (IdeSourceSnippet *)object;

  if (self->mark_begin)
    {
      g_object_remove_weak_pointer (G_OBJECT (self->mark_begin),
                                    (gpointer *) &self->mark_begin);
      gtk_text_buffer_delete_mark (self->buffer, self->mark_begin);
      self->mark_begin = NULL;
    }

  if (self->mark_end)
    {
      g_object_remove_weak_pointer (G_OBJECT (self->mark_end),
                                    (gpointer *) &self->mark_end);
      gtk_text_buffer_delete_mark (self->buffer, self->mark_end);
      self->mark_end = NULL;
    }

  g_clear_pointer (&self->runs, (GDestroyNotify) g_array_unref);
  g_clear_pointer (&self->chunks, (GDestroyNotify) g_ptr_array_unref);

  g_clear_object (&self->buffer);
  g_clear_object (&self->snippet_context);

  g_free(self->language);
  g_free(self->description);
}
static gboolean
gb_color_picker_document_monitor_queue_oper_cb (gpointer data)
{
  QueuedColorize *qc = data;

  g_assert (qc != NULL);
  g_assert (GB_IS_COLOR_PICKER_DOCUMENT_MONITOR (qc->self));
  g_assert (GTK_IS_TEXT_MARK (qc->begin));
  g_assert (GTK_IS_TEXT_MARK (qc->end));
  g_assert (GTK_TEXT_BUFFER (qc->buffer));

  block_signals (qc->self, IDE_BUFFER (qc->buffer));

  if (qc->buffer != NULL)
    {
      GtkTextIter begin;
      GtkTextIter end;

      gtk_text_buffer_get_iter_at_mark (qc->buffer, &begin, qc->begin);
      gtk_text_buffer_get_iter_at_mark (qc->buffer, &end, qc->end);

      if (qc->uncolorize)
        gb_color_picker_document_monitor_uncolorize (qc->self, qc->buffer, &begin, &end);
      else
        gb_color_picker_document_monitor_colorize (qc->self, qc->buffer, &begin, &end);

      gtk_text_buffer_delete_mark (qc->buffer, qc->begin);
      gtk_text_buffer_delete_mark (qc->buffer, qc->end);
    }

  unblock_signals (qc->self, IDE_BUFFER (qc->buffer));

  return G_SOURCE_REMOVE;
}
예제 #3
0
static void
gtk_text_region_clear_zero_length_subregions (GtkTextRegion *region)
{
	GtkTextIter start, end;
	GList *node;

	g_return_if_fail (region != NULL);

	for (node = region->subregions; node; ) {
		Subregion *sr = node->data;
		gtk_text_buffer_get_iter_at_mark (region->buffer, &start, sr->start);
		gtk_text_buffer_get_iter_at_mark (region->buffer, &end, sr->end);
		if (gtk_text_iter_equal (&start, &end)) {
			gtk_text_buffer_delete_mark (region->buffer, sr->start);
			gtk_text_buffer_delete_mark (region->buffer, sr->end);
			g_free (sr);
			if (node == region->subregions)
				region->subregions = node = g_list_delete_link (node, node);
			else
				node = g_list_delete_link (node, node);

			++region->time_stamp;

		} else {
			node = node->next;
		}
	}
}
static void
gtksnippets_gtv_var_finalize (GObject *object)
{
	GtkSnippetsGtvVar *self;

	self = GTKSNIPPETS_GTV_VAR (object);
	GList *list = self->priv->mirrors;
	while(list !=NULL)
	{
		g_object_unref(list->data);
		list = g_list_next(list);
	}
	g_list_free(self->priv->mirrors);
	self->priv->mirrors = NULL;

	GtkTextBuffer *buffer = gtk_text_view_get_buffer(self->priv->view);
	gtk_text_buffer_delete_mark(buffer,self->priv->start_mark);
	gtk_text_buffer_delete_mark(buffer,self->priv->end_mark);

	self->priv->view = NULL;
	self->priv->start_mark = NULL;
	self->priv->end_mark = NULL;
	self->priv->tag_name = NULL;
	
	G_OBJECT_CLASS (gtksnippets_gtv_var_parent_class)->finalize (object);
}
예제 #5
0
static void
process_state_free (gpointer data)
{
  ProcessState *state = (ProcessState *)data;
  GtkTextBuffer *buffer;

  g_assert (state != NULL);

  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (state->source_view));
  gtk_text_buffer_delete_mark (buffer, state->begin_mark);
  gtk_text_buffer_delete_mark (buffer, state->end_mark);

  gb_beautifier_helper_remove_tmp_file (state->self, state->src_file);
  g_clear_object (&state->src_file);
  g_clear_object (&state->config_file);

  if (state->tmp_config_file != NULL)
    g_file_delete (state->tmp_config_file, NULL, NULL);
  if (state->tmp_src_file != NULL)
    g_file_delete (state->tmp_src_file, NULL, NULL);
  if (state->tmp_workdir_file != NULL)
    g_file_delete (state->tmp_workdir_file, NULL, NULL);

  g_clear_object (&state->tmp_workdir_file);
  g_clear_object (&state->tmp_config_file);
  g_clear_object (&state->tmp_src_file);

  g_free (state->lang_id);
  g_free (state->text);

  if (state->command_args != NULL)
    g_ptr_array_unref (state->command_args);

  g_slice_free (ProcessState, state);
}
예제 #6
0
static void
gb_vim_do_substitute (GtkTextBuffer *buffer,
                      GtkTextIter   *begin,
                      GtkTextIter   *end,
                      const gchar   *search_text,
                      const gchar   *replace_text,
                      gboolean       is_global,
                      gboolean       should_search_all_lines)
{
  GtkTextIter begin_tmp;
  GtkTextIter end_tmp;
  GtkTextMark *last_line;
  GtkTextIter *current_line;
  GtkTextMark *end_mark;
  GtkTextMark *insert;

  g_assert (search_text);
  g_assert (replace_text);
  g_assert ((!begin && !end) || (begin && end));

  insert = gtk_text_buffer_get_insert (buffer);

  if (!begin)
    {
      if (should_search_all_lines)
        gtk_text_buffer_get_start_iter (buffer, &begin_tmp);
      else
        gtk_text_buffer_get_iter_at_mark (buffer, &begin_tmp, insert);
      begin = &begin_tmp;
    }

  if (!end)
    {
      if (should_search_all_lines)
        gtk_text_buffer_get_end_iter (buffer, &end_tmp);
      else
        gtk_text_buffer_get_iter_at_mark (buffer, &end_tmp, insert);
      end = &end_tmp;
    }

  current_line = begin;
  last_line = gtk_text_buffer_create_mark (buffer, NULL, current_line, FALSE);
  end_mark = gtk_text_buffer_create_mark (buffer, NULL, end, FALSE);

  for (guint line = gtk_text_iter_get_line (current_line);
       line <= gtk_text_iter_get_line (end);
       line++)
    {
      gb_vim_do_substitute_line (buffer, current_line, search_text, replace_text, is_global);
      gtk_text_buffer_get_iter_at_mark (buffer, current_line, last_line);
      gtk_text_buffer_get_iter_at_mark (buffer, end, end_mark);
      gtk_text_iter_set_line (current_line, line + 1);
    }

  gtk_text_buffer_delete_mark (buffer, last_line);
  gtk_text_buffer_delete_mark (buffer, end_mark);
}
예제 #7
0
파일: snippets.c 프로젝트: bqv/gummi-vim
void snippet_info_remove_marks (GuSnippetInfo* info, GuEditor* ec) {
    GList* current = g_list_first (info->einfo);

    while (current) {
        GuSnippetExpandInfo* einfo = GU_SNIPPET_EXPAND_INFO (current->data);
        gtk_text_buffer_delete_mark (ec_buffer, einfo->left_mark);
        gtk_text_buffer_delete_mark (ec_buffer, einfo->right_mark);
        current = g_list_next (current);
    }
    slog (L_DEBUG, "Marks removed\n");
}
static void
ide_highlight_engine__unbind_buffer_cb (IdeHighlightEngine  *self,
                                        EggSignalGroup      *group)
{
    GtkTextBuffer *text_buffer;
    GtkTextTagTable *tag_table;
    GtkTextIter begin;
    GtkTextIter end;
    GSList *iter;

    IDE_ENTRY;

    g_assert (IDE_IS_HIGHLIGHT_ENGINE (self));
    g_assert (EGG_IS_SIGNAL_GROUP (group));

    text_buffer = GTK_TEXT_BUFFER (self->buffer);

    if (self->work_timeout)
    {
        g_source_remove (self->work_timeout);
        self->work_timeout = 0;
    }

    g_object_set_qdata (G_OBJECT (text_buffer), gEngineQuark, NULL);

    tag_table = gtk_text_buffer_get_tag_table (text_buffer);

    gtk_text_buffer_delete_mark (text_buffer, self->invalid_begin);
    gtk_text_buffer_delete_mark (text_buffer, self->invalid_end);

    self->invalid_begin = NULL;
    self->invalid_end = NULL;

    gtk_text_buffer_get_bounds (text_buffer, &begin, &end);

    for (iter = self->private_tags; iter; iter = iter->next)
    {
        gtk_text_buffer_remove_tag (text_buffer, iter->data, &begin, &end);
        gtk_text_tag_table_remove (tag_table, iter->data);
    }
    g_clear_pointer (&self->private_tags, g_slist_free);

    for (iter = self->public_tags; iter; iter = iter->next)
    {
        gtk_text_buffer_remove_tag (text_buffer, iter->data, &begin, &end);
        gtk_text_tag_table_remove (tag_table, iter->data);
    }
    g_clear_pointer (&self->public_tags, g_slist_free);

    ide_clear_weak_pointer (&self->buffer);

    IDE_EXIT;
}
예제 #9
0
/* vers=0: right == NOOPS*/
static void doc_shift_selection( Tdocument *doc, gboolean vers ) {
	GtkTextIter itstart, itend;
	if ( gtk_text_buffer_get_selection_bounds( doc->buffer, &itstart, &itend ) ) {
		GtkTextMark * end;

		doc_unbind_signals( doc );
		doc_unre_new_group( doc );
		/* we have a selection, now we loop trough the characters, and for every newline
		we add or remove a tab, we set the end with a mark */
		end = gtk_text_buffer_create_mark( doc->buffer, NULL, &itend, TRUE );
		/* set to: the fist char of the fist line */
		if ( gtk_text_iter_get_line_offset( &itstart ) > 0 ) {
			gtk_text_iter_set_line_index( &itstart, 0 );
		}
		/* remove one line from current selection for each step*/
		while ( gtk_text_iter_compare( &itstart, &itend ) < 0 ) {
			GtkTextMark * cur;
			cur = gtk_text_buffer_create_mark( doc->buffer, NULL, &itstart, TRUE );
			if ( vers ) {
				itend = itstart;
				gtk_text_iter_forward_chars( &itend, 1 );
				gchar *buf = gtk_text_buffer_get_text( doc->buffer, &itstart, &itend, FALSE );
				if ( !strstr( buf, "\n" ) ) {
					gint offsetstart, offsetend;
					offsetstart = gtk_text_iter_get_offset( &itstart );
					offsetend = gtk_text_iter_get_offset( &itend );
					gtk_text_buffer_delete( doc->buffer, &itstart, &itend );
					doc_unre_add( doc, buf, offsetstart, offsetend, UndoDelete );
				}
				g_free( buf );
			}
			gtk_text_buffer_get_iter_at_mark( doc->buffer, &itstart, cur );
			gtk_text_buffer_get_iter_at_mark( doc->buffer, &itend, end );
			gtk_text_buffer_delete_mark( doc->buffer, cur );
			/* forward one more line */
			gtk_text_iter_forward_line( &itstart );
		}
		gtk_text_buffer_delete_mark( doc->buffer, end );
		doc_bind_signals( doc );
		doc_set_modified( doc, 1 );
	} else {
		/* there is no selection, work on the current line */
		GtkTextIter iter;
		gtk_text_buffer_get_iter_at_mark( doc->buffer, &iter, gtk_text_buffer_get_insert( doc->buffer ) );
		if ( vers ) {
			GtkTextIter itend;
			gtk_text_iter_set_line_offset( &iter, 0 );
			itend = iter;
			gtk_text_iter_forward_chars( &itend, 1 );
			gtk_text_buffer_delete( doc->buffer, &iter, &itend );
		}
	}
}
예제 #10
0
void html_diag_destroy_cb(GtkWidget * widget, Thtml_diag *dg) {
	/* kyanh, removed, 20050225,
	dg->tobedestroyed = TRUE; */
	if (dg->mark_ins) {
		gtk_text_buffer_delete_mark(dg->doc->buffer,dg->mark_ins);
	}
	if (dg->mark_sel) {
		gtk_text_buffer_delete_mark(dg->doc->buffer,dg->mark_sel);
	}
	window_destroy(dg->dialog); /* kyanh, from: gtk_easy.h */
	DEBUG_MSG("html_diag_destroy_cb, about to free dg=%p\n",dg);
	g_free(dg);
}
예제 #11
0
void
html_diag_destroy_cb(GtkWidget * widget, Thtml_diag * dg)
{
	dg->tobedestroyed = TRUE;
	DEBUG_MSG("html_diag_destroy_cb, widget=%p, dg=%p, dg->dialog=%p\n", widget, dg, dg->dialog);
	if (gtk_text_buffer_get_mark(dg->doc->buffer, "diag_ins") == dg->mark_ins) {
		gtk_text_buffer_delete_mark(dg->doc->buffer, dg->mark_ins);
		gtk_text_buffer_delete_mark(dg->doc->buffer, dg->mark_sel);
	}
	window_destroy(dg->dialog);
	DEBUG_MSG("html_diag_destroy_cb, about to free dg=%p\n", dg);
	g_free(dg);
}
static void
on_delete_range (GtkTextBuffer *buffer,
	     	 GtkTextIter   *start,
	     	 GtkTextIter   *end,
	     	 gpointer       user_data)
{
	GtkTextIter iter;
	GSList *marks;
	GSList *item;

	iter = *start;

	/* move to start of line */
	gtk_text_iter_set_line_offset (&iter, 0);

	/* remove any bookmarks that are collapsed on each other due to this */
	marks = gtk_source_buffer_get_source_marks_at_iter (GTK_SOURCE_BUFFER (buffer),
							    &iter,
							    BOOKMARK_CATEGORY);

	if (marks == NULL)
		return;

	/* remove all but the first mark */
	for (item = marks->next; item; item = item->next)
		gtk_text_buffer_delete_mark (buffer, GTK_TEXT_MARK (item->data));

	g_slist_free (marks);
}
예제 #13
0
void
ide_source_snippet_after_delete_range (IdeSourceSnippet *self,
                                       GtkTextBuffer    *buffer,
                                       GtkTextIter      *begin,
                                       GtkTextIter      *end)
{
  GtkTextMark *here;

  g_return_if_fail (IDE_IS_SOURCE_SNIPPET (self));
  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
  g_return_if_fail (begin);
  g_return_if_fail (end);

  here = gtk_text_buffer_create_mark (buffer, NULL, begin, TRUE);

  ide_source_snippet_update_context (self);
  ide_source_snippet_update_context (self);
  ide_source_snippet_rewrite_updated_chunks (self);

  gtk_text_buffer_get_iter_at_mark (buffer, begin, here);
  gtk_text_buffer_get_iter_at_mark (buffer, end, here);
  gtk_text_buffer_delete_mark (buffer, here);

#if 0
  ide_source_snippet_context_dump (self->snippet_context);
#endif
}
예제 #14
0
파일: dlg_chat.c 프로젝트: ralight/ggz
static void handle_ggz_chat_event(GGZMod * ggzmod, GGZModEvent e,
				  const void *data)
{
	const GGZChat *chat = data;
	ChatWidgets *list;
	char message[1024];
	GtkTextBuffer *buf;
	GtkTextIter i;
	GtkTextMark *mark;
	snprintf(message, sizeof(message), "\n%s : %s",
		 chat->player, chat->message);

	for (list = chats; list; list = list->next) {
		if (!list->container)
			continue;

		buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(list->text));
		gtk_text_buffer_get_end_iter(buf, &i);
		gtk_text_buffer_insert(buf, &i, message, -1);

		/* have to use a mark, or this won't work properly */
		gtk_text_buffer_get_end_iter(buf, &i);
		mark = gtk_text_buffer_create_mark(buf, NULL, &i, FALSE);
		gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW
						   (list->text), mark);
		gtk_text_buffer_delete_mark(buf, mark);
	}
}
예제 #15
0
void
on_search_okbutton_clicked (GtkWidget *search_button, AD data)
// 搜尋按鈕的功能,可連續搜尋 
{
  const gchar *text = "e";
  GtkTextBuffer *buffer;
  GtkTextIter iter;
  GtkTextMark *last_pos;
  int result = 0 ; 
  gboolean found = FALSE;  
    
  data->searchWord = gtk_entry_get_text (GTK_ENTRY (data->entry)); // 取得輸入欄的字串 
  
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (data->textview)); 
  
  last_pos = gtk_text_buffer_get_mark (buffer, "last_pos"); // 查看有無last_pos的mark 
  if (last_pos == NULL)
    gtk_text_buffer_get_start_iter (buffer, &iter); // 若無,就從頭搜尋 
  else
    gtk_text_buffer_get_iter_at_mark (buffer, &iter, last_pos); // 若有,就從最後一個last_pos的後面開始搜尋 
  
  found = find (GTK_TEXT_VIEW (data->textview), data->searchWord, &iter);
  
  if (!found)
    gtk_text_buffer_delete_mark (buffer, last_pos); // 搜尋到最後可回到起點重新搜尋 
}
예제 #16
0
파일: popup.c 프로젝트: sina-ht/ebview
static gint scroll_to_top()
{
	GtkTextIter iter;
	GtkTextMark *mark;

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

	gtk_text_buffer_get_start_iter (text_buffer, &iter);

	mark =  gtk_text_buffer_create_mark(text_buffer,
					    "start",
					    &iter,
					    TRUE);

	gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(popup_view),
				     mark,
				     0.0,
				     TRUE,
				     0.0, 0.0);

	gtk_text_buffer_delete_mark(text_buffer, mark);


	LOG(LOG_DEBUG, "OUT : scroll_to_top()");
	return(0);
}
예제 #17
0
파일: gtkspell.c 프로젝트: jmissig/gabber
static void
gtkspell_free(GtkSpell *spell) {
	GtkTextBuffer *buffer;
	GtkTextTagTable *table;
	GtkTextIter start, end;

	buffer = gtk_text_view_get_buffer(spell->view);
	table = gtk_text_buffer_get_tag_table(buffer);

	gtk_text_buffer_get_bounds(buffer, &start, &end);
	gtk_text_buffer_remove_tag(buffer, spell->tag_highlight, &start, &end);
	gtk_text_tag_table_remove(table, spell->tag_highlight);

	gtk_text_buffer_delete_mark(buffer, spell->mark_insert);

	delete_aspell_speller(spell->speller);

	g_signal_handlers_disconnect_matched(spell->view,
			G_SIGNAL_MATCH_DATA,
			0, 0, NULL, NULL,
			spell);
	g_signal_handlers_disconnect_matched(buffer,
			G_SIGNAL_MATCH_DATA,
			0, 0, NULL, NULL,
			spell);
	g_free(spell);
}
예제 #18
0
void bmark_clean_for_doc(Tdocument * doc) {
	GtkTreeIter tmpiter;
	gboolean cont;

	if (doc->bmark_parent == NULL)
		return;
	DEBUG_MSG("bmark_clean_for_doc, getting children for parent_iter=%p\n",doc->bmark_parent);
	cont =
		gtk_tree_model_iter_children(GTK_TREE_MODEL(BFWIN(doc->bfwin)->bookmarkstore), &tmpiter,
									 doc->bmark_parent);
	while (cont) {
		Tbmark *b = NULL;
		DEBUG_MSG("bmark_clean_for_doc, getting bookmark for first child\n");
		gtk_tree_model_get(GTK_TREE_MODEL(BFWIN(doc->bfwin)->bookmarkstore), &tmpiter, PTR_COLUMN,
						   &b, -1);
		if (b) {
			bmark_update_offset_from_textmark(b);
			DEBUG_MSG("bmark_clean_for_doc, bookmark=%p, new offset=%d, now deleting GtkTextMark from TextBuffer\n",b,b->offset);
			gtk_text_buffer_delete_mark(doc->buffer, b->mark);
			b->mark = NULL;
			b->doc = NULL;
			if (!b->is_temp) {
				bmark_store(doc->bfwin, b);
			}
		}
		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(BFWIN(doc->bfwin)->bookmarkstore), &tmpiter);
	}							/* cont */
	/* now unset the Tdocument* in the second column */
	DEBUG_MSG("bmark_clean_for_doc, unsetting and freeing parent_iter %p for doc %p\n",doc->bmark_parent,doc);
	gtk_tree_store_set(GTK_TREE_STORE(BFWIN(doc->bfwin)->bookmarkstore), doc->bmark_parent, PTR_COLUMN, NULL, -1);
	/* remove the pointer from the hastable */
	g_hash_table_remove(BFWIN(doc->bfwin)->bmark_files,doc->filename);
	g_free(doc->bmark_parent);
	doc->bmark_parent = NULL;
}
예제 #19
0
void chatbox_insert_msg(chatbox_t *chatbox, char *sender, time_t *tm, char *msg) {
	char buf[65535];
	GtkTextView *output_textview;
	

	GtkTextBuffer *output_buffer;
	GtkTextIter start;
	GtkTextIter end;
	GtkTextMark *mark;

	chatbox = (chatbox_t*)(chatbox);

	output_textview = chatbox->display_textview;

	output_buffer = gtk_text_view_get_buffer(output_textview);

	sprintf(buf, "%s(%s):\n", sender, my_ctime(tm));
	gtk_text_buffer_get_end_iter(output_buffer, &end);
	gtk_text_buffer_insert_with_tags_by_name(output_buffer, &end,
			buf, -1, "blue_fg", "lmarg", "title_font", NULL);

	insert_msg_with_emotion_to_textview(output_textview, msg);
	
	gtk_text_buffer_get_end_iter(output_buffer, &end);
	mark = gtk_text_buffer_create_mark(output_buffer, NULL, &end, FALSE);
	gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(output_textview), mark,
		0.0, TRUE, 0.0, 0.0);
	gtk_text_buffer_delete_mark(output_buffer, mark);
}
예제 #20
0
/* Format->Comment Out Selection */
void
action_comment_out_selection(GtkAction *action, I7Document *document)
{
	GtkTextBuffer *buffer = GTK_TEXT_BUFFER(i7_document_get_buffer(document));
	GtkTextIter start, end;

	if(!gtk_text_buffer_get_selection_bounds(buffer, &start, &end))
		return;
	gchar *text = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);

	/* Treat it as one single undo action */
	gtk_text_buffer_begin_user_action(buffer);
	/* Delete the entire text and reinsert it inside brackets, in order to
	 avoid excessively recalculating the syntax highlighting */
	gtk_text_buffer_delete(buffer, &start, &end);
	gchar *newtext = g_strconcat("[", text, "]", NULL);
	GtkTextMark *tempmark = gtk_text_buffer_create_mark(buffer, NULL, &end, TRUE);
	gtk_text_buffer_insert(buffer, &end, newtext, -1);
	gtk_text_buffer_end_user_action(buffer);

	g_free(text);
	g_free(newtext);

	/* Select the text again, including [] */
	gtk_text_buffer_get_iter_at_mark(buffer, &start, tempmark);
	gtk_text_buffer_select_range(buffer, &start, &end);
	gtk_text_buffer_delete_mark(buffer, tempmark);
}
예제 #21
0
void
gsc_utils_replace_word (GtkTextBuffer *text_buffer,
                        GtkTextIter     *iter,
                        const gchar     *text,
                        gint             len)
{
    GtkTextBuffer *buffer;
    gchar *word;
    GtkTextIter word_start;
    GtkTextIter word_end;
    GtkTextMark *mark;

    g_return_if_fail (GTK_IS_TEXT_BUFFER (text_buffer));

    buffer = GTK_TEXT_BUFFER (text_buffer);
    gtk_text_buffer_begin_user_action (buffer);

    mark = gtk_text_buffer_create_mark (buffer, NULL, iter, TRUE);
    word = gsc_utils_get_word_iter (text_buffer, iter, &word_start, &word_end);
    g_free (word);

    gtk_text_buffer_delete (buffer, &word_start, &word_end);

    if (text != NULL)
    {
        gtk_text_buffer_insert (buffer, &word_start, text, len);
    }

    /* Reinitialize iter */
    gtk_text_buffer_get_iter_at_mark (buffer, iter, mark);
    gtk_text_buffer_delete_mark (buffer, mark);
    gtk_text_buffer_end_user_action (buffer);
}
예제 #22
0
void Gobby::EditCommands::on_redo()
{
	g_assert(m_current_view != NULL);

	gulong i_ = g_signal_connect_after(m_current_view->get_text_buffer(), "insert-text", G_CALLBACK(recaret_i), NULL);
	gulong e_ = g_signal_connect_after(m_current_view->get_text_buffer(), "delete-range", G_CALLBACK(recaret_e), NULL);

	inf_adopted_session_redo(
		INF_ADOPTED_SESSION(m_current_view->get_session()),
		INF_ADOPTED_USER(m_current_view->get_active_user()),
		m_current_view->get_undo_grouping().get_redo_size()
	);

	g_signal_handler_disconnect(m_current_view->get_text_buffer(), i_);
	g_signal_handler_disconnect(m_current_view->get_text_buffer(), e_);

	if(check)
	{
		GtkTextIter check_iter;
		gtk_text_buffer_get_iter_at_mark(GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), &check_iter, check);
		gtk_text_buffer_select_range(GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), &check_iter, &check_iter);
		gtk_text_buffer_delete_mark(GTK_TEXT_BUFFER(m_current_view->get_text_buffer()), check);
		check = NULL;
	}

	m_current_view->scroll_to_cursor_position(0.0);
}
예제 #23
0
파일: main.c 프로젝트: bf4/pidgin-mac
static void
remove_marks_func(gpointer key, gpointer value, gpointer user_data)
{
    icon_data *data = (icon_data *)value;
    GtkTextBuffer *text_buffer = (GtkTextBuffer *)user_data;
    GList *mark_list = NULL;
    GList *current;

    if(!data)
        return;

    if(data->request_list)
        mark_list = data->request_list;

    /* remove the marks in its GtkTextBuffers */
    current = g_list_first(mark_list);
    while(current) {
        GtkTextMark *current_mark = current->data;
        GtkTextBuffer *current_text_buffer =
            gtk_text_mark_get_buffer(current_mark);
        GList *next;

        next = g_list_next(current);

        if(!current_text_buffer)
            continue;

        if(text_buffer) {
            if(current_text_buffer == text_buffer) {
                /* the mark will be freed in this function */
                gtk_text_buffer_delete_mark(current_text_buffer,
                                            current_mark);
                current->data = NULL;
                mark_list = g_list_delete_link(mark_list, current);
            }
        }
        else {
            gtk_text_buffer_delete_mark(current_text_buffer, current_mark);
            current->data = NULL;
            mark_list = g_list_delete_link(mark_list, current);
        }

        current = next;
    }

    data->request_list = mark_list;
}
static void
load_images(MarkdownTextView * self)
{
    GtkTextBuffer *buffer;
    GtkTextIter iter;
    GSList *tags, *tagp;
    gchar *image_path;
    
    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(self));
    gtk_text_buffer_get_start_iter(buffer, &iter);
    
    do {
       tags = gtk_text_iter_get_tags(&iter);
       for (tagp = tags; tagp != NULL; tagp = tagp->next) {
           GtkTextTag *tag = tagp->data;
           gint is_underline = 0;
           gchar *lang = NULL;

           g_object_get(G_OBJECT(tag),
                        "underline", &is_underline,
                        "language", &lang,
                        NULL);

           if (is_underline == 2 && lang) {
               GdkPixbuf *pixbuf;
               gchar *path;
               
               image_path = egg_markdown_get_link_uri(self->markdown, atoi(lang));
               path = g_build_filename(self->image_directory, image_path, NULL);
               pixbuf = gdk_pixbuf_new_from_file(path, NULL);
               if (pixbuf) {
                   GtkTextMark *mark;
                   GtkTextIter start;

                   mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, FALSE);
                   
                   gtk_text_buffer_get_iter_at_mark(buffer, &start, mark);
                   gtk_text_iter_forward_to_tag_toggle(&iter, tag);
                   gtk_text_buffer_delete(buffer, &start, &iter);

                   gtk_text_buffer_insert_pixbuf(buffer, &iter, pixbuf);
  
                   g_object_unref(pixbuf);
                   gtk_text_buffer_delete_mark(buffer, mark);
               }
               
               g_free(image_path);
               g_free(lang);
               g_free(path);
               break;
           }

           g_free(lang);
       }
       
       if (tags)
           g_slist_free(tags);
   } while (gtk_text_iter_forward_to_tag_toggle(&iter, NULL));
}
예제 #25
0
void GTKTextView::AddText(const char *Text)
{
    GtkTextMark *mark = TextBuffer->AddTextToEnd((char *)Text);
    if (AutoScroll == true)
        //gtk_text_view_scroll_mark_onscreen(TextView, mark);
        gtk_text_buffer_delete_mark(TextBuffer->GetBuffer(), mark);
    g_object_unref(G_OBJECT(mark));
}
예제 #26
0
void
_ide_project_edit_apply (IdeProjectEdit *self,
                         IdeBuffer      *buffer)
{
  IdeProjectEditPrivate *priv = ide_project_edit_get_instance_private (self);
  GtkTextIter begin;
  GtkTextIter end;

  g_assert (IDE_IS_PROJECT_EDIT (self));
  g_assert (IDE_IS_BUFFER (buffer));

  gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &begin, priv->begin_mark);
  gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &end, priv->end_mark);
  gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &begin, &end);
  gtk_text_buffer_insert (GTK_TEXT_BUFFER (buffer), &begin, priv->replacement, -1);
  gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (buffer), priv->begin_mark);
  gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (buffer), priv->end_mark);
}
예제 #27
0
static void insert_icon_at_mark(GtkTextMark * requested_mark, gpointer user_data)
{
    GList          *win_list;
    GtkIMHtml      *target_imhtml = NULL;
    GtkTextBuffer  *target_buffer = NULL;
    GtkTextIter     insertion_point;
    TwitterConvIcon *conv_icon = user_data;

    /* find the conversation that contains the mark  */
    for (win_list = pidgin_conv_windows_get_list(); win_list; win_list = win_list->next) {
        PidginWindow   *win = win_list->data;
        GList          *conv_list;

        for (conv_list = pidgin_conv_window_get_gtkconvs(win); conv_list; conv_list = conv_list->next) {
            PidginConversation *conv = conv_list->data;

            GtkIMHtml      *current_imhtml = GTK_IMHTML(conv->imhtml);
            GtkTextBuffer  *current_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(current_imhtml));

            if (current_buffer == gtk_text_mark_get_buffer(requested_mark)) {
                target_imhtml = current_imhtml;
                target_buffer = current_buffer;
                break;
            }
        }
    }

    if (!(target_imhtml && target_buffer)) {
        purple_debug_warning(PLUGIN_ID, "No target imhtml/target buffer\n");
        return;
    }

    /* insert icon to the mark */
    gtk_text_buffer_get_iter_at_mark(target_buffer, &insertion_point, requested_mark);

    /* in this function, we put an icon for pending marks. we should
     * not invalidate the icon here, otherwise it may result in
     * thrashing. --yaz */

    if (!conv_icon || !conv_icon->pixbuf) {
        purple_debug_warning(PLUGIN_ID, "No pixbuf\n");
        return;
    }

/* We only want to add the icon if the mark is still on screen. If the user cleared the screen with a ctrl-L, this won't be true. TODO -- can we get a callback at the clear and just delete the mark there? */
    if (TRUE == gtk_text_iter_is_end(&insertion_point)) {
        purple_debug_warning(PLUGIN_ID, "Not adding the icon, since the insertion point is no longer in the buffer\n");
    } else {
        /* insert icon actually */
        gtk_text_buffer_insert_pixbuf(target_buffer, &insertion_point, conv_icon->pixbuf);
    }

    gtk_text_buffer_delete_mark(target_buffer, requested_mark);
    requested_mark = NULL;
    purple_debug_info(PLUGIN_ID, "inserted icon into conv\n");
}
예제 #28
0
static void
delete_mark (GtkTextBuffer  *buffer,
             GtkTextMark   **mark)
{
  if (mark != NULL && *mark != NULL)
    {
      GtkTextMark *m = g_steal_pointer (mark);
      gtk_text_buffer_delete_mark (buffer, m);
    }
}
예제 #29
0
파일: console.c 프로젝트: aylusltd/gretl
static void console_scroll_to_end (GtkWidget *cview,
				   GtkTextBuffer *buf, 
				   GtkTextIter *end)
{
    GtkTextMark *mark;

    mark = gtk_text_buffer_create_mark(buf, NULL, end, FALSE);
    gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(cview), mark);
    gtk_text_buffer_delete_mark(buf, mark);
}
예제 #30
0
static void
hide_search_widget (GeditViewFrame *frame,
                    gboolean        cancel)
{
	GtkTextBuffer *buffer;

	if (frame->priv->disable_popdown)
	{
		return;
	}

	g_signal_handler_block (frame->priv->search_entry,
	                        frame->priv->search_entry_focus_out_id);

	if (frame->priv->view_scroll_event_id != 0)
	{
		g_signal_handler_disconnect (frame->priv->view,
		                             frame->priv->view_scroll_event_id);
		frame->priv->view_scroll_event_id = 0;
	}

	if (frame->priv->typeselect_flush_timeout != 0)
	{
		g_source_remove (frame->priv->typeselect_flush_timeout);
		frame->priv->typeselect_flush_timeout = 0;
	}

	/* To hide the slider we just set the animation-state property */
	g_object_set (G_OBJECT (frame->priv->slider),
	              "animation-state", GEDIT_THEATRICS_ANIMATION_STATE_INTENDING_TO_GO,
	              NULL);

	if (cancel)
	{
		GtkTextBuffer *buffer;
		GtkTextIter iter;

		buffer = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->priv->view)));
		gtk_text_buffer_get_iter_at_mark (buffer, &iter,
		                                  frame->priv->start_mark);
		gtk_text_buffer_place_cursor (buffer, &iter);

		gedit_view_scroll_to_cursor (GEDIT_VIEW (frame->priv->view));
	}

	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (frame->priv->view));
	gtk_text_buffer_delete_mark (buffer, frame->priv->start_mark);

	/* Make sure the view is the one who has the focus when we destroy
	   the search widget */
	gtk_widget_grab_focus (frame->priv->view);

	g_signal_handler_unblock (frame->priv->search_entry,
	                          frame->priv->search_entry_focus_out_id);
}