Example #1
0
    def __init__(self,
                 type_id,
                 parent_win,
                 widget_name,
                 contact,
                 account,
                 resource=None):
        # dict { cb id : widget}
        # keep all registered callbacks of widgets, created by self.xml
        self.handlers = {}
        self.type_id = type_id
        self.parent_win = parent_win
        self.widget_name = widget_name
        self.contact = contact
        self.account = account
        self.hide_chat_buttons = False
        self.resource = resource

        self.session = None

        gajim.last_message_time[self.account][self.get_full_jid()] = 0

        self.xml = gtkgui_helpers.get_glade('message_window.glade',
                                            widget_name)
        self.widget = self.xml.get_widget(widget_name)
Example #2
0
	def __init__(self, jid = None, account = None):
		xml = gtkgui_helpers.get_glade('history_window.glade')
		self.window = xml.get_widget('history_window')
		self.jid_entry = xml.get_widget('jid_entry')
		self.calendar = xml.get_widget('calendar')
		scrolledwindow = xml.get_widget('scrolledwindow')
		self.history_textview = conversation_textview.ConversationTextview(
			account, used_in_history_window = True)
		scrolledwindow.add(self.history_textview.tv)
		self.history_buffer = self.history_textview.tv.get_buffer()
		self.history_buffer.create_tag('highlight', background = 'yellow')
		self.checkbutton = xml.get_widget('log_history_checkbutton')
		self.checkbutton.connect('toggled',
			self.on_log_history_checkbutton_toggled)
		self.query_entry = xml.get_widget('query_entry')
		self.query_combobox = xml.get_widget('query_combobox')
		self.query_combobox.set_active(0)
		self.results_treeview = xml.get_widget('results_treeview')
		self.results_window = xml.get_widget('results_scrolledwindow')
		
		# contact_name, date, message, time
		model = gtk.ListStore(str, str, str, str, str)
		self.results_treeview.set_model(model)
		col = gtk.TreeViewColumn(_('Name'))
		self.results_treeview.append_column(col)
		renderer = gtk.CellRendererText()
		col.pack_start(renderer)
		col.set_attributes(renderer, text = C_CONTACT_NAME)
		col.set_sort_column_id(C_CONTACT_NAME) # user can click this header and sort
		col.set_resizable(True)
		
		col = gtk.TreeViewColumn(_('Date'))
		self.results_treeview.append_column(col)
		renderer = gtk.CellRendererText()
		col.pack_start(renderer)
		col.set_attributes(renderer, text = C_UNIXTIME)
		col.set_sort_column_id(C_UNIXTIME) # user can click this header and sort
		col.set_resizable(True)
		
		col = gtk.TreeViewColumn(_('Message'))
		self.results_treeview.append_column(col)
		renderer = gtk.CellRendererText()
		col.pack_start(renderer)
		col.set_attributes(renderer, text = C_MESSAGE)
		col.set_resizable(True)
	
		self.jid = None # The history we are currently viewing
		self.account = None
		self.completion_dict = {}
		self.accounts_seen_online = [] # Update dict when new accounts connect
		self.jids_to_search = []

		# This will load history too
		gobject.idle_add(self._fill_completion_dict().next)

		if jid:
			self.jid_entry.set_text(jid)	

		xml.signal_autoconnect(self)
		self.window.show_all()
Example #3
0
    def __init__(self, dataformnode=None):
        ''' Create a widget. '''
        gtk.Alignment.__init__(self, xscale=1.0, yscale=1.0)

        self._data_form = None

        self.xml = gtkgui_helpers.get_glade('data_form_window.glade',
                                            'data_form_vbox')
        self.xml.signal_autoconnect(self)
        for name in ('instructions_label', 'instructions_hseparator',
                     'single_form_viewport', 'data_form_types_notebook',
                     'single_form_scrolledwindow', 'multiple_form_hbox',
                     'records_treeview', 'buttons_vbox', 'add_button',
                     'remove_button', 'edit_button', 'up_button',
                     'down_button', 'clear_button'):
            self.__dict__[name] = self.xml.get_widget(name)

        self.add(self.xml.get_widget('data_form_vbox'))

        if dataformnode is not None:
            self.set_data_form(dataformnode)

        selection = self.records_treeview.get_selection()
        selection.connect('changed', self.on_records_selection_changed)
        selection.set_mode(gtk.SELECTION_MULTIPLE)
Example #4
0
	def __init__(self):
		self.xml = gtkgui_helpers.get_glade('advanced_configuration_window.glade')
		self.window = self.xml.get_widget('advanced_configuration_window')
		self.window.set_transient_for(
			gajim.interface.instances['preferences'].window)
		self.entry = self.xml.get_widget('advanced_entry')
		self.desc_label = self.xml.get_widget('advanced_desc_label')
		self.restart_label = self.xml.get_widget('restart_label')

		# Format:
		# key = option name (root/subopt/opt separated by \n then)
		# value = array(oldval, newval)
		self.changed_opts = {}
		
		# For i18n
		self.right_true_dict = {True: _('Activated'), False: _('Deactivated')} 
		self.types = {
			'boolean': _('Boolean'),
			'integer': _('Integer'),
			'string': _('Text'),
			'color': _('Color')} 

		treeview = self.xml.get_widget('advanced_treeview')
		self.model = gtk.TreeStore(str, str, str)
		self.model.set_sort_column_id(0, gtk.SORT_ASCENDING)
		self.modelfilter = self.model.filter_new()
		self.modelfilter.set_visible_func(self.visible_func)

		renderer_text = gtk.CellRendererText()
		col = treeview.insert_column_with_attributes(-1, _('Preference Name'),
			renderer_text, text = 0)
		col.set_resizable(True)

		renderer_text = gtk.CellRendererText()
		renderer_text.connect('edited', self.on_config_edited)
		col = treeview.insert_column_with_attributes(-1, _('Value'),
			renderer_text, text = 1)
		col.set_cell_data_func(renderer_text, self.cb_value_column_data)

		col.props.resizable = True
		col.set_max_width(250)

		renderer_text = gtk.CellRendererText()
		treeview.insert_column_with_attributes(-1, _('Type'),
			renderer_text, text = 2)

		# add data to model
		gajim.config.foreach(self.fill, self.model)

		treeview.set_model(self.modelfilter)

		# connect signal for selection change
		treeview.get_selection().connect('changed',
			self.on_advanced_treeview_selection_changed)

		self.xml.signal_autoconnect(self)
		self.window.show_all()
		self.restart_label.hide()
		gajim.interface.instances['advanced_config'] = self
	def make_link_menu(self, event, kind, text):
		xml = gtkgui_helpers.get_glade('chat_context_menu.glade')
		menu = xml.get_widget('chat_context_menu')
		childs = menu.get_children()
		if kind == 'url':
			id = childs[0].connect('activate', self.on_copy_link_activate, text)
			self.handlers[id] = childs[0]
			id = childs[1].connect('activate', self.on_open_link_activate, kind,
				text)
			self.handlers[id] = childs[1]
			childs[2].hide() # copy mail address
			childs[3].hide() # open mail composer
			childs[4].hide() # jid section separator
			childs[5].hide() # start chat
			childs[6].hide() # join group chat
			childs[7].hide() # add to roster
		else: # It's a mail or a JID
			# load muc icon
			join_group_chat_menuitem = xml.get_widget('join_group_chat_menuitem')
			muc_icon = gtkgui_helpers.load_icon('muc_active')
			if muc_icon:
				join_group_chat_menuitem.set_image(muc_icon)

			text = text.lower()
			id = childs[2].connect('activate', self.on_copy_link_activate, text)
			self.handlers[id] = childs[2]
			id = childs[3].connect('activate', self.on_open_link_activate, kind,
				text)
			self.handlers[id] = childs[3]
			id = childs[5].connect('activate', self.on_start_chat_activate, text)
			self.handlers[id] = childs[5]
			id = childs[6].connect('activate',
				self.on_join_group_chat_menuitem_activate, text)
			self.handlers[id] = childs[6]

			allow_add = False
			c = gajim.contacts.get_first_contact_from_jid(self.account, text)
			if c and not gajim.contacts.is_pm_from_contact(self.account, c):
				if _('Not in Roster') in c.groups:
					allow_add = True
			else: # he or she's not at all in the account contacts
				allow_add = True

			if allow_add:
				id = childs[7].connect('activate', self.on_add_to_roster_activate,
					text)
				self.handlers[id] = childs[7]
				childs[7].show() # show add to roster menuitem
			else:
				childs[7].hide() # hide add to roster menuitem

			childs[0].hide() # copy link location
			childs[1].hide() # open link in browser

		menu.popup(None, None, None, event.button, event.time)
Example #6
0
	def __init__(self, contact, account, gc_contact = None):
		# the contact variable is the jid if vcard is true
		self.xml = gtkgui_helpers.get_glade('vcard_information_window.glade')
		self.window = self.xml.get_widget('vcard_information_window')
		self.progressbar = self.xml.get_widget('progressbar')

		self.contact = contact
		self.account = account
		self.gc_contact = gc_contact

		# Get real jid
		if gc_contact:
			# Don't use real jid if room is (semi-)anonymous
			gc_control = gajim.interface.msg_win_mgr.get_gc_control(
			gc_contact.room_jid, account)
			if gc_contact.jid and not gc_control.is_anonymous:
				self.real_jid = gc_contact.jid
				if gc_contact.resource:
					self.real_jid += '/' + gc_contact.resource
			else:
				self.real_jid = gc_contact.get_full_jid()
		else:
			self.real_jid = contact.get_full_jid()

		puny_jid = helpers.sanitize_filename(contact.jid)
		local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid) + \
			'_local'
		for extension in ('.png', '.jpeg'):
			local_avatar_path = local_avatar_basepath + extension
			if os.path.isfile(local_avatar_path):
				image = self.xml.get_widget('custom_avatar_image')
				image.set_from_file(local_avatar_path)
				image.show()
				self.xml.get_widget('custom_avatar_label').show()
				break
		self.avatar_mime_type = None
		self.avatar_encoded = None
		self.vcard_arrived = False
		self.os_info_arrived = False
		self.update_progressbar_timeout_id = gobject.timeout_add(100,
			self.update_progressbar)

		self.fill_jabber_page()
		annotations = gajim.connections[self.account].annotations
		if self.contact.jid in annotations:
			buffer = self.xml.get_widget('textview_annotation').get_buffer()
			buffer.set_text(annotations[self.contact.jid])

		self.xml.signal_autoconnect(self)
		self.window.show_all()
		self.xml.get_widget('close_button').grab_focus()
