Skip to content
Open
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
11 changes: 10 additions & 1 deletion emote/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,21 @@ def grouper(iterable, n, fillvalue=None):
return zip_longest(*args, fillvalue=fillvalue)


WINDOW_POSITION_MAP = {
"Center": Gtk.WindowPosition.CENTER,
"Mouse Cursor": Gtk.WindowPosition.MOUSE,
}


class EmojiPicker(Gtk.Window):
def __init__(self, open_time, update_accelerator, update_theme, show_welcome):
window_position = WINDOW_POSITION_MAP.get(
user_data.load_window_position(), Gtk.WindowPosition.CENTER
)
Gtk.Window.__init__(
self,
title="Emote",
window_position=Gtk.WindowPosition.CENTER,
window_position=window_position,
resizable=False,
deletable=False,
name="emote_window",
Expand Down
21 changes: 21 additions & 0 deletions emote/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ def __init__(self, update_theme):
settings_grid.attach(theme_combo, 2, row, 1, 1)
row += 1

window_position_label = Gtk.Label("Window Position")
window_position_label.set_alignment(0, 0.5)
settings_grid.attach(window_position_label, 1, row, 1, 1)

window_position_combo = Gtk.ComboBoxText()
window_position_combo.set_entry_text_column(0)
window_position_combo.connect("changed", self.on_window_position_combo_changed)
for position in user_data.WINDOW_POSITIONS:
window_position_combo.append_text(position)
window_position_combo.set_active(
user_data.WINDOW_POSITIONS.index(user_data.load_window_position())
)
settings_grid.attach(window_position_combo, 2, row, 1, 1)
row += 1

box.pack_start(settings_grid, True, True, GRID_SIZE)

self.show_all()
Expand All @@ -57,3 +72,9 @@ def on_theme_combo_changed(self, combo):

if theme is not None:
self.update_theme(theme)

def on_window_position_combo_changed(self, combo):
window_position = combo.get_active_text()

if window_position is not None:
user_data.update_window_position(window_position)
14 changes: 14 additions & 0 deletions emote/user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
DEFAULT_SKINTONE_INDEX = 0
SKINTONES = ["✋", "✋🏻", "✋🏼", "✋🏽", "✋🏾", "✋🏿"]

WINDOW_POSITION = "window_position"
DEFAULT_WINDOW_POSITION = "Center"
WINDOW_POSITIONS = ["Center", "Mouse Cursor"]


# Ensure the data dir exists
os.makedirs(DATA_DIR, exist_ok=True)
Expand Down Expand Up @@ -134,3 +138,13 @@ def load_skintone_index():
def update_skintone_index(skintone):
with shelve.open(SHELVE_PATH) as db:
db[SKINTONE_INDEX] = skintone


def load_window_position():
with shelve.open(SHELVE_PATH) as db:
return db.get(WINDOW_POSITION, DEFAULT_WINDOW_POSITION)


def update_window_position(window_position):
with shelve.open(SHELVE_PATH) as db:
db[WINDOW_POSITION] = window_position