Esempio n. 1
0
 def do_get_iter(self, path):
     seq = []
     base = self.h5file
     if len(path.get_indices()) > 1:
         for i in path.get_indices()[1:]:
             if base is None or i >= len(base):
                 return (False, None)
             sorted_keys = sorted(list(base.keys()))
             seq.append(sorted_keys[i])
             base = base[sorted_keys[i]]
     seq = tuple(seq)
     self.pool[abshash(seq)] = seq
     iter = Gtk.TreeIter()
     iter.user_data = abshash(seq)
     iter.user_data2 = 42
     return (True, iter)
    def enabled_languages(self, model, path, piter, ret):
        enabled = model.get_value(piter, self.COLUMN_ENABLED)

        if path.get_indices()[0] == 0 and enabled:
            return True

        if enabled:
            ret.append(model.get_value(piter, self.COLUMN_ID))

        return False
Esempio n. 3
0
    def enabled_languages(self, model, path, piter, ret):
        enabled = model.get_value(piter, self.COLUMN_ENABLED)

        if path.get_indices()[0] == 0 and enabled:
            return True

        if enabled:
            ret.append(model.get_value(piter, self.COLUMN_ID))

        return False
Esempio n. 4
0
    def on_button_press_event(self, widget, event):
        if event.button == 3:
            data = widget.get_path_at_pos(int(event.x),int(event.y))
            res = False
            if data:
                sel=[]
                path, col, cx, cy=data
                indices = path.get_indices()
                iter = self.modelfilter.get_iter(path)

                for i in self.treeview.get_selection().get_selected_rows()[1]:
                    sel.append(i.get_indices()[0])

                if sel:
                    popup = Gtk.Menu()
                    popup.attach_to_widget(self.treeview, None)

                    uuid = self.modelfilter.get_value(iter, 0)
                    name = self.modelfilter.get_value(iter, 5)

                    if self.modelfilter.get_value(iter, 2) > 0:
                        item = Gtk.MenuItem(_("Remove all from panel"))
                        item.connect('activate', lambda x: self.disable_applet(uuid))
                        popup.add(item)

                        checked = self.modelfilter.get_value(iter, 2)
                        max_instances = self.modelfilter.get_value(iter, 3);
                        can_instance = max_instances == -1 or ((max_instances > 0) and (max_instances > checked))
                        if can_instance:
                            item = Gtk.MenuItem(_("Add to panel"))
                            item.connect('activate', lambda x: self.instance_applet(uuid))
                            popup.add(item)
                    else:
                        item = Gtk.MenuItem(_("Add to panel"))
                        item.connect('activate', lambda x: self.enable_applet(uuid))
                        popup.add(item)
                        
                    
                    item = Gtk.MenuItem(_("Uninstall"))
                    if self.modelfilter.get_value(iter, 6):
                        item.connect('activate', lambda x: self.uninstall_applet(uuid, name))
                        item.set_sensitive(True)
                    else:
                        item.set_sensitive(False)
                    popup.add(item)

                    #popup.add(item)
                    popup.show_all()
                    popup.popup(None, None, None, None, event.button, event.time)

                # Only allow context menu for currently selected item
                if indices[0] not in sel:
                    return False

            return True
Esempio n. 5
0
    def on_button_press_event(self, widget, event):
        if event.button == 3:
            data = widget.get_path_at_pos(int(event.x),int(event.y))
            res = False
            if data:
                sel=[]
                path, col, cx, cy=data
                indices = path.get_indices()
                iter = self.modelfilter.get_iter(path)

                for i in self.treeview.get_selection().get_selected_rows()[1]:
                    sel.append(i.get_indices()[0])

                if sel:
                    popup = Gtk.Menu()
                    popup.attach_to_widget(self.treeview, None)

                    uuid = self.modelfilter.get_value(iter, 0)
                    name = self.modelfilter.get_value(iter, 5)

                    if self.modelfilter.get_value(iter, 2) > 0:
                        item = Gtk.MenuItem(_("Remove all from panel"))
                        item.connect('activate', lambda x: self.disable_applet(uuid))
                        popup.add(item)

                        checked = self.modelfilter.get_value(iter, 2)
                        max_instances = self.modelfilter.get_value(iter, 3);
                        can_instance = max_instances == -1 or ((max_instances > 0) and (max_instances > checked))
                        if can_instance:
                            item = Gtk.MenuItem(_("Add to panel"))
                            item.connect('activate', lambda x: self.instance_applet(uuid))
                            popup.add(item)
                    else:
                        item = Gtk.MenuItem(_("Add to panel"))
                        item.connect('activate', lambda x: self.enable_applet(uuid))
                        popup.add(item)
                        
                    
                    item = Gtk.MenuItem(_("Uninstall"))
                    if self.modelfilter.get_value(iter, 6):
                        item.connect('activate', lambda x: self.uninstall_applet(uuid, name))
                        item.set_sensitive(True)
                    else:
                        item.set_sensitive(False)
                    popup.add(item)

                    #popup.add(item)
                    popup.show_all()
                    popup.popup(None, None, None, None, event.button, event.time)

                # Only allow context menu for currently selected item
                if indices[0] not in sel:
                    return False

            return True
