Beispiel #1
0
 def _add_container(self, container, container_widget):
     if self.NOTEBOOK:
         hbox = gtk.HBox(spacing = 8)       
         hbox.pack_start(gtk.image_new_from_pixbuf(container.get_icon()), False, False)
         lbl = gtk.Label(container.get_name())
         hbox.pack_start(lbl, False, False, 4)
         hbox.show_all()
         container_widget.set_border_width(8)
         widget = container_widget
         tab_index = self.notebook.append_page(container_widget, hbox)
         self.tabs[container] = tab_index
         self.notebook.show_all()
     else:
         container_box = gtk.VBox(spacing = 8)
         widget = container_box
         if self.MULTIPLE_VIEW:
             title_box = gtk.HBox(spacing = 8)                        
             title_box.pack_start(gtk.image_new_from_pixbuf(container.get_icon()), False, False)
             lbl = gtk.Label(container.get_name())
             title_box.pack_start(lbl, False, False, 4)
             title_box.show_all()
             container_box.pack_start(title_box, False, False)
         #config_widget = config.get_config_widget()
         container_box.pack_start(container_widget, True, True)
         container_box.pack_start(gtk.HSeparator(), False, False)
         self.containers_box.pack_start(container_box)
         self.containers_box.show_all()
     self.container_widgets[container] = widget
Beispiel #2
0
def to_gtk(entries):
    tree = defaultdict(gtk.Menu)
    for entry in sorted(entries, key=attrgetter('name')):
        category = entry.recommended_category
        if not category:
            continue
        item = None
        if entry.icon:
            icon = lookup_icon(entry.icon)
            if icon is not None:
                item = gtk.ImageMenuItem()
                item.set_image(gtk.image_new_from_pixbuf(icon))
                item.set_label(entry.name)
        if item is None:
            item = gtk.MenuItem(entry.name)
        item.connect('activate', activate_entry, entry)
        item.show()
        tree[category].append(item)
    menu = gtk.Menu()
    for category, submenu in sorted(tree.iteritems(), key=itemgetter(0)):
        icon = None
        if category in CATEGORY_ICONS:
            icon = lookup_icon(CATEGORY_ICONS[category])
        item = gtk.ImageMenuItem(category)
        if icon is not None:
            item.set_image(gtk.image_new_from_pixbuf(icon))
        item.set_submenu(submenu)
        item.show()
        menu.append(item)
    menu.show()
    return menu
Beispiel #3
0
    def get_icon(self, caps, contact=None):
        if not caps:
            return gtk.image_new_from_pixbuf(self.default_pixbuf), _('Unknown')

        client_name = _('Unknown')
        caps_from_jid = self.check_jid(contact.jid)
        if caps_from_jid:
            caps = caps_from_jid

        caps_ = caps.split('#')[0].split()
        if caps_:
            client_icon = clients.get(caps_[0].split()[0], (None,))[0]
            client_name = clients.get(caps_[0].split()[0], ('', _('Unknown')))[1]
        else:
            client_icon = None
        if client_name == _('Unknown'):
            identities = contact.client_caps._lookup_in_cache(
                gajim.caps_cache.capscache).identities
            if identities:
                client_name = identities[0].get('name', _('Unknown'))
                client_icon = clients.get(client_name.split()[0], (None,))[0]

        if not client_icon:
            return gtk.image_new_from_pixbuf(self.default_pixbuf), _('Unknown')
        else:
            icon_path = os.path.join(self.local_file_path('icons'),
                client_icon)
            if icon_path in self.icon_cache:
                return gtk.image_new_from_pixbuf(self.icon_cache[icon_path]), \
                    client_name
            else:
                pb = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 16, 16)
                self.icon_cache[icon_path] = pb
                return gtk.image_new_from_pixbuf(pb), client_name
Beispiel #4
0
 def tree2_button_press_event(self, treeview, event):
  """Fires the tree2 menu popup. This one handles entries options."""
  if event.button == 3:
   x = int(event.x)
   y = int(event.y)
   time = event.time
   pthinfo = treeview.get_path_at_pos(x, y)
   if pthinfo is not None:
    path, col, cellx, celly = pthinfo
    treeview.grab_focus()
    treeview.set_cursor(path, col, 0)

    tree_menu = gtk.Menu()
    # Create the menu items
    toggle_leido_item = gtk.ImageMenuItem("Alternar leído/no leído")
    icon = toggle_leido_item.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)
    toggle_leido_item.set_image(gtk.image_new_from_pixbuf(icon))
    toggle_todos_leido_item = gtk.ImageMenuItem("Alternar leído/no leído (todos)")
    icon = toggle_todos_leido_item.render_icon(gtk.STOCK_SELECT_ALL, gtk.ICON_SIZE_BUTTON)
    toggle_todos_leido_item.set_image(gtk.image_new_from_pixbuf(icon))
    # Add them to the menu
    tree_menu.append(toggle_leido_item)
    tree_menu.append(toggle_todos_leido_item)
    # Attach the callback functions to the activate signal
    #toggle_leido_item.connect_object("activate", self.toggle_leido, None)
    #toggle_todos_leido_item.connect_object("activate", self.callback, None)
    toggle_leido_item.connect("activate", self.toggle_leido, 'single')
    toggle_todos_leido_item.connect("activate", self.toggle_leido, 'all')
    tree_menu.show_all()
    tree_menu.popup(None, None, None, event.button, event.get_time())
   return True
Beispiel #5
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.safe_gtk_pixbuf_load(contact.picture,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
            else:
                picture = gtk.image_new_from_animation(animation)

        else:
            pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Beispiel #6
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.gtk_pixbuf_load(contact.picture,
                        (self.avatar_size, self.avatar_size))
                if bool(contact.blocked)==True:
                    pixbufblock=utils.gtk_pixbuf_load(gui.theme.blocked_overlay)
                    utils.simple_images_overlap(pix,pixbufblock,-pixbufblock.props.width,-pixbufblock.props.width)
                picture = gtk.image_new_from_pixbuf(pix)
            else:
                picture = gtk.image_new_from_animation(animation)

        else:
            pix = utils.gtk_pixbuf_load(gui.theme.user,
                        (self.avatar_size, self.avatar_size))
            if bool(contact.blocked)==True:
                pixbufblock=utils.gtk_pixbuf_load(gui.theme.blocked_overlay)
                utils.simple_images_overlap(pix,pixbufblock,-pixbufblock.props.width,-pixbufblock.props.width)
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
def gen(x, y):
    if y >= x:
        pixbuf = draw_pill_pixbuf(str(x), str(y))
        return gtk.image_new_from_pixbuf(pixbuf)
    else:
        pixbuf = draw_pill_pixbuf('0', '0')
        return gtk.image_new_from_pixbuf(pixbuf)
Beispiel #8
0
 def create_trayicon(self):
  """Creates the TrayIcon of the app and its popup menu."""
  self.statusicon = gtk.StatusIcon()
  self.statusicon.set_tooltip('Náufrago!')
  self.statusicon.set_from_file('Viking_Longship.svg')
  self.statusicon.set_visible(True)
  self.window.connect('hide', self.statusicon_activate) # Hide window associated
  self.statusicon.connect('activate', self.statusicon_activate) # StatusIcon associated

  # StatusIcon popup menu
  self.statusicon_menu = gtk.Menu()
  # Create the menu items
  update_item = gtk.ImageMenuItem("Actualizar")
  icon = update_item.render_icon(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)
  update_item.set_image(gtk.image_new_from_pixbuf(icon))
  quit_item = gtk.ImageMenuItem("Salir")
  icon = quit_item.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_BUTTON)
  quit_item.set_image(gtk.image_new_from_pixbuf(icon))
  # Add them to the menu
  self.statusicon_menu.append(update_item)
  self.statusicon_menu.append(quit_item)
  # Attach the callback functions to the activate signal
  update_item.connect("activate", self.update_all_feeds)
  quit_item.connect("activate", self.delete_event)
  self.statusicon_menu.show_all()
  self.statusicon.connect('popup-menu', self.statusicon_popup_menu)
