def _get_report_link_buttons(report_uri_list, report_description=None):
    if not report_uri_list:
        return None

    vbox_link_buttons = gtk.VBox(homogeneous=False)

    if report_description:
        label_report_text = report_description
        if not _webbrowser_module_found:
            label_report_text += " " + _("(right-click to copy link)")
        label_report_text += ":"

        label_report = gtk.Label(label_report_text)
        label_report.set_alignment(0, 0.5)
        label_report.set_padding(3, 3)
        label_report.set_line_wrap(True)
        label_report.set_line_wrap_mode(pango.WRAP_WORD)
        vbox_link_buttons.pack_start(label_report, expand=False, fill=False)

    report_linkbuttons = []
    for name, uri in report_uri_list:
        linkbutton = gtk.LinkButton(uri, label=name)
        linkbutton.set_alignment(0, 0.5)
        report_linkbuttons.append(linkbutton)

    for linkbutton in report_linkbuttons:
        vbox_link_buttons.pack_start(linkbutton, expand=False, fill=False)

    if _webbrowser_module_found:
        # Apparently, GTK doesn't know how to open URLs on Windows, hence the custom
        # solution.
        for linkbutton in report_linkbuttons:
            linkbutton.connect(
                "clicked",
                lambda linkbutton: webbrowser.open_new_tab(linkbutton.get_uri(
                )))

    return vbox_link_buttons
Beispiel #2
0
 def about_init(self):
     about = gtk.AboutDialog()
     about.set_name('PyGlossary')
     about.set_version(VERSION)
     about.set_authors(authors)
     about.set_comments(aboutText)
     #about.set_license('PyGlossary is licensed by GNU General Public License version 3 (or later)')
     vbox = about.get_children()[0].get_children()[0]
     try:
         link=gtk.LinkButton(homePage)
     except:## May be an old PyGTK version, that has not gtk.LinkButton
         about.set_website(homePage) ## A palin label (not link)
     else:
         vbox.pack_start(link, 0, 0)
         link.show()
         gtk.link_button_set_uri_hook(click_website) ## click_website defined in text_utils.py
     about.set_license(licenseText)
     about.set_wrap_license(True)
     about.connect('delete-event', self.about_close)
     buttons = about.get_children()[0].get_children()[1].get_children()## List of buttons of about dialogs
     buttons[2].connect('clicked', self.about_close) ## Fix the PyGTK bug that Close button does not work!
     about.set_logo(gtk.gdk.pixbuf_new_from_file(logo))
     self.about = about
def display_exception_message(exception_message,
                              plugin_title=None,
                              report_uri_list=None,
                              parent=None):
    """
  Display an error message for exceptions unhandled by the plug-in.
  
  The message also displays the exception message in the Details box, which
  is collapsed by default.
  
  Optionally, the dialog can contain links to sites where the users can report
  this error, copying the exception message to better track the error down.
  
  Parameters:
  
  * `exception_message` - Exception message (usually traceback) to display in
    the Details box.
  
  * `plugin_title` - Name of the plug-in (string) used as the message title and
    in the message contents.
  
  * `report_uri_list` - List of (name, URL) tuples where the user can report
    the error. If no report list is desired, pass None or an empty sequence.
  
  * `parent` - Parent GUI element.
  """
    def connect_linkbuttons(report_linkbuttons):
        def open_browser(linkbutton):
            webbrowser.open_new_tab(linkbutton.get_uri())

        for linkbutton in report_linkbuttons:
            linkbutton.connect("clicked", open_browser)

    dialog = gtk.MessageDialog(parent,
                               type=gtk.MESSAGE_ERROR,
                               flags=gtk.DIALOG_MODAL
                               | gtk.DIALOG_DESTROY_WITH_PARENT)
    dialog.set_markup("<span font_size=\"large\"><b>" +
                      _("Oops! Something went wrong.") + "</b></span>")
    dialog.format_secondary_markup(
        _("{0} encountered an unexpected error and has to close. Sorry about that!"
          ).format(plugin_title))
    dialog.set_title(plugin_title)

    expander = gtk.Expander()
    expander.set_use_markup(True)
    expander.set_label("<b>" + _("Details") + "</b>")

    scrolled_window = gtk.ScrolledWindow()
    scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
    scrolled_window.set_size_request(400, 200)
    scrolled_window.set_shadow_type(gtk.SHADOW_IN)

    exception_text_view = gtk.TextView()
    exception_text_view.set_editable(False)
    exception_text_view.set_cursor_visible(False)
    exception_text_view.set_pixels_above_lines(1)
    exception_text_view.set_pixels_below_lines(1)
    exception_text_view.set_pixels_inside_wrap(0)
    exception_text_view.set_left_margin(5)
    exception_text_view.set_right_margin(5)
    exception_text_view.get_buffer().set_text(exception_message)

    scrolled_window.add(exception_text_view)
    expander.add(scrolled_window)

    vbox_labels_report = gtk.VBox(homogeneous=False)

    if report_uri_list is not None and report_uri_list:
        label_report_header_text = _(
            "You can help fix this error by sending a report with the text "
            "in the details above to one of the following sites")
        if not _webbrowser_module_found:
            label_report_header_text += " " + _("(right-click to copy link)")
        label_report_header_text += ":"

        label_report_header = gtk.Label(label_report_header_text)
        label_report_header.set_alignment(0, 0.5)
        label_report_header.set_padding(3, 3)
        label_report_header.set_line_wrap(True)
        label_report_header.set_line_wrap_mode(gtk.WRAP_WORD)

        report_linkbuttons = []
        for name, uri in report_uri_list:
            linkbutton = gtk.LinkButton(uri, label=name)
            linkbutton.set_alignment(0, 0.5)
            report_linkbuttons.append(linkbutton)

        vbox_labels_report.pack_start(label_report_header,
                                      expand=False,
                                      fill=True)
        for linkbutton in report_linkbuttons:
            vbox_labels_report.pack_start(linkbutton, expand=False, fill=True)

        dialog.vbox.pack_end(vbox_labels_report, expand=False, fill=True)

    dialog.vbox.pack_start(expander, expand=False, fill=True)

    button_ok = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)

    dialog.set_focus(button_ok)

    if report_uri_list is not None and report_uri_list and _webbrowser_module_found:
        # Apparently, GTK doesn't know how to open URLs on Windows, hence the custom
        # solution.
        connect_linkbuttons(report_linkbuttons)

    dialog.show_all()
    dialog.run()
    dialog.destroy()
Beispiel #4
0
 def addLinkButton(self):
     self.linklabel = gtk.LinkButton(
         "http://www.sdu.dk", label="Locate article on Web of Science")
     self.vbox.pack_start(self.linklabel, False, False, 0)
