Code

Store the maximized state in the document (closes bug #168422)
authordvlierop2 <dvlierop2@users.sourceforge.net>
Sun, 31 May 2009 12:51:33 +0000 (12:51 +0000)
committerdvlierop2 <dvlierop2@users.sourceforge.net>
Sun, 31 May 2009 12:51:33 +0000 (12:51 +0000)
src/attributes-test.h
src/attributes.cpp
src/attributes.h
src/sp-namedview.cpp
src/sp-namedview.h

index 5593deeba6464a0ef480435f8e4b6a401d989217..d6851a42b4a77147dd5a19180f15e20838b7eecf 100644 (file)
@@ -372,6 +372,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
     {"inkscape:window-height", true},
     {"inkscape:window-x", true},
     {"inkscape:window-y", true},
+    {"inkscape:window-maximized", true},
     {"inkscape:current-layer", true},
     {"inkscape:connector-type", true},
     {"inkscape:connection-start", true},
index f2fb62a1cb09215050d505fe27f23fb66a63f260..a0801920ebfbe4e32ebb2d360322a6d04190a19b 100644 (file)
@@ -86,6 +86,7 @@ static SPStyleProp const props[] = {
     {SP_ATTR_INKSCAPE_WINDOW_HEIGHT, "inkscape:window-height"},
     {SP_ATTR_INKSCAPE_WINDOW_X, "inkscape:window-x"},
     {SP_ATTR_INKSCAPE_WINDOW_Y, "inkscape:window-y"},
+    {SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED, "inkscape:window-maximized"},
     {SP_ATTR_INKSCAPE_SNAP_GLOBAL, "inkscape:snap-global"},
     {SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"},
     {SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"},
@@ -98,8 +99,7 @@ static SPStyleProp const props[] = {
     {SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINTS, "inkscape:snap-object-midpoints"},
     {SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINTS, "inkscape:snap-bbox-edge-midpoints"},
        {SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINTS, "inkscape:snap-bbox-midpoints"},
-       //{SP_ATTR_INKSCAPE_SNAP_INTERS_GRIDGUIDE, "inkscape:snap-intersection-grid-guide"},
-    {SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, "inkscape:snap-intersection-paths"},
+       {SP_ATTR_INKSCAPE_SNAP_INTERS_PATHS, "inkscape:snap-intersection-paths"},
     {SP_ATTR_INKSCAPE_OBJECT_PATHS, "inkscape:object-paths"},
     {SP_ATTR_INKSCAPE_OBJECT_NODES, "inkscape:object-nodes"},
     {SP_ATTR_INKSCAPE_BBOX_PATHS, "inkscape:bbox-paths"},
index fc9e49f2b36b15796fffe763a6fe5959a4fce983..08ece3483efa2c2beb1048abc162789e772a96a3 100644 (file)
@@ -86,6 +86,7 @@ enum SPAttributeEnum {
     SP_ATTR_INKSCAPE_WINDOW_HEIGHT,
     SP_ATTR_INKSCAPE_WINDOW_X,
     SP_ATTR_INKSCAPE_WINDOW_Y,
+    SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED,
     SP_ATTR_INKSCAPE_SNAP_GLOBAL,
     SP_ATTR_INKSCAPE_SNAP_BBOX,
     SP_ATTR_INKSCAPE_SNAP_NODES,
index c9732eece6e0596a4b6460b6ae487dee0cc27d97..9b4b7b3e754c1a58221a60766b28f1c3d1edef9a 100644 (file)
@@ -241,6 +241,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
     sp_object_read_attr(object, "inkscape:window-height");
     sp_object_read_attr(object, "inkscape:window-x");
     sp_object_read_attr(object, "inkscape:window-y");
+    sp_object_read_attr(object, "inkscape:window-maximized");
     sp_object_read_attr(object, "inkscape:snap-global");
     sp_object_read_attr(object, "inkscape:snap-bbox");
     sp_object_read_attr(object, "inkscape:snap-nodes");
@@ -442,7 +443,11 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
             nv->window_y = value ? atoi(value) : 0;
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_INKSCAPE_SNAP_GLOBAL:
+    case SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED:
+                       nv->window_maximized = value ? atoi(value) : 0;
+                       object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+                       break;
+       case SP_ATTR_INKSCAPE_SNAP_GLOBAL:
             nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE);
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
@@ -746,16 +751,23 @@ void sp_namedview_window_from_document(SPDesktop *desktop)
 
     // restore window size and position stored with the document
     if (geometry_from_file) {
-        gint w = MIN(gdk_screen_width(), nv->window_width);
-        gint h = MIN(gdk_screen_height(), nv->window_height);
-        gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
-        gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
-        if (w>0 && h>0) {
-            desktop->setWindowSize(w, h);
-            x = MIN(gdk_screen_width() - w, x);
-            y = MIN(gdk_screen_height() - h, y);
-            desktop->setWindowPosition(Geom::Point(x, y));
-        }
+       if (nv->window_maximized) {
+               Gtk::Window *win = desktop->getToplevel();
+               if (win){
+                       win->maximize();
+               }
+       } else {
+               gint w = MIN(gdk_screen_width(), nv->window_width);
+                       gint h = MIN(gdk_screen_height(), nv->window_height);
+                       gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x);
+                       gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y);
+                       if (w>0 && h>0) {
+                               desktop->setWindowSize(w, h);
+                               x = MIN(gdk_screen_width() - w, x);
+                               y = MIN(gdk_screen_height() - h, y);
+                               desktop->setWindowPosition(Geom::Point(x, y));
+                       }
+       }
     }
 
     // restore zoom and view
@@ -819,12 +831,13 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
     sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[Geom::Y]);
 
     if (save_geometry_in_file) {
-        gint w, h, x, y;
+       gint w, h, x, y;
         desktop->getWindowGeometry(x, y, w, h);
         sp_repr_set_int(view, "inkscape:window-width", w);
         sp_repr_set_int(view, "inkscape:window-height", h);
         sp_repr_set_int(view, "inkscape:window-x", x);
         sp_repr_set_int(view, "inkscape:window-y", y);
+        sp_repr_set_int(view, "inkscape:window-maximized", desktop->is_maximized());
     }
 
     view->setAttribute("inkscape:current-layer", SP_OBJECT_ID(desktop->currentLayer()));
index 7eafd124934c5a8113a4e498745fc01deba62951..048096d8c0096e569761f332afb9f0d51be03425 100644 (file)
@@ -47,6 +47,7 @@ struct SPNamedView : public SPObjectGroup {
     gint window_height;
     gint window_x;
     gint window_y;
+    gint window_maximized;
 
     SnapManager snap_manager;
     GSList * grids;