<commit_before>"""About and help services. (help browser anyone?)"""

import os
from builtins import object
from logging import getLogger

from gi.repository import Gtk
import pkg_resources
from zope.interface import implementer

from gaphor.application import Application
from gaphor.core import _, inject, action, build_action_group
from gaphor.interfaces import IService, IActionProvider


@implementer(IService, IActionProvider)
class HelpService(object):

    menu_xml = """
      <ui>
        <menubar name="mainwindow">
          <menu action="help">
            <placeholder name="ternary">
              <menuitem action="help-about" />
            </placeholder>
          </menu>
        </menubar>
      </ui>
    """

    main_window = inject('main_window')
    logger = getLogger('HelpService')

    def __init__(self):
        pass

    def init(self, app):
        self.logger.info('Starting')
        self.action_group = build_action_group(self)

    def shutdown(self):
        self.logger.info('Shutting down')

    @action(name='help-about', stock_id='gtk-about')
    def about(self):
        logo_file =  os.path.join(pkg_resources.get_distribution('gaphor').location, 'gaphor', 'ui', 'pixmaps', 'logo.png')
        logo = GdkPixbuf.Pixbuf.new_from_file(logo_file)
        version = Application.distribution.version
        about = Gtk.Dialog(_('About Gaphor'), self.main_window.window, Gtk.DialogFlags.MODAL, (Gtk.STOCK_OK, Gtk.ResponseType.OK))
        about.set_default_response(Gtk.ResponseType.OK)
        vbox = about.vbox

        image = Gtk.Image()
        image.set_from_pixbuf(logo)
        vbox.pack_start(image, True, True, 0)

        notebook = Gtk.Notebook()
        notebook.set_scrollable(True)
        notebook.set_border_width(4)
        notebook.set_tab_pos(Gtk.PositionType.BOTTOM)
        vbox.pack_start(notebook, True, True, 0)

        tab_vbox = Gtk.VBox()

        def add_label(text, padding_x=0, padding_y=0):
            label = Gtk.Label(label=text)
            label.set_property('use-markup', True)
            label.set_padding(padding_x, padding_y)
            label.set_justify(Gtk.Justification.CENTER)
            tab_vbox.pack_start(label, True, True, 0)

        add_label('<span weight="bold">version %s</span>' % version)
        add_label('<span variant="smallcaps">UML Modeling tool for GNOME</span>', 8, 8)
        add_label('<span size="small">Copyright (c) 2001-2007 <NAME></span>', 8, 8)

        notebook.append_page(tab_vbox, Gtk.Label(label=_('About')))

        tab_vbox = Gtk.VBox()
        
        add_label('This software is published\n'
                  'under the terms of the\n'
                  '<span weight="bold">GNU General Public License v2</span>.\n'
                  'See the COPYING file for details.', 0, 8)
        notebook.append_page(tab_vbox, Gtk.Label(label=_('License')))

        tab_vbox = Gtk.VBox()
        
        add_label('Gaphor is written by:\n'
                  '<NAME>\n'
                  '<NAME>\n'
                  '<NAME>')
        add_label('')
        notebook.append_page(tab_vbox, Gtk.Label(label=_('Authors')))

        vbox.show_all()
        about.run()
        about.destroy()


# vim:sw=4:et:ai
<commit_msg>Include GdkPixbuf in module imports<commit_after>"""About and help services. (help browser anyone?)"""

import os
from builtins import object
from logging import getLogger

import pkg_resources
from gi.repository import GdkPixbuf
from gi.repository import Gtk
from zope.interface import implementer

from gaphor.application import Application
from gaphor.core import _, inject, action, build_action_group
from gaphor.interfaces import IService, IActionProvider


@implementer(IService, IActionProvider)
class HelpService(object):

    menu_xml = """
      <ui>
        <menubar name="mainwindow">
          <menu action="help">
            <placeholder name="ternary">
              <menuitem action="help-about" />
            </placeholder>
          </menu>
        </menubar>
      </ui>
    """

    main_window = inject('main_window')
    logger = getLogger('HelpService')

    def __init__(self):
        pass

    def init(self, app):
        self.logger.info('Starting')
        self.action_group = build_action_group(self)

    def shutdown(self):
        self.logger.info('Shutting down')

    @action(name='help-about', stock_id='gtk-about')
    def about(self):
        logo_file =  os.path.join(pkg_resources.get_distribution('gaphor').location, 'gaphor', 'ui', 'pixmaps', 'logo.png')
        logo = GdkPixbuf.Pixbuf.new_from_file(logo_file)
        version = Application.distribution.version
        about = Gtk.Dialog(_('About Gaphor'), self.main_window.window, Gtk.DialogFlags.MODAL, (Gtk.STOCK_OK, Gtk.ResponseType.OK))
        about.set_default_response(Gtk.ResponseType.OK)
        vbox = about.vbox

        image = Gtk.Image()
        image.set_from_pixbuf(logo)
        vbox.pack_start(image, True, True, 0)

        notebook = Gtk.Notebook()
        notebook.set_scrollable(True)
        notebook.set_border_width(4)
        notebook.set_tab_pos(Gtk.PositionType.BOTTOM)
        vbox.pack_start(notebook, True, True, 0)

        tab_vbox = Gtk.VBox()

        def add_label(text, padding_x=0, padding_y=0):
            label = Gtk.Label(label=text)
            label.set_property('use-markup', True)
            label.set_padding(padding_x, padding_y)
            label.set_justify(Gtk.Justification.CENTER)
            tab_vbox.pack_start(label, True, True, 0)

        add_label('<span weight="bold">version %s</span>' % version)
        add_label('<span variant="smallcaps">UML Modeling tool for GNOME</span>', 8, 8)
        add_label('<span size="small">Copyright (c) 2001-2007 <NAME></span>', 8, 8)

        notebook.append_page(tab_vbox, Gtk.Label(label=_('About')))

        tab_vbox = Gtk.VBox()
        
        add_label('This software is published\n'
                  'under the terms of the\n'
                  '<span weight="bold">GNU General Public License v2</span>.\n'
                  'See the COPYING file for details.', 0, 8)
        notebook.append_page(tab_vbox, Gtk.Label(label=_('License')))

        tab_vbox = Gtk.VBox()
        
        add_label('Gaphor is written by:\n'
                  '<NAME>\n'
                  '<NAME>\n'
                  '<NAME>')
        add_label('')
        notebook.append_page(tab_vbox, Gtk.Label(label=_('Authors')))

        vbox.show_all()
        about.run()
        about.destroy()


# vim:sw=4:et:ai

{'fraction_non_alphanumeric': 0.1254980079681275, 'fraction_numerical': 0.006742261722341404, 'mean_word_length': 2.5862637362637364, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5692633', 'n_tokens_mistral': 2108, 'n_tokens_neox': 2041, 'n_words': 404}