Beispiel #5
0
	def __init__(self):
		gtk.Assistant.__init__(self)
		self.set_title(_('Add new target'))
		self.set_geometry_hints(min_width=600,min_height=500)

		self.used_target_id = None

		self.connect('apply',self.apply_pressed)
		self.connect('cancel',self.cancel_pressed)
		self.connect('prepare',self.prepare)

		self.page0 = gtk.VBox(spacing=5)
		hb = gtk.HBox(spacing=5)

		self.append_page(self.page0)
		self.set_page_title(self.page0,_('Entering target name'))
		self.set_page_type(self.page0,gtk.ASSISTANT_PAGE_CONTENT)

		hb.pack_start(gtk.Label(_('Enter new target name')),False,False)
		self.tarname = gtk.Entry()
		hb.pack_end(self.tarname,True)
		self.tarname.connect('changed',self.tarname_changed,self.page0)

		self.page0.pack_start(hb,False,False)

		l = gtk.Label(_('You can specify new target with:'))
		l.set_alignment(0,0.5)
		self.page0.pack_start(l,False,False)

		hb = gtk.HBox(spacing=0)
		hb.pack_start(gtk.Label(),False,False,25)
		hb.pack_start(gtk.LinkButton('http://simbad.u-strasbg.fr','Simbad'),False,False)
		l = gtk.Label(_('database'))
		l.set_alignment(0,0.5)
		hb.pack_end(l,True)

		self.page0.pack_start(hb,False,False)

		self.page1 = gtk.VBox(spacing=5)
		self.append_page(self.page1)

		self.error_label = gtk.Label()
		self.error_label.set_line_wrap(True)

		self.page1.pack_start(self.error_label)
		self.set_page_title(self.page1, _('Resolving target'))
		self.set_page_type(self.page1,gtk.ASSISTANT_PAGE_CONTENT)
		self.set_page_complete(self.page1,False)

		self.page2 = gtk.VBox(spacing=5)

		l = gtk.Label(_('Create new target'))
		l.set_alignment(0,0.5)
		self.page2.pack_start(l,False,False)

		self.resolved_selected = gtk.RadioButton()
		self.resolved_not_selected = gtk.RadioButton(self.resolved_selected)
		self.resolved_not_selected.set_active(True)
		self.resolved_selected.connect('toggled',self.resolved_toggled)
		self.resolved_name = gtk.Entry()
		self.resolved_name.set_text('')
		self.resolved_name.connect('changed',self.tarname_changed,self.page1)
		self.resolved_ra = gtk.Label('123456789012')
		self.resolved_dec = gtk.Label('123456789012')

		self.resolved_desc = gtk.Label()
		self.resolved_desc.set_alignment(0,0.5)

		hb = gtk.HBox(spacing=5)
		hb.pack_start(self.resolved_selected,False,False)
		hb.pack_start(self.resolved_name,True)

		hb.pack_end(self.resolved_dec,False,False)
		hb.pack_end(self.resolved_ra,False,False)

		self.page2.pack_start(hb,False,False)

		l = gtk.Label(_('or please select one from following existing targets'))
		l.set_alignment(0,0.5)
		self.page2.pack_start(l,False,False)

		self.old_path = None
		self.nearest = jsontable.JsonTable('/api/tbystring',data=json.loads('{"h":[{"n":"Target ID","t":"n","prefix":"/targets/","href":0,"c":0},{"n":"Target Name","t":"a","prefix":"/targets/","href":0,"c":1},{"n":"RA","t":"r","c":2},{"n":"DEC","t":"d","c":3},{"n":"Description","t":"s","c":4},{"n":"Distance","t":"d","c":5}],"d":[]}'),radio_select=_('Sel'),radio_select_func=self.toggled_target)

		self.page2.pack_end(self.nearest,True)

		self.append_page(self.page2)
		self.set_page_type(self.page2,gtk.ASSISTANT_PAGE_CONTENT)
		self.set_page_title(self.page2,_('Select target'))

		self.page3 = gtk.VBox(spacing=5)

		self.append_page(self.page3)
		self.set_page_type(self.page3,gtk.ASSISTANT_PAGE_PROGRESS)
		self.set_page_title(self.page3,_('Creating new target'))

		self.page4 = script.ScriptEditor()

		self.append_page(self.page4)

		self.set_page_type(self.page4,gtk.ASSISTANT_PAGE_CONTENT)
		self.set_page_title(self.page4,_('Edit target script'))

		self.page_progress = gtk.VBox(spacing=5)
		self.index_progress = self.append_page(self.page_progress)
		self.set_page_type(self.page_progress, gtk.ASSISTANT_PAGE_PROGRESS)
		self.set_page_title(self.page_progress, _("Retrieving data"))

		self.page_progress_pb = gtk.ProgressBar()
		self.page_progress.pack_start(self.page_progress_pb, True, False)

		self.set_forward_page_func(self.forward,None)

		self.show_all()
    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()