Example #7
0
    def __init__(self, contact, account, gc_contact=None):
        # the contact variable is the jid if vcard is true
        self.xml = gtkgui_helpers.get_glade('vcard_information_window.glade')
        self.window = self.xml.get_widget('vcard_information_window')
        self.progressbar = self.xml.get_widget('progressbar')

        self.contact = contact
        self.account = account
        self.gc_contact = gc_contact

        # Get real jid
        if gc_contact:
            # Don't use real jid if room is (semi-)anonymous
            gc_control = gajim.interface.msg_win_mgr.get_gc_control(
                gc_contact.room_jid, account)
            if gc_contact.jid and not gc_control.is_anonymous:
                self.real_jid = gc_contact.jid
                if gc_contact.resource:
                    self.real_jid += '/' + gc_contact.resource
            else:
                self.real_jid = gc_contact.get_full_jid()
        else:
            self.real_jid = contact.get_full_jid()

        puny_jid = helpers.sanitize_filename(contact.jid)
        local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid) + \
         '_local'
        for extension in ('.png', '.jpeg'):
            local_avatar_path = local_avatar_basepath + extension
            if os.path.isfile(local_avatar_path):
                image = self.xml.get_widget('custom_avatar_image')
                image.set_from_file(local_avatar_path)
                image.show()
                self.xml.get_widget('custom_avatar_label').show()
                break
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.vcard_arrived = False
        self.os_info_arrived = False
        self.update_progressbar_timeout_id = gobject.timeout_add(
            100, self.update_progressbar)

        self.fill_jabber_page()
        annotations = gajim.connections[self.account].annotations
        if self.contact.jid in annotations:
            buffer = self.xml.get_widget('textview_annotation').get_buffer()
            buffer.set_text(annotations[self.contact.jid])

        self.xml.signal_autoconnect(self)
        self.window.show_all()
        self.xml.get_widget('close_button').grab_focus()
Example #8
0
	def on_listview_button_press_event(self, widget, event):
		if event.button == 3: # right click
			xml = gtkgui_helpers.get_glade('history_manager.glade', 'context_menu')
			if widget.name != 'jids_listview':
				xml.get_widget('export_menuitem').hide()
			xml.get_widget('delete_menuitem').connect('activate',
				self.on_delete_menuitem_activate, widget)
			
			liststore, list_of_paths = self.jids_listview.get_selection()\
				.get_selected_rows()
			
			xml.signal_autoconnect(self)
			xml.get_widget('context_menu').popup(None, None, None,
				event.button, event.time)
			return True
Example #9
0
    def new_tab(self, control):
        fjid = control.get_full_jid()

        if control.account not in self._controls:
            self._controls[control.account] = {}

        self._controls[control.account][fjid] = control

        if self.get_num_controls() == 2:
            # is first conversation_textview scrolled down ?
            scrolled = False
            first_widget = self.notebook.get_nth_page(0)
            ctrl = self._widget_to_control(first_widget)
            conv_textview = ctrl.conv_textview
            if conv_textview.at_the_end():
                scrolled = True
            self.notebook.set_show_tabs(True)
            if scrolled:
                gobject.idle_add(conv_textview.scroll_to_end_iter)
            self.alignment.set_property('top-padding', 2)

        # Add notebook page and connect up to the tab's close button
        xml = gtkgui_helpers.get_glade('message_window.glade', 'chat_tab_ebox')
        tab_label_box = xml.get_widget('chat_tab_ebox')
        widget = xml.get_widget('tab_close_button')
        id = widget.connect('clicked', self._on_close_button_clicked, control)
        control.handlers[id] = widget

        id = tab_label_box.connect('button-press-event',
                                   self.on_tab_eventbox_button_press_event,
                                   control.widget)
        control.handlers[id] = tab_label_box
        self.notebook.append_page(control.widget, tab_label_box)

        # If GTK+ version >= 2.10, use gtk native way to reorder tabs
        if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0):
            self.notebook.set_tab_reorderable(control.widget, True)
        else:
            self.setup_tab_dnd(control.widget)

        self.redraw_tab(control)
        if self.parent_paned:
            self.notebook.show_all()
        else:
            self.window.show_all()
        # NOTE: we do not call set_control_active(True) since we don't know whether
        # the tab is the active one.
        self.show_title()
Example #10
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_glade('gajim_themes_window.glade')
        self.window = self.xml.get_widget('gajim_themes_window')
        self.window.set_transient_for(gajim.interface.roster.window)

        self.options = ['account', 'group', 'contact', 'banner']
        self.options_combobox = self.xml.get_widget('options_combobox')
        self.textcolor_checkbutton = self.xml.get_widget(
            'textcolor_checkbutton')
        self.background_checkbutton = self.xml.get_widget(
            'background_checkbutton')
        self.textfont_checkbutton = self.xml.get_widget('textfont_checkbutton')
        self.text_colorbutton = self.xml.get_widget('text_colorbutton')
        self.background_colorbutton = self.xml.get_widget(
            'background_colorbutton')
        self.text_fontbutton = self.xml.get_widget('text_fontbutton')
        self.bold_togglebutton = self.xml.get_widget('bold_togglebutton')
        self.italic_togglebutton = self.xml.get_widget('italic_togglebutton')
        self.themes_tree = self.xml.get_widget('themes_treeview')
        self.theme_options_vbox = self.xml.get_widget('theme_options_vbox')
        self.theme_options_table = self.xml.get_widget('theme_options_table')
        self.colorbuttons = {}
        for chatstate in ('inactive', 'composing', 'paused', 'gone', 'muc_msg',
                          'muc_directed_msg'):
            self.colorbuttons[chatstate] = self.xml.get_widget(chatstate + \
             '_colorbutton')
        model = gtk.ListStore(str)
        self.themes_tree.set_model(model)
        col = gtk.TreeViewColumn(_('Theme'))
        self.themes_tree.append_column(col)
        renderer = gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.set_attributes(renderer, text=0)
        renderer.connect('edited', self.on_theme_cell_edited)
        renderer.set_property('editable', True)
        self.current_theme = gajim.config.get('roster_theme')
        self.no_update = False
        self.fill_themes_treeview()
        self.select_active_theme()
        self.current_option = self.options[0]
        self.set_theme_options(self.current_theme, self.current_option)

        self.xml.signal_autoconnect(self)
        self.window.connect('delete-event',
                            self.on_themese_window_delete_event)
        self.themes_tree.get_selection().connect('changed',
                                                 self.selection_changed)
        self.window.show_all()
Example #11
0
	def __init__(self, account, servicejid, groupid):
		'''Open new 'create post' window to create message for groupid on servicejid service.'''
		assert isinstance(servicejid, basestring)
		assert isinstance(groupid, basestring)

		self.account = account
		self.servicejid = servicejid
		self.groupid = groupid

		self.xml = gtkgui_helpers.get_glade('groups_post_window.glade')
		self.window = self.xml.get_widget('groups_post_window')
		for name in ('from_entry', 'subject_entry', 'contents_textview'):
			self.__dict__[name] = self.xml.get_widget(name)

		self.xml.signal_autoconnect(self)
		self.window.show_all()
Example #12
0
    def on_listview_button_press_event(self, widget, event):
        if event.button == 3:  # right click
            xml = gtkgui_helpers.get_glade('history_manager.glade',
                                           'context_menu')
            if widget.name != 'jids_listview':
                xml.get_widget('export_menuitem').hide()
            xml.get_widget('delete_menuitem').connect(
                'activate', self.on_delete_menuitem_activate, widget)

            liststore, list_of_paths = self.jids_listview.get_selection()\
             .get_selected_rows()

            xml.signal_autoconnect(self)
            xml.get_widget('context_menu').popup(None, None, None,
                                                 event.button, event.time)
            return True
Example #13
0
	def __init__(self):
		self.single_message_handler_id = None
		self.new_chat_handler_id = None
		self.t = None
		# click somewhere else does not popdown menu. workaround this.
		self.added_hide_menuitem = False 
		self.img_tray = gtk.Image()
		self.status = 'offline'
		self.double_click = False
		self.double_click_id = None
		self.double_click_time = gtk.settings_get_default().get_property(
			'gtk-double-click-time')
		self.xml = gtkgui_helpers.get_glade('systray_context_menu.glade')
		self.systray_context_menu = self.xml.get_widget('systray_context_menu')
		self.xml.signal_autoconnect(self)
		self.popup_menus = []
Example #14
0
 def __init__(self):
     self.single_message_handler_id = None
     self.new_chat_handler_id = None
     self.t = None
     # click somewhere else does not popdown menu. workaround this.
     self.added_hide_menuitem = False
     self.img_tray = gtk.Image()
     self.status = 'offline'
     self.double_click = False
     self.double_click_id = None
     self.double_click_time = gtk.settings_get_default().get_property(
         'gtk-double-click-time')
     self.xml = gtkgui_helpers.get_glade('systray_context_menu.glade')
     self.systray_context_menu = self.xml.get_widget('systray_context_menu')
     self.xml.signal_autoconnect(self)
     self.popup_menus = []
