Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GSettings for LoadGraph UI colors #247

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,14 @@ create_sys_view (ProcData *procdata, GtkBuilder * builder)

procdata->net_graph = net_graph;
g_free(title_template);

procdata->cpu_graph->background_color = procdata->config.load_graph_background_color;
procdata->mem_graph->background_color = procdata->config.load_graph_background_color;
procdata->net_graph->background_color = procdata->config.load_graph_background_color;

procdata->cpu_graph->grid_color = procdata->config.load_graph_grid_color;
procdata->mem_graph->grid_color = procdata->config.load_graph_grid_color;
procdata->net_graph->grid_color = procdata->config.load_graph_grid_color;
}

static void
Expand Down Expand Up @@ -679,3 +687,4 @@ cb_proc_goto_tab (gint tab)
ProcData *data = ProcData::get_instance ();
gtk_notebook_set_current_page (GTK_NOTEBOOK (data->notebook), tab);
}

13 changes: 4 additions & 9 deletions src/load-graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static void draw_background(LoadGraph *graph) {
cairo_translate (cr, FRAME_WIDTH, FRAME_WIDTH);

/* Draw background rectangle */
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
gdk_cairo_set_source_rgba (cr, &graph->background_color);
cairo_rectangle (cr, graph->rmargin + graph->indent, 0,
graph->draw_width - graph->rmargin - graph->indent, graph->real_draw_height);
cairo_fill(cr);
Expand Down Expand Up @@ -150,10 +150,7 @@ static void draw_background(LoadGraph *graph) {
pango_cairo_show_layout (cr, layout);
}

if (i==0 || i==num_bars)
cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
else
cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
gdk_cairo_set_source_rgba (cr, &graph->grid_color);
cairo_move_to (cr, graph->rmargin + graph->indent - 3, i * graph->graph_dely + 0.5);
cairo_line_to (cr, graph->draw_width - 0.5, i * graph->graph_dely + 0.5);
cairo_stroke (cr);
Expand All @@ -163,10 +160,7 @@ static void draw_background(LoadGraph *graph) {

for (unsigned int i = 0; i < 7; i++) {
double x = (i) * (graph->draw_width - graph->rmargin - graph->indent) / 6;
if (i==0 || i==6)
cairo_set_source_rgba (cr, 0.70, 0.71, 0.70, 1.0);
else
cairo_set_source_rgba (cr, 0.89, 0.89, 0.89, 1.0);
gdk_cairo_set_source_rgba (cr, &graph->grid_color);
cairo_move_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, 0.5);
cairo_line_to (cr, (ceil(x) + 0.5) + graph->rmargin + graph->indent, graph->real_draw_height + 4.5);
cairo_stroke(cr);
Expand Down Expand Up @@ -849,3 +843,4 @@ load_graph_get_swap_color_picker(LoadGraph *graph)
{
return graph->swap_color_picker;
}

3 changes: 3 additions & 0 deletions src/load-graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ struct LoadGraph {
guint graph_buffer_offset;

std::vector<GdkRGBA> colors;
GdkRGBA background_color;
GdkRGBA grid_color;

std::vector<float> data_block;
gfloat* data[NUM_POINTS];
Expand Down Expand Up @@ -124,3 +126,4 @@ GtkWidget*
load_graph_get_swap_color_picker(LoadGraph *g) G_GNUC_CONST;

#endif /* _PROCMAN_LOAD_GRAPH_H_ */

9 changes: 9 additions & 0 deletions src/org.mate.system-monitor.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@
</default>
<summary>Show network traffic in bits</summary>
</key>
<key name="load-graph-background-color" type="s">
<default>'#FFFFFF'</default>
<summary>Default graph background color</summary>
</key>
<key name="load-graph-grid-color" type="s">
<default>'#E3E3E3'</default>
<summary>Default graph grid color</summary>
</key>
<child name="proctree" schema="org.mate.system-monitor.proctree"/>
<child name="disktreenew" schema="org.mate.system-monitor.disktreenew"/>
<child name="memmapstree" schema="org.mate.system-monitor.memmapstree"/>
Expand Down Expand Up @@ -537,3 +545,4 @@
</key>
</schema>
</schemalist>

29 changes: 29 additions & 0 deletions src/procman-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ color_changed_cb (GSettings *settings, const gchar *key, gpointer data)
gdk_rgba_parse (&procdata->config.net_out_color, color);
procdata->net_graph->colors.at(1) = procdata->config.net_out_color;
}
else if (g_str_equal (key, "load-graph-background-color")) {
gdk_rgba_parse (&procdata->config.load_graph_background_color, color);
procdata->cpu_graph->background_color = procdata->config.load_graph_background_color;
procdata->mem_graph->background_color = procdata->config.load_graph_background_color;
procdata->net_graph->background_color = procdata->config.load_graph_background_color;
}
else if (g_str_equal (key, "load-graph-grid-color")) {
gdk_rgba_parse (&procdata->config.load_graph_grid_color, color);
procdata->cpu_graph->grid_color = procdata->config.load_graph_grid_color;
procdata->mem_graph->grid_color = procdata->config.load_graph_grid_color;
procdata->net_graph->grid_color = procdata->config.load_graph_grid_color;
}
else {
g_assert_not_reached();
}
Expand Down Expand Up @@ -306,6 +318,22 @@ procman_data_new (GSettings *settings)
gdk_rgba_parse(&pd->config.net_out_color, color);
g_free (color);

color = g_settings_get_string (settings, "load-graph-background-color");
if (!color)
color = g_strdup ("#ffffff");
g_signal_connect (G_OBJECT(settings), "changed::load-graph-background-color",
G_CALLBACK(color_changed_cb), pd);
gdk_rgba_parse(&pd->config.load_graph_background_color, color);
g_free (color);

color = g_settings_get_string (settings, "load-graph-grid-color");
if (!color)
color = g_strdup ("#e3e3e3");
g_signal_connect (G_OBJECT(settings), "changed::load-graph-grid-color",
G_CALLBACK(color_changed_cb), pd);
gdk_rgba_parse(&pd->config.load_graph_grid_color, color);
g_free (color);

/* Sanity checks */
GdkDisplay *display;
GdkMonitor *monitor;
Expand Down Expand Up @@ -434,3 +462,4 @@ void ProcmanApp::on_shutdown()
glibtop_close();
}


3 changes: 3 additions & 0 deletions src/procman.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ struct ProcConfig
GdkRGBA net_out_color;
GdkRGBA bg_color;
GdkRGBA frame_color;
GdkRGBA load_graph_background_color;
GdkRGBA load_graph_grid_color;
gint num_cpus;
bool solaris_mode;
bool network_in_bits;
Expand Down Expand Up @@ -261,3 +263,4 @@ struct KillArgs
};

#endif /* _PROCMAN_PROCMAN_H_ */