Beispiel #9
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            # TODO: This could be handled in AvatarManager in the same
            # way as avatars from the Avatar class
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.gtk_pixbuf_load(gui.theme.image_theme.user,
                        (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.gtk_pixbuf_load(contact.picture,
                        (self.avatar_size, self.avatar_size))

                if bool(contact.blocked):
                    pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)
                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)

                picture = gtk.image_new_from_pixbuf(pix)
            else:
                myanimation = utils.simple_animation_scale(contact.picture,
                                                           self.avatar_size,
                                                           self.avatar_size)

                if bool(contact.blocked):
                    pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)
                    static_image = myanimation.get_static_image()
                    pix = static_image.scale_simple(self.avatar_size,
                                                    self.avatar_size,
                                                    gtk.gdk.INTERP_BILINEAR)

                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)

                    picture = gtk.image_new_from_pixbuf(pix)
                else:
                    picture = gtk.image_new_from_animation(myanimation)
        else:
            pix = utils.gtk_pixbuf_load(gui.theme.image_theme.user,
                        (self.avatar_size, self.avatar_size))

            if bool(contact.blocked):
                pixbufblock=utils.gtk_pixbuf_load(gui.theme.image_theme.blocked_overlay)
                utils.simple_images_overlap(pix, pixbufblock,
                                            -pixbufblock.props.width,
                                            -pixbufblock.props.width)

            picture = gtk.image_new_from_pixbuf(pix)

        return picture
 def show(self):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     if self.appNum == 0:
         if (getDefaultLanguage() == "default"):
             paddingX = 10
         else:
             paddingX = 45
         
         notifyBox = gtk.VBox()
         notifyAlign = gtk.Alignment()
         notifyAlign.set(0.5, 0.5, 0.0, 0.0)
         notifyAlign.add(notifyBox)
         self.box.pack_start(notifyAlign)
         
         tipImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/%s/downloadTip.png" % (getDefaultLanguage())))
         tipAlign = gtk.Alignment()
         tipAlign.set_padding(0, 0, paddingX, 0)
         tipAlign.add(tipImage)
         notifyBox.pack_start(tipAlign)
         
         penguinImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/penguin.png"))
         penguinAlign = gtk.Alignment()
         penguinAlign.set_padding(0, 0, 0, paddingX)
         penguinAlign.add(penguinImage)
         notifyBox.pack_start(penguinAlign)
         
         self.box.show_all()
     else:
         # Get application list.
         appList = self.getListFunc(
             (self.pageIndex - 1) * self.defaultRows,
             min(self.pageIndex * self.defaultRows, self.appNum)
             )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
         
         # Show all.
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             PAGE_DOWNLOAD_MANAGE, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList))
         
     # Scroll ScrolledWindow to top after render.
     utils.scrollToTop(self.scrolledwindow)
 def show(self):
     '''Show application view.'''
     # Remove child widgets first.
     utils.containerRemoveAll(self.box)
     self.itemDict.clear()
     
     if self.appNum == 0:
         if (getDefaultLanguage() == "default"):
             paddingX = 10
         else:
             paddingX = 45
         
         notifyBox = gtk.VBox()
         notifyAlign = gtk.Alignment()
         notifyAlign.set(0.5, 0.5, 0.0, 0.0)
         notifyAlign.add(notifyBox)
         self.box.pack_start(notifyAlign)
         
         tipImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/%s/downloadTip.png" % (getDefaultLanguage())))
         tipAlign = gtk.Alignment()
         tipAlign.set_padding(0, 0, paddingX, 0)
         tipAlign.add(tipImage)
         notifyBox.pack_start(tipAlign)
         
         penguinImage = gtk.image_new_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file("../icon/tips/penguin.png"))
         penguinAlign = gtk.Alignment()
         penguinAlign.set_padding(0, 0, 0, paddingX)
         penguinAlign.add(penguinImage)
         notifyBox.pack_start(penguinAlign)
         
         self.box.show_all()
     else:
         # Get application list.
         appList = self.getListFunc(
             (self.pageIndex - 1) * self.defaultRows,
             min(self.pageIndex * self.defaultRows, self.appNum)
             )
         
         # Create application view.
         self.box.pack_start(self.createAppList(appList))
         
         # Create index view.
         indexbar = self.createIndexbar()
         if not indexbar == None:
             self.box.pack_start(indexbar)
         
         # Show all.
         self.box.show_all()
         
         # Request vote data.
         self.fetchVoteCallback(
             PAGE_DOWNLOAD_MANAGE, 
             map (lambda appInfo: utils.getPkgName(appInfo.pkg), appList))
         
     # Scroll ScrolledWindow to top after render.
     utils.scrollToTop(self.scrolledwindow)
def getPkgIcon(pkg, iconWidth=32, iconHeight=32):
    '''Get package icon.'''
    iconPath = "../pkgData/AppIcon/" + pkg.name + ".png"
    if os.path.exists (iconPath):
        return gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file_at_size(iconPath, iconWidth, iconHeight))
    else:
        return gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file_at_size(
                "../theme/default/image/icon/appIcon.ico", 
                iconWidth, iconHeight))
Beispiel #13
0
    def draw_title(self):
        eventbox = gtk.EventBox()
        eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('white'))
        self.pack_start(eventbox, False, False, 0)

        vbox = gtk.VBox()
        eventbox.add(vbox)

        align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        align.set_padding(5, 5, 5, 5)
        vbox.pack_start(align)

        hbox = gtk.HBox(False, 6)
        align.add(hbox)

        inner_vbox = gtk.VBox(False, 6)
        hbox.pack_start(inner_vbox)

        align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        inner_vbox.pack_start(align, False, False, 0)

        inner_hbox = gtk.HBox(False, 0)
        align.add(inner_hbox)

        name = gtk.Label()
        name.set_markup('<b><big>%s</big></b>' % self.__title__)
        name.set_alignment(0, 0.5)
        inner_hbox.pack_start(name, False, False, 0)

        if self.__url__:
            more = gtk.Label()
            more.set_markup('<a href="%s">%s</a>' % (self.__url__, self.__urltitle__))
            inner_hbox.pack_end(more, False, False, 0)

        desc = gtk.Label(self.__desc__)
        desc.set_ellipsize(pango.ELLIPSIZE_END)
        desc.set_alignment(0, 0.5)
        inner_vbox.pack_start(desc, False, False, 0)

        if self.__icon__:
            if type(self.__icon__) != list:
                if self.__icon__.endswith('.png'):
                    icon_path = os.path.join(DATA_DIR, 'pixmaps', self.__icon__)
                    image = gtk.image_new_from_file(icon_path)
                else:
                    pixbuf = icon.get_from_name(self.__icon__, size=48)
                    image = gtk.image_new_from_pixbuf(pixbuf)
            else:
                pixbuf = icon.get_from_list(self.__icon__, size=48)
                image = gtk.image_new_from_pixbuf(pixbuf)

            image.set_alignment(0, 0)
            image.set_padding(5, 5)
            hbox.pack_end(image, False, False, 0)

        vbox.pack_start(gtk.HSeparator(), False, False, 0)
Beispiel #14
0
 def get_icon(self, icon_name):
     try:
        theme = gtk.icon_theme_get_default()
        pixbuf = theme.load_icon(icon_name.split('.')[0],ICON_SIZE, 0)
        return gtk.image_new_from_pixbuf(pixbuf)
     except:
        if not icon_name or not os.path.exists(icon_name):
            pixbuf = theme.load_icon("exec",ICON_SIZE, 0)
            return gtk.image_new_from_pixbuf(pixbuf)
        return gtk.image_new_from_file (icon_name)
Beispiel #15
0
    def draw_title(self):
        style = gtk.MenuItem().rc_get_style()

        vbox = gtk.VBox()
        vbox.set_style(style)
        self.pack_start(vbox, False, False, 0)

        align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        align.set_padding(5, 5, 5, 5)
        vbox.pack_start(align)

        hbox = gtk.HBox(False, 6)
        align.add(hbox)

        inner_vbox = gtk.VBox(False, 6)
        hbox.pack_start(inner_vbox)

        align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        inner_vbox.pack_start(align, False, False, 0)

        inner_hbox = gtk.HBox(False, 0)
        align.add(inner_hbox)

        name = gtk.Label()
        name.set_markup('<b><big>%s</big></b>' % self.__title__)
        name.set_alignment(0, 0.5)
        inner_hbox.pack_start(name, False, False, 0)

        if self.__url__:
            more = gtk.Label()
            more.set_markup('<a href="%s">%s</a>' %
                            (self.__url__, self.__urltitle__))
            inner_hbox.pack_end(more, False, False, 0)

        desc = gtk.Label(self.__desc__)
        desc.set_ellipsize(pango.ELLIPSIZE_END)
        desc.set_alignment(0, 0.5)
        inner_vbox.pack_start(desc, False, False, 0)

        if self.__icon__:
            if type(self.__icon__) != list:
                if self.__icon__.endswith('.png'):
                    icon_path = os.path.join(DATA_DIR, 'pixmaps',
                                             self.__icon__)
                    image = gtk.image_new_from_file(icon_path)
                else:
                    pixbuf = icon.get_from_name(self.__icon__, size=48)
                    image = gtk.image_new_from_pixbuf(pixbuf)
            else:
                pixbuf = icon.get_from_list(self.__icon__, size=48)
                image = gtk.image_new_from_pixbuf(pixbuf)

            image.set_alignment(0, 0)
            image.set_padding(5, 5)
            hbox.pack_end(image, False, False, 0)
