From 947b32b7dcaf233f3c2bb9a38fb07c2c64a1ee0b Mon Sep 17 00:00:00 2001 From: Hans Breuer Date: Sat, 15 Nov 2003 20:35:55 +0000 Subject: [PATCH] updated added all the new tests 2003-11-15 Hans Breuer * gdk/makefile.msc gdk/gdk.def gtk/gtk.def gtk/makefile.msc.in : updated * tests/makefile.msc : added all the new tests * gtk/gtkfilefilter.c(finalize) : initialize filter from object not from itself * gtk/gtkfilesystemwin32.[hc] : copied from gtkfilesystemunix.[hc] modified as less as posible to have aworking implementation on win32. There maybe the desire to merge the unchanged pats into a common base class. Also implemented a simple glib based bookmark handling, which is currently missing in gtkfilesystemunix.[hc] but can be copied over there. * gtk/gtkfilechooserwidget.c : conditional include gtkfilesystemwin32.h * gdk/win32/gdkwindow-win32.c : implement gdk_window_set_keep_above() and gdk_window_set_keep_below() * tests/testmerge.c : don't include unistd.h unconditionally, #define STDOUT_FILENO if it isn't defined * tests/testfilechooser.c : make it compile on win32 --- ChangeLog | 26 + ChangeLog.pre-2-10 | 26 + ChangeLog.pre-2-4 | 26 + ChangeLog.pre-2-6 | 26 + ChangeLog.pre-2-8 | 26 + gdk/makefile.msc | 5 +- gdk/win32/gdkwindow-win32.c | 59 ++ gtk/gtk.def | 249 ++++++++- gtk/gtkfilechooserwidget.c | 3 + gtk/gtkfilefilter.c | 2 +- gtk/gtkfilesystemwin32.c | 1015 +++++++++++++++++++++++++++++++++++ gtk/gtkfilesystemwin32.h | 40 ++ gtk/makefile.msc.in | 34 +- tests/makefile.msc | 32 +- tests/testfilechooser.c | 17 +- tests/testmerge.c | 8 + 16 files changed, 1567 insertions(+), 27 deletions(-) create mode 100644 gtk/gtkfilesystemwin32.c create mode 100644 gtk/gtkfilesystemwin32.h diff --git a/ChangeLog b/ChangeLog index 9e317654c2..7f7ffd04b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2003-11-15 Hans Breuer + + * gdk/makefile.msc gdk/gdk.def + gtk/gtk.def gtk/makefile.msc.in : updated + * tests/makefile.msc : added all the new tests + + * gtk/gtkfilefilter.c(finalize) : initialize filter + from object not from itself + + * gtk/gtkfilesystemwin32.[hc] : copied from gtkfilesystemunix.[hc] + modified as less as posible to have aworking implementation + on win32. There maybe the desire to merge the unchanged pats into + a common base class. + Also implemented a simple glib based bookmark handling, which + is currently missing in gtkfilesystemunix.[hc] but can be copied + over there. + * gtk/gtkfilechooserwidget.c : conditional include gtkfilesystemwin32.h + + * gdk/win32/gdkwindow-win32.c : implement + gdk_window_set_keep_above() and gdk_window_set_keep_below() + + * tests/testmerge.c : don't include unistd.h unconditionally, + #define STDOUT_FILENO if it isn't defined + + * tests/testfilechooser.c : make it compile on win32 + 2003-11-15 Tor Lillqvist * gdk/win32/gdkwindow-win32.c (gdk_window_focus): If the window is diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9e317654c2..7f7ffd04b4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,29 @@ +2003-11-15 Hans Breuer + + * gdk/makefile.msc gdk/gdk.def + gtk/gtk.def gtk/makefile.msc.in : updated + * tests/makefile.msc : added all the new tests + + * gtk/gtkfilefilter.c(finalize) : initialize filter + from object not from itself + + * gtk/gtkfilesystemwin32.[hc] : copied from gtkfilesystemunix.[hc] + modified as less as posible to have aworking implementation + on win32. There maybe the desire to merge the unchanged pats into + a common base class. + Also implemented a simple glib based bookmark handling, which + is currently missing in gtkfilesystemunix.[hc] but can be copied + over there. + * gtk/gtkfilechooserwidget.c : conditional include gtkfilesystemwin32.h + + * gdk/win32/gdkwindow-win32.c : implement + gdk_window_set_keep_above() and gdk_window_set_keep_below() + + * tests/testmerge.c : don't include unistd.h unconditionally, + #define STDOUT_FILENO if it isn't defined + + * tests/testfilechooser.c : make it compile on win32 + 2003-11-15 Tor Lillqvist * gdk/win32/gdkwindow-win32.c (gdk_window_focus): If the window is diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9e317654c2..7f7ffd04b4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,29 @@ +2003-11-15 Hans Breuer + + * gdk/makefile.msc gdk/gdk.def + gtk/gtk.def gtk/makefile.msc.in : updated + * tests/makefile.msc : added all the new tests + + * gtk/gtkfilefilter.c(finalize) : initialize filter + from object not from itself + + * gtk/gtkfilesystemwin32.[hc] : copied from gtkfilesystemunix.[hc] + modified as less as posible to have aworking implementation + on win32. There maybe the desire to merge the unchanged pats into + a common base class. + Also implemented a simple glib based bookmark handling, which + is currently missing in gtkfilesystemunix.[hc] but can be copied + over there. + * gtk/gtkfilechooserwidget.c : conditional include gtkfilesystemwin32.h + + * gdk/win32/gdkwindow-win32.c : implement + gdk_window_set_keep_above() and gdk_window_set_keep_below() + + * tests/testmerge.c : don't include unistd.h unconditionally, + #define STDOUT_FILENO if it isn't defined + + * tests/testfilechooser.c : make it compile on win32 + 2003-11-15 Tor Lillqvist * gdk/win32/gdkwindow-win32.c (gdk_window_focus): If the window is diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9e317654c2..7f7ffd04b4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,29 @@ +2003-11-15 Hans Breuer + + * gdk/makefile.msc gdk/gdk.def + gtk/gtk.def gtk/makefile.msc.in : updated + * tests/makefile.msc : added all the new tests + + * gtk/gtkfilefilter.c(finalize) : initialize filter + from object not from itself + + * gtk/gtkfilesystemwin32.[hc] : copied from gtkfilesystemunix.[hc] + modified as less as posible to have aworking implementation + on win32. There maybe the desire to merge the unchanged pats into + a common base class. + Also implemented a simple glib based bookmark handling, which + is currently missing in gtkfilesystemunix.[hc] but can be copied + over there. + * gtk/gtkfilechooserwidget.c : conditional include gtkfilesystemwin32.h + + * gdk/win32/gdkwindow-win32.c : implement + gdk_window_set_keep_above() and gdk_window_set_keep_below() + + * tests/testmerge.c : don't include unistd.h unconditionally, + #define STDOUT_FILENO if it isn't defined + + * tests/testfilechooser.c : make it compile on win32 + 2003-11-15 Tor Lillqvist * gdk/win32/gdkwindow-win32.c (gdk_window_focus): If the window is diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9e317654c2..7f7ffd04b4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,29 @@ +2003-11-15 Hans Breuer + + * gdk/makefile.msc gdk/gdk.def + gtk/gtk.def gtk/makefile.msc.in : updated + * tests/makefile.msc : added all the new tests + + * gtk/gtkfilefilter.c(finalize) : initialize filter + from object not from itself + + * gtk/gtkfilesystemwin32.[hc] : copied from gtkfilesystemunix.[hc] + modified as less as posible to have aworking implementation + on win32. There maybe the desire to merge the unchanged pats into + a common base class. + Also implemented a simple glib based bookmark handling, which + is currently missing in gtkfilesystemunix.[hc] but can be copied + over there. + * gtk/gtkfilechooserwidget.c : conditional include gtkfilesystemwin32.h + + * gdk/win32/gdkwindow-win32.c : implement + gdk_window_set_keep_above() and gdk_window_set_keep_below() + + * tests/testmerge.c : don't include unistd.h unconditionally, + #define STDOUT_FILENO if it isn't defined + + * tests/testfilechooser.c : make it compile on win32 + 2003-11-15 Tor Lillqvist * gdk/win32/gdkwindow-win32.c (gdk_window_focus): If the window is diff --git a/gdk/makefile.msc b/gdk/makefile.msc index cf20dcf5f0..8baf968186 100644 --- a/gdk/makefile.msc +++ b/gdk/makefile.msc @@ -42,7 +42,10 @@ PERL = perl CFLAGS = -FImsvc_recommended_pragmas.h -I . -I .. \ $(GLIB_CFLAGS) $(PANGO_CFLAGS) -I ../gdk-pixbuf \ - $(G_DEBUGGING) -DHAVE_CONFIG_H -DGDK_ENABLE_BROKEN -DGDK_VERSION=\"$(GTK_VER)\" + $(G_DEBUGGING) -DHAVE_CONFIG_H -DGDK_ENABLE_BROKEN \ + -DGDK_VERSION=\"$(GTK_VER)\" \ + -DG_LOG_DOMAIN=\"Gdk\" + EXTRALIBS = $(WTKIT)\lib\i386\wntab32x.lib $(GLIB_LIBS) \ ..\gdk-pixbuf\gdk_pixbuf-$(GDK_PIXBUF_VER).lib \ $(PANGOWIN32_LIBS) $(INTL_LIBS) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 6651e54664..e2b7d629a2 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -732,6 +732,12 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, private->state &= (~GDK_WINDOW_STATE_WITHDRAWN); else private->state |= GDK_WINDOW_STATE_WITHDRAWN; + if (GetWindowLong ((HWND)anid, GWL_EXSTYLE) & WS_EX_TOPMOST) + private->state |= GDK_WINDOW_STATE_ABOVE; + else + private->state &= (~GDK_WINDOW_STATE_ABOVE); + private->state &= (~GDK_WINDOW_STATE_BELOW); + private->depth = gdk_visual_get_system ()->depth; _gdk_window_init_position (GDK_WINDOW (private)); @@ -954,6 +960,19 @@ show_window_internal (GdkWindow *window, old_active_window = GetActiveWindow (); + if (private->state & (GDK_WINDOW_STATE_BELOW | GDK_WINDOW_STATE_ABOVE)) + { + DWORD exstyle = GetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE); + + if (private->state & GDK_WINDOW_STATE_BELOW) + exstyle &= (~WS_EX_TOPMOST); + if (private->state & GDK_WINDOW_STATE_ABOVE) + exstyle |= WS_EX_TOPMOST; + + if (!SetWindowLong (GDK_WINDOW_HWND (window), GWL_EXSTYLE, exstyle)) + WIN32_API_FAILED ("SetWindowLong"); + } + if (private->state & GDK_WINDOW_STATE_FULLSCREEN) gdk_window_fullscreen (window); else if (private->state & GDK_WINDOW_STATE_MAXIMIZED) @@ -2702,6 +2721,46 @@ gdk_window_unfullscreen (GdkWindow *window) } } +void +gdk_window_set_keep_above (GdkWindow *window, gboolean setting) +{ + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_WINDOW_DESTROYED (window)) + return; + + if (GDK_WINDOW_IS_MAPPED (window)) + { + if (!SetWindowPos(GDK_WINDOW_HWND (window), setting ? HWND_TOPMOST : HWND_NOTOPMOST, + 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE)) + WIN32_API_FAILED ("SetWindowPos"); + } + else + gdk_synthesize_window_state (window, + setting ? GDK_WINDOW_STATE_BELOW : GDK_WINDOW_STATE_ABOVE, + setting ? GDK_WINDOW_STATE_ABOVE : 0); +} + +void +gdk_window_set_keep_below (GdkWindow *window, gboolean setting) +{ + g_return_if_fail (GDK_IS_WINDOW (window)); + + if (GDK_WINDOW_DESTROYED (window)) + return; + + if (GDK_WINDOW_IS_MAPPED (window)) + { + if (!SetWindowPos(GDK_WINDOW_HWND (window), setting ? HWND_BOTTOM : HWND_NOTOPMOST, + 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE)) + WIN32_API_FAILED ("SetWindowPos"); + } + else + gdk_synthesize_window_state (window, + setting ? GDK_WINDOW_STATE_ABOVE : GDK_WINDOW_STATE_BELOW, + setting ? GDK_WINDOW_STATE_BELOW : 0); +} + void gdk_window_focus (GdkWindow *window, guint32 timestamp) diff --git a/gtk/gtk.def b/gtk/gtk.def index 0b8f330a52..24103055d0 100755 --- a/gtk/gtk.def +++ b/gtk/gtk.def @@ -38,6 +38,36 @@ EXPORTS gtk_accelerator_valid gtk_accessible_connect_widget_destroyed gtk_accessible_get_type + gtk_action_activate + gtk_action_block_activate_from + gtk_action_connect_accelerator + gtk_action_connect_proxy + gtk_action_create_icon + gtk_action_create_menu_item + gtk_action_create_tool_item + gtk_action_disconnect_accelerator + gtk_action_disconnect_proxy + gtk_action_get_name + gtk_action_get_proxies + gtk_action_get_type + gtk_action_group_add_action + gtk_action_group_add_actions + gtk_action_group_add_actions_full + gtk_action_group_add_radio_actions + gtk_action_group_add_radio_actions_full + gtk_action_group_add_toggle_actions + gtk_action_group_add_toggle_actions_full + gtk_action_group_get_action + gtk_action_group_get_name + gtk_action_group_get_type + gtk_action_group_list_actions + gtk_action_group_new + gtk_action_group_remove_action + gtk_action_group_set_translate_func + gtk_action_group_set_translation_domain + gtk_action_set_accel_group + gtk_action_set_accel_path + gtk_action_unblock_activate_from gtk_adjustment_changed gtk_adjustment_clamp_page gtk_adjustment_get_type @@ -168,17 +198,36 @@ EXPORTS gtk_cell_renderer_toggle_set_active gtk_cell_renderer_toggle_set_radio gtk_cell_type_get_type + gtk_cell_view_get_displayed_row + gtk_cell_view_get_type + gtk_cell_view_menu_item_get_type + gtk_cell_view_menu_item_new + gtk_cell_view_menu_item_new_from_model + gtk_cell_view_menu_item_new_with_markup + gtk_cell_view_menu_item_new_with_pixbuf + gtk_cell_view_menu_item_new_with_text + gtk_cell_view_new + gtk_cell_view_new_with_markup + gtk_cell_view_new_with_pixbuf + gtk_cell_view_new_with_text + gtk_cell_view_set_background_color + gtk_cell_view_set_displayed_row + gtk_cell_view_set_model + gtk_cell_view_set_value + gtk_cell_view_set_values gtk_check_button_get_type gtk_check_button_new gtk_check_button_new_with_label gtk_check_button_new_with_mnemonic gtk_check_menu_item_get_active + gtk_check_menu_item_get_draw_as_radio gtk_check_menu_item_get_inconsistent gtk_check_menu_item_get_type gtk_check_menu_item_new gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_mnemonic gtk_check_menu_item_set_active + gtk_check_menu_item_set_draw_as_radio gtk_check_menu_item_set_inconsistent gtk_check_menu_item_set_show_toggle gtk_check_menu_item_toggled @@ -307,6 +356,23 @@ EXPORTS gtk_color_selection_set_previous_alpha gtk_color_selection_set_previous_color gtk_color_selection_set_update_policy + gtk_combo_box_append_text + gtk_combo_box_entry_get_text_column + gtk_combo_box_entry_get_type + gtk_combo_box_entry_new + gtk_combo_box_get_active + gtk_combo_box_get_active_iter + gtk_combo_box_get_model + gtk_combo_box_get_type + gtk_combo_box_insert_text + gtk_combo_box_new + gtk_combo_box_new_text + gtk_combo_box_prepend_text + gtk_combo_box_set_active + gtk_combo_box_set_active_iter + gtk_combo_box_set_column_span_column + gtk_combo_box_set_row_span_column + gtk_combo_box_set_wrap_width gtk_combo_disable_activate gtk_combo_get_type gtk_combo_new @@ -316,6 +382,7 @@ EXPORTS gtk_combo_set_use_arrows gtk_combo_set_use_arrows_always gtk_combo_set_value_in_list + gtk_combo_string_key gtk_container_add gtk_container_add_with_properties gtk_container_check_resize @@ -558,8 +625,12 @@ EXPORTS gtk_entry_set_visibility gtk_entry_set_width_chars gtk_entry_text_index_to_layout_index + gtk_event_box_get_above_child gtk_event_box_get_type + gtk_event_box_get_visible_window gtk_event_box_new + gtk_event_box_set_above_child + gtk_event_box_set_visible_window gtk_events_pending gtk_exit gtk_expander_get_expanded @@ -577,6 +648,94 @@ EXPORTS gtk_expander_set_use_underline gtk_expander_style_get_type gtk_false + gtk_file_chooser_action_get_type + gtk_file_chooser_add_filter + gtk_file_chooser_add_shortcut_folder + gtk_file_chooser_add_shortcut_folder_uri + gtk_file_chooser_dialog_get_type + gtk_file_chooser_dialog_new + gtk_file_chooser_error_get_type + gtk_file_chooser_error_quark + gtk_file_chooser_get_action + gtk_file_chooser_get_current_folder + gtk_file_chooser_get_current_folder_uri + gtk_file_chooser_get_extra_widget + gtk_file_chooser_get_filename + gtk_file_chooser_get_filenames + gtk_file_chooser_get_filter + gtk_file_chooser_get_folder_mode + gtk_file_chooser_get_local_only + gtk_file_chooser_get_preview_filename + gtk_file_chooser_get_preview_uri + gtk_file_chooser_get_preview_widget + gtk_file_chooser_get_preview_widget_active + gtk_file_chooser_get_select_multiple + gtk_file_chooser_get_type + gtk_file_chooser_get_uri + gtk_file_chooser_get_uris + gtk_file_chooser_list_filters + gtk_file_chooser_list_shortcut_folder_uris + gtk_file_chooser_list_shortcut_folders + gtk_file_chooser_remove_filter + gtk_file_chooser_remove_shortcut_folder + gtk_file_chooser_remove_shortcut_folder_uri + gtk_file_chooser_select_all + gtk_file_chooser_select_filename + gtk_file_chooser_select_uri + gtk_file_chooser_set_action + gtk_file_chooser_set_current_folder + gtk_file_chooser_set_current_folder_uri + gtk_file_chooser_set_current_name + gtk_file_chooser_set_extra_widget + gtk_file_chooser_set_filename + gtk_file_chooser_set_filter + gtk_file_chooser_set_folder_mode + gtk_file_chooser_set_local_only + gtk_file_chooser_set_preview_widget + gtk_file_chooser_set_preview_widget_active + gtk_file_chooser_set_select_multiple + gtk_file_chooser_set_uri + gtk_file_chooser_unselect_all + gtk_file_chooser_unselect_filename + gtk_file_chooser_unselect_uri + gtk_file_chooser_widget_get_type + gtk_file_chooser_widget_new + gtk_file_filter_add_custom + gtk_file_filter_add_mime_type + gtk_file_filter_add_pattern + gtk_file_filter_filter + gtk_file_filter_flags_get_type + gtk_file_filter_get_name + gtk_file_filter_get_needed + gtk_file_filter_get_type + gtk_file_filter_new + gtk_file_filter_set_name + gtk_file_folder_get_info + gtk_file_folder_get_type + gtk_file_folder_list_children + gtk_file_info_copy + gtk_file_info_free + gtk_file_info_get_display_key + gtk_file_info_get_display_name + gtk_file_info_get_icon_type + gtk_file_info_get_is_folder + gtk_file_info_get_is_hidden + gtk_file_info_get_mime_type + gtk_file_info_get_modification_time + gtk_file_info_get_size + gtk_file_info_get_type + gtk_file_info_new + gtk_file_info_render_icon + gtk_file_info_set_display_name + gtk_file_info_set_icon_type + gtk_file_info_set_is_folder + gtk_file_info_set_is_hidden + gtk_file_info_set_mime_type + gtk_file_info_set_modification_time + gtk_file_info_set_size + gtk_file_paths_copy + gtk_file_paths_free + gtk_file_paths_sort gtk_file_selection_complete gtk_file_selection_get_filename gtk_file_selection_get_select_multiple @@ -587,6 +746,23 @@ EXPORTS gtk_file_selection_set_filename gtk_file_selection_set_select_multiple gtk_file_selection_show_fileop_buttons + gtk_file_system_add_bookmark + gtk_file_system_error_quark + gtk_file_system_filename_to_path + gtk_file_system_get_folder + gtk_file_system_get_parent + gtk_file_system_get_root_info + gtk_file_system_get_type + gtk_file_system_list_bookmarks + gtk_file_system_list_roots + gtk_file_system_make_path + gtk_file_system_parse + gtk_file_system_path_to_filename + gtk_file_system_path_to_uri + gtk_file_system_remove_bookmark + gtk_file_system_unix_get_type + gtk_file_system_unix_new + gtk_file_system_uri_to_path gtk_fixed_get_has_window gtk_fixed_get_type gtk_fixed_move @@ -698,6 +874,7 @@ EXPORTS gtk_icon_info_get_type gtk_icon_info_load_icon gtk_icon_info_set_raw_coordinates + gtk_icon_lookup_flags_get_type gtk_icon_set_add_source gtk_icon_set_copy gtk_icon_set_get_sizes @@ -738,6 +915,7 @@ EXPORTS gtk_icon_source_set_state_wildcarded gtk_icon_theme_add_builtin_icon gtk_icon_theme_append_search_path + gtk_icon_theme_error_get_type gtk_icon_theme_error_quark gtk_icon_theme_get_default gtk_icon_theme_get_example_icon_name @@ -989,6 +1167,7 @@ EXPORTS gtk_marshal_VOID__UINT_POINTER_UINT_UINT_ENUM gtk_marshal_VOID__UINT_STRING gtk_match_type_get_type + gtk_menu_attach gtk_menu_attach_to_widget gtk_menu_bar_get_type gtk_menu_bar_new @@ -1223,6 +1402,10 @@ EXPORTS gtk_quit_add_full gtk_quit_remove gtk_quit_remove_by_data + gtk_radio_action_get_current_value + gtk_radio_action_get_group + gtk_radio_action_get_type + gtk_radio_action_set_group gtk_radio_button_get_group gtk_radio_button_get_type gtk_radio_button_new @@ -1347,8 +1530,10 @@ EXPORTS gtk_separator_get_type gtk_separator_menu_item_get_type gtk_separator_menu_item_new + gtk_separator_tool_item_get_draw gtk_separator_tool_item_get_type gtk_separator_tool_item_new + gtk_separator_tool_item_set_draw gtk_set_locale gtk_settings_get_default gtk_settings_get_for_screen @@ -1464,6 +1649,7 @@ EXPORTS gtk_tearoff_menu_item_get_type gtk_tearoff_menu_item_new gtk_text_anchored_child_set_layout + gtk_text_attr_appearance_type gtk_text_attributes_copy gtk_text_attributes_copy_values gtk_text_attributes_get_type @@ -1529,6 +1715,7 @@ EXPORTS gtk_text_buffer_set_modified gtk_text_buffer_set_text gtk_text_byte_begins_utf8_char + gtk_text_char_type gtk_text_child_anchor_get_deleted gtk_text_child_anchor_get_type gtk_text_child_anchor_get_widgets @@ -1536,6 +1723,7 @@ EXPORTS gtk_text_child_anchor_queue_resize gtk_text_child_anchor_register_child gtk_text_child_anchor_unregister_child + gtk_text_child_type gtk_text_direction_get_type gtk_text_forward_delete gtk_text_freeze @@ -1554,6 +1742,10 @@ EXPORTS gtk_text_iter_backward_sentence_start gtk_text_iter_backward_sentence_starts gtk_text_iter_backward_to_tag_toggle + gtk_text_iter_backward_visible_cursor_position + gtk_text_iter_backward_visible_cursor_positions + gtk_text_iter_backward_visible_word_start + gtk_text_iter_backward_visible_word_starts gtk_text_iter_backward_word_start gtk_text_iter_backward_word_starts gtk_text_iter_begins_tag @@ -1579,6 +1771,10 @@ EXPORTS gtk_text_iter_forward_to_end gtk_text_iter_forward_to_line_end gtk_text_iter_forward_to_tag_toggle + gtk_text_iter_forward_visible_cursor_position + gtk_text_iter_forward_visible_cursor_positions + gtk_text_iter_forward_visible_word_end + gtk_text_iter_forward_visible_word_ends gtk_text_iter_forward_word_end gtk_text_iter_forward_word_ends gtk_text_iter_free @@ -1662,6 +1858,7 @@ EXPORTS gtk_text_layout_wrap gtk_text_layout_wrap_loop_end gtk_text_layout_wrap_loop_start + gtk_text_left_mark_type gtk_text_line_segment_split gtk_text_mark_get_buffer gtk_text_mark_get_deleted @@ -1671,6 +1868,8 @@ EXPORTS gtk_text_mark_get_visible gtk_text_mark_set_visible gtk_text_new + gtk_text_pixbuf_type + gtk_text_right_mark_type gtk_text_search_flags_get_type gtk_text_set_adjustments gtk_text_set_editable @@ -1690,6 +1889,8 @@ EXPORTS gtk_text_tag_table_new gtk_text_tag_table_remove gtk_text_thaw + gtk_text_toggle_off_type + gtk_text_toggle_on_type gtk_text_unknown_char_utf8 gtk_text_view_add_child_at_anchor gtk_text_view_add_child_in_window @@ -1698,6 +1899,7 @@ EXPORTS gtk_text_view_buffer_to_window_coords gtk_text_view_forward_display_line gtk_text_view_forward_display_line_end + gtk_text_view_get_accepts_tab gtk_text_view_get_border_window_size gtk_text_view_get_buffer gtk_text_view_get_cursor_visible @@ -1730,6 +1932,7 @@ EXPORTS gtk_text_view_scroll_mark_onscreen gtk_text_view_scroll_to_iter gtk_text_view_scroll_to_mark + gtk_text_view_set_accepts_tab gtk_text_view_set_border_window_size gtk_text_view_set_buffer gtk_text_view_set_cursor_visible @@ -1759,6 +1962,12 @@ EXPORTS gtk_tips_query_set_labels gtk_tips_query_start_query gtk_tips_query_stop_query + gtk_toggle_action_get_active + gtk_toggle_action_get_draw_as_radio + gtk_toggle_action_get_type + gtk_toggle_action_set_active + gtk_toggle_action_set_draw_as_radio + gtk_toggle_action_toggled gtk_toggle_button_get_active gtk_toggle_button_get_inconsistent gtk_toggle_button_get_mode @@ -1791,8 +2000,8 @@ EXPORTS gtk_tool_item_get_expand gtk_tool_item_get_homogeneous gtk_tool_item_get_icon_size + gtk_tool_item_get_is_important gtk_tool_item_get_orientation - gtk_tool_item_get_pack_end gtk_tool_item_get_proxy_menu_item gtk_tool_item_get_relief_style gtk_tool_item_get_toolbar_style @@ -1804,7 +2013,7 @@ EXPORTS gtk_tool_item_retrieve_proxy_menu_item gtk_tool_item_set_expand gtk_tool_item_set_homogeneous - gtk_tool_item_set_pack_end + gtk_tool_item_set_is_important gtk_tool_item_set_proxy_menu_item gtk_tool_item_set_tooltip gtk_tool_item_set_use_drag_window @@ -1838,6 +2047,7 @@ EXPORTS gtk_toolbar_prepend_space gtk_toolbar_prepend_widget gtk_toolbar_remove_space + gtk_toolbar_set_drop_highlight_item gtk_toolbar_set_icon_size gtk_toolbar_set_orientation gtk_toolbar_set_show_arrow @@ -1845,6 +2055,7 @@ EXPORTS gtk_toolbar_set_tooltips gtk_toolbar_space_style_get_type gtk_toolbar_style_get_type + gtk_toolbar_unhighlight_drop_location gtk_toolbar_unset_icon_size gtk_toolbar_unset_style gtk_tooltips_data_get @@ -2145,6 +2356,23 @@ EXPORTS gtk_type_init gtk_type_new gtk_type_unique + gtk_ui_manager_add_ui + gtk_ui_manager_add_ui_from_file + gtk_ui_manager_add_ui_from_string + gtk_ui_manager_ensure_update + gtk_ui_manager_get_accel_group + gtk_ui_manager_get_action + gtk_ui_manager_get_action_groups + gtk_ui_manager_get_add_tearoffs + gtk_ui_manager_get_type + gtk_ui_manager_get_ui + gtk_ui_manager_get_widget + gtk_ui_manager_insert_action_group + gtk_ui_manager_new + gtk_ui_manager_new_merge_id + gtk_ui_manager_remove_action_group + gtk_ui_manager_remove_ui + gtk_ui_manager_set_add_tearoffs gtk_update_type_get_type gtk_vbox_get_type gtk_vbox_new @@ -2210,6 +2438,7 @@ EXPORTS gtk_widget_get_extension_events gtk_widget_get_modifier_style gtk_widget_get_name + gtk_widget_get_no_show_all gtk_widget_get_pango_context gtk_widget_get_parent gtk_widget_get_parent_window @@ -2275,6 +2504,7 @@ EXPORTS gtk_widget_set_events gtk_widget_set_extension_events gtk_widget_set_name + gtk_widget_set_no_show_all gtk_widget_set_parent gtk_widget_set_parent_window gtk_widget_set_redraw_on_allocate @@ -2322,7 +2552,6 @@ EXPORTS gtk_window_get_mnemonic_modifier gtk_window_get_modal gtk_window_get_position - gtk_window_get_private gtk_window_get_resizable gtk_window_get_role gtk_window_get_screen @@ -2337,6 +2566,8 @@ EXPORTS gtk_window_group_get_type gtk_window_group_new gtk_window_group_remove_window + gtk_window_has_toplevel_focus + gtk_window_is_active gtk_window_iconify gtk_window_list_toplevels gtk_window_maximize @@ -2388,15 +2619,3 @@ EXPORTS gtk_window_unmaximize gtk_window_unstick gtk_wrap_mode_get_type - -; gtk_plug_construct -; gtk_plug_construct_for_display -; gtk_plug_get_id -; gtk_plug_get_type -; gtk_plug_new -; gtk_plug_new_for_display -; gtk_socket_add_id -; gtk_socket_get_id -; gtk_socket_get_type -; gtk_socket_new -; gtk_socket_steal diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 13a7b73a9a..caf445cbd7 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -24,6 +24,9 @@ #ifdef G_OS_UNIX #include "gtkfilesystemunix.h" #endif +#ifdef G_OS_WIN32 +#include "gtkfilesystemwin32.h" +#endif #include "gtktypebuiltins.h" struct _GtkFileChooserWidgetPrivate diff --git a/gtk/gtkfilefilter.c b/gtk/gtkfilefilter.c index cfa332aaf9..d17af98f5e 100644 --- a/gtk/gtkfilefilter.c +++ b/gtk/gtkfilefilter.c @@ -133,7 +133,7 @@ filter_rule_free (FilterRule *rule) static void gtk_file_filter_finalize (GObject *object) { - GtkFileFilter *filter = GTK_FILE_FILTER (filter); + GtkFileFilter *filter = GTK_FILE_FILTER (object); g_slist_foreach (filter->rules, (GFunc)filter_rule_free, NULL); diff --git a/gtk/gtkfilesystemwin32.c b/gtk/gtkfilesystemwin32.c new file mode 100644 index 0000000000..81bb7f0acd --- /dev/null +++ b/gtk/gtkfilesystemwin32.c @@ -0,0 +1,1015 @@ +/* GTK - The GIMP Toolkit + * gtkfilesystemunix.c: Default implementation of GtkFileSystem for UNIX-like systems + * Copyright (C) 2003, Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "gtkfilesystem.h" +#include "gtkfilesystemunix.h" +#include "gtkintl.h" +#include "gtkstock.h" + +#include +#include +#include +#include + +#ifdef G_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#define mkdir(p,m) _mkdir(p) +#else +#error "The implementation is win32 only yet." +#endif /* G_OS_WIN32 */ + +typedef struct _GtkFileSystemUnixClass GtkFileSystemUnixClass; + +#define GTK_FILE_SYSTEM_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_SYSTEM_UNIX, GtkFileSystemUnixClass)) +#define GTK_IS_FILE_SYSTEM_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_SYSTEM_UNIX)) +#define GTK_FILE_SYSTEM_UNIX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_SYSTEM_UNIX, GtkFileSystemUnixClass)) + +struct _GtkFileSystemUnixClass +{ + GObjectClass parent_class; +}; + +struct _GtkFileSystemUnix +{ + GObject parent_instance; +}; + +#define GTK_TYPE_FILE_FOLDER_UNIX (gtk_file_folder_unix_get_type ()) +#define GTK_FILE_FOLDER_UNIX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER_UNIX, GtkFileFolderUnix)) +#define GTK_IS_FILE_FOLDER_UNIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER_UNIX)) +#define GTK_FILE_FOLDER_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_FOLDER_UNIX, GtkFileFolderUnixClass)) +#define GTK_IS_FILE_FOLDER_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_FOLDER_UNIX)) +#define GTK_FILE_FOLDER_UNIX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_FOLDER_UNIX, GtkFileFolderUnixClass)) + +typedef struct _GtkFileFolderUnix GtkFileFolderUnix; +typedef struct _GtkFileFolderUnixClass GtkFileFolderUnixClass; + +struct _GtkFileFolderUnixClass +{ + GObjectClass parent_class; +}; + +struct _GtkFileFolderUnix +{ + GObject parent_instance; + + GtkFileInfoType types; + gchar *filename; +}; + +static GObjectClass *system_parent_class; +static GObjectClass *folder_parent_class; + +static void gtk_file_system_unix_class_init (GtkFileSystemUnixClass *class); +static void gtk_file_system_unix_iface_init (GtkFileSystemIface *iface); +static void gtk_file_system_unix_init (GtkFileSystemUnix *impl); +static void gtk_file_system_unix_finalize (GObject *object); + +static GSList * gtk_file_system_unix_list_roots (GtkFileSystem *file_system); +static GtkFileInfo * gtk_file_system_unix_get_root_info (GtkFileSystem *file_system, + const GtkFilePath *path, + GtkFileInfoType types, + GError **error); +static GtkFileFolder *gtk_file_system_unix_get_folder (GtkFileSystem *file_system, + const GtkFilePath *path, + GtkFileInfoType types, + GError **error); +static gboolean gtk_file_system_unix_create_folder (GtkFileSystem *file_system, + const GtkFilePath *path, + GError **error); +static gboolean gtk_file_system_unix_get_parent (GtkFileSystem *file_system, + const GtkFilePath *path, + GtkFilePath **parent, + GError **error); +static GtkFilePath * gtk_file_system_unix_make_path (GtkFileSystem *file_system, + const GtkFilePath *base_path, + const gchar *display_name, + GError **error); +static gboolean gtk_file_system_unix_parse (GtkFileSystem *file_system, + const GtkFilePath *base_path, + const gchar *str, + GtkFilePath **folder, + gchar **file_part, + GError **error); + +static gchar * gtk_file_system_unix_path_to_uri (GtkFileSystem *file_system, + const GtkFilePath *path); +static gchar * gtk_file_system_unix_path_to_filename (GtkFileSystem *file_system, + const GtkFilePath *path); +static GtkFilePath *gtk_file_system_unix_uri_to_path (GtkFileSystem *file_system, + const gchar *uri); +static GtkFilePath *gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system, + const gchar *filename); + +static gboolean gtk_file_system_unix_add_bookmark (GtkFileSystem *file_system, + const GtkFilePath *path, + GError **error); +static gboolean gtk_file_system_unix_remove_bookmark (GtkFileSystem *file_system, + const GtkFilePath *path, + GError **error); +static GSList * gtk_file_system_unix_list_bookmarks (GtkFileSystem *file_system); + +static GType gtk_file_folder_unix_get_type (void); +static void gtk_file_folder_unix_class_init (GtkFileFolderUnixClass *class); +static void gtk_file_folder_unix_iface_init (GtkFileFolderIface *iface); +static void gtk_file_folder_unix_init (GtkFileFolderUnix *impl); +static void gtk_file_folder_unix_finalize (GObject *object); + +static GtkFileInfo *gtk_file_folder_unix_get_info (GtkFileFolder *folder, + const GtkFilePath *path, + GError **error); +static gboolean gtk_file_folder_unix_list_children (GtkFileFolder *folder, + GSList **children, + GError **error); + +static gchar * filename_from_path (const GtkFilePath *path); +static GtkFilePath *filename_to_path (const gchar *filename); + +static gboolean filename_is_root (const char *filename); +static GtkFileInfo *filename_get_info (const gchar *filename, + GtkFileInfoType types, + GError **error); + +/* + * GtkFileSystemUnix + */ +GType +gtk_file_system_unix_get_type (void) +{ + static GType file_system_unix_type = 0; + + if (!file_system_unix_type) + { + static const GTypeInfo file_system_unix_info = + { + sizeof (GtkFileSystemUnixClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gtk_file_system_unix_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkFileSystemUnix), + 0, /* n_preallocs */ + (GInstanceInitFunc) gtk_file_system_unix_init, + }; + + static const GInterfaceInfo file_system_info = + { + (GInterfaceInitFunc) gtk_file_system_unix_iface_init, /* interface_init */ + NULL, /* interface_finalize */ + NULL /* interface_data */ + }; + + file_system_unix_type = g_type_register_static (G_TYPE_OBJECT, + "GtkFileSystemUnix", + &file_system_unix_info, 0); + g_type_add_interface_static (file_system_unix_type, + GTK_TYPE_FILE_SYSTEM, + &file_system_info); + } + + return file_system_unix_type; +} + +/** + * gtk_file_system_unix_new: + * + * Creates a new #GtkFileSystemUnix object. #GtkFileSystemUnix + * implements the #GtkFileSystem interface with direct access to + * the filesystem using Unix/Linux API calls + * + * Return value: the new #GtkFileSystemUnix object + **/ +GtkFileSystem * +gtk_file_system_unix_new (void) +{ + return g_object_new (GTK_TYPE_FILE_SYSTEM_UNIX, NULL); +} + +static void +gtk_file_system_unix_class_init (GtkFileSystemUnixClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + + system_parent_class = g_type_class_peek_parent (class); + + gobject_class->finalize = gtk_file_system_unix_finalize; +} + +static void +gtk_file_system_unix_iface_init (GtkFileSystemIface *iface) +{ + iface->list_roots = gtk_file_system_unix_list_roots; + iface->get_folder = gtk_file_system_unix_get_folder; + iface->get_root_info = gtk_file_system_unix_get_root_info; + iface->create_folder = gtk_file_system_unix_create_folder; + iface->get_parent = gtk_file_system_unix_get_parent; + iface->make_path = gtk_file_system_unix_make_path; + iface->parse = gtk_file_system_unix_parse; + iface->path_to_uri = gtk_file_system_unix_path_to_uri; + iface->path_to_filename = gtk_file_system_unix_path_to_filename; + iface->uri_to_path = gtk_file_system_unix_uri_to_path; + iface->filename_to_path = gtk_file_system_unix_filename_to_path; + iface->add_bookmark = gtk_file_system_unix_add_bookmark; + iface->remove_bookmark = gtk_file_system_unix_remove_bookmark; + iface->list_bookmarks = gtk_file_system_unix_list_bookmarks; +} + +static void +gtk_file_system_unix_init (GtkFileSystemUnix *system_unix) +{ +} + +static void +gtk_file_system_unix_finalize (GObject *object) +{ + system_parent_class->finalize (object); +} + +static GSList * +gtk_file_system_unix_list_roots (GtkFileSystem *file_system) +{ + gchar drives[26*4]; + guint len; + gchar *p; + GSList *list = NULL; + + len = GetLogicalDriveStrings(sizeof(drives), drives); + + if (len < 3) + g_warning("No drive strings available!"); + + p = drives; + while ((len = strlen(p)) != 0) + { + /* skip floppy */ + if (p[0] != 'a' && p[0] != 'b') + { + //FIXME: gtk_fie_path_compare is case sensitive, we are not + p[0] = toupper (p[0]); + /* needed without the backslash */ + p[2] = '\0'; + list = g_slist_append (list, gtk_file_path_new_dup (p)); + } + p += len + 1; + } + return list; +} + +static GtkFileInfo * +gtk_file_system_unix_get_root_info (GtkFileSystem *file_system, + const GtkFilePath *path, + GtkFileInfoType types, + GError **error) +{ + /* needed _with_ the trailing backslash */ + gchar *filename = g_strconcat(gtk_file_path_get_string (path), "\\", NULL); + GtkFileInfo *info; + DWORD dt = GetDriveType (filename); + + info = filename_get_info (filename, types, error); + + /* additional info */ + if (GTK_FILE_INFO_DISPLAY_NAME & types) + { + gchar display_name[80]; + + if (GetVolumeInformation (filename, + display_name, sizeof(display_name), + NULL, /* serial number */ + NULL, /* max. component length */ + NULL, /* fs flags */ + NULL, 0)) /* fs type like FAT, NTFS */ + { + gchar* real_display_name = g_strconcat (display_name, " (", filename, ")", NULL); + + gtk_file_info_set_display_name (info, real_display_name); + g_free (real_display_name); + } + else + gtk_file_info_set_display_name (info, filename); + } + + if (GTK_FILE_INFO_ICON & types) + { + switch (dt) + { + case DRIVE_REMOVABLE : + //gtk_file_info_set_icon_type (info, GTK_STOCK_FLOPPY); + break; + case DRIVE_CDROM : + //gtk_file_info_set_icon_type (info, GTK_STOCK_CDROM); + break; + case DRIVE_REMOTE : + //FIXME: need a network stock icon + case DRIVE_FIXED : + //FIXME: need a hard disk stock icon + case DRIVE_RAMDISK : + //FIXME: need a ram stock icon + //gtk_file_info_set_icon_type (info, GTK_STOCK_OPEN); + break; + default : + g_assert_not_reached (); + } + } + g_free (filename); + return info; +} + +static GtkFileFolder * +gtk_file_system_unix_get_folder (GtkFileSystem *file_system, + const GtkFilePath *path, + GtkFileInfoType types, + GError **error) +{ + GtkFileFolderUnix *folder_unix; + gchar *filename; + + filename = filename_from_path (path); + g_return_val_if_fail (filename != NULL, NULL); + + folder_unix = g_object_new (GTK_TYPE_FILE_FOLDER_UNIX, NULL); + folder_unix->filename = filename; + folder_unix->types = types; + + return GTK_FILE_FOLDER (folder_unix); +} + +static gboolean +gtk_file_system_unix_create_folder (GtkFileSystem *file_system, + const GtkFilePath *path, + GError **error) +{ + gchar *filename; + gboolean result; + + filename = filename_from_path (path); + g_return_val_if_fail (filename != NULL, FALSE); + + result = mkdir (filename, 0777) != 0; + + if (!result) + { + gchar *filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); + g_set_error (error, + GTK_FILE_SYSTEM_ERROR, + GTK_FILE_SYSTEM_ERROR_NONEXISTENT, + _("error creating directory '%s': %s"), + filename_utf8 ? filename_utf8 : "???", + g_strerror (errno)); + g_free (filename_utf8); + } + + g_free (filename); + + return result; +} + +static gboolean +gtk_file_system_unix_get_parent (GtkFileSystem *file_system, + const GtkFilePath *path, + GtkFilePath **parent, + GError **error) +{ + gchar *filename = filename_from_path (path); + g_return_val_if_fail (filename != NULL, FALSE); + + if (filename_is_root (filename)) + { + *parent = NULL; + } + else + { + gchar *parent_filename = g_path_get_dirname (filename); + *parent = filename_to_path (parent_filename); + g_free (parent_filename); + } + + g_free (filename); + + return TRUE; +} + +static GtkFilePath * +gtk_file_system_unix_make_path (GtkFileSystem *file_system, + const GtkFilePath *base_path, + const gchar *display_name, + GError **error) +{ + gchar *base_filename; + gchar *filename; + gchar *full_filename; + GError *tmp_error = NULL; + GtkFilePath *result; + + base_filename = filename_from_path (base_path); + g_return_val_if_fail (base_filename != NULL, NULL); + + filename = g_filename_from_utf8 (display_name, -1, NULL, NULL, &tmp_error); + if (!filename) + { + g_set_error (error, + GTK_FILE_SYSTEM_ERROR, + GTK_FILE_SYSTEM_ERROR_BAD_FILENAME, + "%s", + tmp_error->message); + + g_error_free (tmp_error); + g_free (base_filename); + + return FALSE; + } + + full_filename = g_build_filename (base_filename, filename, NULL); + result = filename_to_path (full_filename); + g_free (base_filename); + g_free (filename); + g_free (full_filename); + + return result; +} + +/* If this was a publically exported function, it should return + * a dup'ed result, but we make it modify-in-place for efficiency + * here, and because it works for us. + */ +static void +canonicalize_filename (gchar *filename) +{ + gchar *p, *q; + gboolean last_was_slash = FALSE; + + p = filename; + q = filename; + + while (*p) + { + if (*p == G_DIR_SEPARATOR) + { + if (!last_was_slash) + *q++ = G_DIR_SEPARATOR; + + last_was_slash = TRUE; + } + else + { + if (last_was_slash && *p == '.') + { + if (*(p + 1) == G_DIR_SEPARATOR || + *(p + 1) == '\0') + { + if (*(p + 1) == '\0') + break; + + p += 1; + } + else if (*(p + 1) == '.' && + (*(p + 2) == G_DIR_SEPARATOR || + *(p + 2) == '\0')) + { + if (q > filename + 1) + { + q--; + while (q > filename + 1 && + *(q - 1) != G_DIR_SEPARATOR) + q--; + } + + if (*(p + 2) == '\0') + break; + + p += 2; + } + else + { + *q++ = *p; + last_was_slash = FALSE; + } + } + else + { + *q++ = *p; + last_was_slash = FALSE; + } + } + + p++; + } + + if (q > filename + 1 && *(q - 1) == G_DIR_SEPARATOR) + q--; + + *q = '\0'; +} + +static gboolean +gtk_file_system_unix_parse (GtkFileSystem *file_system, + const GtkFilePath *base_path, + const gchar *str, + GtkFilePath **folder, + gchar **file_part, + GError **error) +{ + char *base_filename; + gchar *last_slash; + gboolean result = FALSE; + + base_filename = filename_from_path (base_path); + g_return_val_if_fail (base_filename != NULL, FALSE); + + last_slash = strrchr (str, G_DIR_SEPARATOR); + if (!last_slash) + { + *folder = gtk_file_path_copy (base_path); + *file_part = g_strdup (str); + result = TRUE; + } + else + { + gchar *folder_part; + gchar *folder_path; + GError *tmp_error = NULL; + + if (last_slash == str) + folder_part = g_strdup ("/"); + else + folder_part = g_filename_from_utf8 (str, last_slash - str, + NULL, NULL, &tmp_error); + + if (!folder_part) + { + g_set_error (error, + GTK_FILE_SYSTEM_ERROR, + GTK_FILE_SYSTEM_ERROR_BAD_FILENAME, + "%s", + tmp_error->message); + g_error_free (tmp_error); + } + else + { + if (folder_part[1] == ':') + folder_path = folder_part; + else + { + folder_path = g_build_filename (base_filename, folder_part, NULL); + g_free (folder_part); + } + + canonicalize_filename (folder_path); + + *folder = filename_to_path (folder_path); + *file_part = g_strdup (last_slash + 1); + + g_free (folder_path); + + result = TRUE; + } + } + + g_free (base_filename); + + return result; +} + +static gchar * +gtk_file_system_unix_path_to_uri (GtkFileSystem *file_system, + const GtkFilePath *path) +{ + return g_filename_to_uri (gtk_file_path_get_string (path), NULL, NULL); +} + +static gchar * +gtk_file_system_unix_path_to_filename (GtkFileSystem *file_system, + const GtkFilePath *path) +{ + return g_strdup (gtk_file_path_get_string (path)); +} + +static GtkFilePath * +gtk_file_system_unix_uri_to_path (GtkFileSystem *file_system, + const gchar *uri) +{ + gchar *filename = g_filename_from_uri (uri, NULL, NULL); + if (filename) + return gtk_file_path_new_steal (filename); + else + return NULL; +} + +static GtkFilePath * +gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system, + const gchar *filename) +{ + return gtk_file_path_new_dup (filename); +} + +static gboolean +bookmarks_serialize (GSList **bookmarks, + gchar *uri, + gboolean add, + GError **error) +{ + gchar *filename; + gboolean ok = TRUE; + GSList *list = *bookmarks; + + filename = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL); + + if (filename) + { + gchar *contents = NULL; + gsize len = 0; + GList *entry; + FILE *f; + + if (g_file_test (filename, G_FILE_TEST_EXISTS)) + { + if (g_file_get_contents (filename, &contents, &len, error)) + { + gchar **lines = g_strsplit (contents, "\n", -1); + gint i; + + for (i = 0; lines[i] != NULL; i++) + { + if (lines[i][0] && !g_slist_find_custom (list, lines[i], strcmp)) + list = g_slist_append (list, g_strdup (lines[i])); + } + g_strfreev (lines); + } + else + ok = FALSE; + } + if (ok && (f = fopen (filename, "wb")) != NULL) + { + for (entry = list; entry != NULL; entry = entry->next) + { + gchar *line = entry->data; + + if (strcmp (line, uri) != 0) + { + fputs (line, f); + fputs ("\n", f); + } + } + if (add) + { + fputs (uri, f); + fputs ("\n", f); + } + fclose (f); + } + else if (ok && error) + { + g_set_error (error, + GTK_FILE_SYSTEM_ERROR, + GTK_FILE_SYSTEM_ERROR_FAILED, + _("Bookmark saving failed (%s)"), + g_strerror (errno)); + } + } + *bookmarks = list; + return ok; +} + +static GSList *_bookmarks = NULL; + +static gboolean +gtk_file_system_unix_add_bookmark (GtkFileSystem *file_system, + const GtkFilePath *path, + GError **error) +{ + gchar *uri = gtk_file_system_unix_path_to_uri (file_system, path); + gboolean ret = bookmarks_serialize (&_bookmarks, uri, TRUE, error); + g_free (uri); + return ret; + +} + +static gboolean +gtk_file_system_unix_remove_bookmark (GtkFileSystem *file_system, + const GtkFilePath *path, + GError **error) +{ + gchar *uri = gtk_file_system_unix_path_to_uri (file_system, path); + gboolean ret = bookmarks_serialize (&_bookmarks, uri, FALSE, error); + g_free (uri); + return ret; +} + +static GSList * +gtk_file_system_unix_list_bookmarks (GtkFileSystem *file_system) +{ + GSList *list = NULL; + GSList *entry; + + if (bookmarks_serialize (&_bookmarks, "", FALSE, NULL)) + { + GSList *entry; + + for (entry = _bookmarks; entry != NULL; entry = entry->next) + { + GtkFilePath *path = gtk_file_system_unix_uri_to_path ( + file_system, (gchar *)entry->data); + + list = g_slist_append (list, path); + } + } + + return list; +} + +/* + * GtkFileFolderUnix + */ +static GType +gtk_file_folder_unix_get_type (void) +{ + static GType file_folder_unix_type = 0; + + if (!file_folder_unix_type) + { + static const GTypeInfo file_folder_unix_info = + { + sizeof (GtkFileFolderUnixClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gtk_file_folder_unix_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkFileFolderUnix), + 0, /* n_preallocs */ + (GInstanceInitFunc) gtk_file_folder_unix_init, + }; + + static const GInterfaceInfo file_folder_info = + { + (GInterfaceInitFunc) gtk_file_folder_unix_iface_init, /* interface_init */ + NULL, /* interface_finalize */ + NULL /* interface_data */ + }; + + file_folder_unix_type = g_type_register_static (G_TYPE_OBJECT, + "GtkFileFolderUnix", + &file_folder_unix_info, 0); + g_type_add_interface_static (file_folder_unix_type, + GTK_TYPE_FILE_FOLDER, + &file_folder_info); + } + + return file_folder_unix_type; +} + +static void +gtk_file_folder_unix_class_init (GtkFileFolderUnixClass *class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (class); + + folder_parent_class = g_type_class_peek_parent (class); + + gobject_class->finalize = gtk_file_folder_unix_finalize; +} + +static void +gtk_file_folder_unix_iface_init (GtkFileFolderIface *iface) +{ + iface->get_info = gtk_file_folder_unix_get_info; + iface->list_children = gtk_file_folder_unix_list_children; +} + +static void +gtk_file_folder_unix_init (GtkFileFolderUnix *impl) +{ +} + +static void +gtk_file_folder_unix_finalize (GObject *object) +{ + GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (object); + + g_free (folder_unix->filename); + + folder_parent_class->finalize (object); +} + +static GtkFileInfo * +gtk_file_folder_unix_get_info (GtkFileFolder *folder, + const GtkFilePath *path, + GError **error) +{ + GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (folder); + GtkFileInfo *info; + gchar *dirname; + gchar *filename; + + filename = filename_from_path (path); + g_return_val_if_fail (filename != NULL, NULL); + +#if 0 + dirname = g_path_get_dirname (filename); + g_return_val_if_fail (strcmp (dirname, folder_unix->filename) == 0, NULL); + g_free (dirname); +#endif + + info = filename_get_info (filename, folder_unix->types, error); + + g_free (filename); + + return info; +} + +static gboolean +gtk_file_folder_unix_list_children (GtkFileFolder *folder, + GSList **children, + GError **error) +{ + GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (folder); + GError *tmp_error = NULL; + GDir *dir; + + *children = NULL; + + dir = g_dir_open (folder_unix->filename, 0, &tmp_error); + if (!dir) + { + g_set_error (error, + GTK_FILE_SYSTEM_ERROR, + GTK_FILE_SYSTEM_ERROR_NONEXISTENT, + "%s", + tmp_error->message); + + g_error_free (tmp_error); + + return FALSE; + } + + while (TRUE) + { + const gchar *filename = g_dir_read_name (dir); + gchar *fullname; + + if (!filename) + break; + + fullname = g_build_filename (folder_unix->filename, filename, NULL); + *children = g_slist_prepend (*children, filename_to_path (fullname)); + g_free (fullname); + } + + g_dir_close (dir); + + *children = g_slist_reverse (*children); + + return TRUE; +} + +static GtkFileInfo * +filename_get_info (const gchar *filename, + GtkFileInfoType types, + GError **error) +{ + GtkFileInfo *info; + GtkFileIconType icon_type = GTK_FILE_ICON_REGULAR; + WIN32_FILE_ATTRIBUTE_DATA wfad; + + if (!GetFileAttributesEx (filename, GetFileExInfoStandard, &wfad)) + { + gchar *filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL); + g_set_error (error, + GTK_FILE_SYSTEM_ERROR, + GTK_FILE_SYSTEM_ERROR_NONEXISTENT, + _("error getting information for '%s': %s"), + filename_utf8 ? filename_utf8 : "???", + g_win32_error_message (GetLastError ())); + g_free (filename_utf8); + + return NULL; + } + + info = gtk_file_info_new (); + + if (filename_is_root (filename)) + { + if (types & GTK_FILE_INFO_DISPLAY_NAME) + gtk_file_info_set_display_name (info, filename); + + if (types & GTK_FILE_INFO_IS_HIDDEN) + gtk_file_info_set_is_hidden (info, FALSE); + } + else + { + gchar *basename = g_path_get_basename (filename); + + if (types & GTK_FILE_INFO_DISPLAY_NAME) + { + gchar *display_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL); + if (!display_name) + display_name = g_strescape (basename, NULL); + + gtk_file_info_set_display_name (info, display_name); + + g_free (display_name); + } + + if (types & GTK_FILE_INFO_IS_HIDDEN) + { + /* unix convention ... */ + gboolean is_hidden = basename[0] == '.'; + /* ... _and_ windoze attribute */ + is_hidden = is_hidden || !!(wfad.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN); + gtk_file_info_set_is_hidden (info, is_hidden); + } + + g_free (basename); + } + + if (types & GTK_FILE_INFO_IS_FOLDER) + { + gtk_file_info_set_is_folder (info, !!(wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)); + } + + if (types & GTK_FILE_INFO_ICON) + { + if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + icon_type = GTK_FILE_ICON_DIRECTORY; + + gtk_file_info_set_icon_type (info, icon_type); + } + + if ((types & GTK_FILE_INFO_MIME_TYPE) || + ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR)) + { +#if 0 + const char *mime_type = xdg_mime_get_mime_type_for_file (filename); + gtk_file_info_set_mime_type (info, mime_type); + + if ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR && + (statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) && + (strcmp (mime_type, XDG_MIME_TYPE_UNKNOWN) == 0 || + strcmp (mime_type, "application/x-executable") == 0 || + strcmp (mime_type, "application/x-shellscript") == 0)) + gtk_file_info_set_icon_type (info, GTK_FILE_ICON_EXECUTABLE); +#endif + } + + if (types & GTK_FILE_INFO_MODIFICATION_TIME) + { + GtkFileTime time = wfad.ftLastWriteTime.dwLowDateTime + | ((guint64)wfad.ftLastWriteTime.dwHighDateTime) << 32; + /* 100-nanosecond intervals since January 1, 1601, urgh! */ + time /= 10000000I64; /* now seconds */ + time -= 134774I64 * 24 * 3600; /* good old unix time */ + gtk_file_info_set_modification_time (info, time); + } + + if (types & GTK_FILE_INFO_SIZE) + { + gint64 size = wfad.nFileSizeLow | ((guint64)wfad.nFileSizeHigh) << 32; + gtk_file_info_set_size (info, size); + } + + return info; +} + +static gchar * +filename_from_path (const GtkFilePath *path) +{ + return g_strdup (gtk_file_path_get_string (path)); +} + +static GtkFilePath * +filename_to_path (const char *filename) +{ + return gtk_file_path_new_dup (filename); +} + +static gboolean +filename_is_root (const char *filename) +{ + guint len = strlen(filename); + + /* accept both forms */ + + return ( (len == 2 && filename[1] == ':') + || (len == 3 && filename[1] == ':' && filename[2] == '\\')); +} + diff --git a/gtk/gtkfilesystemwin32.h b/gtk/gtkfilesystemwin32.h new file mode 100644 index 0000000000..2c2e6d5400 --- /dev/null +++ b/gtk/gtkfilesystemwin32.h @@ -0,0 +1,40 @@ +/* GTK - The GIMP Toolkit + * gtkfilesystemunix.h: Default implementation of GtkFileSystem for UNIX-like systems + * Copyright (C) 2003, Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GTK_FILE_SYSTEM_UNIX_H__ +#define __GTK_FILE_SYSTEM_UNIX_H__ + +#include +#include "gtkfilesystem.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_FILE_SYSTEM_UNIX (gtk_file_system_unix_get_type ()) +#define GTK_FILE_SYSTEM_UNIX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM_UNIX, GtkFileSystemUnix)) +#define GTK_IS_FILE_SYSTEM_UNIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM_UNIX)) + +typedef struct _GtkFileSystemUnix GtkFileSystemUnix; + +GtkFileSystem *gtk_file_system_unix_new (void); +GType gtk_file_system_unix_get_type (void); + +G_END_DECLS + +#endif /* __GTK_FILE_SYSTEM_UNIX_H__ */ diff --git a/gtk/makefile.msc.in b/gtk/makefile.msc.in index 6fc0368b9e..41800dea13 100644 --- a/gtk/makefile.msc.in +++ b/gtk/makefile.msc.in @@ -34,7 +34,8 @@ LDFLAGS = $(ATK_LIBS) /link /machine:ix86 $(LINKDEBUG) DEFINES = $(G_DEBUGGING) -DGTK_DISABLE_COMPAT_H -DG_LOG_DOMAIN=\"Gtk\" -Dnear=xxnear \ -DPANGO_ENABLE_BACKEND \ -DGTK_VERSION=\"$(GTK_VER)\" -DGTK_BINARY_VERSION=\"$(GTK_BINARY_VERSION)\" \ - -DGTK_HOST=\"win32\" + -DGTK_HOST=\"win32\" \ + -DGTK_FILE_SYSTEM_ENABLE_UNSUPPORTED TOUCH = copy makefile.msc+nul @@ -58,6 +59,8 @@ gtk_OBJECTS = \ gtkaccellabel.obj \ gtkaccelmap.obj \ gtkaccessible.obj \ + gtkaction.obj \ + gtkactiongroup.obj \ gtkadjustment.obj \ gtkalignment.obj \ gtkarrow.obj \ @@ -74,6 +77,9 @@ gtk_OBJECTS = \ gtkcellrenderertext.obj \ gtkcellrenderertoggle.obj \ gtkcellrendererpixbuf.obj \ + gtkcellrendererseptext.obj \ + gtkcellview.obj \ + gtkcellviewmenuitem.obj \ gtkcheckbutton.obj \ gtkcheckmenuitem.obj \ gtkclipboard.obj \ @@ -82,6 +88,8 @@ gtk_OBJECTS = \ gtkcolorsel.obj \ gtkcolorseldialog.obj \ gtkcombo.obj \ + gtkcombobox.obj \ + gtkcomboboxentry.obj \ gtkcontainer.obj \ gtkctree.obj \ gtkcurve.obj \ @@ -93,7 +101,17 @@ gtk_OBJECTS = \ gtkentrycompletion.obj \ gtkeventbox.obj \ gtkexpander.obj \ + gtkfilechooser.obj \ + gtkfilechooserdefault.obj \ + gtkfilechooserdialog.obj \ + gtkfilechooserentry.obj \ + gtkfilechooserutils.obj \ + gtkfilechooserwidget.obj \ + gtkfilefilter.obj \ gtkfilesel.obj \ + gtkfilesystem.obj \ + gtkfilesystemmodel.obj \ + gtkfilesystemwin32.obj \ gtkfixed.obj \ gtkfontsel.obj \ gtkfontbutton.obj \ @@ -147,6 +165,7 @@ gtk_OBJECTS = \ gtkpreview.obj \ gtkprogress.obj \ gtkprogressbar.obj \ + gtkradioaction.obj \ gtkradiobutton.obj \ gtkradiotoolbutton.obj \ gtkradiomenuitem.obj \ @@ -187,6 +206,7 @@ gtk_OBJECTS = \ gtktextview.obj \ gtkthemes.obj \ gtktipsquery.obj \ + gtktoggleaction.obj \ gtktogglebutton.obj \ gtktoggletoolbutton.obj \ gtktoolbar.obj \ @@ -207,6 +227,7 @@ gtk_OBJECTS = \ gtktreeviewcolumn.obj \ gtktypeutils.obj \ gtktypebuiltins.obj \ + gtkuimanager.obj \ gtkvbbox.obj \ gtkvbox.obj \ gtkviewport.obj \ @@ -264,6 +285,10 @@ gtk_public_h_sources = \ gtkenums.h \ gtkeventbox.h \ gtkexpander.h \ + gtkfilechooser.h \ + gtkfilechooserdialog.h \ + gtkfilechooserwidget.h \ + gtkfilefilter.h \ gtkfilesel.h \ gtkfixed.h \ gtkfontbutton.h \ @@ -450,11 +475,14 @@ gtkmarshal.c : gtkmarshal.list gtksignal.obj : gtksignal.c gtkmarshal.c gtkmarshal.h $(CC) $(CFLAGS) -GD -c -DGTK_COMPILATION -DG_LOG_DOMAIN=\"Gtk\" gtksignal.c +gtk.res : gtk.rc + rc -DBUILDNUMBER=0 -r -fo gtk.res gtk.rc + # # Linking: # -libgtk-win32-$(GTK_VER)-0.dll : $(gtk_OBJECTS) gtk.def - $(CC) $(CFLAGS) -LD -Fm -Fe$@ $(gtk_OBJECTS) \ +libgtk-win32-$(GTK_VER)-0.dll : $(gtk_OBJECTS) gtk.def gtk.res + $(CC) $(CFLAGS) -LD -Fm -Fe$@ $(gtk_OBJECTS) gtk.res \ $(GDK_LIBS) $(GDK_PIXBUF_LIBS) $(PANGO_LIBS) $(INTL_LIBS) $(GLIB_LIBS) \ gdi32.lib user32.lib advapi32.lib wsock32.lib \ $(LDFLAGS) /implib:gtk-win32-$(GTK_VER).lib /def:gtk.def diff --git a/tests/makefile.msc b/tests/makefile.msc index cb7f999626..02b599a096 100644 --- a/tests/makefile.msc +++ b/tests/makefile.msc @@ -38,11 +38,22 @@ all : \ # # Test programs: # -TESTAPPS = testcalendar testdnd testgtk testinput testrgb testselection \ - testtext testtextbuffer testsocket testsocket_child \ - testtreeedit testtreeflow \ - testtreecolumns testtreefocus testtreesort testtreeview treestoretest \ - testthreads simple +TESTAPPS = \ + testabi testactions \ + testcalendar testcombo \ + testdnd \ + testfilechooser \ + testgtk \ + testicontheme testinput \ + testmenus testmerge testmultidisplay testmultiscreen \ + testrgb \ + testselection \ + testtext testtextbuffer testtoolbar \ + testtreecolumns testtreeedit testtreeflow testtreefocus \ + testtreesort testtreeview treestoretest \ + testsocket testsocket_child \ + testthreads \ + simple all-test-apps: @@ -65,8 +76,17 @@ EXTRA_OBJETCS = prop-editor.obj EXTRA_OBJETCS = prop-editor.obj !ENDIF +!IFDEF EXTRA_testtoolbar +EXTRA_OBJETCS = prop-editor.obj +!ENDIF + +!IFDEF EXTRA_testfilechooser +EXTRA_OBJETCS = prop-editor.obj +EXTRA_LIBS = gdi32.lib user32.lib shell32.lib +!ENDIF + $(TESTAPP).exe : ../gtk/gtk-win32-$(GTK_VER).lib $(TESTAPP).obj - $(CC) $(CFLAGS) $(TESTAPP).obj $(EXTRA_OBJETCS) $(GTK_LIBS) $(GDK_LIBS) $(GDK_PIXBUF_LIBS) $(PANGO_LIBS) $(GLIB_LIBS) $(LDFLAGS) + $(CC) $(CFLAGS) $(TESTAPP).obj $(EXTRA_OBJETCS) $(GTK_LIBS) $(GDK_LIBS) $(GDK_PIXBUF_LIBS) $(PANGO_LIBS) $(GLIB_LIBS) $(EXTRA_LIBS) $(LDFLAGS) $(TESTAPP).obj : $(TESTAPP).c $(CC) $(CFLAGS) -c -DG_LOG_DOMAIN=\"$(TESTAPP)\" $(TESTAPP).c diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c index d813549536..66aff6d8a2 100644 --- a/tests/testfilechooser.c +++ b/tests/testfilechooser.c @@ -1,11 +1,26 @@ +#include "config.h" + #include #include #include #include #include +#ifdef HAVE_UNISTD_H #include - +#endif #include + +#ifdef G_OS_WIN32 +# define WIN32_MEAN_AND_LEAN +# include /* ExtractAssociatedIcon */ +# include +# define localtime_r(t,b) localtime(t) +# ifndef S_ISREG +# define S_ISREG(m) ((m) & _S_IFREG) +# endif +# include /* gdk_win32_hdc_get */ +#endif + #include "prop-editor.h" static GtkWidget *preview_label; diff --git a/tests/testmerge.c b/tests/testmerge.c index 53c676a6bb..ff78028e46 100644 --- a/tests/testmerge.c +++ b/tests/testmerge.c @@ -1,8 +1,16 @@ +#include "config.h" + #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + struct { const gchar *filename; guint merge_id; } merge_ids[] = { { "merge-1.ui", 0 }, { "merge-2.ui", 0 },