Esempio n. 6
0
    def on_project_treeview_row_activated(self, widget, path, column):
        pth = self.project_treeview.convert_indices_to_path(path.get_indices())
        fpth = wayround_i2p.utils.path.join(
            self.project_treeview.get_root_directory(), pth)

        if os.path.isfile(fpth):
            self.open_file(fpth)

        if self.source_view is not None:
            self.source_view.grab_focus()
        return
Esempio n. 7
0
 def on_activate_row(self, widget, path, column):
     inx, = path.get_indices()
     # XXX cheesy assumption edge is an import
     if self.edge_type is self.OUTGOING:
         path = self.edges[inx].dest.path
     elif self.edge_type is self.INCOMING:
         path = self.edges[inx].source.path
     else:
         raise NotImplementedError()
         
     self.emit('location-selected', UILocation(node.Location(path, 0, 0)))
Esempio n. 8
0
        def on_remove_clicked(widget):
            [list, iter] = self.profiles.get_selection().get_selected()

            path = list.get_path(iter)
            list.row_deleted(path)
            profiles = self._settings.get_value("profiles").unpack()
            index = path.get_indices()[0]
            # Original JavaScript code.
            # profiles[self.profiles_combo_box.get_active_text()].splice(path.get_indices(), 1)
            profiles[self.profiles_combo_box.get_active_text()] = profiles[self.profiles_combo_box.get_active_text()][
                :index] + profiles[self.profiles_combo_box.get_active_text()][index + 1:]
            self._settings.set_value("profiles", GLib.Variant("a{sa(sb)}", profiles))
            self.remove.set_sensitive(False)
Esempio n. 9
0
    def tool_in_language(self, tool, lang):
        if not lang in self._languages:
            return False

        ref = self._languages[lang]
        parent = ref.get_path()

        for row in self._tool_rows[tool]:
            path = row.get_path()

            if path.get_indices()[0] == parent.get_indices()[0]:
                return True

        return False
    def tool_in_language(self, tool, lang):
        if not lang in self._languages:
            return False

        ref = self._languages[lang]
        parent = ref.get_path()

        for row in self._tool_rows[tool]:
            path = row.get_path()

            if path.get_indices()[0] == parent.get_indices()[0]:
                return True

        return False
Esempio n. 11
0
        def on_remove_clicked(widget):
            [list, iter] = self.profiles.get_selection().get_selected()

            path = list.get_path(iter)
            list.row_deleted(path)
            profiles = self._settings.get_value("profiles").unpack()
            index = path.get_indices()[0]
            # Original JavaScript code.
            # profiles[self.profiles_combo_box.get_active_text()].splice(path.get_indices(), 1)
            profiles[self.profiles_combo_box.get_active_text()] = profiles[
                self.profiles_combo_box.get_active_text()][:index] + profiles[
                    self.profiles_combo_box.get_active_text()][index + 1:]
            self._settings.set_value("profiles",
                                     GLib.Variant("a{sa(sb)}", profiles))
            self.remove.set_sensitive(False)
Esempio n. 12
0
        def on_item_acivated(self, widget, path, column):

            m = self.get_model()

            pth = self.convert_indices_to_path(path.get_indices())

            fpth = wayround_i2p.utils.path.join(self._root_dir, pth)

            if os.path.isdir(fpth):

                self.load_dir(m.get_iter(path), fpth)

                if m.iter_has_child(m.get_iter(path)):
                    self.expand_row(path, False)
                    self.scroll_to_cell(path, None, True, 0.5, 0.0)

            return
