Commit 9714f211 authored by Lars Clausen's avatar Lars Clausen

Moving newgroup into app where it will eventually live. Shortened

diagram_unselect.  Note about autobugcheck.  Virtualization of initial diagram.
parent da145909
2006-08-13 Lars Clausen <lars@raeder.dk>
* objects/Misc/libmisc.c:
* {app,objects/Misc}/Makefile.am:
* objects/Misc/newgroup.c:
* app/newgroup.c: Moved newgroup.
* app/diagram.[ch]:
* app/undo.c:
* app/modify_tool.c:
* app/select.c: Trim diagram_unselect_object() to the one required
argument.
* app/app_procs.c:
* app/interface.c (dia_dnd_file_drag_data_received):
* app/recent_files.c (open_recent_file_callback):
* app/filedlg.c (file_open_response_callback):
* app/diagram.c (diagram_load):
Make the diagram created at start-up be a virtual diagram that
if unchanged is filled in by the first opened diagram, like Gnumeric.
2006-08-11 Lars Clausen <lars@raeder.dk>
* app/properties.c (properties_give_focus): Give focus to first
......
......@@ -5,6 +5,8 @@ This document, at this point, is a proposal only. It attempts to
document how we intend to make the upcoming releases, in order to make
as sure as possible no stupid bugs creep in just before the release.
For the next release, consider getting coverity.com to bugcheck.
Contents
--------
......
......@@ -201,6 +201,7 @@ dia_core_files = \
textedit.c \
textedit.h \
diagrid.h \
newgroup.c \
$(print_files)
dia_SOURCES = \
......
......@@ -597,8 +597,9 @@ handle_initial_diagram(const char *in_file_name,
} else {
if (g_file_test(in_file_name, G_FILE_TEST_EXISTS)) {
diagram = diagram_load (in_file_name, NULL);
} else
} else {
diagram = new_diagram (in_file_name);
}
if (diagram != NULL) {
diagram_update_extents(diagram);
......@@ -938,15 +939,13 @@ app_init (int argc, char **argv)
Diagram *diagram = new_diagram (filename);
g_free(filename);
if (diagram != NULL) {
diagram_update_extents(diagram);
if (app_is_interactive()) {
diagram->virtual = TRUE;
layer_dialog_set_diagram(diagram);
new_display(diagram);
}
}
}
g_slist_free(files);
if (made_conversions) exit(0);
......
......@@ -43,6 +43,7 @@
#include "dynamic_refresh.h"
#include "textedit.h"
#include "lib/diamarshal.h"
#include "parent.h"
static GList *open_diagrams = NULL;
......@@ -59,6 +60,7 @@ static gint diagram_parent_sort_cb(gconstpointer a, gconstpointer b);
static void diagram_class_init (DiagramClass *klass);
static gboolean diagram_init(Diagram *obj, const char *filename);
static void diagram_update_for_filename(Diagram *dia);
enum {
SELECTION_CHANGED,
......@@ -269,16 +271,31 @@ diagram_load_into(Diagram *diagram,
Diagram *
diagram_load(const char *filename, DiaImportFilter *ifilter)
{
Diagram *diagram;
Diagram *diagram = NULL;
GList *diagrams;
for (diagrams = open_diagrams; diagrams != NULL; diagrams = g_list_next(diagrams)) {
Diagram *old_diagram = (Diagram*)diagrams->data;
if (old_diagram->virtual) {
diagram = old_diagram;
break;
}
}
/* TODO: Make diagram not be initialized twice */
if (diagram == NULL) {
diagram = new_diagram(filename);
}
if (diagram == NULL) return NULL;
if (!diagram_load_into (diagram, filename, ifilter)) {
diagram_destroy(diagram);
diagram = NULL;
}
if (diagram->virtual) {
diagram_update_for_filename(diagram);
diagram->virtual = FALSE;
}
return diagram;
}
......@@ -328,7 +345,10 @@ diagram_modified(Diagram *dia)
ddisplay_update_statusbar(display);
displays = g_slist_next(displays);
}
if (diagram_is_modified(dia)) dia->autosaved = FALSE;
if (diagram_is_modified(dia)) {
dia->autosaved = FALSE;
dia->virtual = FALSE;
}
/* diagram_set_modified(dia, TRUE);*/
}
......@@ -621,12 +641,15 @@ diagram_remove_all_selected(Diagram *diagram, int delete_empty)
}
void
diagram_unselect_object(Diagram *diagram, DiaObject *obj)
diagram_unselect_object(DiaObject *obj)
{
Diagram *diagram = DIA_DIAGRAM(layer_get_parent_diagram
(dia_object_get_parent_layer(obj)));
object_add_updates(obj, diagram);
textedit_remove_focus(obj, diagram);
data_unselect(diagram->data, obj);
g_signal_emit (diagram, diagram_signals[SELECTION_CHANGED], 0, g_list_length (diagram->data->selected));
data_unselect(DIA_DIAGRAM_DATA(diagram), obj);
g_signal_emit (diagram, diagram_signals[SELECTION_CHANGED], 0,
g_list_length (DIA_DIAGRAM_DATA(diagram)->selected));
}
void
......@@ -642,7 +665,7 @@ diagram_unselect_objects(Diagram *dia, GList *obj_list)
obj = (DiaObject *) list->data;
if (g_list_find(dia->data->selected, obj) != NULL){
diagram_unselect_object(dia, obj);
diagram_unselect_object(obj);
}
list = g_list_next(list);
......@@ -1141,7 +1164,7 @@ void diagram_ungroup_selected(Diagram *dia)
Change *change;
/* Fix selection */
diagram_unselect_object(dia, group);
diagram_unselect_object(group);
group_list = group_objects(group);
diagram_select_list(dia, group_list);
......@@ -1317,13 +1340,25 @@ diagram_place_down_selected(Diagram *dia)
void
diagram_set_filename(Diagram *dia, const char *filename)
{
g_free(dia->filename);
dia->filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
diagram_update_for_filename(dia);
}
/** Update the various areas that require updating when changing filename
* This will ensure that all places that use the filename are updated:
* Window titles, layer dialog, recent files, diagram tree.
* @param dia The diagram whose filename has changed.
*/
static void
diagram_update_for_filename(Diagram *dia)
{
GSList *l;
DDisplay *ddisp;
char *title;
g_free(dia->filename);
dia->filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
char *filename = dia->filename;
title = diagram_get_name(dia);
......
......@@ -45,6 +45,7 @@ struct _Diagram {
char *filename;
int unsaved; /* True if diagram is created but not saved.*/
gboolean virtual; /* True if the diagram was created as the default.*/
int mollified;
gboolean autosaved; /* True if the diagram is autosaved since last mod */
char *autosavefilename; /* Holds the name of the current autosave file
......@@ -69,7 +70,7 @@ struct _Diagram {
};
typedef struct _DiagramClass {
GObjectClass parent_class;
DiagramDataClass parent_class;
/* signals */
void (* removed) (Diagram*);
......@@ -94,7 +95,7 @@ void diagram_add_object(Diagram *dia, DiaObject *obj);
void diagram_add_object_list(Diagram *dia, GList *list);
void diagram_selected_break_external(Diagram *dia);
void diagram_remove_all_selected(Diagram *diagram, int delete_empty);
void diagram_unselect_object(Diagram *diagram, DiaObject *obj);
void diagram_unselect_object(DiaObject *obj);
void diagram_unselect_objects(Diagram *dia, GList *obj_list);
void diagram_select(Diagram *diagram, DiaObject *obj);
void diagram_select_list(Diagram *diagram, GList *list);
......
......@@ -165,8 +165,8 @@ file_open_response_callback(GtkWidget *fs,
diagram_update_extents(diagram);
layer_dialog_set_diagram(diagram);
if (diagram->displays != NULL) {
GSList *displays = diagram->displays;
if (diagram->displays == NULL) {
/* GSList *displays = diagram->displays;
GSList *displays_head = displays;
diagram->displays = NULL;
for (; displays != NULL; displays = g_slist_next(displays)) {
......@@ -176,6 +176,7 @@ file_open_response_callback(GtkWidget *fs,
}
g_slist_free(displays_head);
} else {
*/
new_display(diagram);
}
}
......
......@@ -1209,8 +1209,10 @@ dia_dnd_file_drag_data_received (GtkWidget *widget,
diagram_update_extents(diagram);
layer_dialog_set_diagram(diagram);
if (diagram->displays == NULL) {
ddisp = new_display(diagram);
}
}
pFrom = strstr(pTo, "file:");
} /* while */
......
......@@ -178,7 +178,7 @@ click_select_object(DDisplay *ddisp, Point *clickedpoint,
if (event->state & GDK_SHIFT_MASK) { /* Multi-select */
/* Remove the selected selected */
ddisplay_do_update_menu_sensitivity(ddisp);
diagram_unselect_object(ddisp->diagram, (DiaObject *)already->data);
diagram_unselect_object((DiaObject *)already->data);
diagram_flush(ddisp->diagram);
} else {
/* Maybe start editing text */
......@@ -750,10 +750,10 @@ modify_button_release(ModifyTool *tool, GdkEventButton *event,
if (selection_style == SELECT_REMOVE) {
if (diagram_is_selected(ddisp->diagram, obj))
diagram_unselect_object(ddisp->diagram, obj);
diagram_unselect_object(obj);
} else if (selection_style == SELECT_INVERT) {
if (diagram_is_selected(ddisp->diagram, obj))
diagram_unselect_object(ddisp->diagram, obj);
diagram_unselect_object(obj);
else
diagram_select(ddisp->diagram, obj);
} else {
......
......@@ -32,8 +32,10 @@
#include "widgets.h"
#include "message.h"
#include "properties.h"
#include "diagramdata.h"
#include "parent.h"
#include "pixmaps/newgroup.xpm"
#include "objects/Misc/pixmaps/newgroup.xpm"
#define NUM_CONNECTIONS 9
......@@ -264,7 +266,20 @@ newgroup_update_data(NewGroup *group)
if (group->is_open) {
obj->flags &= ~DIA_OBJECT_GRABS_CHILD_INPUT;
} else {
gboolean newlySet = FALSE;
Layer *layer;
if (!object_flags_set(obj, DIA_OBJECT_GRABS_CHILD_INPUT)) {
newlySet = TRUE;
}
obj->flags |= DIA_OBJECT_GRABS_CHILD_INPUT;
if (newlySet) {
layer = dia_object_get_parent_layer(obj);
if (layer != NULL) { /* Placed in diagram already */
/* Iterate through all selected objects, picking out children */
parent_apply_to_children(obj, diagram_unselect_object);
}
}
}
}
......
......@@ -167,7 +167,9 @@ open_recent_file_callback(GtkWidget *widget, gpointer data)
if (diagram != NULL) {
diagram_update_extents(diagram);
layer_dialog_set_diagram(diagram);
if (diagram->displays == NULL) {
new_display(diagram);
}
} else
recent_file_history_remove (filename);
g_free(filename);
......
......@@ -89,7 +89,7 @@ select_invert_callback(gpointer data, guint action, GtkWidget *widget)
if (!diagram_is_selected(dia, obj)) {
diagram_select(dia, obj);
} else {
diagram_unselect_object(dia, obj);
diagram_unselect_object(obj);
}
}
......
......@@ -927,7 +927,7 @@ group_objects_revert(struct GroupObjectsChange *change, Diagram *dia)
DEBUG_PRINTF(("group_objects_revert()\n"));
change->applied = 0;
diagram_unselect_object(dia, change->group);
diagram_unselect_object(change->group);
object_add_updates(change->group, dia);
layer_set_object_list(change->layer, g_list_copy(change->orig_list));
......@@ -995,7 +995,7 @@ ungroup_objects_apply(struct UngroupObjectsChange *change, Diagram *dia)
change->applied = 1;
diagram_unselect_object(dia, change->group);
diagram_unselect_object(change->group);
object_add_updates(change->group, dia);
layer_replace_object_with_list(change->layer, change->group,
g_list_copy(change->obj_list));
......
......@@ -180,11 +180,9 @@ diagram_data_class_init(DiagramDataClass *klass)
G_TYPE_POINTER,
G_TYPE_POINTER);
object_class->finalize = diagram_data_finalize;
klass->object_add = _diagram_data_object_add;
klass->object_remove = _diagram_data_object_remove;
}
/** Create a new layer in this diagram.
......@@ -588,15 +586,15 @@ data_get_sorted_selected_remove(DiagramData *data)
* @param signal_name The name of the signal.
*/
void
data_emit(DiagramData *data,Layer *layer,DiaObject* obj,const char *signal_name)
data_emit(DiagramData *data, Layer *layer, DiaObject* obj,
const char *signal_name)
{
/* check what signal it is */
if (strcmp("object_add",signal_name) == 0)
g_signal_emit (data, diagram_data_signals[OBJECT_ADD], 0,layer,obj);
g_signal_emit(data, diagram_data_signals[OBJECT_ADD], 0, layer, obj);
if (strcmp("object_remove",signal_name) == 0)
g_signal_emit (data, diagram_data_signals[OBJECT_REMOVE], 0,layer,obj);
g_signal_emit(data, diagram_data_signals[OBJECT_REMOVE], 0, layer, obj);
}
......
......@@ -26,4 +26,3 @@ VOID: VOID
VOID: OBJECT
VOID: INT
VOID: POINTER,POINTER
......@@ -3,8 +3,7 @@
pkglib_LTLIBRARIES = libmisc_objects.la
libmisc_objects_la_SOURCES = \
libmisc.c \
analog_clock.c \
newgroup.c
analog_clock.c
libmisc_objects_la_LDFLAGS = -export-dynamic -module -avoid-version
......
......@@ -29,6 +29,7 @@
#include "plug-ins.h"
extern DiaObjectType analog_clock_type;
/** Taken from app, but here while testing. */
extern DiaObjectType newgroup_type;
DIA_PLUGIN_CHECK_INIT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment