snap to grid feature



hi,

since yesterday evening i have the idea of doing some 'snap to grid'
feature so i can adjust the icons on my desktop. the first idea i had
was to do it in offline mode as many people are doing right now. that is
quitting gnome, grabbing the prefered editor and change the values in
the xml file to adjust the icons. then load up gnome again and the icons
are somehow nicelely grid'ed.

after keeping all this ideas in head i thought that it may be easier to
solve this stuff in the nautilus code itself. after investigating into
the nautilus code (which really beats me, since i never looked into
that) i finally found out about the 2 main files that seem to be
responsible for layouting stuff.

a) src/file-manager/fm-icon-view.c

which seems to call up the callback and some other stuff that i need to
figure out first.

b) nautilus/libnautilus-private/nautilus-iconcontainer.c

which has 90% of the code done that are imo needed to make a snap to
grid function. it has the x/y value of the icon, the dimension of the
whole desktop (container) etc. everything needed to do the grid
function. i have also figured out a simple algorithm howto sort the
icons on the desktop which globally looks like this:

- grab the 1st icon,
- look at the x/y position

- grab x position,
- start counting from 0/0 and add the pad value (which seems to be the
  default icon <-> icon pad and add it to that until you reach the
  leftmost (min value) of x, save that value same for the rightmost (max
  value). now calculate (x-min value) and (x-max value) now compare both
  results and which one is more little grid it to either min value or
  max value.

  example:

  pad    = 64
  icon x = 1112

  17 * 64 = 1088

  ---- icon is here between these 2 values

  18 * 64 = 1152

  1088 - 1112 = |24|
  1152 - 1112 = |40|

  so the first resulting value is more little than the second one so we
  grid this icon's x to 1088

- same we do with y

we also make sure that we don't bound the icon out of it's maximal
window border that is if the desktop x is 1152 maximal then we cant grid
the icon over that value.

the theoretics is quite easy if you don't count the scalable stuff into
this and go with the predefined padding values inside nautilus.

but the problem for me is, nautilus right now is a tad overhelming for
me and i need some advises howto go through this procedure. i would be
really happy and glad to see (anyhow) nautilus supporting snap to grid
one day.

help, comments, advice all welcome.....

-- 
Name....: Ali Akcaagac
Status..: Student Of Computer & Economic Science
E-Mail..: mailto:ali akcaagac stud fh-wilhelmshaven de
WWW.....: http://www.fh-wilhelmshaven.de/~akcaagaa




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