Example #15
0
    def __init__(self, account, servicejid, groupid):
        '''Open new 'create post' window to create message for groupid on servicejid service.'''
        assert isinstance(servicejid, basestring)
        assert isinstance(groupid, basestring)

        self.account = account
        self.servicejid = servicejid
        self.groupid = groupid

        self.xml = gtkgui_helpers.get_glade('groups_post_window.glade')
        self.window = self.xml.get_widget('groups_post_window')
        for name in ('from_entry', 'subject_entry', 'contents_textview'):
            self.__dict__[name] = self.xml.get_widget(name)

        self.xml.signal_autoconnect(self)
        self.window.show_all()
Example #16
0
	def new_tab(self, control):
		fjid = control.get_full_jid()

		if control.account not in self._controls:
			self._controls[control.account] = {}

		self._controls[control.account][fjid] = control

		if self.get_num_controls() == 2:
			# is first conversation_textview scrolled down ?
			scrolled = False
			first_widget = self.notebook.get_nth_page(0)
			ctrl = self._widget_to_control(first_widget)
			conv_textview = ctrl.conv_textview
			if conv_textview.at_the_end():
				scrolled = True
			self.notebook.set_show_tabs(True)
			if scrolled:
				gobject.idle_add(conv_textview.scroll_to_end_iter)
			self.alignment.set_property('top-padding', 2)

		# Add notebook page and connect up to the tab's close button
		xml = gtkgui_helpers.get_glade('message_window.glade', 'chat_tab_ebox')
		tab_label_box = xml.get_widget('chat_tab_ebox')
		widget = xml.get_widget('tab_close_button')
		id = widget.connect('clicked', self._on_close_button_clicked, control)
		control.handlers[id] = widget

		id = tab_label_box.connect('button-press-event', self.on_tab_eventbox_button_press_event,
					control.widget)
		control.handlers[id] = tab_label_box
		self.notebook.append_page(control.widget, tab_label_box)

		# If GTK+ version >= 2.10, use gtk native way to reorder tabs
		if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0):
			self.notebook.set_tab_reorderable(control.widget, True)
		else:
			self.setup_tab_dnd(control.widget)

		self.redraw_tab(control)
		if self.parent_paned:
			self.notebook.show_all()
		else:
			self.window.show_all()
		# NOTE: we do not call set_control_active(True) since we don't know whether
		# the tab is the active one.
		self.show_title()
Example #17
0
	def __init__(self, account, jid, session, form):
		self.account = account
		self.jid = jid
		self.form = form
		self.session = session

		self.xml = gtkgui_helpers.get_glade('data_form_window.glade', 'data_form_window')
		self.window = self.xml.get_widget('data_form_window')

		config_vbox = self.xml.get_widget('config_vbox')
		dataform = dataforms.ExtendForm(node = self.form)
		self.data_form_widget = dataforms_widget.DataFormWidget(dataform)
		self.data_form_widget.show()
		config_vbox.pack_start(self.data_form_widget)

		self.xml.signal_autoconnect(self)
		self.window.show_all()
Example #18
0
	def on_export_menuitem_activate(self, widget):
		xml = gtkgui_helpers.get_glade('history_manager.glade', 'filechooserdialog')
		xml.signal_autoconnect(self)
		
		dlg = xml.get_widget('filechooserdialog')
		dlg.set_title(_('Exporting History Logs...'))
		dlg.set_current_folder(gajim.HOME_DIR)
		dlg.props.do_overwrite_confirmation = True
		response = dlg.run()
		
		if response == gtk.RESPONSE_OK: # user want us to export ;)
			liststore, list_of_paths = self.jids_listview.get_selection()\
				.get_selected_rows()
			path_to_file = dlg.get_filename()
			self._export_jids_logs_to_file(liststore, list_of_paths, path_to_file)
		
		dlg.destroy()	
Example #19
0
	def __init__(self, contact, account, is_fake = False):
		# the contact variable is the jid if vcard is true
		self.xml = gtkgui_helpers.get_glade('zeroconf_information_window.glade')
		self.window = self.xml.get_widget('zeroconf_information_window')

		self.contact = contact
		self.account = account
		self.is_fake = is_fake

	#	self.avatar_mime_type = None
	#	self.avatar_encoded = None

		self.fill_contact_page()
		self.fill_personal_page()

		self.xml.signal_autoconnect(self)
		self.window.show_all()
Example #20
0
    def __init__(self, contact, account, is_fake=False):
        # the contact variable is the jid if vcard is true
        self.xml = gtkgui_helpers.get_glade(
            'zeroconf_information_window.glade')
        self.window = self.xml.get_widget('zeroconf_information_window')

        self.contact = contact
        self.account = account
        self.is_fake = is_fake

        #	self.avatar_mime_type = None
        #	self.avatar_encoded = None

        self.fill_contact_page()
        self.fill_personal_page()

        self.xml.signal_autoconnect(self)
        self.window.show_all()
Example #21
0
    def __init__(self, type_id, parent_win, widget_name, contact, account, resource=None):
        # dict { cb id : widget}
        # keep all registered callbacks of widgets, created by self.xml
        self.handlers = {}
        self.type_id = type_id
        self.parent_win = parent_win
        self.widget_name = widget_name
        self.contact = contact
        self.account = account
        self.hide_chat_buttons = False
        self.resource = resource

        self.session = None

        gajim.last_message_time[self.account][self.get_full_jid()] = 0

        self.xml = gtkgui_helpers.get_glade("message_window.glade", widget_name)
        self.widget = self.xml.get_widget(widget_name)
Example #22
0
	def __init__(self):
		self.xml = gtkgui_helpers.get_glade('gajim_themes_window.glade')
		self.window = self.xml.get_widget('gajim_themes_window')
		self.window.set_transient_for(gajim.interface.roster.window)
		
		self.options = ['account', 'group', 'contact', 'banner']
		self.options_combobox = self.xml.get_widget('options_combobox')
		self.textcolor_checkbutton = self.xml.get_widget('textcolor_checkbutton')
		self.background_checkbutton = self.xml.get_widget('background_checkbutton')
		self.textfont_checkbutton = self.xml.get_widget('textfont_checkbutton')
		self.text_colorbutton = self.xml.get_widget('text_colorbutton')
		self.background_colorbutton = self.xml.get_widget('background_colorbutton')
		self.text_fontbutton = self.xml.get_widget('text_fontbutton')
		self.bold_togglebutton = self.xml.get_widget('bold_togglebutton')
		self.italic_togglebutton = self.xml.get_widget('italic_togglebutton')
		self.themes_tree = self.xml.get_widget('themes_treeview')
		self.theme_options_vbox = self.xml.get_widget('theme_options_vbox')
		self.theme_options_table = self.xml.get_widget('theme_options_table')
		self.colorbuttons = {}
		for chatstate in ('inactive', 'composing', 'paused', 'gone',
		'muc_msg', 'muc_directed_msg'):
			self.colorbuttons[chatstate] = self.xml.get_widget(chatstate + \
				'_colorbutton')
		model = gtk.ListStore(str)
		self.themes_tree.set_model(model)
		col = gtk.TreeViewColumn(_('Theme'))
		self.themes_tree.append_column(col)
		renderer = gtk.CellRendererText()
		col.pack_start(renderer, True)
		col.set_attributes(renderer, text = 0)
		renderer.connect('edited', self.on_theme_cell_edited)
		renderer.set_property('editable', True)
		self.current_theme = gajim.config.get('roster_theme')
		self.no_update = False
		self.fill_themes_treeview()
		self.select_active_theme()
		self.current_option = self.options[0]
		self.set_theme_options(self.current_theme, self.current_option)
		
		self.xml.signal_autoconnect(self)
		self.window.connect('delete-event', self.on_themese_window_delete_event)
		self.themes_tree.get_selection().connect('changed', 
				self.selection_changed)
		self.window.show_all()
Example #23
0
    def on_export_menuitem_activate(self, widget):
        xml = gtkgui_helpers.get_glade('history_manager.glade',
                                       'filechooserdialog')
        xml.signal_autoconnect(self)

        dlg = xml.get_widget('filechooserdialog')
        dlg.set_title(_('Exporting History Logs...'))
        dlg.set_current_folder(gajim.HOME_DIR)
        dlg.props.do_overwrite_confirmation = True
        response = dlg.run()

        if response == gtk.RESPONSE_OK:  # user want us to export ;)
            liststore, list_of_paths = self.jids_listview.get_selection()\
             .get_selected_rows()
            path_to_file = dlg.get_filename()
            self._export_jids_logs_to_file(liststore, list_of_paths,
                                           path_to_file)

        dlg.destroy()
Example #24
0
    def __init__(self):
        path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')
        pix = gtk.gdk.pixbuf_new_from_file(path_to_file)
        gtk.window_set_default_icon(
            pix)  # set the icon to all newly opened windows

        if not os.path.exists(LOG_DB_PATH):
            dialogs.ErrorDialog(_('Cannot find history logs database'),
                                '%s does not exist.' % LOG_DB_PATH)
            sys.exit()

        xml = gtkgui_helpers.get_glade('history_manager.glade')
        self.window = xml.get_widget('history_manager_window')
        self.jids_listview = xml.get_widget('jids_listview')
        self.logs_listview = xml.get_widget('logs_listview')
        self.search_results_listview = xml.get_widget(
            'search_results_listview')
        self.search_entry = xml.get_widget('search_entry')
        self.logs_scrolledwindow = xml.get_widget('logs_scrolledwindow')
        self.search_results_scrolledwindow = xml.get_widget(
            'search_results_scrolledwindow')
        self.welcome_vbox = xml.get_widget('welcome_vbox')

        self.jids_already_in = []  # holds jids that we already have in DB
        self.AT_LEAST_ONE_DELETION_DONE = False

        self.con = sqlite.connect(LOG_DB_PATH,
                                  timeout=20.0,
                                  isolation_level='IMMEDIATE')
        self.cur = self.con.cursor()

        self._init_jids_listview()
        self._init_logs_listview()
        self._init_search_results_listview()

        self._fill_jids_listview()

        self.search_entry.grab_focus()

        self.window.show_all()

        xml.signal_autoconnect(self)
