Пример #1
0
void
nemo_action_activate (NemoAction *action, GList *selection, NemoFile *parent)
{
    GList *l;
    GString *exec = g_string_new (action->exec);

    gchar *ptr;
    TokenType token_type;

    ptr = find_token_type (exec->str, &token_type);

    while (ptr != NULL) {
        gint shift = ptr - exec->str;

        gchar *insertion = get_insertion_string (token_type, selection, parent);
        exec = g_string_erase (exec, shift, 2);
        exec = g_string_insert (exec, shift, insertion);

        token_type = TOKEN_NONE;
        g_free  (insertion);
        ptr = find_token_type (exec->str, &token_type);
    }

    if (action->use_parent_dir) {
        exec = g_string_prepend (exec, G_DIR_SEPARATOR_S);
        exec = g_string_prepend (exec, action->parent_dir);
    }

    DEBUG ("Spawning: %s\n", exec->str);
    g_spawn_command_line_async (exec->str, NULL);

    nemo_file_list_free (selection);
    g_string_free (exec, TRUE);
}
Пример #2
0
static GString *
expand_action_string (NemoAction *action, GList *selection, NemoFile *parent, GString *str)
{
    gchar *ptr;
    TokenType token_type;

    ptr = find_token_type (str->str, &token_type);

    while (ptr != NULL) {
        gint shift = ptr - str->str;

        gchar *insertion = get_insertion_string (action, token_type, selection, parent);
        str = g_string_erase (str, shift, 2);
        str = g_string_insert (str, shift, insertion);

        token_type = TOKEN_NONE;
        g_free  (insertion);
        ptr = find_token_type (str->str, &token_type);
    }

    return str;
}