~feng-kylin/youker-assistant/youker-assistant

« back to all changes in this revision

Viewing changes to processmanager/util.cpp

  • Committer: kobe
  • Date: 2015-02-13 07:37:10 UTC
  • Revision ID: xiangli@ubuntukylin.com-20150213073710-0jyp02ilyi5njj10
Qt Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 ~ 2014 National University of Defense Technology(NUDT) & Kylin Ltd.
 
3
 * Author: Kobe Lee
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; version 3.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 */
 
17
 
 
18
 
 
19
#include <glib/gi18n.h>
 
20
#include <glib.h>
 
21
#include <glibtop/procstate.h>
 
22
#include "util.h"
 
23
 
 
24
const char* format_process_state(guint state)
 
25
{
 
26
    const char *status;
 
27
 
 
28
    switch (state)
 
29
    {
 
30
        case GLIBTOP_PROCESS_RUNNING:
 
31
            status = _("Running");
 
32
            break;
 
33
 
 
34
        case GLIBTOP_PROCESS_STOPPED:
 
35
            status = _("Stopped");
 
36
            break;
 
37
 
 
38
        case GLIBTOP_PROCESS_ZOMBIE:
 
39
            status = _("Zombie");
 
40
            break;
 
41
 
 
42
        case GLIBTOP_PROCESS_UNINTERRUPTIBLE:
 
43
            status = _("Uninterruptible");
 
44
            break;
 
45
 
 
46
        default:
 
47
            status = _("Sleeping");
 
48
            break;
 
49
    }
 
50
 
 
51
    return status;
 
52
}
 
53
 
 
54
const gchar* get_nice_level (gint nice)
 
55
{
 
56
    if (nice < -7)
 
57
        return _("Very High");
 
58
    else if (nice < -2)
 
59
        return _("High");
 
60
    else if (nice < 3)
 
61
        return _("Normal");
 
62
    else if (nice < 7)
 
63
        return _("Low");
 
64
    else
 
65
        return _("Very Low");
 
66
}