Example #25
0
	def __init__(self):
		''' Create new window... only if we have anything to show. '''
		assert len(self.__class__.entries)>0

		self.entry = None	# the entry actually displayed

		self.xml = gtkgui_helpers.get_glade('atom_entry_window.glade')
		self.window = self.xml.get_widget('atom_entry_window')
		for name in ('new_entry_label', 'feed_title_label', 'feed_title_eventbox',
			'feed_tagline_label', 'entry_title_label', 'entry_title_eventbox',
			'last_modified_label', 'close_button', 'next_button'):
			self.__dict__[name] = self.xml.get_widget(name)

		self.displayNextEntry()

		self.xml.signal_autoconnect(self)
		self.window.show_all()

		self.entry_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
		self.feed_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
Example #26
0
    def __init__(self, account, jid):
        '''Create new window.'''

        # an account object
        self.account = gajim.connections[account]
        self.jid = jid

        self.pulse_id = None  # to satisfy self.setup_pulsing()
        self.commandlist = None  # a list of (commandname, commanddescription)

        # command's data
        self.commandnode = None
        self.sessionid = None
        self.dataform = None
        self.allow_stage3_close = False

        # retrieving widgets from xml
        self.xml = gtkgui_helpers.get_glade('adhoc_commands_window.glade')
        self.window = self.xml.get_widget('adhoc_commands_window')
        self.window.connect('delete-event',
                            self.on_adhoc_commands_window_delete_event)
        for name in ('back_button', 'forward_button', 'execute_button',
                     'close_button', 'stages_notebook',
                     'retrieving_commands_stage_vbox',
                     'command_list_stage_vbox', 'command_list_vbox',
                     'sending_form_stage_vbox', 'sending_form_progressbar',
                     'notes_label', 'no_commands_stage_vbox',
                     'error_stage_vbox', 'error_description_label'):
            self.__dict__[name] = self.xml.get_widget(name)

        # creating data forms widget
        self.data_form_widget = dataforms_widget.DataFormWidget()
        self.data_form_widget.show()
        self.sending_form_stage_vbox.pack_start(self.data_form_widget)

        # setting initial stage
        self.stage1()

        # displaying the window
        self.xml.signal_autoconnect(self)
        self.window.show_all()
Example #27
0
    def __init__(self):
        ''' Create new window... only if we have anything to show. '''
        assert len(self.__class__.entries) > 0

        self.entry = None  # the entry actually displayed

        self.xml = gtkgui_helpers.get_glade('atom_entry_window.glade')
        self.window = self.xml.get_widget('atom_entry_window')
        for name in ('new_entry_label', 'feed_title_label',
                     'feed_title_eventbox', 'feed_tagline_label',
                     'entry_title_label', 'entry_title_eventbox',
                     'last_modified_label', 'close_button', 'next_button'):
            self.__dict__[name] = self.xml.get_widget(name)

        self.displayNextEntry()

        self.xml.signal_autoconnect(self)
        self.window.show_all()

        self.entry_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.feed_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
Example #28
0
	def __init__(self, account, jid):
		'''Create new window.'''

		# an account object
		self.account = gajim.connections[account]
		self.jid = jid

		self.pulse_id=None	# to satisfy self.setup_pulsing()
		self.commandlist=None	# a list of (commandname, commanddescription)

		# command's data
		self.commandnode = None
		self.sessionid = None
		self.dataform = None
		self.allow_stage3_close = False

		# retrieving widgets from xml
		self.xml = gtkgui_helpers.get_glade('adhoc_commands_window.glade')
		self.window = self.xml.get_widget('adhoc_commands_window')
		self.window.connect('delete-event', self.on_adhoc_commands_window_delete_event)
		for name in ('back_button', 'forward_button',
			'execute_button','close_button','stages_notebook',
			'retrieving_commands_stage_vbox',
			'command_list_stage_vbox','command_list_vbox',
			'sending_form_stage_vbox','sending_form_progressbar',
			'notes_label','no_commands_stage_vbox','error_stage_vbox',
			'error_description_label'):
			self.__dict__[name] = self.xml.get_widget(name)

		# creating data forms widget
		self.data_form_widget = dataforms_widget.DataFormWidget()
		self.data_form_widget.show()
		self.sending_form_stage_vbox.pack_start(self.data_form_widget)

		# setting initial stage
		self.stage1()

		# displaying the window
		self.xml.signal_autoconnect(self)
		self.window.show_all()
Example #29
0
    def __init__(self, account):
        self.xml = gtkgui_helpers.get_glade("profile_window.glade")
        self.window = self.xml.get_widget("profile_window")
        self.progressbar = self.xml.get_widget("progressbar")
        self.statusbar = self.xml.get_widget("statusbar")
        self.context_id = self.statusbar.get_context_id("profile")

        self.account = account
        self.jid = gajim.get_jid_from_account(account)

        self.dialog = None
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.message_id = self.statusbar.push(self.context_id, _("Retrieving profile..."))
        self.update_progressbar_timeout_id = gobject.timeout_add(100, self.update_progressbar)
        self.remove_statusbar_timeout_id = None

        # Create Image for avatar button
        image = gtk.Image()
        self.xml.get_widget("PHOTO_button").set_image(image)
        self.xml.signal_autoconnect(self)
        self.window.show_all()
Example #30
0
	def __init__(self):
		path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')
		pix = gtk.gdk.pixbuf_new_from_file(path_to_file)
		gtk.window_set_default_icon(pix) # set the icon to all newly opened windows
		
		if not os.path.exists(LOG_DB_PATH):
			dialogs.ErrorDialog(_('Cannot find history logs database'),
				'%s does not exist.' % LOG_DB_PATH)
			sys.exit()
		
		xml = gtkgui_helpers.get_glade('history_manager.glade')
		self.window = xml.get_widget('history_manager_window')
		self.jids_listview = xml.get_widget('jids_listview')
		self.logs_listview = xml.get_widget('logs_listview')
		self.search_results_listview = xml.get_widget('search_results_listview')
		self.search_entry = xml.get_widget('search_entry')
		self.logs_scrolledwindow = xml.get_widget('logs_scrolledwindow')
		self.search_results_scrolledwindow = xml.get_widget(
			'search_results_scrolledwindow')
		self.welcome_vbox = xml.get_widget('welcome_vbox')

		self.jids_already_in = [] # holds jids that we already have in DB
		self.AT_LEAST_ONE_DELETION_DONE = False
		
		self.con = sqlite.connect(LOG_DB_PATH, timeout = 20.0,
			isolation_level = 'IMMEDIATE')
		self.cur = self.con.cursor()

		self._init_jids_listview()
		self._init_logs_listview()
		self._init_search_results_listview()
		
		self._fill_jids_listview()
		
		self.search_entry.grab_focus()

		self.window.show_all()
		
		xml.signal_autoconnect(self)
Example #31
0
    def __init__(self, account, jid):
        '''Create new window.'''

        # an account object
        self.account = account
        self.jid = jid

        # retrieving widgets from xml
        self.xml = gtkgui_helpers.get_glade('search_window.glade')
        self.window = self.xml.get_widget('search_window')
        for name in ('label', 'progressbar', 'search_vbox', 'search_button',
                     'add_contact_button', 'information_button'):
            self.__dict__[name] = self.xml.get_widget(name)

        # displaying the window
        self.xml.signal_autoconnect(self)
        self.window.show_all()
        self.request_form()
        self.pulse_id = gobject.timeout_add(80, self.pulse_callback)

        self.is_form = None

        # Is there a jid column in results ? if -1: no, else column number
        self.jid_column = -1
Example #32
0
	def __init__(self, dataformnode=None):
		''' Create a widget. '''
		gtk.Alignment.__init__(self, xscale=1.0, yscale=1.0)

		self._data_form = None

		self.xml = gtkgui_helpers.get_glade('data_form_window.glade',
			'data_form_vbox')
		self.xml.signal_autoconnect(self)
		for name in ('instructions_label', 'instructions_hseparator',
				'single_form_viewport', 'data_form_types_notebook',
				'single_form_scrolledwindow', 'multiple_form_hbox',
				'records_treeview', 'buttons_vbox', 'add_button', 'remove_button',
				'edit_button', 'up_button', 'down_button', 'clear_button'):
			self.__dict__[name] = self.xml.get_widget(name)

		self.add(self.xml.get_widget('data_form_vbox'))

		if dataformnode is not None:
			self.set_data_form(dataformnode)

		selection = self.records_treeview.get_selection()
		selection.connect('changed', self.on_records_selection_changed)
		selection.set_mode(gtk.SELECTION_MULTIPLE)
Example #33
0
    def __init__(self, account):
        self.xml = gtkgui_helpers.get_glade('profile_window.glade')
        self.window = self.xml.get_widget('profile_window')
        self.progressbar = self.xml.get_widget('progressbar')
        self.statusbar = self.xml.get_widget('statusbar')
        self.context_id = self.statusbar.get_context_id('profile')

        self.account = account
        self.jid = gajim.get_jid_from_account(account)

        self.dialog = None
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.message_id = self.statusbar.push(self.context_id,
                                              _('Retrieving profile...'))
        self.update_progressbar_timeout_id = gobject.timeout_add(
            100, self.update_progressbar)
        self.remove_statusbar_timeout_id = None

        # Create Image for avatar button
        image = gtk.Image()
        self.xml.get_widget('PHOTO_button').set_image(image)
        self.xml.signal_autoconnect(self)
        self.window.show_all()
