From a2ae53dd767d8def3545fa7d53599505619ca5f1 Mon Sep 17 00:00:00 2001 From: Bert Burgemeister Date: Wed, 27 Apr 2016 20:15:32 +0200 Subject: [PATCH] Automate away GtkDrawinArea command "refresh" --- NEWS | 2 ++ clock.sh | 1 - pipeglade.1 | 7 +------ pipeglade.c | 25 +++++++++++++++++------- pipegladetest.sh | 58 ++++++++++++++++++++++++++++---------------------------- 5 files changed, 50 insertions(+), 43 deletions(-) diff --git a/NEWS b/NEWS index 7953825..ee6b8f6 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ * Add missing GtkStatusbar command remove_all_id. * GtkStatusbar commands take non-whitespace strings as context id, not just integers. + * Remove GtkDrawingArea command refresh; refreshing happens + automatically. * Add GtkDrawingArea command set_font_face. * Add GtkDrawingArea command rel_move_for supporting text placement with respect to center, upper left corner, etc., of the text. diff --git a/clock.sh b/clock.sh index 784cdc3..cb3d60d 100755 --- a/clock.sh +++ b/clock.sh @@ -56,7 +56,6 @@ echo "drawingarea1:stroke $S" echo "drawingarea1:remove $S0" S0=$S - echo "drawingarea1:refresh" sleep 1 done diff --git a/pipeglade.1 b/pipeglade.1 index a164bbd..0bfe3a1 100644 --- a/pipeglade.1 +++ b/pipeglade.1 @@ -19,7 +19,7 @@ .\" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION .\" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. .\" -.Dd April 24, 2016 +.Dd April 27, 2016 .Dt PIPEGLADE 1 PRM .Os BSD .Sh NAME @@ -603,11 +603,6 @@ adds a rectangle to the current path. The top left corner is at .Pq Ar x , y . .Pp -.Qq Ar name Ns Cm :refresh -redraws the -.Cm GtkDrawingArea -.Ar name . -.Pp .Qq Ar name Ns Cm :rel_curve_to Ar id dx1 dy1 dx2 dy2 dx3 dy3 adds a cubic Bezier spline from the current point to .Pq Ar dx3 , dy3 , diff --git a/pipeglade.c b/pipeglade.c index b250c9e..49f112d 100644 --- a/pipeglade.c +++ b/pipeglade.c @@ -1554,6 +1554,16 @@ rem_draw_op(GObject *widget, const char *data) return true; } +static gboolean +refresh_widget(GtkWidget *widget) +{ + gint width = gtk_widget_get_allocated_width(widget); + gint height = gtk_widget_get_allocated_height(widget); + + gtk_widget_queue_draw_area(widget, 0, 0, width, height); + return G_SOURCE_REMOVE; +} + static void update_drawing_area(GObject *obj, const char *action, const char *data, const char *whole_msg, GType type) @@ -1561,14 +1571,16 @@ update_drawing_area(GObject *obj, const char *action, if (eql(action, "remove")) { if (!rem_draw_op(obj, data)) ign_cmd(type, whole_msg); - } else if (eql(action, "refresh")) { - gint width = gtk_widget_get_allocated_width(GTK_WIDGET(obj)); - gint height = gtk_widget_get_allocated_height(GTK_WIDGET(obj)); - - gtk_widget_queue_draw_area(GTK_WIDGET(obj), 0, 0, width, height); } else if (ins_draw_op(obj, action, data)); else ign_cmd(type, whole_msg); + if (eql(action, "stroke") || + eql(action, "fill") || + eql(action, "show_text") || + eql(action, "remove")) + gdk_threads_add_idle_full(G_PRIORITY_LOW, + (GSourceFunc) refresh_widget, + GTK_WIDGET(obj), NULL); } static void @@ -2697,8 +2709,7 @@ connect_widget_signals(gpointer *obj, char *ui_file) g_signal_connect(renderer, "toggled", G_CALLBACK(cb_tree_model_toggle), model); } } - } - else if (type == GTK_TYPE_BUTTON) { + } else if (type == GTK_TYPE_BUTTON) { /* Button associated with a GtkTextView. */ if ((suffix = strstr(name, "_send_text")) != NULL && GTK_IS_TEXT_VIEW(obj2 = obj_sans_suffix(suffix, name))) diff --git a/pipegladetest.sh b/pipegladetest.sh index f482f11..7874053 100755 --- a/pipegladetest.sh +++ b/pipegladetest.sh @@ -1751,19 +1751,19 @@ check 1 "" \ "calendar1:clicked 1752-03-13" check 0 "" \ - "drawingarea1:rectangle 1 0 0 150 150\n drawingarea1:fill 1\n drawingarea1:refresh" + "drawingarea1:rectangle 1 0 0 150 150\n drawingarea1:fill 1" check 0 "" \ - "drawingarea1:remove 1\n drawingarea1:remove 2\n drawingarea1:remove 3\n drawingarea1:remove 4\n drawingarea1:refresh" + "drawingarea1:remove 1\n drawingarea1:remove 2\n drawingarea1:remove 3\n drawingarea1:remove 4" check 0 "" \ - "drawingarea1:rectangle 1 0 0 150 150\n drawingarea1:fill 1\n drawingarea1:refresh" + "drawingarea1:rectangle 1 0 0 150 150\n drawingarea1:fill 1" check 0 "" \ - "drawingarea1:arc 1 80 80 60 30 60\n drawingarea1:set_source_rgba 1 red\n drawingarea1:stroke_preserve 1\n drawingarea1:line_to 1 80 80\n drawingarea1:fill 1\n drawingarea1:refresh" + "drawingarea1:arc 1 80 80 60 30 60\n drawingarea1:set_source_rgba 1 red\n drawingarea1:stroke_preserve 1\n drawingarea1:line_to 1 80 80\n drawingarea1:fill 1" check 0 "" \ - "drawingarea1:arc_negative 1 80 80 70 30 60\n drawingarea1:set_source_rgba 1 green\n drawingarea1:stroke_preserve 1\n drawingarea1:rel_line_to 1 -50 -50\n drawingarea1:stroke 1\n drawingarea1:refresh" + "drawingarea1:arc_negative 1 80 80 70 30 60\n drawingarea1:set_source_rgba 1 green\n drawingarea1:stroke_preserve 1\n drawingarea1:rel_line_to 1 -50 -50\n drawingarea1:stroke 1" check 0 "" \ - "drawingarea1:curve_to 1 30 30 90 120 120 30\n drawingarea1:set_source_rgba 1 blue\n drawingarea1:stroke 1\n drawingarea1:refresh" + "drawingarea1:curve_to 1 30 30 90 120 120 30\n drawingarea1:set_source_rgba 1 blue\n drawingarea1:stroke 1" check 0 "" \ - "drawingarea1:move_to 1 160 160\n drawingarea1:rel_curve_to 1 30 30 90 120 120 30\n drawingarea1:set_source_rgba 1 orange\n drawingarea1:stroke_preserve 1\n drawingarea1:refresh" + "drawingarea1:move_to 1 160 160\n drawingarea1:rel_curve_to 1 30 30 90 120 120 30\n drawingarea1:set_source_rgba 1 orange\n drawingarea1:stroke_preserve 1" check 0 "" \ "drawingarea1:move_to 1 0 0\n drawingarea1:rel_move_to 1 0 155\n drawingarea1:rel_line_to 1 300 0\n drawingarea1:set_dash 1 10\n drawingarea1:stroke 1" check 0 "" \ @@ -1773,43 +1773,43 @@ check 0 "" \ check 0 "" \ "drawingarea1:move_to 1 0 170\n drawingarea1:rel_line_to 1 300 0\n drawingarea1:set_dash 1 3 3 3 3 3 15\n drawingarea1:stroke 1" check 0 "" \ - "drawingarea1:refresh\n drawingarea1:set_dash 1" + "drawingarea1:set_dash 1" check 0 "" \ "drawingarea1:set_source_rgba 1 brown\n drawingarea1:set_line_width 1 15" check 1 "Press \"OK\" if the brown shape is rounded" \ - "drawingarea1:set_line_join 2 round\n drawingarea1:set_line_cap 2 round\n drawingarea1:move_to 1 160 20\n drawingarea1:rel_line_to 1 20 0\n drawingarea1:rel_line_to 1 0 20\n drawingarea1:stroke 1\n drawingarea1:refresh" \ + "drawingarea1:set_line_join 2 round\n drawingarea1:set_line_cap 2 round\n drawingarea1:move_to 1 160 20\n drawingarea1:rel_line_to 1 20 0\n drawingarea1:rel_line_to 1 0 20\n drawingarea1:stroke 1" \ "button1:clicked" check 1 "Press \"OK\" if the second brown shape is shorter and bevelled" \ - "drawingarea1:set_line_join 3 bevel\n drawingarea1:set_line_cap 3 butt\n drawingarea1:move_to 1 160 70\n drawingarea1:rel_line_to 1 20 0\n drawingarea1:rel_line_to 1 0 20\n drawingarea1:stroke 1\n drawingarea1:refresh" \ + "drawingarea1:set_line_join 3 bevel\n drawingarea1:set_line_cap 3 butt\n drawingarea1:move_to 1 160 70\n drawingarea1:rel_line_to 1 20 0\n drawingarea1:rel_line_to 1 0 20\n drawingarea1:stroke 1" \ "button1:clicked" check 1 "Press \"OK\" if the third brown shape is square" \ - "drawingarea1:set_line_join 3 miter\n drawingarea1:set_line_cap 3 square\n drawingarea1:move_to 1 160 120\n drawingarea1:rel_line_to 1 20 0\n drawingarea1:rel_line_to 1 0 20\n drawingarea1:stroke 1\n drawingarea1:refresh" \ + "drawingarea1:set_line_join 3 miter\n drawingarea1:set_line_cap 3 square\n drawingarea1:move_to 1 160 120\n drawingarea1:rel_line_to 1 20 0\n drawingarea1:rel_line_to 1 0 20\n drawingarea1:stroke 1" \ "button1:clicked" check 1 "Press \"OK\" if the first brown shape is no longer rounded" \ - "drawingarea1:remove 2\n drawingarea1:refresh" \ + "drawingarea1:remove 2" \ "button1:clicked" check 1 "Press \"OK\" if all three brown shapes look the same" \ - "drawingarea1:remove 3\n drawingarea1:refresh" \ + "drawingarea1:remove 3" \ "button1:clicked" check 0 "" \ - "drawingarea1:move_to 5 50 50\n drawingarea1:line_to 5 200 10\n drawingarea1:line_to 5 150 200\n drawingarea1:close_path 1\n drawingarea1:set_source_rgba 5 rgba(0,255,0,.2)\n drawingarea1:fill_preserve 1\n drawingarea1:refresh" + "drawingarea1:move_to 5 50 50\n drawingarea1:line_to 5 200 10\n drawingarea1:line_to 5 150 200\n drawingarea1:close_path 1\n drawingarea1:set_source_rgba 5 rgba(0,255,0,.2)\n drawingarea1:fill_preserve 1" check 0 "" \ - "drawingarea1:move_to 5 10 50\n drawingarea1:set_source_rgba 5 cyan\n drawingarea1:set_font_size 5 30\n drawingarea1:show_text 5 Xyz 789\n drawingarea1:set_font_size 5 10\n drawingarea1:show_text 5 Abc 123\n drawingarea1:refresh" + "drawingarea1:move_to 5 10 50\n drawingarea1:set_source_rgba 5 cyan\n drawingarea1:set_font_size 5 30\n drawingarea1:show_text 5 Xyz 789\n drawingarea1:set_font_size 5 10\n drawingarea1:show_text 5 Abc 123" check 0 "" \ - "drawingarea1:move_to 5 10 75\n drawingarea1:set_source_rgba 5 red\n drawingarea1:set_font_face 5 italic bold Courier\n drawingarea1:set_font_size 5 30\n drawingarea1:show_text 5 Xyz 789\n drawingarea1:set_font_size 5 10\n drawingarea1:show_text 5 Abc 123\n drawingarea1:refresh" + "drawingarea1:move_to 5 10 75\n drawingarea1:set_source_rgba 5 red\n drawingarea1:set_font_face 5 italic bold Courier\n drawingarea1:set_font_size 5 30\n drawingarea1:show_text 5 Xyz 789\n drawingarea1:set_font_size 5 10\n drawingarea1:show_text 5 Abc 123" check 0 "" \ - "drawingarea1:remove 1\n drawingarea1:remove 2\n drawingarea1:remove 3\n drawingarea1:remove 4\n drawingarea1:refresh" + "drawingarea1:remove 1\n drawingarea1:remove 2\n drawingarea1:remove 3\n drawingarea1:remove 4" check 0 "" \ - "drawingarea2:rectangle 1 0 0 150 150\n drawingarea2:fill 1\n drawingarea2:refresh" + "drawingarea2:rectangle 1 0 0 150 150\n drawingarea2:fill 1" check 0 "" \ - "drawingarea2:arc 1 80 80 60 30 60\n drawingarea2:set_source_rgba 1 red\n drawingarea2:stroke_preserve 1\n drawingarea2:line_to 1 80 80\n drawingarea2:fill 1\n drawingarea2:refresh" + "drawingarea2:arc 1 80 80 60 30 60\n drawingarea2:set_source_rgba 1 red\n drawingarea2:stroke_preserve 1\n drawingarea2:line_to 1 80 80\n drawingarea2:fill 1" check 0 "" \ - "drawingarea2:arc_negative 1 80 80 70 30 60\n drawingarea2:set_source_rgba 1 green\n drawingarea2:stroke_preserve 1\n drawingarea2:rel_line_to 1 -50 -50\n drawingarea2:stroke 1\n drawingarea2:refresh" + "drawingarea2:arc_negative 1 80 80 70 30 60\n drawingarea2:set_source_rgba 1 green\n drawingarea2:stroke_preserve 1\n drawingarea2:rel_line_to 1 -50 -50\n drawingarea2:stroke 1" check 0 "" \ - "drawingarea2:curve_to 1 30 30 90 120 120 30\n drawingarea2:set_source_rgba 1 blue\n drawingarea2:stroke 1\n drawingarea2:refresh" + "drawingarea2:curve_to 1 30 30 90 120 120 30\n drawingarea2:set_source_rgba 1 blue\n drawingarea2:stroke 1" check 0 "" \ - "drawingarea2:move_to 1 160 160\n drawingarea2:rel_curve_to 1 30 30 90 120 120 30\n drawingarea2:set_source_rgba 1 orange\n drawingarea2:stroke_preserve 1\n drawingarea2:refresh" + "drawingarea2:move_to 1 160 160\n drawingarea2:rel_curve_to 1 30 30 90 120 120 30\n drawingarea2:set_source_rgba 1 orange\n drawingarea2:stroke_preserve 1" check 0 "" \ "drawingarea2:move_to 1 0 0\n drawingarea2:rel_move_to 1 0 155\n drawingarea2:rel_line_to 1 300 0\n drawingarea2:set_dash 1 10\n drawingarea2:stroke 1" check 0 "" \ @@ -1819,19 +1819,19 @@ check 0 "" \ check 0 "" \ "drawingarea2:move_to 1 0 170\n drawingarea2:rel_line_to 1 300 0\n drawingarea2:set_dash 1 3 3 3 3 3 15\n drawingarea2:stroke 1" check 0 "" \ - "drawingarea2:refresh\n drawingarea2:set_dash 1" + "drawingarea2:set_dash 1" check 0 "" \ "drawingarea2:set_source_rgba 1 brown\n drawingarea2:set_line_width 1 15" check 0 "" \ - "drawingarea2:set_line_cap 2 round\n drawingarea2:move_to 1 160 20\n drawingarea2:rel_line_to 1 20 0\n drawingarea2:rel_line_to 1 0 20\n drawingarea2:stroke 1\n drawingarea2:refresh" + "drawingarea2:set_line_cap 2 round\n drawingarea2:move_to 1 160 20\n drawingarea2:rel_line_to 1 20 0\n drawingarea2:rel_line_to 1 0 20\n drawingarea2:stroke 1" check 0 "" \ - "drawingarea2:set_line_join 3 bevel\n drawingarea2:set_line_cap 3 butt\n drawingarea2:move_to 1 160 70\n drawingarea2:rel_line_to 1 20 0\n drawingarea2:rel_line_to 1 0 20\n drawingarea2:stroke 1\n drawingarea2:refresh" + "drawingarea2:set_line_join 3 bevel\n drawingarea2:set_line_cap 3 butt\n drawingarea2:move_to 1 160 70\n drawingarea2:rel_line_to 1 20 0\n drawingarea2:rel_line_to 1 0 20\n drawingarea2:stroke 1" check 0 "" \ - "drawingarea2:set_line_join 3 miter\n drawingarea2:set_line_cap 3 square\n drawingarea2:move_to 1 160 120\n drawingarea2:rel_line_to 1 20 0\n drawingarea2:rel_line_to 1 0 20\n drawingarea2:stroke 1\n drawingarea2:refresh" + "drawingarea2:set_line_join 3 miter\n drawingarea2:set_line_cap 3 square\n drawingarea2:move_to 1 160 120\n drawingarea2:rel_line_to 1 20 0\n drawingarea2:rel_line_to 1 0 20\n drawingarea2:stroke 1" check 0 "" \ - "drawingarea2:remove 2\n drawingarea2:refresh" + "drawingarea2:remove 2" check 0 "" \ - "drawingarea2:remove 3\n drawingarea2:refresh" + "drawingarea2:remove 3" check 0 "" \ "drawingarea1:set_source_rgba 6 red\n drawingarea1:set_font_size 6 20" @@ -1858,7 +1858,7 @@ check 0 "" \ check 0 "" \ "drawingarea1:move_to 6 100 140\n drawingarea1:rel_move_for 6 e EAST\n drawingarea1:show_text 6 EAST" check 0 "" \ - "drawingarea1:move_to 6 100 140\n drawingarea1:rel_move_for 6 w WEST\n drawingarea1:show_text 6 WEST\n drawingarea1:refresh" + "drawingarea1:move_to 6 100 140\n drawingarea1:rel_move_for 6 w WEST\n drawingarea1:show_text 6 WEST" check 2 "Hit Backspace, Enter" \ "eventbox1:grab_focus" \ -- 2.11.4.GIT