コード例 #1
0
ファイル: utils.py プロジェクト: DaveMDS/egitu
    def __init__(self, parent, commit, show_full_msg=False):
        self.commit = commit

        Table.__init__(self, parent,  padding=(5,5))
        self.show()

        pic = GravatarPict(self)
        pic.size_hint_align = 0.0, 0.0
        pic.email_set(commit.author_email)
        self.pack(pic, 0, 0, 1, 1)
        pic.show()

        if commit.committer and commit.committer != commit.author:
            committed = '<name>Committed by:</name> <b>{}</b><br>'.format(
                        commit.committer)
        else:
            committed = ''
        text = '<name>{}</name>  <b>{}</b>  {}<br>{}<br>{}'.format(
                commit.sha[:9], commit.author, format_date(commit.commit_date), 
                committed, utf8_to_markup(commit.title))
        if show_full_msg:
            text += '<br><br>{}'.format(utf8_to_markup(commit.message))
        en = Entry(self, text=text, line_wrap=ELM_WRAP_NONE,
                   size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.pack(en, 1, 0, 1, 1)
        en.show()
コード例 #2
0
ファイル: utils.py プロジェクト: DaveMDS/egitu
    def lines_set(self, lines):
        markup = ''
        from_fname = to_fname = None

        for line in lines:
            if from_fname and to_fname:
                if from_fname == '/dev/null':
                    action = 'A'
                elif to_fname == '/dev/null':
                    action = 'D'
                else:
                    action = 'M'
                markup += '<br><subtitle>' + action + ' ' + to_fname + '</subtitle><br>'
                from_fname = to_fname = None

            if line.startswith(('diff', 'index', 'new')):
                pass
            elif line.startswith('---'):
                from_fname = line[4:]
            elif line.startswith('+++'):
                to_fname = line[4:]
            elif line.startswith('@@'):
                markup += '<hilight>'+utf8_to_markup(line)+'</hilight><br>'
            elif line[0] == '+':
                markup += '<line_added>'+utf8_to_markup(line)+'</line_added><br>'
            elif line[0] == '-':
                markup += '<line_removed>'+utf8_to_markup(line)+'</line_removed><br>'
            else:
                markup += utf8_to_markup(line)+'<br>'

        if markup.startswith('<br>'): # remove the first "<br>"
            markup = markup[4:]
        self.text = u'<code><font={0} font_size={1}>{2}</font></code>'.format(
                      options.diff_font_face, options.diff_font_size, markup)
コード例 #3
0
def events_cb(obj, src, event_type, event, data):

    entry = data
    append = entry.entry_append

    append(utf8_to_markup(
        "Obj: %r\n\nSrc: %r\n\nEvent: %s" % (obj, src, event)
        ))
    append("<br><br>Modifiers:<br>")
    append(utf8_to_markup(
        "Control: %s Shift: %s Alt: %s" % (
            event.modifier_is_set("Control"),
            event.modifier_is_set("Shift"),
            event.modifier_is_set("Alt")
            )
        ))

    if event_type == EVAS_CALLBACK_KEY_UP:
        append("<br><br>This event was handled so it won't propagate to a parent of Obj.<br><br>")
        append("---------------------------------------------------------------")
        append("<br><br>")

        return True

    append("<br><br>This event was not handled so it will propagate to a parent of Obj if it has one.<br><br>")
    append("---------------------------------------------------------------")
    append("<br><br>")

    return False
コード例 #4
0
 def reply_handler(self, *rets):
     if rets:
         if options.pretty_output:
             s = utf8_to_markup(json.dumps(rets, indent=2))
         else:
             s = utf8_to_markup(str(rets))
     else:
         s = "Method executed successfully.<br>Nothing returned."
     self._return_entry.entry = s
コード例 #5
0
 def reply_handler(self, *rets):
     if rets:
         if options.pretty_output:
             s = utf8_to_markup(json.dumps(rets, indent=2))
         else:
             s = utf8_to_markup(str(rets))
     else:
         s = "Method executed successfully.<br>Nothing returned."
     self._return_entry.entry = s
コード例 #6
0
ファイル: movies.py プロジェクト: DaveMDS/epymc
 def poster_get(self, url, mod):
    if mod._movie_db.id_exists(url):
       e = mod._movie_db.get_data(url)
       poster = get_poster_filename(e['id'])
       if os.path.exists(poster):
          return poster
       else:
          return 'special/bd/' + utf8_to_markup(e['title'])
    else:
       return 'special/bd/' + utf8_to_markup(os.path.basename(url))
コード例 #7
0
ファイル: music.py プロジェクト: DaveMDS/epymc
 def info_get(self, url, song):
    text = '<title>{}</>'.format(utf8_to_markup(song['title']))
    if 'length' in song:
       length = utils.seconds_to_duration(int(song['length']) / 1000)
       text += ' <small>({})</small><br>'.format(length)
    else:
       text += '<br>'
    if 'artist' in song:
       text += '<artist>{0} {1}</artist><br>'.format(_('by'),
                                              utf8_to_markup(song['artist']))
    if 'album' in song:
       text += '<album>{0} {1}</album><br>'.format(_('from'),
                                            utf8_to_markup(song['album']))
    
    return text
コード例 #8
0
    def run_clicked_cb(self, btn):
        # collect method infos
        named_service = self._method.parent.parent.parent
        object_path = self._method.parent.parent.name
        iface_name = self._method.parent.name
        method_name = self._method.name
        if self._param_entry:
            user_params = markup_to_utf8(self._param_entry.entry)
        else:
            user_params = None

        # create the dbus proxy
        obj = bus.get_object(named_service, object_path)
        iface = dbus.Interface(obj, iface_name)
        meth = iface.get_dbus_method(method_name)

        # async method call # TODO make another  example for this
        try:
            if user_params:
                meth(eval(user_params),
                     reply_handler=self.reply_handler,
                     error_handler=self.error_handler)
            else:
                meth(reply_handler=self.reply_handler,
                     error_handler=self.error_handler)
        except Exception as e:
            s = "Error running method<br>Exception: "
            self._return_entry.entry = s + utf8_to_markup(str(e))
コード例 #9
0
ファイル: commitdialog.py プロジェクト: simotek/egitu
 def commit_done_cb(self, success, err_msg=None):
     if success:
         self.delete()
         self.win.update_header()
         self.win.graph.populate(self.repo)
     else:
         ErrorPopup(self, 'Commit Failed', utf8_to_markup(err_msg))
コード例 #10
0
    def run_clicked_cb(self, btn):
        # collect method infos
        named_service = self._method.parent.parent.parent
        object_path = self._method.parent.parent.name
        iface_name = self._method.parent.name
        method_name = self._method.name
        if self._param_entry:
            user_params = markup_to_utf8(self._param_entry.entry)
        else:
            user_params = None

        # create the dbus proxy
        obj = bus.get_object(named_service, object_path)
        iface = dbus.Interface(obj, iface_name)
        meth = iface.get_dbus_method(method_name)

        # async method call # TODO make another  example for this
        try:
            if user_params:
                meth(eval(user_params),
                     reply_handler = self.reply_handler,
                     error_handler = self.error_handler)
            else:
                meth(reply_handler = self.reply_handler,
                     error_handler = self.error_handler)
        except Exception as e:
            s = "Error running method<br>Exception: "
            self._return_entry.entry = s + utf8_to_markup(str(e))
コード例 #11
0
ファイル: utils.py プロジェクト: DaveMDS/egitu
    def __init__(self, cmd, exec_cb):
        DialogWindow.__init__(self, _app_instance.win, 'egitu-review',
                              'Git Command Review', autodel=True, size=(300,50))

        # main table (inside a padding frame)
        fr = Frame(self, style='default', text='Command to execute',
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        self.resize_object_add(fr)
        fr.show()

        tb = Table(self, padding=(6,6),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        fr.content = tb
        tb.show()

        # cmd entry
        en = Entry(self, single_line=True, scrollable=True, 
                   text=utf8_to_markup(cmd),
                   size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
        tb.pack(en, 0, 0, 2, 1)
        en.show()

        # buttons
        bt = Button(self, text='Close', size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
        bt.callback_clicked_add(lambda b: self.delete())
        tb.pack(bt, 0, 1, 1, 1)
        bt.show()

        bt = Button(self, text='Execute', size_hint_expand=EXPAND_HORIZ, size_hint_fill=FILL_HORIZ)
        bt.callback_clicked_add(self._exec_clicked_cb, en, exec_cb)
        tb.pack(bt, 1, 1, 1, 1)
        bt.show()

        #
        self.show()
コード例 #12
0
ファイル: branches.py プロジェクト: DaveMDS/egitu
 def _merge_done_cb(self, success, err_msg=None):
     self.app.action_update_header()
     if success:
         self.delete()
         self.app.action_update_all()
     else:
         ErrorPopup(self.parent, msg=utf8_to_markup(err_msg))
コード例 #13
0
ファイル: compare.py プロジェクト: DaveMDS/egitu
    def _commits_done_cb(self, success, err_msg=None):
        count = self.commits_list.items_count
        if not success:
            ErrorPopup(self, msg=utf8_to_markup(err_msg))
            return

        # update commits list
        if count == 0:
            self.commits_frame.text = 'No commits to show'
        else:
            self.commits_frame.text = '{} {} in {} but not in {}'.format(
                                    count, 'commit' if count == 1 else 'commits',
                                    self.compare_combo.text,
                                    self.base_combo.text)

        # update diff entry
        if count == 0:
            self.diff_entry.text = \
                '<info>There isn’t anything to compare.</info><br>' \
                'The two revisions are identical.<br>' \
                'You’ll need to use two different branch names ' \
                'to get a valid comparison.'
        else:
            self.update_diff()

        # update merge button + label
        if self.base_combo.text != self.app.repo.status.current_branch.name:
            self.merge_btn.disabled = True
            self.merge_label.text = '<warning>You can only merge in the current branch.</>'
        elif count == 0:
            self.merge_btn.disabled = True
            self.merge_label.text = '<info>Nothing to merge.</>'
        else:
            self.merge_btn.disabled = False
            self.merge_label.text = '' # TODO check conflicts !!!
コード例 #14
0
ファイル: music.py プロジェクト: DaveMDS/epymc
 def info_get(self, url, artist):
    n = len(artist['albums'])
    albums = ngettext('%d album', '%d albums', n) % n
    n = len(artist['songs'])
    songs = ngettext('%d song', '%d songs', n) % n
    name = utf8_to_markup(artist['name'])
    return '<title>%s</><br>%s, %s' % (name, albums, songs)
コード例 #15
0
ファイル: music.py プロジェクト: DaveMDS/epymc
 def info_get(self, url, album):
    text = '<title>%s</title><br>' % utf8_to_markup(album['name'])
    text += _('<em>by</em> %s<br>') % utf8_to_markup(album['artist'])
    n = len(album['songs'])
    text += ngettext('%d song', '%d songs', n) % n
    
    lenght = 0
    for song in album['songs']:
       song_data = _mod._songs_db.get_data(song)
       if 'length' in song_data:
          lenght += int(song_data['length'])
    if lenght > 0:
       n = lenght / 60000
       runtime = ngettext('%d minute', '%d minutes', n) % n
       text += ', ' + runtime
    return text
コード例 #16
0
 def display_error(self, exc):
     self.load_notify.content.delete()
     l = Label(self.load_notify,
               style="marker",
               text="Document load error: %s" % utf8_to_markup(str(exc)),
               color=(255, 0, 0, 255))
     self.load_notify.content = l
     l.show()
コード例 #17
0
ファイル: tvshows.py プロジェクト: DaveMDS/epymc
 def poster_get(self, url, season_num):
    serie_name = mod_instance._current_serie_name
    if mod_instance._tvshows_db.id_exists(serie_name):
       e = mod_instance._tvshows_db.get_data(serie_name)
       poster_file = get_tv_poster_filename(e['id'], season_num)
       if os.path.exists(poster_file):
          return poster_file
       return get_tv_poster_filename(e['id'])
    return 'special/bd/' + utf8_to_markup(os.path.basename(url))
コード例 #18
0
ファイル: movies.py プロジェクト: DaveMDS/epymc
 def info_get(self, url, mod):
    if mod._movie_db.id_exists(url):
       e = mod._movie_db.get_data(url)
       text = '<title>%s (%s %s)</><br>' \
              '<name>%s:</> %s/10<br>' \
              '<name>%s:</> %s<br>' \
              '<name>%s:</> %s<br>' % (
                utf8_to_markup(e['title']), e['country'], e['release_date'][:4],
                _('Rating'), e['rating'],
                _('Director'), e['director'],
                _('Cast'), mod._get_cast(e, 4))
    else:
       name, year = get_movie_name_from_url(url)
       text = '<title>%s</><br><name>%s:</> %s<br>' \
              '<name>%s:</> %s<br><name>%s:</> %s<br>' % (
                utf8_to_markup(os.path.basename(url)),
                _('File size'),
                utils.hum_size(os.path.getsize(utils.url2path(url))),
                _('Title'), utf8_to_markup(name),
                _('Year'), year or _('Unknown'))
    return text
コード例 #19
0
ファイル: diffview.py プロジェクト: druonysus/egitu
    def show_commit(self, commit):
        self.commit = commit

        self.picture.email_set(commit.author_email)
        line1 = '<name>{}</name>  <b>{}</b>  {}<br>'.format(commit.sha[:9],
                 commit.author, format_date(commit.commit_date))
        line2 = line3 = line4 = ''
        if commit.committer and commit.committer != commit.author:
            line2 = '<name>Committed by:</name> <b>{}</b><br>'.format(
                     commit.committer)
        if commit.title:
            line3 = '<bigger><b>{}</b></bigger><br>'.format(
                    utf8_to_markup(commit.title.strip()))
        if commit.message:
            line4 = '<br>{}'.format(utf8_to_markup(commit.message.strip()))
        text = line1 + line2 + line3 + line4
        self.entry.text = text

        self.update_action_buttons(['checkout', 'revert', 'cherrypick'])
        self.diff_entry.text = ''
        self.diff_list.clear()
        self.app.repo.request_changes(self._changes_done_cb, commit1=commit)
コード例 #20
0
ファイル: tvshows.py プロジェクト: DaveMDS/epymc
   def __init__(self, serie_name):
      self._serie_name = serie_name
      if mod_instance._tvshows_db.id_exists(serie_name):
         self._db_data = mod_instance._tvshows_db.get_data(serie_name)
      else:
         self._db_data = None

      self._image = Image(gui.win)
      EmcDialog.__init__(self, style='panel', title=utf8_to_markup(serie_name),
                         text=' ', content=self._image)
      self.button_add(_('Posters'), self._posters_button_cb)
      self.button_add(_('Backdrops'), self._backdrop_button_cb)
      self.button_add(_('Cast'), self._cast_button_cb)
      self.button_add(_('Refresh info'), self._refresh_info_button_cb)
      self.update()
コード例 #21
0
ファイル: __init__.py プロジェクト: JeffHoogland/edgar-moksha
    def popup_update(self, popup):
        if self.db.is_running:
            popup.data['lb'].text = utf8_to_markup(self.db.status_msg)
            popup.data['bt'].text = 'Stop Dropbox'
            popup.data['bt'].disabled = False
        elif self.db.is_installed:
            popup.data['lb'].text = "Dropbox isn't running!"
            popup.data['bt'].text = 'Start Dropbox'
            popup.data['bt'].disabled = False
        else:
            popup.data['lb'].text = "Dropbox isn't installed!"
            popup.data['bt'].text = 'Install Dropbox'
            popup.data['bt'].disabled = True

        # force the popup to recalculate it's size
        popup.size_hint_min = popup.size_min
コード例 #22
0
ファイル: tvshows.py プロジェクト: DaveMDS/epymc
 def poster_get(self, url, episode_data):
    series_id = episode_data['series_id']
    season_num = episode_data['season_num']
    episode_id = episode_data['id']
    if episode_data['thumb_url']:
       # episode thumb
       return (episode_data['thumb_url'],
               get_tv_poster_filename(series_id, episode_id=episode_id))
    else:
       # season poster
       poster_file = get_tv_poster_filename(series_id, season_num)
       if os.path.exists(poster_file):
          return poster_file
       else:
          # serie poster
          return get_tv_poster_filename(series_id)
    return 'special/bd/' + utf8_to_markup(os.path.basename(url))
コード例 #23
0
ファイル: remotes.py プロジェクト: DaveMDS/egitu
 def _remote_info_cb(self, success, info, err_msg=None):
     self.wait_popup.delete()
     if success:
         self.info_entry.text = '<code>%s</code>' % utf8_to_markup(info)
     else:
         self.info_entry.text = '<code>%s</code>' % utf8_to_markup(err_msg)
コード例 #24
0
def prettify_if_needed(data):
    if options.pretty_output:
        return utf8_to_markup(json.dumps(data, indent=2))
    else:
        return utf8_to_markup(str(data))
コード例 #25
0
ファイル: egitu.py プロジェクト: DaveMDS/egitu
 def _done_cb(success, err_msg=None):
     if success:
         self.action_update_all()
     else:
         ErrorPopup(self.win, msg=utf8_to_markup(err_msg))
コード例 #26
0
ファイル: tags.py プロジェクト: druonysus/egitu
 def _delete_done_cb(self, success, err_msg=None):
     if success:
         self.app.action_update_all()
         self.populate()
     else:
         ErrorPopup(self, 'Delete Failed', utf8_to_markup(err_msg))
コード例 #27
0
ファイル: tags.py プロジェクト: druonysus/egitu
 def _checkout_done_cb(self, success, err_msg=None):
     if success:
         self.app.action_update_all()
         self.delete()
     else:
         ErrorPopup(self, 'Checkout Failed', utf8_to_markup(err_msg))
コード例 #28
0
ファイル: commit.py プロジェクト: druonysus/egitu
    def __init__(self, app, revert_commit=None, cherrypick_commit=None):
        self.app = app
        self.confirmed = False
        self.revert_commit = revert_commit
        self.cherrypick_commit = cherrypick_commit

        DialogWindow.__init__(self, app.win, 'Egitu', 'Egitu',
                              size=(500,500), autodel=True)

        vbox = Box(self, size_hint_weight=EXPAND_BOTH,
                   size_hint_align=FILL_BOTH)
        self.resize_object_add(vbox)
        vbox.show()

        # title
        if revert_commit:
            title = 'Revert commit'
        elif cherrypick_commit:
            title = 'Cherry-pick commit'
        else:
            title = 'Commit changes'
        en = Entry(self, editable=False,
                   text='<title><align=center>%s</align></title>' % title,
                   size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        vbox.pack_end(en)
        en.show()

        # auto-commit checkbox (for revert and cherry-pick)
        if revert_commit or cherrypick_commit:
            ck = Check(vbox, state=True)
            ck.text = 'Automatically commit, in branch: %s' % \
                      app.repo.status.current_branch.name
            ck.callback_changed_add(lambda c: self.msg_entry.disabled_set(not c.state))
            vbox.pack_end(ck)
            ck.show()
            self.autocommit_chk = ck

        # Panes
        panes = Panes(self, content_left_size = 0.2, horizontal=True,
                      size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        vbox.pack_end(panes)
        panes.show()

        # message entry
        en = Entry(self, editable=True, scrollable=True,
                   size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        en.part_text_set('guide', 'Enter commit message here')
        panes.part_content_set("left", en)
        if revert_commit:
            en.text = 'Revert "%s"<br><br>This reverts commit %s.<br><br>' % \
                      (utf8_to_markup(revert_commit.title),
                       revert_commit.sha)
        elif cherrypick_commit:
            en.text = '%s<br><br>%s<br>(cherry picked from commit %s)<br>' % \
                      (utf8_to_markup(cherrypick_commit.title),
                       utf8_to_markup(cherrypick_commit.message),
                       cherrypick_commit.sha)
        en.cursor_end_set()
        en.show()
        self.msg_entry = en

        # diff entry
        self.diff_entry = DiffedEntry(self)
        panes.part_content_set('right', self.diff_entry)
        self.diff_entry.show()

        # buttons
        hbox = Box(self, horizontal=True, size_hint_weight=EXPAND_HORIZ,
                   size_hint_align=FILL_HORIZ)
        vbox.pack_end(hbox)
        hbox.show()

        bt = Button(self, text='Cancel')
        bt.callback_clicked_add(lambda b: self.delete())
        hbox.pack_end(bt)
        bt.show()

        if revert_commit:
            label = 'Revert'
        elif cherrypick_commit:
            label = 'Cherry-pick'
        else:
            label = 'Commit'
        bt = Button(self, text=label)
        bt.callback_clicked_add(self.commit_button_cb)
        hbox.pack_end(bt)
        bt.show()

        # show the window and give focus to the editable entry
        self.show()
        en.focus = True

        # load the diff
        if revert_commit:
            app.repo.request_diff(self.diff_done_cb, revert=True,
                                  ref1=revert_commit.sha)
        elif cherrypick_commit:
            app.repo.request_diff(self.diff_done_cb, ref1=cherrypick_commit.sha)
        else:
            app.repo.request_diff(self.diff_done_cb, only_staged=True)
コード例 #29
0
ファイル: commit.py プロジェクト: druonysus/egitu
 def commit_done_cb(self, success, err_msg=None):
     if success:
         self.delete()
         self.app.action_update_all()
     else:
         ErrorPopup(self, 'Operation Failed', utf8_to_markup(err_msg))
コード例 #30
0
ファイル: commit.py プロジェクト: druonysus/egitu
 def _discard_done_cb(self, success, err_msg=None):
     self.delete()
     if success:
         self.app.win.update_all()
     else:
         ErrorPopup(self.app.win, 'Operation Failed', utf8_to_markup(err_msg))
コード例 #31
0
ファイル: music.py プロジェクト: DaveMDS/epymc
 def label_get(self, url, song):
    title = utf8_to_markup(song['title'])
    try:
       return "%02d. %s" % (song['tracknumber'], title)
    except:
       return title
コード例 #32
0
ファイル: music.py プロジェクト: DaveMDS/epymc
 def label_get(self, url, song):
    title = utf8_to_markup(song['title'])
    artist = utf8_to_markup(song['artist'])
    return '<song>{0}</song> <artist>{1} {2}</artist>'.format(
            title, _('by'), artist)
コード例 #33
0
ファイル: music.py プロジェクト: DaveMDS/epymc
 def label_get(self, url, album):
    # return utf8_to_markup(_('%(name)s by %(artist)s') % (album))
    return utf8_to_markup(album['name'])
コード例 #34
0
ファイル: music.py プロジェクト: DaveMDS/epymc
 def label_get(self, url, artist):
    return utf8_to_markup(artist['name'])