Beispiel #16
0
    def tree_button_press_event(self, treeview, event):
        """Fires the tree menu popup. This handles the feed list options.
  Showing feed entries is handled through *tree_row_selection* handler
  callbacked by the *change* event."""
        if event.button == 3:
            x = int(event.x)
            y = int(event.y)
            time = event.time
            pthinfo = treeview.get_path_at_pos(x, y)
            if pthinfo is not None:
                path, col, cellx, celly = pthinfo
                treeview.grab_focus()
                treeview.set_cursor(path, col, 0)

                tree_menu = gtk.Menu()
                # Create the menu items
                new_feed_item = gtk.ImageMenuItem("Nuevo feed")
                icon = new_feed_item.render_icon(gtk.STOCK_FILE,
                                                 gtk.ICON_SIZE_BUTTON)
                new_feed_item.set_image(gtk.image_new_from_pixbuf(icon))
                new_category_item = gtk.ImageMenuItem("Nueva categoría")
                icon = new_category_item.render_icon(gtk.STOCK_DIRECTORY,
                                                     gtk.ICON_SIZE_BUTTON)
                new_category_item.set_image(gtk.image_new_from_pixbuf(icon))
                delete_feed_item = gtk.ImageMenuItem("Eliminar feed")
                icon = delete_feed_item.render_icon(gtk.STOCK_CLEAR,
                                                    gtk.ICON_SIZE_BUTTON)
                delete_feed_item.set_image(gtk.image_new_from_pixbuf(icon))
                delete_category_item = gtk.ImageMenuItem("Eliminar categoría")
                icon = delete_category_item.render_icon(
                    gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
                delete_category_item.set_image(gtk.image_new_from_pixbuf(icon))
                edit_item = gtk.ImageMenuItem("Editar")
                icon = edit_item.render_icon(gtk.STOCK_EDIT,
                                             gtk.ICON_SIZE_BUTTON)
                edit_item.set_image(gtk.image_new_from_pixbuf(icon))
                # Add them to the menu
                tree_menu.append(new_feed_item)
                tree_menu.append(new_category_item)
                tree_menu.append(delete_feed_item)
                tree_menu.append(delete_category_item)
                tree_menu.append(edit_item)
                # Attach the callback functions to the activate signal
                new_feed_item.connect_object("activate", self.add_feed, None)
                new_category_item.connect_object("activate", self.add_category,
                                                 None)
                delete_feed_item.connect_object("activate", self.delete_feed,
                                                None)
                delete_category_item.connect_object("activate",
                                                    self.delete_category, None)
                edit_item.connect_object("activate", self.edit, None)
                tree_menu.show_all()
                tree_menu.popup(None, None, None, event.button,
                                event.get_time())
            return True
def getPkgIcon(pkg, iconWidth=32, iconHeight=32):
    '''Get package icon.'''
    iconPath = "../pkgData/AppIcon/" + pkg.name + ".png"
    if os.path.exists(iconPath):
        return gtk.image_new_from_pixbuf(
            gtk.gdk.pixbuf_new_from_file_at_size(iconPath, iconWidth,
                                                 iconHeight))
    else:
        return gtk.image_new_from_pixbuf(
            gtk.gdk.pixbuf_new_from_file_at_size(
                "../theme/default/image/icon/appIcon.ico", iconWidth,
                iconHeight))
Beispiel #18
0
    def __custom_status(self, success, failure = None):
        icon = success and '/success.png' or '/failure.png'
        image = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file(ICON_PATH + icon).scale_simple(28, 28, gtk.gdk.INTERP_HYPER))
        frame = self.status_bar.get_children()[0]
        hbox = self.status_bar.get_children()[0].child
        label = self.status_bar.get_children()[0].child.get_children()[0]
        label.set_ellipsize(False)
        frame.hide_all()
        hbox.remove(label)
        hbox.pack_start(image, False, False)
        hbox.pack_start(label, True, True)
        message = success and '<span font_desc="belgrano 10"> Message has been <span foreground="#3BB048"><b>submitted successfully</b></span></span>'\
or '<span font_desc="belgrano 10"><span foreground="#FF0000"><b> Submission failed</b></span> to </span>'
        self.status_bar.get_children()[0].child.get_children()[1].set_markup(message)
        tooltip = '<span font_desc="belgrano 10" foreground="#%s"><b>Submission %s</b></span>'
        tooltip_status = success and ('3BB048', 'Successful') or ('FF0000', 'Failure')
        self.status_bar.get_children()[0].child.get_children()[1].set_tooltip_markup(tooltip % tooltip_status)
        if not success:
            combo = gtk.combo_box_new_text()
            combo.child.modify_font(pango.FontDescription('CrashNumberingGothic'))
            combo.set_size_request(-1, 28)
            for number in failure:
                combo.append_text(str(number))
            combo.set_active(0)
            hbox.pack_start(combo, False, False)
            relog = gtk.EventBox()
            relog.add(gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file(ICON_PATH + '/refresh.png').scale_simple(28, 28, gtk.gdk.INTERP_HYPER)))
            relog.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#FFFFFF'))
            relog.set_tooltip_text('Retry by setting\n   new cookie')
            hbox.pack_start(relog, False, False)
            def set_cursor(unused_widget, unused_event):
                relog.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND2))
            def unset_cursor(unused_widget, unused_event):
                relog.window.set_cursor(None)
            def re_log_in(unused_widget, unused_event):
                from way2sms import login
                import time
                database = DataBase()
                user = database.get_default()
                thread.start_new_thread(login, (str(user[0]), user[1], True))
                database.close()
                time.sleep(3.4)
                self.__generalize_status_bar()
                self.__push_status_message('<span font_desc="belgrano 10"><b>  Try to <span foreground="#0000FF">re send</span> once more</b></span>')
                return
            relog.connect('enter_notify_event', set_cursor)
            relog.connect('leave_notify_event', unset_cursor)
            relog.connect('button_release_event', re_log_in)
        alignment = gtk.Alignment(0, 0, 0, 1)
        frame.remove(hbox)
        frame.add(alignment)
        alignment.add(hbox)
        self.status_bar.show_all()
Beispiel #19
0
    def draw_title(self):
        style = gtk.MenuItem().rc_get_style()

        vbox = gtk.VBox()
        vbox.set_style(style)
        self.pack_start(vbox, False, False, 0)

        align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        align.set_padding(5, 5, 5, 5)
        vbox.pack_start(align)

        hbox = gtk.HBox(False, 6)
        align.add(hbox)

        inner_vbox = gtk.VBox(False, 6)
        hbox.pack_start(inner_vbox)

        align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
        inner_vbox.pack_start(align, False, False, 0)

        inner_hbox = gtk.HBox(False, 0)
        align.add(inner_hbox)

        name = gtk.Label()
        name.set_markup('<b><big>%s</big></b>' % self.__title__)
        name.set_alignment(0, 0.5)
        inner_hbox.pack_start(name, False, False, 0)

        if self.__url__:
            more = gtk.Label()
            more.set_markup('<a href="%s">%s</a>' % (self.__url__, self.__urltitle__))
            inner_hbox.pack_end(more, False, False, 0)

        desc = gtk.Label(self.__desc__)
        desc.set_ellipsize(pango.ELLIPSIZE_END)
        desc.set_alignment(0, 0.5)
        inner_vbox.pack_start(desc, False, False, 0)

        if self.__icon__:
            if type(self.__icon__) != list:
                if self.__icon__.endswith('.png'):
                    icon_path = os.path.join(DATA_DIR, 'pixmaps', self.__icon__)
                    image = gtk.image_new_from_file(icon_path)
                else:
                    pixbuf = icon.get_from_name(self.__icon__, size=48)
                    image = gtk.image_new_from_pixbuf(pixbuf)
            else:
                pixbuf = icon.get_from_list(self.__icon__, size=48)
                image = gtk.image_new_from_pixbuf(pixbuf)

            image.set_alignment(0, 0)
            image.set_padding(5, 5)
            hbox.pack_end(image, False, False, 0)
 def __make_playback_box(self, stream, index):
     process_id = int(stream['proplist']['application.process.id'])
     if process_id == os.getpid():
         return
     # if it has show mpris, then don't show sink_input
     if process_id in self.mpris_list:
         self.mpris_stream[process_id] = index
         self.stream_mpris[index] = process_id
         return
     icon_name, is_filtered = self.__white_list_check(stream, index)
     if is_filtered:
         return
     self.stream_list[index] = {}
     volume_max_percent = pypulse.MAX_VOLUME_VALUE * 100 / pypulse.NORMAL_VOLUME_VALUE
     if icon_name:
         if icon_name[0] == '/':
             try:
                 img = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file(
                     icon_name).scale_simple(16, 16, gtk.gdk.INTERP_TILES))
             except:
                 img = gtk.image_new_from_pixbuf(self.stream_icon)
         else:
             image_pixbuf = self.__get_pixbuf_from_icon_name(icon_name)
             if image_pixbuf:
                 img = gtk.image_new_from_pixbuf(image_pixbuf)
             else:
                 img = gtk.image_new_from_pixbuf(self.stream_icon)
                 #img = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
     else:
         img = gtk.image_new_from_pixbuf(self.stream_icon)
     img.set_size_request(16, 16)
     scale = HScalebar(show_value=False, format_value="%", value_min=0, value_max=volume_max_percent)
     scale.set_magnetic_values([(0, 5), (100, 5), (volume_max_percent, 5)])
     scale.set_size_request(90, 10)
     mute_button = SwitchButton(
         inactive_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"), 
         active_disable_dpixbuf=app_theme.get_pixbuf("toggle_button/inactive_normal.png"))
     hbox = gtk.HBox()
     hbox.pack_start(self.__make_align(img), False, False)
     hbox.pack_start(self.__make_align(scale, yalign=0.0, yscale=1.0, padding_left=5, padding_right=5, height=25), False, False)
     hbox.pack_start(self.__make_align(mute_button), False, False)
     self.stream_list[index]['scale'] = scale
     self.stream_list[index]['button'] = mute_button
     self.stream_list[index]['container'] = hbox
     self.stream_list[index]['process_id'] = process_id
     self.stream_list[index]['stream_id'] = index
     self.stream_process[process_id] = self.stream_list[index]
     self.__set_playback_status(stream, scale, mute_button)
     if stream['volume_writable']:
         scale.connect("value-changed", self.playback_stream_scale_changed_cb, index, mute_button)
         mute_button.connect("toggled", self.playback_stream_toggled_cb, index, scale)
     hbox.show_all()
     self.__app_vbox.pack_start(hbox, False, False)