Beispiel #7
0
    def __init__(self, prefs=None, applet=None):
        gtk.Window.__init__(self)

        if prefs is not None:
            self.prefs = prefs
            self.applet = prefs.applet
            self.set_transient_for(prefs)

        elif applet is not None:
            self.applet = applet

        self.google_source = None
        for source in self.applet.feeds.values():
            if isinstance(source, classes.GoogleFeed):
                self.google_source = source
                break

        self.site_images = {}

        self.set_border_width(12)
        self.set_title(_("Add Feed"))
        self.set_icon_from_file(icon_path)

        #Source: label and radio buttons
        source_label = gtk.Label(_("Source:"))
        source_label.set_alignment(1.0, 0.0)

        source_vbox = gtk.VBox(False, 3)

        #Search via Google Reader
        pb = self.icon_theme.load_icon("system-search", 16, 0)
        pb = classes.get_16x16(pb)

        search_radio = gtk.RadioButton(None)
        search_radio.add(self.get_radio_hbox(pb, _("Search")))
        if not self.google_source:
            search_radio.set_sensitive(False)
            search_radio.set_tooltip_text(
                _("You must sign in to a Google service to search for feeds."))

        #Regular RSS/Atom feed
        try:
            pb = self.icon_theme.load_icon('application-rss+xml', 16, 0)
            pb = classes.get_16x16(pb)
        except:
            pb = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 16, 16)
        webfeed_radio = gtk.RadioButton(search_radio, None)
        webfeed_radio.add(self.get_radio_hbox(pb, _("RSS/Atom")))

        #Google (Reader and Wave)
        pb = self.applet.get_favicon('www.google.com', True)

        google_radio = gtk.RadioButton(search_radio, None)
        google_radio.add(
            self.get_radio_hbox(pb, classes.GoogleFeed.title,
                                'www.google.com'))

        #Google Reader (CheckButton)
        pb = get_greader_icon()

        self.greader_check = gtk.CheckButton()
        self.greader_check.add(
            self.get_radio_hbox(pb, classes.GoogleReader.title,
                                'google-reader'))
        self.greader_check.set_active(True)
        self.greader_check.connect('toggled', self.check_toggled)

        #Google Wave
        pb = self.applet.get_favicon('wave.google.com', True)

        self.gwave_check = gtk.CheckButton()
        self.gwave_check.add(
            self.get_radio_hbox(pb, classes.GoogleWave.title,
                                'wave.google.com'))
        self.gwave_check.connect('toggled', self.check_toggled)

        google_vbox = gtk.VBox(False, 3)
        google_vbox.pack_start(self.greader_check, False)
        google_vbox.pack_start(self.gwave_check, False)
        google_vbox.show_all()

        self.google_align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        self.google_align.set_padding(0, 0, 12, 0)
        self.google_align.add(google_vbox)
        self.google_align.set_no_show_all(True)

        #Reddit Inbox
        pb = self.applet.get_favicon('www.reddit.com', True)

        reddit_radio = gtk.RadioButton(search_radio, None)
        reddit_radio.add(
            self.get_radio_hbox(pb, classes.Reddit.title, 'www.reddit.com'))

        #Twitter Timeline and/or Replies
        pb = gtk.gdk.pixbuf_new_from_file_at_size(twitter_path, 16, 16)

        twitter_radio = gtk.RadioButton(search_radio, None)
        twitter_radio.add(self.get_radio_hbox(pb, _("Twitter")))

        self.twitter_timeline_check = gtk.CheckButton(_("Timeline"))
        self.twitter_timeline_check.set_active(True)
        self.twitter_timeline_check.connect('toggled', self.check_toggled)
        self.twitter_timeline_check.show()

        self.twitter_replies_check = gtk.CheckButton(_("Replies"))
        self.twitter_replies_check.connect('toggled', self.check_toggled)
        self.twitter_replies_check.show()

        twitter_vbox = gtk.VBox(False, 3)
        twitter_vbox.pack_start(self.twitter_timeline_check, False)
        twitter_vbox.pack_start(self.twitter_replies_check, False)
        twitter_vbox.show_all()

        self.twitter_align = gtk.Alignment(0.0, 0.0, 1.0, 0.0)
        self.twitter_align.set_padding(0, 0, 12, 0)
        self.twitter_align.add(twitter_vbox)
        self.twitter_align.set_no_show_all(True)

        num = 0
        for widget in (search_radio, webfeed_radio, google_radio,
                       self.google_align, reddit_radio, twitter_radio,
                       self.twitter_align):
            if isinstance(widget, gtk.RadioButton):
                widget.connect('toggled', self.radio_toggled)
                widget.num = num
                num += 1

            source_vbox.pack_start(widget, False, False, 0)

        source_hbox = gtk.HBox(False, 6)
        source_hbox.pack_start(source_label, False, False)
        source_hbox.pack_start(source_vbox)

        #"Search for" label and entry
        search_label = gtk.Label(_("Search for"))
        search_label.set_alignment(1.0, 0.5)
        search_label.show()

        self.search_entry = gtk.Entry()
        self.search_entry.show()
        self.search_entry.connect('changed', self.entry_changed)

        self.search_hbox = gtk.HBox(False, 6)
        self.search_hbox.pack_start(search_label, False)
        self.search_hbox.pack_start(self.search_entry)
        self.search_hbox.set_no_show_all(True)

        #URL: label and entry
        url_label = gtk.Label(_("URL:"))
        url_label.set_alignment(1.0, 0.5)
        url_label.show()

        self.url_entry = gtk.Entry()
        self.url_entry.show()
        self.url_entry.connect('changed', self.entry_changed)

        self.url_hbox = gtk.HBox(False, 6)
        self.url_hbox.pack_start(url_label, False, False)
        self.url_hbox.pack_start(self.url_entry)
        self.url_hbox.set_no_show_all(True)

        #Username: label and entry
        user_label = gtk.Label(_("Username:"******"Password:"******"Feed search by "))
        button = gtk.LinkButton(reader_url, _("Google Reader"))

        image.show()
        image_align.show()
        label.show()
        button.show()

        hbox = gtk.HBox()
        hbox.pack_start(image_align, False, False, 6)
        hbox.pack_start(label, False)
        hbox.pack_start(button, False)
        hbox.show()

        self.search_msg = gtk.HBox()
        self.search_msg.pack_start(hbox, True, False)
        self.search_msg.set_no_show_all(True)

        #Results VBox and ScrolledWindow for Feed Search
        self.results_vbox = gtk.VBox(False, 3)
        self.results_vbox.show()

        self.results_sw = gtk.ScrolledWindow()
        self.results_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.results_sw.add_with_viewport(self.results_vbox)
        self.results_sw.set_no_show_all(True)

        #Cancel and Add buttons
        cancel = gtk.Button(stock=gtk.STOCK_CLOSE)
        cancel.connect('clicked', self.close)

        self.add_button = gtk.Button(stock=gtk.STOCK_ADD)
        self.add_button.set_flags(gtk.CAN_DEFAULT)
        self.add_button.set_sensitive(False)
        self.add_button.set_no_show_all(True)
        self.add_button.connect('clicked', self.almost_add_feed)

        #If signed in to Google Reader
        self.search_button = gtk.Button(_("_Search"))
        image = gtk.image_new_from_icon_name('search', gtk.ICON_SIZE_BUTTON)
        self.search_button.set_image(image)
        self.search_button.set_flags(gtk.CAN_DEFAULT)
        self.search_button.set_sensitive(False)
        self.search_button.set_no_show_all(True)
        self.search_button.connect('clicked', self.do_search)

        if self.google_source is not None:
            self.search_button.show()
            self.search_hbox.show()
            self.search_msg.show()

        else:
            self.add_button.show()
            self.url_hbox.show()
            webfeed_radio.set_active(True)

        button_hbox = gtk.HBox(False, 6)
        button_hbox.pack_end(self.add_button, False, False)
        button_hbox.pack_end(self.search_button, False, False)
        button_hbox.pack_end(cancel, False, False)

        main_vbox = gtk.VBox(False, 6)
        main_vbox.pack_start(source_hbox, False, False)
        main_vbox.pack_start(self.search_hbox, False, False)
        main_vbox.pack_start(self.url_hbox, False, False)
        main_vbox.pack_start(self.user_hbox, False, False)
        main_vbox.pack_start(self.pass_hbox, False, False)
        main_vbox.pack_start(self.search_msg, False, False)
        main_vbox.pack_start(self.results_sw)
        main_vbox.pack_end(button_hbox, False, False)
        main_vbox.show_all()

        self.add(main_vbox)
        self.add_button.grab_default()

        #Make the labels the same size
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        sg.add_widget(source_label)
        sg.add_widget(search_label)
        sg.add_widget(url_label)
        sg.add_widget(user_label)
        sg.add_widget(pass_label)

        #Make the buttons the same size
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        sg.add_widget(cancel)
        sg.add_widget(self.add_button)
        sg.add_widget(self.search_button)

        self.show_all()

        #Update any downloaded favicons if necessary
        for siteid in ('www.google.com', 'google-reader', 'wave.google.com',
                       'www.reddit.com'):
            self.applet.fetch_favicon(self.fetched_favicon, siteid, siteid)
Beispiel #8
0
    def update_info(self, app):
        port = app.info

        # Clear
        for child in port.get_children():
            port.remove(child)

        # Alignment
        align = gtk.Alignment(0, 0, 1, 1)
        align.set_padding(4, 4, 4, 4)
        port.add(align)

        # Vertical box
        vbox = gtk.VBox()
        align.add(vbox)

        for category in self.info:
            name = category[0]
            category = category[1:]

            # Frame
            frame = gtk.Frame('<b>%s</b>' % name)
            frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
            frame.get_label_widget().set_use_markup(True)
            vbox.pack_start(frame, False)

            # Alignment
            align = gtk.Alignment(0, 0, 1, 1)
            align.set_padding(0, 0, 12, 0)
            frame.add(align)

            # Table
            table = gtk.Table(len(category), 2)
            table.set_col_spacing(0, 5)
            align.add(table)

            row = 0
            for name, value in category:
                # Name
                label = gtk.Label('<b>%s</b>' % name)
                label.set_use_markup(True)
                label.set_alignment(1, 0.5)
                table.attach(label, 0, 1, row, row + 1, gtk.FILL, gtk.FILL)

                # Value
                if value.startswith('http://'):
                    label = gtk.LinkButton(value, value)
                    label.set_relief(gtk.RELIEF_NONE)
                    label.set_property('can-focus', False)

                else:
                    label = gtk.Label(value)

                label.set_alignment(0, 0.5)
                label.modify_font(app.mono_font)
                table.attach(label, 1, 2, row, row + 1, yoptions=gtk.FILL)

                row += 1

        port.realize()
        port.show_all()
