Moving the anchor of a desklet

Contribute code & patches
Forum rules
No support questions here please

Moving the anchor of a desklet

Postby tipichris on Thu Mar 27, 2014 6:19 am

Apologies if this is the wrong forum for this question - there doesn't seem to be one obviously geared to desklet development.

I've written a desklet (http://cinnamon-spices.linuxmint.com/desklets/view/20) which displays data taken from a remote source. The length of one string in particular can vary and the desklet grows or shrinks to contain it. By default desklets are anchored to the top left corner, so they grow to the right and down. This is a pain if you want to place the desklet in bottom right of the screen.

Switching the anchor is straightforward

Code: Select all
this.actor.move_anchor_point_from_gravity(4);


But this makes a mess of drag and drop. It seems part of the DND code assumes a top left anchor. The only way I can see to get around this is to give DND what it wants by overriding Desklet._onDragBegin() and Desklet._onDragEnd() to move the anchor back to top left before a drag, and to bottom left after:

Code: Select all
 
  _onDragBegin: function() {
      global.set_stage_input_mode(Cinnamon.StageInputMode.FULLSCREEN);
      this.actor.move_anchor_point_from_gravity(8);
  },
 
  _onDragEnd: function() {
      global.set_stage_input_mode(Cinnamon.StageInputMode.NORMAL);
      this._trackMouse();
      this.actor.move_anchor_point_from_gravity(4);
  },


But I guess from the underscore that these are intended to be private functions that I shouldn't be messing with. Can anyone suggest a way to achieve what I'm after? Also, if overriding these is the only way, is there a way in which I can call the original, rather than having to reproduce all its code. Something like php's parent

Thanks
tipichris
Level 1
Level 1
 
Posts: 3
Joined: Mon Feb 03, 2014 6:31 am

Linux Mint is funded by ads and donations.
 

Return to Code & Patches

Who is online

Users browsing this forum: No registered users and 0 guests