def _setup_ui_dialogs(self): # This needs to be here otherwise we can't install the dialog if 'STOQ_TEST_MODE' in os.environ: return log.debug('providing graphical notification dialogs') from stoqlib.gui.base.dialogs import DialogSystemNotifier from stoqlib.lib.interfaces import ISystemNotifier from kiwi.component import provide_utility provide_utility(ISystemNotifier, DialogSystemNotifier(), replace=True) import gtk from kiwi.environ import environ from kiwi.ui.pixbufutils import pixbuf_from_string data = environ.get_resource_string( 'stoq', 'pixmaps', 'stoq-stock-app-24x24.png') gtk.window_set_default_icon(pixbuf_from_string(data)) if platform.system() == 'Darwin': from AppKit import NSApplication, NSData, NSImage bytes = environ.get_resource_string( 'stoq', 'pixmaps', 'stoq-stock-app-48x48.png') data = NSData.alloc().initWithBytes_length_(bytes, len(bytes)) icon = NSImage.alloc().initWithData_(data) app = NSApplication.sharedApplication() app.setApplicationIconImage_(icon)
def __init__(self, option, logging): # id, icon_name, category, icon_theme_path self.indicator = appindicator.Indicator( 'WallpaperOptimzier', "wallopt_off", appindicator.CATEGORY_APPLICATION_STATUS, WallpaperOptimizer.ICONDIR) self.option = option self.logging = logging # Initialize Status self.timeoutObject = None self.bVisible = True self.bCanceled = True self.bEntryPath = [False, False] # Initialize AppIndicator self._loadIcon() self.indicator.set_status(appindicator.STATUS_ACTIVE) self._create_menu() self.indicator.set_menu(self.indicatormenu) gtk.window_set_default_icon(self._select_icon(self.bCanceled)) self.indicator.set_icon('wallopt') # optionInitialize self.option.opts.window = True self.option.args = ['', ''] self.core = Core(self.option) # Initialize Applet self._initializeWindow()
def __init__(self, cb_on_close, height=410, width=250, posx=100, posy=100): gtk.Window.__init__(self) self.set_location(width, height, posx, posy) self.set_title("emesene") image_theme = gui.theme.image_theme try: gtk.window_set_default_icon_list( utils.safe_gtk_image_load(image_theme.logo16).get_pixbuf(), utils.safe_gtk_image_load(image_theme.logo32).get_pixbuf(), utils.safe_gtk_image_load(image_theme.logo48).get_pixbuf(), utils.safe_gtk_image_load(image_theme.logo96).get_pixbuf()) except: gtk.window_set_default_icon( utils.safe_gtk_image_load(image_theme.logo).get_pixbuf()) self.cb_on_close = cb_on_close self.cb_on_quit = cb_on_close self._state = 0 self.connect('delete-event', self._on_delete_event) self.connect('key-press-event', self._on_key_press) self.connect('window-state-event', self._on_window_state_event) self.content = None self.content_type = 'empty'
def _setup_ui_dialogs(self): # This needs to be here otherwise we can't install the dialog if 'STOQ_TEST_MODE' in os.environ: return log.debug('providing graphical notification dialogs') from stoqlib.gui.base.dialogs import DialogSystemNotifier from stoqlib.lib.interfaces import ISystemNotifier from kiwi.component import provide_utility provide_utility(ISystemNotifier, DialogSystemNotifier(), replace=True) import gtk from kiwi.environ import environ from kiwi.ui.pixbufutils import pixbuf_from_string data = environ.get_resource_string('stoq', 'pixmaps', 'stoq-stock-app-24x24.png') gtk.window_set_default_icon(pixbuf_from_string(data)) if platform.system() == 'Darwin': from AppKit import NSApplication, NSData, NSImage bytes = environ.get_resource_string('stoq', 'pixmaps', 'stoq-stock-app-48x48.png') data = NSData.alloc().initWithBytes_length_(bytes, len(bytes)) icon = NSImage.alloc().initWithData_(data) app = NSApplication.sharedApplication() app.setApplicationIconImage_(icon)
def set_icon(self, icon_path): ''' Set the icon of the application. This icon is used by the window manager or the dock. @param icon_path: The path of application icon. ''' gtk.window_set_default_icon(gtk.gdk.pixbuf_new_from_file(icon_path))
def set_icon(self, icon_dpixbuf): """ Set the icon of the application. This icon is used by the window manager or the dock. @param icon_dpixbuf: The icon pixbuf of dtk.ui.theme.DynamicPixbuf. """ gtk.window_set_default_icon(icon_dpixbuf.get_pixbuf())
def run(): """Start the application""" gtk.window_set_default_icon(MainWindow.logo) w = MainWindow() MainWindow.instance = w for child in w.get_children(): w.show_all() w.maximize() w.show() gtk.main()
def __init__(self): SimpleGladeApp.__init__(self, os.path.dirname(__file__) + "/ui.glade") store = FavoritesStore() self.wxIconView.set_model(store) self.wxIconView.set_text_column(1) self.wxIconView.set_pixbuf_column(0) gtk.window_set_default_icon(load_icon(WINDOW_ICON))
def load_icons(): _icons = (('gimp-flip-horizontal.png', 'comix-flip-horizontal'), ('gimp-flip-vertical.png', 'comix-flip-vertical'), ('gimp-rotate-180.png', 'comix-rotate-180'), ('gimp-rotate-270.png', 'comix-rotate-270'), ('gimp-rotate-90.png', 'comix-rotate-90'), ('gimp-thumbnails.png', 'comix-thumbnails'), ('gimp-transform.png', 'comix-transform'), ('tango-enhance-image.png', 'comix-enhance-image'), ('tango-add-bookmark.png', 'comix-add-bookmark'), ('tango-archive.png', 'comix-archive'), ('tango-image.png', 'comix-image'), ('library.png', 'comix-library'), ('comments.png', 'comix-comments'), ('zoom.png', 'comix-zoom'), ('lens.png', 'comix-lens'), ('double-page.png', 'comix-double-page'), ('manga.png', 'comix-manga'), ('fitbest.png', 'comix-fitbest'), ('fitwidth.png', 'comix-fitwidth'), ('fitheight.png', 'comix-fitheight'), ('fitmanual.png', 'comix-fitmanual')) icon_path = None # Some heuristics to find the path to the icon image files. base = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) # Try source directory. if os.path.isfile(os.path.join(base, 'images/16x16/comix.png')): icon_path = os.path.join(base, 'images') else: # Try system directories. for prefix in [base, '/usr', '/usr/local', '/usr/X11R6']: if os.path.isfile( os.path.join( prefix, 'share/comix/images/16x16/comix.png')): # Try one icon_path = os.path.join(prefix, 'share/comix/images') break if icon_path is None: return # Load window title icon. pixbuf = gtk.gdk.pixbuf_new_from_file( os.path.join(icon_path, '16x16/comix.png')) gtk.window_set_default_icon(pixbuf) # Load application icons. factory = gtk.IconFactory() for filename, stockid in _icons: try: filename = os.path.join(icon_path, filename) pixbuf = gtk.gdk.pixbuf_new_from_file(filename) iconset = gtk.IconSet(pixbuf) factory.add(stockid, iconset) except Exception: print('! Could not load icon "{}".'.format(filename)) factory.add_default()
def __init__(self, applet, iid): self.applet = applet self.gconf = EasyGConf("/apps/mintMenu/") self.gconf.notifyAdd("applet_text", self.gconfEntriesChanged) self.gconf.notifyAdd("theme_name", self.changeTheme) self.gconf.notifyAdd("hot_key", self.gconfEntriesChanged) self.gconf.notifyAdd("applet_icon", self.gconfEntriesChanged) self.gconf.notifyAdd("hide_applet_icon", self.gconfEntriesChanged) self.gconf.notifyAdd("applet_icon_size", self.gconfEntriesChanged) self.getGconfEntries() self.gconftheme = EasyGConf("/desktop/gnome/interface/") self.gconftheme.notifyAdd("gtk_theme", self.changeTheme) self.createPanelButton() self.applet.set_applet_flags(gnomeapplet.EXPAND_MINOR) self.applet.connect("button-press-event", self.showMenu) self.applet.connect("change-orient", self.changeOrientation) self.applet.connect("change-background", self.changeBackground) self.applet.connect("enter-notify-event", self.enter_notify) self.applet.connect("leave-notify-event", self.leave_notify) self.mainwin = MainWindow(self.button_box) self.mainwin.window.connect("map-event", lambda *args: self.applet.set_state(gtk.STATE_SELECTED)) self.mainwin.window.connect("unmap-event", lambda *args: self.applet.set_state(gtk.STATE_NORMAL)) self.mainwin.window.connect("size-allocate", lambda *args: self.positionMenu()) self.mainwin.window.set_name("mintmenu") # Name used in Gtk RC files icon = iconManager.getIcon(self.mainwin.icon, 1) if icon: gtk.window_set_default_icon(icon) self.propxml = """ <popup name="button3"> <menuitem name="Item 1" verb="Preferences" label="%s" pixtype="stock" pixname="gtk-preferences" /> <menuitem name="Item 1" verb="Edit" label="%s" pixtype="stock" pixname="gtk-edit" /> <menuitem name="Item 2" verb="Reload" label="%s" pixtype="stock" pixname="gtk-refresh" /> <menuitem name="Item 3" verb="About" label="%s" pixtype="stock" pixname="gtk-about" /> </popup> """ % ( _("Preferences"), _("Edit menu"), _("Reload plugins"), _("About"), ) self.verbs = [ ("Preferences", self.showPreferences), ("Edit", self.showMenuEditor), ("About", self.showAboutDialog), ("Reload", self.mainwin.RegenPlugins), ] self.bind_hot_key()
def setup_icons(self): """ Setup the GTK+ icon theme, adding the path for FreeSpeak art. Set the default icon for all windows. """ self.icon_theme = gtk.icon_theme_get_default() self.icon_theme.append_search_path(self.icons_path) # FIXME: must take care if the application was created from another # application. window_icon = self.icon_theme.load_icon(defs.PACKAGE, 64, 0) gtk.window_set_default_icon(window_icon)
def setup_icons (self): """ Setup the GTK+ icon theme, adding the path for FreeSpeak art. Set the default icon for all windows. """ self.icon_theme = gtk.icon_theme_get_default () self.icon_theme.append_search_path (self.icons_path) # FIXME: must take care if the application was created from another # application. window_icon = self.icon_theme.load_icon (defs.PACKAGE, 64, 0) gtk.window_set_default_icon (window_icon)
def setWindowsIcon(self): """ Set the icon for the window """ icon_theme = gtk.icon_theme_get_default() try: icon = icon_theme.load_icon("mouseTrap", 48, 0) except: return gtk.window_set_default_icon(icon)
def __init__(self, applet, iid): self.applet = applet self.gconf = EasyGConf("/apps/mintMenu/") self.gconf.notifyAdd("applet_text", self.gconfEntriesChanged) self.gconf.notifyAdd("theme_name", self.changeTheme) self.gconf.notifyAdd("hot_key", self.gconfEntriesChanged) self.gconf.notifyAdd("applet_icon", self.gconfEntriesChanged) self.gconf.notifyAdd("hide_applet_icon", self.gconfEntriesChanged) self.gconf.notifyAdd("applet_icon_size", self.gconfEntriesChanged) self.getGconfEntries() self.gconftheme = EasyGConf("/desktop/gnome/interface/") self.gconftheme.notifyAdd("gtk_theme", self.changeTheme) self.createPanelButton() self.applet.set_applet_flags(gnomeapplet.EXPAND_MINOR) self.applet.connect("button-press-event", self.showMenu) self.applet.connect("change-orient", self.changeOrientation) self.applet.connect("change-background", self.changeBackground) self.applet.connect("enter-notify-event", self.enter_notify) self.applet.connect("leave-notify-event", self.leave_notify) self.mainwin = MainWindow(self.button_box) self.mainwin.window.connect( "map-event", lambda *args: self.applet.set_state(gtk.STATE_SELECTED)) self.mainwin.window.connect( "unmap-event", lambda *args: self.applet.set_state(gtk.STATE_NORMAL)) self.mainwin.window.connect("size-allocate", lambda *args: self.positionMenu()) self.mainwin.window.set_name("mintmenu") # Name used in Gtk RC files icon = iconManager.getIcon(self.mainwin.icon, 1) if icon: gtk.window_set_default_icon(icon) self.propxml = """ <popup name="button3"> <menuitem name="Item 1" verb="Preferences" label="%s" pixtype="stock" pixname="gtk-preferences" /> <menuitem name="Item 1" verb="Edit" label="%s" pixtype="stock" pixname="gtk-edit" /> <menuitem name="Item 2" verb="Reload" label="%s" pixtype="stock" pixname="gtk-refresh" /> <menuitem name="Item 3" verb="About" label="%s" pixtype="stock" pixname="gtk-about" /> </popup> """ % (_("Preferences"), _("Edit menu"), _("Reload plugins"), _("About")) self.verbs = [("Preferences", self.showPreferences), ("Edit", self.showMenuEditor), ("About", self.showAboutDialog), ("Reload", self.mainwin.RegenPlugins)] self.bind_hot_key()
def load_icons(): _icons = (('gimp-flip-horizontal.png', 'comix-flip-horizontal'), ('gimp-flip-vertical.png', 'comix-flip-vertical'), ('gimp-rotate-180.png', 'comix-rotate-180'), ('gimp-rotate-270.png', 'comix-rotate-270'), ('gimp-rotate-90.png', 'comix-rotate-90'), ('gimp-thumbnails.png', 'comix-thumbnails'), ('gimp-transform.png', 'comix-transform'), ('tango-enhance-image.png', 'comix-enhance-image'), ('tango-add-bookmark.png', 'comix-add-bookmark'), ('tango-archive.png', 'comix-archive'), ('tango-image.png', 'comix-image'), ('library.png', 'comix-library'), ('comments.png', 'comix-comments'), ('zoom.png', 'comix-zoom'), ('lens.png', 'comix-lens'), ('double-page.png', 'comix-double-page'), ('manga.png', 'comix-manga'), ('fitbest.png', 'comix-fitbest'), ('fitwidth.png', 'comix-fitwidth'), ('fitheight.png', 'comix-fitheight'), ('fitmanual.png', 'comix-fitmanual')) icon_path = None # Some heuristics to find the path to the icon image files. base = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0]))) # Try source directory. if os.path.isfile(os.path.join(base, 'images/16x16/comix.png')): icon_path = os.path.join(base, 'images') else: # Try system directories. for prefix in [base, '/usr', '/usr/local', '/usr/X11R6']: if os.path.isfile(os.path.join(prefix, 'share/comix/images/16x16/comix.png')): # Try one icon_path = os.path.join(prefix, 'share/comix/images') break if icon_path is None: return # Load window title icon. pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(icon_path, '16x16/comix.png')) gtk.window_set_default_icon(pixbuf) # Load application icons. factory = gtk.IconFactory() for filename, stockid in _icons: try: filename = os.path.join(icon_path, filename) pixbuf = gtk.gdk.pixbuf_new_from_file(filename) iconset = gtk.IconSet(pixbuf) factory.add(stockid, iconset) except Exception: print '! Could not load icon "%s".' % filename factory.add_default()
def setIcon(self): """ Try to set the application icon """ icon_theme = gtk.icon_theme_get_default() try: icon = icon_theme.load_icon("seaslug", 48, 0) except: return # Don't do anything for this exception but display the default. # We only care a little if there's no seaslugs gtk.window_set_default_icon(icon)
def main(args): gettext.textdomain("gnome-codec-install") gettext.bindtextdomain("gnome-codec-install") (requests, xid) = parse_arguments(args) try: icon = gtk.icon_theme_get_default().load_icon("gnome-codec-install", 32, 0) except: icon = None if icon: gtk.window_set_default_icon(icon) if requests == None or len(requests) == 0: sys.stderr.write("invalid commandline '%s'\n" % (args)) dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("Invalid commandline")) dlg.format_secondary_text(_("The parameters passed to the application " "had an invalid format. Please file a bug!\n\n" "The parameters were:\n%s") % ("\n".join(map(str, args)))) dlg.set_title(_("Invalid commandline")) set_transient_for_xid(dlg, xid) dlg.run() dlg.destroy() exit(INSTALL_PLUGINS_ERROR) else: dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL, _("Search for suitable plugin?")) dlg.format_secondary_text(_("The required software to play this " "file is not installed. You need to install " "suitable plugins to play " "media files. Do you want to search for a plugin " "that supports the selected file?\n\n" "The search will also include software which is not " "officially supported.")) btn = dlg.add_button(_("_Search"), gtk.RESPONSE_YES) btn.grab_focus() dlg.set_title(_("Search for suitable plugin?")) set_transient_for_xid(dlg, xid) res = dlg.run() dlg.destroy() while gtk.events_pending(): gtk.main_iteration() if res != gtk.RESPONSE_YES: exit(INSTALL_PLUGINS_USER_ABORT) import MainWindow window = MainWindow.MainWindow(requests, xid) exit(window.main())
def __init__(self): gobject.GObject.__init__(self) self._protocol = None self._tryReconnecting = False self._pingDefer = None self._chatWindows = {} reactor.addSystemEventTrigger('before', 'shutdown', self._beforeShutdown) gtk.window_set_default_icon(icons.shield) CptCommon.manager = self CptCommon.mainWindow = MainWindow() CptCommon.systray = Systray() CptCommon.mainWindow.afterSystrayInit() CptCommon.downloadManager = DownloadManager() if CptCommon.cmdline.debug: DebugWindow()
def setWindowsIcon( self ): """ Sets the icon for the preffGUI. Arguments: - self: The main object pointer. """ icon_theme = gtk.icon_theme_get_default() try: icon = icon_theme.load_icon("mouseTrap", 48, 0) except: return gtk.window_set_default_icon(icon)
def __init__(self): gtk.Window.__init__(self) self.set_title('VIM Color Picker') self.default_bg = Color('#eeeeee') self.default_fg = Color('#000000') icon = self.render_icon(gtk.STOCK_COLOR_PICKER, gtk.ICON_SIZE_MENU) self.set_icon(icon) gtk.window_set_default_icon(icon) self.set_size_request(670, -1) self.set_resizable(False) self.set_border_width(10) self.make_ui()
def main(): parser = optparse.OptionParser( usage='usage: %prog [options] [saved flow graphs]', version=VERSION_AND_DISCLAIMER_TEMPLATE % gr.version()) options, args = parser.parse_args() try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0)) except: pass platform = Platform( prefs_file=gr.prefs(), version=gr.version(), version_parts=(gr.major_version(), gr.api_version(), gr.minor_version()), install_prefix=gr.prefix() ) ActionHandler(args, platform) gtk.main()
def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window=window window.set_title(_('Screenshot')) bbox=gtk.HBox(False,0) window.add(bbox) window.connect("destroy", self.destroy) self.registerStock('cat-screenshot',_('_Screenshot'),DefaultIcon) button1=gtk.Button(stock='cat-screenshot') button2=gtk.Button(stock='gtk-cancel') bbox.pack_start(button1,True,True,0) bbox.pack_start(button2,True,True,0) button1.connect('clicked',self.start) button2.connect('clicked',self.destroy) window.set_border_width(5) window.set_position(gtk.WIN_POS_CENTER_ALWAYS) gtk.window_set_default_icon(gtk.gdk.pixbuf_new_from_xpm_data(DefaultIcon)) window.set_resizable(False) window.show_all()
def setup_window (self, window_reload): self.setLtR() if window_reload: self.window.destroy() elif flags.livecdInstall: pixbuf = getPixbuf("anaconda.png") gtk.window_set_default_icon(pixbuf) self.loadGlade() self.window = self.mainxml.get_widget("mainWindow") self.createWidgets() self.connectSignals() self.setScreen() self.window.show() # calling present() will focus the window in the winodw manager so # the mnemonics work without additional clicking self.window.present()
def setup_window(self, window_reload): self.setLtR() if window_reload: self.window.destroy() elif flags.livecdInstall: pixbuf = getPixbuf("anaconda.png") gtk.window_set_default_icon(pixbuf) self.loadGlade() self.window = self.mainxml.get_widget("mainWindow") self.createWidgets() self.connectSignals() self.setScreen() self.window.show() # calling present() will focus the window in the winodw manager so # the mnemonics work without additional clicking self.window.present()
def __init__(self): path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png') pix = gtk.gdk.pixbuf_new_from_file(path_to_file) gtk.window_set_default_icon( pix) # set the icon to all newly opened windows if not os.path.exists(LOG_DB_PATH): dialogs.ErrorDialog(_('Cannot find history logs database'), '%s does not exist.' % LOG_DB_PATH) sys.exit() xml = gtkgui_helpers.get_glade('history_manager.glade') self.window = xml.get_widget('history_manager_window') self.jids_listview = xml.get_widget('jids_listview') self.logs_listview = xml.get_widget('logs_listview') self.search_results_listview = xml.get_widget( 'search_results_listview') self.search_entry = xml.get_widget('search_entry') self.logs_scrolledwindow = xml.get_widget('logs_scrolledwindow') self.search_results_scrolledwindow = xml.get_widget( 'search_results_scrolledwindow') self.welcome_vbox = xml.get_widget('welcome_vbox') self.jids_already_in = [] # holds jids that we already have in DB self.AT_LEAST_ONE_DELETION_DONE = False self.con = sqlite.connect(LOG_DB_PATH, timeout=20.0, isolation_level='IMMEDIATE') self.cur = self.con.cursor() self._init_jids_listview() self._init_logs_listview() self._init_search_results_listview() self._fill_jids_listview() self.search_entry.grab_focus() self.window.show_all() xml.signal_autoconnect(self)
def __init__(self): # create the window window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window = window window.set_title('Lite Control Panel') window.connect("destroy", self.destroy) window.set_border_width(3) window.set_position(gtk.WIN_POS_CENTER_ALWAYS) # we make the icons it = gtk.icon_theme_get_default() gtk.window_set_default_icon( it.load_icon("gtk-preferences", 48, gtk.ICON_LOOKUP_FORCE_SVG)) window.resize(740, 400) self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, str) self.iv = gtk.IconView(self.liststore) self.iv.set_pixbuf_column(0) self.iv.set_text_column(1) self.iv.set_events(self.iv.get_events() | gtk.gdk.BUTTON_PRESS_MASK) self.iv.connect("button-press-event", self.valtamaction) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(self.iv) window.add(sw) first = True for line in zoose_icons: if first: first = False continue try: if '/' in line[1]: pixbuf = gtk.gdk.pixbuf_new_from_file(line[1]) else: pixbuf = it.load_icon(line[1], 48, gtk.ICON_LOOKUP_FORCE_SVG) except: pixbuf = it.load_icon('gtk-stop', 48, gtk.ICON_LOOKUP_FORCE_SVG) namen = (line[0]) self.liststore.append([pixbuf, namen, line[2]]) window.show_all()
def __init__(self, cb_on_close, height=410, width=250, posx=100, posy=100): gtk.Window.__init__(self) self.box = gtk.HPaned() self.box.set_can_focus(False) # HACK! a bunch of properties/methods accessed by the outside self.box.add_accel_group = self.add_accel_group self.box.set_title = self.set_title self.box.set_icon = self.set_icon self.box.set_urgency_hint = self.set_urgency_hint self.box.present = self.present self.box.is_active = self.is_active self.box.get_dimensions = self.get_dimensions self.box.is_maximized = self.is_maximized self._content_main = None self._content_conv = None self.set_location(width, height, posx, posy) self.set_title("emesene") image_theme = gui.theme.image_theme try: gtk.window_set_default_icon_list( utils.safe_gtk_image_load(image_theme.logo16).get_pixbuf(), utils.safe_gtk_image_load(image_theme.logo32).get_pixbuf(), utils.safe_gtk_image_load(image_theme.logo48).get_pixbuf(), utils.safe_gtk_image_load(image_theme.logo96).get_pixbuf()) except: gtk.window_set_default_icon( utils.safe_gtk_image_load(image_theme.logo).get_pixbuf()) self.cb_on_close = cb_on_close self.cb_on_close_conv = cb_on_close self.cb_on_quit = cb_on_close self._state = 0 self.accel_group = None self.add(self.box) self.connect('delete-event', self._on_delete_event) self.connect('window-state-event', self._on_window_state_event)
def setup_window (self, window_reload): self.setLtR() if window_reload: self.window.destroy() elif flags.livecdInstall: pixbuf = getPixbuf("anaconda.png") gtk.window_set_default_icon(pixbuf) self.loadGlade() self.window = self.mainxml.get_widget("mainWindow") self.createWidgets() self.connectSignals() # 'Back and 'Next' is disabled by default icw = InstallControlState(self) icw.setPrevEnabled(False) icw.setNextEnabled(False) self.window.show() # calling present() will focus the window in the winodw manager so # the mnemonics work without additional clicking self.window.present()
def __init__(self): # create a new window window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window=window window.set_title(_('LXDE-Control-Center')) window.connect("destroy", self.destroy) window.set_border_width(3) window.set_position(gtk.WIN_POS_CENTER_ALWAYS) it=gtk.icon_theme_get_default() gtk.window_set_default_icon(it.load_icon("gtk-preferences",48,gtk.ICON_LOOKUP_FORCE_SVG)) window.resize(800,400) self.liststore=gtk.ListStore(gtk.gdk.Pixbuf,str,str) self.iv=gtk.IconView(self.liststore) self.iv.set_pixbuf_column(0) self.iv.set_text_column(1) self.iv.set_events(self.iv.get_events() | gtk.gdk.BUTTON_PRESS_MASK) self.iv.connect("button-press-event", self.mouse) sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(self.iv) window.add(sw) first=True for line in control_center_icons: if first: first=False continue try: if '/' in line[1]: pixbuf=gtk.gdk.pixbuf_new_from_file(line[1]) else: pixbuf=it.load_icon(line[1],48,gtk.ICON_LOOKUP_FORCE_SVG) except: pixbuf=it.load_icon('gtk-stop',48,gtk.ICON_LOOKUP_FORCE_SVG) namen=(line[0]) self.liststore.append([ pixbuf,namen,line[2] ]) window.show_all()
def __init__(self): path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png') pix = gtk.gdk.pixbuf_new_from_file(path_to_file) gtk.window_set_default_icon(pix) # set the icon to all newly opened windows if not os.path.exists(LOG_DB_PATH): dialogs.ErrorDialog(_('Cannot find history logs database'), '%s does not exist.' % LOG_DB_PATH) sys.exit() xml = gtkgui_helpers.get_glade('history_manager.glade') self.window = xml.get_widget('history_manager_window') self.jids_listview = xml.get_widget('jids_listview') self.logs_listview = xml.get_widget('logs_listview') self.search_results_listview = xml.get_widget('search_results_listview') self.search_entry = xml.get_widget('search_entry') self.logs_scrolledwindow = xml.get_widget('logs_scrolledwindow') self.search_results_scrolledwindow = xml.get_widget( 'search_results_scrolledwindow') self.welcome_vbox = xml.get_widget('welcome_vbox') self.jids_already_in = [] # holds jids that we already have in DB self.AT_LEAST_ONE_DELETION_DONE = False self.con = sqlite.connect(LOG_DB_PATH, timeout = 20.0, isolation_level = 'IMMEDIATE') self.cur = self.con.cursor() self._init_jids_listview() self._init_logs_listview() self._init_search_results_listview() self._fill_jids_listview() self.search_entry.grab_focus() self.window.show_all() xml.signal_autoconnect(self)
def __init__(self, languagefrom="de", languageto="en"): gtk.StatusIcon.__init__(self) self._langfrom = languagefrom self._langto = languageto if libtranstray.is_installed(): self.set_from_icon_name(self.APP_ICON) gtk.window_set_default_icon_name(self.get_icon_name()) else: self.set_from_file("%s.svg" % self.APP_ICON) gtk.window_set_default_icon(self.get_pixbuf()) self.set_visible(True) self.connect('activate', self._on_activate) self.connect('popup-menu', self._on_popup_menu) self._create_right_menu() self._nl = NetworkListener() #monitor the selection clipboard self._clip_selection = gtk.clipboard_get("PRIMARY") pynotify.init(self.APP_NAME)
def __init__(self): # Create the temporary directory self.tmp_dir = tempfile.mkdtemp("pdfslider") os.chmod(self.tmp_dir, 0700) icon_theme = gtk.icon_theme_get_default() try: gtk.window_set_default_icon(icon_theme.load_icon("pdfslider", 64, 0)) except: print(_("Can't load icon. Application is not installed correctly.")) # Import the user interface file, trying different possible locations ui_path = '/usr/share/pdfslider/pdfslider.ui' if not os.path.exists(ui_path): ui_path = '/usr/local/share/pdfslider/pdfslider.ui' if not os.path.exists(ui_path): parent_dir = os.path.dirname( \ os.path.dirname(os.path.realpath(__file__))) ui_path = os.path.join(parent_dir, 'data', 'pdfslider.ui') if not os.path.exists(ui_path): head, tail = os.path.split(parent_dir) while tail != 'lib' and tail != '': head, tail = os.path.split(head) if tail == 'lib': ui_path = os.path.join(head, 'share', 'pdfslider', \ 'pdfslider.ui') self.uiXML = gtk.Builder() self.uiXML.add_from_file(ui_path) self.uiXML.connect_signals(self) # Create the main window, and attach delete_event signal to terminating # the application self.window = self.uiXML.get_object('main_window') self.window.set_title(APPNAME) self.window.set_border_width(0) self.window.move(self.prefs['window x'], self.prefs['window y']) self.window.set_default_size(self.prefs['window width'], self.prefs['window height']) self.window.connect('delete_event', self.close_application) # Create a scrolled window to hold the thumbnails-container self.sw = self.uiXML.get_object('scrolledwindow') self.sw.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, self.TARGETS_SW, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.sw.connect('drag_data_received', self.sw_dnd_received_data) self.sw.connect('button_press_event', self.sw_button_press_event) self.sw.connect('scroll_event', self.sw_scroll_event) # Create an alignment to keep the thumbnails center-aligned align = gtk.Alignment(0.5, 0.5, 0, 0) self.sw.add_with_viewport(align) # Create ListStore model and IconView self.model = gtk.ListStore(str, # 0.Text descriptor gobject.TYPE_PYOBJECT, # 1.Cached page image int, # 2.Document number int, # 3.Page number float, # 4.Scale str, # 5.Document filename int, # 6.Rotation angle float, # 7.Crop left float, # 8.Crop right float, # 9.Crop top float, # 10.Crop bottom int, # 11.Page width int, # 12.Page height float) # 13.Resampling factor self.zoom_set(self.prefs['initial zoom level']) self.iv_col_width = self.prefs['initial thumbnail size'] self.iconview = gtk.IconView(self.model) self.iconview.set_item_width(self.iv_col_width + 12) self.cellthmb = CellRendererImage() self.iconview.pack_start(self.cellthmb, False) self.iconview.set_attributes(self.cellthmb, image=1, scale=4, rotation=6, cropL=7, cropR=8, cropT=9, cropB=10, width=11, height=12, resample=13) self.celltxt = gtk.CellRendererText() self.celltxt.set_property('width', self.iv_col_width) self.celltxt.set_property('wrap-width', self.iv_col_width) self.celltxt.set_property('alignment', pango.ALIGN_CENTER) self.iconview.pack_start(self.celltxt, False) self.iconview.set_attributes(self.celltxt, text=0) self.iconview.set_selection_mode(gtk.SELECTION_MULTIPLE) self.iconview.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, self.TARGETS_IV, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.iconview.enable_model_drag_dest(self.TARGETS_IV, gtk.gdk.ACTION_DEFAULT) self.iconview.connect('drag_begin', self.iv_drag_begin) self.iconview.connect('drag_data_get', self.iv_dnd_get_data) self.iconview.connect('drag_data_received', self.iv_dnd_received_data) self.iconview.connect('drag_data_delete', self.iv_dnd_data_delete) self.iconview.connect('drag_motion', self.iv_dnd_motion) self.iconview.connect('drag_leave', self.iv_dnd_leave_end) self.iconview.connect('drag_end', self.iv_dnd_leave_end) self.iconview.connect('button_press_event', self.iv_button_press_event) align.add(self.iconview) # Progress bar self.progress_bar = self.uiXML.get_object('progressbar') self.progress_bar_timeout_id = 0 # Define window callback function and show window self.window.connect('size_allocate', self.on_window_size_request) # resize self.window.connect('key_press_event', self.on_keypress_event ) # keypress self.window.show_all() self.progress_bar.hide_all() # Change iconview color background style = self.sw.get_style().copy() for state in (gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE): style.base[state] = style.bg[gtk.STATE_NORMAL] self.iconview.set_style(style) # Creating the popup menu self.popup = gtk.Menu() popup_rotate_right = gtk.ImageMenuItem(_('_Rotate Right')) popup_rotate_left = gtk.ImageMenuItem(_('Rotate _Left')) popup_crop = gtk.MenuItem(_('C_rop...')) popup_delete = gtk.ImageMenuItem(gtk.STOCK_DELETE) popup_saveselection = gtk.MenuItem(_('_Export selection...')) popup_rotate_right.connect('activate', self.rotate_page_right) popup_rotate_left.connect('activate', self.rotate_page_left) popup_crop.connect('activate', self.crop_page_dialog) popup_delete.connect('activate', self.clear_selected) popup_saveselection.connect('activate', self.choose_export_pdf_name, True) popup_rotate_right.show() popup_rotate_left.show() popup_crop.show() popup_delete.show() popup_saveselection.show() self.popup.append(popup_rotate_right) self.popup.append(popup_rotate_left) self.popup.append(popup_crop) self.popup.append(popup_delete) self.popup.append(popup_saveselection) # Initializing variables self.export_directory = os.getenv('HOME') self.import_directory = self.export_directory self.nfile = 0 self.iv_auto_scroll_direction = 0 self.iv_auto_scroll_timer = None self.pdfqueue = [] gobject.type_register(PDF_Renderer) gobject.signal_new('update_thumbnail', PDF_Renderer, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, [gobject.TYPE_INT, gobject.TYPE_PYOBJECT, gobject.TYPE_FLOAT]) self.rendering_thread = 0 self.set_unsaved(False) # Importing documents passed as command line arguments for filename in sys.argv[1:]: self.add_pdf_pages(filename)
def on_read_tweets_changed(self, widget): unread_tweets = 0 for i in range(self.tweet_notebook.get_n_pages()): pane = self.tweet_notebook.get_nth_page(i) unread_tweets += pane.num_new_tweets if unread_tweets > 0: self.tray_icon.set_property('blinking', True) else: self.tray_icon.set_property('blinking', False) ### end class Hrafn # main if __name__ == "__main__": config.init() base_icon = gtk.gdk.pixbuf_new_from_file('ui/icon.svg') icon = base_icon.scale_simple(128, 128, gtk.gdk.INTERP_BILINEAR) gtk.window_set_default_icon(icon) my_twitter = Hrafn(config.options.resize) gtk.gdk.threads_init() gtk.gdk.threads_enter() gtk.main() gtk.gdk.threads_leave()
import os if __name__ == "__main__": if ('GR_DONT_LOAD_PREFS' in os.environ.keys() and (not 'GRC_BLOCKS_PATH' in os.environ.keys() or len(os.environ['GRC_BLOCKS_PATH']) == 0)): d = gtk.MessageDialog( type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="""Can't find block definitions. Use config.conf or GRC_BLOCKS_PATH. """) d.set_title("No block definitions available.") d.run() exit(-1) usage = 'usage: %prog [options] [saved flow graphs]' version = """ GNU Radio Companion %s This program is part of GNU Radio GRC comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it. """%'GNWversion1' #%gr.version() parser = OptionParser(usage=usage, version=version) (options, args) = parser.parse_args() from gwnc.python.Platform import Platform from gwnc.gui.ActionHandler import ActionHandler #setup icon using icon theme try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0)) except: pass ActionHandler(args, Platform())
def initGUI(self): theme = gtk.icon_theme_get_default() if theme.has_icon("terminal"): icon = theme.lookup_icon("terminal", 128, flags=gtk.ICON_LOOKUP_USE_BUILTIN) if icon is not None: gtk.window_set_default_icon(icon.load_icon()) self.MainWin.set_title("crussh: " + ' '.join(self.Terminals.keys())) self.MainWin.set_role(role="crussh_main_win") self.MainWin.connect("delete-event", lambda window, event: gtk.main_quit()) MainVBox = gtk.VBox() self.MainWin.add(MainVBox) MainMenuBar = gtk.MenuBar() MainVBox.pack_start(MainMenuBar, fill=True, expand=False) def add_host_handler(self, base): diag = EntryDialog(buttons=gtk.BUTTONS_OK, type=gtk.MESSAGE_QUESTION, message_format="Hostname to add:") print "test" host = diag.run() if len(host) > 0: base.addHost(host) diag.destroy() base.reflow(force=True) FileItem = gtk.MenuItem(label="File") FileMenu = gtk.Menu() FileItem.set_submenu(FileMenu) AddHostItem = gtk.MenuItem(label="Add Host") AddHostItem.connect("activate", add_host_handler, self) FileMenu.append(AddHostItem) FileMenu.append(gtk.SeparatorMenuItem()) QuitItem = gtk.ImageMenuItem(gtk.STOCK_QUIT) QuitItem.connect("activate", lambda discard: gtk.main_quit()) FileMenu.append(QuitItem) MainMenuBar.append(FileItem) EditItem = gtk.MenuItem(label="Edit") EditMenu = gtk.Menu() EditItem.set_submenu(EditMenu) ActiveHostsItem = gtk.MenuItem(label="Active Hosts") ActiveHostsItem.connect("activate", lambda discard: HostsMask(self.Terminals)) EditMenu.append(ActiveHostsItem) PrefsItem = gtk.MenuItem(label="Preferences") def save_func(new_config): self.Config = new_config self.reflow(force=True) # save to file last, so it doesn't hold up other GUI actions conf_json = json.dumps(self.Config, sort_keys=True, indent=4) try: conf_file = open(os.path.expanduser("~/.crusshrc"), 'w') conf_file.write(conf_json) conf_file.close() except: pass PrefsItem.connect("activate", lambda discard: CruSSHConf(self.Config, save_func)) EditMenu.append(PrefsItem) MainMenuBar.append(EditItem) self.ScrollWin.props.hscrollbar_policy = gtk.POLICY_NEVER self.ScrollWin.props.vscrollbar_policy = gtk.POLICY_ALWAYS self.ScrollWin.props.shadow_type = gtk.SHADOW_ETCHED_IN MainVBox.pack_start(self.ScrollWin) self.LayoutTable.set_homogeneous(True) self.LayoutTable.set_row_spacings(1) self.LayoutTable.set_col_spacings(1) self.ScrollWin.add_with_viewport(self.LayoutTable) self.ScrollWin.set_size_request(self.TermMinWidth, self.TermMinHeight) # don't display chars while typing. self.EntryBox.set_visibility(False) self.EntryBox.set_invisible_char(' ') # feed GNOME clipboard to all active terminals def feed_paste(widget): for host in self.Terminals: if self.Terminals[host].copy_input: self.Terminals[host].paste_clipboard() self.EntryBox.props.buffer.delete_text(0, -1) # forward key events to all terminals with copy_input set def feed_input(widget, event): self.EntryBox.props.buffer.delete_text(0, -1) # check for paste key shortcut (ctl-shift-v) if (event.type == gtk.gdk.KEY_PRESS) \ and (event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK) \ and (event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK) \ and (event.keyval == gtk.gdk.keyval_from_name('V')): feed_paste(widget) else: # propagate to every terminal for host in self.Terminals: t_event = event.copy() if self.Terminals[host].copy_input: self.Terminals[host].event(t_event) # this stops regular handler from firing, switching focus. return True def click_handler(widget, event): # if middle click if event.button == 2: feed_input(widget, event) self.EntryBox.connect("key_press_event", feed_input) self.EntryBox.connect("key_release_event", feed_input) self.EntryBox.connect("paste_clipboard", feed_paste) self.EntryBox.connect("button_press_event", click_handler) MainVBox.pack_start(self.EntryBox, False, False) # reflow layout on size change. self.MainWin.connect("size-allocate", lambda widget, allocation: self.reflow()) # give EntryBox default focus on init self.EntryBox.props.has_focus = True
def set_icon(self, icon_path): '''Set icon.''' gtk.window_set_default_icon(theme.get_dynamic_pixbuf(icon_path).get_pixbuf())
# -*- coding: utf-8 -*- # (c) 2005-2012 PIDA Authors # vim: ft=python sw=2 ts=2 sts=2 tw=80 import gtk from pygtkhelpers import delegates, utils from a8 import resources gtk.window_set_default_icon(resources.load_icon('a8.png').get_pixbuf()) class A8Window(delegates.WindowView): """Abominade window object""" def post_configure(self): self.widget.set_title('Abominade loves you.') self.accel_group = self.model.shortcuts.create_group() self.widget.add_accel_group(self.accel_group) self.set_title('') self.widget.set_default_size(800, 600) self.widget.show_all() def set_title(self, title): self.widget.set_title(u'a8♥u {0}'.format(title)) class ApplicationWindow(A8Window): """Main application window.""" def create_ui(self): """Create the user interface."""
# Zeobuilder is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/> # #-- from zeobuilder import context import gtk, os class GUIError(Exception): pass def load_image(filename, size=None): filename = context.get_share_filename(filename) if os.path.isfile(filename): if size is None: return gtk.gdk.pixbuf_new_from_file(filename) else: return gtk.gdk.pixbuf_new_from_file_at_size( filename, size[0], size[1]) gtk.window_set_default_icon(load_image("zeobuilder.svg"))
def __init__(self): gobject.GObject.__init__(self) self.config = tgcm.core.Config.Config(tgcm.country_support) self.is_moving = False self.__is_maximized = False self.__unmaximized_width = 0 self.__unmaximized_height = 0 # Variables related to Wi-Fi Access Point status self._wifi_aap = False self._wifi_aap_listener_id = False self.XMLConf = tgcm.core.XMLConfig.XMLConfig() self.XMLConf.import_regional_info() self.XMLTheme = tgcm.core.XMLTheme.XMLTheme() self.XMLTheme.load_theme() self.dock_layout = self.XMLTheme.get_layout('dock.layout') # FIXME: Really ugly hack to set the correct size for a dock # with ads (e.g. Latam). # TGCM/Win uses a floating window to show the advertisements, but in # TGCM/Linux we need to have only one gtk.Window for the dock. The # size of our dock does not directly appear in themes.xml, so it is # needed to do some calculations to get it is_advertising = self.config.is_ads_available() if is_advertising: ad_layout = self.XMLTheme.get_layout('dock.advertising') orig_height = self.dock_layout['size']['height'] ad_height = ad_layout['size']['height'] self.dock_layout['size']['orig_height'] = orig_height self.dock_layout['size']['height'] = orig_height + ad_height orig_minY = self.dock_layout['border']['minY'] self.dock_layout['border']['orig_minY'] = orig_minY self.dock_layout['border']['minY'] = orig_height + ad_height # Gnome 3 is an "application based" system, as opposed to "window based" (see # http://live.gnome.org/GnomeShell/ApplicationBased for more info). The interesting # thing with Gnome 3 is that it uses a different (and somewhat insane) algorithm to # look for the application name. That string is used e.g. in the title bar, alt+tab, etc. # # Currently, it seems that a .desktop file accessible world-wide (e.g. in # /usr/share/applications) is required, and the value of the X property "WM_CLASS" must # match with the name of that .desktop file. For example, if an application package # provides a file called 'xxxx.desktop', the WM_CLASS property of the application window # must be something like WM_CLASS(STRING) = "xxxx", "Xxxx". # # We have a problem with TGCM, because by default PyGTK uses the name of the main python # script to set the WM_CLASS value (in our case WM_CLASS(STRING) = "tgcm", "Tgcm"), so # Gnome 3 fails to find the appropriate .desktop file (eg. "tgcm-[es|ar|de|uy].desktop"). # Instead of showing the correct application name, it shows "Tgcm". # # The following lines are intended to correctly establish the contents of the property # WM_CLASS to something like WM_CLASS(STRING) = "tgcm-es", "Tgcm-es". It unfortunately # fails but that is the documented way to do it. prg_name = 'tgcm-%s' % tgcm.country_support app_name = 'Tgcm-%s' % tgcm.country_support gobject.set_prgname(prg_name) gobject.set_application_name(app_name) gtk.window_set_default_icon(self.XMLTheme.get_window_icon()) self.main_window = gtk.Window() self.main_window.set_name("tgcm_main_window") self.main_window.set_title(self.config.get_app_name()) # WTF: Seems that PyGTK does not properly assign the property WM_CLASS with the # functions "gobject.set_prgname()". The following function indeed it does, but in # a very hostile and probably dangerous way. Keep it in mind! self.main_window.set_wmclass(prg_name, app_name) self.main_window.set_decorated(False) self.main_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL) self.main_window.connect("show", self.__on_show_window) self.main_window.connect("delete-event", self.__on_destroy_window) self.main_window.connect("check-resize", self.__on_check_resize) self.main_window.connect("configure-event", self.__on_configure_event) self.main_window.connect("motion-notify-event", self.__motion_notify_event) self.help_dialog = None self.__is_first_time = False if self.config.is_first_time(): self.__is_first_time = True self.config.done_first_time() self.vbox = gtk.VBox() self.main_window.add(self.vbox) # Hidden menu, used for Ubuntu HUD and keyboard accelerators self.menubar = tgcm.ui.widgets.dock.Menubar.Menubar() self.vbox.pack_start(self.menubar.get_menubar(), False) self.main_box = gtk.Fixed() self.main_box.connect("size-allocate", self.__on_size_allocate) self.vbox.pack_start(self.main_box, True) self.vbox.show() self.menubar.get_menubar().hide() self.main_box.show() # Add a global URI hook to gtk.LinkButton widgets. This hook check if there is an # active connection before opening the URI, and if that is not the case it initiates # the SmartConnector logic gtk.link_button_set_uri_hook(self.__linkbutton_global_uri_hook)
def __init__(self): if os.name == "nt" : self.winux = PdfShuffler_Windows_code() else : self.winux = PdfShuffler_Linux_code() # Create the temporary directory self.tmp_dir = tempfile.mkdtemp("pdfshuffler") self.selection_start = 0 os.chmod(self.tmp_dir, 0700) icon_theme = gtk.icon_theme_get_default() try: gtk.window_set_default_icon(icon_theme.load_icon("pdfshuffler", 64, 0)) except: print(_("Can't load icon. Application is not installed correctly.")) # Import the user interface file, trying different possible locations ui_path = '/usr/share/pdfbooklet/data/pdfshuffler_g.glade' if not os.path.exists(ui_path): ui_path = '/usr/local/share/pdfbooklet/data/pdfshuffler_g.glade' if not os.path.exists(ui_path): # Windows standard path ui_path = './data/pdfshuffler_g.glade' if not os.path.exists(ui_path): parent_dir = os.path.dirname( \ os.path.dirname(os.path.realpath(__file__))) ui_path = os.path.join(parent_dir, 'data', 'pdfshuffler_g.glade') if not os.path.exists(ui_path): head, tail = os.path.split(parent_dir) while tail != 'lib' and tail != '': head, tail = os.path.split(head) if tail == 'lib': ui_path = os.path.join(head, 'share', 'pdfbooklet', \ 'data/pdfshuffler_g.glade') self.uiXML = gtk.Builder() self.uiXML.add_from_file(ui_path) self.uiXML.connect_signals(self) # Create the main window, and attach delete_event signal to terminating # the application self.window = self.uiXML.get_object('main_window') self.window.set_title(APPNAME) self.window.set_border_width(0) self.window.move(self.prefs['window x'], self.prefs['window y']) self.window.set_default_size(self.prefs['window width'], self.prefs['window height']) self.window.connect('delete_event', self.close_application) # Create a scrolled window to hold the thumbnails-container self.sw = self.uiXML.get_object('scrolledwindow') self.sw.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, self.TARGETS_SW, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.sw.connect('drag_data_received', self.sw_dnd_received_data) self.sw.connect('button_press_event', self.sw_button_press_event) self.sw.connect('scroll_event', self.sw_scroll_event) # Create an alignment to keep the thumbnails center-aligned align = gtk.Alignment(0.5, 0.5, 0, 0) self.sw.add_with_viewport(align) # Create ListStore model and IconView self.model = gtk.ListStore(str, # 0.Text descriptor gobject.TYPE_PYOBJECT, # 1.Cached page image int, # 2.Document number int, # 3.Page number float, # 4.Scale str, # 5.Document filename int, # 6.Rotation angle float, # 7.Crop left float, # 8.Crop right float, # 9.Crop top float, # 10.Crop bottom int, # 11.Page width int, # 12.Page height float) # 13.Resampling factor self.zoom_set(self.prefs['initial zoom level']) self.iv_col_width = self.prefs['initial thumbnail size'] self.iconview = gtk.IconView(self.model) self.iconview.set_item_width(self.iv_col_width + 12) self.cellthmb = CellRendererImage() self.iconview.pack_start(self.cellthmb, False) self.iconview.set_attributes(self.cellthmb, image=1, scale=4, rotation=6, cropL=7, cropR=8, cropT=9, cropB=10, width=11, height=12, resample=13) self.celltxt = gtk.CellRendererText() self.celltxt.set_property('width', self.iv_col_width) self.celltxt.set_property('wrap-width', self.iv_col_width) self.celltxt.set_property('alignment', pango.ALIGN_CENTER) self.iconview.pack_start(self.celltxt, False) self.iconview.set_attributes(self.celltxt, text=0) self.iconview.set_selection_mode(gtk.SELECTION_MULTIPLE) self.iconview.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, self.TARGETS_IV, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.iconview.enable_model_drag_dest(self.TARGETS_IV, gtk.gdk.ACTION_DEFAULT) self.iconview.connect('drag_begin', self.iv_drag_begin) self.iconview.connect('drag_data_get', self.iv_dnd_get_data) self.iconview.connect('drag_data_received', self.iv_dnd_received_data) self.iconview.connect('drag_data_delete', self.iv_dnd_data_delete) self.iconview.connect('drag_motion', self.iv_dnd_motion) self.iconview.connect('drag_leave', self.iv_dnd_leave_end) self.iconview.connect('drag_end', self.iv_dnd_leave_end) self.iconview.connect('button_press_event', self.iv_button_press_event) align.add(self.iconview) # Progress bar self.progress_bar = self.uiXML.get_object('progressbar') self.progress_bar_timeout_id = 0 # Define window callback function and show window self.window.connect('size_allocate', self.on_window_size_request) # resize self.window.connect('key_press_event', self.on_keypress_event ) # keypress self.window.show_all() self.progress_bar.hide_all() # Change iconview color background style = self.sw.get_style().copy() for state in (gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE): style.base[state] = style.bg[gtk.STATE_NORMAL] self.iconview.set_style(style) # Creating the popup menu ## self.popup = gtk.Menu() ## popup_rotate_right = gtk.ImageMenuItem(_('_Rotate Right')) ## popup_rotate_left = gtk.ImageMenuItem(_('Rotate _Left')) ## popup_crop = gtk.MenuItem(_('C_rop...')) ## popup_delete = gtk.ImageMenuItem(gtk.STOCK_DELETE) ## popup_rotate_right.connect('activate', self.rotate_page_right) ## popup_rotate_left.connect('activate', self.rotate_page_left) ## popup_crop.connect('activate', self.crop_page_dialog) ## popup_delete.connect('activate', self.clear_selected) ## popup_rotate_right.show() ## popup_rotate_left.show() ## popup_crop.show() ## popup_delete.show() ## self.popup.append(popup_rotate_right) ## self.popup.append(popup_rotate_left) ## self.popup.append(popup_crop) ## self.popup.append(popup_delete) self.popup = self.uiXML.get_object('contextmenu1') # Initializing variables self.export_directory = self.winux.home_dir() self.import_directory = self.export_directory self.nfile = 0 self.iv_auto_scroll_direction = 0 self.iv_auto_scroll_timer = None self.pdfqueue = [] gobject.type_register(PDF_Renderer) gobject.signal_new('update_thumbnail', PDF_Renderer, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, [gobject.TYPE_INT, gobject.TYPE_PYOBJECT, gobject.TYPE_FLOAT]) self.rendering_thread = 0 self.set_unsaved(False) # Importing documents passed as command line arguments for filename in sys.argv[1:]: self.add_pdf_pages(filename)
def __init__(self): # Create and setup a new window # - titlebar, moveable, resizeable... #self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) # - ontop, sticky, un-moveable, un-resizeable... self.window = gtk.Window(gtk.WINDOW_POPUP) # Window properties self.window.set_title(appname) self.window.set_border_width(5) self.window.set_size_request(310, 222) self.window.set_position(gtk.WIN_POS_CENTER) # Connect the destroy event to a handler self.window.connect("destroy", lambda x: gtk.main_quit()) # Create a vertical container box with small padding self.vbox = gtk.VBox(False, 2) # Create an image self.image = gtk.Image() self.image.set_from_file(appimage) # Integrate it into the vbox self.vbox.pack_start(self.image) # Create a label notice self.label = gtk.Label(appname) # Integrate it into the vbox self.vbox.pack_start(self.label) # Create a scrolled window self.scrolledwin = gtk.ScrolledWindow() self.scrolledwin.set_shadow_type(gtk.SHADOW_ETCHED_IN) self.scrolledwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) # Integrate it into the vbox # - child, expand, fill, padding self.vbox.pack_start(self.scrolledwin, True, True, 0) # Create a TreeView object liststore = self.create_listmodel() self.treeview = gtk.TreeView(liststore) self.treeview.connect("row-activated", self.on_clkactivated) # Change the bg color of every 2nd row self.treeview.set_rules_hint(True) # Add the TreeView to the scrolled window self.scrolledwin.add(self.treeview) # Create TreeView columns self.create_columns(self.treeview) # Add the vbox to the main window self.window.add(self.vbox) # Create a button box self.bbox = gtk.HButtonBox() self.vbox.pack_start(self.bbox, False, False, 0) self.bbox.set_layout(gtk.BUTTONBOX_SPREAD) # OK button widget button = gtk.Button(stock=gtk.STOCK_OK) button.connect("clicked", self.on_btnactivated) self.bbox.add(button) # Close button widget button = gtk.Button(stock=gtk.STOCK_CANCEL) button.connect("clicked", lambda w: gtk.main_quit()) self.bbox.add(button) # This is the default button button.set_flags(gtk.CAN_DEFAULT) button.grab_default() # Set window icon gtk.window_set_default_icon(self.presentation_select_icon()) # Draw the presentation manager self.window.show_all()
def __init__(self, monthspec=None): self.window = None # Create a new window window = gtk.Window(appprop[1]) # - floating when TOPLEVEL window.set_resizable(False) # - window properties window.set_title(appprop[0]) window.set_border_width(appprop[5]) # Connect the destroy event to a handler window.connect("destroy", lambda x: gtk.main_quit()) # Auto exit after timeout timer = gobject.timeout_add(appprop[6], lambda: gtk.main_quit()) # The top part of the window: calendar box vbox = gtk.VBox(False, self.DEF_PAD) hbox = gtk.HBox(False, self.DEF_PAD) hbbox = gtk.HButtonBox() window.add(vbox) vbox.pack_start(hbox, True, True, self.DEF_PAD) hbox.pack_start(hbbox, False, False, self.DEF_PAD) hbbox.set_layout(gtk.BUTTONBOX_SPREAD) hbbox.set_spacing(0) # Calendar widget frame = gtk.Frame() hbbox.pack_start(frame, False, True, self.DEF_PAD) calendar = gtk.Calendar() self.window = calendar # Calendar options # GTK_CALENDAR_SHOW_HEADING = 1 << 0, # GTK_CALENDAR_SHOW_DAY_NAMES = 1 << 1, # GTK_CALENDAR_NO_MONTH_CHANGE = 1 << 2, # GTK_CALENDAR_SHOW_WEEK_NUMBERS = 1 << 3, # GTK_CALENDAR_WEEK_START_MONDAY = 1 << 4, # GTK_CALENDAR_SHOW_DETAILS = 1 << 5 # As default, show heading, show days and allow date changes #self.window.set_display_options(3 + (1<<5)) # Show a specific month if requested on startup if monthspec in range(1, 13): # Clear day selection if not viewing current month if monthspec != self.window.get_date()[1]+1: self.window.select_day(0) self.window.select_month(monthspec-1, self.window.get_date()[0]) # Fake a month change on startup, to get marks right away self.calendar_month_changed(calendar) # Put the finished widget in the frame frame.add(calendar) # Signals Handlers calendar.connect("month_changed", self.calendar_month_changed) # Setup buttons if appprop[7]: # The bottom part of the window: button box bbox = gtk.HButtonBox () vbox.pack_start(bbox, False, False, 0) bbox.set_layout(gtk.BUTTONBOX_SPREAD) # Button widget: Agenda # - modify default label for STOCK_EDIT gtk.stock_add([(gtk.STOCK_EDIT, apptips[1][0], 0, 0, "")]) button = gtk.Button(stock=gtk.STOCK_EDIT) button.connect("clicked", lambda w: self.calendar_show_agenda()) bbox.add(button) button.set_tooltip_text(apptips[1][1]) # Button widget: Close # - modify default label for STOCK_CANCEL gtk.stock_add([(gtk.STOCK_CANCEL, apptips[2][0], 0, 0, "")]) button = gtk.Button(stock=gtk.STOCK_CANCEL) button.connect("clicked", lambda w: gtk.main_quit()) bbox.add(button) # - this is the default button button.set_flags(gtk.CAN_DEFAULT) button.grab_default() button.set_tooltip_text(apptips[2][1]) # Set application icon gtk.window_set_default_icon(self.calendar_select_icon()) # Position the window window.move(self.DEF_POS_X, self.DEF_POS_Y) # Draw the calendar window.show_all()
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/> # # -- from zeobuilder import context import gtk, os class GUIError(Exception): pass def load_image(filename, size=None): filename = context.get_share_filename(filename) if os.path.isfile(filename): if size is None: return gtk.gdk.pixbuf_new_from_file(filename) else: return gtk.gdk.pixbuf_new_from_file_at_size( filename, size[0], size[1] ) gtk.window_set_default_icon(load_image("zeobuilder.svg"))
def __init__(self, datadir=None, logdir=None): DistUpgradeView.__init__(self) self.logdir = logdir if not datadir or datadir == '.': localedir = os.path.join(os.getcwd(), "mo") gladedir = os.getcwd() else: localedir = "/usr/share/locale/" gladedir = os.path.join(datadir, "gtkbuilder") # check if we have a display etc gtk.init_check() try: locale.bindtextdomain("ubuntu-release-upgrader", localedir) gettext.textdomain("ubuntu-release-upgrader") except Exception as e: logging.warning("Error setting locales (%s)" % e) icons = gtk.icon_theme_get_default() try: gtk.window_set_default_icon( icons.load_icon("system-software-update", 32, 0)) except gobject.GError as e: logging.debug("error setting default icon, ignoring (%s)" % e) pass SimpleGtkbuilderApp.__init__(self, gladedir + "/DistUpgrade.ui", "ubuntu-release-upgrader") # terminal stuff self.create_terminal() self.prev_step = 0 # keep a record of the latest step # we don't use this currently #self.window_main.set_keep_above(True) self.icontheme = gtk.icon_theme_get_default() # we keep a reference pngloader around so that its in memory # -> this avoid the issue that during the dapper->edgy upgrade # the loaders move from /usr/lib/gtk/2.4.0/loaders to 2.10.0 self.pngloader = gtk.gdk.PixbufLoader("png") try: self.svgloader = gtk.gdk.PixbufLoader("svg") self.svgloader.close() except gobject.GError as e: logging.debug("svg pixbuf loader failed (%s)" % e) pass try: import webkit self._webkit_view = webkit.WebView() self.vbox_main.pack_end(self._webkit_view) except: logging.exception("html widget") self._webkit_view = None self.window_main.realize() self.window_main.window.set_functions(gtk.gdk.FUNC_MOVE) self._opCacheProgress = GtkOpProgress(self.progressbar_cache) self._acquireProgress = GtkAcquireProgressAdapter(self) self._cdromProgress = GtkCdromProgressAdapter(self) self._installProgress = GtkInstallProgressAdapter(self) # details dialog self.details_list = gtk.TreeStore(gobject.TYPE_STRING) column = gtk.TreeViewColumn("") render = gtk.CellRendererText() column.pack_start(render, True) column.add_attribute(render, "markup", 0) self.treeview_details.append_column(column) self.details_list.set_sort_column_id(0, gtk.SORT_ASCENDING) self.treeview_details.set_model(self.details_list) # Use italic style in the status labels attrlist = pango.AttrList() #attr = pango.AttrStyle(pango.STYLE_ITALIC, 0, -1) attr = pango.AttrScale(pango.SCALE_SMALL, 0, -1) attrlist.insert(attr) self.label_status.set_property("attributes", attrlist) # reasonable fault handler sys.excepthook = self._handleException