Example #34
0
	def __init__(self, account, jid):
		'''Create new window.'''

		# an account object
		self.account = account
		self.jid = jid

		# retrieving widgets from xml
		self.xml = gtkgui_helpers.get_glade('search_window.glade')
		self.window = self.xml.get_widget('search_window')
		for name in ('label', 'progressbar', 'search_vbox', 'search_button',
		'add_contact_button', 'information_button'):
			self.__dict__[name] = self.xml.get_widget(name)

		# displaying the window
		self.xml.signal_autoconnect(self)
		self.window.show_all()
		self.request_form()
		self.pulse_id = gobject.timeout_add(80, self.pulse_callback)

		self.is_form = None

		# Is there a jid column in results ? if -1: no, else column number
		self.jid_column = -1
Example #35
0
    def __init__(self, acct, type_, parent_window=None, parent_paned=None):
        # A dictionary of dictionaries
        # where _contacts[account][jid] == A MessageControl
        self._controls = {}

        # If None, the window is not tied to any specific account
        self.account = acct
        # If None, the window is not tied to any specific type
        self.type_ = type_
        # dict { handler id: widget}. Keeps callbacks, which
        # lead to cylcular references
        self.handlers = {}
        # Don't show warning dialogs when we want to delete the window
        self.dont_warn_on_delete = False

        self.widget_name = 'message_window'
        self.xml = gtkgui_helpers.get_glade('%s.glade' % self.widget_name)
        self.window = self.xml.get_widget(self.widget_name)
        self.notebook = self.xml.get_widget('notebook')
        self.parent_paned = None

        if parent_window:
            orig_window = self.window
            self.window = parent_window
            self.parent_paned = parent_paned
            self.notebook.reparent(self.parent_paned)
            self.parent_paned.pack2(self.notebook, resize=True, shrink=True)
            orig_window.destroy()
            del orig_window

        # NOTE: we use 'connect_after' here because in
        # MessageWindowMgr._new_window we register handler that saves window
        # state when closing it, and it should be called before
        # MessageWindow._on_window_delete, which manually destroys window
        # through win.destroy() - this means no additional handlers for
        # 'delete-event' are called.
        id = self.window.connect_after('delete-event', self._on_window_delete)
        self.handlers[id] = self.window
        id = self.window.connect('destroy', self._on_window_destroy)
        self.handlers[id] = self.window
        id = self.window.connect('focus-in-event', self._on_window_focus)
        self.handlers[id] = self.window

        keys=['<Control>f', '<Control>g', '<Control>h', '<Control>i',
         '<Control>l', '<Control>L', '<Control>n', '<Control>t', '<Control>u',
         '<Control>v', '<Control>b', '<Control><Shift>Tab', '<Control>Tab',
         '<Control>F4', '<Control>w', '<Control>Page_Up', '<Control>Page_Down',
         '<Alt>Right', '<Alt>Left', '<Alt>a', '<Alt>c', '<Alt>m', 'Escape'] + \
         ['<Alt>'+str(i) for i in xrange(10)]
        accel_group = gtk.AccelGroup()
        for key in keys:
            keyval, mod = gtk.accelerator_parse(key)
            accel_group.connect_group(keyval, mod, gtk.ACCEL_VISIBLE,
                                      self.accel_group_func)
        self.window.add_accel_group(accel_group)

        # gtk+ doesn't make use of the motion notify on gtkwindow by default
        # so this line adds that
        self.window.add_events(gtk.gdk.POINTER_MOTION_MASK)
        self.alignment = self.xml.get_widget('alignment')

        id = self.notebook.connect('switch-page',
                                   self._on_notebook_switch_page)
        self.handlers[id] = self.notebook
        id = self.notebook.connect('key-press-event',
                                   self._on_notebook_key_press)
        self.handlers[id] = self.notebook

        # Remove the glade pages
        while self.notebook.get_n_pages():
            self.notebook.remove_page(0)
        # Tab customizations
        pref_pos = gajim.config.get('tabs_position')
        if pref_pos == 'bottom':
            nb_pos = gtk.POS_BOTTOM
        elif pref_pos == 'left':
            nb_pos = gtk.POS_LEFT
        elif pref_pos == 'right':
            nb_pos = gtk.POS_RIGHT
        else:
            nb_pos = gtk.POS_TOP
        self.notebook.set_tab_pos(nb_pos)
        window_mode = gajim.interface.msg_win_mgr.mode
        if gajim.config.get('tabs_always_visible') or \
        window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER:
            self.notebook.set_show_tabs(True)
            self.alignment.set_property('top-padding', 2)
        else:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(gajim.config.get('tabs_border'))

        # if GTK+ version < 2.10, use OUR way to reorder tabs (set up DnD)
        if gtk.pygtk_version < (2, 10, 0) or gtk.gtk_version < (2, 10, 0):
            self.hid = self.notebook.connect(
                'drag_data_received', self.on_tab_label_drag_data_received_cb)
            self.handlers[self.hid] = self.notebook
            self.notebook.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.DND_TARGETS,
                                        gtk.gdk.ACTION_MOVE)
Example #36
0
	def __init__(self, acct, type_, parent_window=None, parent_paned=None):
		# A dictionary of dictionaries
		# where _contacts[account][jid] == A MessageControl
		self._controls = {}

		# If None, the window is not tied to any specific account
		self.account = acct
		# If None, the window is not tied to any specific type
		self.type_ = type_
		# dict { handler id: widget}. Keeps callbacks, which
		# lead to cylcular references
		self.handlers = {}
		# Don't show warning dialogs when we want to delete the window
		self.dont_warn_on_delete = False

		self.widget_name = 'message_window'
		self.xml = gtkgui_helpers.get_glade('%s.glade' % self.widget_name)
		self.window = self.xml.get_widget(self.widget_name)
		self.notebook = self.xml.get_widget('notebook')
		self.parent_paned = None

		if parent_window:
			orig_window = self.window
			self.window = parent_window
			self.parent_paned = parent_paned
			self.notebook.reparent(self.parent_paned)
			self.parent_paned.pack2(self.notebook, resize=True, shrink=True)
			orig_window.destroy()
			del orig_window

		# NOTE: we use 'connect_after' here because in 
		# MessageWindowMgr._new_window we register handler that saves window
		# state when closing it, and it should be called before
		# MessageWindow._on_window_delete, which manually destroys window
		# through win.destroy() - this means no additional handlers for
		# 'delete-event' are called.
		id = self.window.connect_after('delete-event', self._on_window_delete)
		self.handlers[id] = self.window
		id = self.window.connect('destroy', self._on_window_destroy)
		self.handlers[id] = self.window
		id = self.window.connect('focus-in-event', self._on_window_focus)
		self.handlers[id] = self.window

		keys=['<Control>f', '<Control>g', '<Control>h', '<Control>i',
			'<Control>l', '<Control>L', '<Control>n', '<Control>t', '<Control>u',
			'<Control>v', '<Control>b', '<Control><Shift>Tab', '<Control>Tab',
			'<Control>F4', '<Control>w', '<Control>Page_Up', '<Control>Page_Down',
			'<Alt>Right', '<Alt>Left', '<Alt>a', '<Alt>c', '<Alt>m', 'Escape'] + \
			['<Alt>'+str(i) for i in xrange(10)]
		accel_group = gtk.AccelGroup()
		for key in keys:
			keyval, mod = gtk.accelerator_parse(key)
			accel_group.connect_group(keyval, mod, gtk.ACCEL_VISIBLE,
				self.accel_group_func)
		self.window.add_accel_group(accel_group)

		# gtk+ doesn't make use of the motion notify on gtkwindow by default
		# so this line adds that
		self.window.add_events(gtk.gdk.POINTER_MOTION_MASK)
		self.alignment = self.xml.get_widget('alignment')

		id = self.notebook.connect('switch-page',
			self._on_notebook_switch_page)
		self.handlers[id] = self.notebook
		id = self.notebook.connect('key-press-event',
			self._on_notebook_key_press)
		self.handlers[id] = self.notebook

		# Remove the glade pages
		while self.notebook.get_n_pages():
			self.notebook.remove_page(0)
		# Tab customizations
		pref_pos = gajim.config.get('tabs_position')
		if pref_pos == 'bottom':
			nb_pos = gtk.POS_BOTTOM
		elif pref_pos == 'left':
			nb_pos = gtk.POS_LEFT
		elif pref_pos == 'right':
			nb_pos = gtk.POS_RIGHT
		else:
			nb_pos = gtk.POS_TOP
		self.notebook.set_tab_pos(nb_pos)
		window_mode = gajim.interface.msg_win_mgr.mode
		if gajim.config.get('tabs_always_visible') or \
		window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER:
			self.notebook.set_show_tabs(True)
			self.alignment.set_property('top-padding', 2)
		else:
			self.notebook.set_show_tabs(False)
		self.notebook.set_show_border(gajim.config.get('tabs_border'))

		# if GTK+ version < 2.10, use OUR way to reorder tabs (set up DnD)
		if gtk.pygtk_version < (2, 10, 0) or gtk.gtk_version < (2, 10, 0):
			self.hid = self.notebook.connect('drag_data_received',
				self.on_tab_label_drag_data_received_cb)
			self.handlers[self.hid] = self.notebook
			self.notebook.drag_dest_set(gtk.DEST_DEFAULT_ALL, self.DND_TARGETS,
				gtk.gdk.ACTION_MOVE)
