Esempio n. 1
0
def load_status_icon(path, size_x, size_y, stock):
    if os.access(path, os.R_OK):
        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path, size_x, size_y)
        return gtk.status_icon_new_from_pixbuf(pixbuf)
    else:
        # Can't find icon file
        logging.warning("cannot find icon file: " + path)
        return gtk.status_icon_new_from_stock(stock)
Esempio n. 2
0
 def create_status_icon(self):
         icon_theme = gtk.IconTheme()
         icon_theme.append_search_path(ICON_LOCATION)
         icon = gui_misc.get_icon(icon_theme, NOTIFY_ICON_NAME, 24)
         status_icon = gtk.status_icon_new_from_pixbuf(icon)
         status_icon.set_visible(False)
         status_icon.connect('activate', self.activate_status_icon)
         status_icon.connect('notify', self.notify_status_icon)
         return status_icon
Esempio n. 3
0
 def create_status_icon(self):
         icon_theme = gtk.IconTheme()
         icon_theme.append_search_path(ICON_LOCATION)
         icon = gui_misc.get_icon(icon_theme, NOTIFY_ICON_NAME, 24)
         status_icon = gtk.status_icon_new_from_pixbuf(icon)
         status_icon.set_visible(False)
         status_icon.connect('activate', self.activate_status_icon)
         status_icon.connect('notify', self.notify_status_icon)
         return status_icon
Esempio n. 4
0
	def __init__(self):
		super(MainWindow, self).__init__()

		# Create window
		self.set_title("Giant Multiplayer Robot")
		self.set_border_width(0)
		self.set_size_request(720, 320)
		self.connect("delete-event", self.on_delete_event)

		# Create the tray icon and bind an action to it
		iconPath = getFilePath("images/tray.png")
		pixbuf = gtk.gdk.pixbuf_new_from_file(iconPath)
		statusicon = gtk.status_icon_new_from_pixbuf(pixbuf)
		statusicon.connect("activate", self.tray_activate)

		# Create a vertical box in which we will display the header and games
		windowBox = gtk.VBox()
		self.add(windowBox)

		# Create a box for the header and make it a nice light gray
		headerBox = gtk.EventBox()
		headerBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#808080"))

		# Add a header object to the box and pack it into the window
		self.header = WindowHeader()
		headerBox.add(self.header)
		windowBox.pack_start(headerBox, False, True, 0)

		# Create an eventBox which will contain both the active turns and all 
		# games box. Make this dark gray.
		gameBox = gtk.EventBox()
		gameBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#303030"))

		# The gameContainer will contain two boxes: One for current turns and
		# one for all games.
		gameContainer = gtk.VBox()
		gameBox.add(gameContainer)
		gameContainer.set_spacing(10)
		windowBox.pack_start(gameBox, True, True, 0)

		# Create a CurrentTurns box and pack it into the gameContainer
		turnsEB = gtk.EventBox()
		turnsEB.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#484848"))
		self.turns = CurrentTurns()
		turnsEB.add(self.turns)
		gameContainer.pack_start(turnsEB, True, True, 0)

		# Do the same thing for a box containing all games
		gamesEB = gtk.EventBox()
		gamesEB.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#484848"))
		self.games = AllGames()
		gamesEB.add(self.games)
		gameContainer.pack_start(gamesEB, False, True, 0)

		# Enter the gtk loop
		self.show_all()
		gtk.main()
