mate-desktop / mate-system-monitor

Process viewer and system resource monitor for MATE
https://mate-desktop.org
GNU General Public License v2.0
45 stars 27 forks source link

Add GSettings for LoadGraph UI colors #247

Open xcodian opened 1 year ago

xcodian commented 1 year ago

Makes the background color and grid color for the load graphs configurable instead of being hardcoded to #FFFFFF and #E3E3E3.

New GSettings keys added to the schema:

Fixes: #88

xcodian commented 1 year ago

My mistake, my editor automatically added them and I didn't notice in the diff. Commit 4e336a90373f46c69b2cb5d328ab68f1c25f6c2d should have removed them now.

zhuyaliang commented 1 year ago

There is a problem. When the load-graph-background-color and load-graph-grid-color GSettings is changed, no emit configure_event signal, so the background will not be cleared and repaint.

 g_signal_connect (G_OBJECT(disp), "configure_event",
                      G_CALLBACK (load_graph_configure), graph);

static gboolean
load_graph_configure (GtkWidget *widget,
                      GdkEventConfigure *event,
                      gpointer data_ptr)
{                     
....
    graph->clear_background();
....
}   

if (graph->background == NULL) {
        draw_background(graph);
}     

I think it should add clear_background:

    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;
        procdata->cpu_graph->clear_background (); 
        procdata->mem_graph->clear_background (); 
        procdata->net_graph->clear_background (); 
    }   
    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;
        procdata->cpu_graph->clear_background (); 
        procdata->mem_graph->clear_background (); 
        procdata->net_graph->clear_background (); 
    }   

Maybe there is a better way. This is just my suggestion