Example #37
0
    def __init__(self, dataform):
        assert isinstance(dataform, dataforms.SimpleDataForm)

        gtk.Table.__init__(self)
        self.set_col_spacings(12)
        self.set_row_spacings(6)

        self.tooltips = gtk.Tooltips()

        def decorate_with_tooltip(widget, field):
            ''' Adds a tooltip containing field's description to a widget.
			Creates EventBox if widget doesn't have its own gdk window.
			Returns decorated widget. '''
            if field.description != '':
                if widget.flags() & gtk.NO_WINDOW:
                    evbox = gtk.EventBox()
                    evbox.add(widget)
                    widget = evbox
                self.tooltips.set_tip(widget, field.description)
            return widget

        self._data_form = dataform

        # building widget
        linecounter = 0

        # is the form changeable?
        readwrite = dataform.type != 'result'

        # for each field...
        for field in self._data_form.iter_fields():
            if field.type == 'hidden': continue

            commonlabel = True
            commonlabelcenter = False
            commonwidget = True
            widget = None

            if field.type == 'boolean':
                commonlabelcenter = True
                widget = gtk.CheckButton()
                widget.connect('toggled', self.on_boolean_checkbutton_toggled,
                               field)
                widget.set_active(field.value)

            elif field.type == 'fixed':
                leftattach = 1
                rightattach = 2
                if field.label is None:
                    commonlabel = False
                    leftattach = 0

                commonwidget = False
                widget = gtk.Label(field.value)
                widget.set_line_wrap(True)
                self.attach(widget,
                            leftattach,
                            rightattach,
                            linecounter,
                            linecounter + 1,
                            xoptions=gtk.FILL,
                            yoptions=gtk.FILL)

            elif field.type == 'list-single':
                # TODO: What if we have radio buttons and non-required field?
                # TODO: We cannot deactivate them all...
                if len(field.options) < 6:
                    # 5 option max: show radiobutton
                    widget = gtk.VBox()
                    first_radio = None
                    for value, label in field.iter_options():
                        if not label:
                            label = value
                        radio = gtk.RadioButton(first_radio, label=label)
                        radio.connect('toggled',
                                      self.on_list_single_radiobutton_toggled,
                                      field, value)
                        if first_radio is None:
                            first_radio = radio
                            if field.value == '':  # TODO: is None when done
                                field.value = value
                        if value == field.value:
                            radio.set_active(True)
                        widget.pack_start(radio, expand=False)
                else:
                    # more than 5 options: show combobox
                    def on_list_single_combobox_changed(combobox, f):
                        iter = combobox.get_active_iter()
                        if iter:
                            model = combobox.get_model()
                            f.value = model[iter][1]
                        else:
                            f.value = ''

                    widget = gtkgui_helpers.create_combobox(
                        field.options, field.value)
                    widget.connect('changed', on_list_single_combobox_changed,
                                   field)
                widget.set_sensitive(readwrite)

            elif field.type == 'list-multi':
                # TODO: When more than few choices, make a list
                widget = gtk.VBox()
                for value, label in field.iter_options():
                    check = gtk.CheckButton(label, use_underline=False)
                    check.set_active(value in field.values)
                    check.connect('toggled',
                                  self.on_list_multi_checkbutton_toggled,
                                  field, value)
                    widget.set_sensitive(readwrite)
                    widget.pack_start(check, expand=False)

            elif field.type == 'jid-single':
                widget = gtk.Entry()
                widget.connect('changed', self.on_text_single_entry_changed,
                               field)
                widget.set_text(field.value)

            elif field.type == 'jid-multi':
                commonwidget = False

                xml = gtkgui_helpers.get_glade('data_form_window.glade',
                                               'item_list_table')
                widget = xml.get_widget('item_list_table')
                treeview = xml.get_widget('item_treeview')

                listmodel = gtk.ListStore(str)
                for value in field.iter_values():
                    # nobody will create several megabytes long stanza
                    listmodel.insert(999999, (value, ))

                treeview.set_model(listmodel)

                renderer = gtk.CellRendererText()
                renderer.set_property('editable', True)
                renderer.connect('edited',
                                 self.on_jid_multi_cellrenderertext_edited,
                                 treeview, listmodel, field)

                treeview.append_column(
                    gtk.TreeViewColumn(None, renderer, text=0))

                decorate_with_tooltip(treeview, field)

                add_button = xml.get_widget('add_button')
                add_button.connect('clicked',
                                   self.on_jid_multi_add_button_clicked,
                                   treeview, listmodel, field)
                edit_button = xml.get_widget('edit_button')
                edit_button.connect('clicked',
                                    self.on_jid_multi_edit_button_clicked,
                                    treeview)
                remove_button = xml.get_widget('remove_button')
                remove_button.connect('clicked',
                                      self.on_jid_multi_remove_button_clicked,
                                      treeview, field)
                clear_button = xml.get_widget('clear_button')
                clear_button.connect('clicked',
                                     self.on_jid_multi_clean_button_clicked,
                                     listmodel, field)
                if not readwrite:
                    add_button.set_no_show_all(True)
                    edit_button.set_no_show_all(True)
                    remove_button.set_no_show_all(True)
                    clear_button.set_no_show_all(True)

                widget.set_sensitive(readwrite)
                self.attach(widget, 1, 2, linecounter, linecounter + 1)

                del xml

            elif field.type == 'text-private':
                commonlabelcenter = True
                widget = gtk.Entry()
                widget.connect('changed', self.on_text_single_entry_changed,
                               field)
                widget.set_visibility(False)
                widget.set_text(field.value)

            elif field.type == 'text-multi':
                # TODO: bigger text view
                commonwidget = False

                textwidget = gtk.TextView()
                textwidget.set_wrap_mode(gtk.WRAP_WORD)
                textwidget.get_buffer().connect(
                    'changed', self.on_text_multi_textbuffer_changed, field)
                textwidget.get_buffer().set_text(field.value)

                widget = gtk.ScrolledWindow()
                widget.add(textwidget)

                widget.set_sensitive(readwrite)
                widget = decorate_with_tooltip(widget, field)
                self.attach(widget, 1, 2, linecounter, linecounter + 1)

            else:
                # field.type == 'text-single' or field.type is nonstandard:
                # JEP says that if we don't understand some type, we
                # should handle it as text-single
                commonlabelcenter = True
                if readwrite:
                    widget = gtk.Entry()
                    widget.connect('changed',
                                   self.on_text_single_entry_changed, field)
                    widget.set_sensitive(readwrite)
                    if field.value is None:
                        field.value = u''
                    widget.set_text(field.value)
                else:
                    commonwidget = False
                    widget = gtk.Label(field.value)
                    widget.set_sensitive(True)
                    widget.set_alignment(0.0, 0.5)
                    widget = decorate_with_tooltip(widget, field)
                    self.attach(widget,
                                1,
                                2,
                                linecounter,
                                linecounter + 1,
                                yoptions=gtk.FILL)

            if commonlabel and field.label is not None:
                label = gtk.Label(field.label)
                if commonlabelcenter:
                    label.set_alignment(0.0, 0.5)
                else:
                    label.set_alignment(0.0, 0.0)
                label = decorate_with_tooltip(label, field)
                self.attach(label,
                            0,
                            1,
                            linecounter,
                            linecounter + 1,
                            xoptions=gtk.FILL,
                            yoptions=gtk.FILL)

            if commonwidget:
                assert widget is not None
                widget.set_sensitive(readwrite)
                widget = decorate_with_tooltip(widget, field)
                self.attach(widget,
                            1,
                            2,
                            linecounter,
                            linecounter + 1,
                            yoptions=gtk.FILL)
            widget.show_all()

            linecounter += 1
        if self.get_property('visible'):
            self.show_all()
Example #38
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_glade('features_window.glade')
        self.window = self.xml.get_widget('features_window')
        treeview = self.xml.get_widget('features_treeview')
        self.desc_label = self.xml.get_widget('feature_desc_label')

        # {name: (available_function, unix_text, windows_text)}
        self.features = {
            _('PyOpenSSL'):
            (self.pyopenssl_available,
             _('A library used to validate server certificates to ensure a secure connection.'
               ), _('Requires python-pyopenssl.'),
             _('Requires python-pyopenssl.')),
            _('Bonjour / Zeroconf'):
            (self.zeroconf_available,
             _('Serverless chatting with autodetected clients in a local network.'
               ), _('Requires python-avahi.'),
             _('Requires pybonjour (http://o2s.csail.mit.edu/o2s-wiki/pybonjour).'
               )),
            _('gajim-remote'):
            (self.dbus_available,
             _('A script to control Gajim via commandline.'),
             _('Requires python-dbus.'),
             _('Feature not available under Windows.')),
            _('OpenGPG'): (self.gpg_available,
                           _('Encrypting chatmessages with gpg keys.'),
                           _('Requires gpg and python-GnuPGInterface.'),
                           _('Feature not available under Windows.')),
            _('network-manager'):
            (self.network_manager_available,
             _('Autodetection of network status.'),
             _('Requires gnome-network-manager and python-dbus.'),
             _('Feature not available under Windows.')),
            _('Session Management'):
            (self.session_management_available,
             _('Gajim session is stored on logout and restored on login.'),
             _('Requires python-gnome2.'),
             _('Feature not available under Windows.')),
            _('gnome-keyring'):
            (self.gnome_keyring_available,
             _('Passwords can be stored securely and not just in plaintext.'),
             _('Requires gnome-keyring and python-gnome2-desktop.'),
             _('Feature not available under Windows.')),
            _('SRV'):
            (self.srv_available,
             _('Ability to connect to servers which are using SRV records.'),
             _('Requires dnsutils.'),
             _('Requires nslookup to use SRV records.')),
            _('Spell Checker'):
            (self.speller_available, _('Spellchecking of composed messages.'),
             _('Requires python-gnome2-extras or compilation of gtkspell module from Gajim sources.'
               ), _('Feature not available under Windows.')),
            _('Notification-daemon'):
            (self.notification_available,
             _('Passive popups notifying for new events.'),
             _('Requires python-notify or instead python-dbus in conjunction with notification-daemon.'
               ), _('Feature not available under Windows.')),
            _('Trayicon'):
            (self.trayicon_available,
             _('A icon in systemtray reflecting the current presence.'),
             _('Requires python-gnome2-extras or compiled trayicon module from Gajim sources.'
               ), _('Requires PyGTK >= 2.10.')),
            _('Idle'):
            (self.idle_available,
             _('Ability to measure idle time, in order to set auto status.'),
             _('Requires compilation of the idle module from Gajim sources.'),
             _('Requires compilation of the idle module from Gajim sources.')),
            _('LaTeX'):
            (self.latex_available,
             _('Transform LaTeX expressions between $$ $$.'),
             _('Requires texlive-latex-base and dvipng. You have to set \'use_latex\' to True in the Advanced Configuration Editor.'
               ),
             _('Requires texlive-latex-base and dvipng (All is in MikTeX). You have to set \'use_latex\' to True in the Advanced Configuration Editor.'
               )),
            _('End to End Encryption'): (self.pycrypto_available,
                                         _('Encrypting chatmessages.'),
                                         _('Requires python-crypto.'),
                                         _('Requires python-crypto.')),
            _('RST Generator'):
            (self.docutils_available,
             _('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).'
               ), _('Requires python-docutils.'),
             _('Requires python-docutils.')),
            _('libsexy'):
            (self.pysexy_available,
             _('Ability to have clickable URLs in chat and groupchat window banners.'
               ), _('Requires python-sexy.'), _('Requires python-sexy.')),
        }

        # name, supported
        self.model = gtk.ListStore(str, bool)
        treeview.set_model(self.model)

        col = gtk.TreeViewColumn(_('Available'))
        treeview.append_column(col)
        cell = gtk.CellRendererToggle()
        cell.set_property('radio', True)
        col.pack_start(cell)
        col.set_attributes(cell, active=1)

        col = gtk.TreeViewColumn(_('Feature'))
        treeview.append_column(col)
        cell = gtk.CellRendererText()
        col.pack_start(cell, expand=True)
        col.add_attribute(cell, 'text', 0)

        # Fill model
        for feature in self.features:
            func = self.features[feature][0]
            rep = func()
            self.model.append([feature, rep])
        self.xml.signal_autoconnect(self)
        self.window.show_all()
        self.xml.get_widget('close_button').grab_focus()
