Exemple #1
0
    def __init__(self):
        self.tooltip = g.Tooltips()
        if tip.value == "": self.tooltip.disable()
        self.vbox = g.VBox(spacing=2)

        self.line1_label = g.Label("")
        if line1.value != "":
            self.vbox.add(self.line1_label)

        self.line2_label = g.Label("")
        if line2.value != "":
            self.vbox.add(self.line2_label)

        self.set_border_width(5)
        self.add(self.vbox)

        rox.app_options.add_notify(self.options_changed)

        self.add_events(g.gdk.BUTTON_PRESS_MASK)
        self.connect("button-press-event", self.button_press)

        self.connect("destroy", self.destroyed)

        self.update_clock()
        self.timeout = gobject.timeout_add(1000, self.update_clock)

        self.show_all()
Exemple #2
0
    def __init__(self):
        g.Button.__init__(self, 'T')
        self.end_time = None
        self.timeout = None
        self.unset_flags(g.CAN_FOCUS)

        tips = g.Tooltips()
        tips.set_tip(self, _('Click here to set the count-down timer.'))

        self.connect('clicked', edit_timer)
Exemple #3
0
from rox import g
import rox, os

__icons = {}
tooltips = g.Tooltips()


def get_weather_icon(n):
    icon = __icons.get(n)
    if not icon:
        icon_path = os.path.join(rox.app_dir, "icons", "%s.png" % n)
        if not os.path.isfile(icon_path):
            icon_path = os.path.join(rox.app_dir, "icons", "-.png")
        icon = g.gdk.pixbuf_new_from_file(icon_path)
        __icons[n] = icon
    return icon
Exemple #4
0
    def __init__(self, options_group, options_xml, translation=None):
        """options_xml is an XML file, usually <app_dir>/Options.xml,
		which defines the layout of the OptionsBox.

		It contains an <options> root element containing (nested)
		<section> elements. Each <section> contains a number of widgets,
		some of which correspond to options. The build_* functions are
		used to create them.

		Example:

		<?xml version='1.0'?>
		<options>
		  <section title='First section'>
		    <label>Here are some options</label>
		    <entry name='default_name' label='Default file name'>
		      When saving an untitled file, use this name as the default.
		    </entry>
		    <section title='Nested section'>
		      ...
		    </section>
		  </section>
		</options>
		"""
        assert isinstance(options_group, options.OptionGroup)

        if translation is None:
            import __main__
            if hasattr(__main__.__builtins__, '_'):
                translation = __main__.__builtins__._
            else:
                translation = lambda x: x
        self._ = translation

        g.Dialog.__init__(self)
        self.tips = g.Tooltips()
        self.set_has_separator(False)

        self.options = options_group
        self.set_title(('%s options') % options_group.program)
        self.set_position(g.WIN_POS_CENTER)

        button = rox.ButtonMixed(g.STOCK_UNDO, _('_Revert'))
        self.add_action_widget(button, REVERT)
        self.tips.set_tip(
            button,
            _('Restore all options to how they were '
              'when the window was opened'))

        self.add_button(g.STOCK_OK, g.RESPONSE_OK)

        doc = minidom.parse(options_xml)
        assert doc.documentElement.localName == 'options'

        self.handlers = {}  # Option -> (get, set)
        self.revert = {}  # Option -> old value

        self.build_window_frame()

        # Add each section
        n = 0
        for section in doc.documentElement.childNodes:
            if section.nodeType != Node.ELEMENT_NODE:
                continue
            if section.localName != 'section':
                print "Unknown section", section
                continue
            self.build_section(section, None)
            n += 1
        if n > 1:
            self.tree_view.expand_all()
        else:
            self.sections_swin.hide()

        self.updating = 0

        def destroyed(widget):
            rox.toplevel_unref()
            if self.changed():
                try:
                    self.options.save()
                except:
                    rox.report_exception()

        self.connect('destroy', destroyed)

        def got_response(widget, response):
            if response == g.RESPONSE_OK:
                self.destroy()
            elif response == REVERT:
                for o in self.options:
                    o._set(self.revert[o])
                self.update_widgets()
                self.options.notify()
                self.update_revert()

        self.connect('response', got_response)
Exemple #5
0
	def __init__(self, memo_list):
		rox.Window.__init__(self)
		MenuWindow.__init__(self)
		self.set_wmclass('Memo', 'Memo')
		self.set_title('Memo')
		self.set_resizable(False)
		if hasattr(self, 'set_deletable'):
			self.set_deletable(False)
		#self.set_type_hint(g.gdk.WINDOW_TYPE_HINT_DIALOG)

		self.tips = g.Tooltips()

		if main_sticky.int_value:
			self.stick()

		self.memo_list = memo_list
		self.last_day = None
		self.prime_in_progress = False

		vbox = g.VBox(FALSE, 0)
		self.add(vbox)

		hbox = g.HBox(False, 0)
		vbox.pack_start(hbox, expand = False)

		self.time_label = g.Label('')
		self.time_button = g.Button()
		self.time_button.add(self.time_label)
		self.time_button.unset_flags(g.CAN_FOCUS)
		hbox.pack_start(self.time_button, expand = True)

		hbox.pack_start(timer.TimerButton(), expand = False)

		self.list = g.TreeView(memo_list.visible)
		vbox.pack_start(self.list, expand = TRUE)
		self.list.unset_flags(g.CAN_FOCUS)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Time', cell, text = 0)
		cell.set_property('xalign', 1)
		self.list.append_column(column)

		cell = g.CellRendererText()
		column = g.TreeViewColumn('Message', cell, text = 1)
		self.list.append_column(column)

		self.list.set_headers_visible(FALSE)
		
		sel = self.list.get_selection()
		sel.set_mode(g.SELECTION_NONE)

		def activate(view, path, column):
			memo = memo_list.visible.get_memo_by_path(path)
			from EditBox import EditBox
			EditBox(memo).show()
		
		self.add_events(g.gdk.BUTTON_PRESS_MASK)
		self.list.connect('button-press-event', self.button_press)
		self.list.connect('row-activated', activate)
		self.time_button.add_events(g.gdk.BUTTON1_MOTION_MASK)
		self.time_button.connect('button-press-event', self.button_press)
		self.time_button.connect('motion-notify-event', self.button_motion)
		self.time_button.connect('clicked', self.time_button_clicked)

		self.update()
		gobject.timeout_add(10000, self.update)	# Update clock

		self.timeout = None	# For next alarm
		self.alert_box = None
		self.show_all_box = None
		self.save_box = None
		self.prime()

		# If we had more than one window, we'd need a remove too...
		memo_list.connect("MemoListChanged", self.prime)
		app_options.add_notify(self.options_changed)
		
		vbox.show_all()