Mercurial > dwindows
comparison gtk4/dw.c @ 2270:819f2492c85f
GTK4: More signal cleanup, fix various issues with windows and dialogs.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 01 Feb 2021 01:28:41 +0000 |
parents | a26cfd4bbffe |
children | 1c52cd5a817f |
comparison
equal
deleted
inserted
replaced
2269:a26cfd4bbffe | 2270:819f2492c85f |
---|---|
113 #define _DW_TREE_TYPE_TREE 2 | 113 #define _DW_TREE_TYPE_TREE 2 |
114 #define _DW_TREE_TYPE_LISTBOX 3 | 114 #define _DW_TREE_TYPE_LISTBOX 3 |
115 #define _DW_TREE_TYPE_COMBOBOX 4 | 115 #define _DW_TREE_TYPE_COMBOBOX 4 |
116 | 116 |
117 /* Signal forwarder prototypes */ | 117 /* Signal forwarder prototypes */ |
118 static gint _button_press_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data); | 118 static gint _dw_button_press_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data); |
119 static gint _button_release_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data); | 119 static gint _dw_button_release_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data); |
120 static gint _motion_notify_event(GtkEventControllerMotion *controller, double x, double y, gpointer data); | 120 static gint _dw_motion_notify_event(GtkEventControllerMotion *controller, double x, double y, gpointer data); |
121 static gboolean _delete_event(GtkWidget *window, gpointer data); | 121 static gboolean _dw_delete_event(GtkWidget *window, gpointer data); |
122 static gint _key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data); | 122 static gint _dw_key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data); |
123 static gint _generic_event(GtkWidget *widget, gpointer data); | 123 static gint _dw_generic_event(GtkWidget *widget, gpointer data); |
124 static gint _configure_event(GtkWidget *widget, int width, int height, gpointer data); | 124 static gint _dw_configure_event(GtkWidget *widget, int width, int height, gpointer data); |
125 static gint _container_enter_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data); | 125 static gint _dw_container_enter_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data); |
126 static gint _combobox_select_event(GtkWidget *widget, gpointer data); | 126 static gint _dw_combobox_select_event(GtkWidget *widget, gpointer data); |
127 static gint _expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data); | 127 static gint _dw_expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data); |
128 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data); | 128 static gint _dw_set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data); |
129 static gint _tree_context_event(GtkWidget *widget, GdkEvent *event, gpointer data); | 129 static gint _dw_tree_context_event(GtkWidget *widget, GdkEvent *event, gpointer data); |
130 static gint _value_changed_event(GtkWidget *widget, gpointer user_data); | 130 static gint _dw_value_changed_event(GtkWidget *widget, gpointer user_data); |
131 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data); | 131 static gint _dw_tree_select_event(GtkTreeSelection *sel, gpointer data); |
132 static gint _tree_expand_event(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer data); | 132 static gint _dw_tree_expand_event(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer data); |
133 static gint _switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data); | 133 static gint _dw_switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data); |
134 static gint _column_click_event(GtkWidget *widget, gpointer data); | 134 static gint _dw_column_click_event(GtkWidget *widget, gpointer data); |
135 static void _html_result_event(GObject *object, GAsyncResult *result, gpointer script_data); | |
136 #ifdef USE_WEBKIT | 135 #ifdef USE_WEBKIT |
137 static void _html_changed_event(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer data); | 136 static void _dw_html_result_event(GObject *object, GAsyncResult *result, gpointer script_data); |
137 static void _dw_html_changed_event(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer data); | |
138 #endif | 138 #endif |
139 static void _dw_signal_disconnect(gpointer data, GClosure *closure); | 139 static void _dw_signal_disconnect(gpointer data, GClosure *closure); |
140 | 140 |
141 GObject *_DWObject = NULL; | 141 GObject *_DWObject = NULL; |
142 GApplication *_DWApp = NULL; | 142 GApplication *_DWApp = NULL; |
161 GObject *_dw_motion_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); | 161 GObject *_dw_motion_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); |
162 GObject *_dw_draw_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); | 162 GObject *_dw_draw_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); |
163 GObject *_dw_value_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); | 163 GObject *_dw_value_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); |
164 GObject *_dw_tree_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); | 164 GObject *_dw_tree_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); |
165 GObject *_dw_focus_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); | 165 GObject *_dw_focus_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); |
166 #ifdef USE_WEBKIT | |
166 GObject *_dw_html_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); | 167 GObject *_dw_html_setup(struct _dw_signal_list *signal, GObject *object, void *params[], void *sigfunc, void *discfunc, void *data); |
168 #endif | |
167 | 169 |
168 typedef struct | 170 typedef struct |
169 { | 171 { |
170 HWND window; | 172 HWND window; |
171 void *func; | 173 void *func; |
175 | 177 |
176 } SignalHandler; | 178 } SignalHandler; |
177 | 179 |
178 /* A list of signal forwarders, to account for paramater differences. */ | 180 /* A list of signal forwarders, to account for paramater differences. */ |
179 static SignalList SignalTranslate[] = { | 181 static SignalList SignalTranslate[] = { |
180 { _configure_event, DW_SIGNAL_CONFIGURE, "resize", NULL }, | 182 { _dw_configure_event, DW_SIGNAL_CONFIGURE, "resize", NULL }, |
181 { _key_press_event, DW_SIGNAL_KEY_PRESS, "key-pressed", _dw_key_setup }, | 183 { _dw_key_press_event, DW_SIGNAL_KEY_PRESS, "key-pressed", _dw_key_setup }, |
182 { _button_press_event, DW_SIGNAL_BUTTON_PRESS, "pressed", _dw_mouse_setup }, | 184 { _dw_button_press_event, DW_SIGNAL_BUTTON_PRESS, "pressed", _dw_mouse_setup }, |
183 { _button_release_event, DW_SIGNAL_BUTTON_RELEASE, "released", _dw_mouse_setup }, | 185 { _dw_button_release_event, DW_SIGNAL_BUTTON_RELEASE, "released", _dw_mouse_setup }, |
184 { _motion_notify_event, DW_SIGNAL_MOTION_NOTIFY, "motion", _dw_motion_setup }, | 186 { _dw_motion_notify_event, DW_SIGNAL_MOTION_NOTIFY, "motion", _dw_motion_setup }, |
185 { _delete_event, DW_SIGNAL_DELETE, "close-request", NULL }, | 187 { _dw_delete_event, DW_SIGNAL_DELETE, "close-request", NULL }, |
186 { _expose_event, DW_SIGNAL_EXPOSE, "draw", _dw_draw_setup }, | 188 { _dw_expose_event, DW_SIGNAL_EXPOSE, "draw", _dw_draw_setup }, |
187 { _generic_event, DW_SIGNAL_CLICKED, "clicked", _dw_button_setup }, | 189 { _dw_generic_event, DW_SIGNAL_CLICKED, "clicked", _dw_button_setup }, |
188 { _container_enter_event, DW_SIGNAL_ITEM_ENTER, "key-pressed", _dw_key_setup }, | 190 { _dw_container_enter_event, DW_SIGNAL_ITEM_ENTER, "key-pressed", _dw_key_setup }, |
189 { _tree_context_event, DW_SIGNAL_ITEM_CONTEXT, "pressed", _dw_tree_setup }, | 191 { _dw_tree_context_event, DW_SIGNAL_ITEM_CONTEXT, "pressed", _dw_tree_setup }, |
190 { _combobox_select_event, DW_SIGNAL_LIST_SELECT, "changed", NULL }, | 192 { _dw_combobox_select_event, DW_SIGNAL_LIST_SELECT, "changed", NULL }, |
191 { _tree_select_event, DW_SIGNAL_ITEM_SELECT, "row-activated", NULL }, | 193 { _dw_tree_select_event, DW_SIGNAL_ITEM_SELECT, "changed", _dw_tree_setup }, |
192 { _set_focus_event, DW_SIGNAL_SET_FOCUS, "activate-focus", _dw_focus_setup }, | 194 { _dw_set_focus_event, DW_SIGNAL_SET_FOCUS, "activate-focus", _dw_focus_setup }, |
193 { _value_changed_event, DW_SIGNAL_VALUE_CHANGED, "value-changed", _dw_value_setup }, | 195 { _dw_value_changed_event, DW_SIGNAL_VALUE_CHANGED, "value-changed", _dw_value_setup }, |
194 { _switch_page_event, DW_SIGNAL_SWITCH_PAGE, "switch-page", NULL }, | 196 { _dw_switch_page_event, DW_SIGNAL_SWITCH_PAGE, "switch-page", NULL }, |
195 { _column_click_event, DW_SIGNAL_COLUMN_CLICK, "activate", _dw_tree_setup }, | 197 { _dw_column_click_event, DW_SIGNAL_COLUMN_CLICK, "activate", _dw_tree_setup }, |
196 { _tree_expand_event, DW_SIGNAL_TREE_EXPAND, "row-expanded", NULL }, | 198 { _dw_tree_expand_event, DW_SIGNAL_TREE_EXPAND, "row-expanded", NULL }, |
197 #ifdef USE_WEBKIT | 199 #ifdef USE_WEBKIT |
198 { _html_changed_event, DW_SIGNAL_HTML_CHANGED, "load-changed", NULL }, | 200 { _dw_html_changed_event, DW_SIGNAL_HTML_CHANGED, "load-changed", NULL }, |
201 { _dw_html_result_event, DW_SIGNAL_HTML_RESULT, "", _dw_html_setup }, | |
199 #endif | 202 #endif |
200 { _html_result_event, DW_SIGNAL_HTML_RESULT, "", _dw_html_setup }, | 203 { NULL, "", "", NULL } |
201 { NULL, "", "", NULL } | |
202 }; | 204 }; |
203 | 205 |
204 /* Alignment flags */ | 206 /* Alignment flags */ |
205 #define DW_CENTER 0.5f | 207 #define DW_CENTER 0.5f |
206 #define DW_LEFT 0.0f | 208 #define DW_LEFT 0.0f |
315 | 317 |
316 sprintf(text, "_dw_sigcid%d", counter); | 318 sprintf(text, "_dw_sigcid%d", counter); |
317 g_object_set_data(object, text, GINT_TO_POINTER(cid)); | 319 g_object_set_data(object, text, GINT_TO_POINTER(cid)); |
318 } | 320 } |
319 | 321 |
322 #ifdef USE_WEBKIT | |
320 static void _html_result_event(GObject *object, GAsyncResult *result, gpointer script_data) | 323 static void _html_result_event(GObject *object, GAsyncResult *result, gpointer script_data) |
321 { | 324 { |
322 #ifdef USE_WEBKIT | |
323 pthread_t saved_thread = _dw_thread; | 325 pthread_t saved_thread = _dw_thread; |
324 WebKitJavascriptResult *js_result; | 326 WebKitJavascriptResult *js_result; |
325 JSCValue *value; | 327 JSCValue *value; |
326 GError *error = NULL; | 328 GError *error = NULL; |
327 int (*htmlresultfunc)(HWND, int, char *, void *, void *) = NULL; | 329 int (*htmlresultfunc)(HWND, int, char *, void *, void *) = NULL; |
369 } | 371 } |
370 else if(htmlresultfunc) | 372 else if(htmlresultfunc) |
371 htmlresultfunc((HWND)object, DW_ERROR_UNKNOWN, NULL, script_data, user_data); | 373 htmlresultfunc((HWND)object, DW_ERROR_UNKNOWN, NULL, script_data, user_data); |
372 webkit_javascript_result_unref (js_result); | 374 webkit_javascript_result_unref (js_result); |
373 _dw_thread = saved_thread; | 375 _dw_thread = saved_thread; |
374 #endif | 376 } |
375 } | 377 |
376 | |
377 #ifdef USE_WEBKIT | |
378 static void _html_changed_event(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer data) | 378 static void _html_changed_event(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer data) |
379 { | 379 { |
380 SignalHandler work = _get_signal_handler(data); | 380 SignalHandler work = _get_signal_handler(data); |
381 char *location = (char *)webkit_web_view_get_uri(web_view); | 381 char *location = (char *)webkit_web_view_get_uri(web_view); |
382 int status = 0; | 382 int status = 0; |
402 htmlchangedfunc(work.window, status, location, work.data); | 402 htmlchangedfunc(work.window, status, location, work.data); |
403 } | 403 } |
404 } | 404 } |
405 #endif | 405 #endif |
406 | 406 |
407 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) | 407 static gint _dw_set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data) |
408 { | 408 { |
409 SignalHandler work = _get_signal_handler(data); | 409 SignalHandler work = _get_signal_handler(data); |
410 int retval = FALSE; | 410 int retval = FALSE; |
411 | 411 |
412 if(work.window) | 412 if(work.window) |
416 retval = setfocusfunc(work.window, work.data); | 416 retval = setfocusfunc(work.window, work.data); |
417 } | 417 } |
418 return retval; | 418 return retval; |
419 } | 419 } |
420 | 420 |
421 static gint _button_press_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data) | 421 static gint _dw_button_press_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data) |
422 { | 422 { |
423 SignalHandler work = _get_signal_handler(data); | 423 SignalHandler work = _get_signal_handler(data); |
424 int retval = FALSE; | 424 int retval = FALSE; |
425 | 425 |
426 if(work.window) | 426 if(work.window) |
439 retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data); | 439 retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data); |
440 } | 440 } |
441 return retval; | 441 return retval; |
442 } | 442 } |
443 | 443 |
444 static gint _button_release_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data) | 444 static gint _dw_button_release_event(GtkGestureClick *gesture, int n_press, double x, double y, gpointer data) |
445 { | 445 { |
446 SignalHandler work = _get_signal_handler(data); | 446 SignalHandler work = _get_signal_handler(data); |
447 int retval = FALSE; | 447 int retval = FALSE; |
448 | 448 |
449 if(work.window) | 449 if(work.window) |
462 retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data); | 462 retval = buttonfunc(work.window, (int)x, (int)y, mybutton, work.data); |
463 } | 463 } |
464 return retval; | 464 return retval; |
465 } | 465 } |
466 | 466 |
467 static gint _motion_notify_event(GtkEventControllerMotion *controller, double x, double y, gpointer data) | 467 static gint _dw_motion_notify_event(GtkEventControllerMotion *controller, double x, double y, gpointer data) |
468 { | 468 { |
469 SignalHandler work = _get_signal_handler(data); | 469 SignalHandler work = _get_signal_handler(data); |
470 int retval = FALSE; | 470 int retval = FALSE; |
471 | 471 |
472 if(work.window) | 472 if(work.window) |
486 retval = motionfunc(work.window, (int)x, (int)y, keys, work.data); | 486 retval = motionfunc(work.window, (int)x, (int)y, keys, work.data); |
487 } | 487 } |
488 return retval; | 488 return retval; |
489 } | 489 } |
490 | 490 |
491 static gboolean _delete_event(GtkWidget *window, gpointer data) | 491 static gboolean _dw_delete_event(GtkWidget *window, gpointer data) |
492 { | 492 { |
493 SignalHandler work = _get_signal_handler(data); | 493 SignalHandler work = _get_signal_handler(data); |
494 int retval = FALSE; | 494 int retval = FALSE; |
495 | 495 |
496 if(work.window) | 496 if(work.window) |
500 retval = closefunc(work.window, work.data); | 500 retval = closefunc(work.window, work.data); |
501 } | 501 } |
502 return retval; | 502 return retval; |
503 } | 503 } |
504 | 504 |
505 static gint _key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data) | 505 static gint _dw_key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data) |
506 { | 506 { |
507 SignalHandler work = _get_signal_handler(data); | 507 SignalHandler work = _get_signal_handler(data); |
508 int retval = FALSE; | 508 int retval = FALSE; |
509 | 509 |
510 if(work.window) | 510 if(work.window) |
519 state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_ALT_MASK), work.data, utf8); | 519 state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_ALT_MASK), work.data, utf8); |
520 } | 520 } |
521 return retval; | 521 return retval; |
522 } | 522 } |
523 | 523 |
524 static gint _generic_event(GtkWidget *widget, gpointer data) | 524 static gint _dw_generic_event(GtkWidget *widget, gpointer data) |
525 { | 525 { |
526 SignalHandler work = _get_signal_handler(data); | 526 SignalHandler work = _get_signal_handler(data); |
527 int retval = FALSE; | 527 int retval = FALSE; |
528 | 528 |
529 if(work.window) | 529 if(work.window) |
533 retval = genericfunc(work.window, work.data); | 533 retval = genericfunc(work.window, work.data); |
534 } | 534 } |
535 return retval; | 535 return retval; |
536 } | 536 } |
537 | 537 |
538 static gint _configure_event(GtkWidget *widget, int width, int height, gpointer data) | 538 static gint _dw_configure_event(GtkWidget *widget, int width, int height, gpointer data) |
539 { | 539 { |
540 SignalHandler work = _get_signal_handler(data); | 540 SignalHandler work = _get_signal_handler(data); |
541 int retval = FALSE; | 541 int retval = FALSE; |
542 | 542 |
543 if(work.window) | 543 if(work.window) |
547 retval = sizefunc(work.window, width, height, work.data); | 547 retval = sizefunc(work.window, width, height, work.data); |
548 } | 548 } |
549 return retval; | 549 return retval; |
550 } | 550 } |
551 | 551 |
552 static gint _expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data) | 552 static gint _dw_expose_event(GtkWidget *widget, cairo_t *cr, int width, int height, gpointer data) |
553 { | 553 { |
554 SignalHandler work = _get_signal_handler(data); | 554 SignalHandler work = _get_signal_handler(data); |
555 int retval = FALSE; | 555 int retval = FALSE; |
556 | 556 |
557 if(work.window) | 557 if(work.window) |
565 retval = exposefunc(work.window, &exp, work.data); | 565 retval = exposefunc(work.window, &exp, work.data); |
566 } | 566 } |
567 return retval; | 567 return retval; |
568 } | 568 } |
569 | 569 |
570 static gint _combobox_select_event(GtkWidget *widget, gpointer data) | 570 static gint _dw_combobox_select_event(GtkWidget *widget, gpointer data) |
571 { | 571 { |
572 SignalHandler work = _get_signal_handler(data); | 572 SignalHandler work = _get_signal_handler(data); |
573 int retval = FALSE; | 573 int retval = FALSE; |
574 | 574 |
575 if(g_object_get_data(G_OBJECT(widget), "_dw_recursing")) | 575 if(g_object_get_data(G_OBJECT(widget), "_dw_recursing")) |
611 } | 611 } |
612 | 612 |
613 #define _DW_DATA_TYPE_STRING 0 | 613 #define _DW_DATA_TYPE_STRING 0 |
614 #define _DW_DATA_TYPE_POINTER 1 | 614 #define _DW_DATA_TYPE_POINTER 1 |
615 | 615 |
616 static gint _tree_context_event(GtkWidget *widget, GdkEvent *event, gpointer data) | 616 static gint _dw_tree_context_event(GtkWidget *widget, GdkEvent *event, gpointer data) |
617 { | 617 { |
618 SignalHandler work = _get_signal_handler(data); | 618 SignalHandler work = _get_signal_handler(data); |
619 int retval = FALSE; | 619 int retval = FALSE; |
620 | 620 |
621 if(work.window) | 621 if(work.window) |
679 } | 679 } |
680 } | 680 } |
681 return retval; | 681 return retval; |
682 } | 682 } |
683 | 683 |
684 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data) | 684 static gint _dw_tree_select_event(GtkTreeSelection *sel, gpointer data) |
685 { | 685 { |
686 GtkWidget *item = NULL, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel); | 686 GtkWidget *item = NULL, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel); |
687 int retval = FALSE; | 687 int retval = FALSE; |
688 | 688 |
689 if(widget) | 689 if(widget) |
776 } | 776 } |
777 } | 777 } |
778 return retval; | 778 return retval; |
779 } | 779 } |
780 | 780 |
781 static gint _tree_expand_event(GtkTreeView *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer data) | 781 static gint _dw_tree_expand_event(GtkTreeView *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer data) |
782 { | 782 { |
783 SignalHandler work = _get_signal_handler(data); | 783 SignalHandler work = _get_signal_handler(data); |
784 int retval = FALSE; | 784 int retval = FALSE; |
785 | 785 |
786 if(!_dw_ignore_expand && work.window) | 786 if(!_dw_ignore_expand && work.window) |
789 retval = treeexpandfunc(work.window, (HTREEITEM)iter, work.data); | 789 retval = treeexpandfunc(work.window, (HTREEITEM)iter, work.data); |
790 } | 790 } |
791 return retval; | 791 return retval; |
792 } | 792 } |
793 | 793 |
794 static gint _container_enter_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data) | 794 static gint _dw_container_enter_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data) |
795 { | 795 { |
796 SignalHandler work = _get_signal_handler(data); | 796 SignalHandler work = _get_signal_handler(data); |
797 int retval = FALSE; | 797 int retval = FALSE; |
798 | 798 |
799 if(work.window && GTK_IS_WIDGET(work.window)) | 799 if(work.window && GTK_IS_WIDGET(work.window)) |
836 } | 836 } |
837 return retval; | 837 return retval; |
838 } | 838 } |
839 | 839 |
840 /* Return the logical page id from the physical page id */ | 840 /* Return the logical page id from the physical page id */ |
841 int _get_logical_page(HWND handle, unsigned long pageid) | 841 int _dw_get_logical_page(HWND handle, unsigned long pageid) |
842 { | 842 { |
843 int z; | 843 int z; |
844 GtkWidget **pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray"); | 844 GtkWidget **pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray"); |
845 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); | 845 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid); |
846 | 846 |
854 } | 854 } |
855 return 256; | 855 return 256; |
856 } | 856 } |
857 | 857 |
858 | 858 |
859 static gint _switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data) | 859 static gint _dw_switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data) |
860 { | 860 { |
861 SignalHandler work = _get_signal_handler(data); | 861 SignalHandler work = _get_signal_handler(data); |
862 int retval = FALSE; | 862 int retval = FALSE; |
863 | 863 |
864 if(work.window) | 864 if(work.window) |
865 { | 865 { |
866 int (*switchpagefunc)(HWND, unsigned long, void *) = work.func; | 866 int (*switchpagefunc)(HWND, unsigned long, void *) = work.func; |
867 retval = switchpagefunc(work.window, _get_logical_page(GTK_WIDGET(notebook), page_num), work.data); | 867 retval = switchpagefunc(work.window, _dw_get_logical_page(GTK_WIDGET(notebook), page_num), work.data); |
868 } | 868 } |
869 return retval; | 869 return retval; |
870 } | 870 } |
871 | 871 |
872 static gint _column_click_event(GtkWidget *widget, gpointer data) | 872 static gint _dw_column_click_event(GtkWidget *widget, gpointer data) |
873 { | 873 { |
874 void **params = data; | 874 void **params = data; |
875 int retval = FALSE; | 875 int retval = FALSE; |
876 | 876 |
877 if(params && params[2]) | 877 if(params && params[2]) |
905 newval++; | 905 newval++; |
906 | 906 |
907 return newval; | 907 return newval; |
908 } | 908 } |
909 | 909 |
910 static gint _value_changed_event(GtkWidget *widget, gpointer data) | 910 static gint _dw_value_changed_event(GtkWidget *widget, gpointer data) |
911 { | 911 { |
912 GtkWidget *slider, *spinbutton, *scrollbar; | 912 GtkWidget *slider, *spinbutton, *scrollbar; |
913 GtkAdjustment *adjustment = (GtkAdjustment *)widget; | 913 GtkAdjustment *adjustment = (GtkAdjustment *)widget; |
914 int max, val; | 914 int max, val; |
915 | 915 |
924 val = _round_value(gtk_adjustment_get_value(adjustment)); | 924 val = _round_value(gtk_adjustment_get_value(adjustment)); |
925 | 925 |
926 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event")) | 926 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event")) |
927 return FALSE; | 927 return FALSE; |
928 | 928 |
929 if (slider || spinbutton || scrollbar) | 929 if(slider || spinbutton || scrollbar) |
930 { | 930 { |
931 SignalHandler work = _get_signal_handler(data); | 931 SignalHandler work = _get_signal_handler(data); |
932 | 932 |
933 if (work.window) | 933 if (work.window) |
934 { | 934 { |
941 } | 941 } |
942 } | 942 } |
943 return FALSE; | 943 return FALSE; |
944 } | 944 } |
945 | 945 |
946 static gint _default_key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data) | 946 static gint _dw_default_key_press_event(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer data) |
947 { | 947 { |
948 GtkWidget *next = (GtkWidget *)data; | 948 GtkWidget *next = (GtkWidget *)data; |
949 | 949 |
950 if(next) | 950 if(next) |
951 { | 951 { |
973 char resource_path[201] = {0}; | 973 char resource_path[201] = {0}; |
974 snprintf(resource_path, 200, "/org/dbsoft/dwindows/resources/%u.png", rid); | 974 snprintf(resource_path, 200, "/org/dbsoft/dwindows/resources/%u.png", rid); |
975 return gdk_pixbuf_new_from_resource(resource_path, NULL); | 975 return gdk_pixbuf_new_from_resource(resource_path, NULL); |
976 } | 976 } |
977 | 977 |
978 static GdkPixbuf *_find_pixbuf(HICN icon, unsigned long *userwidth, unsigned long *userheight) | 978 static GdkPixbuf *_dw_find_pixbuf(HICN icon, unsigned long *userwidth, unsigned long *userheight) |
979 { | 979 { |
980 unsigned int id = GPOINTER_TO_INT(icon); | 980 unsigned int id = GPOINTER_TO_INT(icon); |
981 GdkPixbuf *icon_pixbuf = NULL; | 981 GdkPixbuf *icon_pixbuf = NULL; |
982 | 982 |
983 /* Quick dropout for non-handle */ | 983 /* Quick dropout for non-handle */ |
1192 * Parameters: | 1192 * Parameters: |
1193 * data: User defined data to be passed to functions. | 1193 * data: User defined data to be passed to functions. |
1194 */ | 1194 */ |
1195 DWDialog *dw_dialog_new(void *data) | 1195 DWDialog *dw_dialog_new(void *data) |
1196 { | 1196 { |
1197 DWDialog *tmp = malloc(sizeof(DWDialog)); | 1197 DWDialog *tmp = calloc(sizeof(DWDialog), 1); |
1198 | 1198 |
1199 if ( tmp ) | 1199 if(tmp) |
1200 { | 1200 { |
1201 tmp->eve = dw_event_new(); | 1201 tmp->eve = dw_event_new(); |
1202 dw_event_reset(tmp->eve); | 1202 dw_event_reset(tmp->eve); |
1203 tmp->data = data; | 1203 tmp->data = data; |
1204 tmp->done = FALSE; | 1204 tmp->mainloop = g_main_loop_new(NULL, FALSE); |
1205 tmp->method = FALSE; | 1205 g_main_loop_ref(tmp->mainloop); |
1206 tmp->result = NULL; | |
1207 } | 1206 } |
1208 return tmp; | 1207 return tmp; |
1209 } | 1208 } |
1210 | 1209 |
1211 /* | 1210 /* |
1217 */ | 1216 */ |
1218 int dw_dialog_dismiss(DWDialog *dialog, void *result) | 1217 int dw_dialog_dismiss(DWDialog *dialog, void *result) |
1219 { | 1218 { |
1220 dialog->result = result; | 1219 dialog->result = result; |
1221 if(dialog->method) | 1220 if(dialog->method) |
1222 g_main_loop_quit(_DWMainLoop); | 1221 g_main_loop_quit(dialog->mainloop); |
1223 else | 1222 else |
1224 dw_event_post(dialog->eve); | 1223 dw_event_post(dialog->eve); |
1225 dialog->done = TRUE; | 1224 dialog->done = TRUE; |
1226 return DW_ERROR_NONE; | 1225 return DW_ERROR_NONE; |
1227 } | 1226 } |
1240 return NULL; | 1239 return NULL; |
1241 | 1240 |
1242 if(_dw_thread == (pthread_t)-1 || pthread_self() == _dw_thread) | 1241 if(_dw_thread == (pthread_t)-1 || pthread_self() == _dw_thread) |
1243 { | 1242 { |
1244 dialog->method = TRUE; | 1243 dialog->method = TRUE; |
1245 g_main_loop_run(_DWMainLoop); | 1244 g_main_loop_run(dialog->mainloop); |
1246 } | 1245 } |
1247 else | 1246 else |
1248 { | 1247 { |
1249 dialog->method = FALSE; | 1248 dialog->method = FALSE; |
1250 dw_event_wait(dialog->eve, -1); | 1249 dw_event_wait(dialog->eve, -1); |
1251 } | 1250 } |
1252 | 1251 |
1253 dw_event_close(&dialog->eve); | 1252 dw_event_close(&dialog->eve); |
1253 g_main_loop_unref(dialog->mainloop); | |
1254 tmp = dialog->result; | 1254 tmp = dialog->result; |
1255 free(dialog); | 1255 free(dialog); |
1256 return tmp; | 1256 return tmp; |
1257 } | 1257 } |
1258 | 1258 |
1922 */ | 1922 */ |
1923 void dw_window_set_pointer(HWND handle, int pointertype) | 1923 void dw_window_set_pointer(HWND handle, int pointertype) |
1924 { | 1924 { |
1925 if(pointertype > 65535) | 1925 if(pointertype > 65535) |
1926 { | 1926 { |
1927 GdkPixbuf *pixbuf = _find_pixbuf(GINT_TO_POINTER(pointertype), NULL, NULL); | 1927 GdkPixbuf *pixbuf = _dw_find_pixbuf(GINT_TO_POINTER(pointertype), NULL, NULL); |
1928 GdkCursor *cursor = gdk_cursor_new_from_texture(gdk_texture_new_for_pixbuf(pixbuf), 0, 0, NULL); | 1928 GdkCursor *cursor = gdk_cursor_new_from_texture(gdk_texture_new_for_pixbuf(pixbuf), 0, 0, NULL); |
1929 if(cursor) | 1929 if(cursor) |
1930 gtk_widget_set_cursor(GTK_WIDGET(handle), cursor); | 1930 gtk_widget_set_cursor(GTK_WIDGET(handle), cursor); |
1931 } | 1931 } |
1932 if(pointertype == DW_POINTER_ARROW) | 1932 if(pointertype == DW_POINTER_ARROW) |
1945 void dw_window_release(void) | 1945 void dw_window_release(void) |
1946 { | 1946 { |
1947 /* TODO: See if this is possible in GTK4 */ | 1947 /* TODO: See if this is possible in GTK4 */ |
1948 } | 1948 } |
1949 | 1949 |
1950 /* Window creation flags that will cause the window to have decorations */ | |
1951 #define _DW_DECORATION_FLAGS (DW_FCF_CLOSEBUTTON|DW_FCF_SYSMENU|DW_FCF_TITLEBAR|DW_FCF_MINMAX|DW_FCF_SIZEBORDER|DW_FCF_BORDER|DW_FCF_DLGBORDER) | |
1952 | |
1950 /* | 1953 /* |
1951 * Create a new Window Frame. | 1954 * Create a new Window Frame. |
1952 * Parameters: | 1955 * Parameters: |
1953 * owner: The Owner's window handle or HWND_DESKTOP. | 1956 * owner: The Owner's window handle or HWND_DESKTOP. |
1954 * title: The Window title. | 1957 * title: The Window title. |
1955 * flStyle: Style flags, see the PM reference. | 1958 * flStyle: Style flags, see the PM reference. |
1956 */ | 1959 */ |
1957 HWND dw_window_new(HWND hwndOwner, const char *title, unsigned long flStyle) | 1960 HWND dw_window_new(HWND hwndOwner, const char *title, unsigned long flStyle) |
1958 { | 1961 { |
1959 GtkWidget *tmp; | 1962 GtkWidget *box = dw_box_new(DW_VERT, 0); |
1960 int flags = 0; | 1963 GtkWidget *grid = gtk_grid_new(); |
1961 | 1964 GtkWidget *tmp = gtk_window_new(); |
1962 { | 1965 |
1963 GtkWidget *box = dw_box_new(DW_VERT, 0); | 1966 gtk_widget_show(grid); |
1964 GtkWidget *grid = gtk_grid_new(); | 1967 |
1965 | 1968 /* Handle the window style flags */ |
1966 gtk_widget_show(grid); | 1969 gtk_window_set_title(GTK_WINDOW(tmp), title); |
1967 | 1970 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE); |
1968 last_window = tmp = gtk_window_new(); | 1971 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */ |
1969 | 1972 gtk_window_set_deletable(GTK_WINDOW(tmp), (flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)) ? TRUE : FALSE); |
1970 gtk_window_set_title(GTK_WINDOW(tmp), title); | 1973 gtk_window_set_decorated(GTK_WINDOW(tmp), (flStyle & _DW_DECORATION_FLAGS) ? TRUE : FALSE); |
1971 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE); | 1974 |
1972 | 1975 gtk_widget_realize(tmp); |
1973 gtk_widget_realize(tmp); | 1976 |
1974 | 1977 if(flStyle & DW_FCF_FULLSCREEN) |
1975 if(flStyle & DW_FCF_FULLSCREEN) | 1978 gtk_window_fullscreen(GTK_WINDOW(tmp)); |
1976 gtk_window_fullscreen(GTK_WINDOW(tmp)); | 1979 else |
1977 else | 1980 { |
1978 { | 1981 if(flStyle & DW_FCF_MAXIMIZE) |
1979 if(flStyle & DW_FCF_MAXIMIZE) | 1982 gtk_window_maximize(GTK_WINDOW(tmp)); |
1980 gtk_window_maximize(GTK_WINDOW(tmp)); | 1983 |
1981 | 1984 if(flStyle & DW_FCF_MINIMIZE) |
1982 if(flStyle & DW_FCF_MINIMIZE) | 1985 gtk_window_minimize(GTK_WINDOW(tmp)); |
1983 gtk_window_minimize(GTK_WINDOW(tmp)); | 1986 } |
1984 } | 1987 |
1985 | 1988 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1); |
1986 /* Either the CLOSEBUTTON or SYSMENU flags should make it deletable */ | 1989 gtk_window_set_child(GTK_WINDOW(tmp), grid); |
1987 gtk_window_set_deletable(GTK_WINDOW(tmp), (flStyle & (DW_FCF_CLOSEBUTTON | DW_FCF_SYSMENU)) ? TRUE : FALSE); | 1990 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box); |
1988 | 1991 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid); |
1989 if(!flags) | |
1990 gtk_window_set_decorated(GTK_WINDOW(tmp), FALSE); | |
1991 | |
1992 if(flStyle & DW_FCF_SIZEBORDER) | |
1993 g_object_set_data(G_OBJECT(tmp), "_dw_size", GINT_TO_POINTER(1)); | |
1994 | |
1995 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1); | |
1996 gtk_window_set_child(GTK_WINDOW(tmp), grid); | |
1997 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box); | |
1998 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid); | |
1999 } | |
2000 g_object_set_data(G_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle)); | 1992 g_object_set_data(G_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle)); |
2001 return tmp; | 1993 return tmp; |
2002 } | 1994 } |
2003 | 1995 |
2004 /* | 1996 /* |
3015 { | 3007 { |
3016 /* TODO: figure out how to do this for GTK4 */ | 3008 /* TODO: figure out how to do this for GTK4 */ |
3017 #if GTK3 | 3009 #if GTK3 |
3018 GdkPixbuf *icon_pixbuf; | 3010 GdkPixbuf *icon_pixbuf; |
3019 | 3011 |
3020 icon_pixbuf = _find_pixbuf(icon, NULL, NULL); | 3012 icon_pixbuf = _dw_find_pixbuf(icon, NULL, NULL); |
3021 | 3013 |
3022 if(icon_pixbuf) | 3014 if(icon_pixbuf) |
3023 { | 3015 { |
3024 gtk_window_set_icon_name( | 3016 gtk_window_set_icon_name( |
3025 } | 3017 } |
3044 | 3036 |
3045 if(!id && !filename) | 3037 if(!id && !filename) |
3046 return; | 3038 return; |
3047 | 3039 |
3048 if(id) | 3040 if(id) |
3049 tmp = _find_pixbuf((HICN)id, NULL, NULL); | 3041 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL); |
3050 else | 3042 else |
3051 { | 3043 { |
3052 char *file = alloca(strlen(filename) + 6); | 3044 char *file = alloca(strlen(filename) + 6); |
3053 | 3045 |
3054 if (!file) | 3046 if (!file) |
3132 tmp = gdk_pixbuf_new_from_file(template, NULL); | 3124 tmp = gdk_pixbuf_new_from_file(template, NULL); |
3133 /* remove our temporary file */ | 3125 /* remove our temporary file */ |
3134 unlink(template); | 3126 unlink(template); |
3135 } | 3127 } |
3136 else if (id) | 3128 else if (id) |
3137 tmp = _find_pixbuf((HICN)id, NULL, NULL); | 3129 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL); |
3138 | 3130 |
3139 if(tmp) | 3131 if(tmp) |
3140 { | 3132 { |
3141 if(GTK_IS_BUTTON(handle)) | 3133 if(GTK_IS_BUTTON(handle)) |
3142 { | 3134 { |
3855 && GTK_IS_TREE_VIEW(tree) && | 3847 && GTK_IS_TREE_VIEW(tree) && |
3856 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) | 3848 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) |
3857 { | 3849 { |
3858 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); | 3850 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); |
3859 | 3851 |
3860 pixbuf = _find_pixbuf(icon, NULL, NULL); | 3852 pixbuf = _dw_find_pixbuf(icon, NULL, NULL); |
3861 | 3853 |
3862 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); | 3854 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item); |
3863 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); | 3855 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); |
3864 retval = (HTREEITEM)iter; | 3856 retval = (HTREEITEM)iter; |
3865 } | 3857 } |
3890 && GTK_IS_TREE_VIEW(tree) && | 3882 && GTK_IS_TREE_VIEW(tree) && |
3891 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) | 3883 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) |
3892 { | 3884 { |
3893 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); | 3885 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter)); |
3894 | 3886 |
3895 pixbuf = _find_pixbuf(icon, NULL, NULL); | 3887 pixbuf = _dw_find_pixbuf(icon, NULL, NULL); |
3896 | 3888 |
3897 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); | 3889 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent); |
3898 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); | 3890 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1); |
3899 retval = (HTREEITEM)iter; | 3891 retval = (HTREEITEM)iter; |
3900 } | 3892 } |
3920 | 3912 |
3921 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user")) | 3913 if((tree = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user")) |
3922 && GTK_IS_TREE_VIEW(tree) && | 3914 && GTK_IS_TREE_VIEW(tree) && |
3923 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) | 3915 (store = (GtkTreeStore *)gtk_tree_view_get_model(GTK_TREE_VIEW(tree)))) |
3924 { | 3916 { |
3925 pixbuf = _find_pixbuf(icon, NULL, NULL); | 3917 pixbuf = _dw_find_pixbuf(icon, NULL, NULL); |
3926 | 3918 |
3927 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1); | 3919 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1); |
3928 } | 3920 } |
3929 } | 3921 } |
3930 | 3922 |
4280 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1); | 4272 gtk_tree_view_column_add_attribute(col, rend, "text", z+_DW_CONTAINER_STORE_EXTRA+1); |
4281 gtk_tree_view_column_set_resizable(col, TRUE); | 4273 gtk_tree_view_column_set_resizable(col, TRUE); |
4282 } | 4274 } |
4283 g_object_set_data(G_OBJECT(col), "_dw_column", GINT_TO_POINTER(z)); | 4275 g_object_set_data(G_OBJECT(col), "_dw_column", GINT_TO_POINTER(z)); |
4284 params[2] = tree; | 4276 params[2] = tree; |
4285 g_signal_connect_data(G_OBJECT(col), "clicked", G_CALLBACK(_column_click_event), (gpointer)params, _dw_signal_disconnect, 0); | 4277 g_signal_connect_data(G_OBJECT(col), "clicked", G_CALLBACK(_dw_column_click_event), (gpointer)params, _dw_signal_disconnect, 0); |
4286 gtk_tree_view_column_set_title(col, titles[z]); | 4278 gtk_tree_view_column_set_title(col, titles[z]); |
4287 if(flags[z] & DW_CFA_RIGHT) | 4279 if(flags[z] & DW_CFA_RIGHT) |
4288 { | 4280 { |
4289 gtk_tree_view_column_set_alignment(col, 1.0); | 4281 gtk_tree_view_column_set_alignment(col, 1.0); |
4290 if(rend) | 4282 if(rend) |
4560 if(flag & DW_CFA_STRINGANDICON) | 4552 if(flag & DW_CFA_STRINGANDICON) |
4561 { | 4553 { |
4562 void **thisdata = (void **)data; | 4554 void **thisdata = (void **)data; |
4563 HICN hicon = data ? *((HICN *)thisdata[0]) : 0; | 4555 HICN hicon = data ? *((HICN *)thisdata[0]) : 0; |
4564 char *tmp = data ? (char *)thisdata[1] : NULL; | 4556 char *tmp = data ? (char *)thisdata[1] : NULL; |
4565 GdkPixbuf *pixbuf = hicon ? _find_pixbuf(hicon, NULL, NULL) : NULL; | 4557 GdkPixbuf *pixbuf = hicon ? _dw_find_pixbuf(hicon, NULL, NULL) : NULL; |
4566 | 4558 |
4567 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA, pixbuf, -1); | 4559 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA, pixbuf, -1); |
4568 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1); | 4560 gtk_list_store_set(store, &iter, _DW_CONTAINER_STORE_EXTRA + 1, tmp, -1); |
4569 } | 4561 } |
4570 else if(flag & DW_CFA_BITMAPORICON) | 4562 else if(flag & DW_CFA_BITMAPORICON) |
4571 { | 4563 { |
4572 HICN hicon = data ? *((HICN *)data) : 0; | 4564 HICN hicon = data ? *((HICN *)data) : 0; |
4573 GdkPixbuf *pixbuf = hicon ? _find_pixbuf(hicon, NULL, NULL) : NULL; | 4565 GdkPixbuf *pixbuf = hicon ? _dw_find_pixbuf(hicon, NULL, NULL) : NULL; |
4574 | 4566 |
4575 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, pixbuf, -1); | 4567 gtk_list_store_set(store, &iter, column + _DW_CONTAINER_STORE_EXTRA + 1, pixbuf, -1); |
4576 } | 4568 } |
4577 else if(flag & DW_CFA_STRING) | 4569 else if(flag & DW_CFA_STRING) |
4578 { | 4570 { |
6087 HPIXMAP pixmap; | 6079 HPIXMAP pixmap; |
6088 | 6080 |
6089 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) | 6081 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) |
6090 return NULL; | 6082 return NULL; |
6091 | 6083 |
6092 pixmap->pixbuf = gdk_pixbuf_copy(_find_pixbuf((HICN)id, &pixmap->width, &pixmap->height)); | 6084 pixmap->pixbuf = gdk_pixbuf_copy(_dw_find_pixbuf((HICN)id, &pixmap->width, &pixmap->height)); |
6093 return pixmap; | 6085 return pixmap; |
6094 } | 6086 } |
6095 | 6087 |
6096 /* Call this after drawing to the screen to make sure | 6088 /* Call this after drawing to the screen to make sure |
6097 * anything you have drawn is visible. | 6089 * anything you have drawn is visible. |
7839 unsigned long dw_notebook_page_get(HWND handle) | 7831 unsigned long dw_notebook_page_get(HWND handle) |
7840 { | 7832 { |
7841 int retval, phys; | 7833 int retval, phys; |
7842 | 7834 |
7843 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); | 7835 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); |
7844 retval = _get_logical_page(handle, phys); | 7836 retval = _dw_get_logical_page(handle, phys); |
7845 return retval; | 7837 return retval; |
7846 } | 7838 } |
7847 | 7839 |
7848 /* | 7840 /* |
7849 * Sets the currently visibale page ID. | 7841 * Sets the currently visibale page ID. |
8690 { | 8682 { |
8691 if(window && next && GTK_IS_WIDGET(window) && GTK_IS_WIDGET(next)) | 8683 if(window && next && GTK_IS_WIDGET(window) && GTK_IS_WIDGET(next)) |
8692 { | 8684 { |
8693 GtkEventController *controller = gtk_event_controller_key_new(); | 8685 GtkEventController *controller = gtk_event_controller_key_new(); |
8694 gtk_widget_add_controller(GTK_WIDGET(window), controller); | 8686 gtk_widget_add_controller(GTK_WIDGET(window), controller); |
8695 g_signal_connect(G_OBJECT(controller), "key-pressed", G_CALLBACK(_default_key_press_event), next); | 8687 g_signal_connect(G_OBJECT(controller), "key-pressed", G_CALLBACK(_dw_default_key_press_event), next); |
8696 } | 8688 } |
8697 } | 8689 } |
8698 | 8690 |
8699 | 8691 |
8700 /* | 8692 /* |
9578 */ | 9570 */ |
9579 int sigid = _set_signal_handler(object, (HWND)object, sigfunc, data, signal->func, discfunc); | 9571 int sigid = _set_signal_handler(object, (HWND)object, sigfunc, data, signal->func, discfunc); |
9580 g_object_set_data(object, "_dw_column_click_id", GINT_TO_POINTER(sigid+1)); | 9572 g_object_set_data(object, "_dw_column_click_id", GINT_TO_POINTER(sigid+1)); |
9581 return NULL; | 9573 return NULL; |
9582 } | 9574 } |
9575 else if(strcmp(signal->name, DW_SIGNAL_ITEM_SELECT) == 0) | |
9576 { | |
9577 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(object)); | |
9578 return G_OBJECT(sel); | |
9579 } | |
9583 else | 9580 else |
9584 { | 9581 { |
9585 GtkGesture *gesture = gtk_gesture_click_new(); | 9582 GtkGesture *gesture = gtk_gesture_click_new(); |
9586 gtk_widget_add_controller(GTK_WIDGET(object), GTK_EVENT_CONTROLLER(gesture)); | 9583 gtk_widget_add_controller(GTK_WIDGET(object), GTK_EVENT_CONTROLLER(gesture)); |
9587 return G_OBJECT(gesture); | 9584 return G_OBJECT(gesture); |