Beispiel #21
0
    def set_icon_name(self, icon_name):
        """Sets the image

        Args:
          icon_name: Icon name of the image.
        Raises:
          GError: if the icon isn't present in icon theme.
        """
        it = gtk.icon_theme_get_default()
        pb = it.load_icon(icon_name, gtk.ICON_SIZE_MENU,
                          gtk.ICON_LOOKUP_FORCE_SVG)
        img = gtk.image_new_from_pixbuf(pb)
        self.set_image(gtk.image_new_from_pixbuf(pb))
Beispiel #22
0
    def _get_contact_pixbuf_or_default(self, contact):
        '''try to return a pixbuf of the user picture or the default
        picture
        '''
        if contact.picture:
            try:
                animation = gtk.gdk.PixbufAnimation(contact.picture)
            except gobject.GError:
                pix = utils.gtk_pixbuf_load(
                    gui.theme.user, (self.avatar_size, self.avatar_size))
                picture = gtk.image_new_from_pixbuf(pix)
                return picture

            if animation.is_static_image():
                pix = utils.gtk_pixbuf_load(
                    contact.picture, (self.avatar_size, self.avatar_size))
                if bool(contact.blocked):
                    pixbufblock = utils.gtk_pixbuf_load(
                        gui.theme.blocked_overlay)
                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)
                picture = gtk.image_new_from_pixbuf(pix)
            else:
                myanimation = utils.simple_animation_scale(
                    contact.picture, self.avatar_size, self.avatar_size)
                if bool(contact.blocked):
                    pixbufblock = utils.gtk_pixbuf_load(
                        gui.theme.blocked_overlay)
                    static_image = myanimation.get_static_image()
                    pix = static_image.scale_simple(self.avatar_size,
                                                    self.avatar_size,
                                                    gtk.gdk.INTERP_BILINEAR)
                    utils.simple_images_overlap(pix, pixbufblock,
                                                -pixbufblock.props.width,
                                                -pixbufblock.props.width)
                    picture = gtk.image_new_from_pixbuf(pix)
                else:
                    picture = gtk.image_new_from_animation(myanimation)
        else:
            pix = utils.gtk_pixbuf_load(gui.theme.user,
                                        (self.avatar_size, self.avatar_size))
            if bool(contact.blocked):
                pixbufblock = utils.gtk_pixbuf_load(gui.theme.blocked_overlay)
                utils.simple_images_overlap(pix, pixbufblock,
                                            -pixbufblock.props.width,
                                            -pixbufblock.props.width)
            picture = gtk.image_new_from_pixbuf(pix)

        return picture
Beispiel #23
0
 def friendships_add_thread(self, button, weibo, box):
     '''add friendships'''
     if weibo.friendships_create() is not None:
         gtk.gdk.threads_enter()
         button.destroy()
         if not default_locale.startswith("zh_"):
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed_en.png").get_pixbuf())
         else:
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed.png").get_pixbuf())
         button.show()
         box.pack_start(button, False, False)
         #button.set_label("已关注")
         gtk.gdk.threads_leave()
Beispiel #24
0
 def friendships_add_thread(self, button, weibo, box):
     '''add friendships'''
     if weibo.friendships_create() is not None:
         gtk.gdk.threads_enter()
         button.destroy()
         if not default_locale.startswith("zh_"):
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed_en.png").get_pixbuf())
         else:
             button = gtk.image_new_from_pixbuf(
                 app_theme.get_pixbuf("share/followed.png").get_pixbuf())
         button.show()
         box.pack_start(button, False, False)
         #button.set_label("已关注")
         gtk.gdk.threads_leave()
Beispiel #25
0
    def create_category(self, data):
        from base64 import b64decode
        button = gtk.ToggleButton(use_underline=False)
        button.set_can_focus(False)
        hbox = gtk.HBox()

        # load the image
        loader = gtk.gdk.PixbufLoader()
        loader.write(b64decode(data.get('icon', '')))
        pixbuf = loader.get_pixbuf()
        loader.close()
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.set_visible(True)

        # set the text
        label = gtk.Label(data.get('name', ''))
        label.set_visible(True)

        hbox.pack_start(image, False, False)
        hbox.pack_start(label, False, False, 5)
        hbox.show()
        button.set_name(label.get_label().lower())
        button.connect("button-press-event", self.select_category)
        button.add(hbox)
        return button
 def create_contents(self, container, i):
     """Create the widgets for showing the contents of the Aux_seats window."""
     container.eb = gtk.EventBox()
     container.eb.connect("button_press_event", self.button_press_cb)
     container.add(container.eb)
     container.seen_cards = gtk.image_new_from_pixbuf(self.card_images[0])
     container.eb.add(container.seen_cards)
Beispiel #27
0
    def make_button(self, name, wtyp, icon=None, tooltip=None):
        image = None
        if icon:
            iconfile = os.path.join(self.iconpath, icon+icon_ext)
            try:
                pixbuf = gtksel.pixbuf_new_from_file_at_size(iconfile, 24, 24)
                if pixbuf != None:
                    image = gtk.image_new_from_pixbuf(pixbuf)
            except:
                pass

        if wtyp == 'button':
            if image:
                w = gtk.Button()
                w.set_image(image)
            else:
                w = gtk.Button(name)
        elif wtyp == 'toggle':
            if image:
                w = gtk.ToggleButton()
                w.set_image(image)
            else:
                w = gtk.ToggleButton(name)

        return w
Beispiel #28
0
    def set_map_pixbuf(self, pixbuf):
        """Create a map dialog from the current already-downloaded map
        image. Note that this does not show the dialog, it simply
        creates it. awnlib handles the rest.

        """
        if pixbuf is None:
            return
        if self.map_dialog is None or self.map_vbox is None:
            self.map_dialog = self.applet.dialog.new(
                "secondary", title=self.applet.settings['location'])
            self.map_vbox = gtk.VBox()
            self.map_dialog.add(self.map_vbox)
        else:
            for i in self.map_vbox.get_children():
                self.map_vbox.remove(i)
            self.map_dialog.set_title(self.applet.settings['location'])

        self.map_pixbuf = pixbuf

        map_size = pixbuf.get_width(), pixbuf.get_height()

        # Resize if necessary as defined by map_maxwidth
        ratio = float(self.applet.settings['map_maxwidth']) / map_size[0]
        if ratio < 1:
            width, height = [int(ratio * dim) for dim in map_size]
            pixbuf = pixbuf.scale_simple(width, height,
                                         gtk.gdk.INTERP_BILINEAR)

        self.map_vbox.add(gtk.image_new_from_pixbuf(pixbuf))
