Exemple #1
0
    def icon_clicked_cb(self, widget, event):
        window = wnck.window_get(int(widget.get_name()))
        wsp = self.get_desktop_num_for_win(window)
        active_wsp = self._get_active_desktop()
        active_win = self.screen.get_active_window()
        
        if event.button == 1: # left click

            if not wsp == active_wsp:
                self.switch_to_desktop(wsp)
                window.activate(event.get_time())
            elif window.is_minimized():
                window.unminimize(event.get_time())
                window.activate(event.get_time())
            elif window == active_win:
                window.minimize()
            else:
                window.activate(event.get_time())

        elif event.button==3: # right click
            self.button_focus = window
            self.popupMenu.popup(None, None, None, event.button, event.time)
        
        ## need this to avoid call to Bar menu
        return True
Exemple #2
0
            def wrapper(wm, window=None, *args, **kwargs):

                # Get Wnck and GDK window objects
                window = window or wm.screen.get_active_window()
                if isinstance(window, gtk.gdk.Window):
                    win = wnck.window_get(window.xid)
                else:
                    win = window

                logging.debug("window: %s", win)
                if not win:
                    return None

                monitor_id, monitor_geom = wm.get_monitor(window)

                use_area, use_rect = wm.get_workarea(monitor_geom,
                                                     wm.ignore_workarea)

                # TODO: Replace this MPlayer safety hack with a properly
                #       comprehensive exception catcher.
                if not use_rect:
                    logging.debug("use_rect: %s", use_rect)
                    return None

                state = {
                    "cmd_name": name,
                    "monitor_id": monitor_id,
                    "monitor_geom": monitor_geom,
                    "usable_region": use_area,
                    "usable_rect": use_rect,
                }

                args, kwargs = p_args + args, dict(p_kwargs, **kwargs)
                func(wm, win, state, *args, **kwargs)
Exemple #3
0
    def icon_clicked_cb(self, widget, event):
        window = wnck.window_get(int(widget.get_name()))
        wsp = self.get_desktop_num_for_win(window)
        active_wsp = self._get_active_desktop()
        active_win = self.screen.get_active_window()

        if event.button == 1:  # left click

            if not wsp == active_wsp:
                self.switch_to_desktop(wsp)
                window.activate(event.get_time())
            elif window.is_minimized():
                window.unminimize(event.get_time())
                window.activate(event.get_time())
            elif window == active_win:
                window.minimize()
            else:
                window.activate(event.get_time())

        elif event.button == 3:  # right click
            self.button_focus = window
            self.popupMenu.popup(None, None, None, event.button, event.time)

        ## need this to avoid call to Bar menu
        return True
Exemple #4
0
            def wrapper(wm, window=None, *args, **kwargs):

                # Get Wnck and GDK window objects
                window = window or wm.screen.get_active_window()
                if isinstance(window, gtk.gdk.Window):
                    win = wnck.window_get(window.xid)
                else:
                    win = window

                logging.debug("window: %s", win)
                if not win or win.get_window_type() == wnck.WINDOW_DESKTOP:
                    return None

                monitor_id, monitor_geom = wm.get_monitor(window)

                use_area, use_rect = wm.get_workarea(monitor_geom,
                                                     wm.ignore_workarea)

                # TODO: Replace this MPlayer safety hack with a properly
                #       comprehensive exception catcher.
                if not use_rect:
                    logging.debug("use_rect: %s", use_rect)
                    return None

                state = {
                    "cmd_name": name,
                    "monitor_id": monitor_id,
                    "monitor_geom": monitor_geom,
                    "usable_region": use_area,
                    "usable_rect": use_rect,
                }

                args, kwargs = p_args + args, dict(p_kwargs, **kwargs)
                func(wm, win, state, *args, **kwargs)
Exemple #5
0
    def substitute(self, button, widget):
        window = wnck.window_get(int(widget.get_name()))
        prop = self.window_get_class_hint(window)
        if not prop:
            dialog = self.prefs.get_widget('unsubstitutable')
            if not dialog:
                self.pref_dialog_init()
                dialog = self.prefs.get_widget('unsubstitutable')

            text = dialog.get_property('secondary-text')
            dialog.format_secondary_text(text.replace('%s', window.get_name()))
            dialog.connect('response', lambda w, r: w.destroy())
            dialog.run()
            return

        cls = ".".join(prop)

        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
                   gtk.RESPONSE_ACCEPT)
        dialog = gtk.FileChooserDialog("Pick an icon", buttons=buttons)
        dialog.connect('response', lambda d, l: d.hide())
        response = dialog.run()

        if response != gtk.RESPONSE_ACCEPT:
            return

        self.config['substitutions'][cls] = dialog.get_filename()
        self.ok_clicked_cb(None)  # save
        self.substitution_init()