Beispiel #9
0
    def __init__(self, controls):
        gtk.Frame.__init__(self)
        FControl.__init__(self, controls)

        self.album_label = gtk.Label()
        self.album_label.set_line_wrap(True)
        self.album_label.set_markup("<b></b>")
        self.set_label_widget(self.album_label)

        self.empty = TextArea()

        self.best_songs = SimpleTreeControl(_("Best Songs"), controls)
        self.best_songs.line_title = EventLabel(self.best_songs.get_title(),
                                                func=self.show_current,
                                                arg=self.best_songs,
                                                func1=self.show_best_songs)

        self.artists = SimpleTreeControl(_("Similar Artists"), controls)
        self.artists.line_title = EventLabel(self.artists.get_title(),
                                             func=self.show_current,
                                             arg=self.artists,
                                             func1=self.show_similar_artists)

        self.tracks = SimpleTreeControl(_("Similar Songs"), controls)
        self.tracks.line_title = EventLabel(self.tracks.get_title(),
                                            func=self.show_current,
                                            arg=self.tracks,
                                            func1=self.show_similar_tracks)

        self.tags = SimpleTreeControl(_("Similar Tags"), controls)
        self.tags.line_title = EventLabel(self.tags.get_title(),
                                          func=self.show_current,
                                          arg=self.tags,
                                          func1=self.show_similar_tags)

        self.lyrics = TextArea()
        lyric_title = _("Lyrics")
        self.lyrics.set_text("", lyric_title)
        self.lyrics.line_title = EventLabel(lyric_title,
                                            func=self.show_current,
                                            arg=self.lyrics,
                                            func1=self.show_similar_lyrics)
        """wiki"""
        wBox = gtk.VBox()
        wiki_title = _("About Artist")
        self.wiki = TextArea()

        wBox.line_title = EventLabel(wiki_title,
                                     func=self.show_current,
                                     arg=wBox,
                                     func1=self.show_wiki_info)

        self.last_fm_label = gtk.LinkButton("http://www.last.fm", "last.fm")
        self.wiki_label = gtk.LinkButton("http://www.wikipedia.org",
                                         "wikipedia")

        self.wiki = TextArea()
        self.wiki.set_text("", wiki_title)

        wBox.pack_start(HBoxDecorator(self.last_fm_label, self.wiki_label),
                        False, False)
        wBox.pack_start(self.wiki, True, True)

        wBox.scroll = wBox

        self.vpaned_small = gtk.VBox(False, 0)
        """image and similar artists"""
        ibox = gtk.HBox(False, 0)
        self.image = ImageBase(ICON_BLANK_DISK, FC().info_panel_image_size)

        lbox = gtk.VBox(False, 0)

        self.left_widget = [
            wBox, self.artists, self.tracks, self.tags, self.lyrics,
            self.best_songs
        ]

        for l_widget in self.left_widget:
            lbox.pack_start(l_widget.line_title)

        ibox.pack_start(self.image, False, False)
        ibox.pack_start(lbox, True, True)
        """image and similar artists"""
        sbox = gtk.VBox(False, 0)

        for l_widget in self.left_widget:
            sbox.pack_start(l_widget.scroll, True, True)

        sbox.pack_end(self.empty.scroll, True, True)

        self.vpaned_small.pack_start(ibox, False, False)
        self.vpaned_small.pack_start(sbox, True, True)

        self.add(self.vpaned_small)

        self.hide_all()

        self.bean = None
        self.info_cache = InfoCache()
Beispiel #10
0
def open_link_in_browser(uri):
    link = gtk.LinkButton(uri)
    link.clicked()
Beispiel #11
0
    def __init__(self, policy, iface, env):
        dialog.Dialog.__init__(self)

        self.sf_group_id = 76468
        self.sf_artifact_id = 929902

        self.set_title(_('Report a Bug'))
        self.set_modal(True)
        self.set_has_separator(False)
        self.policy = policy
        self.frames = []

        vbox = gtk.VBox(False, 4)
        vbox.set_border_width(10)
        self.vbox.pack_start(vbox, True, True, 0)

        self.set_default_size(gtk.gdk.screen_width() / 2, -1)

        def frame(title, contents, buffer):
            fr = gtk.Frame()
            label = gtk.Label('')
            label.set_markup('<b>%s</b>' % title)
            fr.set_label_widget(label)
            fr.set_shadow_type(gtk.SHADOW_NONE)
            vbox.pack_start(fr, True, True, 0)

            align = gtk.Alignment(0, 0, 1, 1)
            align.set_padding(0, 0, 16, 0)
            fr.add(align)
            align.add(contents)

            self.frames.append((title, buffer))

        def text_area(text=None, mono=False):
            swin = gtk.ScrolledWindow()
            swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
            swin.set_shadow_type(gtk.SHADOW_IN)

            tv = gtk.TextView()
            tv.set_wrap_mode(gtk.WRAP_WORD)
            swin.add(tv)
            if text:
                tv.get_buffer().insert_at_cursor(text)

            if mono:
                tv.modify_font(pango.FontDescription('mono'))

            tv.set_accepts_tab(False)

            return swin, tv.get_buffer()

        actual = text_area()
        frame(_("What doesn't work?"), *actual)

        expected = text_area()
        frame(_('What did you expect to happen?'), *expected)

        errors_box = gtk.VBox(False, 0)
        errors_swin, errors_buffer = text_area(mono=True)
        errors_box.pack_start(errors_swin, True, True, 0)
        buttons = gtk.HButtonBox()
        buttons.set_layout(gtk.BUTTONBOX_START)
        errors_box.pack_start(buttons, False, True, 4)
        get_errors = gtk.Button(_('Run it now and record the output'))
        get_errors.connect('clicked',
                           lambda button: self.collect_output(errors_buffer))
        buttons.add(get_errors)

        frame(_('Are any errors or warnings displayed?'), errors_box,
              errors_buffer)

        if dialog.last_error:
            errors_buffer.insert_at_cursor(str(dialog.last_error))

        environ = text_area(env, mono=True)
        frame(_('Information about your setup'), *environ)

        browse_url = 'http://sourceforge.net/tracker/?group_id=%d&atid=%d' % (
            self.sf_group_id, self.sf_artifact_id)
        location_hbox = gtk.HBox(False, 4)
        location_hbox.pack_start(gtk.Label(_('Bugs reports will be sent to:')),
                                 False, True, 0)
        if hasattr(gtk, 'LinkButton'):
            import browser
            url_box = gtk.LinkButton(browse_url)
            url_box.connect('clicked',
                            lambda button: browser.open_in_browser(browse_url))
        else:
            url_box = gtk.Label(browse_url)
            url_box.set_selectable(True)
        location_hbox.pack_start(url_box, False, True, 0)
        vbox.pack_start(location_hbox, False, True, 0)

        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        self.set_default_response(gtk.RESPONSE_OK)

        def resp(box, r):
            if r == gtk.RESPONSE_OK:
                text = ''
                for title, buffer in self.frames:
                    start = buffer.get_start_iter()
                    end = buffer.get_end_iter()
                    text += '%s\n\n%s\n\n' % (title, buffer.get_text(
                        start, end).strip())
                title = _('Bug for %s') % iface.get_name()
                self.report_bug(title, text)
                self.destroy()
                dialog.alert(self,
                             _("Your bug report has been sent. Thank you."),
                             type=gtk.MESSAGE_INFO)
            else:
                self.destroy()

        self.connect('response', resp)

        self.show_all()