Esempio n. 13
0
        def get_selected_path(self):

            sel = self.get_selection()

            model, itera = sel.get_selected()

            ret = self.get_root_directory()

            if itera:

                path = model.get_path(itera)

                pth = self.convert_indices_to_path(path.get_indices())

                ret = wayround_i2p.utils.path.join(self._root_dir, pth)

            return ret
Esempio n. 14
0
    def gtk_tree_model_get_iter_parent(treemodel, itera):

        path = treemodel.get_path(itera)

        indices = path.get_indices()

        ret = None

        len_indices = len(indices)

        if len_indices > 1:

            if len_indices == 1:
                path = Gtk.TreePath.new_first()
            else:
                path = Gtk.TreePath(indices[:-1])

            ret = treemodel.get_iter(path)

        return ret
Esempio n. 15
0
    def on_key_press_treeview(self, widget, event, treeview):
        """Handle keypress event"""
        keyname = event.get_keyval()[1]
        state = event.get_state()
        shift_pressed = bool(state & Gdk.ModifierType.SHIFT_MASK)

        if keyname in [Gdk.KEY_Alt_L, Gdk.KEY_Alt_R,
                       Gdk.KEY_Escape]:  # unselect all
            self.tree.get_selection().unselect_all()
            return

        if bool(state & Gdk.ModifierType.CONTROL_MASK):
            if keyname in (Gdk.KEY_c, Gdk.KEY_C):
                self.on_copy()
            elif keyname in (Gdk.KEY_v, Gdk.KEY_V):
                self.on_paste()
            return

        path, col = treeview.get_cursor()
        if path != None:
            columns = [c for c in treeview.get_columns()]
            colnum = columns.index(col)
            rownum = path.get_indices()[0]
            store = treeview.get_model()
            if col in columns:
                if keyname in [Gdk.KEY_Tab, Gdk.KEY_ISO_Left_Tab]:
                    if shift_pressed == 1:
                        # Search over editable states
                        for row in range(rownum, -1, -1):
                            # Determine starting column
                            # For same row
                            if row == rownum:
                                end = (colnum - 1) + 9
                            # For different row
                            else:
                                end = 15
                            for col in range(end, 8, -1):
                                if self.store[row][col] == True:
                                    prev_column = columns[col - 9]
                                    path = Gtk.TreePath.new_from_indices([row])
                                    treeview.scroll_to_cell(
                                        path, prev_column, False)
                                    if row == rownum:
                                        GLib.idle_add(treeview.set_cursor,
                                                      path, prev_column, True)
                                    else:
                                        GLib.timeout_add(
                                            200, treeview.set_cursor, path,
                                            prev_column, True)
                                    return
                    else:
                        # Search over editable states
                        for row in range(rownum, len(store)):
                            # Determine starting column
                            # For same row
                            if row == rownum:
                                start = (colnum + 1) + 9
                            # For different row
                            else:
                                start = 9
                            for col in range(start, 15):
                                if self.store[row][col] == True:
                                    next_column = columns[col - 9]
                                    path = Gtk.TreePath.new_from_indices([row])
                                    treeview.scroll_to_cell(
                                        path, next_column, False)
                                    if row == rownum:
                                        GLib.idle_add(treeview.set_cursor,
                                                      path, next_column, True)
                                    else:
                                        GLib.timeout_add(
                                            200, treeview.set_cursor, path,
                                            next_column, True)
                                    return
Esempio n. 16
0
    def correct_all(self, model, path, piter, enabled):
        if path.get_indices()[0] == 0:
            return False

        model.set_value(piter, self.COLUMN_ENABLED, enabled)
    def correct_all(self, model, path, piter, enabled):
        if path.get_indices()[0] == 0:
            return False

        model.set_value(piter, self.COLUMN_ENABLED, enabled)