Esempio n. 5
0
    def __init__(self):
        super(MainWindow, self).__init__()

        # Create window
        self.set_title("Giant Multiplayer Robot")
        self.set_border_width(0)
        self.set_size_request(720, 320)
        self.connect("delete-event", self.on_delete_event)

        # Create the tray icon and bind an action to it
        iconPath = getFilePath("images/tray.png")
        pixbuf = gtk.gdk.pixbuf_new_from_file(iconPath)
        statusicon = gtk.status_icon_new_from_pixbuf(pixbuf)
        statusicon.connect("activate", self.tray_activate)

        # Create a vertical box in which we will display the header and games
        windowBox = gtk.VBox()
        self.add(windowBox)

        # Create a box for the header and make it a nice light gray
        headerBox = gtk.EventBox()
        headerBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#808080"))

        # Add a header object to the box and pack it into the window
        self.header = WindowHeader()
        headerBox.add(self.header)
        windowBox.pack_start(headerBox, False, True, 0)

        # Create an eventBox which will contain both the active turns and all
        # games box. Make this dark gray.
        gameBox = gtk.EventBox()
        gameBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#303030"))

        # The gameContainer will contain two boxes: One for current turns and
        # one for all games.
        gameContainer = gtk.VBox()
        gameBox.add(gameContainer)
        gameContainer.set_spacing(10)
        windowBox.pack_start(gameBox, True, True, 0)

        # Create a CurrentTurns box and pack it into the gameContainer
        turnsEB = gtk.EventBox()
        turnsEB.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#484848"))
        self.turns = CurrentTurns()
        turnsEB.add(self.turns)
        gameContainer.pack_start(turnsEB, True, True, 0)

        # Do the same thing for a box containing all games
        gamesEB = gtk.EventBox()
        gamesEB.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#484848"))
        self.games = AllGames()
        gamesEB.add(self.games)
        gameContainer.pack_start(gamesEB, False, True, 0)

        # Enter the gtk loop
        self.show_all()
        gtk.main()
Esempio n. 6
0
    def enable(self):
        """Enables the system tray icon."""
        self.builder = Builder()
        self.builder.add_from_file(resource_filename('deluge.ui.gtkui', os.path.join(
            'glade', 'tray_menu.ui')))

        self.builder.connect_signals(self)

        self.tray_menu = self.builder.get_object('tray_menu')

        if appindicator and self.config['enable_appindicator']:
            log.debug('Enabling the Application Indicator...')
            self.indicator = appindicator.Indicator('deluge', 'deluge',
                                                    appindicator.CATEGORY_APPLICATION_STATUS)
            try:
                self.indicator.set_property('title', _('Deluge'))
            except TypeError:
                # Catch 'title' property error for previous appindicator versions
                pass
            # Pass the menu to the Application Indicator
            self.indicator.set_menu(self.tray_menu)

            # Make sure the status of the Show Window MenuItem is correct
            self._sig_win_hide = self.mainwindow.window.connect('hide', self._on_window_hide)
            self._sig_win_show = self.mainwindow.window.connect('show', self._on_window_show)
            if self.mainwindow.visible():
                self.builder.get_object('menuitem_show_deluge').set_active(True)
            else:
                self.builder.get_object('menuitem_show_deluge').set_active(False)

            # Show the Application Indicator
            self.indicator.set_status(appindicator.STATUS_ACTIVE)

        else:
            log.debug('Enabling the system tray icon..')
            if windows_check():
                self.tray = status_icon_new_from_pixbuf(get_logo(32))
            else:
                self.tray = status_icon_new_from_icon_name('deluge')

            self.tray.connect('activate', self.on_tray_clicked)
            self.tray.connect('popup-menu', self.on_tray_popup)

        self.builder.get_object('download-limit-image').set_from_file(get_pixmap('downloading16.png'))
        self.builder.get_object('upload-limit-image').set_from_file(get_pixmap('seeding16.png'))

        client.register_event_handler('ConfigValueChangedEvent', self.config_value_changed)
        if client.connected():
            # We're connected so we need to get some values from the core
            self.__start()
        else:
            # Hide menu widgets because we're not connected to a host.
            for widget in self.hide_widget_list:
                self.builder.get_object(widget).hide()
Esempio n. 7
0
    def __init__(self):
        self.enabled = True
        self.status_icon = gtk.status_icon_new_from_pixbuf(read_icon_pixbuf)
        self.menu = gtk.Menu()

        self.menu_quit = gtk.MenuItem("Quit")
        self.menu_quit.connect_object("activate", quit_app, None)
        self.menu.append(self.menu_quit)
        self.menu_quit.show()

        self.status_icon.connect('popup-menu', self.menu_popup)
        self.status_icon.connect('activate', self.toggle_disable)
