Mercurial > dwindows
comparison gtk/dw.c @ 134:caeb52bb5ef4
Pass pointers to argc and argv on Unix.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 21 Oct 2002 00:40:55 +0000 |
parents | 85f8ba78736d |
children | f57ef391f104 |
comparison
equal
deleted
inserted
replaced
133:85f8ba78736d | 134:caeb52bb5ef4 |
---|---|
667 * Initializes the Dynamic Windows engine. | 667 * Initializes the Dynamic Windows engine. |
668 * Parameters: | 668 * Parameters: |
669 * newthread: True if this is the only thread. | 669 * newthread: True if this is the only thread. |
670 * False if there is already a message loop running. | 670 * False if there is already a message loop running. |
671 */ | 671 */ |
672 int dw_int_init(DWResources *res, int newthread, int argc, char *argv[]) | 672 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[]) |
673 { | 673 { |
674 int z; | 674 int z; |
675 char *tmp; | 675 char *tmp; |
676 | 676 |
677 if(res) | 677 if(res) |
681 _resources.resource_data = res->resource_data; | 681 _resources.resource_data = res->resource_data; |
682 } | 682 } |
683 gtk_set_locale(); | 683 gtk_set_locale(); |
684 g_thread_init(NULL); | 684 g_thread_init(NULL); |
685 | 685 |
686 gtk_init(&argc, &argv); | 686 gtk_init(argc, argv); |
687 #ifdef USE_IMLIB | 687 #ifdef USE_IMLIB |
688 gdk_imlib_init(); | 688 gdk_imlib_init(); |
689 #endif | 689 #endif |
690 /* Add colors to the system colormap */ | 690 /* Add colors to the system colormap */ |
691 _dw_cmap = gdk_colormap_get_system(); | 691 _dw_cmap = gdk_colormap_get_system(); |
834 tmp = dialog->result; | 834 tmp = dialog->result; |
835 free(dialog); | 835 free(dialog); |
836 return tmp; | 836 return tmp; |
837 } | 837 } |
838 | 838 |
839 void _delete(GtkWidget *widget, GtkWidget *event, gpointer param) | 839 int _delete(GtkWidget *widget, GtkWidget *event, gpointer param) |
840 { | 840 { |
841 gtk_widget_destroy(GTK_WIDGET(param)); | 841 gtk_widget_destroy(GTK_WIDGET(param)); |
842 } | 842 return FALSE; |
843 | 843 } |
844 void _delete2(GtkWidget *widget, gpointer param) | 844 |
845 int _delete2(GtkWidget *widget, gpointer param) | |
845 { | 846 { |
846 gtk_widget_destroy(GTK_WIDGET(param)); | 847 gtk_widget_destroy(GTK_WIDGET(param)); |
847 } | 848 return FALSE; |
848 | 849 } |
849 | 850 |
850 void _dw_ok_func(HWND window, void *data) | 851 |
852 int _dw_ok_func(HWND window, void *data) | |
851 { | 853 { |
852 DWDialog *dwwait = (DWDialog *)data; | 854 DWDialog *dwwait = (DWDialog *)data; |
853 | 855 |
854 if(!dwwait) | 856 if(!dwwait) |
855 return; | 857 return FALSE; |
856 | 858 |
857 dw_window_destroy((HWND)dwwait->data); | 859 dw_window_destroy((HWND)dwwait->data); |
858 dw_dialog_dismiss((DWDialog *)data, (void *)0); | 860 dw_dialog_dismiss((DWDialog *)data, (void *)0); |
861 return FALSE; | |
859 } | 862 } |
860 | 863 |
861 /* | 864 /* |
862 * Displays a Message Box with given text and title.. | 865 * Displays a Message Box with given text and title.. |
863 * Parameters: | 866 * Parameters: |
911 dw_dialog_wait(dwwait); | 914 dw_dialog_wait(dwwait); |
912 | 915 |
913 return strlen(outbuf); | 916 return strlen(outbuf); |
914 } | 917 } |
915 | 918 |
916 void _dw_yes_func(HWND window, void *data) | 919 int _dw_yes_func(HWND window, void *data) |
917 { | 920 { |
918 DWDialog *dwwait = (DWDialog *)data; | 921 DWDialog *dwwait = (DWDialog *)data; |
919 | 922 |
920 if(!dwwait) | 923 if(!dwwait) |
921 return; | 924 return FALSE; |
922 | 925 |
923 dw_window_destroy((HWND)dwwait->data); | 926 dw_window_destroy((HWND)dwwait->data); |
924 dw_dialog_dismiss((DWDialog *)data, (void *)1); | 927 dw_dialog_dismiss((DWDialog *)data, (void *)1); |
925 } | 928 return FALSE; |
926 | 929 } |
927 void _dw_no_func(HWND window, void *data) | 930 |
931 int _dw_no_func(HWND window, void *data) | |
928 { | 932 { |
929 DWDialog *dwwait = (DWDialog *)data; | 933 DWDialog *dwwait = (DWDialog *)data; |
930 | 934 |
931 if(!dwwait) | 935 if(!dwwait) |
932 return; | 936 return FALSE; |
933 | 937 |
934 dw_window_destroy((HWND)dwwait->data); | 938 dw_window_destroy((HWND)dwwait->data); |
935 dw_dialog_dismiss((DWDialog *)data, (void *)0); | 939 dw_dialog_dismiss((DWDialog *)data, (void *)0); |
940 return FALSE; | |
936 } | 941 } |
937 | 942 |
938 /* | 943 /* |
939 * Displays a Message Box with given text and title.. | 944 * Displays a Message Box with given text and title.. |
940 * Parameters: | 945 * Parameters: |
4441 * pixmap: Handle to a pixmap returned by | 4446 * pixmap: Handle to a pixmap returned by |
4442 * dw_pixmap_new.. | 4447 * dw_pixmap_new.. |
4443 */ | 4448 */ |
4444 void dw_pixmap_destroy(HPIXMAP pixmap) | 4449 void dw_pixmap_destroy(HPIXMAP pixmap) |
4445 { | 4450 { |
4446 #if GTK_MAJOR_VERSION < 2 | |
4447 int _locked_by_me = FALSE; | 4451 int _locked_by_me = FALSE; |
4448 | 4452 |
4449 DW_MUTEX_LOCK; | 4453 DW_MUTEX_LOCK; |
4450 gdk_pixmap_unref(pixmap->pixmap); | 4454 gdk_pixmap_unref(pixmap->pixmap); |
4451 free(pixmap); | 4455 free(pixmap); |
4452 DW_MUTEX_UNLOCK; | 4456 DW_MUTEX_UNLOCK; |
4453 #endif | |
4454 } | 4457 } |
4455 | 4458 |
4456 /* | 4459 /* |
4457 * Copies from one item to another. | 4460 * Copies from one item to another. |
4458 * Parameters: | 4461 * Parameters: |
5738 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); | 5741 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth"); |
5739 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); | 5742 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight"); |
5740 | 5743 |
5741 /* Prevent infinite recursion ;) */ | 5744 /* Prevent infinite recursion ;) */ |
5742 if(!percent || (lastwidth == event->width && lastheight == event->height)) | 5745 if(!percent || (lastwidth == event->width && lastheight == event->height)) |
5743 return TRUE; | 5746 return FALSE; |
5744 | 5747 |
5745 lastwidth = event->width; lastheight = event->height; | 5748 lastwidth = event->width; lastheight = event->height; |
5746 | 5749 |
5747 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); | 5750 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth); |
5748 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); | 5751 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight); |
5749 | 5752 |
5750 if(GTK_IS_HPANED(widget)) | 5753 if(GTK_IS_HPANED(widget)) |
5751 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0))); | 5754 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0))); |
5752 if(GTK_IS_VPANED(widget)) | 5755 if(GTK_IS_VPANED(widget)) |
5753 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0))); | 5756 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0))); |
5754 return TRUE; | 5757 return FALSE; |
5755 } | 5758 } |
5756 | 5759 |
5757 #if GTK_MAJOR_VERSION > 1 | 5760 #if GTK_MAJOR_VERSION > 1 |
5758 /* Figure out the new percentage */ | 5761 /* Figure out the new percentage */ |
5759 gint _splitbar_accept_position(GtkWidget *widget, gpointer data) | 5762 gint _splitbar_accept_position(GtkWidget *widget, gpointer data) |
5760 { | 5763 { |
5761 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); | 5764 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent"); |
5762 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget)); | 5765 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget)); |
5763 | 5766 |
5764 if(!percent) | 5767 if(!percent) |
5765 return TRUE; | 5768 return FALSE; |
5766 | 5769 |
5767 if(GTK_IS_VPANED(widget)) | 5770 if(GTK_IS_VPANED(widget)) |
5768 size = widget->allocation.height; | 5771 size = widget->allocation.height; |
5769 else if(GTK_IS_HPANED(widget)) | 5772 else if(GTK_IS_HPANED(widget)) |
5770 size = widget->allocation.width; | 5773 size = widget->allocation.width; |
5771 | 5774 |
5772 if(size > 0) | 5775 if(size > 0) |
5773 *percent = ((float)(position * 100) / (float)size); | 5776 *percent = ((float)(position * 100) / (float)size); |
5774 return TRUE; | 5777 return FALSE; |
5775 } | 5778 } |
5776 #endif | 5779 #endif |
5777 | 5780 |
5778 /* | 5781 /* |
5779 * Creates a splitbar window (widget) with given parameters. | 5782 * Creates a splitbar window (widget) with given parameters. |
6023 env->MajorVersion = atoi(tempbuf); | 6026 env->MajorVersion = atoi(tempbuf); |
6024 env->MinorVersion = 0; | 6027 env->MinorVersion = 0; |
6025 } | 6028 } |
6026 | 6029 |
6027 /* Internal function to handle the file OK press */ | 6030 /* Internal function to handle the file OK press */ |
6028 void _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) | 6031 gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait) |
6029 { | 6032 { |
6030 #if GTK_MAJOR_VERSION > 1 | 6033 #if GTK_MAJOR_VERSION > 1 |
6031 const char *tmp; | 6034 const char *tmp; |
6032 #else | 6035 #else |
6033 char *tmp; | 6036 char *tmp; |
6034 #endif | 6037 #endif |
6035 | 6038 |
6036 if(!dwwait) | 6039 if(!dwwait) |
6037 return; | 6040 return FALSE; |
6038 | 6041 |
6039 tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data)); | 6042 tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data)); |
6040 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); | 6043 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); |
6041 _dw_file_active = 0; | 6044 _dw_file_active = 0; |
6042 dw_dialog_dismiss(dwwait, (void *)(tmp ? strdup(tmp) : NULL)); | 6045 dw_dialog_dismiss(dwwait, (void *)(tmp ? strdup(tmp) : NULL)); |
6046 return FALSE; | |
6043 } | 6047 } |
6044 | 6048 |
6045 /* Internal function to handle the file Cancel press */ | 6049 /* Internal function to handle the file Cancel press */ |
6046 void _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) | 6050 gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait) |
6047 { | 6051 { |
6048 if(!dwwait) | 6052 if(!dwwait) |
6049 return; | 6053 return FALSE; |
6050 | 6054 |
6051 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); | 6055 gtk_widget_destroy(GTK_WIDGET(dwwait->data)); |
6052 _dw_file_active = 0; | 6056 _dw_file_active = 0; |
6053 dw_dialog_dismiss(dwwait, NULL); | 6057 dw_dialog_dismiss(dwwait, NULL); |
6058 return FALSE; | |
6054 } | 6059 } |
6055 | 6060 |
6056 /* | 6061 /* |
6057 * Opens a file dialog and queries user selection. | 6062 * Opens a file dialog and queries user selection. |
6058 * Parameters: | 6063 * Parameters: |