예제 #1
0
    def __init__(self, config):
        super(self.__class__,self).__init__()
        self.config = config

        self.isDock = True
        self.defaultUrl = None

        rootBox = gtk.VBox()
        rootBox.set_border_width(2)
        
        toolbar = gtk.Toolbar()
        toolbar.set_style(gtk.TOOLBAR_ICONS)
        gtk.icon_size_register('doctasktoolbar', 16, 16)
        toolbar.set_icon_size(gtk.icon_size_from_name('doctasktoolbar'))

        html = Html()

        dockAction = gtk.Action("input", "input", "if you found you can not input in the web page, click here",
                                gtk.STOCK_INDENT)
        homeAction = gtk.Action("home", "home", "return the start page", gtk.STOCK_HOME)
        refreshAction = gtk.Action("refresh", "refresh", "refresh", gtk.STOCK_REFRESH)
        exitAction = gtk.Action("exit", "exit", "exit", gtk.STOCK_QUIT)
        trayAction = gtk.Action("tray", "tray", "minimize to tray", gtk.STOCK_GO_DOWN)
        newUrlAction = gtk.Action("newUrl", "newUrl", "open a new url", gtk.STOCK_JUMP_TO)
        

        toolbar.add(dockAction.create_tool_item())
        toolbar.add(homeAction.create_tool_item())
        urlListToolButton = gtk.MenuToolButton(gtk.STOCK_SELECT_ALL)
        urlListToolButton.set_menu(self._buildUrlMenu())
        toolbar.add(urlListToolButton)
        # toolbar.add(newUrlAction.create_tool_item())
        toolbar.add(refreshAction.create_tool_item())
        toolbar.add(trayAction.create_tool_item())
        toolbar.add(exitAction.create_tool_item())

        rootBox.pack_start(toolbar, False)

        layout = gtk.ScrolledWindow()
        layout.add(html)

        rootBox.pack_start(layout)
        rootBox.set_focus_child(layout)

        self.add(rootBox)
        self.set_default_size(200, 750)

        self.html = html
        self.statusIcon = StatusIcon(self)

        dockAction.connect("activate", self.onDockButtonClick)
        refreshAction.connect("activate", self.onRefresh)
        exitAction.connect("activate", self.onExit)
        homeAction.connect("activate", self.onHome)
        trayAction.connect("activate", self.onTray)
        newUrlAction.connect("activate", self.onNewUrl)
        self.connect("enter-notify-event", self.onEnterNotifyEvent)
        self.connect("show", self.onShow)
예제 #2
0
파일: icon.py 프로젝트: coopengo/tryton
 def __init__(self, view, attrs):
     super(Icon, self).__init__(view, attrs)
     self.height = int(attrs.get('height', 60))
     self.width = int(attrs.get('width', 60))
     size_name = str(self.width) + '_' + str(self.height)
     self.size = gtk.icon_size_from_name(size_name)
     if self.size.numerator == 0:
         self.size = gtk.icon_size_register(size_name, self.width,
             self.height)
     self.widget = gtk.Image()
     self.update_icon()
예제 #3
0
파일: icon.py 프로젝트: PierreCookie/tryton
 def __init__(self, view, attrs):
     super(Icon, self).__init__(view, attrs)
     self.height = int(attrs.get('height', 60))
     self.width = int(attrs.get('width', 60))
     size_name = str(self.width) + '_' + str(self.height)
     self.size = gtk.icon_size_from_name(size_name)
     if self.size.numerator == 0:
         self.size = gtk.icon_size_register(size_name, self.width,
                                            self.height)
     self.widget = gtk.Image()
     self.update_icon()
예제 #4
0
def channels_to_model(channels):
    new_model=gtk.ListStore(str, str, str, gtk.gdk.Pixbuf, int, gtk.gdk.Pixbuf, str)
    
    for channel in channels:
        (count_available, count_downloaded, count_new, count_unplayed)=channel.get_episode_stats()
        
        new_iter=new_model.append()
        new_model.set(new_iter, 0, channel.url)
        new_model.set(new_iter, 1, channel.title)

        title_markup=saxutils.escape(channel.title)
        description_markup=saxutils.escape(util.get_first_line(channel.description))
        description='%s\n<small>%s</small>' % (title_markup, description_markup)
        if channel.parse_error is not None:
            description='<span foreground="#ff0000">%s</span>' % description
            new_model.set(new_iter, 6, channel.parse_error)
        else:
            new_model.set(new_iter, 6, '')
        
        new_model.set(new_iter, 2, description)

        if count_unplayed > 0 or count_downloaded > 0:
            new_model.set(new_iter, 3, draw.draw_pill_pixbuf(str(count_unplayed), str(count_downloaded)))

        if count_new > 0:
            new_model.set( new_iter, 4, pango.WEIGHT_BOLD)
        else:
            new_model.set( new_iter, 4, pango.WEIGHT_NORMAL)

        channel_cover_found=False
        if os.path.exists( channel.cover_file) and os.path.getsize(channel.cover_file) > 0:
            try:
                new_model.set( new_iter, 5, gtk.gdk.pixbuf_new_from_file_at_size( channel.cover_file, 32, 32))
                channel_cover_found=True
            except: 
                exctype, value=sys.exc_info()[:2]
                log( 'Could not convert icon file "%s", error was "%s"', channel.cover_file, value )
                util.delete_file(channel.cover_file)

        if not channel_cover_found:
            iconsize=gtk.icon_size_from_name('channel-icon')
            if not iconsize:
                iconsize=gtk.icon_size_register('channel-icon',32,32)
            icon_theme=gtk.icon_theme_get_default()
            globe_icon_name='applications-internet'
            try:
                new_model.set( new_iter, 5, icon_theme.load_icon(globe_icon_name, iconsize, 0))
            except:
                log( 'Cannot load "%s" icon (using an old or incomplete icon theme?)', globe_icon_name)
                new_model.set( new_iter, 5, None)
    
    return new_model
