static PyObject * PyDiaDiagram_Unselect(PyDiaDiagram *self, PyObject *args) { PyDiaObject *obj; if (!PyArg_ParseTuple(args, "O!:Diagram.unselect", &PyDiaObject_Type, &obj)) return NULL; diagram_unselect_object(self->dia, obj->object); Py_INCREF(Py_None); return Py_None; }
static void group_objects_revert(struct GroupObjectsChange *change, Diagram *dia) { DEBUG_PRINTF(("group_objects_revert()\n")); change->applied = 0; diagram_unselect_object(dia, change->group); object_add_updates(change->group, dia); layer_set_object_list(change->layer, g_list_copy(change->orig_list)); object_add_updates_list(change->obj_list, dia); properties_hide_if_shown(dia, change->group); diagram_tree_add_objects(diagram_tree(), dia, change->obj_list); diagram_tree_remove_object(diagram_tree(), change->group); }
static void ungroup_objects_apply(struct UngroupObjectsChange *change, Diagram *dia) { DEBUG_PRINTF(("ungroup_objects_apply()\n")); change->applied = 1; diagram_unselect_object(dia, change->group); object_add_updates(change->group, dia); layer_replace_object_with_list(change->layer, change->group, g_list_copy(change->obj_list)); object_add_updates_list(change->obj_list, dia); properties_hide_if_shown(dia, change->group); diagram_tree_add_objects(diagram_tree(), dia, change->obj_list); diagram_tree_remove_object(diagram_tree(), change->group); }
void diagram_ungroup_selected(Diagram *dia) { DiaObject *group; GList *group_list; GList *selected, *selection_copy; int group_index; int any_groups = 0; if (g_list_length(dia->data->selected) < 1) { message_error("Trying to ungroup with no selected objects."); return; } selection_copy = g_list_copy(dia->data->selected); selected = selection_copy; while (selected != NULL) { group = (DiaObject *)selected->data; if (IS_GROUP(group)) { Change *change; /* Fix selection */ diagram_unselect_object(dia, group); group_list = group_objects(group); group_index = layer_object_get_index(dia->data->active_layer, group); change = undo_ungroup_objects(dia, group_list, group, group_index); (change->apply)(change, dia); diagram_select_list(dia, group_list); any_groups = 1; } selected = g_list_next(selected); } g_list_free(selection_copy); if (any_groups) { diagram_modified(dia); diagram_flush(dia); undo_set_transactionpoint(dia->undo); } }
void diagram_unselect_objects(Diagram *dia, GList *obj_list) { GList *list; DiaObject *obj; /* otherwise we would signal objects step by step */ g_signal_handlers_block_by_func (dia, DIA_DIAGRAM_DATA_GET_CLASS (dia)->selection_changed, NULL); list = obj_list; while (list != NULL) { obj = (DiaObject *) list->data; if (g_list_find(dia->data->selected, obj) != NULL){ diagram_unselect_object(dia, obj); } list = g_list_next(list); } g_signal_handlers_unblock_by_func (dia, DIA_DIAGRAM_DATA_GET_CLASS (dia)->selection_changed, NULL); g_signal_emit_by_name (dia, "selection_changed", g_list_length (dia->data->selected)); }
static void modify_button_release(ModifyTool *tool, GdkEventButton *event, DDisplay *ddisp) { Point *dest_pos, to; GList *list; int i; ObjectChange *objchange; tool->break_connections = FALSE; ddisplay_set_all_cursor(default_cursor); /* remove position from status bar */ { GtkStatusbar *statusbar = GTK_STATUSBAR (ddisp->modified_status); guint context_id = gtk_statusbar_get_context_id (statusbar, "ObjectPos"); gtk_statusbar_pop (statusbar, context_id); } switch (tool->state) { case STATE_MOVE_OBJECT: /* Return to normal state */ gdk_pointer_ungrab (event->time); ddisplay_untransform_coords(ddisp, event->x, event->y, &to.x, &to.y); if (!modify_move_already(tool, ddisp, &to)) { tool->orig_pos = NULL; tool->state = STATE_NONE; return; } diagram_update_connections_selection(ddisp->diagram); if (tool->orig_pos != NULL) { /* consider the non-selected children affected */ list = parent_list_affected(ddisp->diagram->data->selected); dest_pos = g_new(Point, g_list_length(list)); i=0; while (list != NULL) { DiaObject *obj = (DiaObject *) list->data; dest_pos[i] = obj->position; list = g_list_next(list); i++; } undo_move_objects(ddisp->diagram, tool->orig_pos, dest_pos, parent_list_affected(ddisp->diagram->data->selected)); } ddisplay_connect_selected(ddisp); /* pushes UNDO info */ diagram_update_extents(ddisp->diagram); diagram_modified(ddisp->diagram); diagram_flush(ddisp->diagram); undo_set_transactionpoint(ddisp->diagram->undo); tool->orig_pos = NULL; tool->state = STATE_NONE; break; case STATE_MOVE_HANDLE: gdk_pointer_ungrab (event->time); tool->state = STATE_NONE; if (tool->orig_pos != NULL) { undo_move_handle(ddisp->diagram, tool->handle, tool->object, *tool->orig_pos, tool->last_to, gdk_event_to_dia_ModifierKeys(event->state)); } /* Final move: */ object_add_updates(tool->object, ddisp->diagram); objchange = tool->object->ops->move_handle(tool->object, tool->handle, &tool->last_to, NULL, HANDLE_MOVE_USER_FINAL,gdk_event_to_dia_ModifierKeys(event->state)); if (objchange != NULL) { undo_object_change(ddisp->diagram, tool->object, objchange); } object_add_updates(tool->object, ddisp->diagram); /* Connect if possible: */ if (tool->handle->connect_type != HANDLE_NONCONNECTABLE) { object_connect_display(ddisp, tool->object, tool->handle, TRUE); /* pushes UNDO info */ diagram_update_connections_selection(ddisp->diagram); } highlight_reset_all(ddisp->diagram); diagram_flush(ddisp->diagram); diagram_modified(ddisp->diagram); diagram_update_extents(ddisp->diagram); undo_set_transactionpoint(ddisp->diagram->undo); if (tool->orig_pos != NULL) { g_free(tool->orig_pos); tool->orig_pos = NULL; } break; case STATE_BOX_SELECT: gdk_pointer_ungrab (event->time); /* Remove last box: */ dia_interactive_renderer_set_selection (ddisp->renderer, FALSE, 0, 0, 0, 0); { GList *list, *list_to_free; list = list_to_free = find_selected_objects(ddisp, tool); if (selection_style == SELECT_REPLACE && !(event->state & GDK_SHIFT_MASK)) { /* Not Multi-select => Remove all selected */ diagram_remove_all_selected(ddisp->diagram, TRUE); } if (selection_style == SELECT_INTERSECTION) { GList *intersection = NULL; while (list != NULL) { DiaObject *obj = (DiaObject *)list->data; if (diagram_is_selected(ddisp->diagram, obj)) { intersection = g_list_append(intersection, obj); } list = g_list_next(list); } list = intersection; diagram_remove_all_selected(ddisp->diagram, TRUE); while (list != NULL) { DiaObject *obj = (DiaObject *)list->data; diagram_select(ddisp->diagram, obj); list = g_list_next(list); } g_list_free(intersection); } else { while (list != NULL) { DiaObject *obj = (DiaObject *)list->data; if (selection_style == SELECT_REMOVE) { if (diagram_is_selected(ddisp->diagram, obj)) diagram_unselect_object(ddisp->diagram, obj); } else if (selection_style == SELECT_INVERT) { if (diagram_is_selected(ddisp->diagram, obj)) diagram_unselect_object(ddisp->diagram, obj); else diagram_select(ddisp->diagram, obj); } else { if (!diagram_is_selected(ddisp->diagram, obj)) diagram_select(ddisp->diagram, obj); } list = g_list_next(list); } } g_list_free(list_to_free); } ddisplay_do_update_menu_sensitivity(ddisp); ddisplay_flush(ddisp); tool->state = STATE_NONE; break; case STATE_NONE: break; default: message_error("Internal error: Strange state in modify_tool\n"); } }
static DiaObject * click_select_object(DDisplay *ddisp, Point *clickedpoint, GdkEventButton *event) { Diagram *diagram; real click_distance; DiaObject *obj; diagram = ddisp->diagram; /* Find the closest object to select it: */ click_distance = ddisplay_untransform_length(ddisp, 3.0); obj = diagram_find_clicked_object(diagram, clickedpoint, click_distance); if (obj!=NULL) { /* Selected an object. */ GList *already; /*printf("Selected object!\n");*/ already = g_list_find(diagram->data->selected, obj); if (already == NULL) { /* Not already selected */ /*printf("Not already selected\n");*/ if (!(event->state & GDK_SHIFT_MASK)) { /* Not Multi-select => remove current selection */ diagram_remove_all_selected(diagram, TRUE); } diagram_select(diagram, obj); /* To be removed once text edit mode is stable. By then, * we don't want to automatically edit selected objects. textedit_activate_object(ddisp, obj, clickedpoint); */ ddisplay_do_update_menu_sensitivity(ddisp); object_add_updates_list(diagram->data->selected, diagram); diagram_flush(diagram); return obj; } else { /* Clicked on already selected. */ /*printf("Already selected\n");*/ /* To be removed once text edit mode is stable. By then, * we don't want to automatically edit selected objects. textedit_activate_object(ddisp, obj, clickedpoint); */ object_add_updates_list(diagram->data->selected, diagram); diagram_flush(diagram); if (event->state & GDK_SHIFT_MASK) { /* Multi-select */ /* Remove the selected selected */ ddisplay_do_update_menu_sensitivity(ddisp); diagram_unselect_object(diagram, (DiaObject *)already->data); diagram_flush(ddisp->diagram); } else { return obj; } } } /* Else part moved to allow union/intersection select */ return NULL; }