Exemplo n.º 1
0
    def __init__(self, library):
        self._library = library
        gtk.HBox.__init__(self, False, 12)

        self.set_border_width(10)
        borderbox = gtk.EventBox()
        borderbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#333'))
        borderbox.set_size_request(350, -1)
        insidebox = gtk.EventBox()
        insidebox.set_border_width(1)
        insidebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ddb'))
        infobox = gtk.VBox(False, 5)
        infobox.set_border_width(10)
        self.pack_start(borderbox, False, False)
        borderbox.add(insidebox)
        insidebox.add(infobox)
        self._namelabel = labels.BoldLabel()
        self._namelabel.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        self._namelabel.set_alignment(0, 0.5)
        infobox.pack_start(self._namelabel, False, False)
        self._pageslabel = gtk.Label()
        self._pageslabel.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        self._pageslabel.set_alignment(0, 0.5)
        infobox.pack_start(self._pageslabel, False, False)
        self._filelabel = gtk.Label()
        self._filelabel.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        self._filelabel.set_alignment(0, 0.5)
        infobox.pack_start(self._filelabel, False, False)
        self._dirlabel = gtk.Label()
        self._dirlabel.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        self._dirlabel.set_alignment(0, 0.5)
        infobox.pack_start(self._dirlabel, False, False)

        vbox = gtk.VBox(False, 10)
        self.pack_start(vbox, True, True)
        hbox = gtk.HBox(False)
        vbox.pack_start(hbox, False, False)
        label = gtk.Label('%s:' % _('Search'))
        hbox.pack_start(label, False, False)
        search_entry = gtk.Entry()
        search_entry.connect('activate', self._filter_books)
        search_entry.set_tooltip_text(
            _('Display only those books that have '
              'the specified text string in their '
              'full path. The search is not case '
              'sensitive.'))
        hbox.pack_start(search_entry, True, True, 6)
        label = gtk.Label('%s:' % _('Cover size'))
        hbox.pack_start(label, False, False, 6)
        adjustment = gtk.Adjustment(prefs['library cover size'], 50, 128, 1,
                                    10, 0)
        cover_size_scale = gtk.HScale(adjustment)
        cover_size_scale.set_size_request(150, -1)
        cover_size_scale.set_draw_value(False)
        cover_size_scale.connect('value_changed', self._change_cover_size)
        hbox.pack_start(cover_size_scale, False, False)
        vbox.pack_start(gtk.HBox(), True, True)

        hbox = gtk.HBox(False, 10)
        vbox.pack_start(hbox, False, False)
        add_book_button = gtk.Button(_('Add books'))
        add_book_button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON))
        add_book_button.connect('clicked', self._add_books)
        add_book_button.set_tooltip_text(_('Add more books to the library.'))
        hbox.pack_start(add_book_button, False, False)
        add_collection_button = gtk.Button(_('Add collection'))
        add_collection_button.connect('clicked', self._add_collection)
        add_collection_button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON))
        add_collection_button.set_tooltip_text(
            _('Add a new empty collection.'))
        hbox.pack_start(add_collection_button, False, False)
        hbox.pack_start(gtk.HBox(), True, True)
        self._open_button = gtk.Button(None, gtk.STOCK_OPEN)
        self._open_button.connect('clicked',
                                  self._library.book_area.open_selected_book)
        self._open_button.set_tooltip_text(_('Open the selected book.'))
        self._open_button.set_sensitive(False)
        hbox.pack_start(self._open_button, False, False)
Exemplo n.º 2
0
    def __init__(self):
        # GTK Stuffs
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_('Login'),
                                 parent=self.parent,
                                 flags=gtk.DIALOG_MODAL
                                 | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_has_separator(True)
        self.dialog.set_icon(TRYTON_ICON)

        tooltips = common.Tooltips()
        button_cancel = gtk.Button(_('_Cancel'))
        img_cancel = gtk.Image()
        img_cancel.set_from_stock('gtk-cancel', gtk.ICON_SIZE_BUTTON)
        button_cancel.set_image(img_cancel)
        tooltips.set_tip(button_cancel,
                         _('Cancel connection to the Tryton server'))
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)
        self.button_connect = gtk.Button(_('C_onnect'))
        img_connect = gtk.Image()
        img_connect.set_from_stock('tryton-connect', gtk.ICON_SIZE_BUTTON)
        self.button_connect.set_image(img_connect)
        self.button_connect.set_flags(gtk.CAN_DEFAULT)
        tooltips.set_tip(self.button_connect, _('Connect the Tryton server'))
        self.dialog.add_action_widget(self.button_connect, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        alignment = gtk.Alignment(yalign=0, yscale=0, xscale=1)
        self.table_main = gtk.Table(3, 3, False)
        self.table_main.set_border_width(0)
        self.table_main.set_row_spacings(3)
        self.table_main.set_col_spacings(3)
        alignment.add(self.table_main)
        self.dialog.vbox.pack_start(alignment, True, True, 0)

        image = gtk.Image()
        image.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        image.set_alignment(0.5, 1)
        ebox = gtk.EventBox()
        ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#1b2019"))
        ebox.add(image)
        self.table_main.attach(ebox, 0, 3, 0, 1, ypadding=2)

        self.profile_store = gtk.ListStore(gobject.TYPE_STRING,
                                           gobject.TYPE_BOOLEAN)
        self.combo_profile = gtk.ComboBox()
        cell = gtk.CellRendererText()
        self.combo_profile.pack_start(cell, True)
        self.combo_profile.add_attribute(cell, 'text', 0)
        self.combo_profile.add_attribute(cell, 'sensitive', 1)
        self.combo_profile.set_model(self.profile_store)
        self.combo_profile.connect('changed', self.profile_changed)
        self.profile_label = gtk.Label(_(u'Profile:'))
        self.profile_label.set_justify(gtk.JUSTIFY_RIGHT)
        self.profile_label.set_alignment(1, 0.5)
        self.profile_label.set_padding(3, 3)
        self.profile_button = gtk.Button(_('_Manage profiles'))
        self.profile_button.connect('clicked', self.profile_manage)
        self.table_main.attach(self.profile_label,
                               0,
                               1,
                               1,
                               2,
                               xoptions=gtk.FILL)
        self.table_main.attach(self.combo_profile, 1, 2, 1, 2)
        self.table_main.attach(self.profile_button,
                               2,
                               3,
                               1,
                               2,
                               xoptions=gtk.FILL)
        image = gtk.Image()
        image.set_from_stock('gtk-edit', gtk.ICON_SIZE_BUTTON)
        self.profile_button.set_image(image)
        self.expander = gtk.Expander(_('Host / Database information'))
        self.expander.connect('notify::expanded', self.expand_hostspec)
        self.table_main.attach(self.expander, 0, 3, 3, 4)
        self.label_host = gtk.Label(_('Host:'))
        self.label_host.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_host.set_alignment(1, 0.5)
        self.label_host.set_padding(3, 3)
        self.entry_host = gtk.Entry()
        self.entry_host.connect_after('focus-out-event',
                                      self.clear_profile_combo)
        self.entry_host.set_activates_default(True)
        self.table_main.attach(self.label_host, 0, 1, 4, 5, xoptions=gtk.FILL)
        self.table_main.attach(self.entry_host, 1, 3, 4, 5)
        self.label_database = gtk.Label(_('Database:'))
        self.label_database.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_database.set_alignment(1, 0.5)
        self.label_database.set_padding(3, 3)
        self.entry_database = gtk.Entry()
        self.entry_database.connect_after('focus-out-event',
                                          self.clear_profile_combo)
        self.entry_database.set_activates_default(True)
        self.table_main.attach(self.label_database,
                               0,
                               1,
                               5,
                               6,
                               xoptions=gtk.FILL)
        self.table_main.attach(self.entry_database, 1, 3, 5, 6)
        self.entry_password = gtk.Entry()
        self.entry_password.set_visibility(False)
        self.entry_password.set_activates_default(True)
        self.table_main.attach(self.entry_password, 1, 3, 7, 8)
        self.entry_login = gtk.Entry()
        self.entry_login.set_activates_default(True)
        self.table_main.attach(self.entry_login, 1, 3, 6, 7)
        label_password = gtk.Label(str=_("Password:"******"User name:"))
        label_username.set_alignment(1, 0.5)
        label_username.set_padding(3, 3)
        self.table_main.attach(label_username, 0, 1, 6, 7, xoptions=gtk.FILL)

        # Profile informations
        self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg')
        self.profiles = ConfigParser.SafeConfigParser({'port': '8000'})
        if not os.path.exists(self.profile_cfg):
            short_version = '.'.join(__version__.split('.', 2)[:2])
            name = 'demo%s.tryton.org' % short_version
            self.profiles.add_section(name)
            self.profiles.set(name, 'host', name)
            self.profiles.set(name, 'port', '8000')
            self.profiles.set(name, 'database', 'demo%s' % short_version)
            self.profiles.set(name, 'username', 'demo')
        else:
            self.profiles.read(self.profile_cfg)
        for section in self.profiles.sections():
            active = all(
                self.profiles.has_option(section, option)
                for option in ('host', 'port', 'database'))
            self.profile_store.append([section, active])
Exemplo n.º 3
0
 def make_evb_widget(self, widget):
     """create an event box and add the given widget to it"""
     evb = gtk.EventBox()
     #evb.show()
     evb.add(widget)
     return evb
Exemplo n.º 4
0
    args = parser.parse_args()

    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    vnc = gtkvnc.Display()

    if args.skin:
        image = Image.open(args.skin)
        IMG_PATH = args.skin
        IMG_WIDTH, IMG_HEIGHT = image.size
        x, y = find_screen_position(image)
        image.close()

        window.set_default_size(IMG_WIDTH, IMG_HEIGHT)
        fix = gtk.Fixed()
        fix.put(vnc, x, y)
        box = gtk.EventBox()
        window.add(box)
        box.add(fix)
    else:
        window.add(vnc)
        box = window

    box.connect("button_press_event", button_press_event)
    box.connect("button_release_event", button_release_event)
    box.connect("motion_notify_event", motion_notify_event)
    window.connect("key-press-event", vnc_screenshot, vnc)

    # borderless
    window.set_decorated(False)

    # transparent background
Exemplo n.º 5
0
    def create_item(self, item):
        v = gtk.VBox(False, 0)
        v.show()

        # -----
        l = gtk.Label(item.short_filename())
        l.show()

        # -----
        i = gtk.Image()
        self.set_image(i, item)
        i.show()

        # -----
        tags = gtk.Label(", ".join(item.get_tags()))
        tags.show()

        # -----
        prgr = gtk.HBox(False, 0)
        prgr.show()
        p = gtk.ProgressBar()
        p.show()
        p.set_text(str(item.get_progress()) + "%")
        p.set_fraction(float(item.get_progress()) / 100.0)
        p.set_usize(120, -1)
        # hack to center the progressbar
        ll = gtk.Label("")
        ll.show()
        prgr.pack_start(ll, expand=True)
        prgr.pack_start(p, expand=False)
        ll = gtk.Label("")
        ll.show()
        prgr.pack_start(ll, expand=True)

        # -----
        vb = gtk.VBox(False, 0)
        vb.show()
        for k in tools.wrap_string(item.get_title()):
            t = gtk.Label("<b>" + k + "</b>")
            t.set_justify(gtk.JUSTIFY_CENTER)
            # http://faq.pygtk.org/index.py?req=show&file=faq07.003.htp
            t.set_use_markup(True)
            t.show()
            vb.pack_start(t, False, False, 2)

        # -----
        vbs = gtk.VBox(False, 0)
        vbs.show()
        for k in tools.wrap_string(item.get_subtitle()):
            t = gtk.Label(k)
            t.set_justify(gtk.JUSTIFY_CENTER)
            t.show()
            vbs.pack_start(t, False, False, 2)

        # -----
        if not self.stuff.settings.vars["view_preview"]:
            i.hide()
        v.pack_start(i, False, False, 5)
        if not self.stuff.settings.vars["view_title"]:
            vb.hide()
        v.pack_start(vb, False, False, 0)
        if not self.stuff.settings.vars["view_subtitle"]:
            vbs.hide()
        v.pack_start(vbs, False, False, 0)
        if not self.stuff.settings.vars["view_progress"]:
            prgr.hide()
        v.pack_start(prgr, False, False, 5)
        if not self.stuff.settings.vars["view_filename"]:
            l.hide()
        v.pack_start(l, False, False, 5)
        if not self.stuff.settings.vars["view_tags"]:
            tags.hide()
        v.pack_start(tags, False, False, 0)

        # -----
        e = gtk.EventBox()
        e.add(v)
        e.show()
        e.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        e.connect("button_press_event", self.viewpdf, item)

        d = {
            "filename": l,
            "image": i,
            "tags": tags,
            "title": vb,
            "box": e,
            "subtitle": vbs,
            "progress": p
        }
        self.items[item.id()] = d

        return e
Exemplo n.º 6
0
    def make_title_bar(self):
        self.title = title = gtk.Label()
        title.modify_font(pango.FontDescription("bold 14"))
        title.set_label(self.name)
        title.set_padding(10, 4)
        title.set_alignment(0.0, 0.5)
        title.set_size_request(0, -1)  # Allow overflow
        title.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000"))
        title.show()

        title_menu = gtk.MenuBar()
        title_item = gtk.MenuItem('')
        title_item.remove(title_item.get_children()[0])
        menu_image = gtk.Image()
        menu_image.set_from_stock('tryton-preferences-system',
                                  gtk.ICON_SIZE_BUTTON)
        title_item.add(menu_image)
        title_item.set_submenu(self.set_menu_form())
        title_menu.append(title_item)
        title_menu.show_all()

        self.info_label = gtk.Label()
        self.info_label.set_padding(3, 3)
        self.info_label.set_alignment(1.0, 0.5)

        self.eb_info = gtk.EventBox()
        self.eb_info.add(self.info_label)
        self.eb_info.connect('button-release-event',
                             lambda *a: self.message_info(''))

        vbox = gtk.VBox()
        vbox.pack_start(self.eb_info, expand=True, fill=True, padding=5)
        vbox.show()

        self.status_label = gtk.Label()
        self.status_label.set_padding(5, 4)
        self.status_label.set_alignment(0.0, 0.5)
        self.status_label.show()

        hbox = gtk.HBox()
        hbox.pack_start(title, expand=True, fill=True)
        hbox.pack_start(vbox, expand=False, fill=True, padding=20)
        hbox.pack_start(self.status_label, expand=False, fill=True)
        hbox.show()

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        frame.add(hbox)
        frame.show()

        eb = gtk.EventBox()
        eb.add(frame)
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff"))
        eb.show()

        frame_menu = gtk.Frame()
        frame_menu.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        frame_menu.add(title_menu)
        frame_menu.show()

        title_box = gtk.HBox()
        title_box.pack_start(frame_menu, expand=False, fill=True)
        title_box.pack_start(eb, expand=True, fill=True)
        title_box.show()

        return title_box
Exemplo n.º 7
0
    def _create_dialog_ui(self):
        self.toplevel = gtk.Dialog()
        self._main_vbox = self.toplevel.get_content_area()

        self.vbox = gtk.VBox()
        self._main_vbox.pack_start(self.vbox, True, True)
        self.vbox.show()

        # FIXME
        # stoqlib/gui/base/search.py - hides the header
        self.header = gtk.EventBox()
        self.vbox.pack_start(self.header, False, False)
        self.header.show()

        self.main = gtk.EventBox()
        self.vbox.pack_start(self.main)
        self.main.show()

        # FIXME
        # stoqlib/gui/dialogs/importerdialog.py - setting
        # stoqlib/gui/base/lists.py - removes the label
        # stoqlib/gui/base/search.py - removes the label
        # plugins/ecf/deviceconstanteditor.py - removes the label
        self.main_label = gtk.Label()
        self.main.add(self.main_label)
        self.main_label.show()

        hbox1 = gtk.HBox()
        self.vbox.pack_start(hbox1, False)
        hbox1.show()

        # FIXME
        # stoqlib/gui/dialogs/paymentmethod.py
        # stoqlib/gui/search/salesearch.py
        self.extra_holder = gtk.EventBox()
        hbox1.pack_start(self.extra_holder, True, True)
        self.extra_holder.show()

        # FIXME
        # stoqlib/gui/search/productsearch.py
        # stoqlib/gui/search/servicesearch.py
        self.print_holder = gtk.EventBox()
        hbox1.pack_start(self.print_holder, True, True)
        self.print_holder.show()

        # FIXME
        # stoqlib/gui/base/search.py
        # stoqlib/gui/slaves/productslave.py
        self.details_holder = gtk.EventBox()
        hbox1.pack_end(self.details_holder, False, False)
        self.details_holder.show()

        # FIXME
        # stoqlib/gui/dialogs/quotedialog.py
        self.notice = gtk.EventBox()
        hbox1.pack_start(self.notice, False)
        self.notice.show()

        action_area = self.toplevel.get_action_area()
        action_area.set_border_width(6)
        action_area.set_layout(gtk.BUTTONBOX_END)

        self.cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL)
        action_area.pack_start(self.cancel_button, True, True)
        self.cancel_button.show()

        self.ok_button = gtk.Button(stock=gtk.STOCK_OK)
        self.ok_button.set_use_underline(True)
        action_area.pack_start(self.ok_button, True, True)
        self.ok_button.show()
