Mercurial > vim
comparison src/gui_gtk_f.c @ 18781:79e10adc821d v8.1.2380
patch 8.1.2380: using old C style comments
Commit: https://github.com/vim/vim/commit/306139005c31ea7e6f892dd119beba3c94dcb982
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 1 22:11:18 2019 +0100
patch 8.1.2380: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Dec 2019 22:15:03 +0100 |
parents | a1229400434a |
children | aadd1cae2ff5 |
comparison
equal
deleted
inserted
replaced
18780:04ce3b8a50ed | 18781:79e10adc821d |
---|---|
24 * | 24 * |
25 * 2016 Kazunobu Kuriyama <kazunobu.kuriyama@gmail.com> | 25 * 2016 Kazunobu Kuriyama <kazunobu.kuriyama@gmail.com> |
26 */ | 26 */ |
27 | 27 |
28 #include "vim.h" | 28 #include "vim.h" |
29 #include <gtk/gtk.h> /* without this it compiles, but gives errors at | 29 #include <gtk/gtk.h> // without this it compiles, but gives errors at |
30 runtime! */ | 30 // runtime! |
31 #include "gui_gtk_f.h" | 31 #include "gui_gtk_f.h" |
32 #if !GTK_CHECK_VERSION(3,0,0) | 32 #if !GTK_CHECK_VERSION(3,0,0) |
33 # include <gtk/gtksignal.h> | 33 # include <gtk/gtksignal.h> |
34 #endif | 34 #endif |
35 #ifdef MSWIN | 35 #ifdef MSWIN |
42 | 42 |
43 struct _GtkFormChild | 43 struct _GtkFormChild |
44 { | 44 { |
45 GtkWidget *widget; | 45 GtkWidget *widget; |
46 GdkWindow *window; | 46 GdkWindow *window; |
47 gint x; /* relative subwidget x position */ | 47 gint x; // relative subwidget x position |
48 gint y; /* relative subwidget y position */ | 48 gint y; // relative subwidget y position |
49 gint mapped; | 49 gint mapped; |
50 }; | 50 }; |
51 | 51 |
52 | 52 |
53 static void gtk_form_class_init(GtkFormClass *klass); | 53 static void gtk_form_class_init(GtkFormClass *klass); |
99 | 99 |
100 #if !GTK_CHECK_VERSION(3,0,0) | 100 #if !GTK_CHECK_VERSION(3,0,0) |
101 static GtkWidgetClass *parent_class = NULL; | 101 static GtkWidgetClass *parent_class = NULL; |
102 #endif | 102 #endif |
103 | 103 |
104 /* Public interface | 104 // Public interface |
105 */ | |
106 | 105 |
107 GtkWidget * | 106 GtkWidget * |
108 gtk_form_new(void) | 107 gtk_form_new(void) |
109 { | 108 { |
110 GtkForm *form; | 109 GtkForm *form; |
126 { | 125 { |
127 GtkFormChild *child; | 126 GtkFormChild *child; |
128 | 127 |
129 g_return_if_fail(GTK_IS_FORM(form)); | 128 g_return_if_fail(GTK_IS_FORM(form)); |
130 | 129 |
131 /* LINTED: avoid warning: conversion to 'unsigned long' */ | 130 // LINTED: avoid warning: conversion to 'unsigned long' |
132 child = g_new(GtkFormChild, 1); | 131 child = g_new(GtkFormChild, 1); |
133 if (child == NULL) | 132 if (child == NULL) |
134 return; | 133 return; |
135 | 134 |
136 child->widget = child_widget; | 135 child->widget = child_widget; |
145 #endif | 144 #endif |
146 child->mapped = FALSE; | 145 child->mapped = FALSE; |
147 | 146 |
148 form->children = g_list_append(form->children, child); | 147 form->children = g_list_append(form->children, child); |
149 | 148 |
150 /* child->window must be created and attached to the widget _before_ | 149 // child->window must be created and attached to the widget _before_ |
151 * it has been realized, or else things will break with GTK2. Note | 150 // it has been realized, or else things will break with GTK2. Note |
152 * that gtk_widget_set_parent() realizes the widget if it's visible | 151 // that gtk_widget_set_parent() realizes the widget if it's visible |
153 * and its parent is mapped. | 152 // and its parent is mapped. |
154 */ | |
155 if (gtk_widget_get_realized(GTK_WIDGET(form))) | 153 if (gtk_widget_get_realized(GTK_WIDGET(form))) |
156 gtk_form_attach_child_window(form, child); | 154 gtk_form_attach_child_window(form, child); |
157 | 155 |
158 gtk_widget_set_parent(child_widget, GTK_WIDGET(form)); | 156 gtk_widget_set_parent(child_widget, GTK_WIDGET(form)); |
159 | 157 |
210 gtk_widget_queue_draw(GTK_WIDGET(form)); | 208 gtk_widget_queue_draw(GTK_WIDGET(form)); |
211 } | 209 } |
212 } | 210 } |
213 } | 211 } |
214 | 212 |
215 /* Basic Object handling procedures | 213 // Basic Object handling procedures |
216 */ | |
217 #if GTK_CHECK_VERSION(3,0,0) | 214 #if GTK_CHECK_VERSION(3,0,0) |
218 G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER) | 215 G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER) |
219 #else | 216 #else |
220 GtkType | 217 GtkType |
221 gtk_form_get_type(void) | 218 gtk_form_get_type(void) |
235 | 232 |
236 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info); | 233 form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info); |
237 } | 234 } |
238 return form_type; | 235 return form_type; |
239 } | 236 } |
240 #endif /* !GTK_CHECK_VERSION(3,0,0) */ | 237 #endif // !GTK_CHECK_VERSION(3,0,0) |
241 | 238 |
242 static void | 239 static void |
243 gtk_form_class_init(GtkFormClass *klass) | 240 gtk_form_class_init(GtkFormClass *klass) |
244 { | 241 { |
245 GtkWidgetClass *widget_class; | 242 GtkWidgetClass *widget_class; |
362 gtk_form_realize_child(form, child); | 359 gtk_form_realize_child(form, child); |
363 } | 360 } |
364 } | 361 } |
365 | 362 |
366 | 363 |
367 /* After reading the documentation at | 364 // After reading the documentation at |
368 * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html | 365 // http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html |
369 * I think it should be possible to remove this function when compiling | 366 // I think it should be possible to remove this function when compiling |
370 * against gtk-2.0. It doesn't seem to cause problems, though. | 367 // against gtk-2.0. It doesn't seem to cause problems, though. |
371 * | 368 // |
372 * Well, I reckon at least the gdk_window_show(form->bin_window) | 369 // Well, I reckon at least the gdk_window_show(form->bin_window) |
373 * is necessary. GtkForm is anything but a usual container widget. | 370 // is necessary. GtkForm is anything but a usual container widget. |
374 */ | |
375 static void | 371 static void |
376 gtk_form_map(GtkWidget *widget) | 372 gtk_form_map(GtkWidget *widget) |
377 { | 373 { |
378 GList *tmp_list; | 374 GList *tmp_list; |
379 GtkForm *form; | 375 GtkForm *form; |
478 gtk_form_size_request(widget, &requisition); | 474 gtk_form_size_request(widget, &requisition); |
479 | 475 |
480 *minimal_height = requisition.height; | 476 *minimal_height = requisition.height; |
481 *natural_height = requisition.height; | 477 *natural_height = requisition.height; |
482 } | 478 } |
483 #endif /* GTK_CHECK_VERSION(3,0,0) */ | 479 #endif // GTK_CHECK_VERSION(3,0,0) |
484 | 480 |
485 static void | 481 static void |
486 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) | 482 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation) |
487 { | 483 { |
488 GList *tmp_list; | 484 GList *tmp_list; |
557 GtkFormChild * const formchild = tmp_list->data; | 553 GtkFormChild * const formchild = tmp_list->data; |
558 | 554 |
559 if (!gtk_widget_get_has_window(formchild->widget) && | 555 if (!gtk_widget_get_has_window(formchild->widget) && |
560 gtk_cairo_should_draw_window(cr, formchild->window)) | 556 gtk_cairo_should_draw_window(cr, formchild->window)) |
561 { | 557 { |
562 /* To get gtk_widget_draw() to work, it is required to call | 558 // To get gtk_widget_draw() to work, it is required to call |
563 * gtk_widget_size_allocate() in advance with a well-posed | 559 // gtk_widget_size_allocate() in advance with a well-posed |
564 * allocation for a given child widget in order to set a | 560 // allocation for a given child widget in order to set a |
565 * certain private GtkWidget variable, called | 561 // certain private GtkWidget variable, called |
566 * widget->priv->alloc_need, to the proper value; otherwise, | 562 // widget->priv->alloc_need, to the proper value; otherwise, |
567 * gtk_widget_draw() fails and the relevant scrollbar won't | 563 // gtk_widget_draw() fails and the relevant scrollbar won't |
568 * appear on the screen. | 564 // appear on the screen. |
569 * | 565 // |
570 * Calling gtk_form_position_child() like this is one of ways | 566 // Calling gtk_form_position_child() like this is one of ways |
571 * to make sure of that. */ | 567 // to make sure of that. |
572 gtk_form_position_child(form, formchild, TRUE); | 568 gtk_form_position_child(form, formchild, TRUE); |
573 | 569 |
574 gtk_form_render_background(formchild->widget, cr); | 570 gtk_form_render_background(formchild->widget, cr); |
575 } | 571 } |
576 } | 572 } |
577 | 573 |
578 return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr); | 574 return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr); |
579 } | 575 } |
580 #else /* !GTK_CHECK_VERSION(3,0,0) */ | 576 #else // !GTK_CHECK_VERSION(3,0,0) |
581 static gint | 577 static gint |
582 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) | 578 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) |
583 { | 579 { |
584 GList *tmp_list; | 580 GList *tmp_list; |
585 GtkForm *form; | 581 GtkForm *form; |
596 GTK_WIDGET(((GtkFormChild *)tmp_list->data)->widget), | 592 GTK_WIDGET(((GtkFormChild *)tmp_list->data)->widget), |
597 event); | 593 event); |
598 | 594 |
599 return FALSE; | 595 return FALSE; |
600 } | 596 } |
601 #endif /* !GTK_CHECK_VERSION(3,0,0) */ | 597 #endif // !GTK_CHECK_VERSION(3,0,0) |
602 | 598 |
603 /* Container method | 599 // Container method |
604 */ | |
605 static void | 600 static void |
606 gtk_form_remove(GtkContainer *container, GtkWidget *widget) | 601 gtk_form_remove(GtkContainer *container, GtkWidget *widget) |
607 { | 602 { |
608 GList *tmp_list; | 603 GList *tmp_list; |
609 GtkForm *form; | 604 GtkForm *form; |
610 GtkFormChild *child = NULL; /* init for gcc */ | 605 GtkFormChild *child = NULL; // init for gcc |
611 | 606 |
612 g_return_if_fail(GTK_IS_FORM(container)); | 607 g_return_if_fail(GTK_IS_FORM(container)); |
613 | 608 |
614 form = GTK_FORM(container); | 609 form = GTK_FORM(container); |
615 | 610 |
632 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), | 627 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
633 FUNC2GENERIC(>k_form_child_map), child); | 628 FUNC2GENERIC(>k_form_child_map), child); |
634 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), | 629 g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget), |
635 FUNC2GENERIC(>k_form_child_unmap), child); | 630 FUNC2GENERIC(>k_form_child_unmap), child); |
636 | 631 |
637 /* FIXME: This will cause problems for reparenting NO_WINDOW | 632 // FIXME: This will cause problems for reparenting NO_WINDOW |
638 * widgets out of a GtkForm | 633 // widgets out of a GtkForm |
639 */ | |
640 gdk_window_set_user_data(child->window, NULL); | 634 gdk_window_set_user_data(child->window, NULL); |
641 gdk_window_destroy(child->window); | 635 gdk_window_destroy(child->window); |
642 } | 636 } |
643 gtk_widget_unparent(widget); | 637 gtk_widget_unparent(widget); |
644 #if GTK_CHECK_VERSION(3,0,0) | 638 #if GTK_CHECK_VERSION(3,0,0) |
674 | 668 |
675 (*callback) (child->widget, callback_data); | 669 (*callback) (child->widget, callback_data); |
676 } | 670 } |
677 } | 671 } |
678 | 672 |
679 /* Operations on children | 673 // Operations on children |
680 */ | |
681 | 674 |
682 static void | 675 static void |
683 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) | 676 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) |
684 { | 677 { |
685 if (child->window != NULL) | 678 if (child->window != NULL) |
686 return; /* been there, done that */ | 679 return; // been there, done that |
687 | 680 |
688 if (!gtk_widget_get_has_window(child->widget)) | 681 if (!gtk_widget_get_has_window(child->widget)) |
689 { | 682 { |
690 GtkWidget *widget; | 683 GtkWidget *widget; |
691 GdkWindowAttr attributes; | 684 GdkWindowAttr attributes; |