Example #1
0
    def step(self):
        """
        Click the progress bar over to the next value.  Be paranoid
        and insure that it doesn't go over 100%.
        """

        from gi.repository import Gtk

        if self.__mode is ProgressMeter.MODE_FRACTION:
            self.__pbar_index = self.__pbar_index + 1.0

            if self.__pbar_index > self.__pbar_max:
                self.__pbar_index = self.__pbar_max

            try:
                val = int(100 * self.__pbar_index / self.__pbar_max)
            except ZeroDivisionError:
                val = 0

            if val != self.__old_val:
                self.__pbar.set_text("%d%%" % val)
                self.__pbar.set_fraction(val / 100.0)
                self.__old_val = val
        else:  # ProgressMeter.MODE_ACTIVITY
            self.__pbar.pulse()

        while Gtk.events_pending():
            Gtk.main_iteration()

        return self.__cancelled
 def start(self):
     self.connect("destroy", Gtk.main_quit)
     self.set_position(Gtk.WindowPosition.CENTER)
     self.show_all()
     GObject.threads_init()
     Gtk.main()
     return self.accepted
Example #3
0
 def task_list_loading(self):
     self.task_list_loading_failed = False
     self.task_pane_info_label.set_text("Loading...")
     self.task_pane_info_label.show()
     # let the ui update become visible
     while Gtk.events_pending():
         Gtk.main_iteration()
Example #4
0
 def on_mainWindow_destroy(self, widget, arg=None):
     """Fin de l'application"""
     if self.engine:
         self.curs.close()
         self.engine.close()
         print "Base sauvegardee"
     Gtk.main_quit()
 def process(self):
     total = len(self.files)
     if total > 0:
         print(self.files)
         workers = []
         print(1)
         cua = Queue(maxsize=total + 1)
         progreso = Progreso("Converting files...", None, total)
         total_workers = total if NUM_THREADS > total else NUM_THREADS
         for i in range(total_workers):
             worker = Worker(cua, self.convert_to)
             worker.connect("converted", progreso.increase)
             worker.start()
             workers.append(worker)
         print(2)
         for afile in self.files:
             cua.put(afile)
             # block until all tasks are done
         print(3)
         cua.join()
         # stop workers
         print(4)
         for i in range(total_workers):
             cua.put(None)
         for worker in workers:
             worker.join()
             while Gtk.events_pending():
                 Gtk.main_iteration()
         print(5)
Example #6
0
def on_ChooseButton_clicked(*args):
    ChooseDialog.hide()
    while Gtk.events_pending():
        Gtk.main_iteration()
    for row in choose_list:
        if row[0] is True:
            to_add.add(row[1].split(":")[0])  # split done in case of optdep choice
Example #7
0
 def Start(self, command_line):
     self.isclose = True
     if self.systype != "windows":
         tr1 = threading.Thread(None, self.MakeAction, name="t1", kwargs={"command": command_line})
         tr1.start()
         Gtk.main_quit()
     self.MakeAction(command_line)
    def _runSpoke(self, action):
        from gi.repository import Gtk

        # This duplicates code in widgets/src/BaseWindow.c, but we want to make sure
        # maximize gets called every time a spoke is displayed to prevent the 25%
        # UI from showing up.
        action.window.maximize()
        action.window.set_property("expand", True)

        action.refresh()

        action.window.set_transient_for(self.window)
        action.window.show_all()

        # Start a recursive main loop for this spoke, which will prevent
        # signals from going to the underlying (but still displayed) Hub and
        # prevent the user from switching away.  It's up to the spoke's back
        # button handler to kill its own layer of main loop.
        Gtk.main()
        action.window.set_transient_for(None)

        action._visitedSinceApplied = True

        # Don't take _visitedSinceApplied into account here.  It will always be
        # True from the line above.
        if action.changed and (not action.skipTo or (action.skipTo and action.applyOnSkip)):
            action.apply()
            action.execute()
            action._visitedSinceApplied = False