Beispiel #29
0
    def make_button(self, name, wtyp, icon=None, tooltip=None):
        image = None
        if icon:
            iconfile = os.path.join(self.iconpath, icon+icon_ext)
            try:
                pixbuf = gtksel.pixbuf_new_from_file_at_size(iconfile, 24, 24)
                if pixbuf != None:
                    image = gtk.image_new_from_pixbuf(pixbuf)
            except:
                pass

        if wtyp == 'button':
            if image:
                w = Widgets.Button()
                _w = w.get_widget()
                _w.set_image(image)
            else:
                w = Widgets.Button(name)
        elif wtyp == 'toggle':
            if image:
                w = Widgets.ToggleButton()
                _w = w.get_widget()
                _w.set_image(image)
            else:
                w = Widgets.ToggleButton(name)

        return w
Beispiel #30
0
    def make_msg_tab(self):
        def pack(txt, i):
            hb = gtk.HBox(False, 2)
            l = gtk.Label()
            l.set_markup('<span size="10000"><b>{}</b></span>'.format(txt))
            hb.add(i)
            hb.add(l)
            return hb

        v = gtk.VBox(False, 1)
        v.pack_start(self.agtora, False, True, 5)
        vv = gtk.HBox(True, 5)
        tooltips = gtk.Tooltips()

        pixbuf = env.IconTheme.load_icon("kuser", 24,
                                         gtk.ICON_LOOKUP_GENERIC_FALLBACK)
        img = gtk.Image()
        img.set_from_pixbuf(pixbuf)
        bt = gtk.Button()
        bt.connect('clicked', self.on_add_agt)
        bt.add(pack('Adaugă', img))
        tooltips.set_tip(bt, 'Adaugă un nou agent!')
        vv.add(bt)

        img = gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU)
        bt = gtk.Button()
        bt.connect('clicked', self.on_del_agt)
        tooltips.set_tip(bt, 'Șterge agentul selectat!')
        bt.add(pack('Șterge', img))
        vv.add(bt)

        pixbuf = env.IconTheme.load_icon("gnome-settings-theme", 24,
                                         gtk.ICON_LOOKUP_GENERIC_FALLBACK)
        img = gtk.Image()
        img.set_from_pixbuf(pixbuf)
        bt = gtk.Button()
        bt.connect('clicked', self.on_edit_agt)
        tooltips.set_tip(bt, 'Modifică numele\nagentului selectat!')
        bt.add(pack('Modifică', img))
        vv.add(bt)
        v.pack_start(vv, False, True)
        v.add(
            gtk.image_new_from_pixbuf(
                gtk.gdk.pixbuf_new_from_file_at_size('agt.png', 64, 64)))

        self.mesaj.set_editable(False)
        self.mesaj.modify_font(FontDescription('Segoe UI 9'))
        self.mesaj.set_wrap_mode(gtk.WRAP_WORD)
        # self.mesaj.set_justification(gtk.JUSTIFY_CENTER)
        self.mesaj.set_cursor_visible(False)
        self.mesaj.set_left_margin(2)
        self.mesaj.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ddd'))
        self.mesaj.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse('#000'))
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.mesaj)
        self.mesaj.set_size_request(-1, 80)
        v.add(sw)
        v.pack_end(self.userbt, False, True)
        return v
Beispiel #31
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = gtk.FileChooserDialog(title="Save image",
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
                                          orig_pixbuf.get_height() / 2,
                                          gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == gtk.RESPONSE_OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.save(path, 'png')

        savedialog.destroy()
Beispiel #32
0
 def __init__(self, parent, version, date):
     gtk.MessageDialog.__init__(self, parent,
             gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
             gtk.BUTTONS_NONE, 'VMNetX update available')
     theme = gtk.icon_theme_get_default()
     try:
         icon = theme.load_icon('vmnetx', 256, 0)
         icon = icon.scale_simple(self.ICON_SIZE, self.ICON_SIZE,
                 gtk.gdk.INTERP_BILINEAR)
     except glib.GError:
         # VMNetX icon not installed in search path
         icon = theme.load_icon('software-update-available',
                 self.ICON_SIZE, 0)
     self.set_image(gtk.image_new_from_pixbuf(icon))
     self.set_title('Update Available')
     datestr = '%s %s, %s' % (
         date.strftime('%B'),
         date.strftime('%d').lstrip('0'),
         date.strftime('%Y')
     )
     self.format_secondary_markup(
             'VMNetX <b>%s</b> was released on <b>%s</b>.' % (
             urllib.quote(version), datestr))
     self.add_buttons('Skip this version', gtk.RESPONSE_REJECT,
             'Remind me later', gtk.RESPONSE_CLOSE,
             'Download update', gtk.RESPONSE_ACCEPT)
     self.set_default_response(gtk.RESPONSE_ACCEPT)
     self.connect('response', self._response)
 def add_picture(self, path, callback, title=None, id=None):
     if os.path.exists(path):
         if self.menu_pictures_size is None:
             pixbuf = gtk.gdk.pixbuf_new_from_file(path)
         else:
             pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
                 path, -1, self.menu_pictures_size)
         image = gtk.image_new_from_pixbuf(pixbuf)
         menuitem = gtk.MenuItem()
         if title is not None:
             vbox = gtk.VBox()
             vbox.pack_start(image, False, False, 2)
             label = gtk.Label()
             label.set_text(title)
             vbox.pack_start(label, False, False, 2)
             menuitem.add(vbox)
         else:
             menuitem.add(image)
         if id is not None:
             menuitem.connect('activate', self._on_picture_selected, path,
                              callback, id)
         else:
             menuitem.connect('activate', self._on_picture_selected, path,
                              callback)
         self.menu.attach(menuitem, self.col, self.col + 1, self.row,
                          self.row + 1)
         self.col = (self.col + 1) % self.num_cols
         if (self.col == 0):
             self.row = self.row + 1
Beispiel #34
0
def myToolTip(widget,
              x,
              y,
              keyboard_mode,
              tooltip,
              title,
              desc,
              filename=None):
    table = gtk.Table(2, 2)
    table.set_row_spacings(2)
    table.set_col_spacings(6)
    table.set_border_width(4)

    pixbuf = mapPixbuf.getImage(filename)
    image = gtk.image_new_from_pixbuf(pixbuf)
    image.set_alignment(0, 0)
    table.attach(image, 0, 1, 0, 2)

    titleLabel = gtk.Label()
    titleLabel.set_markup("<b>%s</b>" % title)
    titleLabel.set_alignment(0, 0)
    table.attach(titleLabel, 1, 2, 0, 1)

    descLabel = gtk.Label(desc)
    descLabel.props.wrap = True
    table.attach(descLabel, 1, 2, 1, 2)

    tooltip.set_custom(table)
    table.show_all()
    return True
Beispiel #35
0
def get_image(img, size):
    img = img+EXT
    try:
        return gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file(os.path.join(cons.MEDIA_PATH, size, img).decode(sys.getfilesystemencoding())))
    except Exception as err:
        logger.warning(err)
        return gtk.image_new_from_stock(gtk.STOCK_MISSING_IMAGE, gtk.ICON_SIZE_BUTTON)
Beispiel #36
0
    def __init__(self, title, message, pic):
        gtk.ImageMenuItem.__init__(self, stock_id=gtk.STOCK_DIALOG_INFO)

        self.set_tooltip_markup(message)

        if pic:
            pb = gtk.gdk.pixbuf_new_from_file_at_size(
                pic.replace("file://", ""),
                *gtk.icon_size_lookup(gtk.ICON_SIZE_MENU))
            self.set_image(gtk.image_new_from_pixbuf(pb))

        lbl = self.get_children()[0]
        lbl.set_text(title)

        #remove the label, and place it in a hbox
        self.remove(lbl)

        hb = gtk.HBox()
        hb.pack_start(lbl, True, True)

        #add another label beside it, that shows the time this item was added
        mtime = gtk.Label('<span style="italic" weight="light">%s</span>' %
                          time.strftime("%I:%M %p"))
        mtime.props.xalign = 1.0
        mtime.props.use_markup = True
        hb.pack_start(mtime, False, False)

        self.add(hb)
Beispiel #37
0
    def create(self, container):
        self.container  = container
        self.grid = gtk.Table(self.rows, self.cols + 4, homogeneous = False)

        for r in range(0, self.rows):
            for c in range(0, self.cols):
                self.seen_cards[(c, r)] = gtk.image_new_from_pixbuf(self.card_images[(0)])
                self.eb[(c, r)]= gtk.EventBox()