Exemplo n.º 8
0
    def activate_open(self, parent=None, buf=None):
        if self.fname != '':
            fname = self.fname
            self.fname = ''
        elif buf == None:
            fname = self.file_open()
        else:
            fname = 'Clipboard'
        print fname
        if fname:
            lines = []
            comments = {}
            if buf == None:
                f = open(fname, "rb")
                rbuf = f.read()
                if rbuf[:9] == "RE-LABv05":
                    print 'Re-Lab project file'
                    # skip "signature"
                    off = 35
                    k = ""
                    while k != "Num of lines":
                        off, k, v = self.rlp_unpack(rbuf, off)
                        print k, v
                    for i in range(v):
                        l = struct.unpack("<I", rbuf[off:off + 4])[0]
                        off += 4
                        s = ord(rbuf[off])
                        lines.append((l, s))
                        off += 1

                    while k != "Num of comments":
                        off, k, v = self.rlp_unpack(rbuf, off)
                        print k, v
                    for i in range(v):
                        tl = ord(rbuf[off])
                        off += 1
                        txt = rbuf[off:off + tl]
                        off += tl
                        coff = struct.unpack("<I", rbuf[off:off + 4])[0]
                        off += 4
                        clen = struct.unpack("<I", rbuf[off:off + 4])[0]
                        off += 4
                        clr0 = ord(rbuf[off]) / 255
                        clr1 = ord(rbuf[off + 1]) / 255
                        clr2 = ord(rbuf[off + 2]) / 255
                        ct = ord(rbuf[off + 3])
                        off += 4
                        comments[coff] = hexview.Comment(
                            txt, coff, clen, (clr0, clr1, clr2), ct)
                    while k != "Data BLOB":
                        off, k, v = self.rlp_unpack(rbuf, off)
                        print k, v
                    buf = rbuf[off:]
                elif fname[len(fname) - 3:] == "rlp":
                    print 'Probably old Re-Lab project file'
                    llen = struct.unpack("<I", rbuf[0:4])[0]
                    clen = struct.unpack("<I", rbuf[4:8])[0]
                    off = 8
                    for i in range(llen):
                        l1 = struct.unpack("<I", rbuf[off:off + 4])[0]
                        off += 4
                        l2 = ord(rbuf[off])
                        off += 1
                        if l2 > 1:
                            off += 4
                            l2 = 1
                        lines.append((l1, l2))
                    for i in range(clen):
                        c1 = struct.unpack("<I", rbuf[off:off + 4])[0]
                        off += 4
                        c2 = ord(rbuf[off])
                        off += 1
                        c3 = ord(rbuf[off])
                        off += 1
                        c4 = rbuf[off:off + c3]
                        comments[c1 + 1] = hexview.Comment(
                            c4, c1 + 1, c2, (1, 0, 0), 0)
                        off += c3
                    buf = rbuf[off:]
                else:
                    buf = rbuf
                f.close()
            doc = hexview.HexView(buf, lines, comments)
            doc.parent = self
            doc.fname = fname
            dnum = len(self.das)
            self.das[dnum] = doc
            pos = fname.rfind('/')
            if pos != -1:
                pname = fname[pos + 1:]
            else:
                pname = fname

            label = gtk.Label(pname)
            ebox = gtk.EventBox()
            ebox.add(label)
            ebox.show_all()
            self.notebook.append_page(doc.table, ebox)
            self.notebook.set_tab_reorderable(doc.table, True)
            self.notebook.show_tabs = True
            self.notebook.show_all()
            self.notebook.set_current_page(-1)
            doc.hv.grab_focus()
        return
Exemplo n.º 9
0
 def _build_search(self, widget):
     '''Builds the search bar.'''
     self.srchtab = gtk.HBox()
     # close button
     close = gtk.Image()
     close.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
     eventbox = gtk.EventBox()
     eventbox.add(close)
     eventbox.connect("button-release-event", self._close)
     self.srchtab.pack_start(eventbox, expand=False, fill=False, padding=3)
     # label
     label = gtk.Label("Find:")
     self.srchtab.pack_start(label, expand=False, fill=False, padding=3)
     # entry
     self.search_entry = gtk.Entry()
     self.search_entry.set_tooltip_text(
         "Type here the phrase you want to find")
     self.search_entry.connect("activate", self._find, "next")
     self.search_entry.connect("changed", self._find, "find")
     self.srchtab.pack_start(self.search_entry,
                             expand=False,
                             fill=False,
                             padding=3)
     # find next button
     if self.small:
         but_text = ''
     else:
         but_text = 'Next'
     butn = SemiStockButton(but_text, gtk.STOCK_GO_DOWN)
     butn.connect("clicked", self._find, "next")
     butn.set_tooltip_text("Find the next ocurrence of the phrase")
     self.srchtab.pack_start(butn, expand=False, fill=False, padding=3)
     # find previous button
     if self.small:
         but_text = ''
     else:
         but_text = ('Previous')
     butp = SemiStockButton(but_text, gtk.STOCK_GO_UP)
     butp.connect("clicked", self._find, "previous")
     butp.set_tooltip_text("Find the previous ocurrence of the phrase")
     self.srchtab.pack_start(butp, expand=False, fill=False, padding=3)
     # make last two buttons equally width
     wn, hn = butn.size_request()
     wp, hp = butp.size_request()
     newwidth = max(wn, wp)
     butn.set_size_request(newwidth, hn)
     butp.set_size_request(newwidth, hp)
     # Match case CheckButton
     butCase = gtk.CheckButton(('Match case'))
     butCase.set_active(self._matchCaseValue)
     butCase.connect("clicked", self._matchCase)
     # FIXME
     # current version of gtk.TextIter doesn't support SEARCH_CASE_INSENSITIVE
     #butCase.show()
     #self.srchtab.pack_start(butCase, expand=False, fill=False, padding=3)
     self.pack_start(self.srchtab, expand=False, fill=False)
     # Results
     self._resultsLabel = gtk.Label("")
     self.srchtab.pack_start(self._resultsLabel,
                             expand=False,
                             fill=False,
                             padding=3)
     self.searching = False