Example #9
0
 def _pack_archive(self, archive_path):
     """Create a new archive with the chosen files."""
     self.set_sensitive(False)
     self.get_window().set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
     while Gtk.events_pending():
         Gtk.main_iteration_do(False)
     image_files = self._image_area.get_file_listing()
     other_files = self._other_area.get_file_listing()
     try:
         tmp_path = tempfile.mkstemp(
             suffix=".%s" % os.path.basename(archive_path), prefix="tmp.", dir=os.path.dirname(archive_path)
         )[1]
         fail = False
     except:
         fail = True
     if not fail:
         packer = archive.Packer(
             image_files, other_files, tmp_path, os.path.splitext(os.path.basename(archive_path))[0]
         )
         packer.pack()
         packing_success = packer.wait()
         if packing_success:
             os.rename(tmp_path, archive_path)
             _close_dialog()
         else:
             fail = True
     if fail:
         self.get_window().set_cursor(None)
         dialog = Gtk.MessageDialog(
             self._window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, _("The new archive could not be saved!")
         )
         dialog.format_secondary_text(_("The original files have not been removed."))
         dialog.run()
         dialog.destroy()
         self.set_sensitive(True)
Example #10
0
def pbosf_render(style_context, cairo_context, pbosf, x, y):
    """Draws the PixbufOrSurface to the cairo context at (x, y)"""

    if isinstance(pbosf, GdkPixbuf.Pixbuf):
        Gtk.render_icon(style_context, cairo_context, pbosf, x, y)
    else:
        Gtk.render_icon_surface(style_context, cairo_context, pbosf, x, y)
Example #11
0
    def attach(self):

        config_home = Common.utils.XDG.CONFIG_HOME

        state_filename = os.path.join(config_home, "gst-debug-viewer", "state")

        self.state = AppState(state_filename)
        self.state_section = self.state.sections["state"]

        self.load_plugins()

        self.windows = []

        # we override expander size because of:
        # https://bugzilla.gnome.org/show_bug.cgi?id=615985
        rcstring = """
        style "no-expander-treeview-style" {
            GtkTreeView::expander_size = 1
            #GtkTreeView::vertical-separator = 0
            GtkWidget::focus-line-width = 0
        }
        
        widget "*.log_view" style "no-expander-treeview-style"
        """
        Gtk.rc_parse_string(rcstring)

        self.open_window()
Example #12
0
 def __init__(self, datadir, version, argv):
     self.file_path = datadir
     self.version = version
     self.editor = MenuEditor()
     Gtk.Window.set_default_icon_name("mozo")
     self.tree = Gtk.Builder()
     self.tree.set_translation_domain(GETTEXT_PACKAGE)
     self.tree.add_from_file(os.path.join(self.file_path, "mozo.ui"))
     self.tree.connect_signals(self)
     self.setupMenuTree()
     self.setupItemTree()
     self.tree.get_object("edit_delete").set_sensitive(False)
     self.tree.get_object("edit_revert_to_original").set_sensitive(False)
     self.tree.get_object("edit_properties").set_sensitive(False)
     self.tree.get_object("move_up_button").set_sensitive(False)
     self.tree.get_object("move_down_button").set_sensitive(False)
     self.tree.get_object("new_separator_button").set_sensitive(False)
     self.tree.get_object("properties_button").set_sensitive(False)
     self.tree.get_object("delete_button").set_sensitive(False)
     accelgroup = Gtk.AccelGroup()
     keyval, modifier = Gtk.accelerator_parse("<Ctrl>Z")
     accelgroup.connect(keyval, modifier, Gtk.AccelFlags.VISIBLE, self.on_mainwindow_undo)
     keyval, modifier = Gtk.accelerator_parse("<Ctrl><Shift>Z")
     accelgroup.connect(keyval, modifier, Gtk.AccelFlags.VISIBLE, self.on_mainwindow_redo)
     keyval, modifier = Gtk.accelerator_parse("F1")
     accelgroup.connect(keyval, modifier, Gtk.AccelFlags.VISIBLE, self.on_help_button_clicked)
     self.tree.get_object("mainwindow").add_accel_group(accelgroup)