#    set up the contents for the cells
        for r in range(0, self.rows):
            self.grid_contents[( 0, r)] = gtk.Label("%d" % (r + 1))
            self.grid_contents[( 1, r)] = gtk.Label("player %d" % (r + 1))
            self.grid_contents[( 1, r)].set_property("width-chars", 12)
            self.grid_contents[( 4, r)] = gtk.Label("-")
            self.grid_contents[( 9, r)] = gtk.Label("-")
            self.grid_contents[( 2, r)] = self.eb[( 0, r)]
            self.grid_contents[( 3, r)] = self.eb[( 1, r)]
            self.grid_contents[( 5, r)] = self.eb[( 2, r)]
            self.grid_contents[( 6, r)] = self.eb[( 3, r)]
            self.grid_contents[( 7, r)] = self.eb[( 4, r)]
            self.grid_contents[( 8, r)] = self.eb[( 5, r)]
            self.grid_contents[(10, r)] = self.eb[( 6, r)]
            for c in range(0, self.cols):
                self.eb[(c, r)].add(self.seen_cards[(c, r)])
            
#    add the cell contents to the table
        for c in range(0, self.cols + 4):
            for r in range(0, self.rows):
                self.grid.attach(self.grid_contents[(c, r)], c, c+1, r, r+1, xpadding = 1, ypadding = 1)
                
        self.container.add(self.grid)
Beispiel #38
0
 def build_image(self, image):
     Build_Picture.pix = gtk.gdk.pixbuf_new_from_file_at_scale(
         image, 300, 200, True)
     #Build_Picture.pix = Build_Picture.pix.scale_simple(300, 200, gtk.gdk.INTERP_BILINEAR)
     Build_Picture.image = gtk.image_new_from_pixbuf(Build_Picture.pix)
     MainWindow.imagebox.pack_start(Build_Picture.image)
     Build_Picture.image.show()
Beispiel #39
0
    def set_map_pixbuf(self, pixbuf):
        """Create a map dialog from the current already-downloaded map
        image. Note that this does not show the dialog, it simply
        creates it. awnlib handles the rest.

        """
        if pixbuf is None:
            return
        if self.map_dialog is None or self.map_vbox is None:
            self.map_dialog = self.applet.dialog.new("secondary", title=self.applet.settings['location'])
            self.map_vbox = gtk.VBox()
            self.map_dialog.add(self.map_vbox)
        else:
            for i in self.map_vbox.get_children():
                self.map_vbox.remove(i)
            self.map_dialog.set_title(self.applet.settings['location'])

        self.map_pixbuf = pixbuf

        map_size = pixbuf.get_width(), pixbuf.get_height()

        # Resize if necessary as defined by map_maxwidth
        ratio = float(self.applet.settings['map_maxwidth']) / map_size[0]
        if ratio < 1:
            width, height = [int(ratio * dim) for dim in map_size]
            pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)

        self.map_vbox.add(gtk.image_new_from_pixbuf(pixbuf))
 def set_controllers(self, config_controllers):
     self.vbox.hide()
     self.vbox.foreach(lambda widget: self.vbox.remove(widget))
     for config in self.configs:
         if config:
             config.cancel_config()
             #self.widget.remove(config.get_config_widget())
             config.hide()        
     self.vbox.pack_end(self.buttons, False, False)        
     #self.widget.show()
     self.configs = config_controllers
     for config in self.configs:
         if config:
             vbox = gtk.HBox(spacing = 8)
             name, icon = config.get_name(), config.get_icon()
             if icon:
                 vbox.pack_start(gtk.image_new_from_pixbuf(icon), False, False)
             if name:
                 lbl = gtk.Label(name)                
                 vbox.pack_start(lbl, False, False)
             if name or icon:
                 self.vbox.pack_start(vbox, False, False)
             self.vbox.pack_start(config.get_config_widget(), False, False)
             self.vbox.pack_start(gtk.HSeparator(), False, False)
             config.show()
             config.connect("changed", self._config_changed_cb)
     self.vbox.show_all()
     self._update_modified()
Beispiel #41
0
    def show_popup(self, status_icon, button, activate_time):
        """
        Create the popupmenu
        """
        ## From the PyGTK 2.10 documentation
        # status_icon : the object which received the signal
        # button :      the button that was pressed, or 0 if the signal is not emitted in response to a button press event
        # activate_time :       the timestamp of the event that triggered the signal emission

        # Create menu items
        if self.specto.specto_gconf.get_entry("always_show_icon") and self.specto.notifier.get_state():
            self.item_show = create_menu_item(_("Hide window"), self.show_notifier, None)
        else:
            self.item_show = create_menu_item(_("Show window"), self.show_notifier, None)

        self.item_pref = create_menu_item(gtk.STOCK_PREFERENCES, self.show_preferences, gtk.STOCK_PREFERENCES)
        self.item_help = create_menu_item(gtk.STOCK_HELP, self.show_help, gtk.STOCK_HELP)
        self.item_about = create_menu_item(gtk.STOCK_ABOUT, self.show_about, gtk.STOCK_ABOUT)
        self.item_quit = create_menu_item(gtk.STOCK_QUIT, self.quit, gtk.STOCK_QUIT)
        self.item_clear = create_menu_item(_("Mark as read"), None, None)
        self.item_refresh = create_menu_item(_("Refresh All"), self.refresh, gtk.STOCK_REFRESH)

        # create submenu for changed watches
        self.sub_menu = gtk.Menu()

        self.sub_item_clear = create_menu_item(
            _("_Mark all read"), self.specto.notifier.mark_all_as_read, gtk.STOCK_CLEAR
        )
        self.sub_menu.append(self.sub_item_clear)

        self.sub_menu.append(gtk.SeparatorMenuItem())

        for watch in self.specto.watch_db:
            if watch.changed == True:
                image = gtk.image_new_from_pixbuf(self.notifier.get_icon(watch.icon, 0, False))
                self.sub_item_clear = create_menu_item(watch.name, None, image)
                self.sub_item_clear.connect("activate", self.specto.notifier.mark_watch_as_read, watch.id)
                self.sub_menu.append(self.sub_item_clear)

        self.sub_menu.show_all()
        self.item_clear.set_submenu(self.sub_menu)

        # Create the menu
        self.menu = gtk.Menu()

        # Append menu items to the menu
        self.menu.append(self.item_show)
        self.menu.append(gtk.SeparatorMenuItem())
        self.menu.append(self.item_refresh)
        self.menu.append(self.item_clear)
        self.menu.append(gtk.SeparatorMenuItem())
        self.menu.append(self.item_pref)
        self.menu.append(self.item_help)
        self.menu.append(self.item_about)
        self.menu.append(gtk.SeparatorMenuItem())
        self.menu.append(self.item_quit)
        self.menu.show_all()
        self.menu.popup(
            None, None, gtk.status_icon_position_menu, button, activate_time, self.tray
        )  # the last argument is to tell gtk.status_icon_position_menu where to grab the coordinates to position the popup menu correctly
