Exemplo n.º 1
0
/**
 * \fn void external_link_catch(GtkWidget *w, GObject *link)
 * \brief This function catch the signal when a clic is made on a note.
 * \param w The widget which triggered the call.
 * \param link ev_link_action.
 * \param editor The GUI structure.
 */
void external_link_catch(GtkWidget *widget, GObject *link, BrailleMusicEditor *editor) {
    EvLinkAction *l = EV_LINK_ACTION(link);
    ev_view_copy_link_address(EV_VIEW(widget), l);
    //get line:column link
    const gchar * lc = ev_link_action_get_uri(l);
    int line, column;
    int i = 0;
    char c = ' ', temp[2048];
    while(c != ':' || i >= strlen(lc)) {
        c = lc[i];
        temp[i] = c;
        i++;
    }
    temp[i+1]='\0';
    line = atoi(temp);
    line--;
    column = atoi(lc+i);
    GtkTextIter it;
    GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor->textview));
    if(gtk_text_buffer_get_line_count(buffer) < line ) {
        line = 0;
        column = 0;
    }

    gtk_text_buffer_get_iter_at_line(buffer, &it, line);
    while(column >0 && !gtk_text_iter_ends_line(&it)) {
        gtk_text_iter_forward_char(&it);
        column--;
    }
    gtk_widget_grab_focus(editor->textview);
    gtk_text_buffer_place_cursor(buffer, &it);
    gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(editor->textview), &it, 0.0, FALSE, 0.5, 0.5);
}
Exemplo n.º 2
0
//signal handler for link
static gint
action_for_link (EvView * view, EvLinkAction * obj, EvDocumentModel *model)
{
    EvDocument *doc = ev_document_model_get_document (model);
 gchar *uri = (gchar *) ev_link_action_get_uri (obj);
 if(Denemo.printstatus->updating_id &&  (Denemo.printstatus->typeset_type != TYPESET_ALL_MOVEMENTS))
   {
    warningdialog (_("Cannot do location when only a range of music is typeset. Turn off continuous typesetting or set the range to All Movements"));
    return TRUE;
    }

  if (uri)
    {
      gchar **orig_vec = g_strsplit (uri, ":", 6);
      gchar **vec = orig_vec;
      if (vec[0] && vec[1] && vec[2] && vec[3] && vec[4] && vec[5] && *vec[5])
        vec++;//this will be the case where the file name has a colon in it, (windows drive name) we do not allow for more than one colon. vec[0] is used hereafter.
      if (g_str_has_prefix (uri, "textedit:") && vec[1] && vec[2] && vec[3])
        {
          DenemoTarget old_target = Denemo.project->movement->target;
          gboolean ObjectLocated = goto_lilypond_position (atoi (vec[2]), atoi (vec[3]));     //sets si->target
          if (ObjectLocated && nearest_annotation_text)
            { DenemoScriptParam param;
                param.string = g_string_new (nearest_annotation_text);
                paste_comment (NULL, &param);
                g_string_free (param.string, TRUE);
            }
           else {
                warningdialog (_("Object not located, no annotation on page, or empty annotation.\n"));
            }
        }
    }
    return TRUE;
}