Skip to content

Add start position option. #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified usr/bin/sticky
100644 → 100755
Empty file.
57 changes: 48 additions & 9 deletions usr/lib/sticky/sticky.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@
]
}

START_POSITIONS = {
'left-top': _("Top Left"),
'center-top': _("Top Center"),
'right-top': _("Top Right"),
'left-center': _("Center Left"),
'center-center': _("Center"),
'right-center': _("Center Right"),
'left-bottom': _("Bottom Left"),
'center-bottom': _("Bottom Center"),
'right-bottom': _("Bottom Right"),
}

class Note(Gtk.Window):
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, return_type=bool,
accumulator=GObject.signal_accumulator_true_handled)
Expand Down Expand Up @@ -602,6 +614,8 @@ def __init__(self, app):
page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
page.pack_start(GSettingsSpinButton(_("Default height"), SCHEMA, 'default-height', mini=50, maxi=2000, step=10), False, False, 0)
page.pack_start(GSettingsSpinButton(_("Default width"), SCHEMA, 'default-width', mini=50, maxi=2000, step=10), False, False, 0)
start_posititions = [(x, y) for x, y in START_POSITIONS.items()]
page.pack_start(GSettingsComboBox(_("Default start position"), SCHEMA, 'default-start-position', options=start_posititions, valtype=str), False, False, 0)
try:
colors = [(x, y) for x, y in COLORS.items()]
colors.append(('sep', ''))
Expand Down Expand Up @@ -920,7 +934,7 @@ def hide_notes(self):
self.notes_hidden = True
self.update_dummy_window()

def find_note_location(self, x, y):
def find_note_location(self, x, y, direction):
while True:
found = False
for note_info in self.file_handler.get_note_list(self.note_group):
Expand All @@ -931,20 +945,45 @@ def find_note_location(self, x, y):
if not found:
break

x += 20
y += 20
x += 20 * direction[0]
y += 60 * direction[1]

return x, y

def new_note(self, button=None, parent=None):
if parent is None:
x = 40
y = 40
workarea_rect = Gdk.Monitor.get_workarea(
Gdk.Display.get_primary_monitor(Gdk.Display.get_default())
)
direction = [1, 1]
if parent:
if parent.x > (workarea_rect.width / 2):
x = parent.x - 20
direction[0] = -1
else:
x = parent.x + 20
if parent.y > (workarea_rect.height / 2):
y = parent.y - 60
direction[1] = -1
else:
y = parent.y + 60
else:
x = parent.x + 20
y = parent.y + 20
start_pos = self.settings.get_string('default-start-position').split('-')
if start_pos[0] == 'right':
x = workarea_rect.width - self.settings.get_uint('default-width') - 20
direction[0] = -1
elif start_pos[0] == 'center':
x = workarea_rect.width / 2 - self.settings.get_uint('default-width') / 2
else:
x = 20
if start_pos[1] == 'bottom':
y = workarea_rect.height - self.settings.get_uint('default-height') - 60
direction[1] = -1
elif start_pos[1] == 'center':
y = workarea_rect.height / 2 - self.settings.get_uint('default-height') / 2
else:
y = 20

x, y = self.find_note_location(x, y)
x, y = self.find_note_location(x, y, direction)

info = {'x': x, 'y': y}

Expand Down
30 changes: 30 additions & 0 deletions usr/share/glib-2.0/schemas/org.x.sticky.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,36 @@
</description>
</key>

<key name='default-start-position' type='s'>
<default>"left-top"</default>
<summary>Default Start Position</summary>
<choices>
<choice value='left-top'/>
<choice value='center-top'/>
<choice value='right-top'/>
<choice value='left-center'/>
<choice value='center-center'/>
<choice value='right-center'/>
<choice value='left-bottom'/>
<choice value='center-bottom'/>
<choice value='right-bottom'/>
</choices>
<aliases>
<alias value='Top Left' target='left-top'/>
<alias value='Top Center' target='center-top'/>
<alias value='Top Right' target='right-top'/>
<alias value='Center Left' target='left-center'/>
<alias value='Center' target='center-center'/>
<alias value='Center Right' target='right-center'/>
<alias value='Bottom Left' target='left-bottom'/>
<alias value='Bottom Center' target='center-bottom'/>
<alias value='Bottom Right' target='right-bottom'/>
</aliases>
<description>
The position that new notes will start at on the screen.
</description>
</key>

<key name='default-color' type='s'>
<default>"yellow"</default>
<summary>Default Color</summary>
Expand Down
Loading