def _change_window_fix_cb(self, settings, key): hint = self.fixed_window_hint \ if settings.get_boolean(key) else Gdk.WindowTypeHint.NORMAL if hint == self.window.get_type_hint(): return self.window.hide() self.window.set_type_hint(hint) self.window.show() is_below = SETTINGS.get_boolean('window-fix') or \ SETTINGS.get_boolean('window-keep-below') self.window.set_keep_below(is_below) if hint == Gdk.WindowTypeHint.NORMAL: if self.window.get_gravity() == Gdk.Gravity.CENTER: border = self.photoimage.window_border x = SETTINGS_GEOMETRY.get_int('root-x') - self.photoimage.w / 2 y = SETTINGS_GEOMETRY.get_int('root-y') - self.photoimage.h / 2 self.window.move(int(x - border), int(y - border)) else: # a workaround for Xfwm bug (Issue #97) x = SETTINGS_GEOMETRY.get_int('root-x') y = SETTINGS_GEOMETRY.get_int('root-y') self.window.move(int(x), int(y))
def set_default_photo_source(): save = SaveListStore() if not save.has_save_file(): monitor_w, monitor_h = get_geometry_first_monitor() if monitor_w > 800 and monitor_h > 600: SETTINGS_GEOMETRY.set_int('root-x', monitor_w - 225) SETTINGS_GEOMETRY.set_int('root-y', 200) folder = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES) sources = {0: {'source': 'Flickr', 'target': _('Interestingness')}, 1: {'source': _('Folder'), 'target': folder}} save.save_to_json(sources)
def __init__(self, photolist): self.photolist = photolist self.fixed_window_hint = Gdk.WindowTypeHint.DOCK gui = Gtk.Builder() gui.add_objects_from_file(constants.UI_FILE, ["window"]) SETTINGS.connect("changed::fullscreen", self._change_fullscreen_cb) SETTINGS.connect("changed::window-sticky", self._change_sticky_cb) SETTINGS.connect("changed::window-fix", self._change_window_fix_cb) SETTINGS.connect("changed::border-color", self._set_border_color) # a workaround for Xfwm bug (Issue #97) gravity = Gdk.Gravity.NORTH_WEST \ if SETTINGS_GEOMETRY.get_string('gravity') == 'NORTH_WEST' \ else Gdk.Gravity.CENTER self.window = gui.get_object('window') self.window.set_gravity(gravity) if SETTINGS.get_boolean('window-sticky'): self.window.stick() self._set_window_state() self._set_window_position() self._set_photoimage() self._set_event_box() self._set_popupmenu(self.photolist, self) self._set_accelerator() # FIXME: Why "query-tooltip" is not enable? self.window.connect("query-tooltip", self.photoimage.tooltip.query_tooltip_cb) gui.connect_signals(self)
def on_window_leave_notify_event(self, widget, event): # if event.mode != 2: # return True self.photoimage.on_leave_cb(widget, event) # save geometry if not SETTINGS.get_boolean('window-fix'): x, y = widget.get_position() w, h = widget.get_size() if self.window.get_gravity() == Gdk.Gravity.CENTER: x += w / 2 y += h / 2 SETTINGS_GEOMETRY.set_int('root-x', x) SETTINGS_GEOMETRY.set_int('root-y', y) return False
def set_default_photo_source(): save = SaveListStore() if not save.has_save_file(): monitor_w, monitor_h = get_geometry_first_monitor() if monitor_w > 800 and monitor_h > 600: SETTINGS_GEOMETRY.set_int('root-x', monitor_w - 225) SETTINGS_GEOMETRY.set_int('root-y', 200) folder = GLib.get_user_special_dir( GLib.UserDirectory.DIRECTORY_PICTURES) sources = { 0: { 'source': 'Flickr', 'target': _('Interestingness') }, 1: { 'source': _('Folder'), 'target': folder } } save.save_to_json(sources)
def _set_window_position(self): self.window.move(SETTINGS_GEOMETRY.get_int('root-x'), SETTINGS_GEOMETRY.get_int('root-y')) self.window.resize(1, 1) self.window.show_all() self.window.get_position()