Exemplo n.º 10
0
    def buildInterface(self, interface):

        # Load users.dat
        self.users = UserManager(os.path.join(paths.CONFIG_DIR, 'users.dat'))

        self.currentInterface = interface

        lUser = gtk.Label(_('_User:'******'_Password:'******'')
        lStatus = gtk.Label(_('_Status:'))

        lUser.set_use_underline(True)
        lPass.set_use_underline(True)
        lStatus.set_use_underline(True)

        # Make a ListStore for users
        self.userListStore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        # User entry with combo (from ListStore)
        self.tUser = gtk.ComboBoxEntry(self.userListStore, 0)
        self.tUser.connect("changed", self.on_comboxEntry_changed)
        self.tUser.connect("key-release-event", self.on_comboxEntry_keyrelease)
        # User entry completion (from ListStore)
        self.userCompletion = gtk.EntryCompletion()
        self.userCompletion.set_model(self.userListStore)
        self.tUser.get_children()[0].set_completion(self.userCompletion)
        self.userCompletion.connect('match-selected', self.matchSelected)
        # Add pictures to the completion
        self.userPixbufCell = gtk.CellRendererPixbuf()
        self.userCompletion.pack_start(self.userPixbufCell)
        self.userCompletion.add_attribute(self.userPixbufCell, 'pixbuf', 1)
        self.userCompletion.set_text_column(0)

        # Make a ListStore for Status
        self.statusListStore = gtk.ListStore(gtk.gdk.Pixbuf,
                                              gobject.TYPE_STRING,
                                              gobject.TYPE_STRING)

        self.tStatus = gtk.ComboBox(self.statusListStore)
        self.statusPixbufCell = gtk.CellRendererPixbuf()
        self.statusTextCell = gtk.CellRendererText()
        self.tStatus.pack_start(self.statusPixbufCell, False)
        self.tStatus.pack_start(self.statusTextCell, False)
        self.statusPixbufCell.set_property('xalign', 0.0)
        self.statusPixbufCell.set_property('xpad', 5)
        self.statusTextCell.set_property('xalign', 0.0)
        self.statusTextCell.set_property('xpad', 5)
        self.tStatus.add_attribute(self.statusTextCell, 'text', 2)
        self.tStatus.add_attribute(self.statusPixbufCell, 'pixbuf', 0)

        self.tPass = gtk.Entry(128)
        self.tPass.set_visibility(False)
        self.tPass.connect('activate' , self.bLogin_clicked)
        self.tPass.connect('key-press-event', self.on_password_keypressed)

        lUser.set_mnemonic_widget(self.tUser)
        lPass.set_mnemonic_widget(self.tPass)
        lStatus.set_mnemonic_widget(self.tStatus)

        # fill the status combobox
        self.statusList = []
        j = 0
        for i in self.controller.status_ordered[ 1 ]:
            if i != 'offline' and i not in self.statusList:
                self.statusListStore\
                        .append([ self.controller.theme.statusToPixbuf(
                               emesenelib.common.status_table[i]).scale_simple(20,20,gtk.gdk.INTERP_BILINEAR), i,
                               _(self.controller.status_ordered[2][j]) ])
                self.statusList.append(i)
            j += 1

        self.tStatus.set_active(0)

        pixbuf = self.controller.theme.getImage('login', False)
        self.loginImage = Widgets.avatarHolder()
        self.loginImage.set_from_pixbuf(pixbuf)
        if not self.controller.config.glob['dontShowAvatarInLoginWindow']:
            self.pack_start(self.loginImage , True , False)

        self.fieldsBox = gtk.VBox(spacing=10)

        userBox = gtk.VBox(spacing=4)
        lUser.set_alignment(0.0, 0.5)
        userBox.pack_start(lUser , False , False)
        userBox.pack_start(self.tUser , False , False)

        self.fieldsBox.pack_start(userBox, False, False)

        passBox = gtk.VBox(spacing=4)
        passLBox = gtk.HBox(spacing=6)
        lPass.set_alignment(0.0, 0.5)
        passLBox.pack_start(lPass , False , False)
        passLBox.pack_start(self.lCaps , False , False)
        passBox.pack_start(passLBox , False , False)
        passBox.pack_start(self.tPass , False , False)

        self.fieldsBox.pack_start(passBox, False, False)

        statusBox = gtk.VBox(spacing=4)
        lStatus.set_alignment(0.0, 0.5)
        statusBox.pack_start(lStatus , False , False)
        statusBox.pack_end(self.tStatus, True, True)

        self.fieldsBox.pack_start(statusBox, False, False)

        fieldsAlig = gtk.Alignment(0.5, 0.5, 0.75, 0.0)
        fieldsAlig.add(self.fieldsBox)
        self.pack_start(fieldsAlig, True, False)

        self.lReconnectCounter = None

        buttonBox = gtk.HButtonBox()

        if interface == 'login':
            self.bLogin = gtk.Button(_('_Login'), gtk.STOCK_CONNECT)
            self.bLogin.connect('clicked' , self.bLogin_clicked)
            buttonBox.pack_start(self.bLogin, False, False)

            self.cRemember = gtk.CheckButton(_('_Remember me'), True)
            self.cRemember.connect('toggled' , self.on_cRemember_toggled)

            self.forgetMe = gtk.EventBox()
            self.forgetMe.set_events(gtk.gdk.BUTTON_PRESS_MASK)
            self.forgetMeLabel = gtk.Label('<span foreground="#0000AA">(' + \
                                            _('Forget me') + ')</span>')
            self.forgetMeLabel.set_use_markup(True)
            self.forgetMe.add(self.forgetMeLabel)
            self.forgetMe.connect('button_press_event', self.onForgetMe)
            self.forgetMe.set_child_visible(False)

            self.cRememberPass = gtk.CheckButton(_('R_emember password'), True)
            self.cRememberPass.connect('toggled' , self.on_cRememberPass_toggled)

            # TODO: find a better description and get-text it
            self.cAutoLogin = gtk.CheckButton(_('Auto-Login'), True)
            self.cAutoLogin.connect('toggled' , self.on_cAutoLogin_toggled)

            #this fixes a bug with user config
            current_user = self.controller.config.getCurrentUser()

            if self.controller.config.glob['rememberMe'] and current_user != '':
                self.cRemember.set_active(True)

            if self.controller.config.glob['rememberMyPassword'] and current_user != '':
                self.cRememberPass.set_active(True)

            if self.controller.config.glob['autoLogin'] and current_user != '':
                self.cAutoLogin.set_active(True)

            self.checkBox = gtk.VBox(spacing=4)

            rememberBox = gtk.HBox(spacing=4)
            rememberBox.pack_start(self.cRemember , False , False)
            rememberBox.pack_start(self.forgetMe , False , False)
                
            self.checkBox.pack_start(rememberBox, False, False)
            self.checkBox.pack_start(self.cRememberPass, False, False)
            self.checkBox.pack_start(self.cAutoLogin, False, False)

            try:
                import locale
                link = "http://status.messenger.msn.com/Status.aspx?mkt="
                link += locale.getlocale()[0].replace('_','-')
                serverStatus = gtk.LinkButton(link,_('Service Status'))
                self.checkBox.pack_start(serverStatus, False, False)
            except:
                # some people have really weird python installs
                pass
                            
            checkAlig = gtk.Alignment(0.5, 0.5)
            checkAlig.add(self.checkBox)

            self.pack_start(checkAlig , True , False)

            serverBox = gtk.VBox(spacing=40)
            serverLBox = gtk.HBox(spacing=6)

            serverBox.pack_start(serverLBox , False , False)

            checkAlig1 = gtk.Alignment(0.5, 0.5)
            checkAlig1.add(serverBox)

            self.pack_start(buttonBox, True, False)
        
            self.pack_start(checkAlig1, True, False)

        elif interface == 'reconnect':
            self.fieldsBox.set_sensitive(False)

            self.lConnectionError = gtk.Label()
            self.lConnectionError.set_markup('<b>' + _('Connection error') + '</b>')

            self.lReconnectCounter = gtk.Label()

            self.bCancelReconnect = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL)
            self.bCancelReconnect.connect('clicked', self.onCancelReconnect)
            self.bReconnectNow = gtk.Button(_('Reconnect now'), gtk.STOCK_CONNECT)
            self.bReconnectNow.connect('clicked' , self.onReconnectNow)

            self.pack_start(self.lConnectionError, True, False)
            self.pack_start(self.lReconnectCounter, True, False)
            buttonBox.pack_start(self.bReconnectNow, True, False)
            buttonBox.pack_start(self.bCancelReconnect, False, False)
            self.pack_start(buttonBox, True, False)
        elif interface == 'loading':
            self.fieldsBox.set_sensitive(False)

            pixbuf = self.controller.theme.getImage('loading', True)
            self.loading = gtk.image_new_from_animation(pixbuf)

            cancelButton = gtk.Button(_('Cancel'), gtk.STOCK_CANCEL)
            cancelButton.connect('clicked', self.onCancelLogin)
            buttonBox.pack_start(cancelButton, False, False)

            self.pack_start(self.loading, False, False)
            self.pack_start(buttonBox, True, False)
            # XXX: progress stuff maybe?

        # fill the user list
        self.refreshUserList()
        if self.users.userExists(self.controller.config.glob['lastLoggedAccount']):
                self.tUser.get_children()[0].set_text(self.controller.config.glob['lastLoggedAccount'])

        self.show_all()
        self.tUser.grab_focus()
Exemplo n.º 11
0
    def _bp_cell_editing_started_cb(self, cell, editable, path):
        iter = self.liststore.get_iter(path)
        action_name = self.liststore.get_value(iter, self.action_column)
        bp_name = self.liststore.get_value(iter, self.bp_column)

        editable.set_sensitive(False)
        dialog = gtk.Dialog()
        if not gtk2compat.USE_GTK3:
            dialog.set_extension_events(gdk.EXTENSION_EVENTS_ALL)
        dialog.set_modal(True)
        dialog.set_title(_("Edit binding for '%s'") % action_name)
        dialog.set_transient_for(self.get_toplevel())
        dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        dialog.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK,
                           gtk.RESPONSE_OK)
        dialog.set_default_response(gtk.RESPONSE_OK)
        dialog.connect("response", self._bp_edit_dialog_response_cb, editable)
        dialog.ok_btn = dialog.get_widget_for_response(gtk.RESPONSE_OK)
        dialog.ok_btn.set_sensitive(bp_name is not None)

        evbox = gtk.EventBox()
        evbox.set_border_width(12)
        evbox.connect("button-press-event", self._bp_edit_box_button_press_cb,
                      dialog, editable)
        evbox.connect("enter-notify-event", self._bp_edit_box_enter_cb)

        table = gtk.Table(3, 2)
        table.set_row_spacings(12)
        table.set_col_spacings(12)

        row = 0
        label = gtk.Label()
        label.set_alignment(0, 0.5)
        label.set_text(_("Action:"))
        table.attach(label, 0, 1, row, row + 1, gtk.FILL)

        label = gtk.Label()
        label.set_alignment(0, 0.5)
        label.set_text(str(action_name))
        table.attach(label, 1, 2, row, row + 1, gtk.FILL | gtk.EXPAND)

        row += 1
        label = gtk.Label()
        label.set_alignment(0, 0.5)
        label.set_text(_("Button press:"))
        table.attach(label, 0, 1, row, row + 1, gtk.FILL)

        label = gtk.Label()
        label.set_alignment(0, 0.5)
        label.set_text(str(bp_name))
        dialog.bp_name = bp_name
        dialog.bp_name_orig = bp_name
        dialog.bp_label = label
        table.attach(label, 1, 2, row, row + 1, gtk.FILL | gtk.EXPAND)

        row += 1
        label = gtk.Label()
        label.set_size_request(300, 75)
        label.set_alignment(0, 0)
        label.set_line_wrap(True)
        dialog.hint_label = label
        self._bp_edit_dialog_set_standard_hint(dialog)
        table.attach(label, 0, 2, row, row + 1, gtk.FILL | gtk.EXPAND,
                     gtk.FILL | gtk.EXPAND, 0, 12)

        evbox.add(table)
        dialog.get_content_area().pack_start(evbox, True, True)
        evbox.show_all()

        dialog.show()
    def __init__(self,
                 controller,
                 pixbuf,
                 title=_("Select area of image"),
                 parent=None):
        gtk.Dialog.__init__(self, title, parent,
                            gtk.DIALOG_DESTROY_WITH_PARENT)

        self.controller = controller
        self.set_default_response(gtk.RESPONSE_CANCEL)
        self.set_resizable(False)
        self.button_accept = gtk.Button(stock=gtk.STOCK_OK)
        self.button_accept.connect(
            'clicked', lambda *args: self.response(gtk.RESPONSE_OK))
        self.button_accept.set_sensitive(False)
        self.button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.button_cancel.connect(
            'clicked', lambda *args: self.response(gtk.RESPONSE_CANCEL))

        self.selector = ImageAreaSelector(controller, self.button_accept)
        self.selector.set_from_pixbuf(pixbuf)

        if not MAC:
            self.button_rcw = gtk.Button(label=_("Rotate"))
            self.button_rcw.connect("clicked", self._on_rcw_clicked)
            self.button_rccw = gtk.Button(label=_("Rotate"))
            self.button_rccw.connect("clicked", self._on_rccw_clicked)

            if Theme:
                theme = Theme.Theme(Config.Config())  # FIXME ARRGH
                image_90 = gtk.Image()
                image_90.set_from_pixbuf(theme.getImage("rotate-90"))
                self.button_rcw.set_image(image_90)
                image_270 = gtk.Image()
                image_270.set_from_pixbuf(theme.getImage("rotate-270"))
                self.button_rccw.set_image(image_270)

            if gtk.gtk_version >= (2, 10, 0):
                self.action_area.pack_start(self.button_rccw)
                self.action_area.pack_end(self.button_rcw)

        self.action_area.pack_end(self.button_cancel)
        self.action_area.pack_end(self.button_accept)

        ##Draw the statusBar
        self.eventBox = gtk.EventBox()
        box = gtk.HBox(False, 0)
        self.eventBox.set_size_request(0, 30)
        self.eventBox.add(box)
        self.eventBox.modify_bg(gtk.STATE_NORMAL, self.controller.tooltipColor)
        self.label = gtk.Label(_('Draw a square to select an area'))
        self.label.set_ellipsize(pango.ELLIPSIZE_END)
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_DIALOG_INFO,
                             gtk.ICON_SIZE_LARGE_TOOLBAR)
        box.pack_start(image, False, False, 5)
        box.pack_start(self.label, True, True, 5)

        self.vbox.pack_start(self.selector)
        self.vbox.pack_end(self.eventBox)
        self.vbox.show_all()
