[dia] selectors: split widgets.{c,h} into seperate files
- From: Zander Brown <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] selectors: split widgets.{c,h} into seperate files
- Date: Wed, 22 Sep 2021 23:23:55 +0000 (UTC)
commit 47a6eded98cea8e8d7c897d72f4c76e19c23d752
Author: Zander Brown <zbrown gnome org>
Date: Wed Sep 22 22:31:10 2021 +0100
selectors: split widgets.{c,h} into seperate files
Reduce the number of things needlessly including widgets.h
Cleanup the selectors to use modern type registration
app/dia-page-layout.c | 2 +-
app/dia-props.c | 35 +-
app/preferences.c | 45 +-
app/sheet-editor/sheets.c | 1 -
lib/arrows.c | 1 -
lib/arrows.h | 7 +
lib/{diaarrowselector.c => dia-arrow-selector.c} | 77 ++-
lib/dia-arrow-selector.h | 38 ++
lib/{diacolorselector.c => dia-colour-selector.c} | 70 +--
lib/dia-colour-selector.h | 41 ++
lib/dia-file-selector.c | 234 ++++++++
lib/dia-file-selector.h | 39 ++
lib/{diafontselector.c => dia-font-selector.c} | 16 +-
lib/{diafontselector.h => dia-font-selector.h} | 13 +-
...nestyleselector.c => dia-line-style-selector.c} | 103 ++--
lib/dia-line-style-selector.h | 41 ++
lib/dia-size-selector.c | 244 ++++++++
lib/dia-size-selector.h | 43 ++
lib/dia-unit-spinner.c | 205 +++++++
lib/dia-unit-spinner.h | 42 ++
lib/diaarrowchooser.c | 2 +-
lib/diaarrowchooser.h | 1 +
lib/dialinechooser.c | 4 +-
lib/dialinechooser.h | 4 +-
lib/diatypes.h | 13 -
lib/dummy_dep.h | 2 +-
lib/libdia.def | 10 +-
lib/meson.build | 42 +-
lib/prefs.c | 1 -
lib/prop_attr.c | 51 +-
lib/prop_dict.c | 1 -
lib/prop_geomtypes.c | 2 +-
lib/prop_matrix.c | 1 -
lib/prop_pattern.c | 1 -
lib/prop_pixbuf.c | 1 -
lib/prop_sdarray.c | 1 -
lib/prop_text.c | 29 +-
lib/prop_widgets.c | 1 -
lib/propdialogs.c | 1 -
lib/widgets.c | 651 ---------------------
lib/widgets.h | 120 +---
objects/UML/class_dialog.c | 41 +-
objects/UML/class_dialog.h | 9 +-
43 files changed, 1227 insertions(+), 1059 deletions(-)
---
diff --git a/app/dia-page-layout.c b/app/dia-page-layout.c
index 49450322a..c58fa138a 100644
--- a/app/dia-page-layout.c
+++ b/app/dia-page-layout.c
@@ -24,7 +24,6 @@
#include <config.h>
#include "dia-page-layout.h"
-#include "widgets.h"
#include "intl.h"
@@ -37,6 +36,7 @@
#include "diamarshal.h"
#include "diaoptionmenu.h"
+#include "dia-unit-spinner.h"
struct _DiaPageLayout {
diff --git a/app/dia-props.c b/app/dia-props.c
index 6b785cb72..e0e6efb4d 100644
--- a/app/dia-props.c
+++ b/app/dia-props.c
@@ -27,10 +27,9 @@
#include "intl.h"
#include "display.h"
-#include "widgets.h"
-#include "display.h"
#include "undo.h"
#include "dia-builder.h"
+#include "dia-colour-selector.h"
typedef struct _DiaDiagramPropertiesDialogPrivate DiaDiagramPropertiesDialogPrivate;
@@ -179,14 +178,14 @@ dia_diagram_properties_dialog_response (GtkDialog *dialog,
priv->diagram->grid.hex =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->hex));
priv->diagram->grid.hex_size = gtk_adjustment_get_value (priv->hex_size);
- dia_color_selector_get_color (priv->background,
- &priv->diagram->data->bg_color);
- dia_color_selector_get_color (priv->grid_lines,
- &priv->diagram->grid.colour);
- dia_color_selector_get_color (priv->page_lines,
- &priv->diagram->pagebreak_color);
- dia_color_selector_get_color (priv->guide_lines,
- &priv->diagram->guide_color);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (priv->background),
+ &priv->diagram->data->bg_color);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (priv->grid_lines),
+ &priv->diagram->grid.colour);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (priv->page_lines),
+ &priv->diagram->pagebreak_color);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (priv->guide_lines),
+ &priv->diagram->guide_color);
diagram_add_update_all (priv->diagram);
diagram_flush (priv->diagram);
diagram_set_modified (priv->diagram, TRUE);
@@ -370,14 +369,14 @@ dia_diagram_properties_dialog_set_diagram (DiaDiagramPropertiesDialog *self,
gtk_adjustment_set_value (priv->hex_size, diagram->grid.hex_size);
- dia_color_selector_set_color (priv->background,
- &diagram->data->bg_color);
- dia_color_selector_set_color (priv->grid_lines,
- &diagram->grid.colour);
- dia_color_selector_set_color (priv->page_lines,
- &diagram->pagebreak_color);
- dia_color_selector_set_color (priv->guide_lines,
- &diagram->guide_color);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (priv->background),
+ &diagram->data->bg_color);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (priv->grid_lines),
+ &diagram->grid.colour);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (priv->page_lines),
+ &diagram->pagebreak_color);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (priv->guide_lines),
+ &diagram->guide_color);
update_sensitivity (GTK_TOGGLE_BUTTON (priv->dynamic), self);
diff --git a/app/preferences.c b/app/preferences.c
index 2487520f0..f7d798e92 100644
--- a/app/preferences.c
+++ b/app/preferences.c
@@ -25,7 +25,6 @@
#include <gtk/gtk.h>
#include "intl.h"
-#include "widgets.h"
#include "diagram.h"
#include "message.h"
#include "preferences.h"
@@ -37,6 +36,7 @@
#include "persistence.h"
#include "filter.h"
#include "dia-builder.h"
+#include "dia-colour-selector.h"
#include "units.h"
@@ -281,11 +281,10 @@ dd_type_changed (GtkComboBox *combo,
static void
-dd_background_changed (DiaColorSelector *selector,
- gpointer data)
+dd_background_changed (DiaColourSelector *selector,
+ gpointer data)
{
- dia_color_selector_get_color (GTK_WIDGET (selector),
- &prefs.new_diagram.bg_color);
+ dia_colour_selector_get_colour (selector, &prefs.new_diagram.bg_color);
persistence_set_color ("new_diagram_bgcolour", &prefs.new_diagram.bg_color);
}
@@ -394,11 +393,10 @@ vd_pb_visible_toggled (GtkCheckButton *check,
static void
-vd_pb_colour_changed (DiaColorSelector *selector,
- gpointer data)
+vd_pb_colour_changed (DiaColourSelector *selector,
+ gpointer data)
{
- dia_color_selector_get_color (GTK_WIDGET (selector),
- &prefs.new_diagram.pagebreak_color);
+ dia_colour_selector_get_colour (selector, &prefs.new_diagram.pagebreak_color);
persistence_set_color ("pagebreak_colour", &prefs.new_diagram.pagebreak_color);
}
@@ -431,11 +429,10 @@ vd_guide_snap_toggled (GtkCheckButton *check,
static void
-vd_guide_colour_changed (GtkCheckButton *selector,
- gpointer data)
+vd_guide_colour_changed (DiaColourSelector *selector,
+ gpointer data)
{
- dia_color_selector_get_color (GTK_WIDGET (selector),
- &prefs.new_diagram.guide_color);
+ dia_colour_selector_get_colour (selector, &prefs.new_diagram.guide_color);
persistence_set_color ("guide_colour", &prefs.new_diagram.guide_color);
}
@@ -595,11 +592,10 @@ gl_snap_toggled (GtkCheckButton *check,
static void
-gl_color_changed (DiaColorSelector *selector,
- gpointer data)
+gl_color_changed (DiaColourSelector *selector,
+ gpointer data)
{
- dia_color_selector_get_color (GTK_WIDGET (selector),
- &prefs.new_diagram.grid_color);
+ dia_colour_selector_get_colour (selector, &prefs.new_diagram.grid_color);
persistence_set_color ("grid_colour", &prefs.new_diagram.grid_color);
}
@@ -888,7 +884,8 @@ dia_preferences_dialog_init (DiaPreferencesDialog *self)
gtk_tree_model_foreach (GTK_TREE_MODEL (paper),
set_current_paper,
&find_paper);
- dia_color_selector_set_color (dd_background, &prefs.new_diagram.bg_color);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (dd_background),
+ &prefs.new_diagram.bg_color);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dd_compress),
prefs.new_diagram.compress_save);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dd_cp_visible),
@@ -904,16 +901,16 @@ dia_preferences_dialog_init (DiaPreferencesDialog *self)
prefs.view_antialiased);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vd_pb_visible),
prefs.pagebreak.visible);
- dia_color_selector_set_color (vd_pb_colour,
- &prefs.new_diagram.pagebreak_color);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (vd_pb_colour),
+ &prefs.new_diagram.pagebreak_color);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vd_pb_solid),
prefs.pagebreak.visible);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vd_guide_visible),
prefs.guides_visible);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vd_guide_snap),
prefs.guides_snap);
- dia_color_selector_set_color (vd_guide_colour,
- &prefs.new_diagram.guide_color);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (vd_guide_colour),
+ &prefs.new_diagram.guide_color);
find_filter.combo = fv_png;
@@ -947,8 +944,8 @@ dia_preferences_dialog_init (DiaPreferencesDialog *self)
prefs.grid.visible);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gl_snap),
prefs.grid.snap);
- dia_color_selector_set_color (gl_color,
- &prefs.new_diagram.grid_color);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (gl_color),
+ &prefs.new_diagram.grid_color);
gtk_adjustment_set_value (gl_lines_adj,
prefs.grid.major_lines);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->gl_dynamic),
diff --git a/app/sheet-editor/sheets.c b/app/sheet-editor/sheets.c
index a4fbe780f..e59d36c30 100644
--- a/app/sheet-editor/sheets.c
+++ b/app/sheet-editor/sheets.c
@@ -40,7 +40,6 @@
#include "preferences.h"
#include "toolbox.h" /* just for interface_current_sheet_name */
#include "commands.h" /* sheets_dialog_show_callback */
-#include "widgets.h"
GtkWidget *sheets_dialog = NULL;
GSList *sheets_mods_list = NULL;
diff --git a/lib/arrows.c b/lib/arrows.c
index 4e2ba1320..c58ef988a 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -40,7 +40,6 @@
#include "arrows.h"
#include "diarenderer.h"
#include "attributes.h"
-#include "widgets.h"
#include "intl.h"
/**
diff --git a/lib/arrows.h b/lib/arrows.h
index 221293e2e..67e6dd6fa 100644
--- a/lib/arrows.h
+++ b/lib/arrows.h
@@ -120,6 +120,13 @@ typedef enum {
*/
#define DEFAULT_ARROW_SIZE 0.5
+
+/* Originally in widgets.h - Do we need these? */
+#define DEFAULT_ARROW ARROW_NONE
+#define DEFAULT_ARROW_LENGTH DEFAULT_ARROW_SIZE
+#define DEFAULT_ARROW_WIDTH DEFAULT_ARROW_SIZE
+
+
/**
* MIN_ARROW_DIMENSION:
*
diff --git a/lib/diaarrowselector.c b/lib/dia-arrow-selector.c
similarity index 76%
rename from lib/diaarrowselector.c
rename to lib/dia-arrow-selector.c
index 0cdcbd181..9ba872489 100644
--- a/lib/diaarrowselector.c
+++ b/lib/dia-arrow-selector.c
@@ -16,17 +16,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include "intl.h"
-#include "widgets.h"
-#include "arrows.h"
-#include "diaarrowchooser.h"
#include "dia-arrow-cell-renderer.h"
-
-/************* DiaArrowSelector: ***************/
+#include "dia-arrow-selector.h"
+#include "dia-size-selector.h"
enum {
@@ -35,9 +32,7 @@ enum {
};
-/* FIXME: Should these structs be in widgets.h instead? */
-struct _DiaArrowSelector
-{
+struct _DiaArrowSelector {
GtkVBox vbox;
GtkHBox *sizebox;
@@ -50,10 +45,6 @@ struct _DiaArrowSelector
ArrowType looking_for;
};
-struct _DiaArrowSelectorClass
-{
- GtkVBoxClass parent_class;
-};
G_DEFINE_TYPE (DiaArrowSelector, dia_arrow_selector, GTK_TYPE_VBOX)
@@ -83,13 +74,12 @@ dia_arrow_selector_class_init (DiaArrowSelectorClass *klass)
object_class->finalize = dia_arrow_selector_finalize;
- das_signals[DAS_VALUE_CHANGED]
- = g_signal_new("value_changed",
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ das_signals[DAS_VALUE_CHANGED] = g_signal_new ("value_changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
@@ -106,8 +96,10 @@ set_size_sensitivity (DiaArrowSelector *as)
COL_ARROW, &active,
-1);
- gtk_widget_set_sensitive (GTK_WIDGET (as->sizelabel), active->type != ARROW_NONE);
- gtk_widget_set_sensitive (GTK_WIDGET (as->size), active->type != ARROW_NONE);
+ gtk_widget_set_sensitive (GTK_WIDGET (as->sizelabel),
+ active->type != ARROW_NONE);
+ gtk_widget_set_sensitive (GTK_WIDGET (as->size),
+ active->type != ARROW_NONE);
dia_arrow_free (active);
} else {
@@ -122,15 +114,17 @@ arrow_type_change_callback (GtkComboBox *widget, gpointer userdata)
{
set_size_sensitivity (DIA_ARROW_SELECTOR (userdata));
g_signal_emit (DIA_ARROW_SELECTOR (userdata),
- das_signals[DAS_VALUE_CHANGED], 0);
+ das_signals[DAS_VALUE_CHANGED],
+ 0);
}
static void
arrow_size_change_callback(DiaSizeSelector *size, gpointer userdata)
{
- g_signal_emit(DIA_ARROW_SELECTOR(userdata),
- das_signals[DAS_VALUE_CHANGED], 0);
+ g_signal_emit (DIA_ARROW_SELECTOR (userdata),
+ das_signals[DAS_VALUE_CHANGED],
+ 0);
}
@@ -172,25 +166,26 @@ dia_arrow_selector_init (DiaArrowSelector *as)
gtk_box_pack_start (GTK_BOX (as), as->combo, FALSE, TRUE, 0);
gtk_widget_show (as->combo);
- box = gtk_hbox_new(FALSE,0);
- as->sizebox = GTK_HBOX(box);
+ box = gtk_hbox_new (FALSE,0);
+ as->sizebox = GTK_HBOX (box);
- label = gtk_label_new(_("Size: "));
- as->sizelabel = GTK_LABEL(label);
- gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
- gtk_widget_show(label);
+ label = gtk_label_new (_("Size: "));
+ as->sizelabel = GTK_LABEL (label);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ gtk_widget_show (label);
- size = dia_size_selector_new(0.0, 0.0);
- as->size = DIA_SIZE_SELECTOR(size);
- gtk_box_pack_start(GTK_BOX(box), size, TRUE, TRUE, 0);
- gtk_widget_show(size);
- g_signal_connect(size, "value-changed",
- G_CALLBACK(arrow_size_change_callback), as);
+ size = dia_size_selector_new (0.0, 0.0);
+ as->size = DIA_SIZE_SELECTOR (size);
+ gtk_box_pack_start (GTK_BOX (box), size, TRUE, TRUE, 0);
+ gtk_widget_show (size);
+ g_signal_connect (size,
+ "value-changed", G_CALLBACK (arrow_size_change_callback),
+ as);
- set_size_sensitivity(as);
- gtk_box_pack_start(GTK_BOX(as), box, TRUE, TRUE, 0);
+ set_size_sensitivity (as);
+ gtk_box_pack_start (GTK_BOX (as), box, TRUE, TRUE, 0);
- gtk_widget_show(box);
+ gtk_widget_show (box);
}
diff --git a/lib/dia-arrow-selector.h b/lib/dia-arrow-selector.h
new file mode 100644
index 000000000..4c1ef5f0c
--- /dev/null
+++ b/lib/dia-arrow-selector.h
@@ -0,0 +1,38 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "arrows.h"
+#include "dia-autoptr.h"
+
+G_BEGIN_DECLS
+
+#define DIA_TYPE_ARROW_SELECTOR dia_arrow_selector_get_type ()
+G_DECLARE_FINAL_TYPE (DiaArrowSelector, dia_arrow_selector, DIA, ARROW_SELECTOR, GtkVBox)
+
+GtkWidget *dia_arrow_selector_new (void);
+Arrow dia_arrow_selector_get_arrow (DiaArrowSelector *as);
+void dia_arrow_selector_set_arrow (DiaArrowSelector *as,
+ Arrow arrow);
+
+G_END_DECLS
diff --git a/lib/diacolorselector.c b/lib/dia-colour-selector.c
similarity index 89%
rename from lib/diacolorselector.c
rename to lib/dia-colour-selector.c
index 8700cf9bf..bff1fef54 100644
--- a/lib/diacolorselector.c
+++ b/lib/dia-colour-selector.c
@@ -15,16 +15,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include "intl.h"
-#include "persistence.h"
-#include "widgets.h"
+#include "dia-colour-selector.h"
#include "dia-colour-cell-renderer.h"
-
-/************* DiaColorSelector: ***************/
+#include "persistence.h"
#define PERSIST_NAME "color-menu"
@@ -42,7 +41,7 @@ enum {
N_COL
};
-struct _DiaColorSelector {
+struct _DiaColourSelector {
GtkHBox hbox;
gboolean use_alpha;
@@ -62,15 +61,7 @@ struct _DiaColorSelector {
GtkWidget *dialog;
};
-
-struct _DiaColorSelectorClass
-{
- GtkHBoxClass parent_class;
-};
-
-
-G_DEFINE_TYPE (DiaColorSelector, dia_color_selector, GTK_TYPE_VBOX)
-
+G_DEFINE_TYPE (DiaColourSelector, dia_colour_selector, GTK_TYPE_VBOX)
enum {
DIA_COLORSEL_VALUE_CHANGED,
@@ -80,23 +71,23 @@ static guint dia_colorsel_signals[DIA_COLORSEL_LAST_SIGNAL] = { 0 };
static void
-dia_color_selector_finalize (GObject *object)
+dia_colour_selector_finalize (GObject *object)
{
- DiaColorSelector *self = DIACOLORSELECTOR (object);
+ DiaColourSelector *self = DIA_COLOUR_SELECTOR (object);
g_clear_object (&self->colour_store);
g_clear_pointer (&self->current, dia_colour_free);
- G_OBJECT_CLASS (dia_color_selector_parent_class)->finalize (object);
+ G_OBJECT_CLASS (dia_colour_selector_parent_class)->finalize (object);
}
static void
-dia_color_selector_class_init (DiaColorSelectorClass *klass)
+dia_colour_selector_class_init (DiaColourSelectorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = dia_color_selector_finalize;
+ object_class->finalize = dia_colour_selector_finalize;
dia_colorsel_signals[DIA_COLORSEL_VALUE_CHANGED]
= g_signal_new ("value_changed",
@@ -109,7 +100,7 @@ dia_color_selector_class_init (DiaColorSelectorClass *klass)
static void
-add_colour (DiaColorSelector *cs, char *hex)
+add_colour (DiaColourSelector *cs, char *hex)
{
GtkTreeIter iter;
Color colour;
@@ -128,7 +119,7 @@ add_colour (DiaColorSelector *cs, char *hex)
static void
colour_selected (GtkWidget *ok, gpointer userdata)
{
- DiaColorSelector *cs = DIACOLORSELECTOR (userdata);
+ DiaColourSelector *cs = DIA_COLOUR_SELECTOR (userdata);
GdkColor gcol;
Color colour;
GtkWidget *cs2 = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (cs->dialog));
@@ -139,7 +130,7 @@ colour_selected (GtkWidget *ok, gpointer userdata)
colour.alpha = gtk_color_selection_get_current_alpha (GTK_COLOR_SELECTION (cs2)) / 65535.0;
- dia_color_selector_set_color (GTK_WIDGET (cs), &colour);
+ dia_colour_selector_set_colour (cs, &colour);
gtk_widget_destroy (cs->dialog);
cs->dialog = NULL;
@@ -149,16 +140,16 @@ colour_selected (GtkWidget *ok, gpointer userdata)
static void
colour_select_cancelled (GtkWidget *ok, gpointer userdata)
{
- DiaColorSelector *cs = DIACOLORSELECTOR (userdata);
+ DiaColourSelector *cs = DIA_COLOUR_SELECTOR (userdata);
- dia_color_selector_set_color (GTK_WIDGET (cs), cs->current);
+ dia_colour_selector_set_colour (cs, cs->current);
gtk_widget_destroy (cs->dialog);
cs->dialog = NULL;
}
static void
-more_colours (DiaColorSelector *cs)
+more_colours (DiaColourSelector *cs)
{
GtkWidget *colorsel;
GString *palette = g_string_new ("");
@@ -251,7 +242,7 @@ more_colours (DiaColorSelector *cs)
static void
changed (GtkComboBox *widget, gpointer user_data)
{
- DiaColorSelector *cs = DIACOLORSELECTOR (user_data);
+ DiaColourSelector *cs = DIA_COLOUR_SELECTOR (user_data);
GtkTreeIter active;
GtkTreeIter iter;
GtkTreePath *path;
@@ -307,7 +298,7 @@ changed (GtkComboBox *widget, gpointer user_data)
gtk_tree_path_free (end_path);
if (cs->current) {
- dia_color_selector_set_color (GTK_WIDGET (cs), cs->current);
+ dia_colour_selector_set_colour (cs, cs->current);
} else {
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (cs->colour_store), &iter);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (cs->combo), &iter);
@@ -335,7 +326,7 @@ is_separator (GtkTreeModel *model,
static void
-dia_color_selector_init (DiaColorSelector *cs)
+dia_colour_selector_init (DiaColourSelector *cs)
{
GtkCellRenderer *renderer;
GList *tmplist;
@@ -415,25 +406,22 @@ dia_color_selector_init (DiaColorSelector *cs)
void
-dia_color_selector_set_use_alpha (GtkWidget *widget, gboolean use_alpha)
+dia_colour_selector_set_use_alpha (DiaColourSelector *cs, gboolean use_alpha)
{
- DiaColorSelector *cs = DIACOLORSELECTOR(widget);
-
cs->use_alpha = use_alpha;
}
GtkWidget *
-dia_color_selector_new (void)
+dia_colour_selector_new (void)
{
- return g_object_new (dia_color_selector_get_type (), NULL);
+ return g_object_new (DIA_TYPE_COLOUR_SELECTOR, NULL);
}
void
-dia_color_selector_get_color (GtkWidget *widget, Color *color)
+dia_colour_selector_get_colour (DiaColourSelector *cs, Color *color)
{
- DiaColorSelector *cs = DIACOLORSELECTOR(widget);
GtkTreeIter iter;
Color *colour;
@@ -463,7 +451,7 @@ set_colour (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- DiaColorSelector *self = DIACOLORSELECTOR (data);
+ DiaColourSelector *self = DIA_COLOUR_SELECTOR (data);
Color *colour;
gboolean res = FALSE;
@@ -490,11 +478,9 @@ set_colour (GtkTreeModel *model,
void
-dia_color_selector_set_color (GtkWidget *widget,
- const Color *color)
+dia_colour_selector_set_colour (DiaColourSelector *cs,
+ const Color *color)
{
- DiaColorSelector *cs = DIACOLORSELECTOR(widget);
-
cs->looking_for = color;
cs->found = FALSE;
gtk_tree_model_foreach (GTK_TREE_MODEL (cs->colour_store), set_colour, cs);
diff --git a/lib/dia-colour-selector.h b/lib/dia-colour-selector.h
new file mode 100644
index 000000000..04339e2af
--- /dev/null
+++ b/lib/dia-colour-selector.h
@@ -0,0 +1,41 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "color.h"
+#include "dia-autoptr.h"
+
+G_BEGIN_DECLS
+
+#define DIA_TYPE_COLOUR_SELECTOR dia_colour_selector_get_type ()
+G_DECLARE_FINAL_TYPE (DiaColourSelector, dia_colour_selector, DIA, COLOUR_SELECTOR, GtkHBox)
+
+GtkWidget *dia_colour_selector_new (void);
+void dia_colour_selector_set_use_alpha (DiaColourSelector *cs,
+ gboolean use_alpha);
+void dia_colour_selector_get_colour (DiaColourSelector *cs,
+ Color *color);
+void dia_colour_selector_set_colour (DiaColourSelector *cs,
+ const Color *color);
+
+G_END_DECLS
diff --git a/lib/dia-file-selector.c b/lib/dia-file-selector.c
new file mode 100644
index 000000000..6b5eb305d
--- /dev/null
+++ b/lib/dia-file-selector.c
@@ -0,0 +1,234 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "dia-file-selector.h"
+
+struct _DiaFileSelector {
+ GtkHBox hbox;
+ GtkEntry *entry;
+ GtkButton *browse;
+ GtkWidget *dialog;
+ char *sys_filename;
+ char *pattern; /* for supported formats */
+};
+
+G_DEFINE_TYPE (DiaFileSelector, dia_file_selector, GTK_TYPE_HBOX)
+
+enum {
+ DFILE_VALUE_CHANGED,
+ DFILE_LAST_SIGNAL
+};
+
+static guint dfile_signals[DFILE_LAST_SIGNAL] = { 0 };
+
+
+static void
+dia_file_selector_dispose (GObject *object)
+{
+ DiaFileSelector *fs = DIA_FILE_SELECTOR (object);
+
+ g_clear_pointer (&fs->dialog, gtk_widget_destroy);
+ g_clear_pointer (&fs->sys_filename, g_free);
+ g_clear_pointer (&fs->pattern, g_free);
+
+ G_OBJECT_CLASS (dia_file_selector_parent_class)->dispose (object);
+}
+
+
+static void
+dia_file_selector_class_init (DiaFileSelectorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = dia_file_selector_dispose;
+
+ dfile_signals[DFILE_VALUE_CHANGED] = g_signal_new ("value-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+
+static void
+dia_file_selector_entry_changed (GtkEditable *editable,
+ gpointer data)
+{
+ DiaFileSelector *fs = DIA_FILE_SELECTOR (data);
+ g_signal_emit (fs, dfile_signals[DFILE_VALUE_CHANGED], 0);
+}
+
+
+static void
+file_open_response_callback (GtkWidget *dialog,
+ int response,
+ DiaFileSelector *fs)
+{
+ if (response == GTK_RESPONSE_ACCEPT || response == GTK_RESPONSE_OK) {
+ char *utf8 = g_filename_to_utf8 (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)),
+ -1, NULL, NULL, NULL);
+
+ gtk_entry_set_text (GTK_ENTRY (fs->entry), utf8);
+
+ g_clear_pointer (&utf8, g_free);
+ }
+
+ g_clear_pointer (&fs->dialog, gtk_widget_destroy);
+}
+
+
+static void
+dia_file_selector_browse_pressed (GtkWidget *widget, gpointer data)
+{
+ GtkWidget *dialog;
+ DiaFileSelector *fs = DIA_FILE_SELECTOR (data);
+ char *filename;
+ GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+
+ if (toplevel && !GTK_WINDOW (toplevel)) {
+ toplevel = NULL;
+ }
+
+ if (fs->dialog == NULL) {
+ GtkFileFilter *filter;
+
+ dialog = fs->dialog =
+ gtk_file_chooser_dialog_new (_("Select image file"),
+ toplevel ? GTK_WINDOW (toplevel) : NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_Open"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+ g_signal_connect (G_OBJECT (dialog), "response",
+ G_CALLBACK (file_open_response_callback), fs);
+ g_signal_connect (G_OBJECT (fs->dialog), "destroy",
+ G_CALLBACK (gtk_widget_destroyed), &fs->dialog);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Supported Formats"));
+ if (fs->pattern) {
+ gtk_file_filter_add_pattern (filter, fs->pattern);
+ } else {
+ /* fallback */
+ gtk_file_filter_add_pixbuf_formats (filter);
+ }
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("All Files"));
+ gtk_file_filter_add_pattern (filter, "*");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ }
+
+ filename = g_filename_from_utf8 (gtk_entry_get_text (fs->entry), -1, NULL, NULL, NULL);
+ /* selecting something in the filechooser officially sucks. See e.g.
http://bugzilla.gnome.org/show_bug.cgi?id=307378 */
+ if (g_path_is_absolute (filename)) {
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (fs->dialog), filename);
+ }
+
+ g_clear_pointer (&filename, g_free);
+
+ gtk_widget_show (GTK_WIDGET (fs->dialog));
+}
+
+
+static void
+dia_file_selector_init (DiaFileSelector *fs)
+{
+ /* Here's where we set up the real thing */
+ fs->dialog = NULL;
+ fs->sys_filename = NULL;
+ fs->pattern = NULL;
+
+ fs->entry = GTK_ENTRY (gtk_entry_new ());
+ gtk_box_pack_start (GTK_BOX (fs), GTK_WIDGET (fs->entry), FALSE, TRUE, 0);
+ g_signal_connect (G_OBJECT (fs->entry),
+ "changed", G_CALLBACK (dia_file_selector_entry_changed),
+ fs);
+ gtk_widget_show (GTK_WIDGET (fs->entry));
+
+ fs->browse = GTK_BUTTON (gtk_button_new_with_label (_("Browse")));
+ gtk_box_pack_start (GTK_BOX (fs), GTK_WIDGET (fs->browse), FALSE, TRUE, 0);
+ g_signal_connect (G_OBJECT (fs->browse),
+ "clicked", G_CALLBACK (dia_file_selector_browse_pressed),
+ fs);
+ gtk_widget_show (GTK_WIDGET (fs->browse));
+}
+
+
+GtkWidget *
+dia_file_selector_new (void)
+{
+ return g_object_new (DIA_TYPE_FILE_SELECTOR, NULL);
+}
+
+
+void
+dia_file_selector_set_extensions (DiaFileSelector *fs, const char **exts)
+{
+ GString *pattern = g_string_new ("*.");
+ int i = 0;
+
+ g_clear_pointer (&fs->pattern, g_free);
+
+ while (exts[i] != NULL) {
+ if (i != 0) {
+ g_string_append (pattern, "|*.");
+ }
+ g_string_append (pattern, exts[i]);
+ ++i;
+ }
+
+ fs->pattern = g_string_free (pattern, FALSE);
+}
+
+
+void
+dia_file_selector_set_file (DiaFileSelector *fs, char *file)
+{
+ GError *error = NULL;
+ /* filename is in system encoding */
+ char *utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, &error);
+
+ gtk_entry_set_text (GTK_ENTRY (fs->entry), utf8);
+ if (error) {
+ g_warning ("Unable to show filename: %s", error->message);
+ }
+
+ g_clear_error (&error);
+ g_clear_pointer (&utf8, g_free);
+}
+
+
+const char *
+dia_file_selector_get_file (DiaFileSelector *fs)
+{
+ /* let it behave like gtk_file_selector_get_file */
+ g_clear_pointer (&fs->sys_filename, g_free);
+ fs->sys_filename = g_filename_from_utf8 (gtk_entry_get_text (GTK_ENTRY (fs->entry)),
+ -1, NULL, NULL, NULL);
+ return fs->sys_filename;
+}
diff --git a/lib/dia-file-selector.h b/lib/dia-file-selector.h
new file mode 100644
index 000000000..ca8c44188
--- /dev/null
+++ b/lib/dia-file-selector.h
@@ -0,0 +1,39 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "dia-autoptr.h"
+
+G_BEGIN_DECLS
+
+#define DIA_TYPE_FILE_SELECTOR dia_file_selector_get_type ()
+G_DECLARE_FINAL_TYPE (DiaFileSelector, dia_file_selector, DIA, FILE_SELECTOR, GtkHBox)
+
+GtkWidget *dia_file_selector_new (void);
+void dia_file_selector_set_extensions (DiaFileSelector *fs,
+ const char **exts);
+void dia_file_selector_set_file (DiaFileSelector *fs,
+ char *file);
+const char *dia_file_selector_get_file (DiaFileSelector *fs);
+
+G_END_DECLS
diff --git a/lib/diafontselector.c b/lib/dia-font-selector.c
similarity index 99%
rename from lib/diafontselector.c
rename to lib/dia-font-selector.c
index 9bf68d382..76f201e71 100644
--- a/lib/diafontselector.c
+++ b/lib/dia-font-selector.c
@@ -16,20 +16,23 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
#include <stdlib.h>
#include <string.h>
-#include "intl.h"
#include <gtk/gtk.h>
-#include "diafontselector.h"
+#include <glib/gi18n-lib.h>
+
+#include "dia-font-selector.h"
#include "font.h"
#include "persistence.h"
#define PERSIST_NAME "font-menu"
-/************* DiaFontSelector: ***************/
+struct _DiaFontSelector {
+ GtkHBox hbox;
+};
typedef struct _DiaFontSelectorPrivate DiaFontSelectorPrivate;
@@ -50,6 +53,7 @@ struct _DiaFontSelectorPrivate {
int current_style;
};
+G_DEFINE_TYPE_WITH_PRIVATE (DiaFontSelector, dia_font_selector, GTK_TYPE_HBOX)
enum {
VALUE_CHANGED,
@@ -76,10 +80,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
* +----------------+
*/
-
-G_DEFINE_TYPE_WITH_PRIVATE (DiaFontSelector, dia_font_selector, GTK_TYPE_HBOX)
-
-
enum {
STYLE_COL_LABEL,
STYLE_COL_ID,
diff --git a/lib/diafontselector.h b/lib/dia-font-selector.h
similarity index 94%
rename from lib/diafontselector.h
rename to lib/dia-font-selector.h
index 7bef86c51..6090f3bbd 100644
--- a/lib/diafontselector.h
+++ b/lib/dia-font-selector.h
@@ -14,24 +14,19 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
+#pragma once
+
#include <gtk/gtk.h>
-#include "diatypes.h"
#include "dia-autoptr.h"
#include "font.h"
-#pragma once
-
G_BEGIN_DECLS
-
-struct _DiaFontSelector
-{
- GtkHBox hbox;
-};
-
#define DIA_TYPE_FONT_SELECTOR dia_font_selector_get_type ()
G_DECLARE_FINAL_TYPE (DiaFontSelector, dia_font_selector, DIA, FONT_SELECTOR, GtkHBox)
diff --git a/lib/dialinestyleselector.c b/lib/dia-line-style-selector.c
similarity index 65%
rename from lib/dialinestyleselector.c
rename to lib/dia-line-style-selector.c
index a314e1a4f..97dbfd252 100644
--- a/lib/dialinestyleselector.c
+++ b/lib/dia-line-style-selector.c
@@ -16,16 +16,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include "intl.h"
-#include "dialinechooser.h"
-#include "widgets.h"
#include "dia-line-cell-renderer.h"
-
-/************* DiaLineStyleSelector: ***************/
+#include "dia-line-style-selector.h"
enum {
COL_LINE,
@@ -33,8 +30,7 @@ enum {
};
-struct _DiaLineStyleSelector
-{
+struct _DiaLineStyleSelector {
GtkVBox vbox;
GtkLabel *lengthlabel;
@@ -45,31 +41,25 @@ struct _DiaLineStyleSelector
LineStyle looking_for;
};
-struct _DiaLineStyleSelectorClass
-{
- GtkVBoxClass parent_class;
-};
+G_DEFINE_TYPE (DiaLineStyleSelector, dia_line_style_selector, GTK_TYPE_VBOX)
enum {
- DLS_VALUE_CHANGED,
- DLS_LAST_SIGNAL
+ DLS_VALUE_CHANGED,
+ DLS_LAST_SIGNAL
};
static guint dls_signals[DLS_LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (DiaLineStyleSelector, dia_line_style_selector, GTK_TYPE_VBOX)
-
static void
-dia_line_style_selector_class_init (DiaLineStyleSelectorClass *class)
+dia_line_style_selector_class_init (DiaLineStyleSelectorClass *klass)
{
- dls_signals[DLS_VALUE_CHANGED]
- = g_signal_new("value-changed",
- G_TYPE_FROM_CLASS(class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ dls_signals[DLS_VALUE_CHANGED] = g_signal_new ("value-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
@@ -86,8 +76,10 @@ set_linestyle_sensitivity (DiaLineStyleSelector *fs)
COL_LINE, &line,
-1);
- gtk_widget_set_sensitive (GTK_WIDGET (fs->lengthlabel), line != LINESTYLE_SOLID);
- gtk_widget_set_sensitive (GTK_WIDGET (fs->dashlength), line != LINESTYLE_SOLID);
+ gtk_widget_set_sensitive (GTK_WIDGET (fs->lengthlabel),
+ line != LINESTYLE_SOLID);
+ gtk_widget_set_sensitive (GTK_WIDGET (fs->dashlength),
+ line != LINESTYLE_SOLID);
} else {
gtk_widget_set_sensitive (GTK_WIDGET (fs->lengthlabel), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (fs->dashlength), FALSE);
@@ -96,18 +88,21 @@ set_linestyle_sensitivity (DiaLineStyleSelector *fs)
static void
-linestyle_type_change_callback(GtkComboBox *menu, gpointer data)
+linestyle_type_change_callback (GtkComboBox *menu, gpointer data)
{
- set_linestyle_sensitivity(DIALINESTYLESELECTOR(data));
- g_signal_emit(DIALINESTYLESELECTOR(data),
- dls_signals[DLS_VALUE_CHANGED], 0);
+ set_linestyle_sensitivity (DIA_LINE_STYLE_SELECTOR (data));
+ g_signal_emit (DIA_LINE_STYLE_SELECTOR (data),
+ dls_signals[DLS_VALUE_CHANGED],
+ 0);
}
+
static void
-linestyle_dashlength_change_callback(GtkSpinButton *sb, gpointer data)
+linestyle_dashlength_change_callback (GtkSpinButton *sb, gpointer data)
{
- g_signal_emit(DIALINESTYLESELECTOR(data),
- dls_signals[DLS_VALUE_CHANGED], 0);
+ g_signal_emit (DIA_LINE_STYLE_SELECTOR (data),
+ dls_signals[DLS_VALUE_CHANGED],
+ 0);
}
@@ -147,43 +142,43 @@ dia_line_style_selector_init (DiaLineStyleSelector *fs)
gtk_box_pack_start (GTK_BOX (fs), fs->combo, FALSE, TRUE, 0);
gtk_widget_show (fs->combo);
- box = gtk_hbox_new(FALSE,0);
+ box = gtk_hbox_new (FALSE, 0);
/* fs->sizebox = GTK_HBOX(box); */
label = gtk_label_new(_("Dash length: "));
- fs->lengthlabel = GTK_LABEL(label);
- gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
- gtk_widget_show(label);
-
- adj = (GtkAdjustment *)gtk_adjustment_new(0.1, 0.00, 10.0, 0.1, 1.0, 0);
- length = gtk_spin_button_new(adj, DEFAULT_LINESTYLE_DASHLEN, 2);
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(length), TRUE);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(length), TRUE);
- fs->dashlength = GTK_SPIN_BUTTON(length);
- gtk_box_pack_start(GTK_BOX (box), length, TRUE, TRUE, 0);
+ fs->lengthlabel = GTK_LABEL (label);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+ gtk_widget_show (label);
+
+ adj = GTK_ADJUSTMENT (gtk_adjustment_new (0.1, 0.00, 10.0, 0.1, 1.0, 0));
+ length = gtk_spin_button_new (adj, DEFAULT_LINESTYLE_DASHLEN, 2);
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON(length), TRUE);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON(length), TRUE);
+ fs->dashlength = GTK_SPIN_BUTTON (length);
+ gtk_box_pack_start (GTK_BOX (box), length, TRUE, TRUE, 0);
gtk_widget_show (length);
- g_signal_connect(G_OBJECT(length), "changed",
- G_CALLBACK(linestyle_dashlength_change_callback), fs);
-
- set_linestyle_sensitivity(fs);
- gtk_box_pack_start(GTK_BOX(fs), box, TRUE, TRUE, 0);
- gtk_widget_show(box);
+ g_signal_connect (G_OBJECT (length),
+ "changed", G_CALLBACK (linestyle_dashlength_change_callback),
+ fs);
+ set_linestyle_sensitivity (fs);
+ gtk_box_pack_start (GTK_BOX (fs), box, TRUE, TRUE, 0);
+ gtk_widget_show (box);
}
GtkWidget *
dia_line_style_selector_new (void)
{
- return g_object_new (dia_line_style_selector_get_type (), NULL);
+ return g_object_new (DIA_TYPE_LINE_STYLE_SELECTOR, NULL);
}
void
dia_line_style_selector_get_linestyle (DiaLineStyleSelector *fs,
LineStyle *ls,
- real *dl)
+ double *dl)
{
GtkTreeIter iter;
@@ -208,7 +203,7 @@ set_style (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- DiaLineStyleSelector *self = DIALINESTYLESELECTOR (data);
+ DiaLineStyleSelector *self = DIA_LINE_STYLE_SELECTOR (data);
LineStyle line;
gboolean res = FALSE;
@@ -229,7 +224,7 @@ set_style (GtkTreeModel *model,
void
dia_line_style_selector_set_linestyle (DiaLineStyleSelector *as,
LineStyle linestyle,
- real dashlength)
+ double dashlength)
{
as->looking_for = linestyle;
gtk_tree_model_foreach (GTK_TREE_MODEL (as->line_store), set_style, as);
diff --git a/lib/dia-line-style-selector.h b/lib/dia-line-style-selector.h
new file mode 100644
index 000000000..21b8630ef
--- /dev/null
+++ b/lib/dia-line-style-selector.h
@@ -0,0 +1,41 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "dia-autoptr.h"
+#include "dia-enums.h"
+
+G_BEGIN_DECLS
+
+#define DIA_TYPE_LINE_STYLE_SELECTOR dia_line_style_selector_get_type ()
+G_DECLARE_FINAL_TYPE (DiaLineStyleSelector, dia_line_style_selector, DIA, LINE_STYLE_SELECTOR, GtkVBox)
+
+GtkWidget *dia_line_style_selector_new (void);
+void dia_line_style_selector_get_linestyle (DiaLineStyleSelector *as,
+ LineStyle *linestyle,
+ double *dashlength);
+void dia_line_style_selector_set_linestyle (DiaLineStyleSelector *as,
+ LineStyle linestyle,
+ double dashlength);
+
+G_END_DECLS
diff --git a/lib/dia-size-selector.c b/lib/dia-size-selector.c
new file mode 100644
index 000000000..f9f5af8c2
--- /dev/null
+++ b/lib/dia-size-selector.c
@@ -0,0 +1,244 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <math.h>
+
+#include "dia-size-selector.h"
+#include "widgets.h"
+
+/**
+ * DiaSizeSelector:
+ *
+ * A widget that selects two sizes, width and height, optionally keeping aspect
+ * ratio. When created, aspect ratio is locked, but the user can unlock it. The
+ * current users do not store aspect ratio, so we have to give a good default.
+ */
+struct _DiaSizeSelector {
+ GtkHBox hbox;
+ GtkSpinButton *width, *height;
+ GtkToggleButton *aspect_locked;
+ double ratio;
+ GtkAdjustment *last_adjusted;
+};
+
+G_DEFINE_TYPE (DiaSizeSelector, dia_size_selector, GTK_TYPE_HBOX)
+
+enum {
+ DSS_VALUE_CHANGED,
+ DSS_LAST_SIGNAL
+};
+
+static guint dss_signals[DSS_LAST_SIGNAL] = { 0 };
+
+
+static void
+dia_size_selector_class_init (DiaSizeSelectorClass *klass)
+{
+ dss_signals[DSS_VALUE_CHANGED] = g_signal_new ("value-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+
+static void
+dia_size_selector_adjust_width (DiaSizeSelector *ss)
+{
+ double height = gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->height));
+
+ if (fabs (ss->ratio) > 1e-6) {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (ss->width),
+ height * ss->ratio);
+ }
+}
+
+
+static void
+dia_size_selector_adjust_height (DiaSizeSelector *ss)
+{
+ double width = gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->width));
+
+ if (fabs (ss->ratio) > 1e-6) {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (ss->height),
+ width / ss->ratio);
+ }
+}
+
+
+static void
+dia_size_selector_ratio_callback (GtkAdjustment *limits, gpointer userdata)
+{
+ static gboolean in_progress = FALSE;
+ DiaSizeSelector *ss = DIA_SIZE_SELECTOR (userdata);
+
+ ss->last_adjusted = limits;
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ss->aspect_locked)) &&
+ ss->ratio != 0.0) {
+
+ if (in_progress) {
+ return;
+ }
+ in_progress = TRUE;
+
+ if (limits == gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (ss->width))) {
+ dia_size_selector_adjust_height (ss);
+ } else {
+ dia_size_selector_adjust_width (ss);
+ }
+
+ in_progress = FALSE;
+ }
+
+ g_signal_emit (ss, dss_signals[DSS_VALUE_CHANGED], 0);
+}
+
+
+/*
+ * Update the ratio of this DSS to be the ratio of width to height.
+ * If height is 0, ratio becomes 0.0.
+ */
+static void
+dia_size_selector_set_ratio (DiaSizeSelector *ss, double width, double height)
+{
+ if (height > 0.0) {
+ ss->ratio = width/height;
+ } else {
+ ss->ratio = 0.0;
+ }
+}
+
+
+static void
+dia_size_selector_lock_pressed (GtkWidget *widget, gpointer data)
+{
+ DiaSizeSelector *ss = DIA_SIZE_SELECTOR (data);
+
+ dia_size_selector_set_ratio (ss,
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->width)),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->height)));
+}
+
+/* Possible args: Init width, init height, digits */
+
+static void
+dia_size_selector_init (DiaSizeSelector *ss)
+{
+ GtkAdjustment *adj;
+
+ ss->ratio = 0.0;
+
+ /* Here's where we set up the real thing */
+ adj = GTK_ADJUSTMENT (gtk_adjustment_new(1.0, 0.01, 10, 0.1, 1.0, 0));
+ ss->width = GTK_SPIN_BUTTON (gtk_spin_button_new (adj, 1.0, 2));
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ss->width), TRUE);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (ss->width), TRUE);
+ gtk_box_pack_start (GTK_BOX (ss), GTK_WIDGET (ss->width), FALSE, TRUE, 0);
+ gtk_widget_show (GTK_WIDGET (ss->width));
+
+ adj = GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 0.01, 10, 0.1, 1.0, 0));
+ ss->height = GTK_SPIN_BUTTON (gtk_spin_button_new (adj, 1.0, 2));
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (ss->height), TRUE);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (ss->height), TRUE);
+ gtk_box_pack_start (GTK_BOX (ss), GTK_WIDGET (ss->height), FALSE, TRUE, 0);
+ gtk_widget_show (GTK_WIDGET (ss->height));
+
+ /* Replace label with images */
+ /* should make sure they're both unallocated when the widget dies.
+ * That should happen in the "destroy" handler, where both should
+ * be unref'd */
+ ss->aspect_locked = GTK_TOGGLE_BUTTON (
+ dia_toggle_button_new_with_icon_names ("dia-chain-unbroken",
+ "dia-chain-broken"));
+
+ gtk_container_set_border_width (GTK_CONTAINER (ss->aspect_locked), 0);
+
+ gtk_box_pack_start (GTK_BOX (ss),
+ GTK_WIDGET (ss->aspect_locked),
+ FALSE,
+ TRUE,
+ 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ss->aspect_locked), TRUE);
+ gtk_widget_show (GTK_WIDGET (ss->aspect_locked));
+
+ g_signal_connect (G_OBJECT (ss->aspect_locked),
+ "clicked", G_CALLBACK (dia_size_selector_lock_pressed),
+ ss);
+ /* Make sure that the aspect ratio stays the same */
+ g_signal_connect (G_OBJECT (gtk_spin_button_get_adjustment (ss->width)),
+ "value_changed", G_CALLBACK (dia_size_selector_ratio_callback),
+ ss);
+ g_signal_connect (G_OBJECT (gtk_spin_button_get_adjustment (ss->height)),
+ "value_changed", G_CALLBACK (dia_size_selector_ratio_callback),
+ ss);
+}
+
+
+GtkWidget *
+dia_size_selector_new (double width, double height)
+{
+ GtkWidget *wid = g_object_new (DIA_TYPE_SIZE_SELECTOR, NULL);
+
+ dia_size_selector_set_size (DIA_SIZE_SELECTOR (wid), width, height);
+
+ return wid;
+}
+
+
+void
+dia_size_selector_set_size (DiaSizeSelector *ss, double width, double height)
+{
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (ss->width), width);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (ss->height), height);
+ /*
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ss->aspect_locked),
+ fabs(width - height) < 0.000001);
+ */
+ dia_size_selector_set_ratio (ss, width, height);
+}
+
+
+void
+dia_size_selector_set_locked (DiaSizeSelector *ss, gboolean locked)
+{
+ if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ss->aspect_locked)) &&
+ locked) {
+ dia_size_selector_set_ratio (ss,
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->width)),
+ gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->height)));
+ }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ss->aspect_locked), locked);
+}
+
+
+gboolean
+dia_size_selector_get_size (DiaSizeSelector *ss,
+ double *width,
+ double *height)
+{
+ g_return_val_if_fail (DIA_IS_SIZE_SELECTOR (ss), FALSE);
+
+ *width = gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->width));
+ *height = gtk_spin_button_get_value (GTK_SPIN_BUTTON (ss->height));
+
+ return gtk_toggle_button_get_active (ss->aspect_locked);
+}
diff --git a/lib/dia-size-selector.h b/lib/dia-size-selector.h
new file mode 100644
index 000000000..e14b58a01
--- /dev/null
+++ b/lib/dia-size-selector.h
@@ -0,0 +1,43 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "dia-autoptr.h"
+
+G_BEGIN_DECLS
+
+#define DIA_TYPE_SIZE_SELECTOR dia_size_selector_get_type ()
+G_DECLARE_FINAL_TYPE (DiaSizeSelector, dia_size_selector, DIA, SIZE_SELECTOR, GtkHBox)
+
+GtkWidget *dia_size_selector_new (double width,
+ double height);
+void dia_size_selector_set_locked (DiaSizeSelector *ss,
+ gboolean locked);
+void dia_size_selector_set_size (DiaSizeSelector *ss,
+ double width,
+ double height);
+gboolean dia_size_selector_get_size (DiaSizeSelector *ss,
+ double *width,
+ double *height);
+
+G_END_DECLS
diff --git a/lib/dia-unit-spinner.c b/lib/dia-unit-spinner.c
new file mode 100644
index 000000000..b507011fe
--- /dev/null
+++ b/lib/dia-unit-spinner.c
@@ -0,0 +1,205 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "dia-unit-spinner.h"
+
+/**
+ * DiaUnitSpinner:
+ *
+ * A Spinner that allows a 'favoured' unit to display in. External access
+ * to the value still happens in cm, but display is in the favored unit.
+ * Internally, the value is kept in the favored unit to a) allow proper
+ * limits, and b) avoid rounding problems while editing.
+ *
+ * Since: dawn-of-time
+ */
+struct _DiaUnitSpinner {
+ GtkSpinButton parent;
+
+ DiaUnit unit_num;
+};
+
+G_DEFINE_TYPE (DiaUnitSpinner, dia_unit_spinner, GTK_TYPE_SPIN_BUTTON)
+
+
+static void
+dia_unit_spinner_class_init (DiaUnitSpinnerClass *klass)
+{
+}
+
+
+static void
+dia_unit_spinner_init (DiaUnitSpinner *self)
+{
+ self->unit_num = DIA_UNIT_CENTIMETER;
+}
+
+
+/*
+ Callback functions for the "input" and "output" signals emitted by
+ GtkSpinButton. All the normal work is done by the spin button, we
+ simply modify how the text in the GtkEntry is treated.
+*/
+
+
+static gboolean
+dia_unit_spinner_input (DiaUnitSpinner *self, double *value)
+{
+ double val, factor = 1.0;
+ char *extra = NULL;
+
+ val = g_strtod (gtk_entry_get_text (GTK_ENTRY (self)), &extra);
+
+ /* get rid of extra white space after number */
+ while (*extra && g_ascii_isspace (*extra)) {
+ extra++;
+ }
+
+ if (*extra) {
+ for (int i = 0; i < DIA_LAST_UNIT; i++) {
+ if (!g_ascii_strcasecmp (dia_unit_get_symbol (i), extra)) {
+ factor = dia_unit_get_factor (i) /
+ dia_unit_get_factor (self->unit_num);
+ break;
+ }
+ }
+ }
+
+ /* convert to prefered units */
+ val *= factor;
+
+ /* Store value in the location provided by the signal emitter. */
+ *value = val;
+
+ /* Return true, so that the default input function is not invoked. */
+ return TRUE;
+}
+
+
+static gboolean
+dia_unit_spinner_output (DiaUnitSpinner *self)
+{
+ char buf[256];
+ GtkSpinButton *sbutton = GTK_SPIN_BUTTON (self);
+ GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (sbutton);
+
+ g_snprintf (buf,
+ sizeof(buf),
+ "%0.*f %s",
+ gtk_spin_button_get_digits(sbutton),
+ gtk_adjustment_get_value(adjustment),
+ dia_unit_get_symbol (self->unit_num));
+ gtk_entry_set_text (GTK_ENTRY(self), buf);
+
+ /* Return true, so that the default output function is not invoked. */
+ return TRUE;
+}
+
+
+GtkWidget *
+dia_unit_spinner_new (GtkAdjustment *adjustment, DiaUnit adj_unit)
+{
+ DiaUnitSpinner *self;
+
+ if (adjustment) {
+ g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
+ }
+
+ self = g_object_new (DIA_TYPE_UNIT_SPINNER, NULL);
+ gtk_entry_set_activates_default (GTK_ENTRY (self), TRUE);
+ self->unit_num = adj_unit;
+
+ gtk_spin_button_configure (GTK_SPIN_BUTTON (self),
+ adjustment, 0.0, dia_unit_get_digits (adj_unit));
+
+ g_signal_connect (GTK_SPIN_BUTTON (self), "output",
+ G_CALLBACK (dia_unit_spinner_output),
+ NULL);
+ g_signal_connect (GTK_SPIN_BUTTON (self), "input",
+ G_CALLBACK (dia_unit_spinner_input),
+ NULL);
+
+ return GTK_WIDGET (self);
+}
+
+
+/**
+ * dia_unit_spinner_set_value:
+ * @self: the DiaUnitSpinner
+ * @val: value in %DIA_UNIT_CENTIMETER
+ *
+ * Set the value (in cm).
+ *
+ * Since: dawn-of-time
+ */
+void
+dia_unit_spinner_set_value (DiaUnitSpinner *self, double val)
+{
+ GtkSpinButton *sbutton = GTK_SPIN_BUTTON(self);
+
+ gtk_spin_button_set_value (sbutton,
+ val /
+ (dia_unit_get_factor (self->unit_num) /
+ (dia_unit_get_factor (DIA_UNIT_CENTIMETER))));
+}
+
+
+/**
+ * dia_unit_spinner_get_value:
+ * @self: the DiaUnitSpinner
+ *
+ * Get the value (in cm)
+ *
+ * Returns: The value in %DIA_UNIT_CENTIMETER
+ *
+ * Since: dawn-of-time
+ */
+double
+dia_unit_spinner_get_value (DiaUnitSpinner *self)
+{
+ GtkSpinButton *sbutton = GTK_SPIN_BUTTON(self);
+
+ return gtk_spin_button_get_value (sbutton) *
+ (dia_unit_get_factor (self->unit_num) /
+ dia_unit_get_factor (DIA_UNIT_CENTIMETER));
+}
+
+
+/**
+ * dia_unit_spinner_set_upper:
+ * @self: the DiaUnitSpinner
+ * @val: value in %DIA_UNIT_CENTIMETER
+ *
+ * Must manipulate the limit values through this to also consider unit.
+ *
+ * Given value is in centimeter.
+ *
+ * Since: dawn-of-time
+ */
+void
+dia_unit_spinner_set_upper (DiaUnitSpinner *self, double val)
+{
+ val /= (dia_unit_get_factor (self->unit_num) /
+ dia_unit_get_factor (DIA_UNIT_CENTIMETER));
+
+ gtk_adjustment_set_upper (
+ gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (self)), val);
+}
+
diff --git a/lib/dia-unit-spinner.h b/lib/dia-unit-spinner.h
new file mode 100644
index 000000000..b8279cc3d
--- /dev/null
+++ b/lib/dia-unit-spinner.h
@@ -0,0 +1,42 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+#include "dia-autoptr.h"
+#include "units.h"
+
+G_BEGIN_DECLS
+
+#define DIA_TYPE_UNIT_SPINNER dia_unit_spinner_get_type ()
+G_DECLARE_FINAL_TYPE (DiaUnitSpinner, dia_unit_spinner, DIA, UNIT_SPINNER, GtkSpinButton)
+
+
+GtkWidget *dia_unit_spinner_new (GtkAdjustment *adjustment,
+ DiaUnit adj_unit);
+void dia_unit_spinner_set_value (DiaUnitSpinner *self,
+ double val);
+double dia_unit_spinner_get_value (DiaUnitSpinner *self);
+void dia_unit_spinner_set_upper (DiaUnitSpinner *self,
+ double val);
+
+G_END_DECLS
diff --git a/lib/diaarrowchooser.c b/lib/diaarrowchooser.c
index 2e3120c7b..bcfe1b81c 100644
--- a/lib/diaarrowchooser.c
+++ b/lib/diaarrowchooser.c
@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
#include "intl.h"
-#include "widgets.h"
+#include "dia-arrow-selector.h"
#include "diaarrowchooser.h"
#include "renderer/diacairo.h"
diff --git a/lib/diaarrowchooser.h b/lib/diaarrowchooser.h
index c52c287d3..19991afe9 100644
--- a/lib/diaarrowchooser.h
+++ b/lib/diaarrowchooser.h
@@ -26,6 +26,7 @@
#include "arrows.h"
#include "diatypes.h"
#include "dia-autoptr.h"
+#include "dia-arrow-selector.h"
G_BEGIN_DECLS
diff --git a/lib/dialinechooser.c b/lib/dialinechooser.c
index 88b316aa5..3d97c50a1 100644
--- a/lib/dialinechooser.c
+++ b/lib/dialinechooser.c
@@ -22,7 +22,7 @@
#include <config.h>
#include "intl.h"
-#include "widgets.h"
+#include "dia-line-style-selector.h"
#include "dialinechooser.h"
static const char *button_menu_key = "dia-button-menu";
@@ -316,7 +316,7 @@ dia_line_chooser_init (DiaLineChooser *lchooser)
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area (GTK_DIALOG(lchooser->dialog))), wid,
TRUE, TRUE, 0);
gtk_widget_show(wid);
- lchooser->selector = DIALINESTYLESELECTOR(wid);
+ lchooser->selector = DIA_LINE_STYLE_SELECTOR(wid);
menu = gtk_menu_new();
g_object_ref_sink(G_OBJECT(menu));
diff --git a/lib/dialinechooser.h b/lib/dialinechooser.h
index 5a70104f2..ff9b64ecb 100644
--- a/lib/dialinechooser.h
+++ b/lib/dialinechooser.h
@@ -26,6 +26,8 @@
#include <gtk/gtk.h>
+#include "dia-line-style-selector.h"
+
/* --------------- DiaLinePreview -------------------------------- */
GType dia_line_preview_get_type (void);
@@ -88,7 +90,7 @@ struct _DiaLineChooserClass
GtkButtonClass parent_class;
};
-void dia_line_chooser_set_line_style(DiaLineChooser *lchooser,
+void dia_line_chooser_set_line_style(DiaLineChooser *lchooser,
LineStyle style,
real dashlength);
GtkWidget *dia_line_chooser_new (DiaChangeLineCallback callback,
diff --git a/lib/diatypes.h b/lib/diatypes.h
index d9d6d3f64..a5982ef71 100644
--- a/lib/diatypes.h
+++ b/lib/diatypes.h
@@ -168,19 +168,6 @@ typedef struct _TextLine TextLine;
/* In textattr.h: */
typedef struct _TextAttributes TextAttributes;
-/* In widgets.h: */
-typedef struct _DiaSizeSelector DiaSizeSelector;
-typedef struct _DiaSizeSelectorClass DiaSizeSelectorClass;
-typedef struct _DiaFontSelector DiaFontSelector;
-typedef struct _DiaLineStyleSelector DiaLineStyleSelector;
-typedef struct _DiaLineStyleSelectorClass DiaLineStyleSelectorClass;
-typedef struct _DiaColorSelector DiaColorSelector;
-typedef struct _DiaColorSelectorClass DiaColorSelectorClass;
-typedef struct _DiaArrowSelector DiaArrowSelector;
-typedef struct _DiaArrowSelectorClass DiaArrowSelectorClass;
-typedef struct _DiaFileSelector DiaFileSelector;
-typedef struct _DiaFileSelectorClass DiaFileSelectorClass;
-
/** A standard definition of a function that takes a DiaObject */
typedef void (*DiaObjectFunc) (const DiaObject *obj);
diff --git a/lib/dummy_dep.h b/lib/dummy_dep.h
index c4e6e077b..55b2333a9 100644
--- a/lib/dummy_dep.h
+++ b/lib/dummy_dep.h
@@ -33,7 +33,7 @@
#include "properties.h"
#include "dynamic_obj.h"
#include "connectionpoint.h"
-#include "diafontselector.h"
+#include "dia-font-selector.h"
#include "dia-state-object-change.h"
/* This is a file with dummy dependencies so that all
diff --git a/lib/libdia.def b/lib/libdia.def
index f1bf11d1d..11e3c9d6e 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -205,11 +205,11 @@ EXPORTS
dia_arrow_cell_renderer_new
dia_assert_true
- dia_color_selector_get_color
- dia_color_selector_get_type
- dia_color_selector_new
- dia_color_selector_set_color
- dia_color_selector_set_use_alpha
+ dia_colour_selector_get_colour
+ dia_colour_selector_get_type
+ dia_colour_selector_new
+ dia_colour_selector_set_colour
+ dia_colour_selector_set_use_alpha
dia_colour_cell_renderer_new
diff --git a/lib/meson.build b/lib/meson.build
index 7bd679e30..62dedb57f 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -142,14 +142,35 @@ libdia_sources = stdprop_sources + [
'dia_svg.c',
'autoroute.c',
'parent.c',
+ 'diaarrowchooser.c',
+ 'dia-autoptr.h',
+ 'dia-arrow-cell-renderer.c',
+ 'dia-arrow-cell-renderer.h',
+ 'dia-arrow-selector.c',
+ 'dia-arrow-selector.h',
+ 'dia-colour-cell-renderer.c',
+ 'dia-colour-cell-renderer.h',
+ 'dia-colour-selector.c',
+ 'dia-colour-selector.h',
+ 'dia-file-selector.c',
+ 'dia-file-selector.h',
+ 'dia-font-selector.c',
+ 'dia-font-selector.h',
+ 'dia-graphene.h',
'dia-guide.c',
'dia-guide.h',
- 'diaarrowchooser.c',
- 'diaarrowselector.c',
- 'diacolorselector.c',
- 'dialinestyleselector.c',
+ 'dia-handle.c',
+ 'dia-line-cell-renderer.c',
+ 'dia-line-cell-renderer.h',
+ 'dia-line-style-selector.c',
+ 'dia-line-style-selector.h',
+ 'dia-simple-list.c',
+ 'dia-simple-list.h',
+ 'dia-size-selector.c',
+ 'dia-size-selector.h',
+ 'dia-unit-spinner.c',
+ 'dia-unit-spinner.h',
'dialinechooser.c',
- 'diafontselector.c',
'persistence.c',
'diaerror.c',
'debug.c',
@@ -157,17 +178,6 @@ libdia_sources = stdprop_sources + [
'dialib.c',
'diacontext.c',
'diacellrendererenum.c',
- 'dia-arrow-cell-renderer.c',
- 'dia-arrow-cell-renderer.h',
- 'dia-colour-cell-renderer.c',
- 'dia-colour-cell-renderer.h',
- 'dia-line-cell-renderer.c',
- 'dia-line-cell-renderer.h',
- 'dia-simple-list.c',
- 'dia-simple-list.h',
- 'dia-autoptr.h',
- 'dia-graphene.h',
- 'dia-handle.c',
'handle.h',
]
diff --git a/lib/prefs.c b/lib/prefs.c
index c347e420c..a5f9527cb 100644
--- a/lib/prefs.c
+++ b/lib/prefs.c
@@ -20,7 +20,6 @@
#include <string.h>
#include "prefs.h"
-#include "widgets.h"
DiaUnit length_unit = DIA_UNIT_CENTIMETER;
DiaUnit fontsize_unit = DIA_UNIT_POINT;
diff --git a/lib/prop_attr.c b/lib/prop_attr.c
index 4ac035588..030f92bc5 100644
--- a/lib/prop_attr.c
+++ b/lib/prop_attr.c
@@ -26,11 +26,13 @@
#include <gtk/gtk.h>
#include "dia_xml.h"
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "diaarrowchooser.h"
-#include "diafontselector.h"
+#include "dia-arrow-selector.h"
+#include "dia-colour-selector.h"
+#include "dia-font-selector.h"
+#include "dia-line-style-selector.h"
/***************************/
/* The LINESTYLE property type. */
@@ -67,22 +69,25 @@ linestyleprop_get_widget(LinestyleProperty *prop, PropDialog *dialog)
return ret;
}
+
static void
-linestyleprop_reset_widget(LinestyleProperty *prop, WIDGET *widget)
+linestyleprop_reset_widget (LinestyleProperty *prop, GtkWidget *widget)
{
- dia_line_style_selector_set_linestyle(DIALINESTYLESELECTOR(widget),
- prop->style,
- prop->dash);
+ dia_line_style_selector_set_linestyle (DIA_LINE_STYLE_SELECTOR (widget),
+ prop->style,
+ prop->dash);
}
+
static void
-linestyleprop_set_from_widget(LinestyleProperty *prop, WIDGET *widget)
+linestyleprop_set_from_widget (LinestyleProperty *prop, GtkWidget *widget)
{
- dia_line_style_selector_get_linestyle(DIALINESTYLESELECTOR(widget),
- &prop->style,
- &prop->dash);
+ dia_line_style_selector_get_linestyle (DIA_LINE_STYLE_SELECTOR (widget),
+ &prop->style,
+ &prop->dash);
}
+
static void
linestyleprop_load(LinestyleProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
@@ -285,29 +290,33 @@ colorprop_copy(ColorProperty *src)
return prop;
}
-static WIDGET *
-colorprop_get_widget(ColorProperty *prop, PropDialog *dialog)
+
+static GtkWidget *
+colorprop_get_widget (ColorProperty *prop, PropDialog *dialog)
{
- GtkWidget *ret = dia_color_selector_new();
- dia_color_selector_set_use_alpha (ret, TRUE);
- prophandler_connect(&prop->common, G_OBJECT(ret), "value-changed");
+ GtkWidget *ret = dia_colour_selector_new ();
+ dia_colour_selector_set_use_alpha (DIA_COLOUR_SELECTOR (ret), TRUE);
+ prophandler_connect (&prop->common, G_OBJECT (ret), "value-changed");
return ret;
}
+
static void
-colorprop_reset_widget(ColorProperty *prop, WIDGET *widget)
+colorprop_reset_widget (ColorProperty *prop, GtkWidget *widget)
{
- dia_color_selector_set_color(widget,
- &prop->color_data);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (widget),
+ &prop->color_data);
}
+
static void
-colorprop_set_from_widget(ColorProperty *prop, WIDGET *widget)
+colorprop_set_from_widget (ColorProperty *prop, GtkWidget *widget)
{
- dia_color_selector_get_color(widget,
- &prop->color_data);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (widget),
+ &prop->color_data);
}
+
static void
colorprop_load(ColorProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
diff --git a/lib/prop_dict.c b/lib/prop_dict.c
index df75e1906..8755f6f62 100644
--- a/lib/prop_dict.c
+++ b/lib/prop_dict.c
@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
diff --git a/lib/prop_geomtypes.c b/lib/prop_geomtypes.c
index ded0c4857..1a946a975 100644
--- a/lib/prop_geomtypes.c
+++ b/lib/prop_geomtypes.c
@@ -28,13 +28,13 @@
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "geometry.h"
#include "connpoint_line.h"
#include "prop_geomtypes.h"
#include "prefs.h"
+#include "dia-unit-spinner.h"
static void fontsizeprop_reset_widget(FontsizeProperty *prop, WIDGET *widget);
diff --git a/lib/prop_matrix.c b/lib/prop_matrix.c
index 1f1cb0bf1..7b4624183 100644
--- a/lib/prop_matrix.c
+++ b/lib/prop_matrix.c
@@ -27,7 +27,6 @@
#include <math.h>
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "message.h"
diff --git a/lib/prop_pattern.c b/lib/prop_pattern.c
index 467b7b4fc..4169d1ea6 100644
--- a/lib/prop_pattern.c
+++ b/lib/prop_pattern.c
@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "pattern.h"
diff --git a/lib/prop_pixbuf.c b/lib/prop_pixbuf.c
index 5ddd865ce..ce9b80981 100644
--- a/lib/prop_pixbuf.c
+++ b/lib/prop_pixbuf.c
@@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "message.h"
diff --git a/lib/prop_sdarray.c b/lib/prop_sdarray.c
index 389aa435f..3a1b22b50 100644
--- a/lib/prop_sdarray.c
+++ b/lib/prop_sdarray.c
@@ -28,7 +28,6 @@
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "prop_sdarray_widget.h"
diff --git a/lib/prop_text.c b/lib/prop_text.c
index 72b72aa84..6d3f40b5f 100644
--- a/lib/prop_text.c
+++ b/lib/prop_text.c
@@ -28,12 +28,12 @@
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "text.h"
#include "group.h"
#include "attributes.h"
+#include "dia-file-selector.h"
/*****************************************************/
/* The STRING, FILE and MULTISTRING property types. */
@@ -154,31 +154,38 @@ multistringprop_set_from_widget(StringProperty *prop, GtkWidget *widget) {
g_strdup (gtk_text_buffer_get_text (buffer, &start, &end, TRUE));
}
+
static GtkWidget *
-fileprop_get_widget(StringProperty *prop, PropDialog *dialog)
+fileprop_get_widget (StringProperty *prop, PropDialog *dialog)
{
- GtkWidget *ret = dia_file_selector_new();
- if (prop->common.descr->extra_data)
- dia_file_selector_set_extensions (DIAFILESELECTOR(ret), prop->common.descr->extra_data);
- prophandler_connect(&prop->common, G_OBJECT(ret), "value-changed");
+ GtkWidget *ret = dia_file_selector_new ();
+ if (prop->common.descr->extra_data) {
+ dia_file_selector_set_extensions (DIA_FILE_SELECTOR (ret),
+ prop->common.descr->extra_data);
+ }
+ prophandler_connect (&prop->common, G_OBJECT (ret), "value-changed");
return ret;
}
+
static void
-fileprop_reset_widget(StringProperty *prop, GtkWidget *widget)
+fileprop_reset_widget (StringProperty *prop, GtkWidget *widget)
{
- if (prop->string_data)
- dia_file_selector_set_file(DIAFILESELECTOR(widget),prop->string_data);
+ if (prop->string_data) {
+ dia_file_selector_set_file (DIA_FILE_SELECTOR (widget), prop->string_data);
+ }
}
+
static void
-fileprop_set_from_widget(StringProperty *prop, GtkWidget *widget)
+fileprop_set_from_widget (StringProperty *prop, GtkWidget *widget)
{
g_clear_pointer (&prop->string_data, g_free);
prop->string_data =
- g_strdup(dia_file_selector_get_file(DIAFILESELECTOR(widget)));
+ g_strdup (dia_file_selector_get_file (DIA_FILE_SELECTOR (widget)));
}
+
static void
stringprop_load(StringProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
diff --git a/lib/prop_widgets.c b/lib/prop_widgets.c
index 84562d999..1ffdf4fe6 100644
--- a/lib/prop_widgets.c
+++ b/lib/prop_widgets.c
@@ -27,7 +27,6 @@
#include <glib.h>
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "dia-simple-list.h"
diff --git a/lib/propdialogs.c b/lib/propdialogs.c
index 566b7dc25..76cb8c532 100644
--- a/lib/propdialogs.c
+++ b/lib/propdialogs.c
@@ -28,7 +28,6 @@
#include <gtk/gtk.h>
#define WIDGET GtkWidget
-#include "widgets.h"
#include "properties.h"
#include "propinternals.h"
#include "object.h"
diff --git a/lib/widgets.c b/lib/widgets.c
index c9cc3d95a..ceb803ca7 100644
--- a/lib/widgets.c
+++ b/lib/widgets.c
@@ -34,230 +34,6 @@
#include <time.h>
#include <gdk/gdkkeysyms.h>
-/************* DiaSizeSelector: ***************/
-/* A widget that selects two sizes, width and height, optionally keeping
- * aspect ratio. When created, aspect ratio is locked, but the user can
- * unlock it. The current users do not store aspect ratio, so we have
- * to give a good default.
- */
-struct _DiaSizeSelector
-{
- GtkHBox hbox;
- GtkSpinButton *width, *height;
- GtkToggleButton *aspect_locked;
- real ratio;
- GtkAdjustment *last_adjusted;
-};
-
-struct _DiaSizeSelectorClass
-{
- GtkHBoxClass parent_class;
-};
-
-enum {
- DSS_VALUE_CHANGED,
- DSS_LAST_SIGNAL
-};
-
-static guint dss_signals[DSS_LAST_SIGNAL] = { 0 };
-
-static void
-dia_size_selector_class_init (DiaSizeSelectorClass *class)
-{
- dss_signals[DSS_VALUE_CHANGED]
- = g_signal_new("value-changed",
- G_TYPE_FROM_CLASS(class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-dia_size_selector_adjust_width(DiaSizeSelector *ss)
-{
- real height =
- gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->height));
- if (fabs(ss->ratio) > 1e-6)
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(ss->width), height*ss->ratio);
-}
-
-static void
-dia_size_selector_adjust_height(DiaSizeSelector *ss)
-{
- real width =
- gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->width));
- if (fabs(ss->ratio) > 1e-6)
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(ss->height), width/ss->ratio);
-}
-
-static void
-dia_size_selector_ratio_callback(GtkAdjustment *limits, gpointer userdata)
-{
- static gboolean in_progress = FALSE;
- DiaSizeSelector *ss = DIA_SIZE_SELECTOR(userdata);
-
- ss->last_adjusted = limits;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ss->aspect_locked))
- && ss->ratio != 0.0) {
-
- if (in_progress)
- return;
- in_progress = TRUE;
-
- if (limits == gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(ss->width))) {
- dia_size_selector_adjust_height(ss);
- } else {
- dia_size_selector_adjust_width(ss);
- }
-
- in_progress = FALSE;
- }
-
- g_signal_emit(ss, dss_signals[DSS_VALUE_CHANGED], 0);
-
-}
-
-/*
- * Update the ratio of this DSS to be the ratio of width to height.
- * If height is 0, ratio becomes 0.0.
- */
-static void
-dia_size_selector_set_ratio(DiaSizeSelector *ss, real width, real height)
-{
- if (height > 0.0)
- ss->ratio = width/height;
- else
- ss->ratio = 0.0;
-}
-
-static void
-dia_size_selector_lock_pressed(GtkWidget *widget, gpointer data)
-{
- DiaSizeSelector *ss = DIA_SIZE_SELECTOR(data);
-
- dia_size_selector_set_ratio(ss,
- gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->width)),
- gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->height)));
-}
-
-/* Possible args: Init width, init height, digits */
-
-static void
-dia_size_selector_init (DiaSizeSelector *ss)
-{
- GtkAdjustment *adj;
-
- ss->ratio = 0.0;
- /* Here's where we set up the real thing */
- adj = GTK_ADJUSTMENT(gtk_adjustment_new(1.0, 0.01, 10,
- 0.1, 1.0, 0));
- ss->width = GTK_SPIN_BUTTON(gtk_spin_button_new(adj, 1.0, 2));
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(ss->width), TRUE);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(ss->width), TRUE);
- gtk_box_pack_start(GTK_BOX(ss), GTK_WIDGET(ss->width), FALSE, TRUE, 0);
- gtk_widget_show(GTK_WIDGET(ss->width));
-
- adj = GTK_ADJUSTMENT(gtk_adjustment_new(1.0, 0.01, 10,
- 0.1, 1.0, 0));
- ss->height = GTK_SPIN_BUTTON(gtk_spin_button_new(adj, 1.0, 2));
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(ss->height), TRUE);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(ss->height), TRUE);
- gtk_box_pack_start(GTK_BOX(ss), GTK_WIDGET(ss->height), FALSE, TRUE, 0);
- gtk_widget_show(GTK_WIDGET(ss->height));
-
- /* Replace label with images */
- /* should make sure they're both unallocated when the widget dies.
- * That should happen in the "destroy" handler, where both should
- * be unref'd */
- ss->aspect_locked = GTK_TOGGLE_BUTTON (
- dia_toggle_button_new_with_icon_names ("dia-chain-unbroken",
- "dia-chain-broken"));
-
- gtk_container_set_border_width(GTK_CONTAINER(ss->aspect_locked), 0);
-
- gtk_box_pack_start(GTK_BOX(ss), GTK_WIDGET(ss->aspect_locked), FALSE, TRUE, 0);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ss->aspect_locked), TRUE);
- gtk_widget_show(GTK_WIDGET(ss->aspect_locked));
-
- g_signal_connect (G_OBJECT (ss->aspect_locked), "clicked",
- G_CALLBACK (dia_size_selector_lock_pressed), ss);
- /* Make sure that the aspect ratio stays the same */
- g_signal_connect(G_OBJECT(gtk_spin_button_get_adjustment(ss->width)),
- "value_changed",
- G_CALLBACK(dia_size_selector_ratio_callback), (gpointer)ss);
- g_signal_connect(G_OBJECT(gtk_spin_button_get_adjustment(ss->height)),
- "value_changed",
- G_CALLBACK(dia_size_selector_ratio_callback), (gpointer)ss);
-}
-
-GType
-dia_size_selector_get_type (void)
-{
- static GType dss_type = 0;
-
- if (!dss_type) {
- static const GTypeInfo dss_info = {
- sizeof (DiaSizeSelectorClass),
- (GBaseInitFunc)NULL,
- (GBaseFinalizeFunc)NULL,
- (GClassInitFunc)dia_size_selector_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (DiaSizeSelector),
- 0, /* n_preallocs */
- (GInstanceInitFunc) dia_size_selector_init
- };
-
- dss_type = g_type_register_static (gtk_hbox_get_type (),
- "DiaSizeSelector",
- &dss_info, 0);
- }
- return dss_type;
-}
-
-GtkWidget *
-dia_size_selector_new (real width, real height)
-{
- GtkWidget *wid;
-
- wid = GTK_WIDGET ( g_object_new (dia_size_selector_get_type (), NULL));
- dia_size_selector_set_size(DIA_SIZE_SELECTOR(wid), width, height);
- return wid;
-}
-
-void
-dia_size_selector_set_size(DiaSizeSelector *ss, real width, real height)
-{
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(ss->width), width);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON(ss->height), height);
- /*
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ss->aspect_locked),
- fabs(width - height) < 0.000001);
- */
- dia_size_selector_set_ratio(ss, width, height);
-}
-
-void
-dia_size_selector_set_locked(DiaSizeSelector *ss, gboolean locked)
-{
- if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ss->aspect_locked))
- && locked) {
- dia_size_selector_set_ratio(ss,
- gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->width)),
- gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->height)));
- }
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ss->aspect_locked), locked);
-}
-
-gboolean
-dia_size_selector_get_size(DiaSizeSelector *ss, real *width, real *height)
-{
- *width = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->width));
- *height = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ss->height));
- return gtk_toggle_button_get_active(ss->aspect_locked);
-}
/************* DiaAlignmentSelector: ***************/
@@ -290,433 +66,6 @@ dia_alignment_selector_set_alignment (GtkWidget *as,
}
-/************* DiaFileSelector: ***************/
-struct _DiaFileSelector
-{
- GtkHBox hbox;
- GtkEntry *entry;
- GtkButton *browse;
- GtkWidget *dialog;
- char *sys_filename;
- char *pattern; /* for supported formats */
-};
-
-struct _DiaFileSelectorClass
-{
- GtkHBoxClass parent_class;
-};
-
-enum {
- DFILE_VALUE_CHANGED,
- DFILE_LAST_SIGNAL
-};
-
-static guint dfile_signals[DFILE_LAST_SIGNAL] = { 0 };
-
-static void
-dia_file_selector_unrealize(GtkWidget *widget)
-{
- DiaFileSelector *fs = DIAFILESELECTOR(widget);
-
- if (fs->dialog != NULL) {
- gtk_widget_destroy(GTK_WIDGET(fs->dialog));
- fs->dialog = NULL;
- }
- g_clear_pointer (&fs->sys_filename, g_free);
- g_clear_pointer (&fs->pattern, g_free);
-
- (* GTK_WIDGET_CLASS (g_type_class_peek_parent (G_OBJECT_GET_CLASS (fs)))->unrealize) (widget);
-}
-
-static void
-dia_file_selector_class_init (DiaFileSelectorClass *class)
-{
- GtkWidgetClass *widget_class;
-
- widget_class = (GtkWidgetClass*) class;
- widget_class->unrealize = dia_file_selector_unrealize;
-
- dfile_signals[DFILE_VALUE_CHANGED]
- = g_signal_new("value-changed",
- G_TYPE_FROM_CLASS(class),
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-static void
-dia_file_selector_entry_changed(GtkEditable *editable
- , gpointer data)
-{
- DiaFileSelector *fs = DIAFILESELECTOR(data);
- g_signal_emit(fs, dfile_signals[DFILE_VALUE_CHANGED], 0);
-}
-
-
-static void
-file_open_response_callback(GtkWidget *dialog,
- gint response,
- gpointer user_data)
-{
- DiaFileSelector *fs =
- DIAFILESELECTOR(g_object_get_data(G_OBJECT(dialog), "user_data"));
-
- if (response == GTK_RESPONSE_ACCEPT || response == GTK_RESPONSE_OK) {
- char *utf8 = g_filename_to_utf8 (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)),
- -1, NULL, NULL, NULL);
- gtk_entry_set_text (GTK_ENTRY (fs->entry), utf8);
- g_clear_pointer (&utf8, g_free);
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-}
-
-
-static void
-dia_file_selector_browse_pressed (GtkWidget *widget, gpointer data)
-{
- GtkWidget *dialog;
- DiaFileSelector *fs = DIAFILESELECTOR(data);
- char *filename;
- GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
-
- if (toplevel && !GTK_WINDOW(toplevel))
- toplevel = NULL;
-
- if (fs->dialog == NULL) {
- GtkFileFilter *filter;
-
- dialog = fs->dialog =
- gtk_file_chooser_dialog_new (_("Select image file"),
- toplevel ? GTK_WINDOW (toplevel) : NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Open"), GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
- g_signal_connect (G_OBJECT (dialog), "response",
- G_CALLBACK (file_open_response_callback), NULL);
- g_signal_connect (G_OBJECT (fs->dialog), "destroy",
- G_CALLBACK (gtk_widget_destroyed), &fs->dialog);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("Supported Formats"));
- if (fs->pattern)
- gtk_file_filter_add_pattern (filter, fs->pattern);
- else /* fallback */
- gtk_file_filter_add_pixbuf_formats (filter);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- filter = gtk_file_filter_new ();
- gtk_file_filter_set_name (filter, _("All Files"));
- gtk_file_filter_add_pattern (filter, "*");
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
-
- g_object_set_data(G_OBJECT(dialog), "user_data", fs);
- }
-
- filename = g_filename_from_utf8(gtk_entry_get_text(fs->entry), -1, NULL, NULL, NULL);
- /* selecting something in the filechooser officially sucks. See e.g.
http://bugzilla.gnome.org/show_bug.cgi?id=307378 */
- if (g_path_is_absolute(filename))
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fs->dialog), filename);
-
- g_clear_pointer (&filename, g_free);
-
- gtk_widget_show(GTK_WIDGET(fs->dialog));
-}
-
-static void
-dia_file_selector_init (DiaFileSelector *fs)
-{
- /* Here's where we set up the real thing */
- fs->dialog = NULL;
- fs->sys_filename = NULL;
- fs->pattern = NULL;
-
- fs->entry = GTK_ENTRY(gtk_entry_new());
- gtk_box_pack_start(GTK_BOX(fs), GTK_WIDGET(fs->entry), FALSE, TRUE, 0);
- g_signal_connect(G_OBJECT(fs->entry), "changed",
- G_CALLBACK(dia_file_selector_entry_changed), fs);
- gtk_widget_show(GTK_WIDGET(fs->entry));
-
- fs->browse = GTK_BUTTON(gtk_button_new_with_label(_("Browse")));
- gtk_box_pack_start(GTK_BOX(fs), GTK_WIDGET(fs->browse), FALSE, TRUE, 0);
- g_signal_connect (G_OBJECT (fs->browse), "clicked",
- G_CALLBACK(dia_file_selector_browse_pressed), fs);
- gtk_widget_show(GTK_WIDGET(fs->browse));
-}
-
-
-GType
-dia_file_selector_get_type (void)
-{
- static GType dfs_type = 0;
-
- if (!dfs_type) {
- static const GTypeInfo dfs_info = {
- sizeof (DiaFileSelectorClass),
- (GBaseInitFunc)NULL,
- (GBaseFinalizeFunc)NULL,
- (GClassInitFunc)dia_file_selector_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (DiaFileSelector),
- 0, /* n_preallocs */
- (GInstanceInitFunc)dia_file_selector_init,
- };
-
- dfs_type = g_type_register_static (gtk_hbox_get_type (),
- "DiaFileSelector",
- &dfs_info, 0);
- }
- return dfs_type;
-}
-
-GtkWidget *
-dia_file_selector_new (void)
-{
- return GTK_WIDGET ( g_object_new (dia_file_selector_get_type (), NULL));
-}
-
-void
-dia_file_selector_set_extensions (DiaFileSelector *fs, const char **exts)
-{
- GString *pattern = g_string_new ("*.");
- int i = 0;
-
- g_clear_pointer (&fs->pattern, g_free);
-
- while (exts[i] != NULL) {
- if (i != 0)
- g_string_append (pattern, "|*.");
- g_string_append (pattern, exts[i]);
- ++i;
- }
- fs->pattern = pattern->str;
- g_string_free (pattern, FALSE);
-}
-
-
-void
-dia_file_selector_set_file (DiaFileSelector *fs, char *file)
-{
- /* filename is in system encoding */
- char *utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, NULL);
- gtk_entry_set_text (GTK_ENTRY (fs->entry), utf8);
- g_clear_pointer (&utf8, g_free);
-}
-
-
-const char *
-dia_file_selector_get_file(DiaFileSelector *fs)
-{
- /* let it behave like gtk_file_selector_get_file */
- g_clear_pointer (&fs->sys_filename, g_free);
- fs->sys_filename = g_filename_from_utf8(gtk_entry_get_text(GTK_ENTRY(fs->entry)),
- -1, NULL, NULL, NULL);
- return fs->sys_filename;
-}
-
-/************* DiaUnitSpinner: ***************/
-
-/**
- * DiaUnitSpinner:
- *
- * A Spinner that allows a 'favoured' unit to display in. External access
- * to the value still happens in cm, but display is in the favored unit.
- * Internally, the value is kept in the favored unit to a) allow proper
- * limits, and b) avoid rounding problems while editing.
- *
- * Since: dawn-of-time
- */
-
-static void dia_unit_spinner_init(DiaUnitSpinner *self);
-
-GType
-dia_unit_spinner_get_type(void)
-{
- static GType us_type = 0;
-
- if (!us_type) {
- static const GTypeInfo us_info = {
- sizeof(DiaUnitSpinnerClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- NULL, /* class_init*/
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(DiaUnitSpinner),
- 0, /* n_preallocs */
- (GInstanceInitFunc) dia_unit_spinner_init,
- };
- us_type = g_type_register_static(GTK_TYPE_SPIN_BUTTON,
- "DiaUnitSpinner",
- &us_info, 0);
- }
- return us_type;
-}
-
-
-static void
-dia_unit_spinner_init(DiaUnitSpinner *self)
-{
- self->unit_num = DIA_UNIT_CENTIMETER;
-}
-
-/*
- Callback functions for the "input" and "output" signals emitted by
- GtkSpinButton. All the normal work is done by the spin button, we
- simply modify how the text in the GtkEntry is treated.
-*/
-static gboolean dia_unit_spinner_input(DiaUnitSpinner *self, gdouble *value);
-static gboolean dia_unit_spinner_output(DiaUnitSpinner *self);
-
-GtkWidget *
-dia_unit_spinner_new(GtkAdjustment *adjustment, DiaUnit adj_unit)
-{
- DiaUnitSpinner *self;
-
- if (adjustment) {
- g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
- }
-
- self = g_object_new(dia_unit_spinner_get_type(), NULL);
- gtk_entry_set_activates_default(GTK_ENTRY(self), TRUE);
- self->unit_num = adj_unit;
-
- gtk_spin_button_configure (GTK_SPIN_BUTTON (self),
- adjustment, 0.0, dia_unit_get_digits (adj_unit));
-
- g_signal_connect(GTK_SPIN_BUTTON(self), "output",
- G_CALLBACK(dia_unit_spinner_output),
- NULL);
- g_signal_connect(GTK_SPIN_BUTTON(self), "input",
- G_CALLBACK(dia_unit_spinner_input),
- NULL);
-
- return GTK_WIDGET(self);
-}
-
-
-static gboolean
-dia_unit_spinner_input (DiaUnitSpinner *self, double *value)
-{
- double val, factor = 1.0;
- char *extra = NULL;
-
- val = g_strtod (gtk_entry_get_text (GTK_ENTRY (self)), &extra);
-
- /* get rid of extra white space after number */
- while (*extra && g_ascii_isspace (*extra)) {
- extra++;
- }
-
- if (*extra) {
- for (int i = 0; i < DIA_LAST_UNIT; i++) {
- if (!g_ascii_strcasecmp (dia_unit_get_symbol (i), extra)) {
- factor = dia_unit_get_factor (i) /
- dia_unit_get_factor (self->unit_num);
- break;
- }
- }
- }
-
- /* convert to prefered units */
- val *= factor;
-
- /* Store value in the location provided by the signal emitter. */
- *value = val;
-
- /* Return true, so that the default input function is not invoked. */
- return TRUE;
-}
-
-
-static gboolean
-dia_unit_spinner_output (DiaUnitSpinner *self)
-{
- char buf[256];
- GtkSpinButton *sbutton = GTK_SPIN_BUTTON (self);
- GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (sbutton);
-
- g_snprintf (buf,
- sizeof(buf),
- "%0.*f %s",
- gtk_spin_button_get_digits(sbutton),
- gtk_adjustment_get_value(adjustment),
- dia_unit_get_symbol (self->unit_num));
- gtk_entry_set_text (GTK_ENTRY(self), buf);
-
- /* Return true, so that the default output function is not invoked. */
- return TRUE;
-}
-
-
-/**
- * dia_unit_spinner_set_value:
- * @self: the DiaUnitSpinner
- * @val: value in %DIA_UNIT_CENTIMETER
- *
- * Set the value (in cm).
- *
- * Since: dawn-of-time
- */
-void
-dia_unit_spinner_set_value (DiaUnitSpinner *self, double val)
-{
- GtkSpinButton *sbutton = GTK_SPIN_BUTTON(self);
-
- gtk_spin_button_set_value (sbutton,
- val /
- (dia_unit_get_factor (self->unit_num) /
- (dia_unit_get_factor (DIA_UNIT_CENTIMETER))));
-}
-
-
-/**
- * dia_unit_spinner_get_value:
- * @self: the DiaUnitSpinner
- *
- * Get the value (in cm)
- *
- * Returns: The value in %DIA_UNIT_CENTIMETER
- *
- * Since: dawn-of-time
- */
-double
-dia_unit_spinner_get_value (DiaUnitSpinner *self)
-{
- GtkSpinButton *sbutton = GTK_SPIN_BUTTON(self);
-
- return gtk_spin_button_get_value (sbutton) *
- (dia_unit_get_factor (self->unit_num) /
- dia_unit_get_factor (DIA_UNIT_CENTIMETER));
-}
-
-
-/**
- * dia_unit_spinner_set_upper:
- * @self: the DiaUnitSpinner
- * @val: value in %DIA_UNIT_CENTIMETER
- *
- * Must manipulate the limit values through this to also consider unit.
- *
- * Given value is in centimeter.
- *
- * Since: dawn-of-time
- */
-void
-dia_unit_spinner_set_upper (DiaUnitSpinner *self, double val)
-{
- val /= (dia_unit_get_factor (self->unit_num) /
- dia_unit_get_factor (DIA_UNIT_CENTIMETER));
-
- gtk_adjustment_set_upper (
- gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (self)), val);
-}
-
-
/* ************************ Misc. util functions ************************ */
struct image_pair { GtkWidget *on; GtkWidget *off; };
diff --git a/lib/widgets.h b/lib/widgets.h
index f632c845b..3064f1e49 100644
--- a/lib/widgets.h
+++ b/lib/widgets.h
@@ -15,122 +15,28 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef WIDGETS_H
-#define WIDGETS_H
+
+#pragma once
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#include "diatypes.h"
-#include "font.h"
-#include "color.h"
-#include "arrows.h"
-#include "units.h"
-#include "dia-autoptr.h"
-
-/* DiaAlignmentSelector: */
-GtkWidget* dia_alignment_selector_new (void);
-Alignment dia_alignment_selector_get_alignment (GtkWidget *as);
-void dia_alignment_selector_set_alignment (GtkWidget *as, Alignment align);
-
-/* DiaLineStyleSelector: */
-#define DIALINESTYLESELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_line_style_selector_get_type
(), DiaLineStyleSelector)
-#define DIALINESTYLESELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_line_style_selector_get_type
(), DiaLineStyleSelectorClass)
-#define IS_DIALINESTYLESELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_line_style_selector_get_type
())
-
-GType dia_line_style_selector_get_type (void);
-GtkWidget* dia_line_style_selector_new (void);
-void dia_line_style_selector_get_linestyle (DiaLineStyleSelector *as,
- LineStyle *linestyle,
- real *dashlength);
-void dia_line_style_selector_set_linestyle (DiaLineStyleSelector *as,
- LineStyle linestyle,
- real dashlength);
-
-/* DiaColorSelector: */
-#define DIACOLORSELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_color_selector_get_type (),
DiaColorSelector)
-#define DIACOLORSELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_color_selector_get_type (),
DiaColorSelectorClass)
-#define IS_DIACOLORSELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_color_selector_get_type ())
-
-GType dia_color_selector_get_type (void);
-GtkWidget* dia_color_selector_new (void);
-void dia_color_selector_set_use_alpha (GtkWidget *cs, gboolean use_alpha);
-void dia_color_selector_get_color (GtkWidget *cs, Color *color);
-void dia_color_selector_set_color (GtkWidget *cs,
- const Color *color);
-
-
-/* DiaArrowSelector */
-#define DIA_TYPE_ARROW_SELECTOR (dia_arrow_selector_get_type())
-#define DIA_ARROW_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, dia_arrow_selector_get_type (),
DiaArrowSelector))
-#define DIA_ARROW_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, dia_arrow_selector_get_type (),
DiaArrowSelectorClass))
-#define DIA_IS_ARROW_SELECTOR(obj) (G_TYPE_CHECK_TYPE (obj, dia_arrow_selector_get_type ()))
-#define DIA_ARROW_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DIA_TYPE_ARROW_SELECTOR,
DiaArrowSelectorClass))
-
-#define DEFAULT_ARROW ARROW_NONE
-#define DEFAULT_ARROW_LENGTH DEFAULT_ARROW_SIZE
-#define DEFAULT_ARROW_WIDTH DEFAULT_ARROW_SIZE
-
-
-GType dia_arrow_selector_get_type (void);
-GtkWidget* dia_arrow_selector_new (void);
-Arrow dia_arrow_selector_get_arrow (DiaArrowSelector *as);
-void dia_arrow_selector_set_arrow (DiaArrowSelector *as,
- Arrow arrow);
-
+#include "dia-enums.h"
-/* DiaFileSelector: */
-#define DIAFILESELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_file_selector_get_type (),
DiaFileSelector)
-#define DIAFILESELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_file_selector_get_type (),
DiaFileSelectorClass)
-#define IS_DIAFILESELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_file_selector_get_type ())
+G_BEGIN_DECLS
-
-GType dia_file_selector_get_type (void);
-GtkWidget* dia_file_selector_new (void);
-void dia_file_selector_set_extensions (DiaFileSelector *fs, const gchar **exts);
-void dia_file_selector_set_file (DiaFileSelector *fs, char *file);
-const gchar *dia_file_selector_get_file (DiaFileSelector *fs);
-
-/* DiaSizeSelector: */
-#define DIA_SIZE_SELECTOR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, dia_size_selector_get_type (),
DiaSizeSelector)
-#define DIA_SIZE_SELECTOR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, dia_size_selector_get_type (),
DiaSizeSelectorClass)
-#define IS_DIA_SIZE_SELECTOR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, dia_size_selector_get_type ())
-
-
-GType dia_size_selector_get_type (void);
-GtkWidget* dia_size_selector_new (real width, real height);
-void dia_size_selector_set_locked(DiaSizeSelector *ss, gboolean locked);
-void dia_size_selector_set_size (DiaSizeSelector *ss, real width, real height);
-gboolean dia_size_selector_get_size (DiaSizeSelector *ss, real *width, real *height);
-
-
-/* DiaUnitSpinner */
-
-struct _DiaUnitSpinner {
- GtkSpinButton parent;
-
- DiaUnit unit_num;
-};
-
-
-#define DIA_TYPE_UNIT_SPINNER dia_unit_spinner_get_type ()
-G_DECLARE_FINAL_TYPE (DiaUnitSpinner, dia_unit_spinner, DIA, UNIT_SPINNER, GtkSpinButton)
-
-
-GtkWidget *dia_unit_spinner_new (GtkAdjustment *adjustment,
- DiaUnit adj_unit);
-void dia_unit_spinner_set_value (DiaUnitSpinner *self,
- double val);
-double dia_unit_spinner_get_value (DiaUnitSpinner *self);
-void dia_unit_spinner_set_upper (DiaUnitSpinner *self,
- double val);
+/* DiaAlignmentSelector: */
+GtkWidget *dia_alignment_selector_new (void);
+Alignment dia_alignment_selector_get_alignment (GtkWidget *as);
+void dia_alignment_selector_set_alignment (GtkWidget *as,
+ Alignment align);
/* **** Util functions for Gtk stuff **** */
-GtkWidget *dia_toggle_button_new_with_icon_names (const gchar *on,
- const gchar *off);
+GtkWidget *dia_toggle_button_new_with_icon_names (const char *on,
+ const char *off);
-GdkPixbuf *pixbuf_from_resource (const gchar *path);
+GdkPixbuf *pixbuf_from_resource (const char *path);
/* Other common defaults */
@@ -138,4 +44,4 @@ GdkPixbuf *pixbuf_from_resource (const gchar *path);
/* This is defined in app/linewidth_area.c. Aw, bummer */
#define DEFAULT_LINE_WIDTH 2*0.05
-#endif /* WIDGETS_H */
+G_END_DECLS
diff --git a/objects/UML/class_dialog.c b/objects/UML/class_dialog.c
index d66218720..b88897a83 100644
--- a/objects/UML/class_dialog.c
+++ b/objects/UML/class_dialog.c
@@ -40,7 +40,6 @@
#include "intl.h"
#include "class.h"
#include "diaoptionmenu.h"
-#include "diafontselector.h"
#include "class_dialog.h"
@@ -234,9 +233,12 @@ class_read_from_dialog(UMLClass *umlclass, UMLClassDialog *prop_dialog)
umlclass->suppress_attributes = gtk_toggle_button_get_active (prop_dialog->attr_supp);
umlclass->suppress_operations = gtk_toggle_button_get_active (prop_dialog->op_supp);
umlclass->line_width = gtk_spin_button_get_value (prop_dialog->line_width);
- dia_color_selector_get_color (GTK_WIDGET (prop_dialog->text_color), ¨class->text_color);
- dia_color_selector_get_color (GTK_WIDGET (prop_dialog->line_color), ¨class->line_color);
- dia_color_selector_get_color (GTK_WIDGET (prop_dialog->fill_color), ¨class->fill_color);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (prop_dialog->text_color),
+ ¨class->text_color);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (prop_dialog->line_color),
+ ¨class->line_color);
+ dia_colour_selector_get_colour (DIA_COLOUR_SELECTOR (prop_dialog->fill_color),
+ ¨class->fill_color);
umlclass->normal_font = dia_font_selector_get_font (prop_dialog->normal_font);
umlclass->polymorphic_font = dia_font_selector_get_font (prop_dialog->polymorphic_font);
@@ -283,9 +285,9 @@ class_fill_in_dialog(UMLClass *umlclass)
gtk_toggle_button_set_active(prop_dialog->attr_supp, umlclass->suppress_attributes);
gtk_toggle_button_set_active(prop_dialog->op_supp, umlclass->suppress_operations);
gtk_spin_button_set_value (prop_dialog->line_width, umlclass->line_width);
- dia_color_selector_set_color(GTK_WIDGET(prop_dialog->text_color), ¨class->text_color);
- dia_color_selector_set_color(GTK_WIDGET(prop_dialog->line_color), ¨class->line_color);
- dia_color_selector_set_color(GTK_WIDGET(prop_dialog->fill_color), ¨class->fill_color);
+ dia_colour_selector_set_colour (prop_dialog->text_color, ¨class->text_color);
+ dia_colour_selector_set_colour (prop_dialog->line_color, ¨class->line_color);
+ dia_colour_selector_set_colour (prop_dialog->fill_color, ¨class->fill_color);
dia_font_selector_set_font (prop_dialog->normal_font, umlclass->normal_font);
dia_font_selector_set_font (prop_dialog->polymorphic_font, umlclass->polymorphic_font);
dia_font_selector_set_font (prop_dialog->abstract_font, umlclass->abstract_font);
@@ -533,27 +535,30 @@ style_create_page(GtkNotebook *notebook, UMLClass *umlclass)
label = gtk_label_new (_("Text Color"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 2);
- text_color = dia_color_selector_new ();
- dia_color_selector_set_use_alpha (text_color, TRUE);
- dia_color_selector_set_color (text_color, ¨class->text_color);
- prop_dialog->text_color = (DiaColorSelector *) text_color;
+ text_color = dia_colour_selector_new ();
+ dia_colour_selector_set_use_alpha (DIA_COLOUR_SELECTOR (text_color), TRUE);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (text_color),
+ ¨class->text_color);
+ prop_dialog->text_color = DIA_COLOUR_SELECTOR (text_color);
gtk_table_attach (GTK_TABLE (table), text_color, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 3, 2);
label = gtk_label_new(_("Foreground Color"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, 0, 2);
- line_color = dia_color_selector_new();
- dia_color_selector_set_use_alpha (line_color, TRUE);
- dia_color_selector_set_color(line_color, ¨class->line_color);
- prop_dialog->line_color = (DiaColorSelector *)line_color;
+ line_color = dia_colour_selector_new ();
+ dia_colour_selector_set_use_alpha (DIA_COLOUR_SELECTOR (line_color), TRUE);
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (line_color),
+ ¨class->line_color);
+ prop_dialog->line_color = DIA_COLOUR_SELECTOR (line_color);
gtk_table_attach (GTK_TABLE (table), line_color, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 3, 2);
label = gtk_label_new(_("Background Color"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 2);
- fill_color = dia_color_selector_new();
- dia_color_selector_set_color(fill_color, ¨class->fill_color);
- prop_dialog->fill_color = (DiaColorSelector *)fill_color;
+ fill_color = dia_colour_selector_new();
+ dia_colour_selector_set_colour (DIA_COLOUR_SELECTOR (fill_color),
+ ¨class->fill_color);
+ prop_dialog->fill_color = DIA_COLOUR_SELECTOR (fill_color);
gtk_table_attach (GTK_TABLE (table), fill_color, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 3, 2);
gtk_widget_show_all (vbox);
diff --git a/objects/UML/class_dialog.h b/objects/UML/class_dialog.h
index c162b841f..6bbb4b404 100644
--- a/objects/UML/class_dialog.h
+++ b/objects/UML/class_dialog.h
@@ -1,6 +1,7 @@
#pragma once
-#include "widgets.h"
+#include "dia-colour-selector.h"
+#include "dia-font-selector.h"
G_BEGIN_DECLS
@@ -47,9 +48,9 @@ struct _UMLClassDialog {
GtkSpinButton *comment_line_length;
GtkToggleButton *comment_tagging;
GtkSpinButton *line_width;
- DiaColorSelector *text_color;
- DiaColorSelector *line_color;
- DiaColorSelector *fill_color;
+ DiaColourSelector *text_color;
+ DiaColourSelector *line_color;
+ DiaColourSelector *fill_color;
GtkLabel *max_length_label;
GtkLabel *Comment_length_label;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]