Exemple #1
0
 def __init__(self, parent, text=""):
     GObject.GObject.__init__(self, use_header_bar=True)
     self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
     self.add_button(_("_OK"), Gtk.ResponseType.OK)
     self.set_default_response(Gtk.ResponseType.OK)
     self.set_transient_for(parent)
     header = self.get_header_bar()
     header.set_title(_("Edit File Patterns"))
     header.set_subtitle(_("Use shell-style wildcards * and **"))
     self.text_view = Gtk.TextView()
     self.text_view.set_accepts_tab(False)
     self.text_view.set_bottom_margin(6)
     self.text_view.set_left_margin(6)
     self.text_view.set_pixels_below_lines(6)
     self.text_view.set_right_margin(6)
     self.text_view.set_top_margin(6)
     self.text_view.set_wrap_mode(Gtk.WrapMode.NONE)
     self.text_view.get_style_context().add_class("monospace")
     scroller = Gtk.ScrolledWindow()
     scroller.set_policy(*((Gtk.PolicyType.AUTOMATIC, ) * 2))
     scroller.set_shadow_type(Gtk.ShadowType.NONE)
     scroller.set_size_request(600, 371)
     scroller.add(self.text_view)
     content = self.get_content_area()
     content.add(scroller)
     text_buffer = self.text_view.get_buffer()
     text_buffer.set_text(text)
     self.show_all()
Exemple #2
0
 def __init__(self):
     self.label = Gtk.Label(label=_("Files scan interval"))
     self.spin = Gtk.SpinButton()
     self.spin.set_increments(1, 5)
     self.spin.set_range(1, 1440)
     self.unit = Gtk.Label(label=_("minutes"))
     self.widget = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                           spacing=12)
     self.widget.pack_start(self.spin, expand=False, fill=False, padding=0)
     self.widget.pack_start(self.unit, expand=False, fill=False, padding=0)
Exemple #3
0
 def __init__(self):
     self.label = Gtk.Label(label=_("Theme"))
     self.widget = Gtk.ComboBoxText()
     themes = catapult.util.list_themes()
     self.themes = sorted(x[0] for x in themes)
     for name in self.themes:
         self.widget.append_text(name)
Exemple #4
0
 def __init__(self, window):
     GObject.GObject.__init__(self)
     self.items = []
     self.set_border_width(18)
     self.set_title(_("Preferences"))
     grid = Gtk.Grid()
     grid.set_column_spacing(18)
     grid.set_row_spacing(12)
     items = [x() for x in self.ITEMS]
     # Add switches for all custom plugins found.
     # TODO: We'll probably eventually want to put these on
     # a separate page of a Gtk.StackSwitcher or something.
     for name, module in catapult.util.list_custom_plugins():
         items.append(CustomPlugin(name))
     for i, item in enumerate(items):
         item.dump(window)
         item.label.set_xalign(1)
         item.label.get_style_context().add_class("dim-label")
         grid.attach(item.label, 0, i, 1, 1)
         box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
         box.pack_start(item.widget, expand=False, fill=False, padding=0)
         grid.attach(box, 1, i, 1, 1)
         self.items.append(item)
     content = self.get_content_area()
     content.add(grid)
     self.show_all()
     self.set_position_offset(0.5, 0.2)
Exemple #5
0
 def _on_activate(self, app, args):
     if self.get_windows():
         # If already running, show the existing window.
         return self.get_active_window().show()
     args = self._parse_arguments(args)
     window = catapult.Window()
     self.add_window(window)
     if args.show:
         window.show()
     print(_("Catapult ready, use {} to engage")
           .format(catapult.conf.toggle_key))
Exemple #6
0
    def _parse_arguments(self, args):
        parser = ArgumentParser(usage=_("catapult [OPTION...]"))
        parser.add_argument("--debug",
                            action="store_true",
                            dest="debug",
                            default=False,
                            help=_("print details of indexing and search results"))

        parser.add_argument("--show",
                            action="store_true",
                            dest="show",
                            default=False,
                            help=_("show window immediately"))

        parser.add_argument("--version",
                            action="version",
                            version=f"catapult {catapult.__version__}")

        args = parser.parse_args()
        catapult.DEBUG = args.debug
        return args
