コード例 #1
0
ファイル: spellcheck-callbacks.c プロジェクト: kyoushuu/gwaei
G_MODULE_EXPORT gboolean 
gw_spellcheck_draw_underline_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
{
    //Declarations
    GwSpellcheck *spellcheck;
    GwSpellcheckPrivate *priv;
    gint x, y, x2, y2;
    GList *link;
    gchar **iter;
    gint start_offset, end_offset;
    gint start_layout_offset, end_layout_offset;

    //Initializations
    spellcheck = GW_SPELLCHECK (data);
    priv = spellcheck->priv;
    iter = priv->tolkens;
    start_offset = end_offset = 0;

    for (link = priv->misspelled; link != NULL && *iter != NULL; link = link->next)
    {
      //Get the letter offsets
      while (*iter != NULL && *iter != (gchar*) link->data)
      {
        start_offset += strlen(*iter) + 1;
        iter++;
      }
      if (*iter != NULL) end_offset = start_offset + strlen(*iter);
      else end_offset = start_offset;

      //Convert it to the layout offset
      start_layout_offset = gtk_entry_text_index_to_layout_index (GTK_ENTRY (widget), start_offset);
      end_layout_offset = gtk_entry_text_index_to_layout_index (GTK_ENTRY (widget), end_offset);

      //Calculate the line
      if (gw_spellcheck_get_line_coordinates (spellcheck, start_layout_offset, end_layout_offset, &x, &y, &x2, &y2))
      {
        gw_spellcheck_draw_line (cr, x, y, x2, y2);
      }
    }

    return FALSE;
}
コード例 #2
0
ファイル: rbgtk-entry.c プロジェクト: adamhooper/ruby-gnome2
static VALUE
rg_text_index_to_layout_index(VALUE self, VALUE text_index)
{
    return INT2NUM(gtk_entry_text_index_to_layout_index(_SELF(self), NUM2INT(text_index)));
}