[goffice] Make editor page scrolling optional. [#696825]



commit a036d2928978784da6ec5f5a42c703f0fd7a1abf
Author: Jean Brefort <jean brefort normalesup org>
Date:   Fri Mar 29 12:37:13 2013 +0100

    Make editor page scrolling optional. [#696825]

 ChangeLog                                |    9 +++++++++
 NEWS                                     |    1 +
 docs/reference/goffice-0.10-sections.txt |    1 +
 goffice/graph/gog-object.c               |    1 +
 goffice/utils/go-editor.c                |   29 +++++++++++++++++++++++++----
 goffice/utils/go-editor.h                |    1 +
 6 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2e296c1..ef73f01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2013-03-29  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-object.c (gog_object_get_editor): force pages inside a
+       scrolled window.
+       * goffice/utils/go-editor.c (go_editor_add_page),
+       (go_editor_set_store_page), (go_editor_set_use_scrolled_window): make the
+       scrolled window optional. [#696825]
+       * goffice/utils/go-editor.h:
+
 2013-03-27  Morten Welinder  <terra gnome org>
 
        * goffice/canvas/goc-widget.c (goc_widget_connect_signals): Plug
diff --git a/NEWS b/NEWS
index d6ee48b..f36523e 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Jean:
        * Don't use uninitialized values in bar/column plots. [#696569]
        * Fix currency selector visibility. [#696647]
        * Fix mouse events for widgets inside a GtkContainer. [#696533]
+       * Make the GOEditor scrolled window optional. [696825]
 
 Morten:
        * Fix problems with cspline boxed type. [#695550]
diff --git a/docs/reference/goffice-0.10-sections.txt b/docs/reference/goffice-0.10-sections.txt
index 5f12a4f..16f333b 100644
--- a/docs/reference/goffice-0.10-sections.txt
+++ b/docs/reference/goffice-0.10-sections.txt
@@ -909,6 +909,7 @@ go_editor_get_page
 go_editor_get_registered_widget
 go_editor_new
 go_editor_register_widget
+go_editor_set_use_scrolled_window
 go_editor_set_store_page
 <SUBSECTION Standard>
 go_editor_get_type
diff --git a/goffice/graph/gog-object.c b/goffice/graph/gog-object.c
index 5c40892..5c4594b 100644
--- a/goffice/graph/gog-object.c
+++ b/goffice/graph/gog-object.c
@@ -1494,6 +1494,7 @@ gog_object_get_editor (GogObject *obj, GogDataAllocator *dalloc,
        g_return_val_if_fail (klass != NULL, NULL);
 
        editor = go_editor_new ();
+       go_editor_set_use_scrolled_window (editor, TRUE);
        if (klass->populate_editor) {
                /* If there are pending updates do them before creating the editor
                 * to avoid expensive widget changes later */
diff --git a/goffice/utils/go-editor.c b/goffice/utils/go-editor.c
index 307a7ee..423e6c6 100644
--- a/goffice/utils/go-editor.c
+++ b/goffice/utils/go-editor.c
@@ -37,6 +37,7 @@ struct _GOEditor {
        GSList          *pages;                 /* GOEditorPage */
        GData           *registered_widgets;
        unsigned     ref_count;
+       gboolean         use_scrolled;
 };
 
 /**
@@ -126,12 +127,15 @@ go_editor_add_page (GOEditor *editor, gpointer widget, char const *label)
        GOEditorPage *page;
 
        g_return_if_fail (editor != NULL);
-       page = g_new (GOEditorPage, 1);
+       page = g_new0 (GOEditorPage, 1);
 
        page->widget = widget;
-       page->scrolled = g_object_ref (gtk_scrolled_window_new (NULL, NULL));
-       gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (page->scrolled),
-                                              widget);
+       if (editor->use_scrolled) {
+               page->scrolled = g_object_ref (gtk_scrolled_window_new (NULL, NULL));
+               gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (page->scrolled),
+                                                          widget);
+       } else
+               page->scrolled = widget;
        page->label = label;
 
        editor->pages = g_slist_prepend (editor->pages, page);
@@ -153,6 +157,23 @@ go_editor_set_store_page (GOEditor *editor, unsigned *store_page)
        editor->store_page = store_page;
 }
 
+/**
+ * go_editor_set_use_scrolled_window:
+ * @editor: a #GOEditor
+ * @use_scrolled: boolean
+ *
+ * Sets whether each page of the editor should be displayed inside a scrolled
+ * window.
+ **/
+
+void
+go_editor_set_use_scrolled_window (GOEditor *editor, gboolean use_scrolled)
+{
+       g_return_if_fail (editor != NULL);
+
+       editor->use_scrolled = use_scrolled;
+}
+
 #ifdef GOFFICE_WITH_GTK
 
 /**
diff --git a/goffice/utils/go-editor.h b/goffice/utils/go-editor.h
index 68dd8f8..e51d5a9 100644
--- a/goffice/utils/go-editor.h
+++ b/goffice/utils/go-editor.h
@@ -32,6 +32,7 @@ GOEditor      *go_editor_new            (void);
 void            go_editor_free                   (GOEditor *editor);
 void            go_editor_add_page               (GOEditor *editor, gpointer widget, char const *label);
 void            go_editor_set_store_page         (GOEditor *editor, unsigned *store_page);
+void            go_editor_set_use_scrolled_window (GOEditor *editor, gboolean use_scrolled);
 #ifdef GOFFICE_WITH_GTK
 void            go_editor_register_widget        (GOEditor *editor, GtkWidget *widget);
 GtkWidget      *go_editor_get_registered_widget (GOEditor *editor, char const *name);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]