Beispiel #12
0
    def detect_tools(self):
        '''
            Iterate through all tool files from import directory
            Each file contains information on a particular tool
            and knows how to determine if the tool is present on the system
            and what configuration options are needed for the tool

            Currently displays the tool info and config grayed out if tool is not present
        '''
        logging.debug('>>')
        self.updateStatusbar(self.statusbarDevice, "Checking for tools")
        #Remove all components in vbox - in case of re-detection
        for child in self.vboxImportTools.get_children():
            self.vboxImportTools.remove(child)
        #Get import tool_* files
        fileList = glob.glob(self.data_path + "import/tool_*.py")
        logging.debug("Tools filelist: %s" % fileList)
        for toolFile in fileList:
            index = fileList.index(toolFile)
            directory, filename = os.path.split(toolFile)
            filename = filename.rstrip('.py')
            classname = filename.lstrip('tool_')
            #Import module
            sys.path.insert(0, self.data_path + "import")
            module = __import__(filename)
            toolMain = getattr(module, classname)
            #Instantiate module
            toolClass = toolMain(self.parent, self.data_path)
            #Get info from class
            toolName = toolClass.getName()
            toolTable = gtk.Table()
            toolFrame = gtk.Frame(label=toolName)
            toolFrame.add(toolTable)
            if toolClass.isPresent():
                version = gtk.Label("Version: " + toolClass.getVersion())
                version.set_alignment(0, 0)
                if toolClass.deviceExists():
                    deviceExists = gtk.Label(_("GPS device found"))
                    deviceExists.set_alignment(0, 0)
                else:
                    deviceExists = gtk.Label(_("GPS device <b>not</b> found"))
                    deviceExists.set_alignment(0, 0)
                    deviceExists.set_use_markup(True)
                toolTable.attach(version,
                                 0,
                                 1,
                                 0,
                                 1,
                                 xoptions=gtk.EXPAND | gtk.FILL,
                                 xpadding=5)
                toolTable.attach(deviceExists,
                                 0,
                                 1,
                                 1,
                                 2,
                                 xoptions=gtk.EXPAND | gtk.FILL,
                                 xpadding=5)
                toolFrame.set_sensitive(1)
            else:
                info = gtk.Label(_("This tool was not found on the system"))
                info.set_alignment(0, 0.5)
                location = gtk.LinkButton(toolClass.getSourceLocation(),
                                          toolName + _(" Homepage"))
                info.set_sensitive(0)
                toolTable.attach(info,
                                 0,
                                 1,
                                 0,
                                 1,
                                 xoptions=gtk.EXPAND | gtk.FILL,
                                 xpadding=5)
                toolTable.attach(location,
                                 1,
                                 2,
                                 0,
                                 1,
                                 xoptions=gtk.EXPAND | gtk.FILL,
                                 xpadding=5)
                #toolFrame.set_sensitive(0)
            self.vboxImportTools.pack_start(toolFrame,
                                            expand=False,
                                            fill=False,
                                            padding=5)
        self.win_importdata.show_all()
        logging.debug('<<')
