Code

Improve layout of grid document properties
authorjohanengelen <johanengelen@users.sourceforge.net>
Sat, 1 Dec 2007 16:43:21 +0000 (16:43 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Sat, 1 Dec 2007 16:43:21 +0000 (16:43 +0000)
src/display/canvas-grid.cpp
src/ui/dialog/document-properties.cpp
src/ui/dialog/document-properties.h

index de9afbfc1d89a01cc5e166c7c8ec0b12644cbfa1..3d291f42a014ec420781abfb27a13e3e0fd9a475 100644 (file)
@@ -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;
index 7528b463f7010e66ef94c70ed9f691a8dd7ef054..a3e9d6eea745542ae1bf1a309c04633eda23ce8a 100644 (file)
@@ -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 (_("<b>Creation</b>"));
-    Gtk::Label* label_crea_type = manage (new Gtk::Label);
-    label_crea_type->set_markup (_("Gridtype"));
+    _grids_label_crea.set_markup(_("<b>Creation</b>"));
+    _grids_label_def.set_markup(_("<b>Defined grids</b>"));
+    _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 (_("<b>Defined grids</b>"));
-
     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();
 }
 
 
index b4e303325828bf3567d11d52f896a2a8be89ed01..3b7e4bb070f2b49b30352c68a09c6afa359d2ed4 100644 (file)
@@ -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;