コード例 #1
0
ファイル: axis_ui.c プロジェクト: mariusal/grace
int set_axis_data(AxisUI *ui, Quark *q, void *caller)
{
    if (ui && q && quark_fid_get(q) == QFlavorAxis) {
        if (!caller || caller == ui->position) {
            axis_set_position(q, GetOptionChoice(ui->position));
        }
        if (!caller || caller == ui->offset) {
            axis_set_offset(q, SpinChoiceGetValue(ui->offset));
        }

        if (!caller || caller == ui->draw_bar) {
            axis_enable_bar(q, ToggleButtonGetState(ui->draw_bar));
        }
        if (!caller || caller == ui->draw_ticks) {
            axis_enable_ticks(q, ToggleButtonGetState(ui->draw_ticks));
        }
        if (!caller || caller == ui->draw_labels) {
            axis_enable_labels(q, ToggleButtonGetState(ui->draw_labels));
        }

        return RETURN_SUCCESS;
    } else {
        return RETURN_FAILURE;
    }
}
コード例 #2
0
ファイル: explorer.c プロジェクト: mariusal/grace
static void init_item(ExplorerUI *eui, TreeItem *item, Quark *q)
{
    int active;
    char *s;

    s = q_labeling(q);
    TreeSetItemText(eui->tree, item, s);
    xfree(s);

    active = quark_is_active(q);

    if (active && quark_count_children(q) > 0) {
        TreeSetItemOpen(eui->tree, item, TRUE);
    } else {
        if (quark_fid_get(q) != QFlavorProject) {
            TreeSetItemOpen(eui->tree, item, FALSE);
        }
    }

    if (active) {
        TreeSetItemPixmap(eui->tree, item, eui->a_icon);
    } else {
        TreeSetItemPixmap(eui->tree, item, eui->h_icon);
    }
}
コード例 #3
0
ファイル: utils.c プロジェクト: armando-2011/grace
static int set_count_hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    int *nsets = (int *) udata;
    
    if (quark_fid_get(q) == QFlavorSet) {
        (*nsets)++;
    }
    
    return TRUE;
}
コード例 #4
0
ファイル: graph_utils.c プロジェクト: armando-2011/grace
static int graph_count_hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    int *ngraphs = (int *) udata;
    
    if (quark_fid_get(q) == QFlavorGraph) {
        (*ngraphs)++;
    }
    
    return TRUE;
}
コード例 #5
0
ファイル: graph_utils.c プロジェクト: armando-2011/grace
static int frame_count_hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    int *nframes = (int *) udata;
    
    if (quark_fid_get(q) == QFlavorFrame) {
        (*nframes)++;
    }
    
    return TRUE;
}
コード例 #6
0
ファイル: grace.c プロジェクト: armando-2011/grace
static GVarType get_proc(const void *obj,
    const char *name, GVarData *prop, void *udata)
{
    Quark *q = (Quark *) obj;
    Grace *grace = grace_from_quark(q);
    DataColumn col;
    int column;
    
    if (!q) {
        return GVarNil;
    }
    
    if (strings_are_equal(name, "idstr")) {
        prop->str = copy_string(NULL, QIDSTR(q));
        return GVarStr;
    } else
    if (strings_are_equal(name, "active")) {
        prop->boolval = quark_is_active(q);
        return GVarBool;
    }
    
    switch (quark_fid_get(q)) {
    case QFlavorSSD:
        if (strings_are_equal(name, "nrows")) {
            prop->num = ssd_get_nrows(q);
            return GVarNum;
        } else
        if (strings_are_equal(name, "ncols")) {
            prop->num = ssd_get_ncols(q);
            return GVarNum;
        } else
        if ((column = ssd_get_column_by_name(q, name)) >= 0) {
            prop->arr = ssd_get_darray(q, column);
            return GVarArr;
        } else {
            return GVarNil;
        }
        break;
    case QFlavorSet:
        if (strings_are_equal(name, "length")) {
            prop->num = set_get_length(q);
            return GVarNum;
        } else
        if ((col = get_dataset_col_by_name(grace, name)) != DATA_BAD) {
            prop->arr = set_get_darray(q, col);
            return GVarArr;
        } else {
            return GVarNil;
        }
        break;
    default:
        return GVarNil;
        break;
    }
}
コード例 #7
0
ファイル: axis_ui.c プロジェクト: mariusal/grace
void update_axis_ui(AxisUI *ui, Quark *q)
{
    if (ui && q && quark_fid_get(q) == QFlavorAxis) {
        SetOptionChoice(ui->position, axis_get_position(q));
        SpinChoiceSetValue(ui->offset, axis_get_offset(q));
        
        ToggleButtonSetState(ui->draw_bar,    axis_bar_enabled(q));
        ToggleButtonSetState(ui->draw_ticks,  axis_ticks_enabled(q));
        ToggleButtonSetState(ui->draw_labels, axis_labels_enabled(q));
    }
}
コード例 #8
0
ファイル: utils.c プロジェクト: armando-2011/grace
static int set_hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    set_hook_t *p = (set_hook_t *) udata;
    
    if (quark_fid_get(q) == QFlavorSet) {
        p->sets[p->nsets] = q;
        p->nsets++;
    }
    
    return TRUE;
}
コード例 #9
0
ファイル: files.c プロジェクト: astrotycoon/grace
static int project_hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    switch (quark_fid_get(q)) {
    case QFlavorProject:
        quark_cb_add(q, project_cb, NULL);
        break;
    case QFlavorSSD:
        quark_cb_add(q, kill_ssd_cb, NULL);
        break;
    }
    
    return TRUE;
}
コード例 #10
0
ファイル: graph_utils.c プロジェクト: armando-2011/grace
static int hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    frame *f;
    view v;
    DObject *o;
    AText *at;
    ext_xy_t *ext_xy = (ext_xy_t *) udata;
    
    switch (quark_fid_get(q)) {
    case QFlavorFrame:
        f = frame_get_data(q);
        frame_get_view(q, &v);
        v.xv1 *= ext_xy->x;
        v.xv2 *= ext_xy->x;
        v.yv1 *= ext_xy->y;
        v.yv2 *= ext_xy->y;
        frame_set_view(q, &v);
        
        f->l.offset.x *= ext_xy->x;
        f->l.offset.y *= ext_xy->y;
        
        /* TODO: tickmark offsets */
        quark_dirtystate_set(q, TRUE);
        break;
    case QFlavorDObject:
        o = object_get_data(q);
        if (object_get_loctype(q) == COORD_VIEW) {
            o->ap.x     *= ext_xy->x;
            o->ap.y     *= ext_xy->y;
            o->offset.x *= ext_xy->x;
            o->offset.y *= ext_xy->y;
            
            quark_dirtystate_set(q, TRUE);
        }
        break;
    case QFlavorAText:
        at = atext_get_data(q);
        if (object_get_loctype(q) == COORD_VIEW) {
            at->ap.x     *= ext_xy->x;
            at->ap.y     *= ext_xy->y;
            at->offset.x *= ext_xy->x;
            at->offset.y *= ext_xy->y;
            
            quark_dirtystate_set(q, TRUE);
        }
        break;
    }
    
    return TRUE;
}
コード例 #11
0
ファイル: graph_utils.c プロジェクト: armando-2011/grace
static int autotick_hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    int *amask = (int *) udata;
    
    switch (quark_fid_get(q)) {
    case QFlavorAGrid:
        closure->descend = FALSE;
        if (((*amask & AXIS_MASK_X) && axisgrid_is_x(q)) ||
            ((*amask & AXIS_MASK_Y) && axisgrid_is_y(q))) {
            axisgrid_autotick(q);
        }
        break;
    }
    
    return TRUE;
}
コード例 #12
0
ファイル: graph_ui.c プロジェクト: astrotycoon/grace
void update_graph_ui(GraphUI *ui, Quark *q)
{
    if (q && quark_fid_get(q) == QFlavorGraph) {
        char buf[32];
        world w;
        GLocator *locator;
        
        graph_get_world(q, &w);
        locator = graph_get_locator(q);

        SetOptionChoice(ui->graph_type, graph_get_type(q));
        SetToggleButtonState(ui->stacked, graph_is_stacked(q));
        SetToggleButtonState(ui->flip_xy, graph_get_xyflip(q));

        sprintf(buf, "%.9g", w.xg1);
        xv_setstr(ui->start_x, buf);
        sprintf(buf, "%.9g", w.xg2);
        xv_setstr(ui->stop_x, buf);
        SetOptionChoice(ui->scale_x, graph_get_xscale(q));
        SetToggleButtonState(ui->invert_x, graph_is_xinvert(q));

        sprintf(buf, "%.9g", w.yg1);
        xv_setstr(ui->start_y, buf);
        sprintf(buf, "%.9g", w.yg2);
        xv_setstr(ui->stop_y, buf);
        SetOptionChoice(ui->scale_y, graph_get_yscale(q));
        SetToggleButtonState(ui->invert_y, graph_is_yinvert(q));

        sprintf(buf, "%g", graph_get_znorm(q));
        xv_setstr(ui->znorm, buf);

        SetSpinChoice(ui->bargap, graph_get_bargap(q));


	SetToggleButtonState(ui->fixedp, locator->pointset);
	SetOptionChoice(ui->loc_type, locator->type);
        SetFormatChoice(ui->loc_fx, &locator->fx);
        SetFormatChoice(ui->loc_fy, &locator->fy);
	sprintf(buf, "%g", locator->origin.x);
	xv_setstr(ui->locx, buf);
	sprintf(buf, "%g", locator->origin.y);
	xv_setstr(ui->locy, buf);
    }
}
コード例 #13
0
ファイル: grace.c プロジェクト: armando-2011/grace
static int set_proc(void *obj,
    const char *name, GVarType type, GVarData prop, void *udata)
{
    Quark *q = (Quark *) obj;
    Grace *grace = grace_from_quark(q);
    DataColumn col;
    int column;
    
    if (!q) {
        return RETURN_FAILURE;
    }

    if (strings_are_equal(name, "idstr") && type == GVarStr) {
        return quark_idstr_set(q, prop.str);
    } else
    if (strings_are_equal(name, "active") && type == GVarBool) {
        return quark_set_active(q, prop.boolval);
    }

    switch (quark_fid_get(q)) {
    case QFlavorSSD:
        if ((column = ssd_get_column_by_name(q, name)) >= 0) {
            return ssd_set_darray(q, column, prop.arr);
        } else {
            return RETURN_FAILURE;
        }
        break;
    case QFlavorSet:
        if ((col = get_dataset_col_by_name(grace, name)) != DATA_BAD) {
            if (set_set_length(q, prop.arr->size) != RETURN_SUCCESS) {
                return RETURN_FAILURE;
            } else {
                return set_set_darray(q, col, prop.arr);
            }
        } else {
            return RETURN_FAILURE;
        }
        break;
    default:
        return RETURN_FAILURE;
        break;
    }
}
コード例 #14
0
ファイル: utils.c プロジェクト: armando-2011/grace
static int coalesce_hook(Quark *q, void *udata, QTraverseClosure *closure)
{
    coalesce_hook_t *p = (coalesce_hook_t *) udata;
    
    if (quark_fid_get(q) == QFlavorSet) {
        Dataset *dsp = set_get_dataset(q);
        unsigned int k;
        for (k = 0; k < MAX_SET_COLS; k++) {
            if (dsp->cols[k] != COL_NONE) {
                dsp->cols[k] += p->nshift;
            }
        }
        if (dsp->acol != COL_NONE) {
            dsp->acol += p->nshift;
        }
    }
    if (closure->depth == 1) {
        quark_reparent(q, p->toq);
    }
    
    return TRUE;
}
コード例 #15
0
ファイル: explorer.c プロジェクト: mariusal/grace
static int highlight_cb(TreeEvent *event)
{
    ExplorerUI *ui = (ExplorerUI *) event->anydata;
    TreeItemList items;
    int count;
    Quark *q = NULL;
    int fid = -1;
    int parent_fid = -1;
    int homogeneous_selection = TRUE;

    TreeGetHighlighted(event->w, &items);
    count = items.count;
    
    ui->homogeneous_parent = TRUE;

    if (count > 0) {
        int i;

        q = TreeGetQuark(items.items[0]);
        fid = quark_fid_get(q);
        parent_fid = quark_fid_get(quark_parent_get(q));

        for (i = 1; i < count; i++) {
            Quark *iq = TreeGetQuark(items.items[i]);
            
            if ((int) quark_fid_get(iq) != fid) {
                homogeneous_selection = FALSE;
            }
            if ((int) quark_fid_get(quark_parent_get(iq)) != parent_fid) {
                ui->homogeneous_parent = FALSE;
            }
        }
    }
    xfree(items.items);

    if (!count || !homogeneous_selection) {
        WidgetSetSensitive(ui->aacbuts[0], FALSE);
        WidgetSetSensitive(ui->aacbuts[1], FALSE);
        
        manage_plugin(ui, NULL);
    } else {
        Widget managed_top;

        WidgetSetSensitive(ui->aacbuts[0], TRUE);
        WidgetSetSensitive(ui->aacbuts[1], TRUE);
        
        switch (fid) {
        case QFlavorProject:
            update_project_ui(ui->project_ui, q);
            managed_top = ui->project_ui->top;
            break;
        case QFlavorSSD:
            update_ssd_ui(ui->ssd_ui, q);
            managed_top = ui->ssd_ui->top;
            break;
        case QFlavorFrame:
            update_frame_ui(ui->frame_ui, q);
            managed_top = ui->frame_ui->top;
            break;
        case QFlavorGraph:
            update_graph_ui(ui->graph_ui, q);
            managed_top = ui->graph_ui->top;
            break;
        case QFlavorSet:
            update_set_ui(ui->set_ui, q);
            managed_top = ui->set_ui->top;
            break;
        case QFlavorAGrid:
            update_axisgrid_ui(ui->axisgrid_ui, q);
            managed_top = ui->axisgrid_ui->top;
            break;
        case QFlavorAxis:
            update_axis_ui(ui->axis_ui, q);
            managed_top = ui->axis_ui->top;
            break;
        case QFlavorDObject:
            update_object_ui(ui->object_ui, q);
            managed_top = ui->object_ui->top;
            break;
        case QFlavorAText:
            update_atext_ui(ui->atext_ui, q);
            managed_top = ui->atext_ui->top;
            break;
        case QFlavorRegion:
            update_region_ui(ui->region_ui, q);
            managed_top = ui->region_ui->top;
            break;
        default:
            managed_top = NULL;
            break;
        }

        manage_plugin(ui, managed_top);
    }

    WidgetSetSensitive(ui->insert_frame_bt,    FALSE);
    WidgetSetSensitive(ui->insert_graph_bt,    FALSE);
    WidgetSetSensitive(ui->insert_set_bt,      FALSE);
    WidgetSetSensitive(ui->insert_ssd_bt,      FALSE);
    WidgetSetSensitive(ui->insert_axisgrid_bt, FALSE);
    WidgetSetSensitive(ui->insert_axis_bt,     FALSE);
    WidgetSetSensitive(ui->insert_object_pane, FALSE);
    if (count == 1) {
        WidgetSetSensitive(ui->idstr->form, TRUE);
        TextSetString(ui->idstr, QIDSTR(q));
        switch (fid) {
        case QFlavorProject:
            WidgetSetSensitive(ui->insert_frame_bt,    TRUE);
            WidgetSetSensitive(ui->insert_object_pane, TRUE);
            break;
        case QFlavorFrame:
            WidgetSetSensitive(ui->insert_graph_bt,    TRUE);
            WidgetSetSensitive(ui->insert_object_pane, TRUE);
            break;
        case QFlavorGraph:
            WidgetSetSensitive(ui->insert_ssd_bt,      TRUE);
            WidgetSetSensitive(ui->insert_axisgrid_bt, TRUE);
            WidgetSetSensitive(ui->insert_object_pane, TRUE);
            break;
        case QFlavorAGrid:
            WidgetSetSensitive(ui->insert_axis_bt,     TRUE);
            break;
        case QFlavorAxis:
            WidgetSetSensitive(ui->insert_object_pane, TRUE);
            break;
        }
        
        if (get_parent_ssd(q) &&
            (fid == QFlavorGraph || fid == QFlavorSSD)) {
            WidgetSetSensitive(ui->insert_set_bt,      TRUE);
        }
    } else {
        WidgetSetSensitive(ui->idstr->form, FALSE);
        TextSetString(ui->idstr, NULL);
    }

    return TRUE;
}
コード例 #16
0
ファイル: graph_ui.c プロジェクト: astrotycoon/grace
int graph_set_data(GraphUI *ui, Quark *q, void *caller)
{
    if (quark_fid_get(q) == QFlavorGraph) {
        double axislim, znorm;
        world w;
        GLocator *locator;

        graph_get_world(q, &w);
        locator = graph_get_locator(q);

        if (!caller || caller == ui->graph_type) {
            graph_set_type(q, GetOptionChoice(ui->graph_type));
        }
        if (!caller || caller == ui->stacked) {
            graph_set_stacked(q, GetToggleButtonState(ui->stacked));
        }
        if (!caller || caller == ui->flip_xy) {
            graph_set_xyflip(q, GetToggleButtonState(ui->flip_xy));
        }

        if (!caller || caller == ui->start_x) {
            if (xv_evalexpr(ui->start_x, &axislim) != RETURN_SUCCESS) {
                errmsg("Axis start/stop values undefined");
                return RETURN_FAILURE;
            }
            w.xg1 = axislim;
        }
        if (!caller || caller == ui->stop_x) {
            if (xv_evalexpr(ui->stop_x, &axislim) != RETURN_SUCCESS) {
                errmsg("Axis start/stop values undefined");
                return RETURN_FAILURE;
            }
            w.xg2 = axislim;
        }

        if (!caller || caller == ui->start_y) {
            if (xv_evalexpr(ui->start_y, &axislim) != RETURN_SUCCESS) {
                errmsg("Axis start/stop values undefined");
                return RETURN_FAILURE;
            }
            w.yg1 = axislim;
        }
        if (!caller || caller == ui->stop_y) {
            if (xv_evalexpr(ui->stop_y, &axislim) != RETURN_SUCCESS) {
                errmsg("Axis start/stop values undefined");
                return RETURN_FAILURE;
            }
            w.yg2 = axislim;
        }

        if (!caller ||
            caller == ui->start_x || caller == ui->stop_x ||
            caller == ui->start_y || caller == ui->stop_y) {
            graph_set_world(q, &w);
        }

        if (!caller || caller == ui->scale_x) {
            graph_set_xscale(q, GetOptionChoice(ui->scale_x));
        }
        if (!caller || caller == ui->invert_x)  {
            graph_set_xinvert(q, GetToggleButtonState(ui->invert_x));
        }

        if (!caller || caller == ui->scale_y) {
            graph_set_yscale(q, GetOptionChoice(ui->scale_y));
        }
        if (!caller || caller == ui->invert_y)  {
            graph_set_yinvert(q, GetToggleButtonState(ui->invert_y));
        }

        if (!caller || caller == ui->bargap) {
            graph_set_bargap(q, GetSpinChoice(ui->bargap));
        }
        if (!caller || caller == ui->znorm) {
            xv_evalexpr(ui->znorm, &znorm);
            graph_set_znorm(q, znorm);
        }


        if (!caller || caller == ui->loc_type) {
            locator->type = GetOptionChoice(ui->loc_type);
            quark_dirtystate_set(q, TRUE);
        }
        if (!caller || caller == ui->loc_fx) {
            Format *format = GetFormatChoice(ui->loc_fx);
            AMem *amem = quark_get_amem(q);
            amem_free(amem, locator->fx.fstring);
            locator->fx = *format;
            locator->fx.fstring = amem_strdup(amem, format->fstring);
            format_free(format);
            quark_dirtystate_set(q, TRUE);
        }
        if (!caller || caller == ui->loc_fy) {
            Format *format = GetFormatChoice(ui->loc_fy);
            AMem *amem = quark_get_amem(q);
            amem_free(amem, locator->fy.fstring);
            locator->fy = *format;
            locator->fy.fstring = amem_strdup(amem, format->fstring);
            format_free(format);
            quark_dirtystate_set(q, TRUE);
        }
        if (!caller || caller == ui->fixedp) {
            locator->pointset = GetToggleButtonState(ui->fixedp);
            quark_dirtystate_set(q, TRUE);
        }
        if (!caller || caller == ui->locx) {
            xv_evalexpr(ui->locx, &locator->origin.x); 
            quark_dirtystate_set(q, TRUE);
        }
        if (!caller || caller == ui->locy) {
            xv_evalexpr(ui->locy, &locator->origin.y); 
            quark_dirtystate_set(q, TRUE);
        }

        return RETURN_SUCCESS;
    } else {
        return RETURN_FAILURE;
    }
}
コード例 #17
0
ファイル: explorer.c プロジェクト: mariusal/grace
static int menu_cb(TreeEvent *event)
{
    ExplorerUI *ui = (ExplorerUI *) event->anydata;
    TreeItemList items;
    int count;
    Quark *q = NULL;
    Quark *p = NULL;
    int parent_child_selection = FALSE;
    int all_shown = TRUE;
    int all_hidden = TRUE;

    TreeGetHighlighted(event->w, &items);
    count = items.count;

    if (count > 0) {
        int i, j;

        q = TreeGetQuark(items.items[0]);

        for (i = 0; i < count; i++) {
            Quark *iq = TreeGetQuark(items.items[i]);

            p = quark_parent_get(iq);
            while (p) {
                for (j = 0; j < count; j++) {
                    if (TreeGetQuark(items.items[j]) == p) {
                        parent_child_selection = TRUE;
                    }
                }
                p = quark_parent_get(p);
            }

            if (quark_is_active(iq)) {
                all_hidden = FALSE;
            } else {
                all_shown = FALSE;
            }
        }

        if (count == 1 && quark_fid_get(q) == QFlavorProject) {
            WidgetSetSensitive(ui->project_popup_show_bt,            FALSE);
            WidgetSetSensitive(ui->project_popup_save_bt,            FALSE);
            WidgetSetSensitive(ui->project_popup_save_as_bt,         FALSE);
            WidgetSetSensitive(ui->project_popup_revert_to_saved_bt, FALSE);
            WidgetSetSensitive(ui->project_popup_close_bt,           FALSE);

            if (quark_is_active(q)) {
                WidgetSetSensitive(ui->project_popup_show_bt,   FALSE);
            } else {
                WidgetSetSensitive(ui->project_popup_show_bt,   TRUE);
            }

            WidgetSetSensitive(ui->project_popup_save_bt,            TRUE);
            WidgetSetSensitive(ui->project_popup_save_as_bt,         TRUE);
            WidgetSetSensitive(ui->project_popup_revert_to_saved_bt, TRUE);

            if (gapp->gpcount > 1) {
                WidgetSetSensitive(ui->project_popup_close_bt,  TRUE);
            } else {
                WidgetSetSensitive(ui->project_popup_close_bt,  FALSE);
            }

            PopupMenuShow(ui->project_popup, event->udata);
        } else {
            WidgetSetSensitive(ui->popup_hide_bt, !all_hidden);
            WidgetSetSensitive(ui->popup_show_bt, !all_shown);

            if (parent_child_selection) {
                WidgetSetSensitive(ui->popup_delete_bt,         FALSE);
                WidgetSetSensitive(ui->popup_duplicate_bt,      FALSE);
            } else {
                WidgetSetSensitive(ui->popup_delete_bt,         TRUE);
                WidgetSetSensitive(ui->popup_duplicate_bt,      TRUE);
            }

            PopupMenuShow(ui->popup, event->udata);
        }
    }

    xfree(items.items);

    return TRUE;
}
コード例 #18
0
ファイル: explorer.c プロジェクト: mariusal/grace
static int drop_cb(TreeEvent *event)
{
    ExplorerUI *ui = (ExplorerUI *) event->anydata;

    int gpcount = 0;
    GProject **gplist;

    if (ui->homogeneous_parent) {
        int count;
        TreeItemList items;

        TreeGetHighlighted(ui->tree, &items);
        count = items.count;
        if (count > 0) {
            TreeItem *item = (TreeItem *) event->udata;
            Quark *drop_q = TreeGetQuark(item);
            Quark *drop_parent = quark_parent_get(drop_q);
            GProject *drop_gp = gproject_from_quark(drop_q);
            Quark *parent = quark_parent_get(TreeGetQuark(items.items[0]));

            gplist = xmalloc(gapp->gpcount*sizeof(GProject));
            if (!gplist) {
                return FALSE;
            }

            if (parent) {
                int i, id;
                Quark *newparent;

                if (quark_fid_get(parent) == quark_fid_get(drop_q)) {
                    id = 0;
                    newparent = drop_q;
                } else if (quark_fid_get(parent) == quark_fid_get(drop_parent)) {
                    id = quark_get_id(drop_q) + 1;
                    newparent = quark_parent_get(drop_q);
                } else {
                    return FALSE;
                }

                for (i = 0; i < count; i++) {
                    Quark *q = TreeGetQuark(items.items[i]);

                    switch (event->drop_action) {
                    case DROP_ACTION_COPY:
                        quark_copy2(q, newparent, id);
                        break;
                    case DROP_ACTION_MOVE:
                        add_to_list(gplist, &gpcount, gproject_from_quark(q));
                        quark_move2(q, newparent, id);
                        break;
                    default:
                        errmsg("unknown drop type");
                        break;
                    }
                }

                switch (event->drop_action) {
                case DROP_ACTION_COPY:
                    explorer_snapshot(gapp, drop_gp, TRUE);
                    break;
                case DROP_ACTION_MOVE:
                    add_to_list(gplist, &gpcount, drop_gp);
                    for (i = 0; i < gpcount; i++) {
                        explorer_snapshot(gapp, gplist[i], TRUE);
                    }
                    xfree(gplist);
                    break;
                }

                return TRUE;
            }
        }
    }
    return FALSE;
}
コード例 #19
0
ファイル: explorer.c プロジェクト: mariusal/grace
static int explorer_apply(ExplorerUI *ui, void *caller)
{
    TreeItemList items;
    int count, i, res = RETURN_SUCCESS;

    int gpcount = 0;
    GProject **gplist;
    
    if (caller && !ToggleButtonGetState(ui->instantupdate)) {
        return RETURN_FAILURE;
    }
    
    TreeGetHighlighted(ui->tree, &items);
    count = items.count;

    if (!count) {
        xfree(items.items);
        return RETURN_FAILURE;
    }

    gplist = xmalloc(gapp->gpcount*sizeof(GProject));
    if (!gplist) {
        return RETURN_FAILURE;
    }

    for (i = 0; i < count && res == RETURN_SUCCESS; i++) {
        Quark *q = TreeGetQuark(items.items[i]);

        add_to_list(gplist, &gpcount, gproject_from_quark(q));

        if (count == 1 && (!caller || caller == ui->idstr)) {
            char *s = TextGetString(ui->idstr);
            quark_idstr_set(q, s);
            xfree(s);
        }

        switch (quark_fid_get(q)) {
        case QFlavorProject:
            if (set_project_data(ui->project_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorSSD:
            if (set_ssd_data(ui->ssd_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorFrame:
            if (set_frame_data(ui->frame_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorGraph:
            if (graph_set_data(ui->graph_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorSet:
            if (set_set_data(ui->set_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorAGrid:
            if (set_axisgrid_data(ui->axisgrid_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorAxis:
            if (set_axis_data(ui->axis_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorDObject:
            if (set_object_data(ui->object_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorAText:
            if (set_atext_data(ui->atext_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        case QFlavorRegion:
            if (set_region_data(ui->region_ui, q, caller) != RETURN_SUCCESS) {
                res = RETURN_FAILURE;
            }
            break;
        default:
            res = RETURN_FAILURE;
            break;
        }
    }
    xfree(items.items);

    for (i = 0; i < gpcount; i++) {
        explorer_snapshot(gapp, gplist[i], FALSE);
    }
    xfree(gplist);

    return res;
}
コード例 #20
0
ファイル: utils.c プロジェクト: armando-2011/grace
char *q_labeling(Quark *q)
{
    Grace *grace = grace_from_quark(q);
    char *buf;
    tickmarks *t;
    DObject *o;
    region *r;
    
    if (!q) {
        return NULL;
    }
    
    buf = xmalloc(strlen(QIDSTR(q)) + 128);
    if (!buf) {
        return NULL;
    }
    
    switch (quark_fid_get(q)) {
    case QFlavorProject:
        sprintf(buf, "Project \"%s%s\"", QIDSTR(q),
            quark_dirtystate_get(q) ? "*":"");

        break;
    case QFlavorSSD:
        sprintf(buf, "SpreadSheet \"%s%s\"", QIDSTR(q),
            quark_dirtystate_get(q) ? "*":"");

        break;
    case QFlavorFrame:
        sprintf(buf, "Frame \"%s%s\"", QIDSTR(q),
            quark_dirtystate_get(q) ? "*":"");

        break;
    case QFlavorGraph:
        sprintf(buf, "Graph \"%s%s\" (type: %s)",
            QIDSTR(q),
            quark_dirtystate_get(q) ? "*":"",
            graph_types(grace, graph_get_type(q)));

        break;
    case QFlavorSet:
        sprintf(buf, "Set \"%s%s\" (%s)",
            QIDSTR(q), quark_dirtystate_get(q) ? "*":"",
            set_types(grace, set_get_type(q)));

        break;
    case QFlavorAGrid:
        t = axisgrid_get_data(q);
        
        sprintf(buf, "%c AGrid \"%s%s\"",
            t->type == AXIS_TYPE_X ? 'X':'Y', QIDSTR(q),
            quark_dirtystate_get(q) ? "*":"");

        break;
    case QFlavorAxis:
        t = axisgrid_get_data(q);
        
        sprintf(buf, "Axis \"%s%s\"", QIDSTR(q),
            quark_dirtystate_get(q) ? "*":"");

        break;
    case QFlavorDObject:
        o = object_get_data(q);

        sprintf(buf, "%s \"%s%s\"",
            object_type_descr(grace, o->type),
            QIDSTR(q), quark_dirtystate_get(q) ? "*":"");
        
        break;
    case QFlavorAText:
        sprintf(buf, "AText \"%s%s\"",
            QIDSTR(q), quark_dirtystate_get(q) ? "*":"");
        
        break;
    case QFlavorRegion:
        r = region_get_data(q);

        sprintf(buf, "Region \"%s%s\" (%d pts)",
            QIDSTR(q), quark_dirtystate_get(q) ? "*":"",
            r->n);
        
        break;
    default:
        sprintf(buf, "??? \"%s%s\"", QIDSTR(q),
            quark_dirtystate_get(q) ? "*":"");
        break;
    }
    
    return buf;
}