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> 2006-08-11 Lars Clausen <lars@raeder.dk>
* app/properties.c (properties_give_focus): Give focus to first * 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 ...@@ -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 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. as sure as possible no stupid bugs creep in just before the release.
For the next release, consider getting coverity.com to bugcheck.
Contents Contents
-------- --------
......
...@@ -201,6 +201,7 @@ dia_core_files = \ ...@@ -201,6 +201,7 @@ dia_core_files = \
textedit.c \ textedit.c \
textedit.h \ textedit.h \
diagrid.h \ diagrid.h \
newgroup.c \
$(print_files) $(print_files)
dia_SOURCES = \ dia_SOURCES = \
......
...@@ -597,8 +597,9 @@ handle_initial_diagram(const char *in_file_name, ...@@ -597,8 +597,9 @@ handle_initial_diagram(const char *in_file_name,
} else { } else {
if (g_file_test(in_file_name, G_FILE_TEST_EXISTS)) { if (g_file_test(in_file_name, G_FILE_TEST_EXISTS)) {
diagram = diagram_load (in_file_name, NULL); diagram = diagram_load (in_file_name, NULL);
} else } else {
diagram = new_diagram (in_file_name); diagram = new_diagram (in_file_name);
}
if (diagram != NULL) { if (diagram != NULL) {
diagram_update_extents(diagram); diagram_update_extents(diagram);
...@@ -937,14 +938,12 @@ app_init (int argc, char **argv) ...@@ -937,14 +938,12 @@ app_init (int argc, char **argv)
gchar *filename = g_filename_from_utf8(_("Diagram1.dia"), -1, NULL, NULL, NULL); gchar *filename = g_filename_from_utf8(_("Diagram1.dia"), -1, NULL, NULL, NULL);
Diagram *diagram = new_diagram (filename); Diagram *diagram = new_diagram (filename);
g_free(filename); g_free(filename);
if (diagram != NULL) { if (diagram != NULL) {
diagram_update_extents(diagram); diagram_update_extents(diagram);
if (app_is_interactive()) { diagram->virtual = TRUE;
layer_dialog_set_diagram(diagram); layer_dialog_set_diagram(diagram);
new_display(diagram); new_display(diagram);
}
} }
} }
g_slist_free(files); g_slist_free(files);
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "dynamic_refresh.h" #include "dynamic_refresh.h"
#include "textedit.h" #include "textedit.h"
#include "lib/diamarshal.h" #include "lib/diamarshal.h"
#include "parent.h"
static GList *open_diagrams = NULL; static GList *open_diagrams = NULL;
...@@ -59,6 +60,7 @@ static gint diagram_parent_sort_cb(gconstpointer a, gconstpointer b); ...@@ -59,6 +60,7 @@ static gint diagram_parent_sort_cb(gconstpointer a, gconstpointer b);
static void diagram_class_init (DiagramClass *klass); static void diagram_class_init (DiagramClass *klass);
static gboolean diagram_init(Diagram *obj, const char *filename); static gboolean diagram_init(Diagram *obj, const char *filename);
static void diagram_update_for_filename(Diagram *dia);
enum { enum {
SELECTION_CHANGED, SELECTION_CHANGED,
...@@ -269,17 +271,32 @@ diagram_load_into(Diagram *diagram, ...@@ -269,17 +271,32 @@ diagram_load_into(Diagram *diagram,
Diagram * Diagram *
diagram_load(const char *filename, DiaImportFilter *ifilter) 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 */ /* TODO: Make diagram not be initialized twice */
diagram = new_diagram(filename); if (diagram == NULL) {
diagram = new_diagram(filename);
}
if (diagram == NULL) return NULL; if (diagram == NULL) return NULL;
if (!diagram_load_into (diagram, filename, ifilter)) { if (!diagram_load_into (diagram, filename, ifilter)) {
diagram_destroy(diagram); diagram_destroy(diagram);
diagram = NULL; diagram = NULL;
} }
if (diagram->virtual) {
diagram_update_for_filename(diagram);
diagram->virtual = FALSE;
}
return diagram; return diagram;
} }
...@@ -328,7 +345,10 @@ diagram_modified(Diagram *dia) ...@@ -328,7 +345,10 @@ diagram_modified(Diagram *dia)
ddisplay_update_statusbar(display); ddisplay_update_statusbar(display);
displays = g_slist_next(displays); 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);*/ /* diagram_set_modified(dia, TRUE);*/
} }
...@@ -621,12 +641,15 @@ diagram_remove_all_selected(Diagram *diagram, int delete_empty) ...@@ -621,12 +641,15 @@ diagram_remove_all_selected(Diagram *diagram, int delete_empty)
} }
void 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); object_add_updates(obj, diagram);
textedit_remove_focus(obj, diagram); textedit_remove_focus(obj, diagram);
data_unselect(diagram->data, obj); data_unselect(DIA_DIAGRAM_DATA(diagram), obj);
g_signal_emit (diagram, diagram_signals[SELECTION_CHANGED], 0, g_list_length (diagram->data->selected)); g_signal_emit (diagram, diagram_signals[SELECTION_CHANGED], 0,
g_list_length (DIA_DIAGRAM_DATA(diagram)->selected));
} }
void void
...@@ -642,7 +665,7 @@ diagram_unselect_objects(Diagram *dia, GList *obj_list) ...@@ -642,7 +665,7 @@ diagram_unselect_objects(Diagram *dia, GList *obj_list)
obj = (DiaObject *) list->data; obj = (DiaObject *) list->data;
if (g_list_find(dia->data->selected, obj) != NULL){ if (g_list_find(dia->data->selected, obj) != NULL){
diagram_unselect_object(dia, obj); diagram_unselect_object(obj);
} }
list = g_list_next(list); list = g_list_next(list);
...@@ -1141,7 +1164,7 @@ void diagram_ungroup_selected(Diagram *dia) ...@@ -1141,7 +1164,7 @@ void diagram_ungroup_selected(Diagram *dia)
Change *change; Change *change;
/* Fix selection */ /* Fix selection */
diagram_unselect_object(dia, group); diagram_unselect_object(group);
group_list = group_objects(group); group_list = group_objects(group);
diagram_select_list(dia, group_list); diagram_select_list(dia, group_list);
...@@ -1317,13 +1340,25 @@ diagram_place_down_selected(Diagram *dia) ...@@ -1317,13 +1340,25 @@ diagram_place_down_selected(Diagram *dia)
void void
diagram_set_filename(Diagram *dia, const char *filename) 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; GSList *l;
DDisplay *ddisp; DDisplay *ddisp;
char *title; char *title;
char *filename = dia->filename;
g_free(dia->filename);
dia->filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
title = diagram_get_name(dia); title = diagram_get_name(dia);
......
...@@ -45,6 +45,7 @@ struct _Diagram { ...@@ -45,6 +45,7 @@ struct _Diagram {
char *filename; char *filename;
int unsaved; /* True if diagram is created but not saved.*/ int unsaved; /* True if diagram is created but not saved.*/
gboolean virtual; /* True if the diagram was created as the default.*/
int mollified; int mollified;
gboolean autosaved; /* True if the diagram is autosaved since last mod */ gboolean autosaved; /* True if the diagram is autosaved since last mod */
char *autosavefilename; /* Holds the name of the current autosave file char *autosavefilename; /* Holds the name of the current autosave file
...@@ -69,7 +70,7 @@ struct _Diagram { ...@@ -69,7 +70,7 @@ struct _Diagram {
}; };
typedef struct _DiagramClass { typedef struct _DiagramClass {
GObjectClass parent_class; DiagramDataClass parent_class;
/* signals */ /* signals */
void (* removed) (Diagram*); void (* removed) (Diagram*);
...@@ -94,7 +95,7 @@ void diagram_add_object(Diagram *dia, DiaObject *obj); ...@@ -94,7 +95,7 @@ void diagram_add_object(Diagram *dia, DiaObject *obj);
void diagram_add_object_list(Diagram *dia, GList *list); void diagram_add_object_list(Diagram *dia, GList *list);
void diagram_selected_break_external(Diagram *dia); void diagram_selected_break_external(Diagram *dia);
void diagram_remove_all_selected(Diagram *diagram, int delete_empty); 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_unselect_objects(Diagram *dia, GList *obj_list);
void diagram_select(Diagram *diagram, DiaObject *obj); void diagram_select(Diagram *diagram, DiaObject *obj);
void diagram_select_list(Diagram *diagram, GList *list); void diagram_select_list(Diagram *diagram, GList *list);
......
...@@ -165,8 +165,8 @@ file_open_response_callback(GtkWidget *fs, ...@@ -165,8 +165,8 @@ file_open_response_callback(GtkWidget *fs,
diagram_update_extents(diagram); diagram_update_extents(diagram);
layer_dialog_set_diagram(diagram); layer_dialog_set_diagram(diagram);
if (diagram->displays != NULL) { if (diagram->displays == NULL) {
GSList *displays = diagram->displays; /* GSList *displays = diagram->displays;
GSList *displays_head = displays; GSList *displays_head = displays;
diagram->displays = NULL; diagram->displays = NULL;
for (; displays != NULL; displays = g_slist_next(displays)) { for (; displays != NULL; displays = g_slist_next(displays)) {
...@@ -176,6 +176,7 @@ file_open_response_callback(GtkWidget *fs, ...@@ -176,6 +176,7 @@ file_open_response_callback(GtkWidget *fs,
} }
g_slist_free(displays_head); g_slist_free(displays_head);
} else { } else {
*/
new_display(diagram); new_display(diagram);
} }
} }
......
...@@ -1209,7 +1209,9 @@ dia_dnd_file_drag_data_received (GtkWidget *widget, ...@@ -1209,7 +1209,9 @@ dia_dnd_file_drag_data_received (GtkWidget *widget,
diagram_update_extents(diagram); diagram_update_extents(diagram);
layer_dialog_set_diagram(diagram); layer_dialog_set_diagram(diagram);
ddisp = new_display(diagram); if (diagram->displays == NULL) {
ddisp = new_display(diagram);
}
} }
pFrom = strstr(pTo, "file:"); pFrom = strstr(pTo, "file:");
......
...@@ -178,7 +178,7 @@ click_select_object(DDisplay *ddisp, Point *clickedpoint, ...@@ -178,7 +178,7 @@ click_select_object(DDisplay *ddisp, Point *clickedpoint,
if (event->state & GDK_SHIFT_MASK) { /* Multi-select */ if (event->state & GDK_SHIFT_MASK) { /* Multi-select */
/* Remove the selected selected */ /* Remove the selected selected */
ddisplay_do_update_menu_sensitivity(ddisp); ddisplay_do_update_menu_sensitivity(ddisp);
diagram_unselect_object(ddisp->diagram, (DiaObject *)already->data); diagram_unselect_object((DiaObject *)already->data);
diagram_flush(ddisp->diagram); diagram_flush(ddisp->diagram);
} else { } else {
/* Maybe start editing text */ /* Maybe start editing text */
...@@ -750,10 +750,10 @@ modify_button_release(ModifyTool *tool, GdkEventButton *event, ...@@ -750,10 +750,10 @@ modify_button_release(ModifyTool *tool, GdkEventButton *event,
if (selection_style == SELECT_REMOVE) { if (selection_style == SELECT_REMOVE) {
if (diagram_is_selected(ddisp->diagram, obj)) if (diagram_is_selected(ddisp->diagram, obj))
diagram_unselect_object(ddisp->diagram, obj); diagram_unselect_object(obj);
} else if (selection_style == SELECT_INVERT) { } else if (selection_style == SELECT_INVERT) {
if (diagram_is_selected(ddisp->diagram, obj)) if (diagram_is_selected(ddisp->diagram, obj))
diagram_unselect_object(ddisp->diagram, obj); diagram_unselect_object(obj);
else else
diagram_select(ddisp->diagram, obj); diagram_select(ddisp->diagram, obj);
} else { } else {
......
...@@ -32,8 +32,10 @@ ...@@ -32,8 +32,10 @@
#include "widgets.h" #include "widgets.h"
#include "message.h" #include "message.h"
#include "properties.h" #include "properties.h"
#include "diagramdata.h"
#include "parent.h"
#include "pixmaps/newgroup.xpm" #include "objects/Misc/pixmaps/newgroup.xpm"
#define NUM_CONNECTIONS 9 #define NUM_CONNECTIONS 9
...@@ -264,7 +266,20 @@ newgroup_update_data(NewGroup *group) ...@@ -264,7 +266,20 @@ newgroup_update_data(NewGroup *group)
if (group->is_open) { if (group->is_open) {
obj->flags &= ~DIA_OBJECT_GRABS_CHILD_INPUT; obj->flags &= ~DIA_OBJECT_GRABS_CHILD_INPUT;
} else { } 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; 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) ...@@ -167,7 +167,9 @@ open_recent_file_callback(GtkWidget *widget, gpointer data)
if (diagram != NULL) { if (diagram != NULL) {
diagram_update_extents(diagram); diagram_update_extents(diagram);
layer_dialog_set_diagram(diagram); layer_dialog_set_diagram(diagram);
new_display(diagram); if (diagram->displays == NULL) {
new_display(diagram);
}
} else } else
recent_file_history_remove (filename); recent_file_history_remove (filename);
g_free(filename); g_free(filename);
......
...@@ -89,7 +89,7 @@ select_invert_callback(gpointer data, guint action, GtkWidget *widget) ...@@ -89,7 +89,7 @@ select_invert_callback(gpointer data, guint action, GtkWidget *widget)
if (!diagram_is_selected(dia, obj)) { if (!diagram_is_selected(dia, obj)) {
diagram_select(dia, obj); diagram_select(dia, obj);
} else { } else {
diagram_unselect_object(dia, obj); diagram_unselect_object(obj);
} }
} }
......
...@@ -927,7 +927,7 @@ group_objects_revert(struct GroupObjectsChange *change, Diagram *dia) ...@@ -927,7 +927,7 @@ group_objects_revert(struct GroupObjectsChange *change, Diagram *dia)
DEBUG_PRINTF(("group_objects_revert()\n")); DEBUG_PRINTF(("group_objects_revert()\n"));
change->applied = 0; change->applied = 0;
diagram_unselect_object(dia, change->group); diagram_unselect_object(change->group);
object_add_updates(change->group, dia); object_add_updates(change->group, dia);
layer_set_object_list(change->layer, g_list_copy(change->orig_list)); layer_set_object_list(change->layer, g_list_copy(change->orig_list));
...@@ -995,7 +995,7 @@ ungroup_objects_apply(struct UngroupObjectsChange *change, Diagram *dia) ...@@ -995,7 +995,7 @@ ungroup_objects_apply(struct UngroupObjectsChange *change, Diagram *dia)
change->applied = 1; change->applied = 1;
diagram_unselect_object(dia, change->group); diagram_unselect_object(change->group);
object_add_updates(change->group, dia); object_add_updates(change->group, dia);
layer_replace_object_with_list(change->layer, change->group, layer_replace_object_with_list(change->layer, change->group,
g_list_copy(change->obj_list)); g_list_copy(change->obj_list));
......
...@@ -180,11 +180,9 @@ diagram_data_class_init(DiagramDataClass *klass) ...@@ -180,11 +180,9 @@ diagram_data_class_init(DiagramDataClass *klass)
G_TYPE_POINTER, G_TYPE_POINTER,
G_TYPE_POINTER); G_TYPE_POINTER);
object_class->finalize = diagram_data_finalize; object_class->finalize = diagram_data_finalize;
klass->object_add = _diagram_data_object_add; klass->object_add = _diagram_data_object_add;
klass->object_remove = _diagram_data_object_remove; klass->object_remove = _diagram_data_object_remove;
} }
/** Create a new layer in this diagram. /** Create a new layer in this diagram.
...@@ -588,16 +586,16 @@ data_get_sorted_selected_remove(DiagramData *data) ...@@ -588,16 +586,16 @@ data_get_sorted_selected_remove(DiagramData *data)
* @param signal_name The name of the signal. * @param signal_name The name of the signal.
*/ */
void 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 */
/* check what signal it is */ if (strcmp("object_add",signal_name) == 0)
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)
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);
} }
......
...@@ -90,7 +90,7 @@ typedef struct _DiagramDataClass { ...@@ -90,7 +90,7 @@ typedef struct _DiagramDataClass {
/* Signals */ /* Signals */
void (* object_add) (DiagramData*, Layer*, DiaObject*); void (* object_add) (DiagramData*, Layer*, DiaObject*);
void (* object_remove) (DiagramData*, Layer*, DiaObject*); void (* object_remove) (DiagramData*, Layer*, DiaObject*);
} DiagramDataClass; } DiagramDataClass;
/*! /*!
......
...@@ -26,4 +26,3 @@ VOID: VOID ...@@ -26,4 +26,3 @@ VOID: VOID
VOID: OBJECT VOID: OBJECT
VOID: INT VOID: INT
VOID: POINTER,POINTER VOID: POINTER,POINTER
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
pkglib_LTLIBRARIES = libmisc_objects.la pkglib_LTLIBRARIES = libmisc_objects.la
libmisc_objects_la_SOURCES = \ libmisc_objects_la_SOURCES = \
libmisc.c \ libmisc.c \
analog_clock.c \ analog_clock.c
newgroup.c
libmisc_objects_la_LDFLAGS = -export-dynamic -module -avoid-version libmisc_objects_la_LDFLAGS = -export-dynamic -module -avoid-version
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "plug-ins.h" #include "plug-ins.h"
extern DiaObjectType analog_clock_type; extern DiaObjectType analog_clock_type;
/** Taken from app, but here while testing. */
extern DiaObjectType newgroup_type; extern DiaObjectType newgroup_type;
DIA_PLUGIN_CHECK_INIT 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