Exemplo n.º 13
0
    def create(self):
        super(Submenu, self).create()

        player_id = None
        for id in self.stat_dict.keys():
            if self.seat == self.stat_dict[id]['seat']:
                player_id = id
        if player_id is None:
            self.destroy_pop()

        number_of_items = len(self.pop.pu_stats)
        if number_of_items < 1:
            self.destroy_pop()

        #Put an eventbox into an eventbox - this allows an all-round
        #border to be created
        self.inner_box = gtk.EventBox()
        self.inner_box.set_border_width(1)
        self.inner_box.modify_bg(gtk.STATE_NORMAL, self.win.aw.bgcolor)
        self.inner_box.modify_fg(gtk.STATE_NORMAL, self.win.aw.fgcolor)
        #set outerbox colour to grey, and attach innerbox
        self.eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#303030"))
        self.eb.add(self.inner_box)

        self.grid = gtk.Table(number_of_items, 3, False)
        self.inner_box.add(self.grid)

        grid_line = {}
        row = 1

        for stat, submenu_to_run in self.pop.pu_stats_submenu:

            grid_line[row] = {}
            grid_line[row]['eb'] = gtk.EventBox()
            grid_line[row]['lab'] = gtk.Label()
            grid_line[row]['eb'].add(grid_line[row]['lab'])
            grid_line[row]['eb'].modify_bg(gtk.STATE_NORMAL,
                                           self.win.aw.bgcolor)
            grid_line[row]['eb'].modify_fg(gtk.STATE_NORMAL,
                                           self.win.aw.fgcolor)
            grid_line[row]['lab'].modify_bg(gtk.STATE_NORMAL,
                                            self.win.aw.bgcolor)
            grid_line[row]['lab'].modify_fg(gtk.STATE_NORMAL,
                                            self.win.aw.fgcolor)
            grid_line[row]['lab'].set_alignment(xalign=0, yalign=1)
            grid_line[row]['lab'].set_padding(2, 0)

            try:
                number = Stats.do_stat(self.stat_dict,
                                       player=int(player_id),
                                       stat=stat,
                                       hand_instance=self.hand_instance)
                grid_line[row]['text'] = number[3]
                grid_line[row]['lab'].set_text(number[3])
                Stats.do_tip(grid_line[row]['lab'],
                             number[5] + " " + number[4])
            except:
                grid_line[row]['text'] = stat
                grid_line[row]['lab'].set_text(stat)

            if row == 1:
                #put an "x" close label onto the popup, invert bg/fg
                # the window can also be closed by clicking on any non-menu label
                # but this "x" is added incase the menu is entirely non-menu labels

                grid_line[row]['x'] = gtk.EventBox()
                xlab = gtk.Label()
                xlab.set_text("x")
                xlab.modify_bg(gtk.STATE_NORMAL, self.win.aw.fgcolor)
                xlab.modify_fg(gtk.STATE_NORMAL, self.win.aw.bgcolor)
                grid_line[row]['x'].add(xlab)
                grid_line[row]['x'].modify_bg(gtk.STATE_NORMAL,
                                              self.win.aw.fgcolor)
                grid_line[row]['x'].modify_fg(gtk.STATE_NORMAL,
                                              self.win.aw.bgcolor)
                #grid_line[row]['x'].set_border_width(2)
                self.grid.attach(grid_line[row]['x'], 2, 3, row - 1, row)
                grid_line[row]['x'].connect("button_press_event",
                                            self.submenu_press_cb, "_destroy")

            if submenu_to_run:
                grid_line[row]['arrow_object'] = gtk.EventBox()
                lab = gtk.Label()
                lab.set_text(">")
                lab.modify_bg(gtk.STATE_NORMAL, self.win.aw.bgcolor)
                lab.modify_fg(gtk.STATE_NORMAL, self.win.aw.fgcolor)
                lab.set_alignment(xalign=0.75, yalign=0.5)
                grid_line[row]['arrow_object'].add(lab)
                grid_line[row]['arrow_object'].modify_bg(
                    gtk.STATE_NORMAL, self.win.aw.bgcolor)
                grid_line[row]['arrow_object'].modify_fg(
                    gtk.STATE_NORMAL, self.win.aw.fgcolor)
                grid_line[row]['arrow_object'].connect("button_press_event",
                                                       self.submenu_press_cb,
                                                       submenu_to_run)
                if row == 1:
                    self.grid.attach(grid_line[row]['arrow_object'], 1, 2,
                                     row - 1, row)
                else:
                    self.grid.attach(grid_line[row]['arrow_object'], 1, 3,
                                     row - 1, row)
                grid_line[row]['eb'].connect("button_press_event",
                                             self.submenu_press_cb,
                                             submenu_to_run)
            else:
                grid_line[row]['eb'].connect("button_press_event",
                                             self.button_press_cb)

            self.grid.attach(grid_line[row]['eb'], 0, 1, row - 1, row)

            row += 1

        self.show_all()
Exemplo n.º 14
0
    def __init__(self,
                 screen,
                 callback,
                 view_type='form',
                 new=False,
                 many=0,
                 domain=None,
                 context=None,
                 save_current=False,
                 title='',
                 rec_name=None):
        NoModal.__init__(self)
        self.screen = screen
        self.callback = callback
        self.many = many
        self.domain = domain
        self.context = context
        self.save_current = save_current
        self.title = title
        self.prev_view = self.screen.current_view
        self.screen.screen_container.alternate_view = True
        if view_type not in (x.view_type for x in self.screen.views) and \
                view_type not in self.screen.view_to_load:
            self.screen.add_view_id(None, view_type)
        self.screen.switch_view(view_type=view_type)
        if new:
            self.screen.new(rec_name=rec_name)
        self.win = gtk.Dialog(_('Link'), self.parent,
                              gtk.DIALOG_DESTROY_WITH_PARENT)
        self.win.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.win.set_icon(TRYTON_ICON)
        self.win.set_deletable(False)
        self.win.connect('delete-event', lambda *a: True)
        self.win.connect('close', self.close)
        self.win.connect('response', self.response)

        self.accel_group = gtk.AccelGroup()
        self.win.add_accel_group(self.accel_group)

        readonly = self.screen.readonly or self.screen.group.readonly

        self.but_ok = None
        self.but_new = None

        if view_type == 'form':
            if not new and self.screen.current_record.id < 0:
                stock_id = gtk.STOCK_DELETE
            else:
                stock_id = gtk.STOCK_CANCEL
            self.but_cancel = self.win.add_button(stock_id,
                                                  gtk.RESPONSE_CANCEL)

        if new and self.many:
            self.but_new = self.win.add_button(gtk.STOCK_NEW,
                                               gtk.RESPONSE_ACCEPT)
            self.but_new.set_accel_path('<tryton>/Form/New', self.accel_group)

        if self.save_current:
            self.but_ok = gtk.Button(_('_Save'))
            img_save = gtk.Image()
            img_save.set_from_stock('tryton-save', gtk.ICON_SIZE_BUTTON)
            self.but_ok.set_image(img_save)
            self.but_ok.set_accel_path('<tryton>/Form/Save', self.accel_group)
            self.but_ok.set_can_default(True)
            self.but_ok.show()
            self.win.add_action_widget(self.but_ok, gtk.RESPONSE_OK)
            if not new:
                self.but_ok.props.sensitive = False
        else:
            self.but_ok = self.win.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        self.but_ok.add_accelerator('clicked', self.accel_group,
                                    gtk.keysyms.Return, gtk.gdk.CONTROL_MASK,
                                    gtk.ACCEL_VISIBLE)
        self.win.set_default_response(gtk.RESPONSE_OK)

        self.win.set_title(self.title)

        title = gtk.Label()
        title.modify_font(pango.FontDescription("bold 12"))
        title.set_label(self.title)
        title.set_padding(20, 3)
        title.set_alignment(0.0, 0.5)
        title.set_size_request(0, -1)  # Allow overflow
        title.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000"))
        title.show()

        hbox = gtk.HBox()
        hbox.pack_start(title, expand=True, fill=True)
        hbox.show()

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        frame.add(hbox)
        frame.show()

        eb = gtk.EventBox()
        eb.add(frame)
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff"))
        eb.show()

        self.win.vbox.pack_start(eb, expand=False, fill=True, padding=3)

        if view_type == 'tree':
            hbox = gtk.HBox(homogeneous=False, spacing=0)
            tooltips = common.Tooltips()
            access = common.MODELACCESS[screen.model_name]

            if domain is not None:
                self.wid_text = gtk.Entry()
                self.wid_text.set_property('width_chars', 13)
                self.wid_text.connect('activate', self._sig_activate)
                self.wid_text.connect('focus-out-event', self._focus_out)
                hbox.pack_start(self.wid_text, expand=True, fill=True)

                self.but_add = gtk.Button()
                tooltips.set_tip(self.but_add, _('Add'))
                self.but_add.connect('clicked', self._sig_add)
                img_add = gtk.Image()
                img_add.set_from_stock('tryton-list-add',
                                       gtk.ICON_SIZE_SMALL_TOOLBAR)
                img_add.set_alignment(0.5, 0.5)
                self.but_add.add(img_add)
                self.but_add.set_relief(gtk.RELIEF_NONE)
                hbox.pack_start(self.but_add, expand=False, fill=False)
                if not access['read'] or readonly:
                    self.but_add.set_sensitive(False)

                self.but_remove = gtk.Button()
                tooltips.set_tip(self.but_remove, _('Remove <Del>'))
                self.but_remove.connect('clicked', self._sig_remove, True)
                img_remove = gtk.Image()
                img_remove.set_from_stock('tryton-list-remove',
                                          gtk.ICON_SIZE_SMALL_TOOLBAR)
                img_remove.set_alignment(0.5, 0.5)
                self.but_remove.add(img_remove)
                self.but_remove.set_relief(gtk.RELIEF_NONE)
                hbox.pack_start(self.but_remove, expand=False, fill=False)
                if not access['read'] or readonly:
                    self.but_remove.set_sensitive(False)

                hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

            self.but_new = gtk.Button()
            tooltips.set_tip(self.but_new, _('Create a new record <F3>'))
            self.but_new.connect('clicked', self._sig_new)
            img_new = gtk.Image()
            img_new.set_from_stock('tryton-new', gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_new.set_alignment(0.5, 0.5)
            self.but_new.add(img_new)
            self.but_new.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_new, expand=False, fill=False)
            if not access['create'] or readonly:
                self.but_new.set_sensitive(False)

            self.but_del = gtk.Button()
            tooltips.set_tip(self.but_del, _('Delete selected record <Del>'))
            self.but_del.connect('clicked', self._sig_remove, False)
            img_del = gtk.Image()
            img_del.set_from_stock('tryton-delete',
                                   gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_del.set_alignment(0.5, 0.5)
            self.but_del.add(img_del)
            self.but_del.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_del, expand=False, fill=False)
            if not access['delete'] or readonly:
                self.but_del.set_sensitive(False)

            self.but_undel = gtk.Button()
            tooltips.set_tip(self.but_undel,
                             _('Undelete selected record <Ins>'))
            self.but_undel.connect('clicked', self._sig_undelete)
            img_undel = gtk.Image()
            img_undel.set_from_stock('tryton-undo',
                                     gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_undel.set_alignment(0.5, 0.5)
            self.but_undel.add(img_undel)
            self.but_undel.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_undel, expand=False, fill=False)
            if not access['delete'] or readonly:
                self.but_undel.set_sensitive(False)

            hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

            self.but_pre = gtk.Button()
            tooltips.set_tip(self.but_pre, _('Previous'))
            self.but_pre.connect('clicked', self._sig_previous)
            img_pre = gtk.Image()
            img_pre.set_from_stock('tryton-go-previous',
                                   gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_pre.set_alignment(0.5, 0.5)
            self.but_pre.add(img_pre)
            self.but_pre.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_pre, expand=False, fill=False)

            self.label = gtk.Label('(0,0)')
            hbox.pack_start(self.label, expand=False, fill=False)

            self.but_next = gtk.Button()
            tooltips.set_tip(self.but_next, _('Next'))
            self.but_next.connect('clicked', self._sig_next)
            img_next = gtk.Image()
            img_next.set_from_stock('tryton-go-next',
                                    gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_next.set_alignment(0.5, 0.5)
            self.but_next.add(img_next)
            self.but_next.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(self.but_next, expand=False, fill=False)

            hbox.pack_start(gtk.VSeparator(), expand=False, fill=True)

            but_switch = gtk.Button()
            tooltips.set_tip(but_switch, _('Switch'))
            but_switch.connect('clicked', self.switch_view)
            img_switch = gtk.Image()
            img_switch.set_from_stock('tryton-fullscreen',
                                      gtk.ICON_SIZE_SMALL_TOOLBAR)
            img_switch.set_alignment(0.5, 0.5)
            but_switch.add(img_switch)
            but_switch.set_relief(gtk.RELIEF_NONE)
            hbox.pack_start(but_switch, expand=False, fill=False)

            but_switch.props.sensitive = screen.number_of_views > 1

            tooltips.enable()

            alignment = gtk.Alignment(1.0)
            alignment.add(hbox)
            alignment.show_all()

            self.win.vbox.pack_start(alignment, expand=False, fill=True)

        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_placement(gtk.CORNER_TOP_LEFT)
        scroll.set_shadow_type(gtk.SHADOW_NONE)
        scroll.show()
        self.win.vbox.pack_start(scroll, expand=True, fill=True)

        scroll.add(self.screen.screen_container.alternate_viewport)

        self.create_info_bar()
        self.win.vbox.pack_start(self.info_bar, False, True)

        sensible_allocation = self.sensible_widget.get_allocation()
        self.win.set_default_size(int(sensible_allocation.width * 0.9),
                                  int(sensible_allocation.height * 0.9))

        if view_type == 'tree':
            self.screen.signal_connect(self, 'record-message', self._sig_label)
            self.screen.screen_container.alternate_viewport.connect(
                'key-press-event', self.on_keypress)

        if self.save_current and not new:
            self.screen.signal_connect(self, 'record-message',
                                       self.activate_save)
            self.screen.signal_connect(self, 'record-modified',
                                       self.activate_save)

        self.register()
        self.win.show()

        common.center_window(self.win, self.parent, self.sensible_widget)

        self.screen.display()
        self.screen.current_view.set_cursor()
Exemplo n.º 15
0
Arquivo: iads.py Projeto: mjibson/junk
	def __init__(self):
		threading.Thread.__init__(self)

		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.window.connect('destroy', self.destroy)
		self.window.connect('key-press-event', self.press)
		self.window.fullscreen()

		global WIDTH, HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, TIME_OFF, TIME_ON
		self.screen = self.window.get_screen()
		WIDTH = self.screen.get_width()
		HEIGHT = self.screen.get_height()

		try:
			url = globals()['LIST_HOST'] + 'info/' + globals()['LOCATION_ID']
			logging.debug('downloading info: %s', url)
			info = urllib2.urlopen(url).read().split()

			for i in info:
				t = [int(v) for v in i[1:].split(':')]

				if i[0] == 'h':
					SCREEN_HEIGHT = int(i[1:])
				elif i[0] == 'w':
					SCREEN_WIDTH = int(i[1:])
				elif i[0] == 'f':
					TIME_OFF = time(t[0], t[1], t[2])
				elif i[0] == 'n':
					TIME_ON = time(t[0], t[1], t[2])
		except:
			logging.error('could not download screen info', exc_info=True)
			SCREEN_WIDTH = 0
			SCREEN_HEIGHT = 0
			TIME_OFF = time.min
			TIME_ON = time.min

		logging.info('display size: ' + str(WIDTH) + 'x' + str(HEIGHT))
		logging.info('screen size: ' + str(SCREEN_WIDTH) + 'x' + str(SCREEN_HEIGHT))
		logging.info('time on: ' + str(TIME_ON))
		logging.info('time off: ' + str(TIME_OFF))

		self.logo = Ad('logo.png')

		self.image = gtk.Image()
		self.image.set_from_pixbuf(self.logo.pixbuf)
		self.image.show()

		self.eventbox = gtk.EventBox()
		self.eventbox.add(self.image)
		self.eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color())
		self.eventbox.show()

		self.window.add(self.eventbox)
		self.window.show()

		pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
		color = gtk.gdk.Color()
		cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
		self.eventbox.window.set_cursor(cursor)

		self.lock = threading.Lock()
		self.adloc = 0
		self.adlist = []
		self.adcache = {}