Exemple #7
0
    def __init__(self, parent):
        GObject.GObject.__init__(self)
        self.set_artists(("Osmo Salomaa <*****@*****.**>",))
        self.set_authors(("Osmo Salomaa <*****@*****.**>",))
        self.set_comments(_("App launcher"))
        self.set_copyright("Copyright © 2021 Osmo Salomaa")
        self.set_license_type(Gtk.License.GPL_3_0)
        self.set_logo_icon_name("io.otsaloma.catapult")
        self.set_program_name("Catapult")
        self.set_title(_("About Catapult"))
        self.set_version(catapult.__version__)
        self.set_website("https://otsaloma.io/catapult")
        self.set_website_label("https://otsaloma.io/catapult")

        # TRANSLATORS: This is a special message that shouldn't be translated
        # literally. It is used in the about dialog to give credits to the
        # translators. Thus, you should translate it to your name and email
        # address. You can also include other translators who have contributed
        # to this translation; in that case, please write them on separate
        # lines seperated by newlines (\n).
        self.set_translator_credits(_("translator-credits"))

        self.set_position_offset(0.5, 0.2)
Exemple #8
0
 def __init__(self, plugin):
     title = plugin.replace("_", " ").title()
     self.label = Gtk.Label(label=_("{} plugin").format(title))
     self.plugin = plugin
     self.widget = Gtk.Switch()
Exemple #9
0
 def __init__(self):
     self.label = Gtk.Label(label=_("Calculator plugin"))
     self.widget = Gtk.Switch()
Exemple #10
0
 def __init__(self):
     self.label = Gtk.Label(label=_("Files exclude patterns"))
     self.widget = Gtk.Button()
     self.widget.set_label(_("Edit"))
     self.widget.connect("clicked", self._on_clicked)
Exemple #11
0
 def __init__(self):
     self.label = Gtk.Label(label=_("Files plugin"))
     self.widget = Gtk.Switch()
Exemple #12
0
 def __init__(self):
     self.label = Gtk.Label(label=_("Session plugin"))
     self.widget = Gtk.Switch()
Exemple #13
0
 def __init__(self):
     self.label = Gtk.Label(label=_("Activation key"))
     self.widget = Gtk.Entry()
     self.widget.catapult_key = None
     self.widget.connect("key-press-event", self._on_key_press_event)
Exemple #14
0
 def search(self, query):
     query = query.lower().strip()
     if not query.startswith(":"): return
     icon = catapult.util.lookup_icon(
         "io.otsaloma.catapult",
         "application-x-executable",
     )
     if ":about".startswith(query):
         self.debug(f"Found :about for {query!r}")
         yield catapult.SearchResult(
             description=_("About Catapult"),
             fuzzy=False,
             icon=icon,
             id=":about",
             offset=0,
             plugin=self,
             score=1,
             title=":about",
         )
     if ":preferences".startswith(query):
         self.debug(f"Found :preferences for {query!r}")
         yield catapult.SearchResult(
             description=_("Catapult preferences"),
             fuzzy=False,
             icon=icon,
             id=":preferences",
             offset=0,
             plugin=self,
             score=1,
             title=":preferences",
         )
     if ":reload-plugins".startswith(query):
         self.debug(f"Found :reload-plugins for {query!r}")
         yield catapult.SearchResult(
             description=_("Reload plugins"),
             fuzzy=False,
             icon=icon,
             id=":reload-plugins",
             offset=0,
             plugin=self,
             score=1,
             title=":reload-plugins",
         )
     if ":reload-theme".startswith(query):
         self.debug(f"Found :reload-theme for {query!r}")
         yield catapult.SearchResult(
             description=_("Reload theme"),
             fuzzy=False,
             icon=icon,
             id=":reload-theme",
             offset=0,
             plugin=self,
             score=1,
             title=":reload-theme",
         )
     if ":quit".startswith(query):
         self.debug(f"Found :quit for {query!r}")
         yield catapult.SearchResult(
             description=_("Quit Catapult"),
             fuzzy=False,
             icon=icon,
             id=":quit",
             offset=0,
             plugin=self,
             score=1,
             title=":quit",
         )
     if ":update".startswith(query):
         self.debug(f"Found :update for {query!r}")
         yield catapult.SearchResult(
             description=_("Update search index"),
             fuzzy=False,
             icon=icon,
             id=":update",
             offset=0,
             plugin=self,
             score=1,
             title=":update",
         )
Exemple #15
0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import catapult
import subprocess

from catapult.i18n import _

ACTIONS = [{
    "desktops": ["GNOME"],
    "titles":   [_("Lock Screen")],
    "command":  "gnome-screensaver-command --lock",
}, {
    "desktops": ["GNOME"],
    "titles":   [_("Log Out"), _("Log Off")],
    "command":  "gnome-session-quit --logout",
}, {
    "desktops": ["GNOME"],
    "titles":   [_("Power Off"), _("Shutdown")],
    "command":  "gnome-session-quit --power-off",
}, {
    "desktops": ["GNOME"],
    "titles":   [_("Reboot"), _("Restart")],
    "command":  "gnome-session-quit --reboot",
}]