summaryrefslogtreecommitdiff
path: root/src/prettytable.h
blob: ac150de337599ae4a480e3ae42244c92782a17ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// -*- c++ -*-

#ifndef _PROCMAN_PRETTYTABLE_H_
#define _PROCMAN_PRETTYTABLE_H_

#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <glibmm/refptr.h>
#include <gdkmm/pixbuf.h>
#include <giomm/filemonitor.h>

#include <map>
#include <string>

extern "C" {
#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include <libwnck/libwnck.h>
}

#include "iconthemewrapper.h"

class ProcInfo;

using std::string;



class PrettyTable
{
 public:
    PrettyTable();
    ~PrettyTable();

    void set_icon(ProcInfo &);

private:

    static void on_application_opened(WnckScreen* screen, WnckApplication* app, gpointer data);
    static void on_application_closed(WnckScreen* screen, WnckApplication* app, gpointer data);

    void register_application(pid_t pid, Glib::RefPtr<Gdk::Pixbuf> icon);
    void unregister_application(pid_t pid);


    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_theme(const ProcInfo &);
    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_default(const ProcInfo &);
    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_gio(const ProcInfo &);
    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_wnck(const ProcInfo &);
    Glib::RefPtr<Gdk::Pixbuf> get_icon_from_name(const ProcInfo &);
    Glib::RefPtr<Gdk::Pixbuf> get_icon_for_kernel(const ProcInfo &);
    Glib::RefPtr<Gdk::Pixbuf> get_icon_dummy(const ProcInfo &);

    bool get_default_icon_name(const string &cmd, string &name);
    void file_monitor_event (Glib::RefPtr<Gio::File>,
                             Glib::RefPtr<Gio::File>,
                             Gio::FileMonitorEvent);
    void init_gio_app_cache ();


    typedef std::map<string, Glib::RefPtr<Gdk::Pixbuf> > IconCache;
    typedef std::map<pid_t, Glib::RefPtr<Gdk::Pixbuf> > IconsForPID;
    typedef std::map<string, Glib::RefPtr<Gio::AppInfo> > AppCache;
    typedef std::map<string, Glib::RefPtr<Gio::FileMonitor> > DesktopDirMonitors;

    IconsForPID apps;
    IconCache defaults;
    DesktopDirMonitors monitors;
    AppCache gio_apps;
    procman::IconThemeWrapper theme;
};


#endif /* _PROCMAN_PRETTYTABLE_H_ */