Exemplo n.º 16
0
 def build_operation_box(self, obj_evt):
     # build the widget to present an event :
     # tooltip with event infos
     # image containing snapshot of the event
     # label with the time of the event
     corpsstr = ''
     if obj_evt.content is not None:
         corpsstr = urllib.unquote(obj_evt.content.encode('utf-8'))
     ev_time = time.strftime("%H:%M:%S", time.localtime(obj_evt.time))
     if self.options['time'] == 'activity':
         ev_time = helper.format_time_reference(obj_evt.activity_time)
     if obj_evt.name in self.operations_names:
         if ECACatalog.event_names[obj_evt.name]:
             entetestr = "%s : %s" % (ev_time, ECACatalog.event_names[obj_evt.name])
         else:
             entetestr = "%s : %s" % (ev_time, "Operation not described")
         if obj_evt.concerned_object['id']:
             entetestr = entetestr + ' (%s)' % obj_evt.concerned_object['id']
     elif obj_evt.name in self.incomplete_operations_names.keys():
         comp = ''
         # store type of item in the trace
         ob = self.controller.package.get_element_by_id(obj_evt.concerned_object['id'])
         #print "%s %s %s" % (self.controller.package, obj_evt.concerned_object['id'], ob)
         if isinstance(ob, advene.model.annotation.Annotation):
             comp = _('of an annotation (%s)') % obj_evt.concerned_object['id']
         elif isinstance(ob,advene.model.annotation.Relation):
             comp = _('of a relation (%s)') % obj_evt.concerned_object['id']
         elif isinstance(ob,advene.model.schema.AnnotationType):
             comp = _('of an annotation type (%s)') % obj_evt.concerned_object['id']
         elif isinstance(ob,advene.model.schema.RelationType):
             comp = _('of a relation type (%s)') % obj_evt.concerned_object['id']
         elif isinstance(ob,advene.model.schema.Schema):
             comp = _('of a schema (%s)') % obj_evt.concerned_object['id']
         elif isinstance(ob,advene.model.view.View):
             comp = _('of a view (%s)') % obj_evt.concerned_object['id']
         elif isinstance(ob,advene.model.package.Package):
             comp = _('of a package (%s)') % obj_evt.concerned_object['id']
         else:
             comp = _('of an unknown item (%s)') % obj_evt.concerned_object['id']
         entetestr = "%s : %s %s" % (ev_time, self.incomplete_operations_names[obj_evt.name], comp)
     else:
         print "unlabelled event : %s" % obj_evt.name
         entetestr = "%s : %s" % (ev_time, obj_evt.name)
     entete = gtk.Label(entetestr.encode("UTF-8"))
     hb = gtk.HBox()
     box = gtk.EventBox()
     tr = TimestampRepresentation(obj_evt.movietime, self.controller, 50, 0, None , False)
     if tr is not None:
         hb.pack_start(tr, expand=False)
         hb.pack_start(gtk.VSeparator(), expand=False)
     if corpsstr != "":
         box.set_tooltip_text(corpsstr)
     def box_pressed(w, event, id):
         #print "%s %s" % (id, mtime)
         if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS:
             if id is not None:
                 obj = self.controller.package.get_element_by_id(id)
                 if obj is not None:
                     #Need to edit the item
                     #print obj
                     self.controller.gui.edit_element(obj)
                 else:
                     print "item %s no longuer exists" % id
         return
     box.add(entete)
     box.connect('button-press-event', box_pressed, obj_evt.concerned_object['id'])
     hb.pack_start(box, expand=False)
     return hb
Exemplo n.º 17
0
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.client = gconf.client_get_default()
        self.current_nick = self.client.get_string("/desktop/sugar/user/nick")
        self.current_colour = self.client.get_string(
            "/desktop/sugar/user/color")
        self.current_colours = _parse_string(self.current_colour)
        self.toolbox = activity.ActivityToolbox(self)
        activity_toolbar = self.toolbox.get_activity_toolbar()
        activity_toolbar.share.props.visible = False
        activity_toolbar.keep.props.visible = False
        self.ok_button = ToolButton(icon)
        self.ok_button.props.tooltip = "Aplicar"
        self.ok_button.connect("clicked", self.apply)
        self.ok_button.show()
        activity_toolbar.insert(self.ok_button, 2)
        self.set_toolbox(self.toolbox)
        self.toolbox.show()

        self.canvas = gtk.VBox()
        name_box = gtk.HBox()
        self.canvas.pack_start(name_box, True, True, 5)
        name_label = gtk.Label("Nombre:")
        self.name_entry = gtk.Entry()
        self.name_entry.set_text(self.current_nick)
        name_label.show()
        self.name_entry.show()
        name_box.pack_start(name_label, False, True, 0)
        name_box.pack_start(self.name_entry, True, True, 0)
        name_box.show()

        self.colour_picker = gtk.HBox()

        selectors = gtk.VBox()
        self.out_colour_selector = gtk.ColorSelection()
        self.out_colour_selector.set_current_color(
            gtk.gdk.color_parse(self.current_colours[0]))
        self.out_colour_selector.connect("color-changed",
                                         self.colour_changed_callback, "out")
        self.out_colour_selector.show()
        selectors.pack_start(self.out_colour_selector, True, True, 0)

        self.in_colour_selector = gtk.ColorSelection()
        self.in_colour_selector.set_current_color(
            gtk.gdk.color_parse(self.current_colours[1]))
        self.in_colour_selector.connect("color-changed",
                                        self.colour_changed_callback, "in")
        self.in_colour_selector.show()
        selectors.pack_start(self.in_colour_selector, True, True, 0)

        selectors.show()
        self.colour_picker.pack_start(selectors, True, True, 0)

        self.xo_icon = gtk.EventBox()
        self.icon = Icon(pixel_size=style.XLARGE_ICON_SIZE)
        self.icon.props.xo_color = XoColor(self.current_colour)
        self.icon.props.icon_name = 'computer-xo'
        self.icon.props.pixel_size = style.XLARGE_ICON_SIZE
        self.icon.show()
        self.xo_icon.add(self.icon)
        self.xo_icon.show()
        self.colour_picker.pack_start(self.xo_icon)
        self.canvas.pack_start(self.colour_picker, True, True, 5)
        self.colour_picker.show()

        self.canvas.show()
        self.set_canvas(self.canvas)

        self.show()
Exemplo n.º 18
0
    def __init__(self, *args, **kwargs):
        GUIModule.__init__(self, *args, **kwargs)

        # some constants
        self.msLongPress = 400

        # window state
        self.fullscreen = False

        # map center shifting variables
        self.centerShift = (0, 0)
        self.expandViewportTiles = 0.0

        # viewport
        self.viewportWH = (0,0)

        """
        NOTE: we are calling the device module through the main class
        as it otherwise is first available in firstTime
        """

        # create the GTK window

        # when on N900, use a hildon StackableWindow, which
        # enables app menu and other features on Maemo 5
        if self.modrana.dmod.getDeviceIDString() == 'n900':
            try:
                import hildon

                win = hildon.StackableWindow()
            except Exception:
                self.log.exception("creating hildon stackable window failed")
                win = gtk.Window()
        else:
            win = gtk.Window()
        self.win = win
        win.connect("destroy", self._destroyCB)

        # register centering.shift callbacks
        self._registerCenteringShiftCallbacks()

        # resize it to preferred width x height
        (w, h) = self.modrana.dmod.getWinWH()
        self.resize(w, h)
        self.modrana.addTime("window created")
        # set title
        self.setWindowTitle("modRana")
        # connect delete event
        win.connect('delete-event', gtk.main_quit)

        ## Instantiate the main widget ##
        self.mw = MainWidget(self)
        self.mw.topWindow = win
        # make the main window accessible from modules
        self.topWindow = win
        self.modrana.addTime("map widget created")

        # check if we should start in fullscreen
        if self.shouldStartInFullscreen():
            self.setFullscreen(True)

        # Event handling
        event_box = gtk.EventBox()

        event_box.connect("button_press_event", self.mw.pressed)
        event_box.connect("button_release_event", self.mw.released)
        event_box.connect("scroll_event", self.mw.scrolled)
        event_box.connect("motion_notify_event", self.mw.moved)
        win.add(event_box)

        # add redraw request watch
        self.watch('needRedraw', self.mw._checkForRedrawCB) # react on redraw requests
        # TODO: add a function for directly requesting redraw

        event_box.add(self.mw)
        # Finalise the window
        win.show_all()
        self.modrana.addTime("window finalized")
Exemplo n.º 19
0
    def create_window(self):
        """
		Creates an empty results window
		"""

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.realize()

        # Windows appears to ignore the skip taskbar hint, so we initialize
        # an icon and a name to display in the taskbar
        if self.os == "windows":
            self.window.set_icon_from_file("data\\icons\\gnotero.png")

        self.window.set_title("Gnotero")
        self.window.set_decorated(False)
        self.window.set_keep_above(True)
        self.window.set_skip_taskbar_hint(True)

        self.style = self.window.get_style()

        self.search_edit = gtk.Entry()
        self.search_edit.set_has_frame(False)
        self.search_edit.connect("activate", self.search)

        if self.enable_live_search == "yes":
            print "gnotero.create_window(): enabling live search"
            self.search_edit.connect("changed", self.live_search)

        self.search_box = gtk.HBox()
        self.search_box.pack_start(self.search_edit, True, True)
        self.search_box.set_border_width(16)

        self.search_event_box = gtk.EventBox()
        self.search_event_box.add(self.search_box)
        self.search_event_box.modify_bg(gtk.STATE_NORMAL,
                                        self.style.bg[gtk.STATE_SELECTED])

        self.results_box = gtk.VBox()
        self.results_box.set_homogeneous(False)
        self.results_box.set_border_width(4)
        self.results_box.set_spacing(4)

        self.border_box = gtk.HBox()
        self.border_box.set_border_width(self.lower_border_width)

        self.border_event_box = gtk.EventBox()
        self.border_event_box.add(self.border_box)
        self.border_event_box.modify_bg(gtk.STATE_NORMAL,
                                        self.style.bg[gtk.STATE_SELECTED])

        self.main_box = gtk.VBox()
        self.main_box.pack_start(self.search_event_box)
        self.main_box.pack_start(self.results_box)
        self.main_box.pack_start(self.border_event_box)

        self.window.add(self.main_box)

        self.window.connect("focus-out-event", self.on_focus_out)
        self.window.set_size_request(self.popup_width, -1)

        self.search()