Esempio n. 18
0
    def gm_on_button_press_event(self, widget, event):
        if event.button == 1:
            data=widget.get_path_at_pos(int(event.x),int(event.y))
            if data:
                path, column, x, y = data
                if column.get_property('title')==_("Action"):
                    iter = self.gm_modelfilter.get_iter(path)
                    uuid = self.gm_modelfilter.get_value(iter, 0)
                    self.gm_view_details(uuid)
                    return False


        if event.button == 3:
            data = widget.get_path_at_pos(int(event.x),int(event.y))
            res = False
            if data:
                sel=[]
                path, col, cx, cy=data
                indices = path.get_indices()
                iter = self.gm_modelfilter.get_iter(path)

                for i in self.gm_treeview.get_selection().get_selected_rows()[1]:
                    sel.append(i.get_indices()[0])

                if sel:
                    popup = Gtk.Menu()
                    popup.attach_to_widget(self.treeview, None)

                    uuid = self.gm_modelfilter.get_value(iter, 0)
                    name = self.gm_modelfilter.get_value(iter, 5)
                    marked = self.gm_modelfilter.get_value(iter, 2)

                    if (marked):
                        item = Gtk.MenuItem(_("Unmark"))
                        popup.add(item)
                        item.connect('activate', lambda x: self.gm_mark(uuid, False))
                    else:
                        item = Gtk.MenuItem(_("Mark for installation"))
                        popup.add(item)
                        item.connect('activate', lambda x: self.gm_mark(uuid, True))
                    

                    item = Gtk.MenuItem(_("More info"))
                    item.connect('activate', lambda x: self.gm_view_details(uuid))
                    popup.add(item)

                    #item = Gtk.MenuItem(_("Homepage.."))
                    #item.connect('activate', lambda x: self.gm_launch_homepage(uuid))
                    #popup.add(item)

                    #item = Gtk.MenuItem(_("Review.."))
                    #item.connect('activate', lambda x: self.gm_view_on_spices(uuid))
                    #popup.add(item)

                    popup.show_all()
                    popup.popup(None, None, None, None, event.button, event.time)

                # Only allow context menu for currently selected item
                if indices[0] not in sel:
                    return False

            return True
Esempio n. 19
0
    def gm_on_button_press_event(self, widget, event):
        if event.button == 1:
            data=widget.get_path_at_pos(int(event.x),int(event.y))
            if data:
                path, column, x, y = data
                if column.get_property('title')==_("Action"):
                    iter = self.gm_modelfilter.get_iter(path)
                    uuid = self.gm_modelfilter.get_value(iter, 0)
                    self.gm_view_details(uuid)
                    return False


        if event.button == 3:
            data = widget.get_path_at_pos(int(event.x),int(event.y))
            res = False
            if data:
                sel=[]
                path, col, cx, cy=data
                indices = path.get_indices()
                iter = self.gm_modelfilter.get_iter(path)

                for i in self.gm_treeview.get_selection().get_selected_rows()[1]:
                    sel.append(i.get_indices()[0])

                if sel:
                    popup = Gtk.Menu()
                    popup.attach_to_widget(self.treeview, None)

                    uuid = self.gm_modelfilter.get_value(iter, 0)
                    name = self.gm_modelfilter.get_value(iter, 5)
                    marked = self.gm_modelfilter.get_value(iter, 2)

                    if (marked):
                        item = Gtk.MenuItem(_("Unmark"))
                        popup.add(item)
                        item.connect('activate', lambda x: self.gm_mark(uuid, False))
                    else:
                        item = Gtk.MenuItem(_("Mark for installation"))
                        popup.add(item)
                        item.connect('activate', lambda x: self.gm_mark(uuid, True))
                    

                    item = Gtk.MenuItem(_("More info"))
                    item.connect('activate', lambda x: self.gm_view_details(uuid))
                    popup.add(item)

                    #item = Gtk.MenuItem(_("Homepage.."))
                    #item.connect('activate', lambda x: self.gm_launch_homepage(uuid))
                    #popup.add(item)

                    #item = Gtk.MenuItem(_("Review.."))
                    #item.connect('activate', lambda x: self.gm_view_on_spices(uuid))
                    #popup.add(item)

                    popup.show_all()
                    popup.popup(None, None, None, None, event.button, event.time)

                # Only allow context menu for currently selected item
                if indices[0] not in sel:
                    return False

            return True
 def selected_filter(self):
     model, iterator = self.lstFilters.get_selection().get_selected()
     if iterator is None:
         return None
     path = model.get_path(iterator)
     return self.controler.get_filter_from_index(path.get_indices()[0])