Esempio n. 8
0
 def __init__(self):
     super(GtkSystrayClient, self).__init__()
     
     self.cache = {}
     
     discharged_icon = pkg_resources.resource_filename(__name__, "resources/battery_discharging.png")
     charged_icon = pkg_resources.resource_filename(__name__, "resources/battery_charged.png")
     
     self.charged_icon = Image.open(charged_icon)
     self.discharged_icon = Image.open(discharged_icon)
     
     pixbuf = gdk.pixbuf_new_from_file(discharged_icon)
     self.statusicon = gtk.status_icon_new_from_pixbuf(pixbuf)
     self.statusicon.connect("query-tooltip", self.tooltip)
     self.statusicon.set_has_tooltip(True)
Esempio n. 9
0
    def __init__(self):
        super(Main, self).__init__()
        self.connect('delete-event', self.on_delete_event)
        self.set_title("Quick Capture")
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_default_size(400,10)
        self.set_geometry_hints(min_width=320, min_height=100)
        icon = os.path.join(Defaults.prog_root_dir,"Img/logo-tray.xpm")
        self.set_icon_from_file(icon)
        box1 = gtk.VBox(gtk.FALSE, 0)
        self.add(box1)
        box1.show()

        box2 = gtk.VBox(gtk.FALSE, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, gtk.TRUE, gtk.TRUE, 0)
        box2.show()
        table = gtk.Table(2, 3, gtk.FALSE)
        table.set_row_spacing(0, 2)
        table.set_col_spacing(0, 2)
        box2.pack_start(table, gtk.TRUE, gtk.TRUE, 0)
        table.show()
        # Create the GtkText widget
        self._text_window = gtk.Entry(50)
        self._text_window.set_editable(gtk.TRUE)
        self._text_window.connect("activate", self.on_ok_event)
        #frame = gtk.Frame()
        #frame.add(self._text_window)
        table.attach(self._text_window, 0, 1, 0, 1,
        gtk.EXPAND | gtk.SHRINK | gtk.FILL,
        gtk.EXPAND | gtk.SHRINK | gtk.FILL, 0, 0)
        self._text_window.show()
        button_box = gtk.HButtonBox()
        okbutton = gtk.Button("OK")
        okbutton.connect("clicked", self.on_ok_event)
        cancelbutton = gtk.Button("Cancel")
        cancelbutton.connect("clicked", self.on_cancel_event)
        button_box.add(okbutton)
        button_box.add(cancelbutton)
        box2.pack_end(button_box, gtk.FALSE, gtk.FALSE)
        okbutton.show()
        pixbuf = gdk.pixbuf_new_from_file_at_size(icon,25,25)
        statusicon = gtk.StatusIcon()
        statusicon = gtk.status_icon_new_from_pixbuf(pixbuf)
        statusicon.connect("activate",self.tray_activate)
        self.show_all()
        self.hide()
Esempio n. 10
0
 def __init__(self):
     gtk.Window.__init__(self)
     self.icon = gtk.status_icon_new_from_pixbuf(audio_volume_high)
     self.icon.connect('activate', self.show_win)
     self.icon.connect('popup-menu', self.menu)
     self.set_default_size(25, 200)
     self.set_decorated(False)
     self.connect('focus-out-event', self.focus_lost)
     self.scale_vol_control = gtk.VScale()
     self.scale_vol_control.set_digits(0)
     self.scale_vol_control.set_inverted(True)
     self.scale_vol_control.connect('format-value', self.Sound_Control)
     self.cheak = gtk.CheckButton(None)
     self.cheak.connect('toggled', self.toggled_mut)
     self.bo = gtk.VBox()
     self.bo.pack_start(self.scale_vol_control, True, True, 0)
     self.bo.pack_start(self.cheak, False, False, 0)
     self.add(self.bo)
Esempio n. 11
0
    def _init_gui(self):
        """
        Loads GTK resources and connects callbacks.
        """
        resource_xml = resources.alerter
        resource_xml.signal_autoconnect(self)
        
        self.settings = resource_xml.get_widget('settings-dialog')
        self._username_entry = resource_xml.get_widget('username_entry')
        self._key_entry = resource_xml.get_widget('key_entry')
        self._interval_entry = resource_xml.get_widget('interval_entry')

        self.popup_menu = resource_xml.get_widget('popup-menu')

        self.icon = gtk.status_icon_new_from_pixbuf(resources.tank)
        self.icon.connect('activate', self.on_systray_icon_activate)
        self.icon.connect('popup-menu', self.on_systray_icon_popup_menu, self.popup_menu)
        self.icon.set_visible(True)
