[goffice] Add sample plot to the plot type selector.
- From: Jean Bréfort <jbrefort src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [goffice] Add sample plot to the plot type selector.
- Date: Thu, 14 Jan 2010 10:10:58 +0000 (UTC)
commit 5790c454b303a217ffbde71790e065e92d9f9662
Author: Jean Brefort <jean brefort normalesup org>
Date: Thu Jan 14 11:12:15 2010 +0100
Add sample plot to the plot type selector.
ChangeLog | 9 ++
NEWS | 2 +
goffice/graph/gog-guru-type-selector.ui | 138 ++++++------------------------
goffice/graph/gog-guru.c | 115 ++++++++++----------------
plugins/plot_barcol/plot-types.xml.in | 12 ++--
5 files changed, 90 insertions(+), 186 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1c408e3..6f27e35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-01-14 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/graph/gog-guru-type-selector.ui: add a sample and remove obsolete
+ widgets. [#495781 and #606162].
+ * goffice/graph/gog-guru.c (cb_typesel_sample_plot_resize),
+ (graph_typeselect_minor), (cb_selection_changed),
+ (cb_plot_types_init), (cb_plot_families_init),
+ (graph_guru_type_selector_new), (gog_guru_add_custom_widget):
+
2010-01-12 Jean Brefort <jean brefort normalesup org>
* goffice/graph/gog-guru.c (graph_typeselect_minor),
diff --git a/NEWS b/NEWS
index fadb55e..d7b694a 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ Jean:
* Add a name to regression curves for display in legends. [#605040]
* Fixed GocPolygon bounds. [#605496]
* Moved plot area position page from plot to chart. [#605771]
+ * Add sample to the plot type selector. [#495781]
+ * Don't use multiline GtkLabel. [#606162]
--------------------------------------------------------------------------
goffice 0.7.17:
diff --git a/goffice/graph/gog-guru-type-selector.ui b/goffice/graph/gog-guru-type-selector.ui
index cd7a24b..f2232ad 100644
--- a/goffice/graph/gog-guru-type-selector.ui
+++ b/goffice/graph/gog-guru-type-selector.ui
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<interface>
+ <!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAlignment" id="type_selector">
<property name="visible">True</property>
@@ -68,13 +69,10 @@
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
- <object class="GtkLabel" id="subtype_label">
+ <object class="GtkLabel" id="sample-label">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes"><b>_Subtype</b></property>
+ <property name="label" translatable="yes"><b>Sample</b></property>
<property name="use_markup">True</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">type_treeview</property>
</object>
<packing>
<property name="expand">False</property>
@@ -83,70 +81,31 @@
</packing>
</child>
<child>
- <object class="GtkFrame" id="canvas_container">
+ <object class="GtkFrame" id="sample-container">
+ <property name="height_request">240</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
+ <child type="label_item">
+ <placeholder/>
+ </child>
</object>
<packing>
+ <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkAlignment" id="alignment10">
+ <object class="GtkLabel" id="subtype_label">
<property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="yalign">0</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <property name="top_padding">6</property>
- <child>
- <object class="GtkButton" id="sample_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="focus_on_click">False</property>
- <child>
- <object class="GtkAlignment" id="alignment8">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <object class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="image27">
- <property name="visible">True</property>
- <property name="stock">gtk-dialog-info</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="sample_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Show sample</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>_Subtype</b></property>
+ <property name="use_markup">True</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">type_treeview</property>
</object>
<packing>
<property name="expand">False</property>
@@ -154,74 +113,33 @@
<property name="position">2</property>
</packing>
</child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="spacing">24</property>
- <child>
- <object class="GtkVBox" id="vbox3">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="description_title_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes"><b>Description</b></property>
- <property name="use_markup">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkFrame" id="frame2">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">in</property>
<child>
- <object class="GtkLabel" id="description_label">
- <property name="height_request">60</property>
+ <object class="GtkScrolledWindow" id="canvas-container">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="xpad">6</property>
- <property name="ypad">6</property>
- <property name="wrap">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
+ <packing>
+ <property name="position">3</property>
+ </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
<packing>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
diff --git a/goffice/graph/gog-guru.c b/goffice/graph/gog-guru.c
index 0f2b819..0bf27ce 100644
--- a/goffice/graph/gog-guru.c
+++ b/goffice/graph/gog-guru.c
@@ -90,8 +90,7 @@ struct _GraphGuruState {
struct _GraphGuruTypeSelector {
GtkBuilder *gui;
GtkWidget *canvas;
- GtkWidget *sample_button;
- GtkLabel *label;
+ GtkWidget *sample_canvas;
GtkTreeView *list_view;
GtkListStore *model;
GocItem *selector;
@@ -132,6 +131,7 @@ enum {
#define FIRST_MINOR_TYPE "first_minor_type"
#define ROLE_KEY "role"
#define STATE_KEY "plot_type"
+#define ROWS_KEY "rows-key"
static void
get_pos (int col, int row, double *x, double *y)
@@ -140,6 +140,17 @@ get_pos (int col, int row, double *x, double *y)
*y = (row-1) * (MINOR_PIXMAP_HEIGHT + BORDER) + BORDER;
}
+static void
+cb_typesel_sample_plot_resize (GocCanvas *canvas,
+ GtkAllocation *alloc, GraphGuruTypeSelector *typesel)
+{
+ if (typesel->sample_graph_item != NULL)
+ goc_item_set (typesel->sample_graph_item,
+ "width", (double)alloc->width,
+ "height", (double)alloc->height,
+ NULL);
+}
+
/*
* graph_typeselect_minor :
*
@@ -172,8 +183,6 @@ graph_typeselect_minor (GraphGuruTypeSelector *typesel, GocItem *item)
"x", x1-1., "y", y1-1.,
"width", x2-x1+2., "height", y2-y1+2.,
NULL);
- gtk_label_set_text (typesel->label, _(type->description));
- gtk_widget_set_sensitive (typesel->sample_button, TRUE);
enable_next_button = (s->plot == NULL);
@@ -200,6 +209,16 @@ graph_typeselect_minor (GraphGuruTypeSelector *typesel, GocItem *item)
gtk_widget_set_sensitive (s->button_navigate, TRUE);
g_object_set_data (G_OBJECT (typesel->selector), PLOT_TYPE_KEY, (gpointer)type);
+ if (typesel->sample_graph_item == NULL) {
+ GtkAllocation size;
+ typesel->sample_graph_item = goc_item_new (typesel->graph_group,
+ GOC_TYPE_GRAPH,
+ "graph", typesel->state->graph,
+ NULL);
+ gtk_widget_get_allocation (GTK_WIDGET (typesel->sample_canvas), &size);
+ cb_typesel_sample_plot_resize (GOC_CANVAS (typesel->sample_canvas),
+ &size, typesel);
+ }
}
static gboolean
@@ -285,6 +304,7 @@ cb_selection_changed (GraphGuruTypeSelector *typesel)
GtkTreeIter iter;
GocItem *item;
GocGroup *group;
+ int rows;
if (typesel->current_family_item != NULL)
goc_item_hide (GOC_ITEM (typesel->current_family_item));
@@ -299,55 +319,13 @@ cb_selection_changed (GraphGuruTypeSelector *typesel)
goc_item_hide (GOC_ITEM (typesel->selector));
item = g_object_get_data (G_OBJECT (group), FIRST_MINOR_TYPE);
+ rows = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (group), ROWS_KEY));
if (item != NULL)
graph_typeselect_minor (typesel, item);
goc_item_show (GOC_ITEM (typesel->selector));
-}
-
-static void
-cb_typesel_sample_plot_resize (GocCanvas *canvas,
- GtkAllocation *alloc, GraphGuruTypeSelector *typesel)
-{
- if (typesel->sample_graph_item != NULL)
- goc_item_set (typesel->sample_graph_item,
- "width", (double)alloc->width,
- "height", (double)alloc->height,
- NULL);
-}
-
-static void
-cb_sample_pressed (GraphGuruTypeSelector *typesel)
-{
- if (typesel->current_family_item == NULL)
- return;
-
- if (typesel->sample_graph_item == NULL) {
- GtkAllocation size;
- gtk_widget_get_allocation (GTK_WIDGET (typesel->canvas), &size);
- typesel->sample_graph_item = goc_item_new (typesel->graph_group,
- GOC_TYPE_GRAPH,
- "graph", typesel->state->graph,
- NULL);
- cb_typesel_sample_plot_resize (GOC_CANVAS (typesel->canvas),
- &size, typesel);
-
- g_return_if_fail (typesel->sample_graph_item != NULL);
- }
-
- goc_item_hide (GOC_ITEM (typesel->current_family_item));
- goc_item_hide (GOC_ITEM (typesel->selector));
- goc_item_show (GOC_ITEM (typesel->graph_group));
-}
-
-static void
-cb_sample_released (GraphGuruTypeSelector *typesel)
-{
- if (typesel->current_family_item == NULL)
- return;
-
- goc_item_hide (GOC_ITEM (typesel->graph_group));
- goc_item_show (GOC_ITEM (typesel->current_family_item));
- goc_item_show (GOC_ITEM (typesel->selector));
+ gtk_widget_set_size_request (typesel->canvas,
+ MINOR_PIXMAP_WIDTH*3 + BORDER*5,
+ (MINOR_PIXMAP_HEIGHT + BORDER) * rows + BORDER);
}
typedef struct {
@@ -356,6 +334,7 @@ typedef struct {
GocItem *current_item;
GogPlotType *current_type;
int col, row;
+ int max_row;
} type_list_closure;
typedef GocPixbuf GogGuruPixbuf;
@@ -436,6 +415,8 @@ cb_plot_types_init (char const *id, GogPlotType *type,
closure->col = col;
closure->row = row;
}
+ if (row > closure->max_row)
+ closure->max_row = row;
}
static void
@@ -475,12 +456,15 @@ cb_plot_families_init (char const *id, GogPlotFamily *family,
closure.group = group;
closure.current_type = NULL;
closure.current_item = NULL;
+ closure.max_row = 2;
/* Init the list and the canvas group for each family */
g_hash_table_foreach (family->types,
(GHFunc) cb_plot_types_init, &closure);
g_object_set_data (G_OBJECT (group), FIRST_MINOR_TYPE,
closure.current_item);
+ g_object_set_data (G_OBJECT (group), ROWS_KEY,
+ GUINT_TO_POINTER (closure.max_row));
}
static void
@@ -1202,13 +1186,8 @@ graph_guru_type_selector_new (GraphGuruState *s)
/* Setup an canvas to display the sample image & the sample plot. */
typesel->canvas = GTK_WIDGET (g_object_new (GOC_TYPE_CANVAS, NULL));
- typesel->graph_group = GOC_GROUP (goc_item_new (
- goc_canvas_get_root (GOC_CANVAS (typesel->canvas)),
- goc_group_get_type (),
- NULL));
g_object_connect (typesel->canvas,
"signal::realize", G_CALLBACK (cb_canvas_realized), typesel,
- "signal::size_allocate", G_CALLBACK (cb_typesel_sample_plot_resize), typesel,
"signal_after::key_press_event", G_CALLBACK (cb_key_press_event), typesel,
"signal::button_press_event", G_CALLBACK (cb_button_press_event), typesel,
"swapped_signal::focus_in_event", G_CALLBACK (typesel_set_selection_color), typesel,
@@ -1216,9 +1195,15 @@ graph_guru_type_selector_new (GraphGuruState *s)
NULL);
gtk_widget_set_size_request (typesel->canvas,
MINOR_PIXMAP_WIDTH*3 + BORDER*5,
- MINOR_PIXMAP_HEIGHT*3 + BORDER*5);
- gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (gui, "canvas_container")),
+ MINOR_PIXMAP_HEIGHT*3 + BORDER*4);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (gtk_builder_get_object (gui, "canvas-container")),
typesel->canvas);
+ typesel->sample_canvas = GTK_WIDGET (g_object_new (GOC_TYPE_CANVAS, NULL));
+ g_object_connect (typesel->sample_canvas,
+ "signal::size_allocate", G_CALLBACK (cb_typesel_sample_plot_resize), typesel,
+ NULL);
+ typesel->graph_group = goc_canvas_get_root (GOC_CANVAS (typesel->sample_canvas));
+ gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (gui, "sample-container")), typesel->sample_canvas);
/* Init the list and the canvas group for each family */
g_hash_table_foreach ((GHashTable *)gog_plot_families (),
@@ -1240,18 +1225,6 @@ graph_guru_type_selector_new (GraphGuruState *s)
style->line.color = 0x000000ff; /* black */
typesel_set_selection_color (typesel);
- /* Setup the description label */
- typesel->label = GTK_LABEL (gtk_builder_get_object (gui, "description_label"));
-
- /* Set up sample button */
- typesel->sample_button = go_gtk_builder_get_widget (gui, "sample_button");
- g_signal_connect_swapped (G_OBJECT (typesel->sample_button),
- "pressed",
- G_CALLBACK (cb_sample_pressed), typesel);
- g_signal_connect_swapped (G_OBJECT (typesel->sample_button),
- "released",
- G_CALLBACK (cb_sample_released), typesel);
-
g_object_set_data_full (G_OBJECT (selector),
"state", typesel, (GDestroyNotify) g_free);
@@ -1379,7 +1352,9 @@ void
gog_guru_add_custom_widget (GtkWidget *guru, GtkWidget *custom)
{
GraphGuruState *state = g_object_get_data (G_OBJECT (guru), "state");
- GtkBox *box = GTK_BOX (gtk_widget_get_parent (gtk_widget_get_parent (state->type_selector->canvas)));
+ GtkBox *box = GTK_BOX (gtk_widget_get_parent (
+ gtk_widget_get_parent (
+ gtk_widget_get_parent (state->type_selector->canvas))));
if (custom) {
gtk_box_pack_start (GTK_BOX (box), custom, FALSE, TRUE, 0);
g_object_set_data (G_OBJECT (custom), "graph", state->graph);
diff --git a/plugins/plot_barcol/plot-types.xml.in b/plugins/plot_barcol/plot-types.xml.in
index 90616ea..95c235d 100644
--- a/plugins/plot_barcol/plot-types.xml.in
+++ b/plugins/plot_barcol/plot-types.xml.in
@@ -9,7 +9,7 @@
<Type _name="Unmarked Lines" row="1" col="1"
engine="GogLinePlot" family="Line"
- _description="Line plot."
+ _description="Unmarked line plot."
sample_image_file="chart_line_1_1.png">
<property name="type">normal</property>
<property name="default-style-has-markers">FALSE</property>
@@ -17,7 +17,7 @@
</Type>
<Type _name="Unmarked Stacked Lines" row="1" col="2"
engine="GogLinePlot" family="Line"
- _description="Stacked line plot."
+ _description="Unmarked stacked line plot."
sample_image_file="chart_line_1_2.png">
<property name="type">stacked</property>
<property name="default-style-has-markers">FALSE</property>
@@ -25,7 +25,7 @@
</Type>
<Type _name="Unmarked Percentage Lines" row="1" col="3"
engine="GogLinePlot" family="Line"
- _description="Percentage line plot."
+ _description="Unmarked percentage line plot."
sample_image_file="chart_line_1_3.png">
<property name="type">as_percentage</property>
<property name="default-style-has-markers">FALSE</property>
@@ -34,21 +34,21 @@
<Type _name="Lines" row="2" col="1"
engine="GogLinePlot" family="Line"
- _description="Line plot."
+ _description="Line plot with markers."
sample_image_file="chart_line_2_1.png">
<property name="type">normal</property>
<property name="guru-hints">backplane</property>
</Type>
<Type _name="Stacked Lines" row="2" col="2"
engine="GogLinePlot" family="Line"
- _description="Stacked line plot."
+ _description="Stacked line plot with markers."
sample_image_file="chart_line_2_2.png">
<property name="type">stacked</property>
<property name="guru-hints">backplane</property>
</Type>
<Type _name="Percentage Lines" row="2" col="3"
engine="GogLinePlot" family="Line"
- _description="Percentage line plot."
+ _description="Percentage line plot with markers."
sample_image_file="chart_line_2_3.png">
<property name="type">as_percentage</property>
<property name="guru-hints">backplane</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]