Example #39
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_glade(
            'advanced_configuration_window.glade')
        self.window = self.xml.get_widget('advanced_configuration_window')
        self.window.set_transient_for(
            gajim.interface.instances['preferences'].window)
        self.entry = self.xml.get_widget('advanced_entry')
        self.desc_label = self.xml.get_widget('advanced_desc_label')
        self.restart_label = self.xml.get_widget('restart_label')

        # Format:
        # key = option name (root/subopt/opt separated by \n then)
        # value = array(oldval, newval)
        self.changed_opts = {}

        # For i18n
        self.right_true_dict = {True: _('Activated'), False: _('Deactivated')}
        self.types = {
            'boolean': _('Boolean'),
            'integer': _('Integer'),
            'string': _('Text'),
            'color': _('Color')
        }

        treeview = self.xml.get_widget('advanced_treeview')
        self.model = gtk.TreeStore(str, str, str)
        self.model.set_sort_column_id(0, gtk.SORT_ASCENDING)
        self.modelfilter = self.model.filter_new()
        self.modelfilter.set_visible_func(self.visible_func)

        renderer_text = gtk.CellRendererText()
        col = treeview.insert_column_with_attributes(-1,
                                                     _('Preference Name'),
                                                     renderer_text,
                                                     text=0)
        col.set_resizable(True)

        renderer_text = gtk.CellRendererText()
        renderer_text.connect('edited', self.on_config_edited)
        col = treeview.insert_column_with_attributes(-1,
                                                     _('Value'),
                                                     renderer_text,
                                                     text=1)
        col.set_cell_data_func(renderer_text, self.cb_value_column_data)

        col.props.resizable = True
        col.set_max_width(250)

        renderer_text = gtk.CellRendererText()
        treeview.insert_column_with_attributes(-1,
                                               _('Type'),
                                               renderer_text,
                                               text=2)

        # add data to model
        gajim.config.foreach(self.fill, self.model)

        treeview.set_model(self.modelfilter)

        # connect signal for selection change
        treeview.get_selection().connect(
            'changed', self.on_advanced_treeview_selection_changed)

        self.xml.signal_autoconnect(self)
        self.window.show_all()
        self.restart_label.hide()
        gajim.interface.instances['advanced_config'] = self
Example #40
0
	def __init__(self):
		self.xml = gtkgui_helpers.get_glade('features_window.glade')
		self.window = self.xml.get_widget('features_window')
		treeview = self.xml.get_widget('features_treeview')
		self.desc_label = self.xml.get_widget('feature_desc_label')

		# {name: (available_function, unix_text, windows_text)}
		self.features = {
			_('PyOpenSSL'): (self.pyopenssl_available,
				_('A library used to validate server certificates to ensure a secure connection.'),
				_('Requires python-pyopenssl.'),
				_('Requires python-pyopenssl.')),
			_('Bonjour / Zeroconf'): (self.zeroconf_available,
				_('Serverless chatting with autodetected clients in a local network.'),
				_('Requires python-avahi.'),
				_('Requires pybonjour (http://o2s.csail.mit.edu/o2s-wiki/pybonjour).')),
			_('gajim-remote'): (self.dbus_available,
				_('A script to control Gajim via commandline.'),
				_('Requires python-dbus.'),
				_('Feature not available under Windows.')),
			_('OpenGPG'): (self.gpg_available,
				_('Encrypting chatmessages with gpg keys.'),
				_('Requires gpg and python-GnuPGInterface.'),
				_('Feature not available under Windows.')),
			_('network-manager'): (self.network_manager_available,
				_('Autodetection of network status.'),
				_('Requires gnome-network-manager and python-dbus.'),
				_('Feature not available under Windows.')),
			_('Session Management'): (self.session_management_available,
				_('Gajim session is stored on logout and restored on login.'),
				_('Requires python-gnome2.'),
				_('Feature not available under Windows.')),
			_('gnome-keyring'): (self.gnome_keyring_available,
				_('Passwords can be stored securely and not just in plaintext.'),
				_('Requires gnome-keyring and python-gnome2-desktop.'),
				_('Feature not available under Windows.')),
			_('SRV'): (self.srv_available,
				_('Ability to connect to servers which are using SRV records.'),
				_('Requires dnsutils.'),
				_('Requires nslookup to use SRV records.')),
			_('Spell Checker'): (self.speller_available,
				_('Spellchecking of composed messages.'),
				_('Requires python-gnome2-extras or compilation of gtkspell module from Gajim sources.'),
				_('Feature not available under Windows.')),
			_('Notification-daemon'): (self.notification_available,
				_('Passive popups notifying for new events.'),	
				_('Requires python-notify or instead python-dbus in conjunction with notification-daemon.'),
				_('Feature not available under Windows.')),
			_('Trayicon'): (self.trayicon_available,
				_('A icon in systemtray reflecting the current presence.'), 
				_('Requires python-gnome2-extras or compiled trayicon module from Gajim sources.'),
				_('Requires PyGTK >= 2.10.')),
			_('Idle'): (self.idle_available,
				_('Ability to measure idle time, in order to set auto status.'),
				_('Requires compilation of the idle module from Gajim sources.'),
				_('Requires compilation of the idle module from Gajim sources.')),
			_('LaTeX'): (self.latex_available,
				_('Transform LaTeX expressions between $$ $$.'),
				_('Requires texlive-latex-base and dvipng. You have to set \'use_latex\' to True in the Advanced Configuration Editor.'),
				_('Requires texlive-latex-base and dvipng (All is in MikTeX). You have to set \'use_latex\' to True in the Advanced Configuration Editor.')),
			_('End to End Encryption'): (self.pycrypto_available,
				_('Encrypting chatmessages.'),
				_('Requires python-crypto.'),
				_('Requires python-crypto.')),
			_('RST Generator'): (self.docutils_available,
				_('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).'),
				_('Requires python-docutils.'),
				_('Requires python-docutils.')),
			_('libsexy'): (self.pysexy_available,
				_('Ability to have clickable URLs in chat and groupchat window banners.'),
				_('Requires python-sexy.'),
				_('Requires python-sexy.')),
		}

		# name, supported
		self.model = gtk.ListStore(str, bool)
		treeview.set_model(self.model)

		col = gtk.TreeViewColumn(_('Available'))
		treeview.append_column(col)
		cell = gtk.CellRendererToggle()
		cell.set_property('radio', True)
		col.pack_start(cell)
		col.set_attributes(cell, active = 1)

		col = gtk.TreeViewColumn(_('Feature'))
		treeview.append_column(col)
		cell = gtk.CellRendererText()
		col.pack_start(cell, expand = True)
		col.add_attribute(cell, 'text', 0)

		# Fill model
		for feature in self.features:
			func = self.features[feature][0]
			rep = func()
			self.model.append([feature, rep])
		self.xml.signal_autoconnect(self)
		self.window.show_all()
		self.xml.get_widget('close_button').grab_focus()