Esempio n. 12
0
    def _init_gui(self):
        """
        Loads GTK resources and connects callbacks.
        """
        resource_xml = resources.alerter
        resource_xml.signal_autoconnect(self)

        self.settings = resource_xml.get_widget('settings-dialog')
        self._username_entry = resource_xml.get_widget('username_entry')
        self._key_entry = resource_xml.get_widget('key_entry')
        self._interval_entry = resource_xml.get_widget('interval_entry')

        self.popup_menu = resource_xml.get_widget('popup-menu')

        self.icon = gtk.status_icon_new_from_pixbuf(resources.tank)
        self.icon.connect('activate', self.on_systray_icon_activate)
        self.icon.connect('popup-menu', self.on_systray_icon_popup_menu,
                          self.popup_menu)
        self.icon.set_visible(True)
    def _startup_gui_1_main(self):
        self.log.debug('Create Main Window')
        self.mainWindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.mainWindow.set_position(gtk.WIN_POS_CENTER)
        self.mainWindow.set_size_request(1000, 500)
        self.mainWindow.set_title("FeedHamster (v%s)"%self.feedhamster.settings['version'])
        self.mainWindow.connect("delete_event", self.function_shutdown)

        picture = "./images/hamster.png"
        if os.path.isfile(picture):
            self.mainWindow.set_icon_from_file(picture)
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(picture,60,60)
            statusicon = gtk.StatusIcon()
            statusicon = gtk.status_icon_new_from_pixbuf(pixbuf)
            statusicon.connect("activate",self.gui_event_tray_clicked)
        else:
            self.log.warning('Picture Missing: %s'%os.path.abspath(picture))
        self.log.debug('Done')
        #Create Main Box
        self.log.debug('Create Main Box...')
        self.mainBox = gtk.VBox(False, 0)
        self.mainWindow.add(self.mainBox)
        self.mainBox.show()
        #Create Top Menu
        self.topBox = gtk.HBox(False, 0)
        self.mainBox.pack_start(self.topBox, False, False, 2)
        self.topBox.show()
        #Create Working Box
        self.log.debug('Create Working Box...')
        self.workBox = gtk.HBox(False, 0)
        self.mainBox.add(self.workBox)
        self.workBox.show()
        #Create Message Box
        self.log.debug('Create Message Box...')
        self.messBox = gtk.VBox(False, 0)
        self.workBox.pack_end(self.messBox, True, True, 0)
        self.messBox.show()
        #Create Botton Box
        self.log.debug('Create Message Box...')
        self.bottonBox = gtk.HBox(False, 0)
        self.mainBox.pack_end(self.bottonBox, False, False, 2)
        self.bottonBox.show()
 def __init_gtk(self):
     self.__menu = gtk.Menu()
     #view in main window checkbox
     view_browser_checkbox = gtk.CheckMenuItem(_("_View Main Window"))
     view_browser_checkbox.set_active(self.__view_manager.get_browser( \
                                                         ).is_shown())
     self.__signal_handler = view_browser_checkbox.connect('activate',
                                                    self.__toggle_browser)
     self.__view_manager.get_browser().connect('visibility-toggled',
                                             self.__on_browser_toggled,
                                             view_browser_checkbox)
     self.__menu.append(view_browser_checkbox)
     #add "new task"
     menuItem = gtk.ImageMenuItem(gtk.STOCK_ADD)
     menuItem.get_children()[0].set_label(_('Add _New Task'))
     menuItem.connect('activate', self.__open_task)
     self.__menu.append(menuItem)
     #quit item
     menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
     menuItem.connect('activate', self.__view_manager.close_browser)
     self.__menu.append(menuItem)
     self.__menu.show_all()
     #separator (it's intended to be after show_all)
     self.__task_separator = gtk.SeparatorMenuItem()
     self.__task_separator.show()
     self.__menu.append(self.__task_separator)
     self.__menu_top_length = len(self.__menu)
     if self.__indicator:
         self.__indicator.set_menu(self.__menu)
         self.__indicator.set_status(appindicator.STATUS_ACTIVE)
     else:
         print "ELSE?"
         icon = gtk.gdk.pixbuf_new_from_file_at_size(DATA_DIR + \
                             "/icons/hicolor/16x16/apps/gtg.png", 16, 16)
         self.status_icon = gtk.status_icon_new_from_pixbuf(icon)
         self.status_icon.set_tooltip("Getting Things Gnome!")
         self.status_icon.set_visible(True)
         self.status_icon.connect('activate', self.__toggle_browser)
         self.status_icon.connect('popup-menu', \
                                  self.__on_icon_popup, \
                                  self.__menu)
