Mercurial > dwindows
comparison gtk/dw.c @ 1485:928daa73de8d
Suppress value_changed event on GTK 2.x when calling dw_scrollbar_set_pos
to be consistent with all other platforms.
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 24 Dec 2011 12:28:29 +0000 |
parents | dd584f431f9f |
children | 5cfbf2715eec |
comparison
equal
deleted
inserted
replaced
1484:9b24233d7606 | 1485:928daa73de8d |
---|---|
1821 valuechangedfunc(work.window, (max - val) - 1, work.data); | 1821 valuechangedfunc(work.window, (max - val) - 1, work.data); |
1822 else | 1822 else |
1823 valuechangedfunc(work.window, val, work.data); | 1823 valuechangedfunc(work.window, val, work.data); |
1824 } | 1824 } |
1825 } | 1825 } |
1826 else if (scrollbar || spinbutton) | 1826 else if (spinbutton) |
1827 { | 1827 { |
1828 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data); | 1828 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data); |
1829 | 1829 |
1830 if (work.window) | 1830 if (work.window) |
1831 { | 1831 { |
1832 int (*valuechangedfunc)(HWND, int, void *) = work.func; | 1832 int (*valuechangedfunc)(HWND, int, void *) = work.func; |
1833 | 1833 |
1834 valuechangedfunc(work.window, val, work.data); | 1834 valuechangedfunc(work.window, val, work.data); |
1835 } | |
1836 } | |
1837 else if (scrollbar) | |
1838 { | |
1839 gint suppress; | |
1840 suppress = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(adjustment), "_dw_suppress_value_changed_event")); | |
1841 if (!suppress ) | |
1842 { | |
1843 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data); | |
1844 | |
1845 if (work.window) | |
1846 { | |
1847 int (*valuechangedfunc)(HWND, int, void *) = work.func; | |
1848 | |
1849 valuechangedfunc(work.window, val, work.data); | |
1850 } | |
1835 } | 1851 } |
1836 } | 1852 } |
1837 return FALSE; | 1853 return FALSE; |
1838 } | 1854 } |
1839 | 1855 |
1895 if(data) | 1911 if(data) |
1896 { | 1912 { |
1897 GdkPixmap *icon_pixmap = NULL; | 1913 GdkPixmap *icon_pixmap = NULL; |
1898 #if GTK_MAJOR_VERSION > 1 | 1914 #if GTK_MAJOR_VERSION > 1 |
1899 GdkPixbuf *icon_pixbuf; | 1915 GdkPixbuf *icon_pixbuf; |
1900 | 1916 |
1901 if(data[0] == 'G' && data[1] == 'd' && data[2] == 'k' && data[3] == 'P') | 1917 if(data[0] == 'G' && data[1] == 'd' && data[2] == 'k' && data[3] == 'P') |
1902 icon_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)data, FALSE, NULL); | 1918 icon_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)data, FALSE, NULL); |
1903 else | 1919 else |
1904 icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data); | 1920 icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data); |
1905 | 1921 |
2102 /* Setup the private data directory */ | 2118 /* Setup the private data directory */ |
2103 if(argc && argv && *argc > 0 && (*argv)[0]) | 2119 if(argc && argv && *argc > 0 && (*argv)[0]) |
2104 { | 2120 { |
2105 char *pathcopy = strdup((*argv)[0]); | 2121 char *pathcopy = strdup((*argv)[0]); |
2106 char *pos = strrchr(pathcopy, '/'); | 2122 char *pos = strrchr(pathcopy, '/'); |
2107 | 2123 |
2108 if(pos) | 2124 if(pos) |
2109 { | 2125 { |
2110 char *binname = pos + 1; | 2126 char *binname = pos + 1; |
2111 | 2127 |
2112 *pos = 0; | 2128 *pos = 0; |
2113 if(*binname) | 2129 if(*binname) |
2114 { | 2130 { |
2115 char *binpos = strstr(pathcopy, "/bin"); | 2131 char *binpos = strstr(pathcopy, "/bin"); |
2116 | 2132 |
2117 if(binpos) | 2133 if(binpos) |
2118 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); | 2134 strncpy(_dw_share_path, pathcopy, (size_t)(binpos - pathcopy)); |
2119 else | 2135 else |
2120 strcpy(_dw_share_path, "/usr/local"); | 2136 strcpy(_dw_share_path, "/usr/local"); |
2121 strcat(_dw_share_path, "/share/"); | 2137 strcat(_dw_share_path, "/share/"); |
2126 free(pathcopy); | 2142 free(pathcopy); |
2127 } | 2143 } |
2128 /* If that failed... just get the current directory */ | 2144 /* If that failed... just get the current directory */ |
2129 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) | 2145 if(!_dw_share_path[0] && !getcwd(_dw_share_path, PATH_MAX)) |
2130 _dw_share_path[0] = '/'; | 2146 _dw_share_path[0] = '/'; |
2131 | 2147 |
2132 gtk_set_locale(); | 2148 gtk_set_locale(); |
2133 #if !GLIB_CHECK_VERSION(2,32,0) | 2149 #if !GLIB_CHECK_VERSION(2,32,0) |
2134 g_thread_init(NULL); | 2150 g_thread_init(NULL); |
2135 #endif | 2151 #endif |
2136 #if GTK_MAJOR_VERSION > 1 | 2152 #if GTK_MAJOR_VERSION > 1 |
2415 char outbuf[1025] = {0}; | 2431 char outbuf[1025] = {0}; |
2416 | 2432 |
2417 va_start(args, format); | 2433 va_start(args, format); |
2418 vsnprintf(outbuf, 1024, format, args); | 2434 vsnprintf(outbuf, 1024, format, args); |
2419 va_end(args); | 2435 va_end(args); |
2420 | 2436 |
2421 fprintf(stderr, "%s", outbuf); | 2437 fprintf(stderr, "%s", outbuf); |
2422 } | 2438 } |
2423 | 2439 |
2424 /* | 2440 /* |
2425 * Displays a Message Box with given text and title.. | 2441 * Displays a Message Box with given text and title.. |
2684 else | 2700 else |
2685 #endif | 2701 #endif |
2686 if(GTK_IS_WINDOW(handle)) | 2702 if(GTK_IS_WINDOW(handle)) |
2687 { | 2703 { |
2688 /* Move the window to where it should be so gdk_window_get_frame_extents() | 2704 /* Move the window to where it should be so gdk_window_get_frame_extents() |
2689 * called from dw_window_set_pos() and dw_window_set_size() don't make the | 2705 * called from dw_window_set_pos() and dw_window_set_size() don't make the |
2690 * window appear in a bad location on the screen. | 2706 * window appear in a bad location on the screen. |
2691 */ | 2707 */ |
2692 if(x || y) | 2708 if(x || y) |
2693 { | 2709 { |
2694 gtk_window_move(GTK_WINDOW(handle), x, y); | 2710 gtk_window_move(GTK_WINDOW(handle), x, y); |
2714 /* If we had a position request before shown */ | 2730 /* If we had a position request before shown */ |
2715 if (gtk_object_get_data(GTK_OBJECT(handle), "_dw_pos")) | 2731 if (gtk_object_get_data(GTK_OBJECT(handle), "_dw_pos")) |
2716 { | 2732 { |
2717 x = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), "_dw_x")); | 2733 x = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), "_dw_x")); |
2718 y = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), "_dw_y")); | 2734 y = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(handle), "_dw_y")); |
2719 | 2735 |
2720 /* Call the position function again now that we are realized */ | 2736 /* Call the position function again now that we are realized */ |
2721 dw_window_set_pos(handle, x, y); | 2737 dw_window_set_pos(handle, x, y); |
2722 /* Clear out the data so we don't do it again */ | 2738 /* Clear out the data so we don't do it again */ |
2723 gtk_object_set_data(GTK_OBJECT(handle), "_dw_pos", NULL); | 2739 gtk_object_set_data(GTK_OBJECT(handle), "_dw_pos", NULL); |
2724 } | 2740 } |
2976 * fontname: Font name in Dynamic Windows format. | 2992 * fontname: Font name in Dynamic Windows format. |
2977 */ | 2993 */ |
2978 void API dw_font_set_default(char *fontname) | 2994 void API dw_font_set_default(char *fontname) |
2979 { | 2995 { |
2980 char *oldfont = _DWDefaultFont; | 2996 char *oldfont = _DWDefaultFont; |
2981 | 2997 |
2982 _DWDefaultFont = strdup(fontname); | 2998 _DWDefaultFont = strdup(fontname); |
2983 | 2999 |
2984 if(oldfont) | 3000 if(oldfont) |
2985 free(oldfont); | 3001 free(oldfont); |
2986 } | 3002 } |
2987 | 3003 |
2988 /* Convert DW style font to pango style */ | 3004 /* Convert DW style font to pango style */ |
3437 { | 3453 { |
3438 GtkWidget *box = dw_box_new(DW_VERT, 0); | 3454 GtkWidget *box = dw_box_new(DW_VERT, 0); |
3439 GtkWidget *table = gtk_table_new(2, 1, FALSE); | 3455 GtkWidget *table = gtk_table_new(2, 1, FALSE); |
3440 | 3456 |
3441 gtk_widget_show_all(table); | 3457 gtk_widget_show_all(table); |
3442 | 3458 |
3443 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 3459 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
3444 | 3460 |
3445 gtk_window_set_title(GTK_WINDOW(tmp), title); | 3461 gtk_window_set_title(GTK_WINDOW(tmp), title); |
3446 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE); | 3462 gtk_window_set_resizable(GTK_WINDOW(tmp), (flStyle & DW_FCF_SIZEBORDER) ? TRUE : FALSE); |
3447 | 3463 |
3845 if (strlen(tempbuf) == 0) | 3861 if (strlen(tempbuf) == 0) |
3846 tmphandle=gtk_menu_item_new(); | 3862 tmphandle=gtk_menu_item_new(); |
3847 else | 3863 else |
3848 { | 3864 { |
3849 char numbuf[11] = {0}; | 3865 char numbuf[11] = {0}; |
3850 | 3866 |
3851 if (check) | 3867 if (check) |
3852 { | 3868 { |
3853 if (accel && accel_group) | 3869 if (accel && accel_group) |
3854 { | 3870 { |
3855 tmphandle = gtk_check_menu_item_new_with_label(""); | 3871 tmphandle = gtk_check_menu_item_new_with_label(""); |
4029 /* | 4045 /* |
4030 * Deletes the menu item specified. | 4046 * Deletes the menu item specified. |
4031 * Parameters: | 4047 * Parameters: |
4032 * menu: The handle to the menu in which the item was appended. | 4048 * menu: The handle to the menu in which the item was appended. |
4033 * id: Menuitem id. | 4049 * id: Menuitem id. |
4034 * Returns: | 4050 * Returns: |
4035 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. | 4051 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. |
4036 */ | 4052 */ |
4037 int API dw_menu_delete_item(HMENUI menu, unsigned long id) | 4053 int API dw_menu_delete_item(HMENUI menu, unsigned long id) |
4038 { | 4054 { |
4039 char numbuf[11]; | 4055 char numbuf[11]; |
4418 } | 4434 } |
4419 | 4435 |
4420 void _create_tooltip(HWND handle, char *text) | 4436 void _create_tooltip(HWND handle, char *text) |
4421 { | 4437 { |
4422 GtkTooltips *tooltips = (GtkTooltips *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_tooltip"); | 4438 GtkTooltips *tooltips = (GtkTooltips *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_tooltip"); |
4423 | 4439 |
4424 if(!tooltips) | 4440 if(!tooltips) |
4425 { | 4441 { |
4426 tooltips = gtk_tooltips_new(); | 4442 tooltips = gtk_tooltips_new(); |
4427 gtk_object_set_data(GTK_OBJECT(handle), "_dw_tooltip", (gpointer)tooltips); | 4443 gtk_object_set_data(GTK_OBJECT(handle), "_dw_tooltip", (gpointer)tooltips); |
4428 } | 4444 } |
4651 GTK_WIDGET_UNSET_FLAGS(tmp, GTK_CAN_FOCUS); | 4667 GTK_WIDGET_UNSET_FLAGS(tmp, GTK_CAN_FOCUS); |
4652 gtk_widget_show(tmp); | 4668 gtk_widget_show(tmp); |
4653 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); | 4669 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); |
4654 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp); | 4670 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp); |
4655 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 4671 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
4672 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_suppress_value_changed_event", GINT_TO_POINTER(0)); | |
4656 DW_MUTEX_UNLOCK; | 4673 DW_MUTEX_UNLOCK; |
4657 return tmp; | 4674 return tmp; |
4658 } | 4675 } |
4659 | 4676 |
4660 /* | 4677 /* |
5828 return; | 5845 return; |
5829 | 5846 |
5830 DW_MUTEX_LOCK; | 5847 DW_MUTEX_LOCK; |
5831 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment"); | 5848 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment"); |
5832 if(adjustment) | 5849 if(adjustment) |
5850 { | |
5851 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(1)); | |
5833 gtk_adjustment_set_value(adjustment, (gfloat)position); | 5852 gtk_adjustment_set_value(adjustment, (gfloat)position); |
5853 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(0)); | |
5854 } | |
5834 DW_MUTEX_UNLOCK; | 5855 DW_MUTEX_UNLOCK; |
5835 } | 5856 } |
5836 | 5857 |
5837 /* | 5858 /* |
5838 * Sets the scrollbar range. | 5859 * Sets the scrollbar range. |
10181 | 10202 |
10182 /* Send the property request */ | 10203 /* Send the property request */ |
10183 XSendEvent(xdisplay, xroot_window, False, | 10204 XSendEvent(xdisplay, xroot_window, False, |
10184 (SubstructureRedirectMask | SubstructureNotifyMask), | 10205 (SubstructureRedirectMask | SubstructureNotifyMask), |
10185 &xevent); | 10206 &xevent); |
10186 | 10207 |
10187 /* Record the request time */ | 10208 /* Record the request time */ |
10188 time(&extents_time); | 10209 time(&extents_time); |
10189 | 10210 |
10190 /* Look for the property notify event */ | 10211 /* Look for the property notify event */ |
10191 XIfEvent(xdisplay, ¬ify_xevent, property_notify_predicate, (XPointer)&window_id); | 10212 XIfEvent(xdisplay, ¬ify_xevent, property_notify_predicate, (XPointer)&window_id); |
10192 | 10213 |
10193 /* If we didn't get the notification... put the event back onto the stack */ | 10214 /* If we didn't get the notification... put the event back onto the stack */ |
10194 if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id | 10215 if(notify_xevent.xany.type != PropertyNotify || notify_xevent.xany.window != window_id |
10195 || notify_xevent.xproperty.atom != extents_atom) | 10216 || notify_xevent.xproperty.atom != extents_atom) |
10196 XPutBackEvent(xdisplay, ¬ify_xevent); | 10217 XPutBackEvent(xdisplay, ¬ify_xevent); |
10197 } | 10218 } |
10198 | 10219 |
10199 /* Attempt to retrieve window's frame extents. */ | 10220 /* Attempt to retrieve window's frame extents. */ |
10200 eu.extents = &extents; | 10221 eu.extents = &extents; |
10201 if(gdk_property_get(window->window, | 10222 if(gdk_property_get(window->window, |
10202 gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE), | 10223 gdk_atom_intern("_NET_FRAME_EXTENTS", FALSE), |
10203 gdk_atom_intern("CARDINAL", FALSE), | 10224 gdk_atom_intern("CARDINAL", FALSE), |
10228 | 10249 |
10229 DW_MUTEX_LOCK; | 10250 DW_MUTEX_LOCK; |
10230 if(GTK_IS_WINDOW(handle)) | 10251 if(GTK_IS_WINDOW(handle)) |
10231 { | 10252 { |
10232 int cx = 0, cy = 0; | 10253 int cx = 0, cy = 0; |
10233 | 10254 |
10234 #ifdef GDK_WINDOWING_X11 | 10255 #ifdef GDK_WINDOWING_X11 |
10235 _size_allocate(GTK_WINDOW(handle)); | 10256 _size_allocate(GTK_WINDOW(handle)); |
10236 #endif | 10257 #endif |
10237 /* If the window is mapped */ | 10258 /* If the window is mapped */ |
10238 if(handle->window && GTK_WIDGET_MAPPED(handle)) | 10259 if(handle->window && GTK_WIDGET_MAPPED(handle)) |
10242 gint gwidth, gheight; | 10263 gint gwidth, gheight; |
10243 | 10264 |
10244 /* Calculate the border size */ | 10265 /* Calculate the border size */ |
10245 gdk_window_get_frame_extents(handle->window, &frame); | 10266 gdk_window_get_frame_extents(handle->window, &frame); |
10246 gdk_window_get_geometry(handle->window, NULL, NULL, &gwidth, &gheight, NULL); | 10267 gdk_window_get_geometry(handle->window, NULL, NULL, &gwidth, &gheight, NULL); |
10247 | 10268 |
10248 cx = frame.width - gwidth; | 10269 cx = frame.width - gwidth; |
10249 if(cx < 0) | 10270 if(cx < 0) |
10250 cx = 0; | 10271 cx = 0; |
10251 cy = frame.height - gheight; | 10272 cy = frame.height - gheight; |
10252 if(cy < 0) | 10273 if(cy < 0) |
10404 GdkRectangle frame; | 10425 GdkRectangle frame; |
10405 int count = 0; | 10426 int count = 0; |
10406 | 10427 |
10407 /* Get the frame size */ | 10428 /* Get the frame size */ |
10408 gdk_window_get_frame_extents(handle->window, &frame); | 10429 gdk_window_get_frame_extents(handle->window, &frame); |
10409 | 10430 |
10410 /* FIXME: Sometimes we get returned an invalid 200x200 | 10431 /* FIXME: Sometimes we get returned an invalid 200x200 |
10411 * result... so if we get this... try the call a second | 10432 * result... so if we get this... try the call a second |
10412 * time and hope for a better result. | 10433 * time and hope for a better result. |
10413 */ | 10434 */ |
10414 while((frame.width == 200 || frame.width == (200 + cx)) && | 10435 while((frame.width == 200 || frame.width == (200 + cx)) && |
10415 (frame.height == 200 || frame.height == (200 + cy)) && count < 10) | 10436 (frame.height == 200 || frame.height == (200 + cy)) && count < 10) |
10416 { | 10437 { |
10417 dw_main_sleep(1); | 10438 dw_main_sleep(1); |
10418 count++; | 10439 count++; |
10419 gdk_window_get_frame_extents(handle->window, &frame); | 10440 gdk_window_get_frame_extents(handle->window, &frame); |
10420 } | 10441 } |
10421 width = frame.width; | 10442 width = frame.width; |
10422 height = frame.height; | 10443 height = frame.height; |
10423 } | 10444 } |
10424 } | 10445 } |
10425 else | 10446 else |
10426 { | 10447 { |
10427 int cx , cy; | 10448 int cx , cy; |
10428 | 10449 |
10465 /* Handle vertical center gravity */ | 10486 /* Handle vertical center gravity */ |
10466 if((vert & 0xf) == DW_GRAV_CENTER) | 10487 if((vert & 0xf) == DW_GRAV_CENTER) |
10467 newy += ((gdk_screen_height() / 2) - (height / 2)); | 10488 newy += ((gdk_screen_height() / 2) - (height / 2)); |
10468 else if((vert & 0xf) == DW_GRAV_BOTTOM) | 10489 else if((vert & 0xf) == DW_GRAV_BOTTOM) |
10469 newy = gdk_screen_height() - height - y; | 10490 newy = gdk_screen_height() - height - y; |
10470 } | 10491 } |
10471 if(GTK_WIDGET_MAPPED(handle)) | 10492 if(GTK_WIDGET_MAPPED(handle)) |
10472 { | 10493 { |
10473 /* Finally move the window into place */ | 10494 /* Finally move the window into place */ |
10474 gtk_window_move(GTK_WINDOW(handle), newx, newy); | 10495 gtk_window_move(GTK_WINDOW(handle), newx, newy); |
10475 } | 10496 } |
10629 gtk_label_set_line_wrap( GTK_LABEL(handle), TRUE ); | 10650 gtk_label_set_line_wrap( GTK_LABEL(handle), TRUE ); |
10630 } | 10651 } |
10631 if ( GTK_IS_CHECK_MENU_ITEM(handle2) && (mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED)) ) | 10652 if ( GTK_IS_CHECK_MENU_ITEM(handle2) && (mask & (DW_MIS_CHECKED | DW_MIS_UNCHECKED)) ) |
10632 { | 10653 { |
10633 int check = 0; | 10654 int check = 0; |
10634 | 10655 |
10635 if ( style & DW_MIS_CHECKED ) | 10656 if ( style & DW_MIS_CHECKED ) |
10636 check = 1; | 10657 check = 1; |
10637 | 10658 |
10638 _dw_ignore_click = 1; | 10659 _dw_ignore_click = 1; |
10639 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(handle2)) != check) | 10660 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(handle2)) != check) |
12009 } | 12030 } |
12010 | 12031 |
12011 if ( defpath ) | 12032 if ( defpath ) |
12012 { | 12033 { |
12013 struct stat buf; | 12034 struct stat buf; |
12014 | 12035 |
12015 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath)) | 12036 if ( g_path_is_absolute( defpath ) || !realpath(defpath, mypath)) |
12016 { | 12037 { |
12017 strcpy( mypath, defpath ); | 12038 strcpy( mypath, defpath ); |
12018 } | 12039 } |
12019 | 12040 |
12020 /* See if the path exists */ | 12041 /* See if the path exists */ |
12021 if(stat(mypath, &buf) == 0) | 12042 if(stat(mypath, &buf) == 0) |
12022 { | 12043 { |
12023 /* If the path is a directory... set the current folder */ | 12044 /* If the path is a directory... set the current folder */ |
12024 if(buf.st_mode & S_IFDIR) | 12045 if(buf.st_mode & S_IFDIR) |
12025 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath ); | 12046 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( filew ), mypath ); |
12031 else if(flags == DW_FILE_SAVE) | 12052 else if(flags == DW_FILE_SAVE) |
12032 { | 12053 { |
12033 if(strchr(mypath, '/')) | 12054 if(strchr(mypath, '/')) |
12034 { | 12055 { |
12035 unsigned long x = strlen(mypath) - 1; | 12056 unsigned long x = strlen(mypath) - 1; |
12036 | 12057 |
12037 /* Trim off the filename */ | 12058 /* Trim off the filename */ |
12038 while(x > 0 && mypath[x] != '/') | 12059 while(x > 0 && mypath[x] != '/') |
12039 { | 12060 { |
12040 x--; | 12061 x--; |
12041 } | 12062 } |
12042 if(mypath[x] == '/') | 12063 if(mypath[x] == '/') |
12043 { | 12064 { |
12044 char *file = NULL; | 12065 char *file = NULL; |
12045 char temp[PATH_MAX+1]; | 12066 char temp[PATH_MAX+1]; |
12046 | 12067 |
12047 /* Save the original path in temp */ | 12068 /* Save the original path in temp */ |
12048 strcpy(temp, mypath); | 12069 strcpy(temp, mypath); |
12049 mypath[x] = 0; | 12070 mypath[x] = 0; |
12050 | 12071 |
12051 /* Check to make sure the trimmed piece is a directory */ | 12072 /* Check to make sure the trimmed piece is a directory */ |
12052 if(realpath(mypath, temp) && stat(temp, &buf) == 0) | 12073 if(realpath(mypath, temp) && stat(temp, &buf) == 0) |
12053 { | 12074 { |
12054 if(buf.st_mode & S_IFDIR) | 12075 if(buf.st_mode & S_IFDIR) |
12055 { | 12076 { |
12056 /* We now have it split */ | 12077 /* We now have it split */ |
12057 file = &mypath[x+1]; | 12078 file = &mypath[x+1]; |
12058 } | 12079 } |
12059 } | 12080 } |
12060 | 12081 |
12061 /* Select folder... */ | 12082 /* Select folder... */ |
12062 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(filew), temp ); | 12083 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(filew), temp ); |
12063 /* ... and file separately */ | 12084 /* ... and file separately */ |
12064 if(file) | 12085 if(file) |
12065 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER(filew), file ); | 12086 gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER(filew), file ); |
12824 return _user_dir; | 12845 return _user_dir; |
12825 } | 12846 } |
12826 | 12847 |
12827 /* | 12848 /* |
12828 * Returns a pointer to a static buffer which containes the | 12849 * Returns a pointer to a static buffer which containes the |
12829 * private application data directory. | 12850 * private application data directory. |
12830 */ | 12851 */ |
12831 char * API dw_app_dir(void) | 12852 char * API dw_app_dir(void) |
12832 { | 12853 { |
12833 return _dw_share_path; | 12854 return _dw_share_path; |
12834 } | 12855 } |