Example #13
0
def main():
    global browser
    global window

    frontend = frontend_fill()

    window = gtk.Window()
    window.connect("destroy", gtk.main_quit)
    window.set_title("Linux Lite Control Center")
    window.set_icon(Pixbuf.new_from_file("{0}/litecc.png".format(app_dir)))
    window.set_size_request(880, 660)
    # Valtam do we need to resize window?
    window.set_resizable(False)
    window.set_position(gtk.WindowPosition.CENTER),
    browser = webkit.WebView()
    swindow = gtk.ScrolledWindow()
    window.add(swindow)
    swindow.add(browser)
    window.show_all()
    browser.connect("navigation-requested", functions)
    browser.load_html_string(frontend, "file://{0}/frontend/".format(app_dir))
    # no right click menu
    settings = browser.get_settings()
    settings.set_property("enable-default-context-menu", False)
    browser.set_settings(settings)
    # Engage
    gtk.main()
def run():
    # Protobuf
    #c = ControllerProtobuf()

    # Directly connected to the vision server
    c = VisionManager()
    
    if not c.is_connected():
        print("Vision server is not accessible.")
        return

    server = Server()
    server.start("127.0.0.1", 5030)

    # add observer output for "server"
    c.add_filter_output_observer(server.send)

    from gi.repository import Gtk, GObject
    import CapraVision.client.gtk.main
    GObject.threads_init()

    w = CapraVision.client.gtk.main.WinFilterChain(c)

    w.window.show_all()
    Gtk.main()

    # Close connection
    server.stop()
    c.close_server()
Example #15
0
def log_error(msg):
    ErrorDialog.format_secondary_text(msg)
    response = ErrorDialog.run()
    while Gtk.events_pending():
        Gtk.main_iteration()
    if response:
        ErrorDialog.hide()
Example #16
0
def run():
    utils.setproctitle("redshift-gtk")

    # Internationalisation
    gettext.bindtextdomain("redshift", defs.LOCALEDIR)
    gettext.textdomain("redshift")

    # Create redshift child process controller
    c = RedshiftController(sys.argv[1:])

    def terminate_child(data=None):
        c.terminate_child()
        return False

    # Install signal handlers
    GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, terminate_child, None)
    GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, terminate_child, None)

    try:
        # Create status icon
        s = RedshiftStatusIcon(c)

        # Run main loop
        Gtk.main()
    except:
        c.kill_child()
        raise
Example #17
0
def log_warning(msg):
    WarningDialog.format_secondary_text(msg)
    response = WarningDialog.run()
    while Gtk.events_pending():
        Gtk.main_iteration()
    if response:
        WarningDialog.hide()
Example #18
0
    def __init__(self):

        self.languages = {"English": "en", "Polski": "pl", "Español": "es", "Français": "fr", "Italiano": "it"}
        self.languages2 = ["English", "Polski", "Español", "Français", "Italiano"]
        self.notifications = ["LiSpeak", "System"]

        filename = "../Setup/templates/settings.glade"
        self.builder = Gtk.Builder()
        self.builder.add_from_file(filename)
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("window1")
        self.window.set_title("LiSpeak Settings")
        self.about = self.builder.get_object("aboutdialog1")
        self.aboutBtn = self.builder.get_object("btnAbout")
        self.aboutBtn.connect("clicked", self.aboutOpen)
        self.notebook = self.builder.get_object("notebook1")
        self.exit = self.builder.get_object("btnClose")
        self.exit.connect("button-release-event", self.close)
        try:
            self.addItems(self.builder.get_object("cmbEngine"), ["espeak", "Google TTS", "pico2wave"])
            self.addItems(self.builder.get_object("cmbLang"), self.languages2)
            self.addItems(self.builder.get_object("cmbNotifications"), self.notifications)
            self.fillFields(lispeak.getInfo())
            self.window.show_all()
        except KeyError:
            print "LiSpeak needs to be setup first"
            Gtk.main_quit()