Esempio n. 15
0
    def __init__(self,
                 file=None,
                 fraction=0.0,
                 fg_color=(0, 0, 0),
                 bg_color=(1, 1, 1)):
        """
        Constructor.
        """

        super(TrayIcon, self).__init__()  # Call constructor of super-class

        # Initialize private variables
        self._fraction = fraction
        self._drawer = PieDrawer(fg_color, bg_color)

        # Initialize status icon
        self._file = file
        if file:
            self._status_icon = gtk.status_icon_new_from_file(file)
            self._from_file = True
        else:
            self._status_icon = gtk.status_icon_new_from_pixbuf(
                self.draw_to_pixbuf())
            self._from_file = False
Esempio n. 16
0
    def enable(self):
        """Enables the system tray icon."""
        self.builder = gtk.Builder()
        self.builder.add_from_file(deluge.common.resource_filename(
            "deluge.ui.gtkui", os.path.join("glade", "tray_menu.ui"))
        )

        self.builder.connect_signals({
            "on_menuitem_show_deluge_activate": self.on_menuitem_show_deluge_activate,
            "on_menuitem_add_torrent_activate": self.on_menuitem_add_torrent_activate,
            "on_menuitem_pause_all_activate": self.on_menuitem_pause_all_activate,
            "on_menuitem_resume_all_activate": self.on_menuitem_resume_all_activate,
            "on_menuitem_quit_activate": self.on_menuitem_quit_activate,
            "on_menuitem_quitdaemon_activate": self.on_menuitem_quitdaemon_activate
        })

        self.tray_menu = self.builder.get_object("tray_menu")

        if appindicator and self.config["enable_appindicator"]:
            log.debug("Enabling the Application Indicator..")
            self.indicator = appindicator.Indicator (
                "deluge", "deluge", appindicator.CATEGORY_APPLICATION_STATUS)
            # Pass the menu to the Application Indicator
            self.indicator.set_menu(self.tray_menu)

            # Make sure the status of the Show Window MenuItem is correct
            self._sig_win_hide = self.window.window.connect("hide", self._on_window_hide)
            self._sig_win_show = self.window.window.connect("show", self._on_window_show)
            if self.window.visible():
                self.builder.get_object("menuitem_show_deluge").set_active(True)
            else:
                self.builder.get_object("menuitem_show_deluge").set_active(False)

            # Show the Application Indicator
            self.indicator.set_status(appindicator.STATUS_ACTIVE)

        else:
            log.debug("Enabling the system tray icon..")
            if deluge.common.windows_check() or deluge.common.osx_check():
                self.tray = gtk.status_icon_new_from_pixbuf(common.get_logo(32))
            else:
                try:
                    self.tray = gtk.status_icon_new_from_icon_name("deluge")
                except:
                    log.warning("Update PyGTK to 2.10 or greater for SystemTray..")
                    return

            self.tray.connect("activate", self.on_tray_clicked)
            self.tray.connect("popup-menu", self.on_tray_popup)

            # For some reason these icons do not display in appindicator
            self.builder.get_object("download-limit-image").set_from_file(
                deluge.common.get_pixmap("downloading16.png"))
            self.builder.get_object("upload-limit-image").set_from_file(
                deluge.common.get_pixmap("seeding16.png"))

        client.register_event_handler("ConfigValueChangedEvent", self.config_value_changed)
        if client.connected():
            # We're connected so we need to get some values from the core
            self.__start()
        else:
            # Hide menu widgets because we're not connected to a host.
            for widget in self.hide_widget_list:
                self.builder.get_object(widget).hide()