Beispiel #13
0
    def init_ui(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_size_request(750, 700)
        window.set_resizable(True)
        window.connect("destroy", self.close_application)
        window.set_title("Commotion Wireless for Windows (prototype 1)")
        window.set_border_width(0)

        box1 = gtk.VBox(False, 0)
        window.add(box1)
        box1.show()

        box2 = gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()

        notebook = gtk.Notebook()
        notebook.set_tab_pos(gtk.POS_TOP)
        notebook.show_all()
        self.show_tabs = True
        self.show_border = True

        def add_page(notebook, title, image, page):
            label = gtk.Label(title)
            vbox = gtk.VBox(False, 0)
            vbox.set_size_request(60, 60)
            image.set_size_request(46, 46)
            vbox.pack_start(image, False, True, 0)
            vbox.pack_start(label, False, True, 0)
            label.show()
            vbox.show()
            notebook.append_page(page, vbox)

        self.textview = gtk.TextView()
        self.textview.set_sensitive(False)
        self.textbuffer = self.textview.get_buffer()
        self.textview.show()

        hbox = gtk.HBox(False, 10)

        # FIXME replace with TreeView: http://www.pygtk.org/pygtk2tutorial/ch-TreeViewWidget.html
        clist = gtk.CList(2)
        for k, v in self.profiles.iteritems():
            clist.append(["@" if v["available"] else "", k])
        clist.set_column_width(0, 10)
        clist.set_column_width(1, 190)
        clist.set_shadow_type(gtk.SHADOW_OUT)
        clist.connect("select_row", self.profile_selection_made)
        clist.show()
        hbox.pack_start(clist, expand=False, fill=False, padding=0)
        hbox.show()

        def get_profile_editor_controls():
            def add_item(b, l, t):
                l.set_alignment(0, 0)
                b.pack_start(l, expand=False, fill=False, padding=0)
                b.pack_start(t, expand=False, fill=False, padding=0)

            vbox = gtk.VBox(False, 10)

            label = gtk.Label("Mesh Netword Name (SSID):")
            self.tbSSID = gtk.Entry()
            self.tbSSID.connect("changed", self.changed)
            add_item(vbox, label, self.tbSSID)

            label = gtk.Label("BSSID:")
            self.tbBSSID = gtk.Entry()
            self.tbBSSID.connect("changed", self.changed)
            add_item(vbox, label, self.tbBSSID)

            label = gtk.Label("Channel:")
            self.tbChannel = gtk.Entry()
            self.tbChannel.connect("changed", self.changed)
            add_item(vbox, label, self.tbChannel)

            label = gtk.Label("IP:")
            self.tbIP = gtk.Entry()
            self.tbIP.connect("changed", self.changed)
            add_item(vbox, label, self.tbIP)

            label = gtk.Label("IPGenerate:")
            self.cbIPGenerate = gtk.CheckButton()
            self.cbIPGenerate.connect("toggled", self.changed)
            add_item(vbox, label, self.cbIPGenerate)

            label = gtk.Label("Netmask:")
            self.tbNetmask = gtk.Entry()
            self.tbNetmask.connect("changed", self.changed)
            add_item(vbox, label, self.tbNetmask)

            label = gtk.Label("DNS:")
            self.tbDNS = gtk.Entry()
            self.tbDNS.connect("changed", self.changed)
            add_item(vbox, label, self.tbDNS)

            hbox = gtk.HBox(False, 10)
            self.save_button = gtk.Button("Save Profile")
            self.save_button.set_sensitive(False)
            self.save_button.connect("clicked", self.save_profile_clicked)
            hbox.pack_start(self.save_button)

            self.undo_changes_button = gtk.Button("Undo Changes")
            self.undo_changes_button.set_sensitive(False)
            self.undo_changes_button.connect("clicked",
                                             self.undo_changes_clicked)
            hbox.pack_start(self.undo_changes_button)

            vbox.pack_end(hbox, expand=False, fill=False, padding=0)

            vbox.show_all()

            # load first profile
            clist.select_row(0, 0)

            return vbox

        vbox_profile_controls = get_profile_editor_controls()
        hbox.pack_start(vbox_profile_controls,
                        expand=True,
                        fill=True,
                        padding=10)
        hbox.show()

        TAB_IMAGE_WIDTH = 40
        TAB_IMAGE_HEIGHT = 40

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabProfiles.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()

        add_page(notebook, "Profiles", image, hbox)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabLog.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()
        """
        vbox = gtk.VBox(False, 10)
        vbox.pack_start(self.textview, True, True, 0)
        button = gtk.Button("show jsoninfo")
        button.connect("clicked", self.show_jsoninfo)
        vbox.pack_start(button, True, True, 0)
        button.show()
        vbox.show()
        add_page(notebook, "Logs", image, vbox)
        """
        add_page(notebook, "Logs", image, self.textview)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabStatus.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()
        label = gtk.Label("Status goes here...")
        label.show()
        add_page(notebook, "Status", image, label)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabHelp.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()

        vbox = gtk.VBox(False, 10)

        logo_pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'commotion_logo.png')))
        logo = gtk.image_new_from_pixbuf(logo_pixbuf)
        logo.show()
        vbox.pack_start(logo)

        blurb = gtk.Label(
            "Commotion is an open-source communication tool that uses mobile phones, computers, and other wireless devices to create decentralized mesh networks."
        )
        blurb.set_line_wrap(True)
        blurb.show()
        vbox.pack_start(blurb)

        link = gtk.LinkButton("https://commotionwireless.net/",
                              "commotionwireless.net")
        link.show()
        vbox.pack_start(link)

        vbox.show()

        add_page(notebook, "About", image, vbox)

        vbox = gtk.VBox(False, 10)

        box2.pack_start(notebook)

        string = "\n"
        self.textbuffer.set_text(string)

        hbox = gtk.HButtonBox()
        box2.pack_start(hbox, False, False, 0)
        hbox.show()

        vbox = gtk.VBox()
        vbox.show()
        hbox.pack_start(vbox, expand=False, fill=False, padding=0)

        # check button to start up commotion
        check = gtk.ToggleButton(strings.TOGGLE_TEXT_START)
        vbox.pack_start(check, expand=False, fill=False, padding=0)
        check.connect("toggled", self.toggle_start, self.textview)
        check.set_active(False)
        check.show()

        separator = gtk.HSeparator()
        box1.pack_start(separator, False, True, 0)
        separator.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, False, True, 0)
        box2.show()

        button = gtk.Button("show mesh status")
        button.connect("clicked", self.show_mesh_status)
        box2.pack_start(button, True, True, 0)
        button.show()

        button = gtk.Button("show jsoninfo")
        button.connect("clicked", self.show_jsoninfo)
        box2.pack_start(button, True, True, 0)
        button.show()

        button = gtk.Button("quit winmesh")
        button.connect("clicked", self.close_application)
        box2.pack_start(button, True, True, 0)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()
        button.show()

        window.show()
Beispiel #14
0
    def __init__(self, glade_xml, window):
        self.xml = glade_xml
        self.xml.signal_autoconnect(self)
        self.window = window

        self._plugins = list(mesk.plugin.get_manager().get_all_plugins())
        self._plugins.sort(
            cmp=lambda x, y: cmp(x['DISPLAY_NAME'], y['DISPLAY_NAME']))
        if not self._plugins:
            # No plugins to show.
            self.prefs_notebook.remove_page(self.PLUGINS_TAB)
            return

        self.plugins_notebook = self.xml.get_widget('plugins_notebook')
        self.plugins_notebook.set_show_tabs(False)
        self.plugin_config_container = self.xml.get_widget(
            'plugin_config_vbox')

        # Plugin info widgets
        self._name_label = self.xml.get_widget('name_label')
        self._desc_label = self.xml.get_widget('description_label')
        self._author_label = self.xml.get_widget('author_label')
        self._copyright_label = self.xml.get_widget('copyright_label')
        self._plugin_image = self.xml.get_widget('plugin_image')
        self._config_button = self.xml.get_widget('plugin_config_button')
        self._config_button.set_sensitive(False)

        self._url_linkbutton = gtk.LinkButton('')
        from mesk.gtk_utils import default_linkbutton_callback
        self._url_linkbutton.connect('clicked', default_linkbutton_callback)

        # Create plugins list and model
        (self.MODEL_ENABLED, self.MODEL_NAME) = range(2)
        plugins_model = gtk.ListStore(
            int,  # Enabled
            str,  # Plugin name
        )

        plugins_view = self.xml.get_widget('plugins_treeview')
        plugins_view.set_model(plugins_model)

        col = gtk.TreeViewColumn(_('Plugin'))
        txt_renderer = gtk.CellRendererText()
        col.pack_start(txt_renderer, True)
        col.add_attribute(txt_renderer, 'text', 1)
        plugins_view.append_column(col)

        col = gtk.TreeViewColumn(_('Enabled'))
        toggle_renderer = gtk.CellRendererToggle()
        toggle_renderer.set_property('activatable', True)
        toggle_renderer.connect('toggled', self._on_plugin_toggled,
                                plugins_model)
        col.pack_start(toggle_renderer, True)
        col.add_attribute(toggle_renderer, 'active', 0)
        plugins_view.append_column(col)

        # Populate plugins list
        active_plugins = mesk.plugin.get_manager().get_active_plugins()
        active_names = []
        for plugin in active_plugins:
            active_names.append(plugin.name)

        for plugin in self._plugins:
            plugins_model.append(
                [plugin['NAME'] in active_names, plugin['DISPLAY_NAME']])
            # Create a Pixbuf from the xpm data
            pixbuf = gtk.gdk.pixbuf_new_from_xpm_data(plugin['XPM'])
            plugin['PIXBUF'] = pixbuf
            # Save some memory
            plugin['XPM'] = ''

        plugins_view.set_cursor(0)
        self._plugins_view = plugins_view