Example #19
0
 def OnDialogOk(self, widget):
     if self.action:
         if self.action == "onRun":
             if self.time:
                 self.OnTimer("Start")
                 self.dialog.hide()
             else:
                 self.SaveSettings()
                 self.Start(self.GetParms())
                 self.runed = True
                 self.dialog.hide()
         elif self.action == "onExit":
             if not self.runed:
                 self.SaveSettings()
                 del self.trayicon
                 self.isclose = True
                 self.dialog.destroy()
                 Gtk.main_quit()
             else:
                 self.Stop()
                 self.SaveSettings()
                 del self.trayicon
                 self.isclose = True
                 self.dialog.destroy()
                 Gtk.main_quit()
Example #20
0
    def __init__(self):
        filename = "../Setup/templates/popup.glade"
        self.builder = Gtk.Builder()
        self.builder.add_from_file(filename)
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("window1")
        self.title = self.builder.get_object("lblTitle")
        self.message = self.builder.get_object("lblMessage")
        self.titleBox = self.builder.get_object("labelbox")
        self.titleBox.connect("button-release-event", self.on_clicked)
        self.exit = self.builder.get_object("exitbox")
        self.exit.connect("button-release-event", self.close_notify)
        self.icon = self.builder.get_object("imgIcon")
        self.window.set_gravity(gdk.Gravity.NORTH_WEST)
        self.display = False
        self.window.set_keep_above(True)
        self.counter = 0
        self.counter2 = 0
        self.counting = False
        self.queue = []

        self.info = lispeak.getInfo()

        gobject.timeout_add_seconds(1, self.timer)
        try:
            gobject.timeout_add_seconds(0.2, self.display_notify)
        except:
            print "Reverting to 1 second check"
            gobject.timeout_add_seconds(1, self.display_notify)
        gobject.timeout_add_seconds(30, self.message_system)
        while gtk.events_pending():
            gtk.main_iteration_do(True)
        self.message_system()
 def close(self, *obj):
     """
     Close the assistant.
     """
     self.hide()
     if self.ownthread:
         Gtk.main_quit()
Example #22
0
 def update_accelerator_label(self):
     if self.current_node.shortcut:
         key, mods = Gtk.accelerator_parse(self.current_node.shortcut)
         label = Gtk.accelerator_get_label(key, mods)
         self["accelerator"].set_text(label)
     else:
         self["accelerator"].set_text("")
Example #23
0
    def _load_active_document_symbols(self):
        """ Load the symbols for the given URI. """
        self._sourcetree.clear()
        self._is_loaded = False
        # do not load if not the active tab in the panel
        panel = self.window.get_side_panel()
        if not panel.item_is_active(self._sourcetree):
            return

        document = self.window.get_active_document()
        if document:
            location = document.get_location()
            if location:
                uri = location.get_uri()
                self._log.debug("Loading %s...", uri)
                if uri is not None:
                    if uri[:7] == "file://":
                        # use get_parse_name() to get path in UTF-8
                        filename = location.get_parse_name()
                        self._sourcetree.parse_file(filename, uri)
                    elif self.load_remote_files:
                        basename = location.get_basename()
                        fd, filename = tempfile.mkstemp("." + basename)
                        contents = document.get_text(document.get_start_iter(), document.get_end_iter(), True)
                        os.write(fd, contents)
                        os.close(fd)
                        while Gtk.events_pending():
                            Gtk.main_iteration()
                        self._sourcetree.parse_file(filename, uri)
                        os.unlink(filename)
                    self._loaded_document = document
        self._is_loaded = True
