summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Østergaard <oe.nick@gmail.com>2021-01-02 14:14:55 +0100
committerNick Østergaard <oe.nick@gmail.com>2021-01-03 17:01:17 +0100
commit10206a0082be18322beb94b1abf91d87415a901e (patch)
tree899ae5994878fd9cf505f7451f1888b8123ff3f4 /src
parentb862dc953ba5ab4c95ad2d4bca696c1be708f8bf (diff)
downloaddistcc-git-10206a0082be18322beb94b1abf91d87415a901e.tar.gz
Initial work on a gtk3 port
Try to align function prototypes Actually works, but is a bit unstable. Bar can appear in left pane or right pane and fill the whole window height, or it can outright crash randomly. Maybe mostly when resizing the window? Or certainly when you click the area with the bars.
Diffstat (limited to 'src')
-rw-r--r--src/mon-gnome.c22
-rw-r--r--src/renderer.c41
-rw-r--r--src/renderer.h3
3 files changed, 49 insertions, 17 deletions
diff --git a/src/mon-gnome.c b/src/mon-gnome.c
index bfc286d..c09140c 100644
--- a/src/mon-gnome.c
+++ b/src/mon-gnome.c
@@ -101,7 +101,9 @@ enum {
* Graphics contexts to be used to draw each particular state into the
* model.
**/
-GdkGC *dcc_phase_gc[DCC_PHASE_DONE];
+//GdkGC *dcc_phase_gc[DCC_PHASE_DONE];
+//TODO rename _gc to _cr
+cairo_t *dcc_phase_gc[DCC_PHASE_DONE];
#if 0
@@ -453,7 +455,7 @@ static void
dcc_create_state_gcs (GtkWidget *widget)
{
enum dcc_phase i_state;
-
+#if 0
for (i_state = 0; i_state < DCC_PHASE_DONE; i_state++)
{
dcc_phase_gc[i_state] = gdk_gc_new (widget->window);
@@ -461,6 +463,16 @@ dcc_create_state_gcs (GtkWidget *widget)
(GdkColor *) &task_color[i_state]);
}
+#else
+ for (i_state = 0; i_state < DCC_PHASE_DONE; i_state++)
+ {
+ GdkWindow * gdk_window = gtk_widget_get_window (widget);
+ dcc_phase_gc[i_state] = gdk_cairo_create(gdk_window);
+ gdk_cairo_set_source_color (dcc_phase_gc[i_state],
+ (GdkColor *) &task_color[i_state]);
+
+ }
+#endif
}
@@ -477,7 +489,7 @@ static void dcc_gnome_make_proc_view (GtkTreeModel *proc_model,
GtkWidget *align, *proc_scroll;
chart_treeview = gtk_tree_view_new_with_model (proc_model);
- gtk_object_set (GTK_OBJECT (chart_treeview),
+ g_object_set (G_OBJECT (chart_treeview),
"headers-visible", TRUE,
NULL);
@@ -592,9 +604,9 @@ static GtkWidget * dcc_gnome_make_mainwin (void)
gtk_window_set_default_size (GTK_WINDOW (mainwin), 500, 300);
/* Quit when it's closed */
- g_signal_connect (GTK_OBJECT(mainwin), "delete-event",
+ g_signal_connect (G_OBJECT(mainwin), "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
- g_signal_connect (GTK_OBJECT(mainwin), "destroy",
+ g_signal_connect (G_OBJECT(mainwin), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
#if GTK_CHECK_VERSION(2,2,0)
diff --git a/src/renderer.c b/src/renderer.c
index ca329fa..a73c8de 100644
--- a/src/renderer.c
+++ b/src/renderer.c
@@ -160,18 +160,17 @@ dcc_cell_renderer_chart_get_property (GObject *object,
**/
static void
dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
- GdkWindow *window,
+ cairo_t *cr,
GtkWidget *UNUSED(widget),
- GdkRectangle *UNUSED(background_area),
- GdkRectangle *cell_area,
- GdkRectangle *UNUSED(expose_area),
+ const GdkRectangle *UNUSED(background_area),
+ const GdkRectangle *cell_area,
GtkCellRendererState UNUSED(flags))
{
const struct dcc_history *history;
enum dcc_phase state;
int x1, y1;
- int bar_height;
- int bar_width;
+ int bar_height, bar_width;
+ int xpad, ypad;
int i;
const enum dcc_phase *phases;
@@ -179,10 +178,23 @@ dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
history = cellchart->history;
g_return_if_fail (history); /* Perhaps we should just ignore this.. */
+ gtk_cell_renderer_get_padding(cell, &xpad, &ypad);
+ x1 = cell_area->x + xpad;
+ y1 = cell_area->y + ypad;
+ bar_height = cell_area->height - (2 * ypad);
+
+ const GdkColor task_color[] = {
+ { 0, 0x9999, 0, 0 }, /* DCC_PHASE_STARTUP, accent red dark */
+ { 0, 0x9999, 0, 0 }, /* DCC_PHASE_BLOCKED, accent red dark */
+ { 0, 0xc1c1, 0x6666, 0x5a5a }, /* DCC_PHASE_CONNECT, red medium */
+ { 0, 0x8888, 0x7f7f, 0xa3a3 }, /* DCC_PHASE_CPP, purple medium*/
+ { 0, 0xe0e0, 0xc3c3, 0x9e9e }, /* DCC_PHASE_SEND, face skin medium*/
+ { 0, 0x8383, 0xa6a6, 0x7f7f }, /* DCC_PHASE_COMPILE, green medium */
+ { 0, 0x7575, 0x9090, 0xaeae }, /* DCC_PHASE_RECEIVE, blue medium*/
+ { 0, 0, 0, 0 }, /* DCC_PHASE_DONE */
+};
+
- x1 = cell_area->x + cell->xpad;
- y1 = cell_area->y + cell->ypad;
- bar_height = cell_area->height - (2 * cell->ypad);
/* bar width is chosen such that the history roughly fills the cell
(but it must be at least 1). We use the full history, not just
@@ -200,10 +212,17 @@ dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
if (state != DCC_PHASE_DONE)
{
+#if 0
gdk_draw_rectangle (window,
dcc_phase_gc[state],
TRUE, /* fill */
x1, y1, bar_width, bar_height);
+#else
+gdk_cairo_set_source_color (cr, (GdkColor *) &task_color[state]);
+cairo_rectangle (cr, x1, y1, bar_width, bar_height);
+cairo_fill (cr);
+//cairo_destroy (cr);
+#endif
}
x1 += bar_width;
@@ -216,9 +235,9 @@ dcc_cell_renderer_chart_render (GtkCellRenderer *cell,
* Measure the size that we want to have allocated for this cell.
*/
static void
-dcc_cell_renderer_chart_get_size (GtkCellRenderer *UNUSED(cell),
+dcc_cell_renderer_chart_get_size (GtkCellRenderer *UNUSED (cell),
GtkWidget *UNUSED (widget),
- GdkRectangle *UNUSED (cell_area),
+ const GdkRectangle *UNUSED (cell_area),
gint *UNUSED (x_offset),
gint *UNUSED (y_offset),
gint *UNUSED (width),
diff --git a/src/renderer.h b/src/renderer.h
index 8246040..4f46eef 100644
--- a/src/renderer.h
+++ b/src/renderer.h
@@ -43,6 +43,7 @@ GType dcc_cell_renderer_chart_get_type (void);
GtkCellRenderer *dcc_cell_renderer_chart_new (void);
-extern GdkGC *dcc_phase_gc[DCC_PHASE_DONE];
+//extern GdkGC *dcc_phase_gc[DCC_PHASE_DONE];
+extern cairo_t *dcc_phase_gc[DCC_PHASE_DONE];
extern const guint dcc_max_history_queue;