Beispiel #42
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = gtk.FileChooserDialog(title="Save image",
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2, 
                                     orig_pixbuf.get_height() / 2,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == gtk.RESPONSE_OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.save(path, 'png')

        savedialog.destroy()
Beispiel #43
0
    def __create_widgets(self):
        self.image = gtk.image_new_from_pixbuf(self._reader.get_logo())

        self.label = gtk.Label('')
        self.label.set_ellipsize(pango.ELLIPSIZE_END)

        self.versions_model = gtk.ListStore(str, str)
        self.versions_button = gtk.ComboBox(self.versions_model)

        rend = gtk.CellRendererPixbuf()
        self.versions_button.pack_start(rend, False)
        self.versions_button.add_attribute(rend, 'stock-id', 0)

        rend = gtk.CellRendererText()
        self.versions_button.pack_end(rend)
        self.versions_button.add_attribute(rend, 'text', 1)

        self.img_play = gtk.image_new_from_stock(gtk.STOCK_MEDIA_PLAY, \
                                                 gtk.ICON_SIZE_BUTTON)
        self.img_stop = gtk.image_new_from_stock(gtk.STOCK_MEDIA_STOP, \
                                                 gtk.ICON_SIZE_BUTTON)

        self.action_btn = HIGButton('')
        self.uninstall_btn = HIGButton(_("Uninstall"), gtk.STOCK_CLEAR)
        self.preference_btn = HIGButton(stock=gtk.STOCK_PREFERENCES)

        self.progressbar = gtk.ProgressBar()
Beispiel #44
0
    def _create_ui(self):
        # creates ui
        self.check_btn = gtk.CheckButton()

        self._name_lb = gtk.Label()
        self._name_lb.set_alignment(0.0, 0.5)
        self._name_lb.set_markup("<b>"+self._name+"</b>")

        self._info = gtk.Label()
        self._info.set_alignment(0.0, 0.5)

        self._set_mounted()

        self.edit_btn = gtk.Button(_("Edit"))

        self.attach(self.check_btn, 0, 1, 0, 2,
                    gtk.SHRINK, gtk.SHRINK)

        if self._mount:
            pixbuf = get_icon("drive-harddisk", 32)
        else:
            pixbuf = get_icon("drive-removable-media", 32)

        self._icon = gtk.image_new_from_pixbuf(pixbuf)
        self.attach(self._icon, 1, 2, 0, 2,
                   gtk.SHRINK, gtk.SHRINK)
        self.attach(self._name_lb, 2, 3, 0, 1,
                    gtk.EXPAND|gtk.FILL, gtk.SHRINK)
        self.attach(self._info, 2, 3, 1, 2,
                    gtk.EXPAND|gtk.FILL, gtk.SHRINK)
        self.attach(self.edit_btn, 3, 4, 0, 2,
                    gtk.SHRINK, gtk.SHRINK)
Beispiel #45
0
    def create_dialog(dest):
        dialog = gtk.Dialog("Confirm", None, gtk.DIALOG_MODAL,
                            ("OK", True, "Cancel", False))

        t = "file"
        if os.path.islink(dest):
            t = "link"
        elif os.path.isdir(dest):
            t = "directory"

        message = "There is already a %s with the same name" % t
        message += " in the destination folder.\n"
        message += "Replace it?"
        label = gtk.Label(message)

        pix = icon_factory.icon_pixbuf(dest)
        image = gtk.image_new_from_pixbuf(pix)

        hbox = gtk.HBox(False, 0)
        hbox.pack_start(image, False, False, 5)
        hbox.pack_start(label, False, False, 5)
        hbox.show_all()

        dialog.vbox.pack_start(hbox)

        return dialog
Beispiel #46
0
 def __init__(self, parent, version, date):
     gtk.MessageDialog.__init__(self, parent,
             gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO,
             gtk.BUTTONS_NONE, 'VMNetX update available')
     theme = gtk.icon_theme_get_default()
     try:
         icon = theme.load_icon('vmnetx', 256, 0)
         icon = icon.scale_simple(self.ICON_SIZE, self.ICON_SIZE,
                 gtk.gdk.INTERP_BILINEAR)
     except glib.GError:
         # VMNetX icon not installed in search path
         icon = theme.load_icon('software-update-available',
                 self.ICON_SIZE, 0)
     self.set_image(gtk.image_new_from_pixbuf(icon))
     self.set_title('Update Available')
     datestr = '%s %s, %s' % (
         date.strftime('%B'),
         date.strftime('%d').lstrip('0'),
         date.strftime('%Y')
     )
     self.format_secondary_markup(
             'VMNetX <b>%s</b> was released on <b>%s</b>.' % (
             urllib.quote(version), datestr))
     self.add_buttons('Skip this version', gtk.RESPONSE_REJECT,
             'Remind me later', gtk.RESPONSE_CLOSE,
             'Download update', gtk.RESPONSE_ACCEPT)
     self.set_default_response(gtk.RESPONSE_ACCEPT)
     self.connect('response', self._response)
Beispiel #47
0
    def create(self, container):
        self.container  = container
        self.grid = gtk.Table(self.rows, self.cols + 4, homogeneous = False)

        for r in range(0, self.rows):
            for c in range(0, self.cols):
                # Start by creating a box of nothing but card backs
                self.seen_cards[(c, r)] = gtk.image_new_from_pixbuf(self.card_images[0].copy())
                self.eb[(c, r)]= gtk.EventBox()

#    set up the contents for the cells
        for r in range(0, self.rows):
            self.grid_contents[( 0, r)] = gtk.Label("%d" % (r + 1))
            self.grid_contents[( 1, r)] = gtk.Label("player %d" % (r + 1))
            self.grid_contents[( 1, r)].set_property("width-chars", 12)
            self.grid_contents[( 4, r)] = gtk.Label("-")
            self.grid_contents[( 9, r)] = gtk.Label("-")
            self.grid_contents[( 2, r)] = self.eb[( 0, r)]
            self.grid_contents[( 3, r)] = self.eb[( 1, r)]
            self.grid_contents[( 5, r)] = self.eb[( 2, r)]
            self.grid_contents[( 6, r)] = self.eb[( 3, r)]
            self.grid_contents[( 7, r)] = self.eb[( 4, r)]
            self.grid_contents[( 8, r)] = self.eb[( 5, r)]
            self.grid_contents[(10, r)] = self.eb[( 6, r)]
            for c in range(0, self.cols):
                self.eb[(c, r)].add(self.seen_cards[(c, r)])
            
#    add the cell contents to the table
        for c in range(0, self.cols + 4):
            for r in range(0, self.rows):
                self.grid.attach(self.grid_contents[(c, r)], c, c+1, r, r+1, xpadding = 1, ypadding = 1)
                
        self.container.add(self.grid)
Beispiel #48
0
    def __init__(self, detail_page, pkg_name, alias_name, star):
        '''
        init docs
        '''
        gtk.HBox.__init__(self)
        self.star = star
        self.pkg_name = pkg_name

        v_box = gtk.VBox()
        pkg_icon_image = gtk.image_new_from_pixbuf(
            gtk.gdk.pixbuf_new_from_file_at_size(get_icon_pixbuf_path(pkg_name), 32, 32))
        pkg_alias_label = Label(alias_name,
                                hover_color=app_theme.get_color("homepage_hover"))
        pkg_alias_label.set_clickable()
        pkg_alias_label.connect("button-press-event", lambda w, e: detail_page.update_pkg_info(pkg_name))

        self.pkg_star_box = gtk.HBox()

        self.pkg_star_view = StarView()
        self.pkg_star_view.star_buffer.star_level = int(star)
        self.pkg_star_view.connect("clicked", lambda w: self.grade_pkg())

        self.pkg_star_mark = StarMark(self.star, self.MARK_SIZE, self.MARK_PADDING_X, self.MARK_PADDING_Y)

        self.pack_start(pkg_icon_image, False, False)
        self.pack_start(v_box, True, True, 8)
        v_box.pack_start(pkg_alias_label, False, False, 2)
        v_box.pack_start(self.pkg_star_box, False, False, 2)
        self.pkg_star_box.pack_start(self.pkg_star_view, False, False)
        self.pkg_star_box.pack_start(self.pkg_star_mark, False, False)
Beispiel #49
0
    def __init__(self):
        super(PyApp, self).__init__()

        self.set_title("logo")
        self.set_size_request(800, 600)
        self.set_position(gtk.WIN_POS_CENTER)
        self.connect("destroy", gtk.main_quit)
        pixbuf = gdk.pixbuf_new_from_file(
            "/root/workspace/EastedClient/EastedUI/bg.png")
        pixbuf1 = pixbuf.scale_simple(1280, 800, gdk.INTERP_BILINEAR)
        im = gtk.image_new_from_pixbuf(pixbuf1)
        fixed = gtk.Fixed()
        ima = gtk.Image()
        ima.set_from_file("/root/workspace/EastedClient/EastedUI/logo.png")

        _passwd_entry = gtk.Entry()
        _passwd_entry.set_editable(True)
        Passwd_label = gtk.Label("Account")
        Passwd_label.set_text(_passwd_entry.get_text())
        Passwd_label.set_no_show_all(0)
        fixed.put(im, 0, 0)
        fixed.put(Passwd_label, 35, 100)
        fixed.put(_passwd_entry, 100, 100)
        fixed.put(ima, 200, 0)

        del pixbuf, pixbuf1
        self.add(fixed)
        self.show_all()
Beispiel #50
0
def image_file_only_button(image_file_path, size):
    import gtk
    pixbuf = get_pixbuf(image_file_path, size, size)
    image = gtk.image_new_from_pixbuf(pixbuf)
    button = gtk.Button()
    button.add(image)
    return button
Beispiel #51
0
    def __init__(self, title, message, pic):
        gtk.ImageMenuItem.__init__(self, stock_id=gtk.STOCK_DIALOG_INFO)

        self.set_tooltip_markup(message)

        if pic:
            pb = gtk.gdk.pixbuf_new_from_file_at_size(
                            pic.replace("file://",""),
                            *gtk.icon_size_lookup(gtk.ICON_SIZE_MENU))
            self.set_image(gtk.image_new_from_pixbuf(pb))

        lbl = self.get_children()[0]
        lbl.set_text(title)

        #remove the label, and place it in a hbox
        self.remove(lbl)

        hb = gtk.HBox()
        hb.pack_start(lbl, True, True)

        #add another label beside it, that shows the time this item was added
        mtime = gtk.Label('<span style="italic" weight="light">%s</span>' % time.strftime("%I:%M %p"))
        mtime.props.xalign = 1.0
        mtime.props.use_markup = True
        hb.pack_start(mtime, False, False)

        self.add(hb)
Beispiel #52
0
 def create_contents(self, container, i):
     """Create the widgets for showing the contents of the Aux_seats window."""
     container.eb = gtk.EventBox()
     container.eb.connect("button_press_event", self.button_press_cb, i)
     container.add(container.eb)
     container.seen_cards = gtk.image_new_from_pixbuf(self.card_images[0].copy())
     container.eb.add(container.seen_cards)
Beispiel #53
0
    def _mkbrushbt(self, frame, brush):
        if brush.icon:
            icon_image = gtk.image_new_from_file(brush.icon)
            pixbuf = icon_image.get_pixbuf()
            width = pixbuf.get_property('width')
            height = pixbuf.get_property('height')
        else:
            self._drawbrush.set_from_brush(brush)
            width = 128
            height = 60

            buf = self._drawbrush.paint_rgb_preview(
                width, height, fmt=_pixbuf.FORMAT_RGBA8_NOA)
            pixbuf = gdk.pixbuf_new_from_data(buf, gdk.COLORSPACE_RGB, True, 8,
                                              buf.width, buf.height,
                                              buf.stride)
            icon_image = gtk.image_new_from_pixbuf(pixbuf)

        bt = gtk.ToggleButton()
        bt.set_image(icon_image)
        bt.set_size_request(width + 15, height + 5)
        bt.show_all()
        bt.connect('clicked', self._on_brush_bt_clicked)
        bt.connect('button-release-event', self._on_brush_bt_released)
        bt.brush = brush
        bt.bt2 = None  # button in another page if it has been added

        t = frame.table
        x = t.count % TABLE_WIDTH
        y = t.count / TABLE_WIDTH
        frame.table.attach(bt, x, x + 1, y, y + 1, gtk.FILL, gtk.FILL, 1, 1)
        t.count += 1

        return bt
Beispiel #54
0
    def get_image_from_name(name, size, fit_size = "both"):
        assert isinstance(name, str), "Image name must be a string"

        icon = None
        if gtk.stock_lookup(name):
            icon = gtk.image_new_from_stock(name, size)
        elif gtk.icon_theme_get_default().has_icon(name):
            icon = gtk.image_new_from_icon_name(name, size)
        else:
            path = os.path.join('..', os.path.dirname(os.path.dirname(__file__)), 'data', 'gfx', name+'.png')
            if os.path.exists(path):
                try:
                    _size = gtk.icon_size_lookup(size)
                    pixbuf = gtk.gdk.pixbuf_new_from_file(path)
                    heightS = max(float(_size[1])/float(pixbuf.get_height()), 1.0)
                    widthS = max(float(_size[0])/float(pixbuf.get_width()), 1.0)

                    if fit_size == 'both':
                        if heightS < widthS:
                            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path, _size[1]*pixbuf.get_width()/pixbuf.get_height(), _size[1])
                        else:
                            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path, _size[0], _size[0]*pixbuf.get_height()/pixbuf.get_width())
                    elif fit_size == 'width':
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path, _size[0], _size[0]*pixbuf.get_height()/pixbuf.get_widtht())
                    else:
                        pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(path, _size[1]*pixbuf.get_width()/pixbuf.get_height(), _size[1])

                    icon = gtk.image_new_from_pixbuf(pixbuf)
                except Exception as e:
                    print e
                    icon = gtk.image_new_from_stock(gtk.STOCK_MISSING_IMAGE, size)
            else:
                icon = gtk.image_new_from_stock(gtk.STOCK_MISSING_IMAGE, size)
        return icon