Example #24
0
def quit(widget, event):

    # saving login url
    check_updates = "TRUE" if switch.get_active() == True else "FALSE"

    db.execute("delete from Settings")

    db.execute(
        'INSERT INTO Settings VALUES("{}","{}","{}","{}")'.format(
            check_updates, url_entry.get_text(), id_entry.get_text(), password_entry.get_text()
        )
    )

    if changed == 1:
        db.execute("delete from Pages")

        # saving pages
        for row in store:
            db.execute('INSERT INTO Pages VALUES("{}","{}","{}")'.format(row[0], row[1], 0))
    try:
        # set startup
        if switch.get_active() == True:

            autostart_dir = os.getenv("HOME") + "/.config/autostart"
            if not os.path.exists(autostart_dir):
                os.makedirs(autostart_dir)

            os.symlink(
                "/usr/share/moodle-monitor/moodled.desktop",
                "{}/.config/autostart/moodled.desktop".format(os.getenv("HOME")),
            )
        else:
            os.unlink("{}/.config/autostart/moodled.desktop".format(os.getenv("HOME")))
    finally:
        Gtk.main_quit()
 def decrease(self):
     self.value -= 1.0
     fraction = self.value / self.max_value
     self.progressbar.set_fraction(fraction)
     self.map()
     while Gtk.events_pending():
         Gtk.main_iteration()
Example #26
0
    def do_draw(self, cr):
        """Render a background that fits the allocated space."""
        allocation = self.get_allocation()
        context = self.get_style_context()
        Gtk.render_background(context, cr, 0, 0, allocation.width, allocation.height)

        EventIcon.do_draw(self, cr)
Example #27
0
    def build_search_box(self):
        self.search_bar_box = ca.new_widget("HBox", {"size_request": (-1, -1), "show": True})

        self.search_bar = ca.new_widget("Entry", {"size_request": (self.window.width / 2, 50), "show": True})
        Gtk.rc_parse_string(
            """style "search-bar-font" { font_name="Sans 20" } class "GtkEntry"  style "search-bar-font" """
        )

        self.search_button = ca.new_widget("Button", {"label": "Search", "size_request": (-1, -1), "show": True})
        self.search_button.connect("clicked", self.submit_query)

        self.init_search_source()
        self.init_search_api()

        self.results_vbox = ca.new_widget(
            "VBox", {"size_request": (int(3 * (self.window.width / 2)), -1), "show": True}
        )

        self.search_bar_box.pack_start(self.search_bar, False, False, 0)
        self.search_bar_box.pack_start(self.search_button, False, False, 0)
        self.search_bar_box.pack_start(self.search_source, False, False, 0)
        self.search_bar_box.pack_start(self.search_source_api, False, False, 0)
        self.search_vbox.pack_start(self.search_bar_box, False, False, 0)
        self.search_vbox.pack_start(self.results_vbox, True, False, 0)
        self.main_layout.put(self.search_vbox, 0, 0)
Example #28
0
def _test():
    """Run interactive tests, outside the application."""
    logging.basicConfig()
    win = BrushEditorWindow()
    win.connect("delete-event", lambda *a: Gtk.main_quit())
    win.show_all()
    Gtk.main()
        def destroy(self, window):
            try:
                self.conn.destroy()
            except AttributeError:
                pass

            Gtk.main_quit()
Example #30
0
    def set_pass(self, header="", total=100, mode=MODE_FRACTION):
        """
        Reset for another pass. Provide a new header and define number
        of steps to be used.
        """

        from gi.repository import Gtk

        self.__mode = mode
        self.__pbar_max = total
        self.__pbar_index = 0.0

        # If it is cancelling, don't overwite that message:
        if not self.__cancelled:
            self.__lbl.set_text(header)
            if header == "":
                self.__lbl.hide()
            else:
                self.__lbl.show()

        if self.__mode is ProgressMeter.MODE_FRACTION:
            self.__pbar.set_fraction(0.0)
        else:  # ProgressMeter.MODE_ACTIVITY
            self.__pbar.set_pulse_step(1.0 / self.__pbar_max)

        while Gtk.events_pending():
            Gtk.main_iteration()