Beispiel #15
0
    def __init__(self, notebookinfo=None, port=8080, public=True, **opts):
        '''Constructor
		@param notebookinfo: the notebook location
		@param port: the http port to serve on
		@param public: allow connections to the server from other
		computers - if C{False} can only connect from localhost
		@param opts: options for L{WWWInterface.__init__()}
		'''
        gtk.Window.__init__(self)
        self.set_title('Zim - ' + _('Web Server'))  # T: Window title
        self.set_border_width(10)
        self.connect('destroy', lambda a: gtk.main_quit())
        self.interface_opts = opts
        self.httpd = None
        self._source_id = None

        # Widgets
        self.status_label = gtk.Label()
        self.status_label.set_markup('<i>' + _('Server not started') + '</i>')
        # T: Status in web server gui
        self.start_button = IconButton('gtk-media-play')
        self.start_button.connect('clicked', lambda o: self.start())
        self.stop_button = IconButton('gtk-media-stop')
        self.stop_button.connect('clicked', lambda o: self.stop())
        self.stop_button.set_sensitive(False)

        if gtk.gtk_version >= (2, 10):
            self.link_button = gtk.LinkButton('')
            self.link_button.set_sensitive(False)
            gtk.link_button_set_uri_hook(lambda o, url: webbrowser.open(url))
        else:
            self.link_button = None

        self.notebookcombobox = NotebookComboBox(current=notebookinfo)
        self.open_button = IconButton('gtk-index')
        self.open_button.connect('clicked',
                                 lambda *a: NotebookDialog(self).run())

        self.portentry = gtk.SpinButton()
        self.portentry.set_numeric(True)
        self.portentry.set_range(80, 10000)
        self.portentry.set_increments(1, 80)
        self.portentry.set_value(port)

        self.public_checkbox = gtk.CheckButton(label=_('Allow public access'))
        # T: Checkbox in web server gui
        self.public_checkbox.set_active(public)

        # Build the interface
        vbox = gtk.VBox()
        self.add(vbox)

        hbox = gtk.HBox(spacing=12)
        hbox.pack_start(self.start_button, False)
        hbox.pack_start(self.stop_button, False)
        hbox.pack_start(self.status_label, False)
        vbox.add(hbox)

        table = input_table_factory((
            (_('Notebook'), self.notebookcombobox, self.open_button),
            # T: Field in web server gui
            (_('Port'), self.portentry),
            # T: Field in web server gui for HTTP port (e.g. port 80)
            self.public_checkbox))
        vbox.add(table)

        if self.link_button:
            hbox = gtk.HBox()
            hbox.pack_end(self.link_button, False)
            vbox.add(hbox)
Beispiel #16
0
    def __init__(self, assistant):
        AssistantPage.__init__(self, assistant)
        self.export_formats = zim.formats.list_formats(
            zim.formats.EXPORT_FORMAT)
        self.export_formats.insert(
            1, 'MHTML (Web Page Archive)')  # TODO translatable

        self.add_form(
            (
                ('format', 'choice', _('Format'),
                 self.export_formats),  # T: Input label in the export dialog
                ('template', 'choice', _('Template'),
                 ()),  # T: Input label in the export dialog
                ('template_file', 'file', None),
                None,
                ('document_root:absolute', 'option',
                 _('Link files under document root with full file path')
                 ),  # T: radio option in export dialog
                ('document_root:url', 'option', _('Map document root to URL') +
                 ': '),  # T: radio option in export dialog
                ('document_root_url', 'string', None),
            ),
            depends={'document_root_url': 'document_root:url'})

        ## Same button appears in edit preferences dialog
        if gtk.gtk_version >= (2, 10) \
        and gtk.pygtk_version >= (2, 10):
            url_button = gtk.LinkButton(
                'https://github.com/jaap-karssenberg/zim-wiki/wiki/Templates',
                _('Get more templates online')  # T: label for button with URL
            )
            self.pack_start(url_button, False)

        # Set template list based on selected format
        def set_templates(self):
            format = self.form['format']
            format = zim.formats.canonical_name(format)
            if format == 'mhtml':
                format = 'html'
            combobox = self.form.widgets['template']
            combobox.get_model().clear()

            for name, _ in zim.templates.list_templates(format):
                combobox.append_text(name)
            combobox.append_text(self.CHOICE_OTHER)
            combobox.set_sensitive(True)

            template = self.uistate['template']
            if template == '__file__':
                # Select "Other..."
                combobox.set_active(len(templates))
            else:
                try:
                    self.form['template'] = template
                except ValueError:
                    combobox.set_active(0)

        self.form.widgets['format'].connect_object('changed', set_templates,
                                                   self)

        # Hook template entry to be sensitive on "Other.."
        self.form.widgets['template_file'].set_sensitive(False)
        self.form.widgets['template'].connect(
            'changed', lambda o: self.form.widgets['template_file'].
            set_sensitive(o.get_active_text() == self.CHOICE_OTHER))

        # Check if we have a document root - if not disable all options
        docroot = assistant.ui.notebook.document_root
        if not docroot:
            for widget in self.form.widgets:
                if widget.startswith('document_root:'):
                    self.form.widgets[widget].set_sensitive(False)
            self.uistate.input(document_root_url='')
    def __init__(self, dialog, plugins):
        gtk.VBox.__init__(self, spacing=5)
        self.dialog = dialog
        self.plugins = plugins

        self.hbox = gtk.HBox(self, spacing=12)
        self.hbox.set_border_width(5)
        self.add(self.hbox)

        #~ logger.debug('Plugins that are loaded: %s' % list(plugins))

        self.treeview = PluginsTreeView(self.plugins)
        self.treeselection = self.treeview.get_selection()
        self.treeselection.connect('changed', self.do_selection_changed)
        swindow = ScrolledWindow(self.treeview, hpolicy=gtk.POLICY_NEVER)
        self.hbox.pack_start(swindow, False)

        vbox = gtk.VBox()
        self.hbox.add(vbox)

        # Textview with scrollbars to show plugins info. Required by small screen devices
        swindow, textview = ScrolledTextView()
        textview.set_cursor_visible(False)
        self.textbuffer = textview.get_buffer()
        self.textbuffer.create_tag('bold', weight=pango.WEIGHT_BOLD)
        self.textbuffer.create_tag('red', foreground='#FF0000')
        vbox.pack_start(swindow, True)

        hbox = gtk.HBox(spacing=5)
        vbox.pack_end(hbox, False)

        self.plugin_help_button = \
         Button(stock=gtk.STOCK_HELP, label=_('_More')) # T: Button in plugin tab
        self.plugin_help_button.connect('clicked', self.on_help_button_clicked)
        hbox.pack_start(self.plugin_help_button, False)

        self.configure_button = \
         Button(stock=gtk.STOCK_PREFERENCES, label=_('C_onfigure')) # T: Button in plugin tab
        self.configure_button.connect('clicked',
                                      self.on_configure_button_clicked)
        hbox.pack_start(self.configure_button, False)

        try:
            self.treeselection.select_path(0)
        except:
            pass  # maybe loading plugins failed

        ## Add buttons to get and install new plugins
        hbox = gtk.HButtonBox()
        hbox.set_border_width(5)
        hbox.set_layout(gtk.BUTTONBOX_START)
        self.pack_start(hbox, False)

        assert hasattr(self.dialog, 'ui')
        open_button = gtk.Button(label=_('Open plugins folder'))
        open_button.connect('clicked',
                            lambda o: self.dialog.ui.open_dir(PLUGIN_FOLDER))
        hbox.pack_start(open_button, False)

        if gtk.gtk_version >= (2, 10) \
        and gtk.pygtk_version >= (2, 10):
            url_button = gtk.LinkButton(
                'http://zim-wiki.org/more_plugins.html',
                _('Get more plugins online')  # T: label for button with URL
            )
            hbox.pack_start(url_button, False)