Exemple #6
0
    def icon_unhover_cb(self, widget, event):
        window = wnck.window_get(int(widget.get_name()))
        widget.pixbuf = widget.pixbuf_origin.copy()
        if window.is_minimized():
            widget.pixbuf.saturate_and_pixelate(widget.pixbuf, 0.3, False)

        ### FIXME !!
        self.bar.can_hide = True
        self.bar.update()
        return True
Exemple #7
0
 def icon_unhover_cb(self, widget, event):
     window = wnck.window_get(int(widget.get_name()))
     widget.pixbuf = widget.pixbuf_origin.copy()
     if window.is_minimized():
         widget.pixbuf.saturate_and_pixelate(widget.pixbuf, 0.3, False)
     
     ### FIXME !!
     self.bar.can_hide = True
     self.bar.update()
     return True
Exemple #8
0
 def icon_clicked_cb(self, widget, event):
     if event.button == 1:
         window = wnck.window_get(int(widget.get_name()))
         if self.window_active == window:
             window.minimize()
         else:
             window.get_workspace().activate(event.get_time())
             window.activate(event.get_time())
     else:
         self.window_context_menu(widget).popup(
             None, None, None, event.button, event.get_time())
Exemple #9
0
    def on_scroll_event(self, widget, event):
        window = wnck.window_get(int(widget.get_name()))

        if event.direction == gtk.gdk.SCROLL_DOWN:
            if window.is_minimized():
                window.unminimize(event.get_time())
            else:
                window.minimize()
        elif event.direction == gtk.gdk.SCROLL_UP:
            if window.is_maximized():
                window.unmaximize()
            else:
                window.maximize()
Exemple #10
0
    def icon_hover_cb(self, widget, event):
        window = wnck.window_get(int(widget.get_name()))

        widget.pixbuf = widget.pixbuf_origin.copy()
        widget.pixbuf.saturate_and_pixelate(widget.pixbuf, 2, False)

        if self.cfg["tooltips"]:
            self.bar.tooltip.run(widget)

        ### FIXME !!
        self.bar.can_hide = False
        self.bar.update()
        return True
Exemple #11
0
 def on_scroll_event(self, widget, event):
     window = wnck.window_get(int(widget.get_name()))
     
     if event.direction == gtk.gdk.SCROLL_DOWN:
             if window.is_minimized():
                 window.unminimize(event.get_time())
             else:
                 window.minimize()
     elif event.direction == gtk.gdk.SCROLL_UP:
         if window.is_maximized():
             window.unmaximize()
         else:
             window.maximize()
Exemple #12
0
    def icon_hover_cb(self, widget, event):
        window = wnck.window_get(int(widget.get_name()))
        
        widget.pixbuf = widget.pixbuf_origin.copy()
        widget.pixbuf.saturate_and_pixelate(widget.pixbuf, 2, False)

        if self.cfg['tooltips']:
            self.bar.tooltip.run(widget)
            
        ### FIXME !!
        self.bar.can_hide = False
        self.bar.update()
        return True
Exemple #13
0
            def wrapper(wm, window=None, *args, **kwargs):

                # Get Wnck and GDK window objects
                window = window or wm.screen.get_active_window()
                if isinstance(window, gtk.gdk.Window):
                    win = wnck.window_get(window.xid)
                else:
                    win = window

                if not win:
                    logging.debug("Received no window object to manipulate.")
                    return None
                elif win.get_window_type() == wnck.WINDOW_DESKTOP:
                    logging.debug("Received desktop window object. Ignoring.")
                    return None
                else:
                    # FIXME: Make calls to win.get_* lazy in case --debug
                    #        wasn't passed.
                    logging.debug(
                        'Operating on window 0x%x with title "%s" ' "and geometry %r",
                        win.get_xid(),
                        win.get_name(),
                        win.get_geometry(),
                    )

                monitor_id, monitor_geom = wm.get_monitor(window)

                use_area, use_rect = wm.get_workarea(monitor_geom, wm.ignore_workarea)

                # TODO: Replace this MPlayer safety hack with a properly
                #       comprehensive exception catcher.
                if not use_rect:
                    logging.debug(
                        "Received a worthless value for largest "
                        "rectangular subset of desktop (%r). Doing "
                        "nothing.",
                        use_rect,
                    )
                    return None

                state = {
                    "cmd_name": name,
                    "monitor_id": monitor_id,
                    "monitor_geom": monitor_geom,
                    "usable_region": use_area,
                    "usable_rect": use_rect,
                }

                args, kwargs = p_args + args, dict(p_kwargs, **kwargs)
                func(wm, win, state, *args, **kwargs)