Example #41
0
	def __init__(self, dataform):
		assert isinstance(dataform, dataforms.SimpleDataForm)

		gtk.Table.__init__(self)
		self.set_col_spacings(12)
		self.set_row_spacings(6)

		self.tooltips = gtk.Tooltips()

		def decorate_with_tooltip(widget, field):
			''' Adds a tooltip containing field's description to a widget.
			Creates EventBox if widget doesn't have its own gdk window.
			Returns decorated widget. '''
			if field.description != '':
				if widget.flags() & gtk.NO_WINDOW:
					evbox = gtk.EventBox()
					evbox.add(widget)
					widget = evbox
				self.tooltips.set_tip(widget, field.description)
			return widget

		self._data_form = dataform

		# building widget
		linecounter = 0

		# is the form changeable?
		readwrite = dataform.type != 'result'

		# for each field...
		for field in self._data_form.iter_fields():
			if field.type == 'hidden': continue

			commonlabel = True
			commonlabelcenter = False
			commonwidget = True
			widget = None

			if field.type == 'boolean':
				commonlabelcenter = True
				widget = gtk.CheckButton()
				widget.connect('toggled', self.on_boolean_checkbutton_toggled,
					field)
				widget.set_active(field.value)

			elif field.type == 'fixed':
				leftattach = 1
				rightattach = 2
				if field.label is None:
					commonlabel = False
					leftattach = 0
				
				commonwidget = False
				widget = gtk.Label(field.value)
				widget.set_line_wrap(True)
				self.attach(widget, leftattach, rightattach, linecounter,
					linecounter+1, xoptions=gtk.FILL, yoptions=gtk.FILL)

			elif field.type == 'list-single':
				# TODO: What if we have radio buttons and non-required field?
				# TODO: We cannot deactivate them all...
				if len(field.options) < 6:
					# 5 option max: show radiobutton
					widget = gtk.VBox()
					first_radio = None
					for value, label in field.iter_options():
						if not label:
							label = value
						radio = gtk.RadioButton(first_radio, label=label)
						radio.connect('toggled',
							self.on_list_single_radiobutton_toggled, field, value)
						if first_radio is None:
							first_radio = radio
							if field.value == '':	# TODO: is None when done
								field.value = value
						if value == field.value:
							radio.set_active(True)
						widget.pack_start(radio, expand=False)
				else:
					# more than 5 options: show combobox
					def on_list_single_combobox_changed(combobox, f):
						iter = combobox.get_active_iter()
						if iter:
							model = combobox.get_model()
							f.value = model[iter][1]
						else:
							f.value = ''
					widget = gtkgui_helpers.create_combobox(field.options,
						field.value)
					widget.connect('changed', on_list_single_combobox_changed, field)
				widget.set_sensitive(readwrite)

			elif field.type == 'list-multi':
				# TODO: When more than few choices, make a list
				widget = gtk.VBox()
				for value, label in field.iter_options():
					check = gtk.CheckButton(label, use_underline=False)
					check.set_active(value in field.values)
					check.connect('toggled', self.on_list_multi_checkbutton_toggled,
						field, value)
					widget.set_sensitive(readwrite)
					widget.pack_start(check, expand=False)

			elif field.type == 'jid-single':
				widget = gtk.Entry()
				widget.connect('changed', self.on_text_single_entry_changed, field)
				widget.set_text(field.value)

			elif field.type == 'jid-multi':
				commonwidget = False

				xml = gtkgui_helpers.get_glade('data_form_window.glade',
					'item_list_table')
				widget = xml.get_widget('item_list_table')
				treeview = xml.get_widget('item_treeview')

				listmodel = gtk.ListStore(str)
				for value in field.iter_values():
					# nobody will create several megabytes long stanza
					listmodel.insert(999999, (value,))

				treeview.set_model(listmodel)

				renderer = gtk.CellRendererText()
				renderer.set_property('editable', True)
				renderer.connect('edited',
					self.on_jid_multi_cellrenderertext_edited, treeview, listmodel,
					field)

				treeview.append_column(gtk.TreeViewColumn(None, renderer,
					text=0))

				decorate_with_tooltip(treeview, field)

				add_button=xml.get_widget('add_button')
				add_button.connect('clicked',
					self.on_jid_multi_add_button_clicked, treeview, listmodel, field)
				edit_button=xml.get_widget('edit_button')
				edit_button.connect('clicked',
					self.on_jid_multi_edit_button_clicked, treeview)
				remove_button=xml.get_widget('remove_button')
				remove_button.connect('clicked',
					self.on_jid_multi_remove_button_clicked, treeview, field)
				clear_button=xml.get_widget('clear_button')
				clear_button.connect('clicked',
					self.on_jid_multi_clean_button_clicked, listmodel, field)
				if not readwrite:
					add_button.set_no_show_all(True)
					edit_button.set_no_show_all(True)
					remove_button.set_no_show_all(True)
					clear_button.set_no_show_all(True)

				widget.set_sensitive(readwrite)
				self.attach(widget, 1, 2, linecounter, linecounter+1)

				del xml

			elif field.type == 'text-private':
				commonlabelcenter = True
				widget = gtk.Entry()
				widget.connect('changed', self.on_text_single_entry_changed, field)
				widget.set_visibility(False)
				widget.set_text(field.value)

			elif field.type == 'text-multi':
				# TODO: bigger text view
				commonwidget = False

				textwidget = gtk.TextView()
				textwidget.set_wrap_mode(gtk.WRAP_WORD)
				textwidget.get_buffer().connect('changed',
					self.on_text_multi_textbuffer_changed, field)
				textwidget.get_buffer().set_text(field.value)

				widget = gtk.ScrolledWindow()
				widget.add(textwidget)

				widget.set_sensitive(readwrite)
				widget=decorate_with_tooltip(widget, field)
				self.attach(widget, 1, 2, linecounter, linecounter+1)

			else:
				# field.type == 'text-single' or field.type is nonstandard:
				# JEP says that if we don't understand some type, we
				# should handle it as text-single
				commonlabelcenter = True
				if readwrite:
					widget = gtk.Entry()
					widget.connect('changed', self.on_text_single_entry_changed,
						field)
					widget.set_sensitive(readwrite)
					if field.value is None:
						field.value = u''
					widget.set_text(field.value)
				else:
					commonwidget=False
					widget = gtk.Label(field.value)
					widget.set_sensitive(True)
					widget.set_alignment(0.0, 0.5)
					widget=decorate_with_tooltip(widget, field)
					self.attach(widget, 1, 2, linecounter, linecounter+1,
						yoptions=gtk.FILL)

			if commonlabel and field.label is not None:
				label = gtk.Label(field.label)
				if commonlabelcenter:
					label.set_alignment(0.0, 0.5)
				else:
					label.set_alignment(0.0, 0.0)
				label = decorate_with_tooltip(label, field)
				self.attach(label, 0, 1, linecounter, linecounter+1,
					xoptions=gtk.FILL, yoptions=gtk.FILL)

			if commonwidget:
				assert widget is not None
				widget.set_sensitive(readwrite)
				widget = decorate_with_tooltip(widget, field)
				self.attach(widget, 1, 2, linecounter, linecounter+1,
					yoptions=gtk.FILL)
			widget.show_all()

			linecounter+=1
		if self.get_property('visible'):
			self.show_all()
Example #42
0
	def __init__(self):
		self.files_props = {'r' : {}, 's': {}}
		self.height_diff = 0
		self.xml = gtkgui_helpers.get_glade('filetransfers.glade')
		self.window = self.xml.get_widget('file_transfers_window')
		self.tree = self.xml.get_widget('transfers_list')
		self.cancel_button = self.xml.get_widget('cancel_button')
		self.pause_button = self.xml.get_widget('pause_restore_button')
		self.cleanup_button = self.xml.get_widget('cleanup_button')
		self.notify_ft_checkbox = self.xml.get_widget(
			'notify_ft_complete_checkbox')
		notify = gajim.config.get('notify_on_file_complete')
		if notify:
			self.notify_ft_checkbox.set_active(True)
		else:
			self.notify_ft_checkbox.set_active(False)
		self.model = gtk.ListStore(gtk.gdk.Pixbuf, str, str, str, str, int, str)
		self.tree.set_model(self.model)
		col = gtk.TreeViewColumn()

		render_pixbuf = gtk.CellRendererPixbuf()

		col.pack_start(render_pixbuf, expand = True)
		render_pixbuf.set_property('xpad', 3)
		render_pixbuf.set_property('ypad', 3)
		render_pixbuf.set_property('yalign', .0)
		col.add_attribute(render_pixbuf, 'pixbuf', 0)
		self.tree.append_column(col)

		col = gtk.TreeViewColumn(_('File'))
		renderer = gtk.CellRendererText()
		col.pack_start(renderer, expand=False)
		col.add_attribute(renderer, 'markup' , C_LABELS)
		renderer.set_property('yalign', 0.)
		renderer = gtk.CellRendererText()
		col.pack_start(renderer, expand=True)
		col.add_attribute(renderer, 'markup' , C_FILE)
		renderer.set_property('xalign', 0.)
		renderer.set_property('yalign', 0.)
		renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
		col.set_resizable(True)
		col.set_expand(True)
		self.tree.append_column(col)

		col = gtk.TreeViewColumn(_('Time'))
		renderer = gtk.CellRendererText()
		col.pack_start(renderer, expand=False)
		col.add_attribute(renderer, 'markup' , C_TIME)
		renderer.set_property('yalign', 0.5)
		renderer.set_property('xalign', 0.5)
		renderer = gtk.CellRendererText()
		renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
		col.set_resizable(True)
		col.set_expand(False)
		self.tree.append_column(col)

		col = gtk.TreeViewColumn(_('Progress'))
		renderer = gtk.CellRendererProgress()
		renderer.set_property('yalign', 0.5)
		renderer.set_property('xalign', 0.5)
		col.pack_start(renderer, expand = False)
		col.add_attribute(renderer, 'text' , C_PROGRESS)
		col.add_attribute(renderer, 'value' , C_PERCENT)
		col.set_resizable(True)
		col.set_expand(False)
		self.tree.append_column(col)

		self.set_images()
		self.tree.get_selection().set_mode(gtk.SELECTION_SINGLE)
		self.tree.get_selection().connect('changed', self.selection_changed)
		self.tooltip = tooltips.FileTransfersTooltip()
		self.file_transfers_menu = self.xml.get_widget('file_transfers_menu')
		self.open_folder_menuitem = self.xml.get_widget('open_folder_menuitem')
		self.cancel_menuitem = self.xml.get_widget('cancel_menuitem')
		self.pause_menuitem = self.xml.get_widget('pause_menuitem')
		self.continue_menuitem = self.xml.get_widget('continue_menuitem')
		self.remove_menuitem = self.xml.get_widget('remove_menuitem')
		self.xml.signal_autoconnect(self)