Exemplo n.º 20
0
    def __init__(self, joint_number=0):
        super(Combi_DRO, self).__init__()

        # get the necesarry connextions to linuxcnc
        self.joint_number = joint_number
        self.linuxcnc = linuxcnc
        self.status = linuxcnc.stat()

        # set some default values'
        self._ORDER = ["Rel", "Abs", "DTG"]
        self.system = "Rel"
        self.homed = False
        self.homed_color = gtk.gdk.Color("green")
        self.unhomed_color = gtk.gdk.Color("red")
        self.abs_color = gtk.gdk.Color("blue")
        self.rel_color = gtk.gdk.Color("black")
        self.dtg_color = gtk.gdk.Color("yellow")
        self.mm_text_template = "%10.3f"
        self.imperial_text_template = "%9.4f"
        self.font_size = 25
        self.metric_units = True
        self.machine_units = _MM
        self.unit_convert = 1
        self._auto_units = True
        self.toggle_readout = True

        # Make the GUI and connect signals
        self.eventbox = gtk.EventBox()
        self.eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"))
        self.add(self.eventbox)
        vbox_main = gtk.VBox(False, 0)
        self.eventbox.add(vbox_main)
        hbox_up = gtk.HBox(False, 0)
        vbox_main.pack_start(hbox_up)
        attr = self._set_attributes((0, 0, 0), (65535, 0, 0),
                                    (self.font_size * 1000, 0, -1),
                                    (600, 0, -1))
        self.lbl_axisletter = gtk.Label(_AXISLETTERS[self.joint_number])
        self.lbl_axisletter.set_attributes(attr)
        hbox_up.pack_start(self.lbl_axisletter, False, False)
        vbox_ref_type = gtk.VBox(False, 0)
        hbox_up.pack_start(vbox_ref_type, False, False)
        lbl_space = gtk.Label("")
        vbox_ref_type.pack_start(lbl_space)
        attr = self._set_attributes((0, 0, 0), (65535, 0, 0),
                                    (int(self.font_size * 1000 / 2.5), 0, -1),
                                    (600, 0, -1))
        self.lbl_sys_main = gtk.Label(self.system)
        vbox_ref_type.pack_start(self.lbl_sys_main, False, False)
        self.lbl_sys_main.set_attributes(attr)
        self.main_dro = gtk.Label("9999.999")
        hbox_up.pack_start(self.main_dro)
        self.main_dro.set_alignment(1.0, 0.5)
        attr = self._set_attributes((0, 0, 0), (65535, 0, 0),
                                    (self.font_size, 0, -1), (600, 0, -1))
        self.main_dro.set_attributes(attr)
        hbox_down = gtk.HBox(False, 5)
        vbox_main.pack_start(hbox_down)
        self.lbl_sys_left = gtk.Label("Abs")
        hbox_down.pack_start(self.lbl_sys_left)
        attr = self._set_attributes((0, 0, 0), (65535, 0, 0),
                                    (int(self.font_size * 1000 / 2.5), 0, -1),
                                    (600, 0, -1))
        self.lbl_sys_left.set_attributes(attr)
        self.dro_left = gtk.Label("-11.111")
        hbox_down.pack_start(self.dro_left)
        self.dro_left.set_alignment(1.0, 0.5)
        self.dro_left.set_attributes(attr)
        self.lbl_sys_right = gtk.Label("DTG")
        hbox_down.pack_start(self.lbl_sys_right)
        self.lbl_sys_right.set_attributes(attr)
        self.dro_right = gtk.Label("22.222")
        hbox_down.pack_start(self.dro_right)
        self.dro_right.set_alignment(1.0, 0.5)
        self.dro_right.set_attributes(attr)

        self.eventbox.connect("button_press_event", self._on_eventbox_clicked)

        self.show_all()

        # add the timer at a period of 100 ms
        gobject.timeout_add(100, self._periodic)

        # This try is only needed because while working with glade
        # linuxcnc may not be working
        try:
            self.inifile = self.linuxcnc.ini(INIPATH)
            # check the ini file if UNITS are set to mm"
            # first check the global settings
            units = self.inifile.find("TRAJ", "LINEAR_UNITS")
            if units == None:
                # else then the X axis units
                units = self.inifile.find("AXIS_0", "UNITS")
        except:
            units = "inch"

        if units == "mm" or units == "metric" or units == "1.0":
            self.machine_units = _MM
        else:
            self.machine_units = _INCH
Exemplo n.º 21
0
    labelHbox = gtk.HBox()
    frameVbox.pack_start(labelHbox, True, True, 0)
    #    dialog.vbox.pack_start(labelHbox,True,True,0)
    valuesHbox = gtk.HBox()
    frameVbox.pack_start(valuesHbox, True, True, 0)
    #    dialog.vbox.pack_start(valuesHbox,True,True,0)
    labelX = gtk.Label("X1")
    labelZ = gtk.Label("Z1")
    labelY = gtk.Label("Y1")
    labelHbox.pack_start(labelX, True, True, 0)
    labelHbox.pack_start(labelZ, True, True, 0)
    labelHbox.pack_start(labelY, True, True, 0)
    valueX = gtk.Label("5.00")
    valueZ = gtk.Label("5.00")
    valueY = gtk.Label("5.00")
    blinkerX = gtk.EventBox()
    blinkerZ = gtk.EventBox()
    blinkerY = gtk.EventBox()
    blinkerX.add(valueX)
    blinkerZ.add(valueZ)
    blinkerY.add(valueY)
    valuesHbox.pack_start(blinkerX, True, True, 0)
    valuesHbox.pack_start(blinkerZ, True, True, 0)
    valuesHbox.pack_start(blinkerY, True, True, 0)

    label = gtk.Label("blank")
    dialog.vbox.pack_start(label, True, True, 0)

    comboboxHbox = gtk.HBox()
    blabel = gtk.Label("")
    comboboxHbox.pack_start(blabel, True, True, 0)
Exemplo n.º 22
0
    def __init__(self, corner, scroll, offset, string, height = 128, \
                width = 200, pixmap = None, closePixmap = None, \
                callback = None, params = None, userPixbuf = None, \
                font = None, color = None):

        gtk.Window.__init__(self, type=gtk.gdk.WINDOW_TOPLEVEL)

        if corner == 0:
            self.set_gravity(gtk.gdk.GRAVITY_NORTH_WEST)
        elif corner == 1:
            self.set_gravity(gtk.gdk.GRAVITY_NORTH_EAST)
        elif corner == 2:
            self.set_gravity(gtk.gdk.GRAVITY_SOUTH_WEST)
        else:
            self.set_gravity(gtk.gdk.GRAVITY_SOUTH_EAST)

        self.set_accept_focus(False)
        self.set_decorated(False)
        self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN)

        self.corner = corner
        self.scroll = scroll

        if scroll == 0:
            self.height = height
            self.max = width
            self.width = 1
        else:
            self.width = width
            self.max = height
            self.height = 1

        self.callback = callback

        self.set_geometry_hints(None, min_width=-1, min_height=-1, \
                max_width=width, max_height=height)

        if pixmap != None:
            self.set_app_paintable(True)
            self.realize()
            self.window.set_back_pixmap(pixmap, False)

        messageLabel = gtk.Label('<span foreground="' + color +'">' \
                + escape(str(string)) + '</span>')
        messageLabel.set_use_markup(True)
        messageLabel.set_justify(gtk.JUSTIFY_CENTER)
        messageLabel.set_ellipsize(pango.ELLIPSIZE_END)
        try:
            messageLabel.modify_font(pango.FontDescription(font))
        except e:
            print e

        if closePixmap == None:
            close = gtk.Label()
            close.set_label("<span background=\"#cc0000\" foreground=" \
                    + color + "\"> X </span>")
            close.set_use_markup(True)
        else:
            close = gtk.Image()
            close.set_from_pixbuf(closePixmap)

        closeEventBox = gtk.EventBox()
        closeEventBox.set_visible_window(False)
        closeEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        closeEventBox.connect("button_press_event", self.close)
        closeEventBox.add(close)

        hbox = gtk.HBox()
        vbox = gtk.VBox()
        lbox = gtk.HBox()
        title = gtk.Label("")
        title.set_use_markup(True)

        avatarImage = gtk.Image()
        if userPixbuf != None:
            userPixbuf = resizePixbuf(userPixbuf, 48, 48)
            avatarImage.set_from_pixbuf(userPixbuf)

        lboxEventBox = gtk.EventBox()
        lboxEventBox.set_visible_window(False)
        lboxEventBox.set_events(gtk.gdk.BUTTON_PRESS_MASK)
        lboxEventBox.connect("button_press_event", self.onClick, params)
        lboxEventBox.add(lbox)

        self.connect("button_press_event", self.onClick, params)

        hbox.pack_start(title, True, True)
        hbox.pack_end(closeEventBox, False, False)
        lbox.pack_start(avatarImage, False, False, 10)
        lbox.pack_start(messageLabel, True, True, 5)

        vbox.pack_start(hbox, False, False)
        vbox.pack_start(lboxEventBox, True, True)

        self.grow(offset, False)
        self.add(vbox)

        vbox.show_all()
Exemplo n.º 23
0
	def show_new_game_menu(self):
		# set main box
		self.name = ''
		self.child = ''
		self.country = '--'
		self.main_box = gtk.VBox()
		name_label = gtk.Label()
		name_label.modify_font(pango.FontDescription('FreeSans 32'))
		name_label.set_markup('<b>Please, enter your name</b>')
		name_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#555555'))
		self.main_box.add(name_label)
		self.name_entry = gtk.Entry(255)
		self.main_box.add(self.name_entry)
		child_label = gtk.Label()
		child_label.modify_font(pango.FontDescription('FreeSans 32'))
		child_label.set_markup('<b>Choose wether you are a girl or a boy</b>')
		child_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#555555'))
		self.main_box.add(child_label)
		child_box = gtk.HBox()
		self.carmen_image = gtk.Image()
		self.carmen_image.set_from_file('../images/carmen_smiling.png')
		carmen_eventbox = gtk.EventBox()
		carmen_eventbox.set_visible_window(False)
		carmen_eventbox.connect('button-press-event', self.clicked_child_callback)
		carmen_eventbox.set_events(gtk.gdk.EXPOSURE_MASK
										| gtk.gdk.BUTTON_PRESS_MASK)
		carmen_eventbox.add(self.carmen_image)
		carmen_eventbox.kind = 'carmen'
		child_box.add(carmen_eventbox)
		carmen_eventbox.show()
		self.carlos_image = gtk.Image()
		self.carlos_image.set_from_file('../images/carlos_smiling.png')
		carlos_eventbox = gtk.EventBox()
		carlos_eventbox.set_visible_window(False)
		carlos_eventbox.connect('button-press-event', self.clicked_child_callback)
		carlos_eventbox.set_events(gtk.gdk.EXPOSURE_MASK
										| gtk.gdk.BUTTON_PRESS_MASK)
		carlos_eventbox.add(self.carlos_image)
		carlos_eventbox.kind = 'carlos'
		child_box.add(carlos_eventbox)
		carlos_eventbox.show()
		self.main_box.add(child_box)
		country_label = gtk.Label()
		country_label.modify_font(pango.FontDescription('FreeSans 32'))
		country_label.set_markup('<b>Please, choose your country</b>')
		country_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#555555'))
		self.main_box.add(country_label)
		countries_combobox = gtk.combo_box_new_text()
		countries_combobox.set_wrap_width(4)
		# TODO: fill with list of countries from the model
		countries_combobox.append_text('--')
		countries_combobox.append_text('China')
		countries_combobox.append_text('France')
		countries_combobox.append_text('Spain')
		countries_combobox.append_text('US')
		countries_combobox.set_active(0)
		countries_combobox.connect('changed', self.changed_country_callback)
		continue_button = gtk.Button('Continue', 'gtk-ok')
		continue_button.connect("clicked", self.ok_callback)
		self.main_box.pack_end(continue_button, True, False)
		self.main_box.pack_end(countries_combobox, True, False)
		self.window.add(self.main_box)
		color = gtk.gdk.color_parse('#ffffff')
		self.window.modify_bg(gtk.STATE_NORMAL, color)
Exemplo n.º 24
0
    def create_prefs_page(self):
        #Select Widget
        hover = gtk.Label()
        self.scheduler_select = SchedulerSelectWidget(hover)

        vbox = gtk.VBox(False, 5)
        hbox = gtk.HBox(False, 5)
        vbox_days = gtk.VBox()
        for day in DAYS:
            vbox_days.pack_start(gtk.Label(day))
        hbox.pack_start(vbox_days, False, False)
        hbox.pack_start(self.scheduler_select, True, True)
        frame = gtk.Frame()
        label = gtk.Label()
        label.set_markup("<b>Schedule</b>")
        frame.set_label_widget(label)
        frame.set_shadow_type(gtk.SHADOW_NONE)
        frame.add(hbox)

        vbox.pack_start(frame, True, True)
        vbox.pack_start(hover)

        table = gtk.Table(3, 4)

        label = gtk.Label(_("Download Limit:"))
        label.set_alignment(0.0, 0.6)
        table.attach(label, 0, 1, 0, 1, gtk.FILL)
        self.spin_download = gtk.SpinButton()
        self.spin_download.set_numeric(True)
        self.spin_download.set_range(-1.0, 99999.0)
        self.spin_download.set_increments(1, 10)
        table.attach(self.spin_download, 1, 2, 0, 1, gtk.FILL)

        label = gtk.Label(_("Upload Limit:"))
        label.set_alignment(0.0, 0.6)
        table.attach(label, 0, 1, 1, 2, gtk.FILL)
        self.spin_upload = gtk.SpinButton()
        self.spin_upload.set_numeric(True)
        self.spin_upload.set_range(-1.0, 99999.0)
        self.spin_upload.set_increments(1, 10)
        table.attach(self.spin_upload, 1, 2, 1, 2, gtk.FILL)

        label = gtk.Label(_("Active Torrents:"))
        label.set_alignment(0.0, 0.6)
        table.attach(label, 2, 3, 0, 1, gtk.FILL)
        self.spin_active = gtk.SpinButton()
        self.spin_active.set_numeric(True)
        self.spin_active.set_range(-1, 9999)
        self.spin_active.set_increments(1, 10)
        table.attach(self.spin_active, 3, 4, 0, 1, gtk.FILL)

        label = gtk.Label(_("Active Downloading:"))
        label.set_alignment(0.0, 0.6)
        table.attach(label, 2, 3, 1, 2, gtk.FILL)
        self.spin_active_down = gtk.SpinButton()
        self.spin_active_down.set_numeric(True)
        self.spin_active_down.set_range(-1, 9999)
        self.spin_active_down.set_increments(1, 10)
        table.attach(self.spin_active_down, 3, 4, 1, 2, gtk.FILL)

        label = gtk.Label(_("Active Seeding:"))
        label.set_alignment(0.0, 0.6)
        table.attach(label, 2, 3, 2, 3, gtk.FILL)
        self.spin_active_up = gtk.SpinButton()
        self.spin_active_up.set_numeric(True)
        self.spin_active_up.set_range(-1, 9999)
        self.spin_active_up.set_increments(1, 10)
        table.attach(self.spin_active_up, 3, 4, 2, 3, gtk.FILL)

        eventbox = gtk.EventBox()
        eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#EDD400"))
        eventbox.add(table)
        frame = gtk.Frame()
        label = gtk.Label()
        label.set_markup(_("<b>Slow Settings</b>"))
        frame.set_label_widget(label)
        frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#CDB400"))
        frame.set_border_width(2)
        frame.add(eventbox)
        vbox.pack_start(frame, False, False)

        vbox.show_all()
        component.get("Preferences").add_page("Scheduler", vbox)
