def __init_values(self): hseparator_color = [(0, ("#777777", 0.0)), (0.5, ("#000000", 0.3)), (1, ("#777777", 0.0)) ] self.height = 0 self.size_check = False self.hbox = gtk.HBox() self.title_image = gtk.image_new_from_file(os.path.join(image_path, "image/usb/usb_label.png")) self.title_label = gtk.Label(_("Storage Device")) #self.title_label.connect("expose-event", self.title_label_expose_event) self.title_label_ali = gtk.Alignment(0, 0, 0, 0) self.title_label_ali.set_padding(0, 0, 0, 0) self.title_label_ali.add(self.title_label) self.hbox.pack_start(self.title_image, False, False) self.hbox.pack_start(self.title_label_ali, True, True) self.h_separator_top = HSeparator(hseparator_color, 0, 0) self.h_separator_ali = gtk.Alignment(1, 1, 1, 1) self.h_separator_ali.set_padding(5, 10, 0, 0) self.h_separator_ali.add(self.h_separator_top) self.monitor_vbox = gtk.VBox() self.vbox = gtk.VBox() self.vbox.pack_start(self.hbox, False, False) self.vbox.pack_start(self.h_separator_ali, True, True) self.vbox.pack_start(self.monitor_vbox, True, True) self._ask_confirmed = False self.monitor = gio.VolumeMonitor() self.op = gio.MountOperation()
def __init__(self): gtk.Toolbar.__init__(self) self.set_style(gtk.TOOLBAR_BOTH_HORIZ) self.set_icon_size(gtk.ICON_SIZE_MENU) self.vm = gio.VolumeMonitor() self.vm.connect('volume-added', self.volume_changed) self.vm.connect('volume-removed', self.volume_changed) self.vm.connect('mount-added', self.volume_changed) self.vm.connect('mount-removed', self.volume_changed) self.refresh(self.vm)
def __init__(self): self.status_icon = gtk.StatusIcon() self.status_icon.set_visible(False) self.status_icon.set_from_stock(gtk.STOCK_HARDDISK) self.status_icon.connect('activate', self.on_left_click) self.status_icon.connect('popup-menu', self.on_right_click) self.status_icon.set_tooltip('Ejectsy') self.monitor = gio.VolumeMonitor() self.monitor.connect('volume-added', self.on_volume_added) self.monitor.connect('volume-removed', self.on_volume_removed) self.update_ui()
def __init__(self, callback): ''' Конструктор панели :param callback: Метод-коллбек, который будет вызван при возникновении события. В качестве параметра будет передан объект DriveEvent ''' gtk.Toolbar.__init__(self) self.callback = callback self.set_style(gtk.TOOLBAR_BOTH_HORIZ) #TOOLBAR_ICONS self.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR) self.vm = gio.VolumeMonitor() self.vm.connect('volume-added', self.volume_changed) self.vm.connect('volume-removed', self.volume_changed) self.vm.connect('mount-added', self.volume_changed) self.vm.connect('mount-removed', self.volume_changed) self.refresh(self.vm)
def _do_activate(self): self.volume_monitor = gio.VolumeMonitor() for mount in self.volume_monitor.get_mounts(): if not mount.is_shadowed(): self._add_mount(mount) if len(self.menu.get_children()) > 0: self.menu.add_separator() for volume in self.volume_monitor.get_volumes(): if volume.get_mount() == None: self._add_volume(volume) # Watch for changes self.volume_monitor.connect("mount_added", self._on_mount_added) self.volume_monitor.connect("mount_removed", self._on_mount_removed) # Refresh disk etc space every minute self._handle = g15scheduler.schedule("DiskRefresh", 60.0, self._refresh)
def automount_garmins__gnome(): import gio import gobject garmins = [] loop = gobject.MainLoop() def mount_done_cbk(volume, result): volume.mount_finish(result) loop.quit() drives = gio.VolumeMonitor().get_connected_drives() for drive in drives: for volume in drive.get_volumes(): dev = volume.get_identifier('unix-device') devprop = get_device_properties(dev) if devprop['ID_VENDOR_ID'] != GARMIN_VENDOR_ID: continue if volume.get_mount() == None: log.info('Mounting Garmin device (' + dev + ')...') if not volume.can_mount(): log.error('Impossible to mount device') else: volume.mount(None, mount_done_cbk) loop.run() log.debug('Mount done') root = volume.get_mount().get_root().get_path() devinfo = find_and_parse_garmindevice_xml(root) if devinfo is None: log.error('Couldn\'t find GarminDevice.xml') continue log.info('Found Garmin ' + devinfo.Model.Description) obj = {'_gnome_volume': volume, 'root': root, 'name': devinfo.Model.Description, 'id': devinfo.Id, 'activities': find_activities_path(root)} if obj['activities'] == None: continue yield obj
def load_menu_items(self): items = [] self.volume_monitor_signals = [] # Webcams etc video_devices = [] for i in os.listdir("/dev"): if i.startswith("video"): video_devices.append(i) if len(video_devices) > 0: items.append( g15theme.MenuItem("video-devices", True, _("Video Devices"), icon=g15icontools.get_icon_path( ["camera-web", "camera-video"]), activatable=False)) for i in video_devices: items.append(G15VideoDeviceMenuItem(self, i)) # Video File def activate_video_file(): gobject.idle_add(self._open_video_file) items.append( g15theme.MenuItem("video-file", True, _("Open Audio/Video File"), activate=activate_video_file, icon=g15icontools.get_icon_path("folder"))) # DVD / Mounts self.volume_monitor = gio.VolumeMonitor() self.volume_monitor_signals.append( self.volume_monitor.connect("mount_added", self._on_mount_added)) self.volume_monitor_signals.append( self.volume_monitor.connect("mount_removed", self._on_mount_removed)) removable_media_items = [] for i, mount in enumerate(self.volume_monitor.get_mounts()): drive = mount.get_drive() if not mount.is_shadowed( ) and drive is not None and drive.is_media_removable(): removable_media_items.append( MountMenuItem('mount-%d' % i, mount, self)) if len(removable_media_items): items.append( g15theme.MenuItem("removable-devices", True, _("Removable Devices"), icon=g15icontools.get_icon_path([ "driver-removable-media", "gnome-dev-removable" ]), activatable=False)) items += removable_media_items # Pulse status, output = g15os.get_command_output("pacmd list-sources") if status == 0 and len(output) > 0: i = 0 pulse_items = [] for line in output.split("\n"): line = line.strip() if line.startswith("name: "): name = line[7:-1] elif line.startswith("device.description = "): pulse_items.append( PulseSourceMenuItem(name, line[22:-1], self)) if len(pulse_items) > 0: items.append( g15theme.MenuItem("pulse-sources", True, _("PulseAudio Source"), icon=g15icontools.get_icon_path([ "audio-card", "audio-speakers", "audio-volume-high", "audio-x-generic" ]), activatable=False)) items += pulse_items # Visualisations - TODO - there must be a better way to list them items.append( g15theme.MenuItem("visualisation-mode", True, _("Visualisation Mode"), icon=g15icontools.get_icon_path([ "preferences-color", "gtk-select-color", "preferences-desktop-screensaver", "kscreensaver", "xscreensaver" ]), activatable=False)) for c in [ "goom", \ "libvisual_bumpscope", \ "libvisual_corona", \ "libvisual_infinite", \ "libvisual_jakdaw", \ "libvisual_jess", \ "libvisual_lv_analyzer", \ "libvisual_lv_scope", \ "libvisual_lv_oinksie", \ "synaesthesia", \ "spacescope", \ "spectrascope", \ "synaescope", \ "wavescope", \ "monoscope"]: try: gst.element_factory_make(c) items.append(G15VisualisationMenuItem(c, self)) except Exception as e: logger.debug("Error creating visualizations", exc_info=e) pass self.menu.set_children(items) if len(items) > 0: self.menu.selected = items[0] else: self.menu.selected = None
#"Changed: " + d.get_name() + "\n" print "\nDrives:" for drive in drives: print drive.get_name() print "\nVolumes:" for volume in volumes: print volume.get_name() print "\nMounts:" for mount in mounts: print mount.get_name() vm = gio.VolumeMonitor() changed(vm, None) #vm.connect('drive-connected', changed) vm.connect('mount-added', changed) vm.connect('volume-added', changed) #vm.connect('drive-disconnected', changed) vm.connect('mount-removed', changed) vm.connect('volume-removed', changed) ''' vm.connect('drive-changed', changed) vm.connect('mount-changed', changed) vm.connect('volume-changed', changed) '''
def __init__(self): gobject.GObject.__init__(self) # Glade setup self.builder = gtk.Builder() self.builder.add_from_file(os.path.join(UIDIR, "filechooser.glade")) self.builder.connect_signals(self) # Retrieve frequently used objects self.nav_box = self.builder.get_object('hbox1') self.eject_column = self.builder.get_object('eject_col') file_adj = self.builder.get_object('scrolledwindow1') self.file_vadj = file_adj.get_vadjustment() self.file_hadj = file_adj.get_hadjustment() # Retrieve data models self.file_liststore = self.builder.get_object("file_liststore") self.bookmark_liststore = self.builder.get_object("bookmark_liststore") # Retrieve treeviews self.file_treeview = self.builder.get_object("file_treeview") self.bookmark_treeview = self.builder.get_object("bookmark_treeview") self.bookmark_treeview.set_row_separator_func(self.bookmark_separator) # Enable DnD TODO DnD is not implemented yet self.file_treeview.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, \ [('text/plain', 0, 0)], gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_COPY) self.file_treeview.enable_model_drag_dest([('text/plain', 0, 0)], \ gtk.gdk.ACTION_COPY) # Connect callbacks to VolumeMonitor self.mounts = gio.VolumeMonitor() self.mounts.connect('mount-added', self.on_mount_added) self.mounts.connect('mount-removed', self.on_mount_removed) # Initialize objects self.ok_cancel_dialog = Dialogs(DialogTypes.OK_CANCEL) self.bookmarks = BookMarks() self.icons = Icons(gtk.icon_theme_get_default()) # Initialize places home = os.environ['HOME'] desktop = os.path.expanduser("~/Desktop") self.places = [home, desktop] # Initialize variables self._cur_dir = desktop self._old_dir = " " self._filters = {} self._filter = '' self._files = [] self._show_hidden = False self._hidden_exts = ['.desktop'] self._copy = True self._selection = None self.nav_btn_list = [] self.nav_btn_path_dict = {} # Initialize self._init_nav_buttons()