[gnumeric] GnmSOLine: use new GOArrowSel widget.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GnmSOLine: use new GOArrowSel widget.
- Date: Wed, 11 Feb 2015 14:40:17 +0000 (UTC)
commit 9e634828347d75b8698e476b668d8f35d49ad58c
Author: Morten Welinder <terra gnome org>
Date: Wed Feb 11 09:39:51 2015 -0500
GnmSOLine: use new GOArrowSel widget.
src/dialogs/dialog-so-styled.c | 84 +++++++---------------------------------
1 files changed, 14 insertions(+), 70 deletions(-)
---
diff --git a/src/dialogs/dialog-so-styled.c b/src/dialogs/dialog-so-styled.c
index 94f6ff8..104ec93 100644
--- a/src/dialogs/dialog-so-styled.c
+++ b/src/dialogs/dialog-so-styled.c
@@ -43,11 +43,6 @@ typedef struct {
char *orig_text;
PangoAttrList *orig_attributes;
so_styled_t extent;
-
- GtkWidget *spin_a;
- GtkWidget *spin_b;
- GtkWidget *spin_c;
- GtkWidget *arrow_draw;
} DialogSOStyled;
#define GNM_SO_STYLED_KEY "gnm-so-styled-key"
@@ -129,82 +124,31 @@ dialog_so_styled_text_widget (DialogSOStyled *state)
}
static void
-cb_arrow_changed (GtkWidget *spin, DialogSOStyled *state)
+cb_arrow_changed (GOArrowSel *as,
+ G_GNUC_UNUSED GParamSpec *pspec,
+ DialogSOStyled *state)
{
- GOArrow *arrow;
-
- g_object_get (state->so, "end-arrow", &arrow, NULL);
- arrow->a = gtk_spin_button_get_value (GTK_SPIN_BUTTON (state->spin_a));
- arrow->b = gtk_spin_button_get_value (GTK_SPIN_BUTTON (state->spin_b));
- arrow->c = gtk_spin_button_get_value (GTK_SPIN_BUTTON (state->spin_c));
- g_object_set (state->so, "end-arrow", arrow, NULL);
- g_free (arrow);
-
- gtk_widget_queue_draw (state->arrow_draw);
-}
-
-static gboolean
-cb_draw_arrow (GtkWidget *widget, cairo_t *cr, DialogSOStyled *state)
-{
- GOArrow *arrow;
- GOStyle *style;
- guint width = gtk_widget_get_allocated_width (widget);
- guint height = gtk_widget_get_allocated_height (widget);
-
- g_object_get (state->so, "end-arrow", &arrow, "style", &style, NULL);
-
- cairo_save (cr);
- cairo_translate (cr, width / 2, height / 2);
- /* cairo_scale (cr, 2, 2); */
- cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (style->line.color));
- go_arrow_draw (arrow, cr, NULL, NULL, 0);
- cairo_restore (cr);
-
- g_object_unref (style);
- g_free (arrow);
- return FALSE;
+ g_object_set (state->so,
+ "end-arrow", go_arrow_sel_get_arrow (as),
+ NULL);
}
static GtkWidget *
dialog_so_styled_line_widget (DialogSOStyled *state)
{
- GtkGrid *grid = GTK_GRID (gtk_grid_new ());
+ GtkWidget *w = go_arrow_sel_new ();
GOArrow *arrow;
- double LIM = 25, STEP = 0.1;
g_object_get (state->so, "end-arrow", &arrow, NULL);
-
- g_object_set (grid, "border-width", 12, "column-spacing", 12, "row-spacing", 6, NULL);
-
- gtk_grid_attach (grid, gtk_label_new (_("Type")), 0, 0, 1, 1);
- gtk_grid_attach (grid, gtk_label_new (_("A")), 0, 1, 1, 1);
- gtk_grid_attach (grid, gtk_label_new (_("B")), 0, 2, 1, 1);
- gtk_grid_attach (grid, gtk_label_new (_("C")), 0, 3, 1, 1);
-
- state->spin_a = gtk_spin_button_new_with_range (0, LIM, STEP);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->spin_a), arrow->a);
- g_signal_connect (state->spin_a, "value-changed", G_CALLBACK (cb_arrow_changed), state);
- gtk_grid_attach (grid, state->spin_a, 1, 1, 1, 1);
-
- state->spin_b = gtk_spin_button_new_with_range (0, LIM, STEP);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->spin_b), arrow->b);
- g_signal_connect (state->spin_b, "value-changed", G_CALLBACK (cb_arrow_changed), state);
- gtk_grid_attach (grid, state->spin_b, 1, 2, 1, 1);
-
- state->spin_c = gtk_spin_button_new_with_range (0, LIM, STEP);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (state->spin_c), arrow->c);
- g_signal_connect (state->spin_c, "value-changed", G_CALLBACK (cb_arrow_changed), state);
- gtk_grid_attach (grid, state->spin_c, 1, 3, 1, 1);
-
- state->arrow_draw = gtk_drawing_area_new ();
- gtk_widget_set_size_request (state->arrow_draw, 100, 100);
- gtk_grid_attach (grid, state->arrow_draw, 2, 0, 1, 4);
- g_signal_connect (G_OBJECT (state->arrow_draw), "draw",
- G_CALLBACK (cb_draw_arrow), state);
-
+ go_arrow_sel_set_arrow (GO_ARROW_SEL (w), arrow);
g_free (arrow);
- return GTK_WIDGET (grid);
+ g_signal_connect (G_OBJECT (w),
+ "notify::arrow",
+ G_CALLBACK (cb_arrow_changed),
+ state);
+
+ return w;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]