Exemplo n.º 25
0
 def table_insert(self, iter_insert, table=None, table_justification=None, text_buffer=None):
     """Insert a Table at the Given Iter"""
     if not text_buffer: text_buffer = self.dad.curr_buffer
     if table != None:
         self.dad.table_columns = len(table['matrix'][0])
         self.dad.table_rows = len(table['matrix']) - 1
         headers = table['matrix'][-1]
         table_col_min = table['col_min']
         table_col_max = table['col_max']
     else:
         headers = [_("click me")]*self.dad.table_columns
         table_col_min = self.dad.table_col_min
         table_col_max = self.dad.table_col_max
     anchor = text_buffer.create_child_anchor(iter_insert)
     anchor.liststore = gtk.ListStore(*(str,)*self.dad.table_columns)
     anchor.treeview = gtk.TreeView(anchor.liststore)
     anchor.renderers_text = []
     for element in range(self.dad.table_columns):
         label = gtk.Label('<b>' + headers[element] + '</b>')
         label.set_use_markup(True)
         label.set_tooltip_text(_("Click to Edit the Column Settings"))
         label.show()
         renderer_text = gtk.CellRendererText()
         renderer_text.set_property('editable', True)
         renderer_text.set_property('wrap-width', table_col_max)
         renderer_text.set_property('wrap-mode', pango.WRAP_WORD_CHAR)
         renderer_text.set_property('font-desc', pango.FontDescription(self.dad.pt_font))
         renderer_text.connect('edited', self.on_table_cell_edited, anchor.liststore, element)
         renderer_text.connect('editing-started', self.on_table_cell_editing_started, anchor.liststore, element)
         column = gtk.TreeViewColumn("", renderer_text, text=element)
         column.set_min_width(table_col_min)
         column.set_clickable(True)
         column.set_widget(label)
         column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
         column.connect('clicked', self.table_column_clicked, anchor, element)
         anchor.treeview.append_column(column)
         anchor.renderers_text.append(renderer_text)
     anchor.headers = headers
     anchor.table_col_min = table_col_min
     anchor.table_col_max = table_col_max
     anchor.treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
     anchor.treeview.connect('button-press-event', self.on_mouse_button_clicked_treeview_table, anchor)
     anchor.treeview.connect('key_press_event', self.on_key_press_treeview_table, anchor)
     anchor.frame = gtk.Frame()
     anchor.frame.add(anchor.treeview)
     anchor.frame.set_shadow_type(gtk.SHADOW_NONE)
     anchor.eventbox = gtk.EventBox()
     anchor.eventbox.add(anchor.frame)
     self.dad.sourceview.add_child_at_anchor(anchor.eventbox, anchor)
     anchor.eventbox.show_all()
     for row in range(self.dad.table_rows):
         row_iter = anchor.liststore.append([""]*self.dad.table_columns)
         if table != None:
             for column in range(self.dad.table_columns):
                 try: anchor.liststore[row_iter][column] = table['matrix'][row][column]
                 except: pass # there are cases when some rows have less columns
     if table_justification:
         text_iter = text_buffer.get_iter_at_child_anchor(anchor)
         self.dad.state_machine.apply_object_justification(text_iter, table_justification, text_buffer)
     elif self.dad.user_active:
         # if I apply a justification, the state is already updated
         self.dad.state_machine.update_state()
Exemplo n.º 26
0
    def __init__(self,
                 crumb,
                 arrow_right=ui_theme.get_pixbuf("treeview/arrow_right.png"),
                 arrow_down=ui_theme.get_pixbuf("treeview/arrow_down.png"),
                 show_others=False,
                 show_entry=False,
                 show_left_right_box=True):
        '''
        Initialize Bread class.

        @param crumb: Crumb instance or a list of crumb instances
        @param arrow_right: Dynamic pixbuf for right arrow, default is \"treeview/arrow_right.png\" from ui theme.
        @param arrow_down: Dynamic pixbuf for down arrow, default is \"treeview/arrow_down.png\" from ui theme.
        @param show_others: If True, crumbs will not be destroyed, otherwise all crumbs on the right side will be destroyed.
        @param show_entry: If True, an entry will pop up when click space area in Bread.
        '''
        # Init.
        super(Bread, self).__init__(spacing=0)
        self.arrow_right = arrow_right
        self.arrow_down = arrow_down
        self.item_list = list()
        self.show_others = show_others
        self.show_entry = show_entry
        self.crumb = self.create_crumb(crumb)
        self.button_width = ARROW_BUTTON_WIDTH  # for left & right buttons
        self.in_event_box = False

        # Init left button and right button.
        self.show_left_right_box = show_left_right_box
        left_box = gtk.HBox(spacing=0)
        right_box = gtk.HBox(spacing=0)

        # FIXME: left && right box static setting size
        #        it is better to consider whether or not shown left && right box
        #        at runtime
        if self.show_left_right_box:
            left_box.set_size_request(self.button_width, -1)
            right_box.set_size_request(self.button_width, -1)
        self.left_btn = Button("&lt;")
        self.right_btn = Button("&gt;")
        self.left_btn.set_no_show_all(True)
        self.right_btn.set_no_show_all(True)
        self.right_btn.connect("clicked", self.move_right)
        self.left_btn.connect("clicked", self.move_left)
        self.left_btn.set_size_request(self.button_width, -1)
        self.right_btn.set_size_request(self.button_width, -1)
        left_box.pack_start(self.left_btn, False, False)
        right_box.pack_start(self.right_btn, False, False)

        # Init Hbox
        self.hbox = gtk.HBox(False, 0)
        self.hbox.show()
        self.eventbox = gtk.EventBox()
        self.eventbox.set_visible_window(False)

        if self.show_entry:
            self.eventbox.connect("enter-notify-event", self.enter_notify)
            self.eventbox.connect("leave-notify-event", self.leave_notify)
            self.eventbox.connect("button-press-event", self.event_box_press)

        self.hbox.pack_end(self.eventbox, True, True)
        self.scroll_win = ScrolledWindow()
        self.pack_start(left_box, False, True)
        self.pack_start(self.hbox, True, True)

        # Add Bread Items
        self.adj = self.scroll_win.get_hadjustment()

        self.add(self.crumb)
Exemplo n.º 27
0
    def __init__(self):
        # Window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Step Maker Window")
        self.window.connect("delete-event", self.delete_event)
        self.window.connect("destroy", self.destroy)
        self.window.set_default_size(600, 800)

        # Main box (inside a frame which is inside a VBox)
        self.menu_vbox = gtk.VBox()
        self.window.add(self.menu_vbox)
        self.menu_vbox.show()

        frame = gtk.Frame()
        frame.set_border_width(10)
        frame.set_shadow_type(gtk.SHADOW_NONE)
        self.menu_vbox.pack_end(frame)
        frame.show()

        self.main_vbox = gtk.VBox(spacing=10)
        frame.add(self.main_vbox)
        self.main_vbox.show()

        # EventBox
        self.scrolledwindow = gtk.ScrolledWindow()
        self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
        self.scrolledwindow.set_shadow_type(gtk.SHADOW_NONE)
        self.main_vbox.pack_start(self.scrolledwindow)
        self.scrolledwindow.show()

        table = gtk.Table(1, 1)
        self.scrolledwindow.add_with_viewport(table)
        table.show()
        table.realize()

        self.event_box = gtk.EventBox()
        table.attach(self.event_box, 0, 1, 0, 1, gtk.EXPAND, gtk.EXPAND)
        self.event_box.show()
        self.event_box.realize()

        # Image
        self.image = gtk.Image()
        self.event_box.add(self.image)
        self.image.show()

        # Data VBox
        self.data_vbox = gtk.VBox(spacing=10)
        self.main_vbox.pack_start(self.data_vbox, expand=False)
        self.data_vbox.show()

        # User VBox
        self.user_vbox = gtk.VBox(spacing=10)
        self.main_vbox.pack_start(self.user_vbox, expand=False)
        self.user_vbox.show()

        # Screendump ID HBox
        box = gtk.HBox(spacing=10)
        self.data_vbox.pack_start(box)
        box.show()

        label = gtk.Label("Screendump ID:")
        box.pack_start(label, False)
        label.show()

        self.entry_screendump = gtk.Entry()
        self.entry_screendump.set_editable(False)
        box.pack_start(self.entry_screendump)
        self.entry_screendump.show()

        label = gtk.Label("Time:")
        box.pack_start(label, False)
        label.show()

        self.entry_time = gtk.Entry()
        self.entry_time.set_editable(False)
        self.entry_time.set_width_chars(10)
        box.pack_start(self.entry_time, False)
        self.entry_time.show()

        # Comment HBox
        box = gtk.HBox(spacing=10)
        self.data_vbox.pack_start(box)
        box.show()

        label = gtk.Label("Comment:")
        box.pack_start(label, False)
        label.show()

        self.entry_comment = gtk.Entry()
        box.pack_start(self.entry_comment)
        self.entry_comment.show()

        # Sleep HBox
        box = gtk.HBox(spacing=10)
        self.data_vbox.pack_start(box)
        box.show()

        self.check_sleep = gtk.CheckButton("Sleep:")
        self.check_sleep.connect("toggled", self.event_check_sleep_toggled)
        box.pack_start(self.check_sleep, False)
        self.check_sleep.show()

        self.spin_sleep = gtk.SpinButton(gtk.Adjustment(0, 0, 50000, 1, 10, 0),
                                         climb_rate=0.0)
        box.pack_start(self.spin_sleep, False)
        self.spin_sleep.show()

        # Barrier HBox
        box = gtk.HBox(spacing=10)
        self.data_vbox.pack_start(box)
        box.show()

        self.check_barrier = gtk.CheckButton("Barrier:")
        self.check_barrier.connect("toggled", self.event_check_barrier_toggled)
        box.pack_start(self.check_barrier, False)
        self.check_barrier.show()

        vbox = gtk.VBox()
        box.pack_start(vbox)
        vbox.show()

        self.label_barrier_region = gtk.Label("Region:")
        self.label_barrier_region.set_alignment(0, 0.5)
        vbox.pack_start(self.label_barrier_region)
        self.label_barrier_region.show()

        self.label_barrier_md5sum = gtk.Label("MD5:")
        self.label_barrier_md5sum.set_alignment(0, 0.5)
        vbox.pack_start(self.label_barrier_md5sum)
        self.label_barrier_md5sum.show()

        self.label_barrier_timeout = gtk.Label("Timeout:")
        box.pack_start(self.label_barrier_timeout, False)
        self.label_barrier_timeout.show()

        self.spin_barrier_timeout = gtk.SpinButton(gtk.Adjustment(0, 0, 50000,
                                                                  1, 10, 0),
                                                   climb_rate=0.0)
        box.pack_start(self.spin_barrier_timeout, False)
        self.spin_barrier_timeout.show()

        self.check_barrier_optional = gtk.CheckButton("Optional")
        box.pack_start(self.check_barrier_optional, False)
        self.check_barrier_optional.show()

        # Keystrokes HBox
        box = gtk.HBox(spacing=10)
        self.data_vbox.pack_start(box)
        box.show()

        label = gtk.Label("Keystrokes:")
        box.pack_start(label, False)
        label.show()

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)
        box.pack_start(frame)
        frame.show()

        self.text_buffer = gtk.TextBuffer()
        self.entry_keys = gtk.TextView(self.text_buffer)
        self.entry_keys.set_wrap_mode(gtk.WRAP_WORD)
        self.entry_keys.connect("key-press-event", self.event_key_press)
        frame.add(self.entry_keys)
        self.entry_keys.show()

        self.check_manual = gtk.CheckButton("Manual")
        self.check_manual.connect("toggled", self.event_manual_toggled)
        box.pack_start(self.check_manual, False)
        self.check_manual.show()

        button = gtk.Button("Clear")
        button.connect("clicked", self.event_clear_clicked)
        box.pack_start(button, False)
        button.show()

        # Mouse click HBox
        box = gtk.HBox(spacing=10)
        self.data_vbox.pack_start(box)
        box.show()

        label = gtk.Label("Mouse action:")
        box.pack_start(label, False)
        label.show()

        self.button_capture = gtk.Button("Capture")
        box.pack_start(self.button_capture, False)
        self.button_capture.show()

        self.check_mousemove = gtk.CheckButton("Move: ...")
        box.pack_start(self.check_mousemove, False)
        self.check_mousemove.show()

        self.check_mouseclick = gtk.CheckButton("Click: ...")
        box.pack_start(self.check_mouseclick, False)
        self.check_mouseclick.show()

        self.spin_sensitivity = gtk.SpinButton(gtk.Adjustment(1, 1, 100, 1, 10,
                                                              0),
                                               climb_rate=0.0)
        box.pack_end(self.spin_sensitivity, False)
        self.spin_sensitivity.show()

        label = gtk.Label("Sensitivity:")
        box.pack_end(label, False)
        label.show()

        self.spin_latency = gtk.SpinButton(
            gtk.Adjustment(10, 1, 500, 1, 10, 0),
            climb_rate=0.0)
        box.pack_end(self.spin_latency, False)
        self.spin_latency.show()

        label = gtk.Label("Latency:")
        box.pack_end(label, False)
        label.show()

        self.handler_event_box_press = None
        self.handler_event_box_release = None
        self.handler_event_box_scroll = None
        self.handler_event_box_motion = None
        self.handler_event_box_expose = None

        self.window.realize()
        self.window.show()

        self.clear_state()
