Ejemplo n.º 1
0
    def __init__(self):
        Gtk.Box.__init__(self, False, 0)

        try:
            current_locale, encoding = locale.getdefaultlocale()
            locale_path = os.path.join(
                os.path.abspath(os.path.dirname(__file__)), 'locale')
            translate = gettext.translation(cn.App.application_shortname,
                                            locale_path, [current_locale])
            _ = translate.gettext
        except FileNotFoundError:
            _ = str

        # Create welcome widget
        welcome = Granite.WidgetsWelcome()
        welcome = welcome.new("Welcome", cn.App.application_description)

        # Welcome voices
        welcome.append("object-inverse", _('Dark Mode'),
                       _('Switch to the dark side'))
        welcome.append("utilities-terminal", _('Open Terminal'),
                       _('Just an example of action'))
        welcome.append("help-contents", _('Info'),
                       _('Learn more about this application'))

        welcome.connect("activated", self.on_welcome_activated)

        self.add(welcome)
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.settings = Gtk.Settings.get_default()

        # main icon/logo
        icon = Gtk.Image()
        icon.set_from_icon_name("com.github.hezral.inspektor",
                                Gtk.IconSize.DIALOG)
        icon.set_pixel_size(128)
        icon.props.valign = Gtk.Align.END
        icon.props.halign = Gtk.Align.CENTER
        icon.props.margin = 15

        # welcome widget
        welcome_widget = Granite.WidgetsWelcome().new(
            "Movens", AppAttributes.application_description)
        welcome_widget.connect("activated", self.on_welcome_activated)

        # welcome menu
        welcome_widget.append("text-x-readme", "README", "Get started manual")
        welcome_widget.append("preferences-desktop", "Preferences",
                              "Configure Movens the way you want it")

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        box.props.margin = 40
        box.pack_start(icon, False, False, 0)
        box.pack_end(welcome_widget, True, True, 0)

        self.add(box)
Ejemplo n.º 3
0
    def __init__(self, parent):
        Gtk.Box.__init__(self, False, 0)
        self.parent = parent

        try:
            current_locale, encoding = locale.getdefaultlocale()
            locale_path = os.path.join(
                os.path.abspath(os.path.dirname(__file__)), 'locale')
            translate = gettext.translation(cn.App.application_shortname,
                                            locale_path, [current_locale])
            _ = translate.gettext
        except FileNotFoundError:
            _ = str

        # Create welcome widget
        self.welcome = Granite.WidgetsWelcome()
        self.welcome = self.welcome.new(cn.App.application_name,
                                        cn.App.application_description)

        # Welcome voices
        self.welcome.append("wine", _('New bottle'), _('Create a new bottle'))
        self.welcome.append("document-import", _('Import and convert'),
                            _('Import a third-party wineprefix'))
        self.welcome.append("gnome-mime-application-x-archive",
                            _('List bottles'), _('List all bottles'))

        self.welcome.connect("activated", self.on_welcome_activated)

        self.add(self.welcome)
Ejemplo n.º 4
0
    def __init__(self, parent):
        Gtk.Box.__init__(self, False, 0)
        self.parent = parent

        try:
            current_locale, encoding = locale.getdefaultlocale()
            locale_path = os.path.join(
                os.path.abspath(os.path.dirname(__file__)), 'locale')
            translate = gettext.translation(cn.App.application_shortname,
                                            locale_path, [current_locale])
            _ = translate.gettext
        except FileNotFoundError:
            _ = str

        # Create welcome widget
        welcome = Granite.WidgetsWelcome()
        welcome = welcome.new("Welcome", cn.App.application_description)

        # Welcome voices
        welcome.append("system-search-symbolic", _('New search'),
                       _('Find min of function'))
        welcome.append("help-contents",
                       _('What is the Golden Section Algorithm'),
                       _('Learn more about this algorithm'))

        welcome.connect("activated", self.on_welcome_activated)

        self.add(welcome)
