diff options
author | Victor Kareh <[email protected]> | 2019-07-11 00:23:18 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-09-13 14:41:47 +0200 |
commit | 3df54a27e70b5fe33be90779f319a627c0773df6 (patch) | |
tree | 68c4b8bf263d8d556f2e7ae734c18d7cbc73f185 /src/proctable.cpp | |
parent | 819b1861ebec1d492029a5e50db2ff79b057c14a (diff) | |
download | mate-system-monitor-3df54a27e70b5fe33be90779f319a627c0773df6.tar.bz2 mate-system-monitor-3df54a27e70b5fe33be90779f319a627c0773df6.tar.xz |
Render icons as cairo surfaces for HiDPI support
back ported from:
https://github.com/mate-desktop/mate-system-monitor/commit/bc190e7
Diffstat (limited to 'src/proctable.cpp')
-rw-r--r-- | src/proctable.cpp | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/src/proctable.cpp b/src/proctable.cpp index f2eb3b5..ef91f8b 100644 --- a/src/proctable.cpp +++ b/src/proctable.cpp @@ -20,7 +20,7 @@ #include <config.h> - +#include <cairo-gobject.h> #include <string.h> #include <math.h> #include <glib/gi18n.h> @@ -276,32 +276,32 @@ proctable_new (ProcData * const procdata) GTK_POLICY_AUTOMATIC); model = gtk_tree_store_new (NUM_COLUMNS, - G_TYPE_STRING, /* Process Name */ - G_TYPE_STRING, /* User */ - G_TYPE_UINT, /* Status */ - G_TYPE_ULONG, /* VM Size */ - G_TYPE_ULONG, /* Resident Memory */ - G_TYPE_ULONG, /* Writable Memory */ - G_TYPE_ULONG, /* Shared Memory */ - G_TYPE_ULONG, /* X Server Memory */ - G_TYPE_UINT, /* % CPU */ - G_TYPE_UINT64, /* CPU time */ - G_TYPE_ULONG, /* Started */ - G_TYPE_INT, /* Nice */ - G_TYPE_UINT, /* ID */ - G_TYPE_STRING, /* Security Context */ - G_TYPE_STRING, /* Arguments */ - G_TYPE_ULONG, /* Memory */ - G_TYPE_STRING, /* wchan */ - G_TYPE_STRING, /* Cgroup */ - G_TYPE_STRING, /* Unit */ - G_TYPE_STRING, /* Session */ - G_TYPE_STRING, /* Seat */ - G_TYPE_STRING, /* Owner */ - G_TYPE_STRING, /* Priority */ - GDK_TYPE_PIXBUF, /* Icon */ - G_TYPE_POINTER, /* ProcInfo */ - G_TYPE_STRING /* Sexy tooltip */ + G_TYPE_STRING, /* Process Name */ + G_TYPE_STRING, /* User */ + G_TYPE_UINT, /* Status */ + G_TYPE_ULONG, /* VM Size */ + G_TYPE_ULONG, /* Resident Memory */ + G_TYPE_ULONG, /* Writable Memory */ + G_TYPE_ULONG, /* Shared Memory */ + G_TYPE_ULONG, /* X Server Memory */ + G_TYPE_UINT, /* % CPU */ + G_TYPE_UINT64, /* CPU time */ + G_TYPE_ULONG, /* Started */ + G_TYPE_INT, /* Nice */ + G_TYPE_UINT, /* ID */ + G_TYPE_STRING, /* Security Context */ + G_TYPE_STRING, /* Arguments */ + G_TYPE_ULONG, /* Memory */ + G_TYPE_STRING, /* wchan */ + G_TYPE_STRING, /* Cgroup */ + G_TYPE_STRING, /* Unit */ + G_TYPE_STRING, /* Session */ + G_TYPE_STRING, /* Seat */ + G_TYPE_STRING, /* Owner */ + G_TYPE_STRING, /* Priority */ + CAIRO_GOBJECT_TYPE_SURFACE, /* Icon */ + G_TYPE_POINTER, /* ProcInfo */ + G_TYPE_STRING /* Sexy tooltip */ ); proctree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); @@ -323,7 +323,7 @@ proctable_new (ProcData * const procdata) cell_renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, cell_renderer, FALSE); gtk_tree_view_column_set_attributes (column, cell_renderer, - "pixbuf", COL_PIXBUF, + "surface", COL_SURFACE, NULL); cell_renderer = gtk_cell_renderer_text_new (); @@ -520,6 +520,7 @@ ProcInfo::~ProcInfo() g_free(this->unit); g_free(this->session); g_free(this->seat); + cairo_surface_destroy(this->surface); } @@ -831,7 +832,7 @@ update_info (ProcData *procdata, ProcInfo *info) ProcInfo::ProcInfo(pid_t pid) : node(), - pixbuf(), + surface(), tooltip(NULL), name(NULL), arguments(NULL), @@ -1117,11 +1118,11 @@ make_loadavg_string(void) void ProcInfo::set_icon(Glib::RefPtr<Gdk::Pixbuf> icon) { - this->pixbuf = icon; + this->surface = gdk_cairo_surface_create_from_pixbuf (icon->gobj(), 0, NULL); GtkTreeModel *model; model = gtk_tree_view_get_model(GTK_TREE_VIEW(ProcData::get_instance()->tree)); gtk_tree_store_set(GTK_TREE_STORE(model), &this->node, - COL_PIXBUF, (this->pixbuf ? this->pixbuf->gobj() : NULL), + COL_SURFACE, this->surface, -1); } |