Esempio n. 17
0
def StatusIcon(title):
    statusicon = gtk.status_icon_new_from_pixbuf(get_icon_pixbuf())
    statusicon.set_tooltip(title)
    return statusicon
Esempio n. 18
0
  open_item.connect_object("activate", open_app, "Open App")
  close_item.connect_object("activate", close_app, "Close App")
  #Show the menu items
  open_item.show()
  close_item.show()

  #Popup the menu
  menu.popup(None, None, None, event_button, event_time)

def on_right_click(data, event_button, event_time):
  #make_menu(event_button, event_time)
  tumblrListView.tumblrListView()

def on_left_click(event):
  print "Showww!"
  show_window()


if __name__ == '__main__':
  file = open("resources/ticon.png", "rb")
  binary = file.read()
  loader = gtk.gdk.PixbufLoader("png")
  loader.write(binary)
  loader.close()
  pixbuf = loader.get_pixbuf()
  #icon = gtk.status_icon_new_from_stock(gtk.STOCK_ABOUT)
  icon  = gtk.status_icon_new_from_pixbuf(pixbuf)
  icon.connect('popup-menu', on_right_click)
  icon.connect('activate', on_left_click)
  gtk.main()
Esempio n. 19
0
 def __init_trayicon(self):
     pixbuf = iconmgr.get_pixbuf('ppdict', gtk.ICON_SIZE_SMALL_TOOLBAR)
     self.trayicon = gtk.status_icon_new_from_pixbuf(pixbuf)
     self.trayicon.connect('popup-menu', self._tryicon_menu_popup)
     self.trayicon.connect('activate', self._menuitem_resume_activated)
     self.set_tray(prefs.getbool('tray'))
Esempio n. 20
0
    def enable(self):
        """Enables the system tray icon."""
        self.builder = gtk.Builder()
        self.builder.add_from_file(
            deluge.common.resource_filename(
                "deluge.ui.gtkui", os.path.join("glade", "tray_menu.ui")))

        self.builder.connect_signals({
            "on_menuitem_show_deluge_activate":
            self.on_menuitem_show_deluge_activate,
            "on_menuitem_add_torrent_activate":
            self.on_menuitem_add_torrent_activate,
            "on_menuitem_pause_all_activate":
            self.on_menuitem_pause_all_activate,
            "on_menuitem_resume_all_activate":
            self.on_menuitem_resume_all_activate,
            "on_menuitem_quit_activate":
            self.on_menuitem_quit_activate,
            "on_menuitem_quitdaemon_activate":
            self.on_menuitem_quitdaemon_activate
        })

        self.tray_menu = self.builder.get_object("tray_menu")

        if appindicator and self.config["enable_appindicator"]:
            log.debug("Enabling the Application Indicator..")
            self.indicator = appindicator.Indicator(
                "deluge", "deluge", appindicator.CATEGORY_APPLICATION_STATUS)
            try:
                self.indicator.set_property("title", _("Deluge"))
            except TypeError:
                # Catch 'title' property error for previous appindicator versions
                pass
            # Pass the menu to the Application Indicator
            self.indicator.set_menu(self.tray_menu)

            # Make sure the status of the Show Window MenuItem is correct
            self._sig_win_hide = self.window.window.connect(
                "hide", self._on_window_hide)
            self._sig_win_show = self.window.window.connect(
                "show", self._on_window_show)
            if self.window.visible():
                self.builder.get_object("menuitem_show_deluge").set_active(
                    True)
            else:
                self.builder.get_object("menuitem_show_deluge").set_active(
                    False)

            # Show the Application Indicator
            self.indicator.set_status(appindicator.STATUS_ACTIVE)

        else:
            log.debug("Enabling the system tray icon..")
            if deluge.common.windows_check() or deluge.common.osx_check():
                self.tray = gtk.status_icon_new_from_pixbuf(
                    common.get_logo(32))
            else:
                try:
                    self.tray = gtk.status_icon_new_from_icon_name("deluge")
                except:
                    log.warning(
                        "Update PyGTK to 2.10 or greater for SystemTray..")
                    return

            self.tray.connect("activate", self.on_tray_clicked)
            self.tray.connect("popup-menu", self.on_tray_popup)

        self.builder.get_object("download-limit-image").set_from_file(
            deluge.common.get_pixmap("downloading16.png"))
        self.builder.get_object("upload-limit-image").set_from_file(
            deluge.common.get_pixmap("seeding16.png"))

        client.register_event_handler("ConfigValueChangedEvent",
                                      self.config_value_changed)
        if client.connected():
            # We're connected so we need to get some values from the core
            self.__start()
        else:
            # Hide menu widgets because we're not connected to a host.
            for widget in self.hide_widget_list:
                self.builder.get_object(widget).hide()
