gboolean
gb_source_view_snippet_move_previous (GbSourceViewSnippet *snippet)
{
   GbSourceViewSnippetPrivate *priv;
   GbSourceViewSnippetChunk *chunk;
   GtkTextBuffer *buffer;
   GtkTextIter iter;

   g_return_val_if_fail(GB_IS_SOURCE_VIEW_SNIPPET(snippet), FALSE);

   priv = snippet->priv;

   if (--priv->tab_stop < 0) {
      buffer = gtk_text_mark_get_buffer(priv->mark_begin);
      gtk_text_buffer_get_iter_at_mark(buffer, &iter, priv->mark_begin);
      gtk_text_buffer_select_range(buffer, &iter, &iter);
      return FALSE;
   }

   if (!(chunk = gb_source_view_snippet_get_chunk_at_tab_stop(snippet, priv->tab_stop))) {
      return FALSE;
   }

   gb_source_view_snippet_chunk_select(chunk);

   return TRUE;
}
Exemple #2
0
CAMLprim value ml_gtk_text_mark_get_buffer (value tm)
{
  CAMLparam1(tm);
  CAMLlocal1(res);
  GtkTextBuffer* tmp;
  tmp = gtk_text_mark_get_buffer(GtkTextMark_val(tm));
  res = Val_option(tmp,Val_GtkTextBuffer);
  CAMLreturn(res);
}
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");
}
static gint
sort_marks_by_priority (gconstpointer m1,
			gconstpointer m2,
			gpointer data)
{
	GtkSourceMark *mark1 = GTK_SOURCE_MARK (m1);
	GtkSourceMark *mark2 = GTK_SOURCE_MARK (m2);
	GtkSourceView *view = GTK_SOURCE_VIEW (data);
	GtkTextIter iter1, iter2;
	gint line1;
	gint line2;

	gtk_text_buffer_get_iter_at_mark (gtk_text_mark_get_buffer (GTK_TEXT_MARK (mark1)),
	                                  &iter1,
	                                  GTK_TEXT_MARK (mark1));

	gtk_text_buffer_get_iter_at_mark (gtk_text_mark_get_buffer (GTK_TEXT_MARK (mark2)),
	                                  &iter2,
	                                  GTK_TEXT_MARK (mark2));

	line1 = gtk_text_iter_get_line (&iter1);
	line2 = gtk_text_iter_get_line (&iter2);

	if (line1 == line2)
	{
		gint priority1 = -1;
		gint priority2 = -1;

		gtk_source_view_get_mark_attributes (view,
		                                     gtk_source_mark_get_category (mark1),
		                                     &priority1);

		gtk_source_view_get_mark_attributes (view,
		                                     gtk_source_mark_get_category (mark2),
		                                     &priority2);

		return priority1 - priority2;
	}
	else
	{
		return line2 - line1;
	}
}
Exemple #5
0
/*#
    @method get_buffer GtkTextMark
    @brief Gets the buffer this mark is located inside, or nil if the mark is deleted.
    @return the mark's GtkTextBuffer.
 */
FALCON_FUNC TextMark::get_buffer( VMARG )
{
    NO_ARGS
    MYSELF;
    GET_OBJ( self );
    GtkTextBuffer* buf = gtk_text_mark_get_buffer( (GtkTextMark*)_obj );
    if ( buf )
        vm->retval( new Gtk::TextBuffer( vm->findWKI( "GtkTextBuffer" )->asClass(), buf ) );
    else
        vm->retnil();
}
/**
 * gtk_source_mark_prev:
 * @mark: a #GtkSourceMark
 * @category: a string specifying the mark category or %NULL
 *
 * Returns the previous #GtkSourceMark in the buffer or %NULL if the mark
 * was not added to a buffer. If there is no previous mark, %NULL is returned.
 * 
 * If @category is %NULL, looks for marks of any category
 *
 * Returns: the previous #GtkSourceMark or %NULL
 *
 * Since: 2.2
 */
GtkSourceMark *
gtk_source_mark_prev (GtkSourceMark *mark,
		      const gchar   *category)
{
	GtkTextBuffer *buffer;

	g_return_val_if_fail (GTK_IS_SOURCE_MARK (mark), NULL);

	buffer = gtk_text_mark_get_buffer (GTK_TEXT_MARK (mark));
	if (buffer != NULL)
		return _gtk_source_buffer_source_mark_prev (GTK_SOURCE_BUFFER (buffer),
							    mark, category);
	else
		return NULL;
}
Exemple #7
0
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 remove_marks_func(TwitterConvIcon * conv_icon, GtkTextBuffer * text_buffer)
{
    GList          *mark_list = NULL;
    GList          *current;

    if (!conv_icon)
        return;

    if (conv_icon->request_list)
        mark_list = conv_icon->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;
    }

    conv_icon->request_list = mark_list;
}
void
gb_source_view_snippet_remove (GbSourceViewSnippet *snippet)
{
   GbSourceViewSnippetPrivate *priv;
   GbSourceViewSnippetChunk *chunk;
   GtkTextBuffer *buffer;
   GtkTextIter begin;
   GtkTextIter end;
   guint i;

   g_return_if_fail(GB_IS_SOURCE_VIEW_SNIPPET(snippet));

   priv = snippet->priv;

   if (!priv->mark_begin || !priv->mark_end) {
      g_warning("Cannot remove snippet as it has not been inserted.");
      return;
   }

   buffer = gtk_text_mark_get_buffer(priv->mark_begin);

   /*
    * TODO: Remove all our GtkTextTag in the range.
    */

   for (i = 0; i < priv->chunks->len; i++) {
      chunk = g_ptr_array_index(priv->chunks, i);
      gb_source_view_snippet_chunk_remove(chunk);
   }

   gtk_text_buffer_get_iter_at_mark(buffer, &begin, priv->mark_begin);
   gtk_text_buffer_get_iter_at_mark(buffer, &end, priv->mark_end);
   gtk_text_buffer_delete(buffer, &begin, &end);
   gtk_text_buffer_delete_mark(buffer, priv->mark_begin);
   gtk_text_buffer_delete_mark(buffer, priv->mark_end);
   g_clear_object(&priv->mark_begin);
   g_clear_object(&priv->mark_end);

   g_object_notify_by_pspec(G_OBJECT(snippet), gParamSpecs[PROP_MARK_BEGIN]);
   g_object_notify_by_pspec(G_OBJECT(snippet), gParamSpecs[PROP_MARK_END]);
}
Exemple #10
0
static VALUE
rg_buffer(VALUE self)
{
    return GOBJ2RVAL(gtk_text_mark_get_buffer(_SELF(self)));
}