def _show_game(self, pixbuf=None, reshuffle=True): if not self.game.get_parent(): self.game_box.pop() while Gtk.events_pending(): Gtk.main_iteration() self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) if not self.game.prepare_image(pixbuf, reshuffle): self._shuffling = False return self._shuffling = False self.get_window().set_cursor(None)
def __init__(self, front, callb, toolt=""): GObject.GObject.__init__(self) self.label = Gtk.Label.new(front) self.curve = Gdk.Cursor(Gdk.CursorType.CROSSHAIR) self.arrow = Gdk.Cursor(Gdk.CursorType.ARROW) #gdk_window = self.get_root_window() #self.arrow = gdk_window.get_cursor() if toolt: self.label.set_tooltip_text(toolt) self.label.set_single_line_mode(True) self.add(self.label) if callb: self.connect_after("button-press-event", callb, front) self.set_above_child(True) #self.label.connect("motion-notify-event", self.area_motion) self.connect("motion-notify-event", self.area_motion)
def __on_realize(self, widget): """ Change cursor over eventbox @param widget as Gtk.Widget """ try: window = widget.get_window() if window is not None: window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2)) except: Logger.warning(_("You are using a broken cursor theme!"))
def on_repos_treeview_selection_changed(widget): global current_filter while Gtk.events_pending(): Gtk.main_iteration() liste, line = repos_selection.get_selected() if line: ManagerWindow.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) while Gtk.events_pending(): Gtk.main_iteration() current_filter = (get_repo_list, repos_list[line][0]) refresh_packages_list(get_repo_list(repos_list[line][0]))
def on_realize(widget): """ Set cursor on widget @param widget as Gtk.Widget """ try: window = widget.get_window() if window is not None: window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2)) except: Logger.warning(_("You are using a broken cursor theme!"))
def add_pixel(self, location): x, y, width, height, color = location # create pixbuf pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, False, 8, 10, 10) pixel = convert.rgb2pixel(color) pixbuf.fill(pixel) # append to treeview self.tree_view.append_row([pixbuf, x, y, width, height, str(color)]) self.select_pixel_button.set_sensitive(True) self.parent.set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW))
def __on_eventbox_realize(self, eventbox): """ Change cursor over eventbox @param eventbox as Gdk.Eventbox """ try: window = eventbox.get_window() if window is not None: window.set_cursor(Gdk.Cursor(Gdk.CursorType.HAND2)) except: Logger.warning(_("You are using a broken cursor theme!"))
def _on_label_realize(self, eventbox): """ Change cursor on label @param eventbox as Gtk.EventBox """ try: if len(self._artist_ids) == 1: eventbox.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.HAND2)) except: Logger.warning(_("You are using a broken cursor theme!"))
def setDriftPoint(self, *args): if (self.clickedDriftP1 or self.clickedDriftP2): if (self.clickedDriftP1): g.driftP1 = self.mousePosition elif (self.clickedDriftP2): g.driftP2 = self.mousePosition self.clickedDriftP1 = False self.clickedDriftP2 = False self.window.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.LEFT_PTR)) self.overlay.queue_draw()
def _uninstall_cb(self, event): confirmation = KanoDialog( title_text=_("Removing {}").format(self._app["title"]), description_text=_("This application will be uninstalled and " "removed from apps. Do you wish to proceed?"), button_dict={ _("YES"): { "return_value": 0 }, _("NO"): { "return_value": -1, "color": "red" } }, parent_window=self._window) confirmation.title.description.set_max_width_chars(40) rv = confirmation.run() del confirmation if rv < 0: return prompt = _("Uninstalling {}").format(self._app["title"]) pw = get_sudo_password(prompt, self._window) if pw is None: return self._window.blur() self._window.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) while Gtk.events_pending(): Gtk.main_iteration() success = uninstall_packages(self._app, pw) if success: remove_from_desktop(self._app) uninstall_link_and_icon(self._app["slug"], pw) self._apps.remove_app(self._app) self._window.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW)) self._window.unblur()
def on_add_feed_done(result, error): if result is not None: thumbnail = os.path.join(comun.THUMBNAILS_DIR, 'feed_{0}.png'.format(result['id'])) pixbuf = get_pixbuf_from_base64string(result['image']) pixbuf.savev(thumbnail, 'png', [], []) self.storefeeds.append([ result['id'], result['url'], result['title'], result['image'], result['norder'], pixbuf ]) self.get_root_window().set_cursor( Gdk.Cursor(Gdk.CursorType.TOP_LEFT_ARROW))
def on_area_button_press(self, area, event): if self.last_b == None: self.last_b = event.button self.last_mx = event.x_root self.last_my = event.y_root if self.last_b == 2: # set vertical line if self.zoom_ratio != 0 and self.xscale != 0: self.line_x = (event.x / self.zoom_ratio - draw.off_x) / self.xscale else: self.line_x = -1 self.queue_draw() if self.last_b == 3: area.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.SB_H_DOUBLE_ARROW)) else: area.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.FLEUR)) self.grab_focus() # select the component on a mouse button press self.queue_draw() return False
def _launch_disconnect_thread(self, widget=None): watch_cursor = Gdk.Cursor(Gdk.CursorType.WATCH) self._win.get_window().set_cursor(watch_cursor) self._connect_btn.start_spinner() self._connect_btn.set_sensitive(False) # Force the spinner to show on the window. while Gtk.events_pending(): Gtk.main_iteration() t = threading.Thread(target=self._threaded_disconnect) t.start()
def __crashed_cb(self, browser): self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.LEFT_PTR)) uri = browser.cached_uri logging.error('WebKit2 WebView at uri %r has crashed', uri) self.close_tab(browser.get_parent()) alert = Alert(title=_('This tab has crashed Browse: %s') % uri, msg=_('If you reopen the tab, it may just crash again')) alert.add_button(Gtk.ResponseType.OK, _('Reopen')) alert.add_button(Gtk.ResponseType.CANCEL, _('Disregard')) alert.connect('response', self.__crashed_alert_cb, uri) self._activity.add_alert(alert)
def on_textview2_motion_notify_event(self, widget, event): logger.info("Mouse moving in text view") """ used to change cursors pointer when mouse over a link. Changed from http://download.gna.org/nfoview/doc/api/nfoview.view_source.html as returns False now so we can still select content """ window = Gtk.TextWindowType.WIDGET x, y = widget.window_to_buffer_coords(window, int(event.x), int(event.y)) logger.debug("cordinates: " + str(x) + " " + str(y)) window = widget.get_window(Gtk.TextWindowType.TEXT) for tag in widget.get_iter_at_location(x, y).get_tags(): logger.debug(" in loop tag = " + tag.url) #print event.get_state() if hasattr(tag, "url") and event.get_state( ) == Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD2_MASK: logger.debug(" Cordinates have tag url") window.set_cursor(Gdk.Cursor(cursor_type=Gdk.CursorType.HAND2)) return False # to not call the default handler. window.set_cursor(Gdk.Cursor(cursor_type=Gdk.CursorType.XTERM)) return False
def on_add_feed_clicked(self, widget): if self.object is None: afd = AddFeedDialog(self) if afd.run() == Gtk.ResponseType.ACCEPT: url = afd.get_url() if not url.startswith('http://') and\ not url.startswith('https://'): url = 'http://' + url self.get_root_window().set_cursor( Gdk.Cursor(Gdk.CursorType.WATCH)) self.add_feed(url) afd.destroy()
def upload(self,arg1): """Upload a doc to Google docs upon GUI call """ #Set the curosr to busy self._mainWindow.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) print 'ssss' folders=self.get_selected_folders() #upload to the first selected folder doc=self._gdam.upload_new_doc(self._filePath,None,self._tbUploadName.get_text()) #copy to the other resources for folder in folders: self._gdam.copy_resource_to_collection(folder,doc) self._mainWindow.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW)) self.show_succ_dlg('File upload succeeded') self.destroy_all(None)
def change_wallpaper(self): def on_change_wallpaper_done(result, error): self.get_window().set_cursor(None) @async_function(on_done=on_change_wallpaper_done) def do_change_wallpaper_in_thread(): self.save_preferences() change_wallpaper() return True self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) do_change_wallpaper_in_thread()
def __on_button_press(self, item, target, event): if event.button == 1: self.__drag_x = event.x self.__drag_y = event.y fleur = Gdk.Cursor(Gdk.CursorType.FLEUR) item.get_canvas().pointer_grab( item, Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK, fleur, event.time) self.__dragging = True return True
def restore_cursor(self): ''' No longer copying or sharing, so restore standard cursor. ''' self.tw.copying_blocks = False self.tw.sharing_blocks = False self.tw.saving_blocks = False self.tw.deleting_blocks = False if hasattr(self, 'get_window'): if hasattr(self.get_window(), 'get_cursor'): self.get_window().set_cursor(self._old_cursor) else: self.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.LEFT_PTR))
def _start_gtk(self): ''' Get a main window set up. ''' self.win.connect('configure_event', self.tw.update_overlay_position) self.tw.parent = self.win self.init_complete = True if self._ta_file is None: self.tw.load_start() else: self.win.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) GObject.idle_add(self._project_loader, self._ta_file) self._set_gconf_overrides() Gtk.main()
def _on_current_changed(self, player): if player.current.id is None: self._infobox.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.LEFT_PTR)) self._cover.hide() self._timelabel.hide() self._total_time_label.hide() self._progress.set_value(0.0) self._progress.set_sensitive(False) self._prev_btn.set_sensitive(False) self._play_btn.set_sensitive(False) self._next_btn.set_sensitive(False) self._title_label.set_text('') self._artist_label.set_text('') self._change_play_btn_status(self._play_image, _("Play")) if Objects.player.is_party(): self._activate_party_button() else: self._prev_btn.set_sensitive(True) self._play_btn.set_sensitive(True) self._next_btn.set_sensitive(True) self._infobox.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.HAND1)) art = Objects.art.get(player.current.album_id, ArtSize.SMALL) if art: self._cover.set_from_pixbuf(art) self._cover.set_tooltip_text(player.current.album) self._cover.show() else: self._cover.hide() self._title_label.set_text(player.current.title) self._artist_label.set_text(player.current.artist) self._progress.set_value(0.0) self._progress.set_range(0.0, player.current.duration * 60) self._total_time_label.set_text( seconds_to_string(player.current.duration)) self._total_time_label.show() self._timelabel.set_text("0:00") self._timelabel.show()
def gdkcursor_to_pbtcursor_str(gdk_cursor_type, cursor_name): cursor = Gdk.Cursor(gdk_cursor_type) pixbuf = cursor.get_image() width = pixbuf.get_width() height = pixbuf.get_height() row_stride = pixbuf.get_rowstride() n_channels = pixbuf.get_n_channels() img_data = pixbuf.get_pixels() unused_surface, xhot, yhot = cursor.get_surface() str_list = [] y_idx = 0 while y_idx < height: x_idx = 0 while x_idx < width: idx = x_idx * n_channels + y_idx * row_stride color = [] color.append(img_data[idx]) color.append(img_data[idx + 1]) color.append(img_data[idx + 2]) if n_channels > 3: color.append(img_data[idx + 3]) else: color.append(0xFF) str_list.append("%s, %s, %s, %s" % (color[0], color[1], color[2], color[3])) x_idx += 1 y_idx += 1 return \ "static unsigned char {cursor_name}_pixels[] = {pxl_list};\n".format(cursor_name = cursor_name, pxl_list = "{" + ", ".join(str_list) + "}") \ + \ "static pbt_cursor_t " + cursor_name + " = {\n" \ + \ " .pixbuf = {\n" \ + \ " .width = {width},\n" \ " .height = {height},\n" \ " .pixels = {cursor_name}_pixels\n".format(width = width, height = height, cursor_name = cursor_name) \ + \ " },\n" \ + \ " .xhot = {xhot},\n" \ " .yhot = {yhot},\n".format(xhot = int(xhot), yhot = int(yhot)) \ + \ "};"
def set_mouse_pointer_type(self, _type): list = [ Gdk.CursorType.ARROW, Gdk.CursorType.TOP_LEFT_CORNER, Gdk.CursorType.SB_V_DOUBLE_ARROW, Gdk.CursorType.TOP_RIGHT_CORNER, Gdk.CursorType.SB_H_DOUBLE_ARROW, Gdk.CursorType.FLEUR, Gdk.CursorType.SB_H_DOUBLE_ARROW, Gdk.CursorType.BOTTOM_LEFT_CORNER, Gdk.CursorType.SB_V_DOUBLE_ARROW, Gdk.CursorType.BOTTOM_RIGHT_CORNER ] arrow = Gdk.Cursor(list[_type]) gdk_window = self.get_root_window() gdk_window.set_cursor(arrow)
def on_realized(self, *args): if self.hide_mouse_pointer: self.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.BLANK_CURSOR)) logging.debug("Main window realized: allocated size %ux%u", self.get_allocated_width(), self.get_allocated_height()) icon_size = 200 if (self.get_allocated_width() > 1000) else 100 self.pause_icon = load_local_image('pause-solid', icon_size) self.play_icon = load_local_image('play-solid', icon_size) prev_icon = load_local_image('backward-solid', icon_size) self.prev_button.set_image(prev_icon) next_icon = load_local_image('forward-solid', icon_size) self.next_button.set_image(next_icon)
def refresh_stats(self, action, window, box): """ Refresh the statistics on the statistics window. """ LOG.info('refresh_stats') cursor = Gdk.Cursor(Gdk.CursorType.WATCH) self.get_root_window().set_cursor(cursor) Gdk.flush() data = requests.get('%s/statistics/' % TAGGERAPI, verify=not self.debug) jsondata = json.loads(data.text) self.statistics = jsondata['summary'] self.stats_action(window=window, box=box)
def on_downloader_failed(self, widget, row, filename): if os.path.exists(filename): os.remove(filename) row.set_downloading(False) row.set_downloaded(False) self.control['play-pause'].set_sensitive(False) self.control['speed'].set_sensitive(False) self.control['position'].set_sensitive(False) self.db.set_track_no_downloaded(row.data['id']) self.get_root_window().set_cursor(Gdk.Cursor(Gdk.CursorType.ARROW))
def add_tag_action(self, *args, **kw): """ Retrieve the tags from `entry_tag` and send them to the server, update the GUI afterward. """ LOG.info('add_tag_action') if not self.user: self.get_user_info(self.add_tag_action) return cursor = Gdk.Cursor(Gdk.CursorType.WATCH) self.get_root_window().set_cursor(cursor) Gdk.flush() self.set_messsage('') tagfield = self.builder.get_object('entry_tag') entries = tagfield.get_text() entries = [entry.strip() for entry in entries.split(',')] tagfield.set_text('') if entries != ['']: data = {'pkgname': self.pkgname, 'tag': ','.join(entries)} req = requests.put('%s/tag/%s/' % (TAGGERAPI, self.pkgname), data=data, auth=self.auth, verify=not self.debug) LOG.info('output: {0}'.format(req.text)) jsonreq = json.loads(req.text) if req.status_code != 200: self.set_messsage(jsonreq['error'], msgtype='error') msg.set_text() else: self.set_messsage('\n'.join(jsonreq['messages'])) self.get_package(self.pkgname) else: self.set_messsage('No tag(s) to add', msgtype='error') cursor = Gdk.Cursor(Gdk.CursorType.ARROW) self.get_root_window().set_cursor(cursor) Gdk.flush()
def _change_cursor(self, widget, cursor): if self.get_window() == None: return cursor_type = None if cursor == Cursor.ARROW: cursor_type = Gdk.CursorType.ARROW elif cursor == Cursor.LOADING: cursor_type = Gdk.CursorType.WATCH if cursor_type != None: self.get_window().set_cursor(Gdk.Cursor(cursor_type))
def _on_album_activated(self, flowbox, child): if self._album_id == child.get_child().get_id(): if Objects.settings.get_value('auto-play'): Objects.player.play_album(self._album_id) else: self._album_id = None self._revealer.set_reveal_child(False) else: self._album_id = child.get_child().get_id() self._populate_context(self._album_id) self._context.show() self._revealer.set_reveal_child(True) self._context_widget.eventbox.get_window().set_cursor( Gdk.Cursor(Gdk.CursorType.HAND1))