Ejemplo n.º 1
0
 def system_dialog(self, caller):
     dialog = Gtk.Dialog(_("Enter System Unlock Code"),
                         caller.widgets.window1,
                         Gtk.DialogFlags.DESTROY_WITH_PARENT)
     label = Gtk.Label(_("Enter System Unlock Code"))
     label.modify_font(Pango.FontDescription("sans 20"))
     calc = gladevcp.Calculator()
     dialog.vbox.pack_start(label, False, False, 0)
     dialog.vbox.add(calc)
     calc.set_value("")
     calc.set_property("font", "sans 20")
     calc.set_editable(True)
     calc.integer_entry_only(True)
     calc.num_pad_only(True)
     calc.entry.connect(
         "activate",
         lambda w: dialog.emit("response", Gtk.ResponseType.ACCEPT))
     dialog.parse_geometry("360x400")
     dialog.set_decorated(True)
     dialog.show_all()
     self.emit("play_sound", "alert")
     response = dialog.run()
     code = calc.get_value()
     dialog.destroy()
     if response == Gtk.ResponseType.ACCEPT:
         if code == int(caller.unlock_code):
             return True
     return False
Ejemplo n.º 2
0
 def system_dialog(self, caller):
     dialog = gtk.Dialog(_("Enter System Unlock Code"),
                caller.widgets.window1,
                gtk.DIALOG_DESTROY_WITH_PARENT,
                (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     label = gtk.Label(_("Enter System Unlock Code"))
     label.modify_font(pango.FontDescription("sans 20"))
     calc = gladevcp.Calculator()
     dialog.vbox.pack_start(label)
     dialog.vbox.add(calc)
     calc.set_value("")
     calc.set_property("font", "sans 20")
     calc.set_editable(True)
     calc.entry.connect("activate", lambda w : dialog.emit("response", gtk.RESPONSE_ACCEPT))
     dialog.parse_geometry("400x400")
     dialog.set_decorated(True)
     dialog.show_all()
     self.emit("play_sound", "alert")
     response = dialog.run()
     code = calc.get_value()
     dialog.destroy()
     if response == gtk.RESPONSE_ACCEPT:
         if code == int(caller.unlock_code):
             return True
     return False
Ejemplo n.º 3
0
 def entry_dialog(self, caller, data = None, header = _("Enter value") , label = _("Enter the value to set"), integer = False):
     dialog = gtk.Dialog(header,
                caller.widgets.window1,
                gtk.DIALOG_DESTROY_WITH_PARENT,
                (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     label = gtk.Label(label)
     label.modify_font(pango.FontDescription("sans 20"))
     calc = gladevcp.Calculator()
     dialog.vbox.pack_start(label)
     dialog.vbox.add(calc)
     if data != None:
         calc.set_value(data)
     else:
         calc.set_value("")
     calc.set_property("font", "sans 20")
     calc.set_editable(True)
     calc.entry.connect("activate", lambda w : dialog.emit("response", gtk.RESPONSE_ACCEPT))
     dialog.parse_geometry("400x400")
     dialog.set_decorated(True)
     self.emit("play_sound", "alert")
     if integer: # The user is only allowed to enter integer values, we hide some button
         calc.num_pad_only(True)
         calc.integer_entry_only(True)
     dialog.show_all()
     response = dialog.run()
     value = calc.get_value()
     dialog.destroy()
     if response == gtk.RESPONSE_ACCEPT:
         if value != None:
             return float(value)
         else:
             return "ERROR"
     return "CANCEL"
Ejemplo n.º 4
0
 def entry_dialog(self,
                  caller,
                  data=None,
                  header=_("Enter value"),
                  label=_("Enter the value to set"),
                  integer=False):
     dialog = Gtk.Dialog(header, caller.widgets.window1,
                         Gtk.DialogFlags.DESTROY_WITH_PARENT,
                         (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                          Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
     label = Gtk.Label(label)
     label.modify_font(Pango.FontDescription("sans 20"))
     calc = gladevcp.Calculator()
     # add label to control the height of the action_area
     label_h = Gtk.Label("\n\n\n")
     dialog.action_area.pack_start(label_h, True, True, 0)
     dialog.action_area.reorder_child(label_h, 0)
     dialog.vbox.pack_start(label, True, True, 0)
     dialog.vbox.add(calc)
     if data != None:
         calc.set_value(data)
     else:
         calc.set_value("")
     calc.set_property("font", "sans 20")
     calc.set_editable(True)
     calc.entry.connect(
         "activate",
         lambda w: dialog.emit("response", Gtk.ResponseType.ACCEPT))
     dialog.parse_geometry("460x400")
     dialog.set_decorated(True)
     self.emit("play_sound", "alert")
     if integer:  # The user is only allowed to enter integer values, we hide some button
         calc.num_pad_only(True)
         calc.integer_entry_only(True)
     dialog.show_all()
     response = dialog.run()
     value = calc.get_value()
     dialog.destroy()
     if response == Gtk.ResponseType.ACCEPT:
         if value != None:
             if integer:
                 return int(value)
             else:
                 return float(value)
         else:
             return "ERROR"
     return "CANCEL"
Ejemplo n.º 5
0
 def entry_dialog(self,
                  caller,
                  data=None,
                  header=_("Enter value"),
                  label=_("Enter the value to set"),
                  integer=False):
     dialog = Gtk.Dialog(header, caller.widgets.window1,
                         Gtk.DialogFlags.DESTROY_WITH_PARENT)
     label = Gtk.Label(label)
     label.modify_font(Pango.FontDescription("sans 20"))
     label.set_margin_top(15)
     calc = gladevcp.Calculator()
     content_area = dialog.get_content_area()
     content_area.pack_start(child=label,
                             expand=False,
                             fill=False,
                             padding=0)
     content_area.add(calc)
     if data != None:
         calc.set_value(data)
     else:
         calc.set_value("")
     calc.set_property("font", "sans 20")
     calc.set_editable(True)
     calc.entry.connect(
         "activate",
         lambda w: dialog.emit("response", Gtk.ResponseType.ACCEPT))
     dialog.parse_geometry("460x400")
     dialog.set_decorated(True)
     self.emit("play_sound", "alert")
     if integer:  # The user is only allowed to enter integer values, we hide some button
         calc.integer_entry_only(True)
         calc.num_pad_only(True)
     dialog.show_all()
     response = dialog.run()
     value = calc.get_value()
     dialog.destroy()
     if response == Gtk.ResponseType.ACCEPT:
         if value != None:
             if integer:
                 return int(value)
             else:
                 return float(value)
         else:
             return "ERROR"
     return "CANCEL"
Ejemplo n.º 6
0
    def restart_dialog(self, caller):

        # highlight the gcode down one line lower
        # used for run-at-line restart
        def restart_down(widget, obj, calc):
            obj.widgets.gcode_view.line_down()
            line = int(obj.widgets.gcode_view.get_line_number())
            calc.set_value(line)

        # highlight the gcode down one line higher
        # used for run-at-line restart
        def restart_up(widget, obj, calc):
            obj.widgets.gcode_view.line_up()
            line = int(obj.widgets.gcode_view.get_line_number())
            calc.set_value(line)

        # highlight the gcode of the entered line
        # used for run-at-line restart
        def enter_button(widget, obj, calc):
            line = int(calc.get_value())
            obj.start_line = line
            obj.widgets.gcode_view.set_line_number(line)

        restart_dialog = gtk.Dialog(_("Restart Entry"),
                   caller.widgets.window1, gtk.DIALOG_DESTROY_WITH_PARENT,
                   (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                     gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        label = gtk.Label(_("Restart Entry"))
        label.modify_font(pango.FontDescription("sans 20"))
        restart_dialog.vbox.pack_start(label)
        calc = gladevcp.Calculator()
        restart_dialog.vbox.add(calc)
        calc.set_value("%d" % caller.widgets.gcode_view.get_line_number())
        calc.set_property("font", "sans 20")
        calc.set_editable(True)
        calc.num_pad_only(True)
        calc.integer_entry_only(True)
        calc.entry.connect("activate", enter_button, caller, calc)
        box = gtk.HButtonBox()
        upbutton = gtk.Button(label = _("Up"))
        box.add(upbutton)
        enterbutton = gtk.Button(label = _("Enter"))
        box.add(enterbutton)
        downbutton = gtk.Button(label = _("Down"))
        box.add(downbutton)
        calc.calc_box.pack_end(box, expand = False, fill = False, padding = 0)
        upbutton.connect("clicked", restart_up, caller, calc)
        downbutton.connect("clicked", restart_down, caller, calc)
        enterbutton.connect("clicked", enter_button, caller, calc)
        restart_dialog.parse_geometry("400x400+0+0")
        restart_dialog.show_all()
        self.emit("play_sound", "alert")
        result = restart_dialog.run()
        restart_dialog.destroy()
        if result == gtk.RESPONSE_REJECT:
            line = 0
        else:
            line = int(calc.get_value())
            if line == None:
                line = 0
        caller.widgets.gcode_view.set_line_number(line)
        caller.start_line = line
Ejemplo n.º 7
0
    def restart_dialog(self, caller):

        # highlight the gcode down one line lower
        # used for run-at-line restart
        def restart_down(widget, obj, calc):
            obj.widgets.gcode_view.line_down()
            line = int(obj.widgets.gcode_view.get_line_number())
            calc.set_value(line)

        # highlight the gcode down one line higher
        # used for run-at-line restart
        def restart_up(widget, obj, calc):
            obj.widgets.gcode_view.line_up()
            line = int(obj.widgets.gcode_view.get_line_number())
            calc.set_value(line)

        # highlight the gcode of the entered line
        # used for run-at-line restart
        def on_enter_button(widget, obj, calc):
            line = int(calc.get_value())
            obj.start_line = line
            obj.widgets.gcode_view.set_line_number(line)

        restart_dialog = Gtk.Dialog(_("Restart Entry"), caller.widgets.window1,
                                    Gtk.DialogFlags.DESTROY_WITH_PARENT)
        label = Gtk.Label(_("Restart Entry"))
        label.modify_font(Pango.FontDescription("sans 20"))
        restart_dialog.vbox.pack_start(label, False, False, 0)
        calc = gladevcp.Calculator()
        restart_dialog.vbox.add(calc)
        calc.set_value("%d" % caller.widgets.gcode_view.get_line_number())
        calc.set_property("font", "sans 20")
        calc.set_editable(True)
        calc.entry.connect("activate", on_enter_button, caller, calc)
        calc.integer_entry_only(True)
        calc.num_pad_only(True)
        # add additional buttons
        upbutton = Gtk.Button.new_with_mnemonic(_("_Up     "))
        upbutton.set_image(
            Gtk.Image.new_from_icon_name("go-up", Gtk.IconSize.BUTTON))
        downbutton = Gtk.Button.new_with_mnemonic(_("_Down"))
        downbutton.set_image(
            Gtk.Image.new_from_icon_name("go-down", Gtk.IconSize.BUTTON))
        enterbutton = Gtk.Button.new_with_mnemonic(_("_Jump to"))
        enterbutton.set_image(
            Gtk.Image.new_from_icon_name("go-jump", Gtk.IconSize.BUTTON))
        calc.table.attach(upbutton, 3, 4, 1, 2)
        calc.table.attach(downbutton, 3, 4, 2, 3)
        calc.table.attach(enterbutton, 3, 4, 3, 4)
        upbutton.connect("clicked", restart_up, caller, calc)
        downbutton.connect("clicked", restart_down, caller, calc)
        enterbutton.connect("clicked", on_enter_button, caller, calc)

        restart_dialog.parse_geometry("410x400+0+0")
        restart_dialog.show_all()
        self.emit("play_sound", "alert")
        result = restart_dialog.run()
        restart_dialog.destroy()
        if result == Gtk.ResponseType.REJECT:
            line = 0
        else:
            line = int(calc.get_value())
            if line == None:
                line = 0
        caller.widgets.gcode_view.set_line_number(line)
        caller.start_line = line