예제 #5
0
파일: gtkutil.py 프로젝트: shreeja0/panucci
def generate_image(filename, is_stock=False):
    image = None
    if is_stock:
        image = gtk.image_new_from_stock(
            filename, gtk.icon_size_from_name('panucci-button') )
    else:
        filename = util.find_data_file(filename)
        if filename is not None:
            image = gtk.image_new_from_file(filename)
    if image is not None:
        if platform.MAEMO:
            image.set_padding(20, 20)
        else:
            image.set_padding(5, 5)
        image.show()
    return image
예제 #6
0
	def __init__(self, bot):
		"""Constructor method."""
		self.__gobject_init__()
		self.bot = bot
		
		# load botwindow.glade file
		self.builder = gtk.Builder()
		self.builder.add_from_file(resourcePath('botwindow.glade'))

		# get some widgets and objects for easier access
		self.botWindow  = self.builder.get_object('botwindow')
		outputScrollArea = self.builder.get_object('outputScrollArea')
		self.outputView = self.builder.get_object('outputView')
		self.commandEntry = self.builder.get_object('commandInputEntry')
		self.destinationSelector = self.builder.get_object('destinationSelector')
		self.startButton = self.builder.get_object('startButton')
		self.restartButton = self.builder.get_object('restartButton')
		self.shutdownButton = self.builder.get_object('shutdownButton')
		self.terminateButton = self.builder.get_object('terminateButton')
		self.statusImage = self.builder.get_object('statusImage')
		self.statusLabel = self.builder.get_object('statusLabel')

		# call scrollViewToBottom() when scroll area's vertical scrollbar changes
		weakConnect(outputScrollArea.get_vadjustment(), 'changed', self.scrollViewToBottom)

		# call onCommandGiven() when user hits enter-key within the entry
		weakConnect(self.commandEntry, 'activate', self.onCommandGiven)
		
		# prevent deletion of the window on close
		weakConnect(self.botWindow, 'delete-event', self.onDeleteEvent)
		
		# be notified of bot's changes
		weakConnect(self.bot, 'notify::isRunning', self.onBotPropertyChanged)
		weakConnect(self.bot, 'notify::apiAccessible', self.onBotPropertyChanged)

		# handle button clicks
		weakConnect(self.startButton, 'clicked', self.onButtonClicked)
		weakConnect(self.restartButton, 'clicked', self.onButtonClicked)
		weakConnect(self.shutdownButton, 'clicked', self.onButtonClicked)
		weakConnect(self.terminateButton, 'clicked', self.onButtonClicked)

		self.outputView.set_buffer(self.bot.getConsoleModel())
		self.statusImage.set_property('icon-size', gtk.icon_size_from_name('status-icon-size'))
		self.updateControlStates()
예제 #7
0
 def register_icon_size(self):
     self._icon_size = gtk.icon_size_from_name("license-icon-size")
     if self._icon_size==0:
         self._icon_size = gtk.icon_size_register("license-icon-size", int(76*self.ICON_SCALE), int(21*self.ICON_SCALE))
     return self._icon_size
