[nautilus/wip/antoniof/switch-to-gtk4: 12/22] general: Adapt to GtkDrawingArea API changes
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/switch-to-gtk4: 12/22] general: Adapt to GtkDrawingArea API changes
- Date: Sun, 9 Jan 2022 00:36:26 +0000 (UTC)
commit 0bd792db240bb9dcc14ab94602b67b44ad5b77c3
Author: António Fernandes <antoniof gnome org>
Date: Thu Dec 23 23:54:46 2021 +0000
general: Adapt to GtkDrawingArea API changes
Now we set a function instead of listening to a signal.
src/nautilus-properties-window.c | 30 ++++++++++++++++++------------
src/nautilus-toolbar.c | 13 +++++++++----
src/resources/ui/nautilus-toolbar.ui | 1 -
3 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index f7274bbfb..1682c514e 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -2400,10 +2400,13 @@ should_show_volume_usage (NautilusPropertiesWindow *self)
}
static void
-paint_legend (GtkWidget *widget,
- cairo_t *cr,
- gpointer data)
+paint_legend (GtkDrawingArea *drawing_area,
+ cairo_t *cr,
+ int width,
+ int height,
+ gpointer data)
{
+ GtkWidget *widget = GTK_WIDGET (drawing_area);
GtkStyleContext *context;
GtkAllocation allocation;
@@ -2488,11 +2491,14 @@ paint_slice (GtkWidget *widget,
}
static void
-paint_pie_chart (GtkWidget *widget,
- cairo_t *cr,
- gpointer data)
+paint_pie_chart (GtkDrawingArea *drawing_area,
+ cairo_t *cr,
+ int width,
+ int height,
+ gpointer data)
{
NautilusPropertiesWindow *self;
+ GtkWidget *widget = GTK_WIDGET (drawing_area);
double free, used, reserved;
self = NAUTILUS_PROPERTIES_WINDOW (data);
@@ -2552,12 +2558,12 @@ setup_pie_widget (NautilusPropertiesWindow *self)
}
}
- g_signal_connect (self->pie_chart, "draw",
- G_CALLBACK (paint_pie_chart), self);
- g_signal_connect (self->used_color, "draw",
- G_CALLBACK (paint_legend), self);
- g_signal_connect (self->free_color, "draw",
- G_CALLBACK (paint_legend), self);
+ gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->pie_chart),
+ paint_pie_chart, self, NULL);
+ gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->used_color),
+ paint_legend, self, NULL);
+ gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->free_color),
+ paint_legend, self, NULL);
}
static void
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 5df687cc0..758d387ee 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -570,18 +570,19 @@ on_new_progress_info (NautilusProgressInfoManager *manager,
}
static void
-on_operations_icon_draw (GtkWidget *widget,
+on_operations_icon_draw (GtkDrawingArea *drawing_area,
cairo_t *cr,
+ int width,
+ int height,
NautilusToolbar *self)
{
+ GtkWidget *widget = GTK_WIDGET (drawing_area);
gfloat elapsed_progress = 0;
gint remaining_progress = 0;
gint total_progress;
gdouble ratio;
GList *progress_infos;
GList *l;
- guint width;
- guint height;
gboolean all_cancelled;
GdkRGBA background;
GdkRGBA foreground;
@@ -869,6 +870,11 @@ nautilus_toolbar_init (NautilusToolbar *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->operations_icon),
+ (GtkDrawingAreaDrawFunc) on_operations_icon_draw,
+ self,
+ NULL);
+
gtk_widget_set_parent (self->back_menu, self->back_button);
g_signal_connect (self->back_menu, "destroy", G_CALLBACK (gtk_widget_unparent), NULL);
gtk_widget_set_parent (self->forward_menu, self->forward_button);
@@ -1141,7 +1147,6 @@ nautilus_toolbar_class_init (NautilusToolbarClass *klass)
gtk_widget_class_bind_template_child (widget_class, NautilusToolbar, search_button);
- gtk_widget_class_bind_template_callback (widget_class, on_operations_icon_draw);
gtk_widget_class_bind_template_callback (widget_class, on_operations_popover_notify_visible);
}
diff --git a/src/resources/ui/nautilus-toolbar.ui b/src/resources/ui/nautilus-toolbar.ui
index a95cbfaae..e9a101029 100644
--- a/src/resources/ui/nautilus-toolbar.ui
+++ b/src/resources/ui/nautilus-toolbar.ui
@@ -254,7 +254,6 @@
<property name="height_request">16</property>
<property name="halign">center</property>
<property name="valign">center</property>
- <signal name="draw" handler="on_operations_icon_draw" object="NautilusToolbar"
swapped="no"/>
</object>
</child>
<style>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]