summaryrefslogtreecommitdiff
path: root/src/proctable.cpp
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2019-07-11 00:23:18 -0400
committerraveit65 <[email protected]>2019-07-13 11:13:14 +0200
commitbc190e7b657f715c5dc21eda1d910d1d3c52664f (patch)
tree3b476660c96d32af2fa867d8b84156f191be6332 /src/proctable.cpp
parent53ea0436414263d0be7e5e2ae5c6dcfc7b9047dc (diff)
downloadmate-system-monitor-bc190e7b657f715c5dc21eda1d910d1d3c52664f.tar.bz2
mate-system-monitor-bc190e7b657f715c5dc21eda1d910d1d3c52664f.tar.xz
Render icons as cairo surfaces for HiDPI support
Diffstat (limited to 'src/proctable.cpp')
-rw-r--r--src/proctable.cpp71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 7b309da..b9b0a75 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>
@@ -281,36 +281,36 @@ 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_UINT64, /* Disk read total */
- G_TYPE_UINT64, /* Disk write total*/
- G_TYPE_UINT64, /* Disk read */
- G_TYPE_UINT64, /* Disk write */
- 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_UINT64, /* Disk read total */
+ G_TYPE_UINT64, /* Disk write total*/
+ G_TYPE_UINT64, /* Disk read */
+ G_TYPE_UINT64, /* Disk write */
+ 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));
@@ -332,7 +332,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 ();
@@ -549,6 +549,7 @@ ProcInfo::~ProcInfo()
g_free(this->unit);
g_free(this->session);
g_free(this->seat);
+ cairo_surface_destroy(this->surface);
}
@@ -875,7 +876,7 @@ update_info (ProcData *procdata, ProcInfo *info)
ProcInfo::ProcInfo(pid_t pid)
: node(),
- pixbuf(),
+ surface(),
tooltip(NULL),
name(NULL),
arguments(NULL),
@@ -1161,11 +1162,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);
}