Esempio n. 21
0
  open_item.connect_object("activate", open_app, "Open App")
  close_item.connect_object("activate", close_app, "Close App")
  #Show the menu items
  open_item.show()
  close_item.show()

  #Popup the menu
  menu.popup(None, None, None, event_button, event_time)

def on_right_click(data, event_button, event_time):
  #make_menu(event_button, event_time)
  show_window()

def on_left_click(event):
  print "Showww!"
  show_window()


if __name__ == '__main__':
  file = open("resources/cicon.png", "rb")
  binary = file.read()
  loader = gtk.gdk.PixbufLoader("png")
  loader.write(binary)
  loader.close()
  pixbuf = loader.get_pixbuf()
  #icon = gtk.status_icon_new_from_stock(gtk.STOCK_ABOUT)
  icon  = gtk.status_icon_new_from_pixbuf(pixbuf)
  icon.connect('popup-menu', on_right_click)
  icon.connect('activate', on_left_click)
  gtk.main()
Esempio n. 22
0
    def enable(self):
        """Enables the system tray icon."""
        self.builder = Builder()
        self.builder.add_from_file(
            resource_filename('deluge.ui.gtkui',
                              os.path.join('glade', 'tray_menu.ui')))

        self.builder.connect_signals(self)

        self.tray_menu = self.builder.get_object('tray_menu')

        if appindicator and self.config['enable_appindicator']:
            log.debug('Enabling the Application Indicator...')
            self.indicator = appindicator.Indicator(
                'deluge', 'deluge', appindicator.CATEGORY_APPLICATION_STATUS)
            try:
                self.indicator.set_property('title', _('Deluge'))
            except TypeError:
                # Catch 'title' property error for previous appindicator versions
                pass
            # Pass the menu to the Application Indicator
            self.indicator.set_menu(self.tray_menu)

            # Make sure the status of the Show Window MenuItem is correct
            self._sig_win_hide = self.mainwindow.window.connect(
                'hide', self._on_window_hide)
            self._sig_win_show = self.mainwindow.window.connect(
                'show', self._on_window_show)
            if self.mainwindow.visible():
                self.builder.get_object('menuitem_show_deluge').set_active(
                    True)
            else:
                self.builder.get_object('menuitem_show_deluge').set_active(
                    False)

            # Show the Application Indicator
            self.indicator.set_status(appindicator.STATUS_ACTIVE)

        else:
            log.debug('Enabling the system tray icon..')
            if windows_check() or osx_check():
                self.tray = status_icon_new_from_pixbuf(get_logo(32))
            else:
                self.tray = status_icon_new_from_icon_name('deluge-panel')

            self.tray.connect('activate', self.on_tray_clicked)
            self.tray.connect('popup-menu', self.on_tray_popup)

        self.builder.get_object('download-limit-image').set_from_file(
            get_pixmap('downloading16.png'))
        self.builder.get_object('upload-limit-image').set_from_file(
            get_pixmap('seeding16.png'))

        client.register_event_handler('ConfigValueChangedEvent',
                                      self.config_value_changed)
        if client.connected():
            # We're connected so we need to get some values from the core
            self.__start()
        else:
            # Hide menu widgets because we're not connected to a host.
            for widget in self.hide_widget_list:
                self.builder.get_object(widget).hide()