Exemple #14
0
 def run(self):
     screen = wnck.screen_get_default()
     screen.force_update()
     active = screen.get_active_window()
     if active.get_name() == "ducklauncher!!!":
         active = screen.get_previously_active_window()
     w = wnck.window_get(self.win_info['id'])
     try:
         if w.is_minimized():
             w.activate(gtk.get_current_event_time())
         elif w.get_xid() == active.get_xid():
             w.minimize()
         else:
             w.activate(gtk.get_current_event_time())
     except AttributeError:
         w.activate(gtk.get_current_event_time())
Exemple #15
0
	def run(self):
		screen = wnck.screen_get_default()
		screen.force_update()
		active= screen.get_active_window()
		if active.get_name()=="ducklauncher!!!":
			active= screen.get_previously_active_window()
		w=wnck.window_get(self.win_info ['id'])
		try:
			if w.is_minimized():
				w.activate(gtk.get_current_event_time())
			elif w.get_xid()==active.get_xid():
				w.minimize()
			else:
				w.activate(gtk.get_current_event_time())
		except AttributeError:
			w.activate(gtk.get_current_event_time())
Exemple #16
0
    def is_on_active_workspace(self):
        """Determines if MainWindow is on the active workspace.

        Returns:
            bool: True if on active workspace (or wnck module not available), otherwise False.

        """
        if wnck:
            self.screen.force_update()
            win = wnck.window_get(self.window.get_window().xid)
            if win:
                active_wksp = win.get_screen().get_active_workspace()
                if active_wksp:
                    return win.is_on_workspace(active_wksp)
                return False
        return True
Exemple #17
0
            def wrapper(wm, window=None, *args, **kwargs):

                # Get Wnck and GDK window objects
                window = window or wm.screen.get_active_window()
                if isinstance(window, gtk.gdk.Window):
                    win = wnck.window_get(window.xid)
                else:
                    win = window

                if not win:
                    logging.debug("Received no window object to manipulate.")
                    return None
                elif win.get_window_type() == wnck.WINDOW_DESKTOP:
                    logging.debug("Received desktop window object. Ignoring.")
                    return None
                else:
                    # FIXME: Make calls to win.get_* lazy in case --debug
                    #        wasn't passed.
                    logging.debug(
                        "Operating on window 0x%x with title \"%s\" "
                        "and geometry %r", win.get_xid(), win.get_name(),
                        win.get_geometry())

                monitor_id, monitor_geom = wm.get_monitor(window)

                use_area, use_rect = wm.get_workarea(monitor_geom,
                                                     wm.ignore_workarea)

                # TODO: Replace this MPlayer safety hack with a properly
                #       comprehensive exception catcher.
                if not use_rect:
                    logging.debug(
                        "Received a worthless value for largest "
                        "rectangular subset of desktop (%r). Doing "
                        "nothing.", use_rect)
                    return None

                state = {
                    "cmd_name": name,
                    "monitor_id": monitor_id,
                    "monitor_geom": monitor_geom,
                    "usable_region": use_area,
                    "usable_rect": use_rect,
                }

                args, kwargs = p_args + args, dict(p_kwargs, **kwargs)
                func(wm, win, state, *args, **kwargs)
Exemple #18
0
import wnck
screen = wnck.screen_get_default()
wnck.window_get(58720313L).activate(9999999999)
Exemple #19
0
def close_window(title):
	w=wnck.window_get(title)
	w.close(gtk.get_current_event_time())
Exemple #20
0
def activateFakewin(id_):
	w = wnck.window_get(id_)
Exemple #21
0
def activateFakewin(id_):
	w = wnck.window_get(id_)
	w.activate(gtk.get_current_event_time())
window_list = ""

