From c026f3fa6df4c655f56c0aa5d2fc30bed8758004 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sat, 1 Dec 2007 16:43:21 +0000 Subject: [PATCH] Improve layout of grid document properties --- src/display/canvas-grid.cpp | 2 +- src/ui/dialog/document-properties.cpp | 47 ++++++++++++++------------- src/ui/dialog/document-properties.h | 8 +++-- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index de9afbfc1..3d291f42a 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -158,7 +158,7 @@ grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i }; CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type) - : namelabel("", Gtk::ALIGN_LEFT), gridtype(type), visible(true), snap_enabled(true) + : namelabel("", Gtk::ALIGN_CENTER), gridtype(type), visible(true), snap_enabled(true) { repr = in_repr; doc = in_doc; diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 7528b463f..a3e9d6eea 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -93,9 +93,11 @@ DocumentProperties::destroy() DocumentProperties::DocumentProperties() : UI::Widget::Panel ("", "dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW), _page_page(1, 1), _page_guides(1, 1), - _page_snap(1, 1), _page_snap_dtls(1, 1), _page_grids(1, 1), + _page_snap(1, 1), _page_snap_dtls(1, 1), + _grids_label_crea("", Gtk::ALIGN_LEFT), _grids_button_new(_("_New"), _("Create new grid.")), _grids_button_remove(_("_Remove"), _("Remove selected grid.")), + _grids_label_def("", Gtk::ALIGN_LEFT), _prefs_path("dialogs.documentoptions") { _tt.enable(); @@ -104,7 +106,7 @@ DocumentProperties::DocumentProperties() _notebook.append_page(_page_page, _("Page")); _notebook.append_page(_page_guides, _("Guides")); - _notebook.append_page(_page_grids, _("Grids")); + _notebook.append_page(_grids_vbox, _("Grids")); _notebook.append_page(_page_snap, _("Snap")); _notebook.append_page(_page_snap_dtls, _("Snap details")); @@ -137,6 +139,7 @@ DocumentProperties::init() G_CALLBACK(on_deactivate_desktop), 0); show_all_children(); + _grids_button_remove.hide(); } DocumentProperties::~DocumentProperties() @@ -410,14 +413,18 @@ DocumentProperties::update_gridspage() } //add tabs + bool grids_present = false; for (GSList const * l = nv->grids; l != NULL; l = l->next) { Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; _grids_notebook.append_page(grid->getWidget(), grid->repr->attribute("id")); - + grids_present = true; } _grids_notebook.show_all(); - _page_grids.table().resize_children(); + if (grids_present) + _grids_button_remove.show(); + else + _grids_button_remove.hide(); } /** @@ -426,41 +433,37 @@ DocumentProperties::update_gridspage() void DocumentProperties::build_gridspage() { - _page_grids.show(); - /// \todo FIXME: gray out snapping when grid is off. /// Dissenting view: you want snapping without grid. SPDesktop *dt = SP_ACTIVE_DESKTOP; SPNamedView *nv = sp_desktop_namedview(dt); - Gtk::Label* label_crea = manage (new Gtk::Label); - label_crea->set_markup (_("Creation")); - Gtk::Label* label_crea_type = manage (new Gtk::Label); - label_crea_type->set_markup (_("Gridtype")); + _grids_label_crea.set_markup(_("Creation")); + _grids_label_def.set_markup(_("Defined grids")); + _grids_hbox_crea.pack_start(_grids_combo_gridtype, true, true); + _grids_hbox_crea.pack_start(_grids_button_new, true, true); for (gint t = 0; t <= GRID_MAXTYPENR; t++) { _grids_combo_gridtype.append_text( CanvasGrid::getName( (GridType) t ) ); } _grids_combo_gridtype.set_active_text( CanvasGrid::getName(GRID_RECTANGULAR) ); - Gtk::Label* label_def = manage (new Gtk::Label); - label_def->set_markup (_("Defined grids")); - for (GSList const * l = nv->grids; l != NULL; l = l->next) { Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; _grids_notebook.append_page(grid->getWidget(), grid->repr->attribute("id")); } - Gtk::Widget *const widget_array[] = - { - label_crea, 0, - label_crea_type, (Gtk::Widget*) &_grids_combo_gridtype, - (Gtk::Widget*) &_grids_button_new, (Gtk::Widget*) &_grids_button_remove, - label_def, 0 - }; - attach_all(_page_grids.table(), widget_array, G_N_ELEMENTS(widget_array)); - _page_grids.table().attach(_grids_notebook, 0, 3, 4, 5, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); + _grids_space.set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); + + _grids_vbox.set_spacing(4); + _grids_vbox.pack_start(_grids_label_crea, false, false); + _grids_vbox.pack_start(_grids_hbox_crea, false, false); + _grids_vbox.pack_start(_grids_space, false, false); + _grids_vbox.pack_start(_grids_label_def, false, false); + _grids_vbox.pack_start(_grids_notebook, false, false); + _grids_vbox.pack_start(_grids_button_remove, false, false); + _grids_button_remove.hide(); } diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index b4e303325..3b7e4bb07 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -59,7 +59,7 @@ protected: NotebookPage _page_page, _page_guides; NotebookPage _page_snap, _page_snap_dtls; - NotebookPage _page_grids; + Gtk::VBox _grids_vbox; //--------------------------------------------------------------- RegisteredCheckButton _rcb_canb, _rcb_bord, _rcb_shad; @@ -82,11 +82,15 @@ protected: //--------------------------------------------------------------- RegisteredCheckButton _rcbic, _rcbsng; RegisteredCheckButton _rcbsigg, _rcbsils; - //--------------------------------------------------------------- + //--------------------------------------------------------------- Gtk::Notebook _grids_notebook; + Gtk::HBox _grids_hbox_crea; + Gtk::Label _grids_label_crea; Gtk::Button _grids_button_new; Gtk::Button _grids_button_remove; Gtk::ComboBoxText _grids_combo_gridtype; + Gtk::Label _grids_label_def; + Gtk::HBox _grids_space; //--------------------------------------------------------------- gchar const *_prefs_path; -- 2.30.2