예제 #8
0
	def __init__(self, botModel, settingModel):
		"""Constructor method."""
		self.__gobject_init__()
		self.botModel = botModel
		self.settingModel = settingModel
		self.position = (200, 200)
		# load controlpanel.glade file
		self.builder = gtk.Builder()
		self.builder.add_from_file(resourcePath('controlpanel.glade'))
		
		self.view = self.builder.get_object('controlPanelWindow')
		self.botListView = self.builder.get_object('botListView')
		self.botListContextMenu = self.builder.get_object('botListContextMenu')
		self.contextItemOpen = self.builder.get_object('contextItemOpen')
		self.contextItemModify = self.builder.get_object('contextItemConfigure')
		self.contextItemRemove = self.builder.get_object('contextItemRemove')
		self.contextItemStart = self.builder.get_object('contextItemStart')
		self.contextItemRestart = self.builder.get_object('contextItemRestart')
		self.contextItemShutdown = self.builder.get_object('contextItemShutdown')
		self.contextItemTerminate = self.builder.get_object('contextItemTerminate')
		
		self.botListView.set_model(self.botModel)

		# setup column for bot's name
		def botNameSetter(column, cell, model, iter):
			bot = model[iter][BotModel.COLUMN_BOTOBJECT]
			name = bot.getName()
			cell.set_property('text', name)
		nameRenderer = gtk.CellRendererText()
		nameRenderer.set_property('height', 50)
		nameColumn = gtk.TreeViewColumn('Bot', nameRenderer)
		nameColumn.set_property('expand', True)
		nameColumn.set_cell_data_func(nameRenderer, botNameSetter)
		self.botListView.append_column(nameColumn)
		
		# setup column for bot's status
		def botStatusSetter(column, cell, model, iter):
			bot = model[iter][BotModel.COLUMN_BOTOBJECT]
			status = getBotUIStatus(bot)
			cell.set_property('icon-name', status[1])

		statusRenderer = gtk.CellRendererPixbuf()
		statusRenderer.set_property('width', 50)
		statusRenderer.set_property('stock-size', gtk.icon_size_from_name('status-icon-size'))
		statusColumn = gtk.TreeViewColumn('Status', statusRenderer)
		statusColumn.set_cell_data_func(statusRenderer, botStatusSetter)
		self.botListView.append_column(statusColumn)
		
		# set default action as bold
		setItemAsBold(self.contextItemOpen)

		self.view.connect('delete-event', self.onDeleteEvent)
		self.view.connect('show', self.onViewShown)
		self.view.connect('hide', self.onViewHidden)
		
		self.botListView.connect('button-press-event', self.onBotListViewMousePressed)
		self.botListView.connect('key-press-event', self.onBotListViewKeyPressed)
		
		self.botListView.connect('row-activated', self.onBotListViewRowActivated)
		
		self.contextItemOpen.connect('activate', self.onContextMenuItemClicked, 'open')
		self.contextItemModify.connect('activate', self.onContextMenuItemClicked, 'configure')
		self.contextItemRemove.connect('activate', self.onContextMenuItemClicked, 'remove')
		self.contextItemStart.connect('activate', self.onContextMenuItemClicked, 'start')
		self.contextItemRestart.connect('activate', self.onContextMenuItemClicked, 'restart')
		self.contextItemShutdown.connect('activate', self.onContextMenuItemClicked, 'shutdown')
		self.contextItemTerminate.connect('activate', self.onContextMenuItemClicked, 'terminate')
		
		self.builder.get_object('addBotButton').connect('clicked', self.onAddBotClicked)
		self.builder.get_object('exitButton').connect('clicked', self.onExitClicked)
예제 #9
0
파일: panel.py 프로젝트: engla/folderdock
	def set_gicon(self, gicon):
		self.image.set_from_gicon(gicon, gtk.icon_size_from_name(SZ_NAME))
예제 #10
0
파일: pysiv.py 프로젝트: kylehuff/pysiv
else:
    window.move(
        window.get_position()[0], 0
    )  # Move the window to the x value of Center, and 0.. So Top, Center.. ( I couldnt find a gtk constant for top-center)

window.drag_event = False  # Specify the initial value of the drag_event
window.connect("destroy", gtk.main_quit)  # Connect the destory event to killing of the gtk main loop

if orientation == "vertical":
    vbox = gtk.VBox(False, 0)  # An horizontal box to add our widgets too.

    window.add(vbox)  # Add hbox to window

    close_image = gtk.Image()  # Image to be assigned to close_button
    gtk.icon_size_register("VOL_BUTTONS", 12, 12)  # Register a special size for usage with gtk.STOCK_* items
    close_image.set_from_stock(gtk.STOCK_CLOSE, gtk.icon_size_from_name("VOL_BUTTONS"))  # Assign the STOCK_CLOSE icon
    close_button = gtk.Button()  # Create the button
    close_button.set_image(close_image)  # Set the button image to the value of close_image
    close_button.connect("clicked", gtk.main_quit)  # Connect the clicked event to the killing of the gtk main loop
    vbox.add(close_button)  # Add the widget to the hbox

    vol_adj = gtk.VScale(
        gtk.Adjustment(value=vol, lower=0, upper=100, step_incr=1, page_incr=6)
    )  # Create a scale for volume adjustment/display
    vol_adj.set_inverted(True)
    vol_adj.set_size_request(20, 100)  # Request the size of the widget to be 100 wide and 20 tall
    vol_adj.changed_event_connection_id = vol_adj.connect(
        "value_changed", change_volume
    )  # Connect the change event to the change_volume function (I am assigning it to the variable vol_adh.changed_event_connection_id because I need the returned ID to later block the event, since the value of the control will be changed progromatically later
    vol_adj.set_draw_value(False)  # Tell the scale not to draw the decimal value of the scales current position
    vbox.add(vol_adj)  # Add the widget to our hbox