Logo Search packages:      
Sourcecode: webboard version File versions  Download package

def webboardlib::webboard::WebBoard::__init__ (   self,
  config,
  history,
  clip = False,
  file = None 
)
Initialize the main window of webboard

Definition at line 78 of file webboard.py.

                                                              :
        """
        Initialize the main window of webboard
        """
        self.config = config
        self.config.add_notifier(self.on_config_changed)
        self.history = history

        # setup an icon for the application
        icons = gtk.icon_theme_get_default()
        self.logo_pixbuf=icons.load_icon("gtk-paste", 32, 0)
        gtk.window_set_default_icon_list(self.logo_pixbuf)
        
        # get the glade widget
        self.glade = gtk.glade.XML(util.find_glade_file("webboard.glade"))
        self.glade.signal_autoconnect(self)

        #set the default language : Plain text
        # FIXME : Couldn't we autodetect this ?
        self.language = "Plain"

        # setup the gtksourceview
        self.lm = gtksourceview.SourceLanguagesManager()
        buffer = gtksourceview.SourceBuffer()
        buffer.set_data('languages-manager', self.lm)
        self.textview = gtksourceview.SourceView(buffer)
        mono_font = config.get_mono_font()
        if mono_font :
            font = pango.FontDescription(mono_font)
            self.textview.modify_font(font)
        scroller = self.glade.get_widget("scrolledwindow_code")
        scroller.add(self.textview)

        # setup the combobox to select the language
        lang_store = gtk.ListStore(gobject.TYPE_STRING,
                                   gobject.TYPE_STRING,
                                   gobject.TYPE_STRING)
        lang_store.set_sort_column_id(1, gtk.SORT_ASCENDING)

        for format in langs_list.keys():
            lang_store.append([format, langs_list[format][0],
                              langs_list[format][1]])

        self.combobox_syntax = self.glade.get_widget("combobox_syntax")
        cell = gtk.CellRendererText()
        self.combobox_syntax.pack_start(cell, True)
        self.combobox_syntax.add_attribute(cell, 'text', 1)

        self.combobox_syntax.set_model(lang_store)
        # FIXME : Do this in a cleaner way (won't work when translated)
        self.combobox_syntax.set_active(21)
        self.combobox_syntax.connect("changed", self.on_combobox_syntax_changed)
        
        # setup drag'n'drop
        self.textview.drag_dest_set(gtk.DEST_DEFAULT_ALL, \
                                    [('text/uri-list',0 , 0)], \
                                    gtk.gdk.ACTION_COPY)
        self.textview.connect("drag_motion", \
                              self.on_textview_drag_motion)
        self.textview.connect("drag_data_received", \
                              self.on_textview_drag_data_received)
        self.window_main = self.glade.get_widget("window_main")
        self.toolbutton_open = self.glade.get_widget("toolbutton_open")
        self.toolbutton_copy = self.glade.get_widget("toolbutton_copy")
        self.toolbutton_send = self.glade.get_widget("toolbutton_send")
        self.combobox_pastebin = self.glade.get_widget("combobox_pastebin")
        self.statusbar = self.glade.get_widget("statusbar")

        self.context = self.statusbar.get_context_id("context_webboard")

        self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)

        self.tooltips = gtk.Tooltips()

        self.on_config_changed()

        self.buffer = self.textview.get_buffer()
        text = self.clipboard.wait_for_text()
        if clip and text:
            self.buffer.set_text(text)
        else:
            self.buffer.set_text(self.welcome)
        if file:
            self.open_file(file)

        # Select the whole text
        self.buffer.select_range(self.buffer.get_start_iter(),
                                 self.buffer.get_end_iter())

        self.textview.show()
        self.window_main.show()


Generated by  Doxygen 1.6.0   Back to index