Codebase list sugar-read-activity / 47ae870
Port from GObject to GLib James Cameron authored 5 years ago Rahul Bothra committed 5 years ago
3 changed file(s) with 23 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
1919 import cairo
2020 import math
2121
22 from gi.repository import GLib
2223 from gi.repository import Gtk
2324 from gi.repository import Gdk
2425 from gi.repository import GdkPixbuf
9192 __gproperties__ = {
9293 "hscroll-policy": (Gtk.ScrollablePolicy, "hscroll-policy",
9394 "hscroll-policy", Gtk.ScrollablePolicy.MINIMUM,
94 GObject.PARAM_READWRITE),
95 GObject.ParamFlags.READWRITE),
9596 "hadjustment": (Gtk.Adjustment, "hadjustment", "hadjustment",
96 GObject.PARAM_READWRITE),
97 GObject.ParamFlags.READWRITE),
9798 "vscroll-policy": (Gtk.ScrollablePolicy, "hscroll-policy",
9899 "hscroll-policy", Gtk.ScrollablePolicy.MINIMUM,
99 GObject.PARAM_READWRITE),
100 GObject.ParamFlags.READWRITE),
100101 "vadjustment": (Gtk.Adjustment, "hadjustment", "hadjustment",
101 GObject.PARAM_READWRITE),
102 GObject.ParamFlags.READWRITE),
102103 }
103104
104105 __gsignals__ = {
221222 # be set to False. This is to perform a faster drawing while
222223 # scrolling.
223224 if self._scrolling_hid is not None:
224 GObject.source_remove(self._scrolling_hid)
225 self._scrolling_hid = GObject.timeout_add(200,
226 self._stop_scrolling)
225 GLib.source_remove(self._scrolling_hid)
226 self._scrolling_hid = GLib.timeout_add(200,
227 self._stop_scrolling)
227228
228229 def __hadj_value_changed_cb(self, adj):
229230 alloc = self.get_allocation()
2929 import emptypanel
3030
3131 import dbus
32 from gi.repository import GLib
3233 from gi.repository import GObject
3334 from gi.repository import Gtk
3435 from gi.repository import Gdk
684685 if self.props.active:
685686 # Now active, start initial suspend timeout
686687 if self._idle_timer > 0:
687 GObject.source_remove(self._idle_timer)
688 self._idle_timer = GObject.timeout_add_seconds(15,
689 self._suspend_cb)
688 GLib.source_remove(self._idle_timer)
689 self._idle_timer = GLib.timeout_add_seconds(15,
690 self._suspend_cb)
690691 self._sleep_inhibit = False
691692 else:
692693 # Now inactive
704705 def _user_action_cb(self, widget):
705706 """Set a timer for going back to ebook mode idle sleep."""
706707 if self._idle_timer > 0:
707 GObject.source_remove(self._idle_timer)
708 self._idle_timer = GObject.timeout_add_seconds(5, self._suspend_cb)
708 GLib.source_remove(self._idle_timer)
709 self._idle_timer = GLib.timeout_add_seconds(5, self._suspend_cb)
709710
710711 def _suspend_cb(self):
711712 """Go into ebook mode idle sleep."""
730731 self._load_document('file://' + tempfile)
731732
732733 # FIXME: This should obviously be fixed properly
733 GObject.timeout_add_seconds(
734 GLib.timeout_add_seconds(
734735 1, self.__view_toolbar_needs_update_size_cb, None)
735736
736737 def write_file(self, file_path):
840841 self._progress_alert = None
841842
842843 # download the metadata
843 GObject.idle_add(self._download_metadata, tube_id, tube_ip, tube_port)
844 GLib.idle_add(self._download_metadata, tube_id, tube_ip, tube_port)
844845
845846 def _download_metadata_result_cb(self, getter, tempfile, suggested_name,
846847 tube_id):
850851 os.remove(tempfile)
851852
852853 # load the object from the datastore to update the file path
853 GObject.idle_add(self._open_downloaded_file, shared_metadata)
854 GLib.idle_add(self._open_downloaded_file, shared_metadata)
854855
855856 def _open_downloaded_file(self, shared_metadata):
856857 self._jobject = datastore.get(self._jobject.object_id)
881882 if self._progress_alert is not None:
882883 self.remove_alert(self._progress_alert)
883884 self._progress_alert = None
884 GObject.idle_add(self._get_document)
885 GLib.idle_add(self._get_document)
885886
886887 def _get_connection_params(self, tube_id):
887888 # return ip and port to download a file
939940
940941 # Avoid trying to download the document multiple times at once
941942 self._want_document = False
942 GObject.idle_add(self._download_document, tube_id)
943 GLib.idle_add(self._download_document, tube_id)
943944 return False
944945
945946 def _joined_cb(self, also_self):
951952 if self._progress_alert is not None:
952953 self._progress_alert.props.msg = _('Receiving book...')
953954
954 GObject.idle_add(self._get_document)
955 GLib.idle_add(self._get_document)
955956
956957 def _load_document(self, filepath):
957958 """Load the specified document and set up the UI.
11231124 self.unused_download_tubes.add(tube_id)
11241125 # if no download is in progress, let's fetch the document
11251126 if self._want_document:
1126 GObject.idle_add(self._get_document)
1127 GLib.idle_add(self._get_document)
11271128
11281129 def _list_tubes_reply_cb(self, tubes):
11291130 """Callback when new tubes are available."""
12541255 # but we don't have a event yet, Evince model have a event
12551256 # we need check the differnt backends and implement
12561257 # in all the backends.
1257 GObject.timeout_add_seconds(2, self._update_preview, button, page)
1258 GLib.timeout_add_seconds(2, self._update_preview, button, page)
12581259
12591260 def _update_preview(self, button, page):
12601261 thumb = self._get_screenshot()
125125 self._search_entry_changed = True
126126 self._update_find_buttons()
127127
128 # GObject.timeout_add(500, self._search_entry_timeout_cb)
128 # GLib.timeout_add(500, self._search_entry_timeout_cb)
129129 #
130130 # def _search_entry_timeout_cb(self):
131131 # self._clear_find_job()