Ejemplo n.º 5
0
    def __init__(self, parent: Gtk.Widget, text: str = None):
        super().__init__(modal=False)
        self.set_default_size(800, 600)
        self.set_transient_for(parent)

        self.header_overlay.add_overlay(self.header_revealer)
        self.header_revealer.set_reveal_child(True)

        # print_button = Gtk.Button.new_from_icon_name('document-print', Gtk.IconSize.LARGE_TOOLBAR)
        # print_button.set_tooltip_markup(Granite.markup_accel_tooltip(None, _('Print document')))
        # print_button.connect('clicked', lambda x: self.emit('print'))

        # self.spinner = Gtk.Spinner(visible=False)
        #
        # header = Gtk.HeaderBar(title=_("Preview"))
        # header.set_has_subtitle(False)
        # header.set_show_close_button(True)
        # header.get_style_context().add_class('norka-header')
        #
        # header.pack_start(self.spinner)
        # header.pack_end(print_button)

        # self.set_titlebar(header)

        self.temp_file = tempfile.NamedTemporaryFile(prefix='norka-',
                                                     delete=False)

        # Render in thread
        if text:
            GObjectWorker.call(Exporter.export_html_preview,
                               (self.temp_file.name, text, True),
                               self.update_html)

        ctx = WebKit2.WebContext.get_default()
        self.web: WebKit2.WebView = WebKit2.WebView.new_with_context(ctx)
        self.web.connect('load-changed', self.on_load_changed)
        web_settings = self.web.get_settings()
        web_settings.set_enable_developer_extras(False)
        web_settings.set_enable_tabs_to_links(False)
        self.web.set_settings(web_settings)

        self.empty = Granite.WidgetsWelcome()
        self.empty.set_title(_('Nothing to preview'))
        self.empty.set_subtitle(_('To render preview open a document'))

        # self.stack = Gtk.Stack()
        # self.stack.add_named(self.empty, 'empty-page')
        # self.stack.add_named(self.web, 'preview-page')

        self.content_deck.add(self.empty)
        self.content_deck.add(self.web)

        self.connect('enter-notify-event', self.on_enter_notify)
        self.connect('leave-notify-event', self.on_leave_notify)
Ejemplo n.º 6
0
    def __init__(self):
        Gtk.Box.__init__(self, False, 0)

        # Create welcome widget
        welcome = Granite.WidgetsWelcome()
        welcome = welcome.new("Welcome", cn.App.application_description)

        # Welcome voices
        #welcome.append("object-inverse", "Dark mode", "Switch to the dark side")
        #welcome.append("utilities-terminal", "Open Terminal", "Just an example of action")
        #welcome.append("help-contents", "Info", "Learn more about this application")
        
        welcome.connect("activated", self.on_welcome_activated)

        self.add(welcome)
Ejemplo n.º 7
0
    def __init__(self, parent):
        Gtk.Box.__init__(self, False, 0)

        self.parent = parent

        # Create welcome widget
        self.welcome = Granite.WidgetsWelcome()
        self.welcome = self.welcome.new(cn.App.application_name, cn.App.application_description)

        # Welcome voices
        self.welcome.append("document-new", "Create Invoice", "Create a new invoice")


        self.welcome.connect("activated", self.on_welcome_activated)

        self.add(self.welcome)
Ejemplo n.º 8
0
    def __init__(self):
        Gtk.Box.__init__(self, False, 0)
        self.light = LightWindow()

        self.settings.set_property("gtk-application-prefer-dark-theme", True)

        # Create welcome widget
        self.welcome = Granite.WidgetsWelcome()
        self.welcome = self.welcome.new("Welcome", "What do you want to do?")

        # Welcome voices
        self.welcome.append("folder-videos", "Open", "Open Video or Playlist")

        self.welcome.connect("activated", self.on_welcome_activated)

        self.add(self.welcome)
Ejemplo n.º 9
0
 def __init__(self):
     '''Our class will be a Gtk.Box and will contain our 
     new Welcome Widget.'''
     Gtk.Box.__init__(self, False, 0)
     '''Your app needs translations, right?
     Here we are trying to set the locale_path to the system one, assuming 
     the app is installed.'''
     try:
         current_locale, encoding = locale.getdefaultlocale()
         locale_path = os.path.join(
             os.path.abspath(os.path.dirname(__file__)), 'locale')
         translate = gettext.translation(cn.App.application_shortname,
                                         locale_path, [current_locale])
         _ = translate.gettext
     except FileNotFoundError:
         _ = str
     ''''The self._ can be used for defining a new translation string.
     Note: that if the translation is not loaded (the check above), 
           self._ will be the same as str, so you won't get any errors.'''
     self._ = _
     '''Here we are creating a new Welcome Widget from the Granite library'''
     welcome = Granite.WidgetsWelcome()
     welcome = welcome.new(_("Welcome"), cn.App.application_description)
     '''Let's populate the Welcome menu actions.'''
     welcome.append(
         "weather-clear-night",  # the action icon (a valid icon name)
         _('Dark Mode'),  # the action name
         _('Switch to the dark side')  # the action description
     )
     welcome.append("utilities-terminal", _('Open Terminal'),
                    _('Just an example of action'))
     welcome.append("help-contents", _('Info'),
                    _('Learn more about this application'))
     welcome.append("help-browser", _('Doc'), _('Valadoc for Granite'))
     '''Here we are connecting the on_welcome_activated method to the 
     activated signal of the Welcome Widget, so this will be triggered 
     when an action is activated'''
     welcome.connect("activated", self.on_welcome_activated)
     '''Do you remember the Box we were talking about at the beginning?
     Here, we add the Welcome Widget to this.'''
     self.add(welcome)