Beispiel #18
0
    def __init__(self):
        """Init function with the whole GUI declaration and signals"""

        gtk.Window.__init__(self)
        self.set_default_size(900, 800)
        self.connect('destroy', lambda win: gtk.main_quit())

        self.set_title('DOSEMATIC v0.2')

        # Add a VBox
        vbox = gtk.VBox()
        self.add(vbox)

        # Setup Scrolled Window
        scrolled_win = gtk.ScrolledWindow()
        scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        # Setup ListStore to contain images and description
        model = {}
        DEFAULT_IMAGE_WIDTH = 230
        view = {}
        frame = {}
        frames = gtk.VBox()
        for key in desc:
            model[key] = (gtk.ListStore(gtk.gdk.Pixbuf, str))
            for im, dsc in zip(images[key], desc[key]):
                try:
                    pixbuf = gtk.gdk.pixbuf_new_from_file("images/" + im)
                    pix_w = pixbuf.get_width()
                    pix_h = pixbuf.get_height()
                    new_h = (
                        pix_h * DEFAULT_IMAGE_WIDTH
                    ) / pix_w  # Calculate the scaled height before resizing image
                    scaled_pix = pixbuf.scale_simple(DEFAULT_IMAGE_WIDTH,
                                                     new_h,
                                                     gtk.gdk.INTERP_TILES)
                    model[key].append((scaled_pix, dsc))
                    i += 1
                except:
                    pass
            # Setup GtkIconView
            view[key] = gtk.IconView(
                model[key]
            )  # Pass the model stored in a ListStore to the GtkIconView
            view[key].set_pixbuf_column(0)
            view[key].set_text_column(1)
            view[key].set_selection_mode(gtk.SELECTION_SINGLE)
            view[key].set_columns(0)
            view[key].set_item_width(265)
            # connect signals to IconView
            view[key].connect('selection-changed', self.on_selection_changed,
                              key)
            view[key].connect('item-activated', self.on_item_activated, key)

            frame[key] = gtk.Frame(module_titles[key])
            frame[key].set_border_width(10)
            frame[key].add(view[key])

        eb = gtk.EventBox()
        eb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
        eb.add(frames)

        self.list_recent = []
        self.read_recent(self.list_recent)
        # Recently used modules:
        list_recent = self.list_recent
        model_recent = gtk.ListStore(gtk.gdk.Pixbuf, str)
        images_recent = []
        images_recent.append(images[list_recent[0][0]][int(list_recent[0][1])])
        images_recent.append(images[list_recent[1][0]][int(list_recent[1][1])])
        images_recent.append(images[list_recent[2][0]][int(list_recent[2][1])])
        desc_recent = []
        desc_recent.append(module_titles[list_recent[0][0]] + ": " +
                           desc[list_recent[0][0]][int(list_recent[0][1])])
        desc_recent.append(module_titles[list_recent[1][0]] + ": " +
                           desc[list_recent[1][0]][int(list_recent[1][1])])
        desc_recent.append(module_titles[list_recent[2][0]] + ": " +
                           desc[list_recent[2][0]][int(list_recent[2][1])])
        for im, dsc in zip(images_recent, desc_recent):
            try:
                pixbuf = gtk.gdk.pixbuf_new_from_file("images/" + im)
                pix_w = pixbuf.get_width()
                pix_h = pixbuf.get_height()
                new_h = (
                    pix_h * DEFAULT_IMAGE_WIDTH
                ) / pix_w  # Calculate the scaled height before resizing image
                scaled_pix = pixbuf.scale_simple(DEFAULT_IMAGE_WIDTH, new_h,
                                                 gtk.gdk.INTERP_TILES)
                model_recent.append((scaled_pix, dsc))
            except:
                pass
        # Setup GtkIconView
        view_recent = gtk.IconView(
            model_recent
        )  # Pass the model stored in a ListStore to the GtkIconView
        view_recent.set_pixbuf_column(0)
        view_recent.set_text_column(1)
        view_recent.set_selection_mode(gtk.SELECTION_SINGLE)
        view_recent.set_columns(0)
        view_recent.set_item_width(265)
        # connect signals to IconView
        view_recent.connect('selection-changed',
                            self.on_selection_changed_recent, list_recent)
        view_recent.connect('item-activated', self.on_item_activated_recent,
                            list_recent)

        frame_recent = gtk.Frame("Recently Used")
        frame_recent.set_border_width(15)
        frame_recent.add(view_recent)

        # Pack objects
        frames.pack_start(frame_recent, True, True)
        hsep = gtk.HSeparator()
        frames.pack_start(hsep, False, False, 5)
        for key in desc:
            frames.pack_start(frame[key], True, True)

        scrolled_win.add_with_viewport(eb)
        scrolled_win.set_size_request(900, 610)
        scrolled_win.set_border_width(0)

        vbox.pack_start(scrolled_win)

        # Add TextView to show info about modules
        self.text = gtk.TextView()
        self.text.set_editable(False)
        self.text.set_left_margin(10)
        self.text.set_right_margin(10)
        self.text.set_pixels_above_lines(5)
        self.text.set_wrap_mode(gtk.WRAP_WORD)  # wrap words
        scroll_text = gtk.ScrolledWindow()  # into scrollable env
        scroll_text.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        scroll_text.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll_text.add(self.text)
        scroll_text.set_border_width(10)

        # Buttons: help->[guide,credits], launch->[basic,advanced], options?
        #i_help = gtk.Image()
        #i_help.set_from_stock(gtk.STOCK_HELP, gtk.ICON_SIZE_LARGE_TOOLBAR)
        #help_button = gtk.Button()
        #help_button.add(i_help)
        #help_button.set_tooltip_text("Help");

        # Buttons: help->[guide,credits], launch->[basic,advanced], options?
        i_info = gtk.Image()
        i_info.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_LARGE_TOOLBAR)
        info_button = gtk.LinkButton(
            "http://malewick.web.cern.ch/malewick/dosematic/TRS405_scr.pdf")
        info_button.add(i_info)
        info_button.set_tooltip_text("Information")

        i_index = gtk.Image()
        i_index.set_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_LARGE_TOOLBAR)
        index_button = gtk.LinkButton(
            "http://malewick.web.cern.ch/malewick/dosematic/uncertainty.pdf")
        index_button.add(i_index)
        index_button.set_tooltip_text("Handbook and Documentation")

        # pack buttons and scrollable text view together
        buttons_vbox = gtk.VBox()
        hruler = gtk.HSeparator()
        #buttons_vbox.pack_start(hruler, False, False, 20)
        buttons_vbox.pack_start(info_button, False, False, 5)
        #buttons_vbox.pack_start(help_button, False, False, 5)
        buttons_vbox.pack_start(index_button, False, False, 5)

        hbox = gtk.HBox()
        hbox.pack_start(scroll_text, True, True, 0)
        hbox.pack_start(buttons_vbox, False, False, 5)

        vbox.pack_start(hbox, True, True, 0)
        self.send_to_textview(general_description)
        self.module_chosen = False