def callback():
    global cnt
    cnt += 1
    """gtk.Image.set_from_file("./image0.jpg")
    image=gtk.image_new_from_file("./image0.jpg")
    print(type(image))
    pix=gtk.Image.pixbuf_new_from_file(os.path.join("./", "image1.jpg")) 
    window = gtk.Window()
    window.connect("destroy", gtk.main_quit)
    window.fullscreen() 
    bg=newPix(gtk.gdk.screen_width(), gtk.gdk.screen_height())
    #pixFitted=scaleToBg(pix, bg) 
    gtk.Image.set_from_pixbuf(image) """
    path = "./image%s.jpg" % (cnt % 2)
    pix = gtk.gdk.pixbuf_new_from_file(os.path.join(path))
    window = gtk.Window()
    window.connect("destroy", gtk.main_quit)
    window.fullscreen()
    bg = newPix(gtk.gdk.screen_width(), gtk.gdk.screen_height())
    pixFitted = scaleToBg(pix, bg)
    image = gtk.image_new_from_pixbuf(pixFitted)
    window.add(image)
    window.show_all()

    gobject.timeout_add(500, callback)
    def __init__(self, txt):
        super(ClosableLabel, self).__init__(False, 2)

        self.arrow = gtk.Arrow(gtk.ARROW_RIGHT, gtk.SHADOW_NONE)

        self.arrow_box = gtk.EventBox()
        self.arrow_box.add(self.arrow)
        self.arrow_box.set_visible_window(False)
        self.arrow_box.connect('button-press-event', self.__on_arrow_btn)

        self.label = gtk.Label(txt)
        self.label.set_use_markup(True)
        self.label.set_alignment(0, 0.5)
        self.label.set_ellipsize(pango.ELLIPSIZE_START)
        self.label.set_size_request(150, -1)

        self.button = gtk.Button()
        self.button.add(gtk.image_new_from_pixbuf(self.__close_icon))
        self.button.set_relief(gtk.RELIEF_NONE)
        self.button.connect('clicked', self.__on_clicked)

        self.pack_start(self.arrow_box, False, False)
        self.pack_start(self.label)
        self.pack_start(self.button, False, False)

        self.label.show_all()
        self.button.show_all()
Beispiel #57
0
    def clone_image(self, image):
        storage = image.get_storage_type()
        if storage == gtk.IMAGE_PIXMAP:
            img, mask = image.get_pixmap()
            return gtk.image_new_from_pixmap(img, mask)
        if storage == gtk.IMAGE_IMAGE:
            img, mask = image.get_image()
            return gtk.image_new_from_image(img, mask)
        if storage == gtk.IMAGE_PIXBUF:
            return gtk.image_new_from_pixbuf(image.get_pixbuf())
        if storage == gtk.IMAGE_STOCK:
            img, size = image.get_stock()
            return gtk.image_new_from_stock(img, size)
        if storage == gtk.IMAGE_ICON_SET:
            img, size = image.get_icon_set()
            return gtk.image_new_from_icon_set(img, size)
        if storage == gtk.IMAGE_ANIMATION:
            return gtk.image_new_from_animation(image.get_animation())
        if storage == gtk.IMAGE_ICON_NAME:
            img, size = image.get_icon_name()
            return gtk.image_new_from_icon_name(img, size)


#		if storage == gtk.IMAGE_EMPTY:
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU)
        return img
Beispiel #58
0
    def handle_NotificationEvent(self, event):
        summary = event.get_summary()
        message = event.get_content()
        icon = event.get_icon()

        label = gtk.Label()
        label.set_markup(summary + "\n" + message)
        label.set_line_wrap(True)
        label.set_width_chars(self.config['maxCharsPerLine'])
        if icon and self.config['showIcons']:
            hbox = gtk.HBox()
            hbox.pack_start(gtk.image_new_from_pixbuf(icon))
            hbox.pack_start(label)
            self.vbox.pack_start(hbox)
        else:
            self.vbox.pack_start(label)
        self.vbox.pack_start(gtk.HSeparator())
        self.vbox.show_all()

        #scroll to bottom
        try:
            adjustment = self.scrolled.get_vadjustment()
            adjustment.set_value(adjustment.upper)
        except:
            self.noteo.logger.debug("Couldn't scroll to bottom for some reason")
Beispiel #59
0
    def __init__(self, conf, source, messages_file, settings_file, groundstation_window):
        mydir = os.path.dirname(os.path.abspath(__file__))
        uifile = os.path.join(mydir, "radiocalibration.ui")
        gs.ui.GtkBuilderWidget.__init__(self, uifile)

        pb = gs.ui.get_icon_pixbuf("radio.svg",size=gtk.ICON_SIZE_MENU)
        item = gtk.ImageMenuItem("Calibrate Radio")
        item.set_image(gtk.image_new_from_pixbuf(pb))
        item.connect("activate", self._show_window)
        groundstation_window.add_menu_item("UAV", item)

        #fill the models with names of radio channels
        self._channel_model = gtk.ListStore(str)
        self._channels = {}
        for c in RADIO_CHANNELS:
            self._channels[c] = self._channel_model.append((c,))
        self._nchannels = len(self._channels)

        self._source = source
        self._initialized = []
        self._win = self.get_resource("mainwindow")
        self._win.set_icon(pb)
        self._win.set_title("Calibrate Radio")
        self._win.connect("delete-event", self._hide_window)
        self.get_resource("close_button").connect("clicked", self._on_close)
        self.get_resource("save_button").connect("clicked", self._on_save)
        self.get_resource("open_button").connect("clicked", self._on_open)