def __init__(self,filename): self.filename = filename; self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_decorated(0) ### agar border window terlihat/tidak terlihat (0=hidden/1=shown), origin=0 self.window.set_default_size(800, 650) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize colors, alpha transparency self.window.set_app_paintable(1) ### agar window bisa diwarnain (0=ga bisa / 1=bisa), origiin=1 self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w,self.h = self.window.get_size() self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit)
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_UTILITY) self.window.set_position(gtk.WIN_POS_CENTER) self.window.set_decorated(0) self.window.set_default_size(960, 650) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize colors, alpha transparency self.window.set_app_paintable(1) self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w, self.h = self.window.get_size() self.window.connect("expose_event", self.expose)
def __init__(self): self.duration=2 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_decorated(0) self.window.set_default_size(800, 650) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) self.window.set_app_paintable(1) self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w,self.h = self.window.get_size() self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit) self.counter=0 gobject.timeout_add(self.duration*1000, self.close_screen)
def __init__(self): self._Winwo_bgImg = './images/calendar_single.png' #Create Window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) #Set Signals self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit) #Set Window PRoperties self.window.set_decorated(False) self.window.set_size_request(130, 141) self.window.move(1220,50) self.window.set_property('skip-taskbar-hint', True) self.window.set_transient_for(None) self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK) self.window.stick() self.window.set_keep_below(True) #Initialize colors, alpha transparency self.window.set_app_paintable(True) self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if self.window.is_composited(): self.supports_alpha = True else: self.supports_alpha = False self.w,self.h = self.window.get_size()
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_decorated(True) self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.window.set_keep_above(True) self.window.set_skip_taskbar_hint(True) self.window.set_skip_pager_hint(True) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize colors, alpha transparency self.window.set_app_paintable(True) self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w,self.h = self.window.get_size() self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit)
def __init__(self): self.window = gtk.Window(gtk.WINDOW_POPUP) # Initialize window self.window.set_decorated(False) self.window.set_keep_above(True) self.window.set_app_paintable(True) self.window.set_skip_pager_hint(True) self.window.set_skip_taskbar_hint(True) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize colors, alpha transparency self.screen = self.window.get_screen() w, h = self.screen.get_width(), self.screen.get_height() # self.window.set_default_size(w, 100) # self.window.move(800, 600) colormap = self.screen.get_rgba_colormap() if colormap == None: colormap = self.screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w, self.h = self.window.get_size() pixmap = gtk.gdk.Pixmap(None, self.w, self.h, 1) self.window.input_shape_combine_mask(pixmap, 0, 0) self.window.connect('expose_event', self.on_expose_event) self.window.connect('destroy', gtk.main_quit) self.layout = None gobject.timeout_add(2000, self.on_timeout)
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_UTILITY) self.window.set_position(gtk.WIN_POS_CENTER) self.window.set_decorated(0) self.window.set_default_size(960, 650) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize colors, alpha transparency self.window.set_app_paintable(1) self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w,self.h = self.window.get_size() self.window.connect("expose_event", self.expose)
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_decorated(True) self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS) self.window.set_keep_above(True) self.window.set_skip_taskbar_hint(True) self.window.set_skip_pager_hint(True) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize colors, alpha transparency self.window.set_app_paintable(True) self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w, self.h = self.window.get_size() self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit)
def __init__(self): gtk.Window.__init__(self) self.has_cursor = None self.set_position(gtk.WIN_POS_CENTER_ALWAYS) gtk.window_set_default_icon_from_file(ICON + "logo.png") self.set_title(_("Device Manager")) #window.set_resizable(False) self.set_decorated(False) self.set_size_request(DEFAULT_WIDTH, DEFAULT_HEIGHT) self.set_app_paintable(True) # receive all event masks self.set_events(gtk.gdk.ALL_EVENTS_MASK) self.connect("destroy", self.destroy) self.connect("expose_event", self.expose) self.connect("size-allocate", self.size_allocate_event) self.connect("motion-notify-event", self.motion_notify) self.connect("button-press-event", self.resize_window) # supports alpha channels screen = self.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) self.set_geometry_hints(None, 600, 400)
def __init__(self, hide_method): gobject.GObject.__init__(self) print 'start' self.searchitem = '' self.hide_method = hide_method #Set the main working directory to home os.chdir(Globals.HomeDirectory) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title('GnoMenu') self.window.set_focus_on_map(1) self.window.set_app_paintable(1) self.window.set_skip_taskbar_hint(1) self.window.set_skip_pager_hint(1) self.window.set_decorated(0) self.window.set_keep_above(0) #Make this always above other windows self.window.stick() #Make this appear on all desktops self.window.set_default_size(Globals.MenuWidth,Globals.MenuHeight) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) try: # Workaround for Ubuntu Natty self.window.set_property('has-resize-grip', False) except TypeError: pass #if not self.window.window: self.colorpb = None self.setup() self.window.connect("composited-changed", self.composite_changed) self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit) #Fixme? self.window.connect("focus-out-event", self.lose_focus) #self.window.connect("button-press-event",self.lose_focus) self.window.connect("key-press-event", self.key_down) # self.window.connect("proximity_out_event",self.lose_focus) self.gtk_screen = self.window.get_screen() print self.gtk_screen self.Launcher = Launcher.Launcher() self.Launcher.connect('special-command',self.special_command) colormap = self.gtk_screen.get_rgba_colormap() print colormap if colormap is None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True #print self.sys_get_window_manager() #try: # if self.sys_get_window_manager() == 'compiz': # pass#self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_MENU) #except:pass self.w,self.h = self.window.get_size() self.leave_focus = True self.callback = None self.callback_search = None self.GnomeMenu = None self.visible = False if Globals.Settings['SuperL'] == 1: self.bind_with_keybinder()
def __init__(self, title="", width=None, height=None, main_window=True): #set share if share.USE_FULLSCREEN: share.REAL_WIDTH = share.SCREEN_WIDTH share.REAL_HEIGHT = int( share.SCREEN_WIDTH*( share.STD_HEIGHT*1.0/share.STD_WIDTH)) else: if width: share.REAL_WIDTH = width if height: share.REAL_HEIGHT = height share.WIDTH_ZOOM_SCALE = share.REAL_WIDTH*1.0/share.STD_WIDTH share.HEIGHT_ZOOM_SCALE = share.REAL_HEIGHT*1.0/share.STD_HEIGHT share.WINDOW_TITLE = title #set window gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) widget.Widget.__init__(self) self.set_resizable(False) self.set_app_paintable(True) if share.USE_FULLSCREEN: self.modify_bg(0, gtk.gdk.color_parse("#333")) self.set_decorated(False) self.set_size_request(share.SCREEN_WIDTH, share.SCREEN_HEIGHT) else: self.set_size_request(share.REAL_WIDTH, share.REAL_HEIGHT) self.set_position(gtk.WIN_POS_CENTER) self.set_title(title) #self.set_events(share.EVENT_MASK) #enable rgba support #gtk.gdk.Screen().get_rgb_colormap() #gtk.gdk.Screen().get_rgba_colormap() self.color_map = self.get_screen().get_rgba_colormap() #rgba support if self.color_map: gtk.widget_set_default_colormap(self.color_map) self.set_colormap(self.color_map) #set layer self.layer_list = {} if share.USE_FULLSCREEN: self.layer_list["__BASE__"] = layer.Layer("__BASE__") self.layer_list["__SCREEN__"] = layer.Layer("__SCREEN__") self.layer_list["__SCREEN__"].put( self.layer_list["__BASE__"], 0, (share.SCREEN_HEIGHT-share.REAL_HEIGHT)/2, ) self.add(self.layer_list["__SCREEN__"]) else: self.layer_list["__BASE__"] = layer.Layer("__BASE__") self.add(self.layer_list["__BASE__"]) #set event self.bind_event("exit", event.exit) self.bind_event("destroy", lambda *args: True) self.show_all() #set main window if main_window: share.MAIN_WINDOW = self share.set_gtk_font(share.GLOBAL_GTK_FONT_NAME, share.GLOBAL_GTK_FONT_SIZE) self.hide()
def main(): log.logger.info('Started') # Localization locale.setlocale(locale.LC_ALL, '') gettext.textdomain(consts.appNameShort) gettext.bindtextdomain(consts.appNameShort, consts.dirLocale) # Command line prefs.setCmdLine((optOptions, optArgs)) # PyGTK initialization gobject.threads_init() gtk.window_set_default_icon_list( gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon16), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon24), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon32), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon48), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon64), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon128)) # Create the GUI wTree = loadGladeFile('MainWindow.ui') paned = wTree.get_object('pan-main') window = wTree.get_object('win-main') prefs.setWidgetsTree(wTree) # RGBA support try: colormap = window.get_screen().get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) except: log.logger.info('No RGBA support (requires PyGTK 2.10+)') # Show all widgets and restore the window size BEFORE hiding some of them # when restoring the view mode # Resizing must be done before showing the window to make sure that the WM # correctly places the window if prefs.get(__name__, 'win-is-maximized', DEFAULT_MAXIMIZED_STATE): window.maximize() height = prefs.get(__name__, 'win-height', DEFAULT_WIN_HEIGHT) window.resize(prefs.get(__name__, 'win-width', DEFAULT_WIN_WIDTH), height) window.show_all() # Restore sizes once more #window.resize(prefs.get(__name__, 'win-width', DEFAULT_WIN_WIDTH), height) paned.set_position(prefs.get(__name__, 'paned-pos', DEFAULT_PANED_POS)) # Initialization done, let's continue the show gobject.idle_add(realStartup, window, paned) gtk.main()
def __init__(self, window, terminal): self.window = window self.terminal = terminal self.window.set_size_request(640, 480) self.window.set_position(gtk.WIN_POS_CENTER) self.window.connect('delete-event', self.delete_event) colormap = self.window.get_screen().get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) self.window.add(terminal) self.childpid = self.terminal.fork_command(self.command[0], self.command, os.getcwd()) if self.childpid > 0: self.childexited = self.terminal.connect('child-exited', self.on_child_exited) self.window.connect('delete-event', lambda w, e: gtk.main_quit()) else: self.childexited = None spawn_later(0.5, self.show_startup_notify) self.window.show_all() logo_filename = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'promgui.png') self.window.set_icon_from_file(logo_filename) if appindicator: self.trayicon = appindicator.Indicator( 'Prom', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS) self.trayicon.set_status(appindicator.STATUS_ACTIVE) self.trayicon.set_attention_icon('indicator-messages-new') self.trayicon.set_icon(logo_filename) self.trayicon.set_menu(self.make_menu()) else: self.trayicon = gtk.StatusIcon() self.trayicon.set_from_file(logo_filename) self.trayicon.connect( 'popup-menu', lambda i, b, t: self.make_menu().popup( None, None, gtk.status_icon_position_menu, b, t, self. trayicon)) self.trayicon.connect('activate', self.show_hide_toggle) self.trayicon.set_tooltip('Prom') self.trayicon.set_visible(True)
def __init__(self): gtk.Window.__init__(self) self.set_border_width(24) self.set_app_paintable(True) self.set_decorated(False) self.set_position(gtk.WIN_POS_CENTER_ALWAYS) # setup RGBA colormaps for translucency screen = self.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) # parse the rcdata gtk.rc_parse_string(rcdata) self.connect('expose-event', self.hud_expose)
def __init__(self, bgimg): self.width = 800 self.height = 600 self.lockfile = "/tmp/.classroom-assembly-working" self.bgimg = bgimg # Create Top Level Window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) # Remove decoration self.window.set_decorated(0) # Set splash position self.window.set_position(gtk.WIN_POS_CENTER) # Set splash window size self.window.set_default_size(self.width, self.height) # Masking events self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize RGBA self.window.set_app_paintable(1) # Setting screen self.gtk_screen = self.window.get_screen() # Setting Colormap colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) # Is composite enable? if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w, self.h = self.window.get_size() print "w=" + str(self.w) + " h=" + str(self.h) print "x=" + str(self.width) + " y=" + str(self.height) # Binding events self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit)
def SetUpSocket(self, mode="socket"): 'Attach the socket and color it black to avoid flashes when changing previews' # Disable alpha colormap gtk.widget_set_default_colormap(self.rgbcolormap) if mode == "socket": Socket = gtk.Socket() elif mode == "drawingarea": Socket = gtk.DrawingArea() self.Preview.add(Socket) black = gtk.gdk.Color(red=0, green=0, blue=0, pixel=0) Socket.modify_bg(gtk.STATE_NORMAL, black) # Re-enable alpha colormap gtk.widget_set_default_colormap(self.colormap) return Socket
def SetUpSocket(self,mode="socket"): 'Attach the socket and color it black to avoid flashes when changing previews' # Disable alpha colormap gtk.widget_set_default_colormap(self.rgbcolormap) if mode == "socket": Socket = gtk.Socket() elif mode == "drawingarea": Socket = gtk.DrawingArea() self.Preview.add(Socket) black = gtk.gdk.Color(red=0, green=0, blue=0, pixel=0) Socket.modify_bg(gtk.STATE_NORMAL,black) # Re-enable alpha colormap gtk.widget_set_default_colormap(self.colormap) return Socket
def __init__(self, window, terminal): self.window = window self.terminal = terminal self.window.set_size_request(640, 480) self.window.set_position(gtk.WIN_POS_CENTER) self.window.connect('delete-event', self.delete_event) colormap = self.window.get_screen().get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) self.window.add(terminal) self.childpid = self.terminal.fork_command( self.command[0], self.command, os.getcwd()) if self.childpid > 0: self.childexited = self.terminal.connect( 'child-exited', self.on_child_exited) self.window.connect('delete-event', lambda w, e: gtk.main_quit()) else: self.childexited = None spawn_later(0.5, self.show_startup_notify) self.window.show_all() logo_filename = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'goproxy-gtk.png') self.window.set_icon_from_file(logo_filename) if appindicator: self.trayicon = appindicator.Indicator( 'GoProxy', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS) self.trayicon.set_status(appindicator.STATUS_ACTIVE) self.trayicon.set_attention_icon('indicator-messages-new') self.trayicon.set_icon(logo_filename) self.trayicon.set_menu(self.make_menu()) else: self.trayicon = gtk.StatusIcon() self.trayicon.set_from_file(logo_filename) self.trayicon.connect('popup-menu', lambda i, b, t: self.make_menu().popup( None, None, gtk.status_icon_position_menu, b, t, self.trayicon)) self.trayicon.connect('activate', self.show_hide_toggle) self.trayicon.set_tooltip('GoProxy') self.trayicon.set_visible(True)
def run(animation, texture, getFrameRect, size=(200, 200), offset=(0, 0)): gtk.threads_init() gtk.threads_enter() window = gtk.Window() widget = Screen(animation, texture, getFrameRect, offset) widget.show() def on_size_allocate(wind, rect): #print("walloc") shapemap = widget.shapemap() if shapemap: window.input_shape_combine_mask(shapemap, 0, 0) #window.reset_shapes() #print("walloc with bitmap") window.connect("delete-event", gtk.main_quit) window.connect("size-allocate", on_size_allocate) window.add(widget) window.set_decorated(False) window.set_skip_taskbar_hint(True) window.set_skip_pager_hint(True) window.set_keep_above(True) window.stick() window.set_default_size(*size) #the other function doesn't work on windows #which sadly means that transparency doesn't work on windows if os.name=="nt": colormap = gtk.gdk.colormap_get_system() else: colormap = window.get_screen().get_rgba_colormap() gtk.widget_set_default_colormap(colormap) window.present() refresher = Refresher(window) refresher.start() try: gtk.main() finally: gtk.threads_leave()
def __init__(self): builder = gtk.Builder() builder.add_from_file(GLADE_FILE) signals_dict = { 'on_unlock_activate': self.on_unlock_activate, 'on_backup_activate': self.on_backup_activate, 'on_restore_activate': self.on_restore_activate, 'on_apply_activate': self.on_apply_activate, 'on_quit_activate': self.on_quit_activate, 'on_about_activate': self.on_about_activate, } builder.connect_signals(signals_dict) self.main_window = builder.get_object('main_window') colormap = self.main_window.get_screen().get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) self.main_window.show_all() self.xid = self.main_window.window.xid self.backup_action = builder.get_object('backup_action') self.restore_action = builder.get_object('restore_action') self.apply_action = builder.get_object('apply_action')
def initWindow(self): """init main Window""" window = gtk.Window() window.set_position(gtk.WIN_POS_CENTER_ALWAYS) # 设置无边框 window.set_decorated(False) window.set_resizable(False) window.set_size_request(600, 400) window.set_app_paintable(True) # 程序logo # window.set_icon_from_file(ICON + "logo.png") # 启用RGBA透明支持 screen = window.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) # 伸缩 window.set_geometry_hints(None, 600, 400) return window
def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Running Inkscape") self.window.set_decorated(0) self.window.set_default_size(1366, 768) self.window.set_events(gtk.gdk.ALL_EVENTS_MASK) # Initialize colors, alpha transparency self.window.set_app_paintable(1) self.gtk_screen = self.window.get_screen() colormap = self.gtk_screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.window.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.w, self.h = self.window.get_size() self.window.connect("expose_event", self.expose) self.window.connect("destroy", gtk.main_quit)
def __init__(self, conduitApplication, moduleManager, typeConverter, syncManager): """ Constructs the mainwindow. Throws up a splash screen to cover the most time consuming pieces """ #add some additional dirs to the icon theme search path so that #modules can provider their own icons icon_dirs = [ conduit.SHARED_DATA_DIR, conduit.SHARED_MODULE_DIR, os.path.join(conduit.SHARED_DATA_DIR,"icons"), os.path.join(conduit.USER_DIR, "modules") ] for i in icon_dirs: gtk.icon_theme_get_default().prepend_search_path(i) gtk.window_set_default_icon_name("conduit") signals = { "on_mainwindow_delete" : self.on_window_closed, "on_mainwindow_state_event" : self.on_window_state_event, "on_synchronize_activate" : self.on_synchronize_all_clicked, "on_cancel_activate" : self.on_cancel_all_clicked, "on_quit_activate" : self.on_window_closed, "on_clear_canvas_activate" : self.on_clear_canvas, "on_preferences_activate" : self.on_conduit_preferences, "on_about_activate" : self.on_about_conduit, "on_contents_activate" : self.on_help, "on_save1_activate" : self.save_settings, } self.conduitApplication = conduitApplication self.builder = _GtkBuilderWrapper(conduit.SHARED_DATA_DIR, "conduit.ui") self.builder.connect_signals(signals) #type converter and sync manager self.type_converter = typeConverter self.sync_manager = syncManager #Initialize the mainWindow self.mainWindow = self.builder.get_object("MainWindow") #Enable RGBA colormap if conduit.GLOBALS.settings.get("gui_use_rgba_colormap") == True: screen = self.mainWindow.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) self.mainWindow.set_position(gtk.WIN_POS_CENTER) title = "Conduit" if conduit.IS_DEVELOPMENT_VERSION: title = title + _(" - %s (Development Version)") % conduit.VERSION if not conduit.IS_INSTALLED: title = title + _(" - Running Uninstalled") self.mainWindow.set_title(title) #Configure canvas self.canvasSW = self.builder.get_object("canvasScrolledWindow") self.hpane = self.builder.get_object("hpaned1") #start up the canvas msg = MsgArea.MsgAreaController() self.builder.get_object("mainVbox").pack_start(msg, False, False) self.canvas = Canvas.Canvas( parentWindow=self.mainWindow, typeConverter=self.type_converter, syncManager=self.sync_manager, gtkbuilder=self.builder, msg=msg ) self.canvasSW.add(self.canvas) self.canvas.connect('drag-drop', self.drop_cb) self.canvas.connect("drag-data-received", self.drag_data_received_data) # Populate the tree model self.dataproviderTreeModel = Tree.DataProviderTreeModel() dataproviderScrolledWindow = self.builder.get_object("scrolledwindow2") self.dataproviderTreeView = Tree.DataProviderTreeView(self.dataproviderTreeModel) dataproviderScrolledWindow.add(self.dataproviderTreeView) #Set up the expander used for resolving sync conflicts self.conflictResolver = ConflictResolver.ConflictResolver(self.builder) #Preferences manager self.preferences = PreferencesWindow(self.builder) #add the preconfigured Conduit menu if conduit.GLOBALS.settings.get("gui_show_hints"): self.preconfiguredConduitsMenu = _PreconfiguredConduitMenu() self.builder.get_object("file_menu").insert(self.preconfiguredConduitsMenu.item, 3) else: self.preconfiguredConduitsMenu = None #if running a development version, add some developer specific links #to the help menu if conduit.IS_DEVELOPMENT_VERSION: helpMenu = self.builder.get_object("help_menu") developersMenuItem = gtk.ImageMenuItem(_("Developers")) developersMenuItem.set_image( gtk.image_new_from_icon_name( "applications-development", gtk.ICON_SIZE_MENU)) developersMenu = gtk.Menu() developersMenuItem.set_submenu(developersMenu) helpMenu.prepend(developersMenuItem) for name,url in DEVELOPER_WEB_LINKS: item = gtk.ImageMenuItem(_(name)) item.set_image( gtk.image_new_from_icon_name( "applications-internet", gtk.ICON_SIZE_MENU)) item.connect("activate",self.on_developer_menu_item_clicked,_(name),url) developersMenu.append(item) #final GUI setup self.cancelSyncButton = self.builder.get_object('cancel') self.hpane.set_position(conduit.GLOBALS.settings.get("gui_hpane_postion")) self.dataproviderTreeView.set_expand_rows() self.window_state = 0 log.info("Main window constructed (thread: %s)" % thread.get_ident())
def __init__(self): print "\n[ Gavin Langdon's GWINWRAP -- Keep it Simple Stupid! ]" # TODO: Add a filechooserbutton to choose a custom directory? if os.path.isdir("/usr/libexec/xscreensaver/"): self.XSSDir = "/usr/libexec/xscreensaver/" elif os.path.isdir("/usr/lib64/xscreensaver/"): self.XSSDir = "/usr/lib64/xscreensaver/" else: self.XSSDir = "/usr/lib/xscreensaver/" ### ADJUSTABLE VARIABLES -- It won't hurt to edit these a bit # The nice command self.nice = ["nice", "-n", "15"] # Pickle files self.pickle = ["presets.gwrp", "prefs.gwrp"] # Startup items directory self.startupDir = "/.config/autostart/" ### END AJUSTABLE VARIABLES ### print " * Loading Presets..." self.settingLists = self.ReadFromDisk() self.PrefCommand = self.ReadFromDisk("preferences") # Set the Glade file print " * Setting up GUI..." self.gladefile = "gwinwrap.glade" self.gladeXML = gtk.glade.XML(self.gladefile) # Initialize some program variables self.PreviewShowing = False self.selectedSaver = "" self.selectedEffect = "" self.MakingNew = False self.CancelPressed = False self.PresetSelectionProcess = False self.ScreenSavers = [] self.OldName = "" self.MovieFile = "" # Create our dictionary and connect it dic = { "on_Main_destroy": self.Quit, "on_Close_clicked": self.Quit, "on_Apply_clicked": self.Apply, "on_Refresh_clicked": self.Refresh, "on_SaverList_cursor_changed": self.SaverListSelect, "on_EffectsList_cursor_changed": self.EffectsListSelect, "on_Stop_clicked": self.Stop, "on_Speed_value_changed": self.OptionChange, "on_Opacity_value_changed": self.OptionChange, "on_CPUPriority_toggled": self.OptionChange, "on_SpeedCheckBox_toggled": self.OptionChange, "on_ArgLabel_changed": self.OptionChange, "on_Loop_toggled": self.OptionChange, "on_Sound_toggled": self.OptionChange, "on_XscreensaverClose_clicked": self.Quit, "on_XwinwrapClose_clicked": self.Quit, "on_Remove_clicked": self.Remove, "on_RemoveConfirm_response": self.RemoveConfirmResponse, "on_New_clicked": self.PaneChange, "on_Edit_clicked": self.PaneChange, "on_CancelEdit_clicked": self.PaneChange, "on_SaveEdit_clicked": self.PaneChange, "on_Add_clicked": self.PaneChange, "on_EffectName_changed": self.EffectSaveableCheck, "on_EffectDescr_changed": self.EffectSaveableCheck, "on_MovieRadio_toggled": self.MovieRadioToggled, "on_SSRadio_toggled": self.SaverRadioToggled, "on_Preferences_clicked": self.PrefPane, "on_ClosePrefs_clicked": self.PrefPane, "on_StartupCombo_changed": self.CheckStartupBox } self.gladeXML.signal_autoconnect(dic) # Get the widgets we need # > Explanation for those who don't understand glade: # This is assigning the xml stuff that the program Glade creates # to memory so that the program can interact with it. The string names # come from the widget's name defined in Glade. self.Main = self.gladeXML.get_widget("Main") self.SpeedCheckBox = self.gladeXML.get_widget("SpeedCheckBox") self.Speed = self.gladeXML.get_widget("Speed") self.Opacity = self.gladeXML.get_widget("Opacity") self.Stop = self.gladeXML.get_widget("Stop") self.Apply = self.gladeXML.get_widget("Apply") self.Refresh = self.gladeXML.get_widget("Refresh") self.SpeedHBox = self.gladeXML.get_widget("SpeedHBox") self.WelcomeBox = self.gladeXML.get_widget("WelcomeBox") self.Preview = self.gladeXML.get_widget("Preview") self.NoXscreensavers = self.gladeXML.get_widget("NoXscreensavers") self.NoXwinwrap = self.gladeXML.get_widget("NoXwinwrap") self.SaverList = self.gladeXML.get_widget("SaverList") self.Preview = self.gladeXML.get_widget("Preview") self.ArgLabel = self.gladeXML.get_widget("ArgLabel") self.CPUPriority = self.gladeXML.get_widget("CPUPriority") self.RemoveConfirm = self.gladeXML.get_widget("RemoveConfirm") self.CustomFrame = self.gladeXML.get_widget("CustomFrame") self.EditFrame = self.gladeXML.get_widget("EditFrame") self.SSRadio = self.gladeXML.get_widget("SSRadio") self.MovieHBox = self.gladeXML.get_widget("MovieHBox") self.MovieRadio = self.gladeXML.get_widget("MovieRadio") self.SaveEdit = self.gladeXML.get_widget("SaveEdit") self.Add = self.gladeXML.get_widget("Add") self.New = self.gladeXML.get_widget("New") self.CancelEdit = self.gladeXML.get_widget("CancelEdit") self.EffectsList = self.gladeXML.get_widget("EffectsList") self.EffectName = self.gladeXML.get_widget("EffectName") self.NewHelpBox = self.gladeXML.get_widget("NewHelpBox") self.Remove = self.gladeXML.get_widget("Remove") self.EffectDescr = self.gladeXML.get_widget("EffectDescr") self.Edit = self.gladeXML.get_widget("Edit") self.DuplicateWarning = self.gladeXML.get_widget("DuplicateWarning") self.Prefs = self.gladeXML.get_widget("Prefs") self.Preferences = self.gladeXML.get_widget("Preferences") self.noinput = self.gladeXML.get_widget("noinput") self.nofocus = self.gladeXML.get_widget("nofocus") self.sticky = self.gladeXML.get_widget("sticky") self.fullscreen = self.gladeXML.get_widget("fullscreen") self.skiptaskbar = self.gladeXML.get_widget("skiptaskbar") self.skippager = self.gladeXML.get_widget("skippager") self.above = self.gladeXML.get_widget("above") self.below = self.gladeXML.get_widget("below") self.overrideredirect = self.gladeXML.get_widget("overrideredirect") self.InfoName = self.gladeXML.get_widget("InfoName") self.InfoDescr = self.gladeXML.get_widget("InfoDescr") self.InfoSet = self.gladeXML.get_widget("InfoSet") self.MovieOptionsHBox = self.gladeXML.get_widget("MovieOptionsHBox") self.Loop = self.gladeXML.get_widget("Loop") self.Sound = self.gladeXML.get_widget("Sound") self.StartupCombo = self.gladeXML.get_widget("StartupCombo") self.StartupCheckBox = self.gladeXML.get_widget("StartupCheckBox") # Check for Xwinwrap print " * Checking for Xwinwrap and MPlayer..." if not self.is_installed("xwinwrap"): self.NoXwinwrap.show() print " ** You don't have Xwinwrap installed!" else: self.ShantzCheck() if not self.is_installed("mplayer"): self.MovieHBox.set_sensitive(False) print " ** Disabling video support -- you don't have mplayer installed" # Enable RGBA colormap # > This is so that we have transparent windows. We need to check so we don't # crash if the theme doesn't support it. self.gtk_screen = self.Main.get_screen() self.rgbcolormap = self.gtk_screen.get_rgb_colormap() self.colormap = self.gtk_screen.get_rgba_colormap() if self.colormap == None: self.colormap = self.rgbcolormap gtk.widget_set_default_colormap(self.colormap) print " * Loading global preferences..." self.PrefButtonID = { self.noinput: "-ni", self.nofocus: "-nf", self.sticky: "-s", self.fullscreen: "-fs", self.skiptaskbar: "-st", self.skippager: "-sp", self.above: "-a", self.below: "-b", self.overrideredirect: "-ov" } self.InitializeChoosers() # Enable stopping the already running xwinwrap process if self.xwinwrap_running(): self.Stop.set_sensitive(True) if startOptions.options.stop: self.KillAll() if not startOptions.args and not startOptions.options.window: quit() if startOptions.options.stop == True and not startOptions.args and not startOptions.options.window: print " * No need to stop anything, nothing's running.\n" quit() self.SetUpTreeView("effects") self.SetUpTreeView("screensavers") self.StartupCombo.set_model(self.EffectListstore) self.startupeffect = self.DesktopEntry() self.UpdateStartup() # Express Mode # > This is used to start the effect without the window opening (used for startup command, etc). if startOptions.args: if startOptions.args[0] in self.EffectNameList(): print " * GWINWRAP ** Express mode enabled, launching preset \"%s\" now." % startOptions.args[ 0] nameindex = self.EffectNameList(startOptions.args[0]) self.EffectsListSelection.select_path(nameindex) self.PresetSelectionProcess = True self.SetSettings(startOptions.args[0]) if self.MovieRadio.get_active(): self.ComposeCommand("movie", express=True) else: self.ComposeCommand("xscreensaver", express=True) self.ApplyEffect() else: print " * GWINWRAP ** ERROR: The chosen preset \"%s\" does not exist." % startOptions.args[ 0] if not startOptions.options.window: quit() self.SetPrefCheckBoxes() print " * Showing Main window..." self.Main.show()
gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon48), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon64), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon128)) # Create the GUI wtree = loadGladeFile('MainWindow.ui') window = wtree.get_object('win-main') prefs.setWidgetsTree(wtree) # RGBA support try: colormap = window.get_screen().get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) except: log.logger.info('No RGBA support (requires PyGTK 2.10+)') # This object takes care of the window (mainly event handlers) mainWindow.MainWindow(wtree, window) def delayedStartup(): """ Perform all the initialization stuff that is not mandatory to display the window This function should be called within the GTK main loop, once the window has been displayed """ import atexit, dbus.mainloop.glib, modules, signal def atExit():
def __init__(self, conduitApplication, moduleManager, typeConverter, syncManager): """ Constructs the mainwindow. Throws up a splash screen to cover the most time consuming pieces """ #add some additional dirs to the icon theme search path so that #modules can provider their own icons icon_dirs = [ conduit.SHARED_DATA_DIR, conduit.SHARED_MODULE_DIR, os.path.join(conduit.SHARED_DATA_DIR, "icons"), os.path.join(conduit.USER_DIR, "modules") ] for i in icon_dirs: gtk.icon_theme_get_default().prepend_search_path(i) gtk.window_set_default_icon_name("conduit") signals = { "on_mainwindow_delete": self.on_window_closed, "on_mainwindow_state_event": self.on_window_state_event, "on_synchronize_activate": self.on_synchronize_all_clicked, "on_cancel_activate": self.on_cancel_all_clicked, "on_quit_activate": self.on_window_closed, "on_clear_canvas_activate": self.on_clear_canvas, "on_preferences_activate": self.on_conduit_preferences, "on_about_activate": self.on_about_conduit, "on_contents_activate": self.on_help, "on_save1_activate": self.save_settings, } self.conduitApplication = conduitApplication self.builder = _GtkBuilderWrapper(conduit.SHARED_DATA_DIR, "conduit.ui") self.builder.connect_signals(signals) #type converter and sync manager self.type_converter = typeConverter self.sync_manager = syncManager #Initialize the mainWindow self.mainWindow = self.builder.get_object("MainWindow") #Enable RGBA colormap if conduit.GLOBALS.settings.get("gui_use_rgba_colormap") == True: screen = self.mainWindow.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) self.mainWindow.set_position(gtk.WIN_POS_CENTER) title = "Conduit" if conduit.IS_DEVELOPMENT_VERSION: title = title + _(" - %s (Development Version)") % conduit.VERSION if not conduit.IS_INSTALLED: title = title + _(" - Running Uninstalled") self.mainWindow.set_title(title) #Configure canvas self.canvasSW = self.builder.get_object("canvasScrolledWindow") self.hpane = self.builder.get_object("hpaned1") #start up the canvas msg = MsgArea.MsgAreaController() self.builder.get_object("mainVbox").pack_start(msg, False, False) self.canvas = Canvas.Canvas(parentWindow=self.mainWindow, typeConverter=self.type_converter, syncManager=self.sync_manager, gtkbuilder=self.builder, msg=msg) self.canvasSW.add(self.canvas) self.canvas.connect('drag-drop', self.drop_cb) self.canvas.connect("drag-data-received", self.drag_data_received_data) # Populate the tree model self.dataproviderTreeModel = Tree.DataProviderTreeModel() dataproviderScrolledWindow = self.builder.get_object("scrolledwindow2") self.dataproviderTreeView = Tree.DataProviderTreeView( self.dataproviderTreeModel) dataproviderScrolledWindow.add(self.dataproviderTreeView) #Set up the expander used for resolving sync conflicts self.conflictResolver = ConflictResolver.ConflictResolver(self.builder) #Preferences manager self.preferences = PreferencesWindow(self.builder) #add the preconfigured Conduit menu if conduit.GLOBALS.settings.get("gui_show_hints"): self.preconfiguredConduitsMenu = _PreconfiguredConduitMenu() self.builder.get_object("file_menu").insert( self.preconfiguredConduitsMenu.item, 3) else: self.preconfiguredConduitsMenu = None #if running a development version, add some developer specific links #to the help menu if conduit.IS_DEVELOPMENT_VERSION: helpMenu = self.builder.get_object("help_menu") developersMenuItem = gtk.ImageMenuItem(_("Developers")) developersMenuItem.set_image( gtk.image_new_from_icon_name("applications-development", gtk.ICON_SIZE_MENU)) developersMenu = gtk.Menu() developersMenuItem.set_submenu(developersMenu) helpMenu.prepend(developersMenuItem) for name, url in DEVELOPER_WEB_LINKS: item = gtk.ImageMenuItem(_(name)) item.set_image( gtk.image_new_from_icon_name("applications-internet", gtk.ICON_SIZE_MENU)) item.connect("activate", self.on_developer_menu_item_clicked, _(name), url) developersMenu.append(item) #final GUI setup self.cancelSyncButton = self.builder.get_object('cancel') self.hpane.set_position( conduit.GLOBALS.settings.get("gui_hpane_postion")) self.dataproviderTreeView.set_expand_rows() self.window_state = 0 log.info("Main window constructed (thread: %s)" % thread.get_ident())
def enable_rgba(widget, old_screen=None): screen = widget.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap)
def __set_rgba(self): screen = self.__window.get_screen() colormap = screen.get_rgba_colormap() from gtk import widget_set_default_colormap if colormap: widget_set_default_colormap(colormap) return False
def __init__(self): super(logout, self).__init__() self.set_decorated(0) self.set_skip_taskbar_hint(1) self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) self.set_keep_above(True) self.activate_focus() self.set_position(gtk.WIN_POS_CENTER) self.set_default_size(300, 70) self.set_border_width(5) self.connect("key-press-event", self.keyPress) self.connect("expose-event", self.expose) self.set_app_paintable(1) self.screen = self.get_screen() colormap = self.screen.get_rgba_colormap() if colormap == None: colormap = self.gtk_screen.get_rgb_colormap() gtk.widget_set_default_colormap(colormap) if not self.is_composited(): self.supports_alpha = False else: self.supports_alpha = True self.set_colormap(colormap) keys = ['Logout','Reboot','Shutdown','Suspend','Hibernate','Cancel'] currentdir = os.path.dirname(__file__) + os.sep + 'icons' topbox = gtk.VBox(False, 5) mainbox = gtk.HBox(False, 20) header = gtk.Label() header.set_use_markup(1) header.set_markup("<span foreground='#c9c9c9' size='xx-large'>Logout Options</span>") header.show() topbox.add(header) for key in keys: ebox = gtk.EventBox() ebox.set_app_paintable(1) ebox.connect("expose-event", self.expose) ebox.show() box = gtk.VBox() image = gtk.Image() image.set_from_file("%s/%s.png" % (currentdir, key)) label = gtk.Label() label.set_use_markup(True) label.set_markup("<span foreground='#c9c9c9' size='x-large'>%s</span>" % (key)) image.show() label.show() box.add(image) box.add(label) box.show() ebox.add(box) ebox.connect("button_press_event", self.action, key) mainbox.add(ebox) mainbox.show() topbox.add(mainbox) topbox.show() self.add(topbox)
alpha += 0.05; if alpha <= 1.0: gobject.timeout_add(20, fade_window, data); return False; # init window splash = gtk.Window(gtk.WINDOW_TOPLEVEL) # enable RGBA colormap for opacity screen = splash.get_screen() colormap = screen.get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) # Set width and height splash.set_size_request (595, 218) # Set window hint spashscreen splash.set_type_hint (gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN) # Set window centered splash.set_position (gtk.WIN_POS_CENTER) # Set window above the others splash.set_keep_above (True) # _I_ draw the window splash.set_app_paintable(True) # Draw window splash.realize() # Set null background splash.window.set_back_pixmap(None, False)
def main(): # Command line optparser = optparse.OptionParser(usage='Usage: %prog [options] [FILE(s)]') optparser.add_option('-p', '--playbin', action='store_true', default=False, help='use the playbin GStreamer component instead of playbin2') optparser.add_option('--multiple-instances', action='store_true', default=False, help='start a new instance even if one is already running') optparser.add_option('--no-glossy-cover', action='store_true', default=False, help='disable the gloss effect applied to covers') optparser.add_option('--volume-button', action='store_true', default=False, help='always show the volume button') (optOptions, optArgs) = optparser.parse_args() # Check whether DAP is already running? if not optOptions.multiple_instances: shouldStop = False dbusSession = None try: dbusSession = dbus.SessionBus() activeServices = dbusSession.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus').ListNames() if consts.dbusService in activeServices: shouldStop = True # Raise the window of the already running instance dbus.Interface(dbusSession.get_object(consts.dbusService, '/'), consts.dbusInterface).RaiseWindow() # Fill the current instance with the given tracks, if any if len(optArgs) != 0: dbus.Interface(dbusSession.get_object(consts.dbusService, '/TrackList'), consts.dbusInterface).SetTracks(optArgs, True) except: pass if dbusSession is not None: dbusSession.close() if shouldStop: sys.exit(1) log.logger.info('Started') prefs.setCmdLine((optOptions, optArgs)) # Localization locale.setlocale(locale.LC_ALL, '') gettext.textdomain(consts.appNameShort) gettext.bindtextdomain(consts.appNameShort, consts.dirLocale) # PyGTK initialization gobject.threads_init() gtk.window_set_default_icon_list( gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon16), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon24), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon32), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon48), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon64), gtk.gdk.pixbuf_new_from_file(consts.fileImgIcon128)) # Create the GUI wtree = loadGladeFile('MainWindow.ui') window = wtree.get_object('win-main') prefs.setWidgetsTree(wtree) # RGBA support try: colormap = window.get_screen().get_rgba_colormap() if colormap: gtk.widget_set_default_colormap(colormap) except: log.logger.info('No RGBA support (requires PyGTK 2.10+)') # This object takes care of the window (mainly event handlers) mainWindow.MainWindow(wtree, window) def delayedStartup(): """ Perform all the initialization stuff that is not mandatory to display the window This function should be called within the GTK main loop, once the window has been displayed """ import atexit, dbus.mainloop.glib, signal from . import modules def atExit(): """ Final function, called just before exiting the Python interpreter """ prefs.save() log.logger.info('Stopped') def onInterrupt(window): """ Handler for interrupt signals e.g., Ctrl-C """ window.hide() modules.postQuitMsg() # D-Bus dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) # Register a few handlers atexit.register(atExit) signal.signal(signal.SIGINT, lambda sig, frame: onInterrupt(window)) signal.signal(signal.SIGTERM, lambda sig, frame: onInterrupt(window)) # Now we can start all modules gobject.idle_add(modules.postMsg, consts.MSG_EVT_APP_STARTED) # Immediately show the preferences the first time the application is started if prefs.get(__name__, 'first-time', True): prefs.set(__name__, 'first-time', False) gobject.idle_add(modules.showPreferences) # Let's go gobject.idle_add(delayedStartup) gtk.main()
def __init__(self): print "\n[ Gavin Langdon's GWINWRAP -- Keep it Simple Stupid! ]" # TODO: Add a filechooserbutton to choose a custom directory? if os.path.isdir("/usr/libexec/xscreensaver/"): self.XSSDir = "/usr/libexec/xscreensaver/" elif os.path.isdir("/usr/lib64/xscreensaver/"): self.XSSDir = "/usr/lib64/xscreensaver/" else: self.XSSDir = "/usr/lib/xscreensaver/" ### ADJUSTABLE VARIABLES -- It won't hurt to edit these a bit # The nice command self.nice = ["nice","-n","15"] # Pickle files self.pickle = ["presets.gwrp","prefs.gwrp"] # Startup items directory self.startupDir = "/.config/autostart/" ### END AJUSTABLE VARIABLES ### print " * Loading Presets..." self.settingLists = self.ReadFromDisk() self.PrefCommand = self.ReadFromDisk("preferences") # Set the Glade file print " * Setting up GUI..." self.gladefile = "gwinwrap.glade" self.gladeXML = gtk.glade.XML(self.gladefile) # Initialize some program variables self.PreviewShowing = False self.selectedSaver = "" self.selectedEffect = "" self.MakingNew = False self.CancelPressed = False self.PresetSelectionProcess = False self.ScreenSavers = [] self.OldName = "" self.MovieFile = "" # Create our dictionary and connect it dic = {"on_Main_destroy" : self.Quit , "on_Close_clicked" : self.Quit , "on_Apply_clicked" : self.Apply , "on_Refresh_clicked" : self.Refresh , "on_SaverList_cursor_changed" : self.SaverListSelect , "on_EffectsList_cursor_changed" : self.EffectsListSelect , "on_Stop_clicked" : self.Stop , "on_Speed_value_changed" : self.OptionChange , "on_Opacity_value_changed" : self.OptionChange , "on_CPUPriority_toggled" : self.OptionChange , "on_SpeedCheckBox_toggled" : self.OptionChange , "on_ArgLabel_changed" : self.OptionChange , "on_Loop_toggled" : self.OptionChange , "on_Sound_toggled" : self.OptionChange , "on_XscreensaverClose_clicked" : self.Quit , "on_XwinwrapClose_clicked" : self.Quit , "on_Remove_clicked" : self.Remove , "on_RemoveConfirm_response" : self.RemoveConfirmResponse , "on_New_clicked" : self.PaneChange , "on_Edit_clicked" : self.PaneChange , "on_CancelEdit_clicked" : self.PaneChange , "on_SaveEdit_clicked" : self.PaneChange , "on_Add_clicked" : self.PaneChange , "on_EffectName_changed" : self.EffectSaveableCheck , "on_EffectDescr_changed" : self.EffectSaveableCheck , "on_MovieRadio_toggled" : self.MovieRadioToggled , "on_SSRadio_toggled" : self.SaverRadioToggled , "on_Preferences_clicked" : self.PrefPane , "on_ClosePrefs_clicked" : self.PrefPane , "on_StartupCombo_changed" : self.CheckStartupBox } self.gladeXML.signal_autoconnect(dic) # Get the widgets we need # > Explanation for those who don't understand glade: # This is assigning the xml stuff that the program Glade creates # to memory so that the program can interact with it. The string names # come from the widget's name defined in Glade. self.Main = self.gladeXML.get_widget("Main") self.SpeedCheckBox = self.gladeXML.get_widget("SpeedCheckBox") self.Speed = self.gladeXML.get_widget("Speed") self.Opacity = self.gladeXML.get_widget("Opacity") self.Stop = self.gladeXML.get_widget("Stop") self.Apply = self.gladeXML.get_widget("Apply") self.Refresh = self.gladeXML.get_widget("Refresh") self.SpeedHBox = self.gladeXML.get_widget("SpeedHBox") self.WelcomeBox = self.gladeXML.get_widget("WelcomeBox") self.Preview = self.gladeXML.get_widget("Preview") self.NoXscreensavers = self.gladeXML.get_widget("NoXscreensavers") self.NoXwinwrap = self.gladeXML.get_widget("NoXwinwrap") self.SaverList = self.gladeXML.get_widget("SaverList") self.Preview = self.gladeXML.get_widget("Preview") self.ArgLabel = self.gladeXML.get_widget("ArgLabel") self.CPUPriority = self.gladeXML.get_widget("CPUPriority") self.RemoveConfirm = self.gladeXML.get_widget("RemoveConfirm") self.CustomFrame = self.gladeXML.get_widget("CustomFrame") self.EditFrame = self.gladeXML.get_widget("EditFrame") self.SSRadio = self.gladeXML.get_widget("SSRadio") self.MovieHBox = self.gladeXML.get_widget("MovieHBox") self.MovieRadio = self.gladeXML.get_widget("MovieRadio") self.SaveEdit = self.gladeXML.get_widget("SaveEdit") self.Add = self.gladeXML.get_widget("Add") self.New = self.gladeXML.get_widget("New") self.CancelEdit = self.gladeXML.get_widget("CancelEdit") self.EffectsList = self.gladeXML.get_widget("EffectsList") self.EffectName = self.gladeXML.get_widget("EffectName") self.NewHelpBox = self.gladeXML.get_widget("NewHelpBox") self.Remove = self.gladeXML.get_widget("Remove") self.EffectDescr = self.gladeXML.get_widget("EffectDescr") self.Edit = self.gladeXML.get_widget("Edit") self.DuplicateWarning = self.gladeXML.get_widget("DuplicateWarning") self.Prefs = self.gladeXML.get_widget("Prefs") self.Preferences = self.gladeXML.get_widget("Preferences") self.noinput = self.gladeXML.get_widget("noinput") self.nofocus = self.gladeXML.get_widget("nofocus") self.sticky = self.gladeXML.get_widget("sticky") self.fullscreen = self.gladeXML.get_widget("fullscreen") self.skiptaskbar = self.gladeXML.get_widget("skiptaskbar") self.skippager = self.gladeXML.get_widget("skippager") self.above = self.gladeXML.get_widget("above") self.below = self.gladeXML.get_widget("below") self.overrideredirect = self.gladeXML.get_widget("overrideredirect") self.InfoName = self.gladeXML.get_widget("InfoName") self.InfoDescr = self.gladeXML.get_widget("InfoDescr") self.InfoSet = self.gladeXML.get_widget("InfoSet") self.MovieOptionsHBox = self.gladeXML.get_widget("MovieOptionsHBox") self.Loop = self.gladeXML.get_widget("Loop") self.Sound = self.gladeXML.get_widget("Sound") self.StartupCombo = self.gladeXML.get_widget("StartupCombo") self.StartupCheckBox = self.gladeXML.get_widget("StartupCheckBox") # Check for Xwinwrap print " * Checking for Xwinwrap and MPlayer..." if not self.is_installed("xwinwrap"): self.NoXwinwrap.show() print " ** You don't have Xwinwrap installed!" else: self.ShantzCheck() if not self.is_installed("mplayer"): self.MovieHBox.set_sensitive(False) print " ** Disabling video support -- you don't have mplayer installed" # Enable RGBA colormap # > This is so that we have transparent windows. We need to check so we don't # crash if the theme doesn't support it. self.gtk_screen = self.Main.get_screen() self.rgbcolormap = self.gtk_screen.get_rgb_colormap() self.colormap = self.gtk_screen.get_rgba_colormap() if self.colormap == None: self.colormap = self.rgbcolormap gtk.widget_set_default_colormap(self.colormap) print " * Loading global preferences..." self.PrefButtonID = {self.noinput:"-ni",self.nofocus:"-nf",self.sticky:"-s", self.fullscreen:"-fs",self.skiptaskbar:"-st", self.skippager:"-sp",self.above:"-a",self.below:"-b", self.overrideredirect:"-ov" } self.InitializeChoosers() # Enable stopping the already running xwinwrap process if self.xwinwrap_running(): self.Stop.set_sensitive(True) if startOptions.options.stop: self.KillAll() if not startOptions.args and not startOptions.options.window: quit() if startOptions.options.stop == True and not startOptions.args and not startOptions.options.window: print " * No need to stop anything, nothing's running.\n" quit() self.SetUpTreeView("effects") self.SetUpTreeView("screensavers") self.StartupCombo.set_model(self.EffectListstore) self.startupeffect = self.DesktopEntry() self.UpdateStartup() # Express Mode # > This is used to start the effect without the window opening (used for startup command, etc). if startOptions.args: if startOptions.args[0] in self.EffectNameList(): print " * GWINWRAP ** Express mode enabled, launching preset \"%s\" now."%startOptions.args[0] nameindex = self.EffectNameList(startOptions.args[0]) self.EffectsListSelection.select_path(nameindex) self.PresetSelectionProcess = True self.SetSettings(startOptions.args[0]) if self.MovieRadio.get_active(): self.ComposeCommand("movie",express=True) else: self.ComposeCommand("xscreensaver",express=True) self.ApplyEffect() else: print " * GWINWRAP ** ERROR: The chosen preset \"%s\" does not exist." %startOptions.args[0] if not startOptions.options.window: quit() self.SetPrefCheckBoxes() print " * Showing Main window..." self.Main.show()