while running:
		while gtk.events_pending():
				gtk.main_iteration_do(False)

		window_list_new = screen.get_windows()
		if(len(set(window_list_new) ^ set(window_list)) != 0):
				window_list = window_list_new
				if len(window_list) != 0:
						s = ""
						for win in window_list:
								s += str(win.get_xid())+"|"
						try:
								clientfile.write(s+'|'+'\n')
						except Exception:
								pass
				else:
						clientfile.write("No windows open.")

		try:
			line = clientfile.readline().rstrip()
			w = wnck.window_get(int(line))
			w.activate(int(time.time()))
		except Exception:
			pass

clientfile.close()
clientsock.close()

Exemple #23
0
 def icon_hover_cb(self, widget, event):
     window = wnck.window_get(int(widget.get_name()))
     pbuf = self.window_get_icon(window)
     image = widget.get_children()[0]
     self.hover = image.get_pixbuf()
     image.set_from_pixbuf(pbuf)
Exemple #24
0
# get screen 
default = wnck.screen_get_default()
# purge the events
while gtk.events_pending():
       	gtk.main_iteration(False)
# get the window list and make the Unity window active
window_list = default.get_windows()
if len(window_list) == 0:
       	print "No Windows Found"
for win in window_list:
       	if (win.get_name() == 'golf-simulator-current'):
		# print win.get_name()
		# print win.get_xid()
		now = gtk.gdk.x11_get_server_time(gtk.gdk.get_default_root_window())
		wnck.window_get(win.get_xid()).activate(now)
	
while gtk.events_pending():
	gtk.main_iteration()
time.sleep(0.5)

# get the active window
w = gdk.get_default_root_window().get_screen().get_active_window()
sz = w.get_size()
# print "The size of the window is %d x %d" % sz

while True:

	pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
	pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
Exemple #25
0
    def window_context_menu(self, widget):
        menu = gtk.Menu()

        window = wnck.window_get(int(widget.get_name()))

        if window.is_maximized():
            item = gtk.ImageMenuItem(gtk.STOCK_ZOOM_OUT)
            item.get_children()[0].set_label('_Restore')
            item.connect('activate',
                         (lambda button, window: window.unmaximize()), window)
        else:
            item = gtk.ImageMenuItem(gtk.STOCK_ZOOM_100)
            item.get_children()[0].set_label('_Maximize')
            item.connect('activate',
                         (lambda button, window: window.maximize()), window)

        item.show()
        menu.append(item)

        if window.is_minimized():
            item = gtk.ImageMenuItem(gtk.STOCK_REDO)
            item.get_children()[0].set_label('_Unminimize')
            item.connect('activate',
                         (lambda button, window: window.unminimize(0)), window)
        else:
            item = gtk.ImageMenuItem(gtk.STOCK_UNDO)
            item.get_children()[0].set_label('M_inimize')
            item.connect('activate',
                         (lambda button, window: window.minimize()), window)

        item.show()
        menu.append(item)

        item = gtk.ImageMenuItem(gtk.STOCK_CLOSE)
        item.connect('activate',
                     (lambda button, window: window.close(0)), window)
        item.show()
        menu.append(item)

        separator = gtk.SeparatorMenuItem()
        separator.show()
        menu.append(separator)

        substitute = gtk.ImageMenuItem(gtk.STOCK_SELECT_COLOR)
        substitute.get_children()[0].set_label('_Substitute')
        substitute.connect('activate', self.substitute, widget)
        menu.append(substitute)
        substitute.show()

        ary = self.window_icon_is_substituted(
            wnck.window_get(int(widget.get_name())))

        if ary:
            unsubstitute = gtk.ImageMenuItem(gtk.STOCK_CLEAR)
            unsubstitute.get_children()[0].set_label('_Remove Substitution')
            unsubstitute.connect('activate', self.unsubstitute, ary[0])
            unsubstitute.show()
            menu.append(unsubstitute)

        separator = gtk.SeparatorMenuItem()
        separator.show()
        menu.append(separator)

        preferences = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        preferences.connect('activate', lambda w:
                            self.prefs.get_widget('preferences').show())
        preferences.show()
        menu.append(preferences)
        return menu
Exemple #26
0
def activateFakewin(id_):
    w = wnck.window_get(id_)
    w.activate(gtk.get_current_event_time())
Exemple #27
0
def close_window(title):
    w = wnck.window_get(title)
    w.close(gtk.get_current_event_time())