This diff gives defaults dialogs for boxes, ellipses and text, and makes
the arrows for arc behave reasonably (though there might be room for
improvement). There's also some include file changes for gtk 1.1.14, and a
few old things that still reside in my copy of the source.
-Lars
Index: app/load_save.c
===================================================================
RCS file: /cvs/gnome/dia/app/load_save.c,v
retrieving revision 1.10
diff -u -r1.10 load_save.c
--- load_save.c 1999/01/25 13:24:16 1.10
+++ load_save.c 1999/02/01 05:24:43
@@ -27,8 +27,8 @@
#include "intl.h"
/* gnome-xml: */
-#include <tree.h>
-#include <parser.h>
+#include <gnome-xml/tree.h>
+#include <gnome-xml/parser.h>
#include "load_save.h"
#include "dia_xml.h"
Index: app/menus.c
===================================================================
RCS file: /cvs/gnome/dia/app/menus.c,v
retrieving revision 1.11
diff -u -r1.11 menus.c
--- menus.c 1999/01/25 13:24:17 1.11
+++ menus.c 1999/02/01 05:24:43
@@ -26,6 +26,8 @@
#include "menus.h"
#include "commands.h"
#include "message.h"
+#include "display.h"
+#include "interface.h"
static GtkItemFactoryEntry toolbox_menu_items[] =
{
@@ -255,4 +257,83 @@
} else {
message_error(_("Unable to set state for menu which doesn't exist: %s"), path);
}
+}
+
+/* This contains the point that was clicked to get this menu */
+static Point object_menu_clicked_point;
+
+void
+object_menu_proxy(GtkWidget *widget, gpointer data)
+{
+ ObjectMenuData *omd = (ObjectMenuData *)data;
+ DDisplay *ddisp = ddisplay_active();
+ int changed;
+ Object *obj = (Object *)ddisp->diagram->data->selected->data;
+
+ object_add_updates(obj, ddisp->diagram);
+ (omd->callback)(obj, omd->data, &object_menu_clicked_point);
+ object_add_updates(obj, ddisp->diagram);
+ diagram_flush(ddisp->diagram);
+}
+
+void
+object_menu_proxify(GtkItemFactoryEntry *menu_items, int nmenu_items)
+{
+ int i;
+ ObjectMenuData *omd;
+
+ for (i = 0; i < nmenu_items; i++) {
+ if (menu_items[i].callback != NULL) {
+ omd = g_malloc(sizeof(*omd));
+ omd->callback = menu_items[i].callback;
+ /* Is the data really put into a *guint* ? */
+ omd->data = (gpointer)menu_items[i].callback_action;
+ menu_items[i].callback = object_menu_proxy;
+ menu_items[i].callback_action = (guint)omd;
+ }
+ }
+}
+
+static GtkMenu *
+default_object_menu() {
+}
+
+void
+popup_object_menu(GdkEventButton *bevent, DDisplay *ddisp)
+{
+ Diagram *diagram;
+ real click_distance;
+ Object *obj;
+ Point clickedpoint;
+ GtkMenu *menu = NULL;
+ GList *selected_list;
+
+ diagram = ddisp->diagram;
+ if (diagram->data->selected_count != 1) return;
+ selected_list = diagram->data->selected;
+ /* Have to have exactly one selected object */
+ if (selected_list == NULL || g_list_next(selected_list) != NULL) {
+ message_error("Selected list is %s while selected_count is %d\n",
+ (selected_list?"long":"empty"), diagram->data->selected_count);
+ return;
+ }
+ obj = (Object *)g_list_first(selected_list)->data;
+ ddisplay_untransform_coords(ddisp,
+ (int)bevent->x, (int)bevent->y,
+ &clickedpoint.x, &clickedpoint.y);
+ /* Possibly react differently at a handle? */
+ /* Get its menu, if it has registered any */
+ if (obj->ops->get_object_menu) {
+ menu = (obj->ops->get_object_menu)(obj, &clickedpoint);
+ }
+ if (menu == NULL) {
+ menu = default_object_menu();
+ if (menu == NULL) {
+ message_warning("Can't open default object menu");
+ return;
+ }
+ }
+ object_menu_clicked_point = clickedpoint;
+ popup_shell = ddisp->shell;
+ gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, 0);
}
Index: app/menus.h
===================================================================
RCS file: /cvs/gnome/dia/app/menus.h,v
retrieving revision 1.3
diff -u -r1.3 menus.h
--- menus.h 1999/01/14 14:35:00 1.3
+++ menus.h 1999/02/01 05:24:43
@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
+#include <object.h>
+
extern void menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAccelGroup **accel);
extern void menus_get_image_menu (GtkWidget **menu,
@@ -29,6 +31,34 @@
int sensitive);
extern void menus_set_state (char *path, int state);
+
+typedef struct _ObjectMenu ObjectMenu;
+
+struct _ObjectMenu {
+ GtkWidget *menu;
+ GtkAccelGroup *accel_group;
+ GtkItemFactory *item_factory;
+ GtkItemFactoryEntry *menu_items;
+ int nmenu_items;
+ void (*menu_modify_callback)(Object *, ObjectMenu *, Point *);
+};
+
+typedef struct _ObjectMenuData ObjectMenuData;
+
+struct _ObjectMenuData {
+ GtkItemFactoryCallback callback;
+ gpointer data;
+};
+
+extern void object_menu_registry_init(void);
+
+extern void object_register_menu(ObjectType *objtype,
+ GtkItemFactoryEntry *menu_items[],
+ int nmenu_items);
+
+extern void menus_get_object_menu (ObjectType *objtype,
+ GtkWidget **menu,
+ GtkAccelGroup **accel_group);
#endif /* MENUS_H */
Index: app/properties.c
===================================================================
RCS file: /cvs/gnome/dia/app/properties.c,v
retrieving revision 1.6
diff -u -r1.6 properties.c
--- properties.c 1999/01/16 13:20:12 1.6
+++ properties.c 1999/02/01 05:24:43
@@ -126,6 +126,3 @@
current_dia = dia;
}
-
-
-
Index: lib/dia_xml.c
===================================================================
RCS file: /cvs/gnome/dia/lib/dia_xml.c,v
retrieving revision 1.3
diff -u -r1.3 dia_xml.c
--- dia_xml.c 1998/12/06 22:11:19 1.3
+++ dia_xml.c 1999/02/01 05:24:43
@@ -18,7 +18,7 @@
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <tree.h>
+#include <gnome-xml/tree.h>
#include "utils.h"
#include "dia_xml.h"
#include "message.h"
Index: lib/message.c
===================================================================
RCS file: /cvs/gnome/dia/lib/message.c,v
retrieving revision 1.4
diff -u -r1.4 message.c
--- message.c 1999/01/16 13:20:15 1.4
+++ message.c 1999/02/01 05:24:43
@@ -32,8 +32,11 @@
GtkWidget *dialog_window = NULL;
GtkWidget *label;
GtkWidget *button;
+ gint len;
- gint len = format_string_length_upper_bound (fmt, args);
+ vfprintf(stderr, fmt, args);
+
+ len = format_string_length_upper_bound (fmt, args);
if (len >= alloc) {
if (buf)
Index: objects/standard/arc.c
===================================================================
RCS file: /cvs/gnome/dia/objects/standard/arc.c,v
retrieving revision 1.7
diff -u -r1.7 arc.c
--- arc.c 1999/01/28 20:35:15 1.7
+++ arc.c 1999/02/01 05:24:44
@@ -53,8 +53,6 @@
Point center;
real angle1, angle2;
- ArcPropertiesDialog *properties_dialog;
-
} Arc;
typedef struct _ArcProperties {
@@ -83,6 +81,7 @@
DiaArrowTypeSelector *end_arrow;
};
+static ArcPropertiesDialog *arc_properties_dialog;
static ArcDefaultsDialog *arc_defaults_dialog;
static ArcProperties default_properties;
@@ -146,15 +145,11 @@
static void
arc_apply_properties(Arc *arc)
{
- ArcPropertiesDialog *prop_dialog;
-
- prop_dialog = arc->properties_dialog;
-
- arc->line_width = gtk_spin_button_get_value_as_float(prop_dialog->line_width);
- dia_color_selector_get_color(prop_dialog->color, &arc->arc_color);
- arc->line_style = dia_line_style_selector_get_linestyle(prop_dialog->line_style);
- arc->start_arrow = dia_arrow_type_selector_get_arrow_type(prop_dialog->start_arrow);
- arc->end_arrow = dia_arrow_type_selector_get_arrow_type(prop_dialog->end_arrow);
+ arc->line_width =
+gtk_spin_button_get_value_as_float(arc_properties_dialog->line_width);
+ dia_color_selector_get_color(arc_properties_dialog->color, &arc->arc_color);
+ arc->line_style =
+dia_line_style_selector_get_linestyle(arc_properties_dialog->line_style);
+ arc->start_arrow =
+dia_arrow_type_selector_get_arrow_type(arc_properties_dialog->start_arrow);
+ arc->end_arrow =
+dia_arrow_type_selector_get_arrow_type(arc_properties_dialog->end_arrow);
arc_update_data(arc);
@@ -163,7 +158,6 @@
static GtkWidget *
arc_get_properties(Arc *arc)
{
- ArcPropertiesDialog *prop_dialog;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
@@ -173,13 +167,12 @@
GtkWidget *line_width;
GtkAdjustment *adj;
- if (arc->properties_dialog == NULL) {
+ if (arc_properties_dialog == NULL) {
- prop_dialog = g_new(ArcPropertiesDialog, 1);
- arc->properties_dialog = prop_dialog;
+ arc_properties_dialog = g_new(ArcPropertiesDialog, 1);
vbox = gtk_vbox_new(FALSE, 5);
- prop_dialog->vbox = vbox;
+ arc_properties_dialog->vbox = vbox;
hbox = gtk_hbox_new(FALSE, 5);
label = gtk_label_new("Line width:");
@@ -189,7 +182,7 @@
line_width = gtk_spin_button_new(adj, 1.0, 2);
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(line_width), TRUE);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(line_width), TRUE);
- prop_dialog->line_width = GTK_SPIN_BUTTON(line_width);
+ arc_properties_dialog->line_width = GTK_SPIN_BUTTON(line_width);
gtk_box_pack_start(GTK_BOX (hbox), line_width, TRUE, TRUE, 0);
gtk_widget_show (line_width);
gtk_widget_show(hbox);
@@ -200,7 +193,7 @@
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_widget_show (label);
color = dia_color_selector_new();
- prop_dialog->color = DIACOLORSELECTOR(color);
+ arc_properties_dialog->color = DIACOLORSELECTOR(color);
gtk_box_pack_start (GTK_BOX (hbox), color, TRUE, TRUE, 0);
gtk_widget_show (color);
gtk_widget_show(hbox);
@@ -211,7 +204,7 @@
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_widget_show (label);
linestyle = dia_line_style_selector_new();
- prop_dialog->line_style = DIALINESTYLESELECTOR(linestyle);
+ arc_properties_dialog->line_style = DIALINESTYLESELECTOR(linestyle);
gtk_box_pack_start (GTK_BOX (hbox), linestyle, TRUE, TRUE, 0);
gtk_widget_show (linestyle);
gtk_widget_show(hbox);
@@ -222,7 +215,7 @@
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_widget_show (label);
arrow = dia_arrow_type_selector_new();
- prop_dialog->start_arrow = DIAARROWTYPESELECTOR(arrow);
+ arc_properties_dialog->start_arrow = DIAARROWTYPESELECTOR(arrow);
gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0);
gtk_widget_show (arrow);
gtk_widget_show(hbox);
@@ -233,7 +226,7 @@
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_widget_show (label);
arrow = dia_arrow_type_selector_new();
- prop_dialog->end_arrow = DIAARROWTYPESELECTOR(arrow);
+ arc_properties_dialog->end_arrow = DIAARROWTYPESELECTOR(arrow);
gtk_box_pack_start (GTK_BOX (hbox), arrow, TRUE, TRUE, 0);
gtk_widget_show (arrow);
gtk_widget_show(hbox);
@@ -243,18 +236,16 @@
gtk_widget_show (vbox);
}
- prop_dialog = arc->properties_dialog;
-
- gtk_spin_button_set_value(prop_dialog->line_width, arc->line_width);
- dia_color_selector_set_color(prop_dialog->color, &arc->arc_color);
- dia_line_style_selector_set_linestyle(prop_dialog->line_style,
+ gtk_spin_button_set_value(arc_properties_dialog->line_width, arc->line_width);
+ dia_color_selector_set_color(arc_properties_dialog->color, &arc->arc_color);
+ dia_line_style_selector_set_linestyle(arc_properties_dialog->line_style,
arc->line_style);
- dia_arrow_type_selector_set_arrow_type(prop_dialog->start_arrow,
+ dia_arrow_type_selector_set_arrow_type(arc_properties_dialog->start_arrow,
arc->start_arrow);
- dia_arrow_type_selector_set_arrow_type(prop_dialog->end_arrow,
+ dia_arrow_type_selector_set_arrow_type(arc_properties_dialog->end_arrow,
arc->end_arrow);
- return prop_dialog->vbox;
+ return arc_properties_dialog->vbox;
}
static void
@@ -460,18 +451,52 @@
endpoints = &arc->connection.endpoints[0];
- /* FIXME: Maybe these should consider angles? */
- if (arc->start_arrow != ARROW_NONE) {
- arrow_draw(renderer, arc->start_arrow,
- &endpoints[0], &endpoints[1],
- 0.8, 0.8, arc->line_width,
- &arc->arc_color, &color_white);
- }
- if (arc->end_arrow != ARROW_NONE) {
- arrow_draw(renderer, arc->end_arrow,
- &endpoints[1], &endpoints[0],
- 0.8, 0.8, arc->line_width,
- &arc->arc_color, &color_white);
+ if (arc->start_arrow != ARROW_NONE ||
+ arc->end_arrow != ARROW_NONE) {
+ Point reversepoint, centervec;
+ Point controlpoint0, controlpoint1;
+ real len, len2;
+
+ centervec = endpoints[0];
+ point_sub(¢ervec, &endpoints[1]);
+ point_scale(¢ervec, 0.5);
+ len = centervec.x*centervec.x+centervec.y*centervec.y;
+ point_add(¢ervec, &endpoints[1]);
+ /* Centervec should now be the midpoint between [0] and [1] */
+ renderer->ops->draw_line(renderer, ¢ervec, &arc->center, &color_black);
+ reversepoint = centervec;
+ point_sub(¢ervec, &arc->center);
+ len2 = centervec.x*centervec.x+centervec.y*centervec.y;
+ if (len2 != 0) {
+ point_scale(¢ervec, 1/len2);
+ }
+ point_scale(¢ervec, len);
+ point_add(&reversepoint, ¢ervec);
+ controlpoint0 = controlpoint1 = reversepoint;
+ len = arc->angle2-arc->angle1;
+ if (len > 180 || (len < 0.0 && len > -180)) {
+ printf("Flipflop\n");
+ centervec = endpoints[0];
+ point_sub(¢ervec, &reversepoint);
+ point_add(&controlpoint0, ¢ervec);
+ point_add(&controlpoint0, ¢ervec);
+ centervec = endpoints[1];
+ point_sub(¢ervec, &reversepoint);
+ point_add(&controlpoint1, ¢ervec);
+ point_add(&controlpoint1, ¢ervec);
+ }
+ if (arc->start_arrow != ARROW_NONE) {
+ arrow_draw(renderer, arc->start_arrow,
+ &endpoints[0],&controlpoint0,
+ 0.8, 0.8, arc->line_width,
+ &arc->arc_color, &color_white);
+ }
+ if (arc->end_arrow != ARROW_NONE) {
+ arrow_draw(renderer, arc->end_arrow,
+ &endpoints[1], &controlpoint1,
+ 0.8, 0.8, arc->line_width,
+ &arc->arc_color, &color_white);
+ }
}
renderer->ops->set_linewidth(renderer, arc->line_width);
@@ -516,8 +541,6 @@
arc->start_arrow = default_properties.start_arrow;
arc->end_arrow = default_properties.end_arrow;
- arc->properties_dialog = NULL;
-
conn = &arc->connection;
conn->endpoints[0] = *startpoint;
conn->endpoints[1] = *startpoint;
@@ -546,10 +569,6 @@
static void
arc_destroy(Arc *arc)
{
- if (arc->properties_dialog != NULL) {
- gtk_widget_destroy(arc->properties_dialog->vbox);
- g_free(arc->properties_dialog);
- }
connection_destroy(&arc->connection);
}
@@ -583,8 +602,6 @@
newarc->middle_handle = arc->middle_handle;
- newarc->properties_dialog = NULL;
-
return (Object *)newarc;
}
@@ -731,8 +748,6 @@
attr = object_find_attribute(obj_node, "end_arrow");
if (attr != NULL)
arc->end_arrow = data_enum(attribute_first_data(attr));
-
- arc->properties_dialog = NULL;
connection_init(conn, 3, 0);
Index: objects/standard/box.c
===================================================================
RCS file: /cvs/gnome/dia/objects/standard/box.c,v
retrieving revision 1.6
diff -u -r1.6 box.c
--- box.c 1998/12/05 17:01:44 1.6
+++ box.c 1999/02/01 05:24:44
@@ -34,6 +34,7 @@
typedef struct _Box Box;
typedef struct _BoxPropertiesDialog BoxPropertiesDialog;
+typedef struct _BoxDefaultsDialog BoxDefaultsDialog;
struct _Box {
Element element;
@@ -48,6 +49,13 @@
BoxPropertiesDialog *properties_dialog;
};
+typedef struct _BoxProperties {
+ Color *fg_color;
+ Color *bg_color;
+ real border_width;
+ LineStyle line_style;
+} BoxProperties;
+
struct _BoxPropertiesDialog {
GtkWidget *vbox;
@@ -57,6 +65,15 @@
DiaLineStyleSelector *line_style;
};
+struct _BoxDefaultsDialog {
+ GtkWidget *vbox;
+
+ DiaLineStyleSelector *line_style;
+};
+
+static BoxDefaultsDialog *box_defaults_dialog;
+static BoxProperties default_properties;
+
static real box_distance_from(Box *box, Point *point);
static void box_select(Box *box, Point *clicked_point,
Renderer *interactive_renderer);
@@ -76,12 +93,16 @@
static void box_save(Box *box, ObjectNode obj_node );
static Object *box_load(ObjectNode obj_node, int version);
+static GtkWidget *box_get_defaults();
+static void box_apply_defaults();
static ObjectTypeOps box_type_ops =
{
(CreateFunc) box_create,
(LoadFunc) box_load,
- (SaveFunc) box_save
+ (SaveFunc) box_save,
+ (GetDefaultsFunc) box_get_defaults,
+ (ApplyDefaultsFunc) box_apply_defaults
};
ObjectType box_type =
@@ -204,6 +225,46 @@
return prop_dialog->vbox;
}
+static void
+box_apply_defaults()
+{
+ default_properties.line_style =
+dia_line_style_selector_get_linestyle(box_defaults_dialog->line_style);
+}
+
+static GtkWidget *
+box_get_defaults()
+{
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *linestyle;
+
+ if (box_defaults_dialog == NULL) {
+
+ box_defaults_dialog = g_new(BoxDefaultsDialog, 1);
+
+ vbox = gtk_vbox_new(FALSE, 5);
+ box_defaults_dialog->vbox = vbox;
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ label = gtk_label_new("Line style:");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ gtk_widget_show (label);
+ linestyle = dia_line_style_selector_new();
+ box_defaults_dialog->line_style = DIALINESTYLESELECTOR(linestyle);
+ gtk_box_pack_start (GTK_BOX (hbox), linestyle, TRUE, TRUE, 0);
+ gtk_widget_show (linestyle);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+ gtk_widget_show (vbox);
+ }
+
+ dia_line_style_selector_set_linestyle(box_defaults_dialog->line_style,
+ default_properties.line_style);
+
+ return box_defaults_dialog->vbox;
+}
static real
box_distance_from(Box *box, Point *point)
@@ -341,7 +402,7 @@
box->border_width = attributes_get_default_linewidth();
box->border_color = attributes_get_foreground();
box->inner_color = attributes_get_background();
- box->line_style = LINESTYLE_SOLID;
+ box->line_style = default_properties.line_style;
element_init(elem, 8, 8);
Index: objects/standard/ellipse.c
===================================================================
RCS file: /cvs/gnome/dia/objects/standard/ellipse.c,v
retrieving revision 1.6
diff -u -r1.6 ellipse.c
--- ellipse.c 1999/01/14 14:37:00 1.6
+++ ellipse.c 1999/02/01 05:24:44
@@ -34,6 +34,7 @@
typedef struct _Ellipse Ellipse;
typedef struct _EllipsePropertiesDialog EllipsePropertiesDialog;
+typedef struct _EllipseDefaultsDialog EllipseDefaultsDialog;
struct _Ellipse {
Element element;
@@ -48,6 +49,14 @@
EllipsePropertiesDialog *properties_dialog;
};
+
+typedef struct _BoxProperties {
+ Color *fg_color;
+ Color *bg_color;
+ real border_width;
+ LineStyle line_style;
+} BoxProperties;
+
struct _EllipsePropertiesDialog {
GtkWidget *vbox;
@@ -56,7 +65,15 @@
DiaColorSelector *bg_color;
DiaLineStyleSelector *line_style;
};
+struct _EllipseDefaultsDialog {
+ GtkWidget *vbox;
+
+ DiaLineStyleSelector *line_style;
+};
+static EllipseDefaultsDialog *ellipse_defaults_dialog;
+static BoxProperties default_properties;
+
static real ellipse_distance_from(Ellipse *ellipse, Point *point);
static void ellipse_select(Ellipse *ellipse, Point *clicked_point,
Renderer *interactive_renderer);
@@ -76,12 +93,16 @@
static void ellipse_save(Ellipse *ellipse, ObjectNode obj_node);
static Object *ellipse_load(ObjectNode obj_node, int version);
+static GtkWidget *ellipse_get_defaults();
+static void ellipse_apply_defaults();
static ObjectTypeOps ellipse_type_ops =
{
(CreateFunc) ellipse_create,
(LoadFunc) ellipse_load,
- (SaveFunc) ellipse_save
+ (SaveFunc) ellipse_save,
+ (GetDefaultsFunc) ellipse_get_defaults,
+ (ApplyDefaultsFunc) ellipse_apply_defaults
};
ObjectType ellipse_type =
@@ -205,6 +226,46 @@
return prop_dialog->vbox;
}
+static void
+ellipse_apply_defaults()
+{
+ default_properties.line_style =
+dia_line_style_selector_get_linestyle(ellipse_defaults_dialog->line_style);
+}
+
+static GtkWidget *
+ellipse_get_defaults()
+{
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *linestyle;
+
+ if (ellipse_defaults_dialog == NULL) {
+
+ ellipse_defaults_dialog = g_new(EllipseDefaultsDialog, 1);
+
+ vbox = gtk_vbox_new(FALSE, 5);
+ ellipse_defaults_dialog->vbox = vbox;
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ label = gtk_label_new("Line style:");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ gtk_widget_show (label);
+ linestyle = dia_line_style_selector_new();
+ ellipse_defaults_dialog->line_style = DIALINESTYLESELECTOR(linestyle);
+ gtk_box_pack_start (GTK_BOX (hbox), linestyle, TRUE, TRUE, 0);
+ gtk_widget_show (linestyle);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+ gtk_widget_show (vbox);
+ }
+
+ dia_line_style_selector_set_linestyle(ellipse_defaults_dialog->line_style,
+ default_properties.line_style);
+
+ return ellipse_defaults_dialog->vbox;
+}
static real
ellipse_distance_from(Ellipse *ellipse, Point *point)
@@ -341,7 +402,7 @@
ellipse->border_width = attributes_get_default_linewidth();
ellipse->border_color = attributes_get_foreground();
ellipse->inner_color = attributes_get_background();
- ellipse->line_style = LINESTYLE_SOLID;
+ ellipse->line_style = default_properties.line_style;
ellipse->properties_dialog = NULL;
Index: objects/standard/textobj.c
===================================================================
RCS file: /cvs/gnome/dia/objects/standard/textobj.c,v
retrieving revision 1.6
diff -u -r1.6 textobj.c
--- textobj.c 1998/12/05 17:01:48 1.6
+++ textobj.c 1999/02/01 05:24:44
@@ -33,6 +33,7 @@
typedef struct _Textobj Textobj;
typedef struct _TextobjPropertiesDialog TextobjPropertiesDialog;
+typedef struct _TextobjDefaultsDialog TextobjDefaultsDialog;
struct _Textobj {
Object object;
@@ -44,6 +45,13 @@
TextobjPropertiesDialog *properties_dialog;
};
+typedef struct _TextobjProperties {
+ real height;
+ Font *font;
+ Alignment alignment;
+ Color color;
+} TextobjProperties;
+
struct _TextobjPropertiesDialog {
GtkWidget *vbox;
@@ -53,6 +61,18 @@
DiaColorSelector *color;
};
+struct _TextobjDefaultsDialog {
+ GtkWidget *vbox;
+
+ DiaAlignmentSelector *alignment;
+ DiaFontSelector *font;
+ GtkSpinButton *font_size;
+};
+
+static TextobjDefaultsDialog *textobj_defaults_dialog;
+static TextobjProperties default_properties =
+{ 1.0, NULL, ALIGN_CENTER }; /* Can't initialize the font here */
+
static real textobj_distance_from(Textobj *textobj, Point *point);
static void textobj_select(Textobj *textobj, Point *clicked_point,
Renderer *interactive_renderer);
@@ -73,12 +93,16 @@
static void textobj_save(Textobj *textobj, ObjectNode obj_node);
static Object *textobj_load(ObjectNode obj_node, int version);
static int textobj_is_empty(Textobj *textobj);
+static GtkWidget *textobj_get_defaults();
+static void textobj_apply_defaults();
static ObjectTypeOps textobj_type_ops =
{
(CreateFunc) textobj_create,
(LoadFunc) textobj_load,
- (SaveFunc) textobj_save
+ (SaveFunc) textobj_save,
+ (GetDefaultsFunc) textobj_get_defaults,
+ (ApplyDefaultsFunc) textobj_apply_defaults
};
ObjectType textobj_type =
@@ -211,6 +235,87 @@
return textobj->properties_dialog->vbox;
}
+static void
+textobj_apply_defaults()
+{
+ default_properties.alignment =
+dia_alignment_selector_get_alignment(textobj_defaults_dialog->alignment);
+
+ default_properties.font = dia_font_selector_get_font(textobj_defaults_dialog->font);
+
+ default_properties.height =
+gtk_spin_button_get_value_as_float(textobj_defaults_dialog->font_size);
+}
+
+void
+init_defaults()
+{
+ if (default_properties.font == NULL)
+ default_properties.font = font_getfont("Courier");
+}
+
+static GtkWidget *
+textobj_get_defaults()
+{
+ GtkWidget *alignment;
+ GtkWidget *font;
+ GtkWidget *font_size;
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *label;
+ GtkAdjustment *adj;
+
+ if (textobj_defaults_dialog == NULL) {
+ textobj_defaults_dialog = g_new(TextobjDefaultsDialog, 1);
+
+ vbox = gtk_vbox_new(FALSE, 5);
+ textobj_defaults_dialog->vbox = vbox;
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ label = gtk_label_new("Alignment:");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ gtk_widget_show (label);
+ alignment = dia_alignment_selector_new();
+ textobj_defaults_dialog->alignment = DIAALIGNMENTSELECTOR(alignment);
+ gtk_box_pack_start (GTK_BOX (hbox), alignment, TRUE, TRUE, 0);
+ gtk_widget_show (alignment);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ label = gtk_label_new("Font:");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ gtk_widget_show (label);
+ font = dia_font_selector_new();
+ textobj_defaults_dialog->font = DIAFONTSELECTOR(font);
+ gtk_box_pack_start (GTK_BOX (hbox), font, TRUE, TRUE, 0);
+ gtk_widget_show (font);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ label = gtk_label_new("Fontsize:");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+ gtk_widget_show (label);
+ adj = (GtkAdjustment *) gtk_adjustment_new(0.1, 0.1, 10.0, 0.1, 0.0, 0.0);
+ font_size = gtk_spin_button_new(adj, 1.0, 2);
+ gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(font_size), TRUE);
+ gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(font_size), TRUE);
+ textobj_defaults_dialog->font_size = GTK_SPIN_BUTTON(font_size);
+ gtk_box_pack_start(GTK_BOX (hbox), font_size, TRUE, TRUE, 0);
+ gtk_widget_show (font_size);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+ gtk_widget_show (vbox);
+ }
+
+ init_defaults();
+
+ dia_alignment_selector_set_alignment(textobj_defaults_dialog->alignment,
+default_properties.alignment);
+ dia_font_selector_set_font(textobj_defaults_dialog->font, default_properties.font);
+ gtk_spin_button_set_value(textobj_defaults_dialog->font_size,
+default_properties.height);
+
+ return textobj_defaults_dialog->vbox;
+}
static real
textobj_distance_from(Textobj *textobj, Point *point)
@@ -293,10 +398,11 @@
obj->ops = &textobj_ops;
+ init_defaults();
col = attributes_get_foreground();
- textobj->text = new_text("", font_getfont("Courier"), 1.0,
- startpoint, &col, ALIGN_CENTER );
+ textobj->text = new_text("", default_properties.font, default_properties.height,
+ startpoint, &col, default_properties.alignment );
textobj->properties_dialog = NULL;
--
Lars R. Clausen ([EMAIL PROTECTED])
A *real* smart bomb would call in sick, perhaps move to another country,
changing its name in the process, open a beach bar maybe and live out its
days in safe anonymity. -- Barry O'Neill in rhod