Exemplo n.º 28
0
    def __init__(self, stack, title, message, image):
        gtk.Window.__init__(self, type=gtk.WINDOW_POPUP)

        self.set_size_request(stack.size_x, -1)
        self.set_decorated(False)
        self.set_deletable(False)
        self.set_property("skip-pager-hint", True)
        self.set_property("skip-taskbar-hint", True)
        self.connect("enter-notify-event", self.on_hover, True)
        self.connect("leave-notify-event", self.on_hover, False)
        self.set_opacity(0.2)
        self.destroy_cb = stack.destroy_popup_cb

        main_box = gtk.VBox()
        header_box = gtk.HBox()
        self.header = gtk.Label()
        self.header.set_markup("<b>%s</b>" % title)
        self.header.set_padding(3, 3)
        self.header.set_alignment(0, 0)
        close_button = gtk.Image()

        close_button.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON)
        close_button.set_padding(3, 3)
        close_window = gtk.EventBox()
        close_window.set_visible_window(False)
        close_window.connect("button-press-event", self.hide_notification)
        close_window.add(close_button)
        header_box.pack_start(self.header, True, True, 5)
        header_box.pack_end(close_window, False, False)
        main_box.pack_start(header_box)

        body_box = gtk.HBox()
        if image is not None:
            self.image = gtk.Image()
            self.image.set_size_request(70, 70)
            self.image.set_alignment(0, 0)
            self.image.set_from_file(image)
            body_box.pack_start(self.image, False, False, 5)
        self.message = gtk.Label()
        self.message.set_property("wrap", True)
        self.message.set_size_request(stack.size_x - 90, -1)
        self.message.set_alignment(0, 0)
        self.message.set_padding(5, 10)
        self.message.set_markup(message)
        self.counter = gtk.Label()
        self.counter.set_alignment(1, 1)
        self.counter.set_padding(3, 3)
        self.timeout = stack.timeout

        body_box.pack_start(self.message, True, False, 5)
        body_box.pack_end(self.counter, False, False, 5)
        main_box.pack_start(body_box)
        self.add(main_box)

        if stack.bg_color is not None:
            self.modify_bg(gtk.STATE_NORMAL, stack.bg_color)
        if stack.fg_color is not None:
            self.message.modify_fg(gtk.STATE_NORMAL, stack.fg_color)
            self.header.modify_fg(gtk.STATE_NORMAL, stack.fg_color)
            self.counter.modify_fg(gtk.STATE_NORMAL, stack.fg_color)
        self.show_timeout = stack.show_timeout
        self.hover = False
        self.show_all()
        self.x, self.y = self.size_request()
        self.move(
            gtk.gdk.screen_width() - self.x - stack.edge_offset_x,
            gtk.gdk.screen_height() - self.y - stack._offset -
            stack.edge_offset_y)
        self.fade_in_timer = gobject.timeout_add(100, self.fade_in)
Exemplo n.º 29
0
    def __init__(self, parent, db, db_owner, tmpdir, pyro_timeout ):

        self.db = db
        self.db_owner = db_owner
        if pyro_timeout:
            self.pyro_timeout = float(pyro_timeout)
        else:
            self.pyro_timeout = None

        self.regname = None

        self.updater = None
        self.tmpdir = tmpdir
        self.gcapture_windows = []

        gobject.threads_init()

        #self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window = gtk.Dialog( "Choose a suite", parent, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
        #self.window.set_modal(True)
        self.window.set_title("Suite Chooser" )
        self.window.set_size_request(750, 400)
        self.window.set_icon(get_icon()) # TODO: not needed for a dialog window?
        #self.window.set_border_width( 5 )

        self.window.connect("delete_event", self.delete_all_event)

        sw = gtk.ScrolledWindow()
        sw.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC )

        self.regd_treeview = gtk.TreeView()
        self.regd_treestore = gtk.TreeStore( str, str, str, str, str, str, str )
        self.regd_treeview.set_model(self.regd_treestore)
        self.regd_treeview.set_rules_hint(True)
        # search column zero (Ctrl-F)
        self.regd_treeview.connect( 'key_press_event', self.on_suite_select )
        self.regd_treeview.connect( 'button_press_event', self.on_suite_select )
        self.regd_treeview.set_search_column(0)

        # Start updating the liststore now, as we need values in it
        # immediately below (it may be possible to delay this till the
        # end of __init___() but it doesn't really matter.
        if self.db:
            self.dbopt = '--db='+self.db
        else:
            self.dbopt = ''

        regd_ts = self.regd_treeview.get_selection()
        regd_ts.set_mode( gtk.SELECTION_SINGLE )

        cr = gtk.CellRendererText()
        #cr.set_property( 'cell-background', '#def' )
        tvc = gtk.TreeViewColumn( 'Suite', cr, text=0, foreground=4, background=5 )
        tvc.set_resizable(True)
        tvc.set_sort_column_id(0)
        self.regd_treeview.append_column( tvc )

        cr = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn( 'Port', cr, text=1, foreground=4, background=5 )
        tvc.set_resizable(True)
        # not sure how this sorting works
        #tvc.set_sort_column_id(1)
        self.regd_treeview.append_column( tvc )

        cr = gtk.CellRendererText()
        #cr.set_property( 'cell-background', '#def' )
        tvc = gtk.TreeViewColumn( 'Title', cr, markup=2, foreground=4, background=6 )
        tvc.set_resizable(True)
        #vc.set_sort_column_id(2)
        self.regd_treeview.append_column( tvc )

        cr = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn( 'Location', cr, text=3, foreground=4, background=5 )
        tvc.set_resizable(True)
        #vc.set_sort_column_id(3)
        self.regd_treeview.append_column( tvc )

        vbox = self.window.vbox

        sw.add( self.regd_treeview )

        vbox.pack_start( sw, True )

        self.selected_label_text = '(double-click or OK to select; right-click for db options)'
        self.selected_label = gtk.Label( self.selected_label_text )

        filter_entry = EntryTempText()
        filter_entry.set_width_chars( 7 )  # Reduce width in toolbar
        filter_entry.connect( "activate", self.filter )
        filter_entry.set_temp_text( "filter" )
        filter_toolitem = gtk.ToolItem()
        filter_toolitem.add(filter_entry)
        tooltip = gtk.Tooltips()
        tooltip.enable()
        tooltip.set_tip(filter_toolitem, "Filter suites \n(enter a sub-string or regex)")

        expand_button = gtk.ToolButton()
        image = gtk.image_new_from_stock( gtk.STOCK_ADD, gtk.ICON_SIZE_SMALL_TOOLBAR )
        expand_button.set_icon_widget( image )
        expand_button.connect( 'clicked', lambda x: self.regd_treeview.expand_all() )

        collapse_button = gtk.ToolButton()
        image = gtk.image_new_from_stock( gtk.STOCK_REMOVE, gtk.ICON_SIZE_SMALL_TOOLBAR )
        collapse_button.set_icon_widget( image )
        collapse_button.connect( 'clicked', lambda x: self.regd_treeview.collapse_all() )

        hbox = gtk.HBox()

        eb = gtk.EventBox()
        eb.add( self.selected_label )
        eb.modify_bg( gtk.STATE_NORMAL, gtk.gdk.color_parse( '#bbc' ) )
        hbox.pack_start( eb, True )
        hbox.pack_start( expand_button, False )
        hbox.pack_start( collapse_button, False )
        hbox.pack_start (filter_toolitem, False)

        vbox.pack_start( hbox, False )

        self.window.show_all()

        self.start_updater()
Exemplo n.º 30
0
    def __init__(self, suite, suiterc, start_point_string, stop_point_string,
                 template_vars, orientation="TB",
                 subgraphs_on=False, ignore_suicide=True, should_hide=False):
        self.outfile = None
        self.disable_output_image = False
        self.suite = suite
        self.file = suiterc
        self.suiterc = None
        self.orientation = orientation
        self.subgraphs_on = subgraphs_on
        self.template_vars = template_vars
        self.ignore_suicide = ignore_suicide
        self.start_point_string = start_point_string
        self.stop_point_string = stop_point_string
        self.filter_recs = []

        util.setup_icons()

        gtk.Window.__init__(self)

        self.graph = xdot.Graph()

        window = self

        window.set_title('Cylc Suite Dependency Graph Viewer')
        window.set_default_size(512, 512)
        window.set_icon(util.get_icon())
        vbox = gtk.VBox()
        window.add(vbox)

        self.widget = xdot.DotWidget()

        # Create a UIManager instance
        uimanager = self.uimanager = gtk.UIManager()

        # Add the accelerator group to the toplevel window
        accelgroup = uimanager.get_accel_group()
        window.add_accel_group(accelgroup)

        # Create an ActionGroup
        actiongroup = gtk.ActionGroup('Actions')
        self.actiongroup = actiongroup

        # create new stock icons for group and ungroup actions
        imagedir = os.environ['CYLC_DIR'] + '/images/icons'
        factory = gtk.IconFactory()
        for i in ['group', 'ungroup']:
            pixbuf = gtk.gdk.pixbuf_new_from_file(imagedir + '/' + i + '.png')
            iconset = gtk.IconSet(pixbuf)
            factory.add(i, iconset)
        factory.add_default()

        actiongroup.add_actions((
            ('ZoomIn', gtk.STOCK_ZOOM_IN, None, None, 'Zoom In',
                self.widget.on_zoom_in),
            ('ZoomOut', gtk.STOCK_ZOOM_OUT, None, None, 'Zoom Out',
                self.widget.on_zoom_out),
            ('ZoomFit', gtk.STOCK_ZOOM_FIT, None, None, 'Zoom Fit',
                self.widget.on_zoom_fit),
            ('Zoom100', gtk.STOCK_ZOOM_100, None, None, 'Zoom 100',
                self.widget.on_zoom_100),
            ('Group', 'group', 'Group', None, 'Group All Families',
                self.group_all),
            ('UnGroup', 'ungroup', 'Ungroup', None, 'Ungroup All Families',
                self.ungroup_all),
            ('Refresh', gtk.STOCK_REFRESH, None, None, 'Refresh',
                self.on_refresh),
            ('Save', gtk.STOCK_SAVE_AS, None, None, 'Save', self.save_action),
        ))
        actiongroup.add_toggle_actions((
            ('LeftToRight', 'transpose', 'Transpose',
             None, 'Transpose the graph', self.on_left_to_right),
        ))
        actiongroup.add_toggle_actions((
            ('Subgraphs', gtk.STOCK_LEAVE_FULLSCREEN, 'Cycle Point Subgraphs',
             None, 'Organise by cycle point', self.on_subgraphs),
        ))
        actiongroup.add_toggle_actions((
            ('IgnoreSuicide', gtk.STOCK_CANCEL, 'Ignore Suicide Triggers',
             None, 'Ignore Suicide Triggers', self.on_igsui),
        ))

        # Add the actiongroup to the uimanager
        uimanager.insert_action_group(actiongroup, 0)

        # Add a UI descrption
        uimanager.add_ui_from_string(self.ui)

        left_to_right_toolitem = uimanager.get_widget('/ToolBar/LeftToRight')
        left_to_right_toolitem.set_active(self.orientation == "LR")

        subgraphs_toolitem = uimanager.get_widget(
            '/ToolBar/Subgraphs')
        subgraphs_toolitem.set_active(self.subgraphs_on)

        igsui_toolitem = uimanager.get_widget(
            '/ToolBar/IgnoreSuicide')
        igsui_toolitem.set_active(self.ignore_suicide)

        # Create a Toolbar

        toolbar = uimanager.get_widget('/ToolBar')
        vbox.pack_start(toolbar, False)
        vbox.pack_start(self.widget)

        eb = gtk.EventBox()
        eb.add(gtk.Label("right-click on nodes to control family grouping"))
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#8be'))
        vbox.pack_start(eb, False)

        self.set_focus(self.widget)

        if not should_hide:
            self.show_all()
        self.load_config()