Compare commits
49 Commits
2.24.22
...
kris-async
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65bdb7ca9a | ||
|
|
c0d7735260 | ||
|
|
163fa10926 | ||
|
|
6694dbddb9 | ||
|
|
24762914ca | ||
|
|
7cea08bbb6 | ||
|
|
31d0084f7e | ||
|
|
e0792b0e3a | ||
|
|
32d750ea51 | ||
|
|
0c9e045b23 | ||
|
|
064abaf966 | ||
|
|
31d15343ae | ||
|
|
9c9ab7d977 | ||
|
|
614bbed704 | ||
|
|
914b750cbf | ||
|
|
2b419300fd | ||
|
|
5a72f83bc8 | ||
|
|
77a5e4877d | ||
|
|
8e337ee801 | ||
|
|
541805189c | ||
|
|
33cd7bec0e | ||
|
|
0ad7ea990a | ||
|
|
86092bb99a | ||
|
|
a5a40428d6 | ||
|
|
80253eef39 | ||
|
|
67bcafbaa6 | ||
|
|
5671cd6e72 | ||
|
|
6d05ff46d0 | ||
|
|
504e508a94 | ||
|
|
6d95ee973d | ||
|
|
640183f70c | ||
|
|
13e0ec79b5 | ||
|
|
75984fc181 | ||
|
|
f0b4533cdc | ||
|
|
44c163f421 | ||
|
|
dcec12da93 | ||
|
|
c14393c33c | ||
|
|
909146bd83 | ||
|
|
881e00c1d9 | ||
|
|
f471b51452 | ||
|
|
e71098346e | ||
|
|
dd8ceb472f | ||
|
|
185de00018 | ||
|
|
f983226842 | ||
|
|
08db22f008 | ||
|
|
a86b453f7a | ||
|
|
aaac16bf9d | ||
|
|
8b7d8e13c0 | ||
|
|
0291a22d10 |
559
ChangeLog
559
ChangeLog
@@ -1,5 +1,564 @@
|
||||
2006-04-30 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.[ch] (gtk_file_info_render_icon): remove the
|
||||
caching code,
|
||||
(gtk_file_info_get_icon_name): new function,
|
||||
(gtk_file_system_volume_get_icon_name): new function,
|
||||
(gtk_file_system_volume_render_icon): refactor to use
|
||||
get_icon_name() and render the icon on the fly.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_render_icon),
|
||||
(gtk_file_system_unix_volume_get_icon_name): reflect updates in
|
||||
file system interface,
|
||||
(get_fallback_icon): remove, along with icon caching code.
|
||||
|
||||
* gtk/gtk.symbols: updated.
|
||||
|
||||
2006-04-30 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (got_root_folder_cb), (ref_path_cb),
|
||||
(get_children_get_folder_cb): don't leak the handle,
|
||||
(got_root_folder_cb), (get_children_get_folder_cb): emit
|
||||
row-inserted for the newly added nodes.
|
||||
|
||||
2006-04-30 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (file_list_drag_data_select_uris),
|
||||
(file_list_drag_data_received_get_info_cb),
|
||||
(file_list_drag_data_received_cb): refactor code for selecting
|
||||
multiple uris into file_list_drag_data_select_uris().
|
||||
|
||||
2006-04-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (dnd_select_folder_get_info_cb): don't
|
||||
leak handle,
|
||||
(change_icon_theme_get_info_cb), (set_info_get_info_cb),
|
||||
(model_add_special_get_info_cb), (update_label_get_info_cb): ditto.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_reload_icons_get_info_cb):
|
||||
don't leak the handle,
|
||||
(get_file_info_finished), (edited_idle_create_folder_cb),
|
||||
(file_list_drag_data_received_get_info_cb),
|
||||
(show_and_select_paths_get_folder_cb),
|
||||
(update_current_folder_get_info_cb), (add_shortcut_get_info_cb),
|
||||
(confirmation_confirm_get_info_cb), (action_create_folder_cb),
|
||||
(save_entry_get_info_cb), (shortcuts_activate_volume_mount_cb),
|
||||
(shortcuts_activate_get_info_cb), (update_from_entry_get_info_cb):
|
||||
ditto.
|
||||
|
||||
* gtk/gtkfilechooserentry.c (load_directory_get_folder_callback):
|
||||
don't leak the handle.
|
||||
|
||||
* gtk/gtkpathbar.c (set_button_image_get_info_cb),
|
||||
(gtk_path_bar_get_info_callback): don't leak the handle.
|
||||
|
||||
2006-04-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Review.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_reload_icons_get_info_cb):
|
||||
don't forget to unref data->impl at the end.
|
||||
|
||||
2006-04-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Review, continued.
|
||||
|
||||
* gtk/gtkfilechooserdialog.c (response_cb): set response_requested
|
||||
to FALSE after stopping emission of the response signal.
|
||||
|
||||
2006-03-16 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
More review work.
|
||||
|
||||
* gtk/gtkfilechooserprivate.h: remove idle_finished_loading_source
|
||||
from GtkFileSystemModel.
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (gtk_file_system_model_finalize): remove
|
||||
idle_finished_loading_source,
|
||||
(idle_finished_loading_cb), (queue_finished_loading): removed,
|
||||
(got_root_folder_cb): save a list walk, immediately emit
|
||||
finished-loading and don't queue it, since we are already in an
|
||||
idle here, always list_children() so the children the folder already
|
||||
has are returned,
|
||||
(_gtk_file_system_model_new): handle the case where NULL is
|
||||
returned by _get_folder(),
|
||||
(_gtk_file_system_model_path_do): remove comment, and append the
|
||||
new handle to the list, don't try to remove,
|
||||
(get_children_get_folder_cb): save a list walk, remove the dummy
|
||||
child if the _get_folder() call fails or is cancelled.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
More suggestions from Federico.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_create_folder):
|
||||
remove check for filename_is_root(), since we never hit that code
|
||||
and else mkdir will fail anyway,
|
||||
(gtk_file_system_unix_create_folder): fixup parent folder refresh
|
||||
code.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (read_hidden_file), (fill_in_hidden),
|
||||
(get_is_hidden_for_file): factor out g_file_get_contents() code
|
||||
in read_hidden_file(). (Federico Mena Quintero).
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Icon name code suggestions by Federico Mena Quintero.
|
||||
|
||||
* gtk/gtkfilesystemunix.c: add GTK_FILE_INFO_ICON to
|
||||
STAT_NEEDED_MASK,
|
||||
(get_fallback_icon_name), (get_fallback_icon),
|
||||
(get_icon_name_for_directory), (get_special_icon_name): get rid
|
||||
of strdups,
|
||||
(get_icon_type_from_path): add a statbuf argument and use the
|
||||
statbuf when folder_unix is NULL,
|
||||
(create_file_info): adapt to work with above changes.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_info): path
|
||||
is NULL is an error here (gtk_file_system_get_info() already guards
|
||||
path = NULL),
|
||||
(gtk_file_system_unix_get_info): move basename creation to just
|
||||
before create_file_info(). (Federico Mena Quintero).
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (struct _GtkFileFolderUnix): add
|
||||
load_folder_id field,
|
||||
(load_folder): add thread enter/leave construct, set load_folder_id
|
||||
to zero since we have the idle removed when we return,
|
||||
(gtk_file_system_unix_get_folder): initialize load_folder_id to 0
|
||||
and store the source id of the load_folder idle,
|
||||
(gtk_file_folder_unix_finalize): remove the load_folder idle
|
||||
if necessary. (Federico Mena Quintero).
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooser.c (gtk_file_chooser_get_current_folder): return
|
||||
NULL if there is no current folder path.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_map): we
|
||||
reload the current folder if there is one, else we continue the
|
||||
still pending load.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Merge from HEAD to get rid of some warnings (simplifies debugging).
|
||||
|
||||
Thu Feb 23 13:28:21 2006 Tim Janik <timj@imendio.com>
|
||||
|
||||
* gdk/x11/gdkim-x11.c (_gdk_x11_initialize_locale): remove unconditional
|
||||
warnings about missing X locale support. Gdk properly handles this
|
||||
situation anyway.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Couple of fixes from Markku Vire.
|
||||
|
||||
* gtk/gtkfilesystem.c (gtk_file_info_copy): also strdup icon_name
|
||||
and display_key.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_create_folder):
|
||||
initialize error to NULL,
|
||||
(gtk_file_folder_unix_list_children): return an empty list for now if
|
||||
we couldn't read the directory.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb),
|
||||
(gtk_file_chooser_default_update_current_folder): set and unset
|
||||
busy cursor while checking whether the given path is a folder.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.h: change the GtkFileInfo argument of the
|
||||
GetInfoCallback to be const.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c, gtk/gtkfilechooserdefault.c,
|
||||
gtk/gtkpathbar.c: changes functions to reflect the above change.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c, gtk/gtkfilechooserprivate.h: keep track
|
||||
of handles, cancel all pending operations on dispose.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserprivate.h (struct _GtkFileSystemModel): add
|
||||
pending_handles field,
|
||||
(struct _FileModelNode): add load_pending flag.
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (gtk_file_system_model_dispose): introduce,
|
||||
cancel all pending operations here,
|
||||
(got_root_folder_cb), (_gtk_file_system_model_new), (ref_path_cb),
|
||||
(_gtk_file_system_model_path_do): keep track of all pending
|
||||
operations, handle cancelled operations.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_finalize),
|
||||
(gtk_file_chooser_button_destroy): move all handle cancellations
|
||||
and object unrefs to destroy.
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_finalize), (gtk_path_bar_dispose):
|
||||
likewise.
|
||||
|
||||
* gtk/gtkfilechooserentry.c (gtk_file_chooser_entry_class_init):
|
||||
add dispose,
|
||||
(gtk_file_chooser_entry_dispose): cancel handles and unrefs
|
||||
objects here instead of finalize.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.c (get_cached_icon): check if "name" is an
|
||||
absolute path, if so load the icon from that file.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): fix
|
||||
the build.
|
||||
|
||||
2005-12-21 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): remove
|
||||
the FIXME since it doesn't make sense, when we return a cached
|
||||
folder we won't emit finished-loading either,
|
||||
(gtk_file_system_unix_create_folder): remove unused variable,
|
||||
(gtk_file_folder_unix_list_children): remove unused code,
|
||||
(get_is_hidden_for_file): new function,
|
||||
(create_file_info): also handle getting is_hidden when called
|
||||
without a folder unix (from _system_get_info() for example).
|
||||
|
||||
2005-12-20 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (check_is_folder): fully removed!
|
||||
woo!,
|
||||
(check_save_entry): add is_folder argument,
|
||||
(gtk_file_chooser_default_get_paths): update check_save_entry() call,
|
||||
(get_display_name_for_folder): removed,
|
||||
(confirmation_confirm_get_info_cb): new function which will
|
||||
handle the confirmation dialog now we have all information for it,
|
||||
(should_respond_after_confirm_overwrite): replace the call to
|
||||
get_display_name_for_folder() with an asynchronous solution,
|
||||
(action_create_folder_cb): request dialog response on successfull
|
||||
folder creation,
|
||||
(gtk_file_chooser_default_should_respond): update call to
|
||||
check_save_entry(); replace the check is folder call for "path"
|
||||
by just using the is_folder return value from check_save_entry();
|
||||
replaced the check is folder call for "parent_path" with an
|
||||
asynchronous setup, remainder of that work is now done in
|
||||
save_entry_get_info_cb(),
|
||||
(save_entry_get_info_cb): new function.
|
||||
|
||||
* gtk/gtkfilechoosermebed.[ch]: add response-requested signal.
|
||||
|
||||
* gtk/gtkfilechooserdialog.c, gtk/gtkfilechooserprivate.h: handle
|
||||
response_requested signal.
|
||||
|
||||
* gtk/gtkfilechooserentry.[ch]
|
||||
(_gtk_file_chooser_entry_get_is_folder): new function.
|
||||
|
||||
2005-12-20 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (ref_path_cb): when called with
|
||||
!folder, check if node is the node we are looking for (can be
|
||||
triggered when we call ref_path_cb ourselves after a find_child_node),
|
||||
(_gtk_file_system_model_path_do): introduce parent_node field;
|
||||
after finding a child node in a loaded parent node, don't forget
|
||||
to call ref_path_cb,
|
||||
(get_children_get_folder_cb): don't forget to set data->node->folder
|
||||
to the newly acquired folder.
|
||||
|
||||
2005-12-20 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (show_and_select_paths_get_folder_cb):
|
||||
handle case where the folder we get already finished loading.
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (ref_path_cb),
|
||||
(_gtk_file_system_model_path_do): make this work.
|
||||
|
||||
2005-12-19 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_update_count): modify
|
||||
in such a way that it can also negatively update the count on
|
||||
failures,
|
||||
(get_file_info_finished): handle failures, update save folder
|
||||
combo box on success,
|
||||
(shortcuts_insert_path): change the boolean return value into a
|
||||
void one, also refilter the model and update the save folder combo
|
||||
box for the non-asynchronous case,
|
||||
(shortcuts_append_home), (shortcuts_append_desktop),
|
||||
(shortcuts_add_volumes), (shortcuts_add_current_folder),
|
||||
(add_shortcuts_get_info_cb): adapt to shortcuts_insert_path() updates.
|
||||
|
||||
2005-12-19 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkpathbar.[ch]: add handle fields to ButtonData and
|
||||
GtkPathBar; do correct handle bookkeeping.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (load_folder),
|
||||
(gtk_file_system_unix_get_folder),
|
||||
(gtk_file_folder_unix_is_finished_loading): add is_finished_loading
|
||||
field to GtkFileFolderUnix, which is set to true once we are
|
||||
really finished with loading (previous assumption that we are
|
||||
always finshed loading is not true anymore).
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (got_root_folder_cb): if the folder is
|
||||
finished loading, list the children and update the root level.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb):
|
||||
handle cancellation.
|
||||
|
||||
2005-12-19 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtktreeview.c: small fix to make it actually work in this
|
||||
branch.
|
||||
|
||||
* gdk/gdkevents.c: same.
|
||||
|
||||
2005-12-16 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c: always call the callback, even when
|
||||
cancelled; ref handles passed to the callback queue functions;
|
||||
don't set cancelled to TRUE in _cancel_operation(), since operations
|
||||
in this backend are always completed,
|
||||
(get_special_icon_name): don't strdup the value of
|
||||
get_icon_name_for_directory() again.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: adapt to new cancellation policy;
|
||||
reference all objects which are passed as callback arguments; in the
|
||||
callback check if the handles match.
|
||||
|
||||
* gtk/gtkfilechooserentry.c: likewise.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: likewise. Also changed the shortcut
|
||||
loading code to be more like the code in GtkFileChooserButton, where
|
||||
we store all handles in the model and have model_row_free_data
|
||||
cancel any pending operations,
|
||||
(shortcuts_model_create): copy the error.
|
||||
|
||||
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault): remove
|
||||
loading_volumes and loading_bookmarks fields.
|
||||
|
||||
* gtk/gtkfilesystem.c (gtk_file_info_free): free icon_name here...
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (edited_idle_create_folder_cb): fix
|
||||
thinko.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (dispatch_create_folder_callback),
|
||||
(queue_create_folder_callback): need to copy/free the path,
|
||||
(gtk_file_system_unix_create_folder): put the "reget folder" hack
|
||||
back in, though it's working different now.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_finalize),
|
||||
(dnd_select_folder_get_info_cb), (gtk_file_chooser_drag_data_received),
|
||||
(change_icon_theme_get_info_cb), (change_icon_theme),
|
||||
(model_add_special_get_info_cb), (model_add_special),
|
||||
(update_label_get_info_cb), (update_label_and_image): cancel existing
|
||||
operations, if any; added apprioriate fields to
|
||||
GtkFileChooserButtonPrivate.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserentry.c (gtk_file_chooser_entry_finalize): if
|
||||
there's a folder loading, cancel the operation,
|
||||
(load_directory_get_folder_callback): set the loading folder handle
|
||||
to NULL,
|
||||
(load_directory_callback): cancel any currently loading folders
|
||||
before starting a new get folder operation.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): don't overwrite
|
||||
data if it's already set (for example by the "is volume" case).
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (set_info_get_info_cb),
|
||||
(set_info_for_path_at_iter): store a row reference in the temporary
|
||||
data structure and not an iter,
|
||||
(model_add_special), (model_update_current_folder),
|
||||
(gtk_file_chooser_button_add_shorcut_folder): remove unused pixbuf
|
||||
variable.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (get_file_info_finished),
|
||||
(shortcuts_insert_path): replace gtk_file_system_render_icon() call
|
||||
with gtk_file_system_get_file_info(),
|
||||
(gtk_file_chooser_default_add_shortcut_folder),
|
||||
(gtk_file_chooser_default_remove_shortcut_folder): handle shortcuts
|
||||
which are still loading.
|
||||
|
||||
* gtk/gtkfilechooserprivate.h: add shortcuts_loading field to
|
||||
struct _GtkFileChooserDefault.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (set_info_get_info_cb),
|
||||
(set_info_for_path_at_iter), (model_free_row_data): keep handle
|
||||
and path together; now supports adding/removing shortcuts
|
||||
which are still loading.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.c: make the cancelled field an GObject property.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.h: make the GError argument in the callbacks
|
||||
const.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: update callbacks,
|
||||
* gtk/gtkfilechooserentry.c: likewise,
|
||||
* gtk/gtkfilechooserdefault.c: likewise,
|
||||
* gtk/gtkfilesystemmodel.c: likewise,
|
||||
* gtk/gtkpathbar.c: likewise.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (edited_idle_create_folder_cb): copy
|
||||
the error which will be passed to error_creating_folder_dialog(),
|
||||
(action_create_folder_cb): likewise,
|
||||
(file_list_drag_data_received_get_info_cb): add forgotten GError
|
||||
declaration.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkpathbar.c (get_button_image), (set_button_image),
|
||||
(set_button_image_get_info_cb),
|
||||
(gtk_path_bar_update_button_appearance): update to new icon
|
||||
rendering call.
|
||||
|
||||
2005-12-09 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (file_list_drag_data_received),
|
||||
(gtk_file_chooser_default_add_shortcut_folder),
|
||||
(shortcuts_activate_get_info_cb): replace synchronous check_is_folder
|
||||
calls with an async gtk_file_system_get_info() solution.
|
||||
|
||||
2005-12-09 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.c (icon_cache_element_free), (icon_theme_changed),
|
||||
(get_cached_icon), (gtk_file_info_render_icon): implement pixbuf
|
||||
caching as found in the file system backends.
|
||||
|
||||
2005-12-09 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtk.symbols: updated.
|
||||
|
||||
* gtk/gtkfilesystem.[ch] (struct GtkFileInfo): added icon_name field,
|
||||
(enum GtkFileInfoType): added GTK_FILE_INFO_ICON,
|
||||
(gtk_file_info_set_icon_name): new function,
|
||||
(gtk_file_info_render_icon): new function,
|
||||
(gtk_file_system_render_icon): removed.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon): removed,
|
||||
(create_file_info): fill icon_name field if required,
|
||||
(get_*_icon): modified to suit create_file_info() better.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: modified to use
|
||||
gtk_file_info_render_icon() instead of gtk_file_system_render_icon().
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: likewise.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (get_file_info_finished),
|
||||
(update_current_folder_get_info_cb): fix mem leaks.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_info): ditto.
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_set_path_finish): ditto.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (dnd_select_folder_get_info_cb),
|
||||
(gtk_file_chooser_button_drag_data_received): make asynchronous,
|
||||
(update_label_and_image): remove unused variable.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c
|
||||
(gtk_file_chooser_default_update_current_folder): split in two
|
||||
functions, so we can have the is_folder check back.
|
||||
* gtk/gtkfilechooserprivate.h: add update_current_folder_handle
|
||||
field.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (show_and_select_paths): fixed a typo.
|
||||
|
||||
2005-12-05 Federico Mena Quintero <federico@ximian.com>
|
||||
|
||||
(merge from HEAD)
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (trap_activate_cb): "event->state &
|
||||
modifiers", not "event->state && modifiers". Patch by Sadrul
|
||||
Habib Chowdhury <imadil@gmail.com>. Fixes bug #323073.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Beginnings of an asynchronous file chooser.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: display name and the is folder property
|
||||
are now asynchronously set using set_info_for_at_path_iter(), the
|
||||
is folder property is now also stored in the tree model.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: lots of changes to the shortcuts
|
||||
model code to make it operate asynchronously, check_is_folder() has
|
||||
been "disabled" for now, all other synchronous calls were
|
||||
replaced with asychronous ones.
|
||||
|
||||
* gtk/gtkfilechooserentry.c: update call to
|
||||
gtk_file_system_get_folder().
|
||||
|
||||
* gtk/gtkfilechooserprivate.h: added two fields.
|
||||
|
||||
* gtk/gtkfilesystem.[ch]: for about 85% changed to the changes
|
||||
outlined in the proposal discussed on gtk-devel-list.
|
||||
|
||||
* gtk/gtkfilesystemmodel.[ch]: updated all asynchronous calls,
|
||||
_gtk_file_system_model_path_do() basically had to be rewritten
|
||||
(and I still need to finish that).
|
||||
|
||||
* gtk/gtkfilesystemunix.c: changed to be compatible with the new
|
||||
GtkFileSystem interface.
|
||||
|
||||
* gtk/gtkpathbar.c (button_clicked_cb): block/unblock the
|
||||
button_clicked_cb callback around the call to
|
||||
gtk_toggle_button_set_active(), avoids button_clicked_cb getting
|
||||
called twice.
|
||||
(_gtk_path_bar_set_path): refactored to be asynchronous.
|
||||
|
||||
Tue Dec 6 10:32:17 2005 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkstatusbar.c: ported memchunk uses to g_slice, so the code
|
||||
compiles again.
|
||||
|
||||
2005-12-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c:
|
||||
* gtk/gtkuimanager.c:
|
||||
* gtk/gtktreedatalist.c:
|
||||
* gtk/gtktext.c:
|
||||
* gtk/gtkmain.c:
|
||||
* gtk/gtkitemfactory.c:
|
||||
* gtk/gtkseparator.[hc]:
|
||||
* gtk/gtkclist.[hc]:
|
||||
* gtk/gtkctree.c:
|
||||
* gtk/gtkgc.c: Use g_slice instead of mem chunks.
|
||||
|
||||
2005-12-05 Michael Natterer <mitch@imendio.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c: map the new GtkSettings properties
|
||||
"timeout-initial", "timeout-repeat", "color-scheme" and
|
||||
"enable-enimations" to X settings.
|
||||
|
||||
2005-12-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gdk/gdkevents.c:
|
||||
* gdk/gdkcolor.c: Use g_slice instead of mem chunks.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_key_press): Free new_event
|
||||
after sending it to the search entry. (#323209, Crispin Flowerday)
|
||||
|
||||
|
||||
@@ -1,5 +1,564 @@
|
||||
2006-04-30 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.[ch] (gtk_file_info_render_icon): remove the
|
||||
caching code,
|
||||
(gtk_file_info_get_icon_name): new function,
|
||||
(gtk_file_system_volume_get_icon_name): new function,
|
||||
(gtk_file_system_volume_render_icon): refactor to use
|
||||
get_icon_name() and render the icon on the fly.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_render_icon),
|
||||
(gtk_file_system_unix_volume_get_icon_name): reflect updates in
|
||||
file system interface,
|
||||
(get_fallback_icon): remove, along with icon caching code.
|
||||
|
||||
* gtk/gtk.symbols: updated.
|
||||
|
||||
2006-04-30 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (got_root_folder_cb), (ref_path_cb),
|
||||
(get_children_get_folder_cb): don't leak the handle,
|
||||
(got_root_folder_cb), (get_children_get_folder_cb): emit
|
||||
row-inserted for the newly added nodes.
|
||||
|
||||
2006-04-30 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (file_list_drag_data_select_uris),
|
||||
(file_list_drag_data_received_get_info_cb),
|
||||
(file_list_drag_data_received_cb): refactor code for selecting
|
||||
multiple uris into file_list_drag_data_select_uris().
|
||||
|
||||
2006-04-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (dnd_select_folder_get_info_cb): don't
|
||||
leak handle,
|
||||
(change_icon_theme_get_info_cb), (set_info_get_info_cb),
|
||||
(model_add_special_get_info_cb), (update_label_get_info_cb): ditto.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_reload_icons_get_info_cb):
|
||||
don't leak the handle,
|
||||
(get_file_info_finished), (edited_idle_create_folder_cb),
|
||||
(file_list_drag_data_received_get_info_cb),
|
||||
(show_and_select_paths_get_folder_cb),
|
||||
(update_current_folder_get_info_cb), (add_shortcut_get_info_cb),
|
||||
(confirmation_confirm_get_info_cb), (action_create_folder_cb),
|
||||
(save_entry_get_info_cb), (shortcuts_activate_volume_mount_cb),
|
||||
(shortcuts_activate_get_info_cb), (update_from_entry_get_info_cb):
|
||||
ditto.
|
||||
|
||||
* gtk/gtkfilechooserentry.c (load_directory_get_folder_callback):
|
||||
don't leak the handle.
|
||||
|
||||
* gtk/gtkpathbar.c (set_button_image_get_info_cb),
|
||||
(gtk_path_bar_get_info_callback): don't leak the handle.
|
||||
|
||||
2006-04-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Review.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_reload_icons_get_info_cb):
|
||||
don't forget to unref data->impl at the end.
|
||||
|
||||
2006-04-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Review, continued.
|
||||
|
||||
* gtk/gtkfilechooserdialog.c (response_cb): set response_requested
|
||||
to FALSE after stopping emission of the response signal.
|
||||
|
||||
2006-03-16 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
More review work.
|
||||
|
||||
* gtk/gtkfilechooserprivate.h: remove idle_finished_loading_source
|
||||
from GtkFileSystemModel.
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (gtk_file_system_model_finalize): remove
|
||||
idle_finished_loading_source,
|
||||
(idle_finished_loading_cb), (queue_finished_loading): removed,
|
||||
(got_root_folder_cb): save a list walk, immediately emit
|
||||
finished-loading and don't queue it, since we are already in an
|
||||
idle here, always list_children() so the children the folder already
|
||||
has are returned,
|
||||
(_gtk_file_system_model_new): handle the case where NULL is
|
||||
returned by _get_folder(),
|
||||
(_gtk_file_system_model_path_do): remove comment, and append the
|
||||
new handle to the list, don't try to remove,
|
||||
(get_children_get_folder_cb): save a list walk, remove the dummy
|
||||
child if the _get_folder() call fails or is cancelled.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
More suggestions from Federico.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_create_folder):
|
||||
remove check for filename_is_root(), since we never hit that code
|
||||
and else mkdir will fail anyway,
|
||||
(gtk_file_system_unix_create_folder): fixup parent folder refresh
|
||||
code.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (read_hidden_file), (fill_in_hidden),
|
||||
(get_is_hidden_for_file): factor out g_file_get_contents() code
|
||||
in read_hidden_file(). (Federico Mena Quintero).
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Icon name code suggestions by Federico Mena Quintero.
|
||||
|
||||
* gtk/gtkfilesystemunix.c: add GTK_FILE_INFO_ICON to
|
||||
STAT_NEEDED_MASK,
|
||||
(get_fallback_icon_name), (get_fallback_icon),
|
||||
(get_icon_name_for_directory), (get_special_icon_name): get rid
|
||||
of strdups,
|
||||
(get_icon_type_from_path): add a statbuf argument and use the
|
||||
statbuf when folder_unix is NULL,
|
||||
(create_file_info): adapt to work with above changes.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_info): path
|
||||
is NULL is an error here (gtk_file_system_get_info() already guards
|
||||
path = NULL),
|
||||
(gtk_file_system_unix_get_info): move basename creation to just
|
||||
before create_file_info(). (Federico Mena Quintero).
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (struct _GtkFileFolderUnix): add
|
||||
load_folder_id field,
|
||||
(load_folder): add thread enter/leave construct, set load_folder_id
|
||||
to zero since we have the idle removed when we return,
|
||||
(gtk_file_system_unix_get_folder): initialize load_folder_id to 0
|
||||
and store the source id of the load_folder idle,
|
||||
(gtk_file_folder_unix_finalize): remove the load_folder idle
|
||||
if necessary. (Federico Mena Quintero).
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooser.c (gtk_file_chooser_get_current_folder): return
|
||||
NULL if there is no current folder path.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_map): we
|
||||
reload the current folder if there is one, else we continue the
|
||||
still pending load.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Merge from HEAD to get rid of some warnings (simplifies debugging).
|
||||
|
||||
Thu Feb 23 13:28:21 2006 Tim Janik <timj@imendio.com>
|
||||
|
||||
* gdk/x11/gdkim-x11.c (_gdk_x11_initialize_locale): remove unconditional
|
||||
warnings about missing X locale support. Gdk properly handles this
|
||||
situation anyway.
|
||||
|
||||
2006-03-14 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Couple of fixes from Markku Vire.
|
||||
|
||||
* gtk/gtkfilesystem.c (gtk_file_info_copy): also strdup icon_name
|
||||
and display_key.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_create_folder):
|
||||
initialize error to NULL,
|
||||
(gtk_file_folder_unix_list_children): return an empty list for now if
|
||||
we couldn't read the directory.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb),
|
||||
(gtk_file_chooser_default_update_current_folder): set and unset
|
||||
busy cursor while checking whether the given path is a folder.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.h: change the GtkFileInfo argument of the
|
||||
GetInfoCallback to be const.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c, gtk/gtkfilechooserdefault.c,
|
||||
gtk/gtkpathbar.c: changes functions to reflect the above change.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c, gtk/gtkfilechooserprivate.h: keep track
|
||||
of handles, cancel all pending operations on dispose.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserprivate.h (struct _GtkFileSystemModel): add
|
||||
pending_handles field,
|
||||
(struct _FileModelNode): add load_pending flag.
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (gtk_file_system_model_dispose): introduce,
|
||||
cancel all pending operations here,
|
||||
(got_root_folder_cb), (_gtk_file_system_model_new), (ref_path_cb),
|
||||
(_gtk_file_system_model_path_do): keep track of all pending
|
||||
operations, handle cancelled operations.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_finalize),
|
||||
(gtk_file_chooser_button_destroy): move all handle cancellations
|
||||
and object unrefs to destroy.
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_finalize), (gtk_path_bar_dispose):
|
||||
likewise.
|
||||
|
||||
* gtk/gtkfilechooserentry.c (gtk_file_chooser_entry_class_init):
|
||||
add dispose,
|
||||
(gtk_file_chooser_entry_dispose): cancel handles and unrefs
|
||||
objects here instead of finalize.
|
||||
|
||||
2005-12-23 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.c (get_cached_icon): check if "name" is an
|
||||
absolute path, if so load the icon from that file.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): fix
|
||||
the build.
|
||||
|
||||
2005-12-21 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): remove
|
||||
the FIXME since it doesn't make sense, when we return a cached
|
||||
folder we won't emit finished-loading either,
|
||||
(gtk_file_system_unix_create_folder): remove unused variable,
|
||||
(gtk_file_folder_unix_list_children): remove unused code,
|
||||
(get_is_hidden_for_file): new function,
|
||||
(create_file_info): also handle getting is_hidden when called
|
||||
without a folder unix (from _system_get_info() for example).
|
||||
|
||||
2005-12-20 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (check_is_folder): fully removed!
|
||||
woo!,
|
||||
(check_save_entry): add is_folder argument,
|
||||
(gtk_file_chooser_default_get_paths): update check_save_entry() call,
|
||||
(get_display_name_for_folder): removed,
|
||||
(confirmation_confirm_get_info_cb): new function which will
|
||||
handle the confirmation dialog now we have all information for it,
|
||||
(should_respond_after_confirm_overwrite): replace the call to
|
||||
get_display_name_for_folder() with an asynchronous solution,
|
||||
(action_create_folder_cb): request dialog response on successfull
|
||||
folder creation,
|
||||
(gtk_file_chooser_default_should_respond): update call to
|
||||
check_save_entry(); replace the check is folder call for "path"
|
||||
by just using the is_folder return value from check_save_entry();
|
||||
replaced the check is folder call for "parent_path" with an
|
||||
asynchronous setup, remainder of that work is now done in
|
||||
save_entry_get_info_cb(),
|
||||
(save_entry_get_info_cb): new function.
|
||||
|
||||
* gtk/gtkfilechoosermebed.[ch]: add response-requested signal.
|
||||
|
||||
* gtk/gtkfilechooserdialog.c, gtk/gtkfilechooserprivate.h: handle
|
||||
response_requested signal.
|
||||
|
||||
* gtk/gtkfilechooserentry.[ch]
|
||||
(_gtk_file_chooser_entry_get_is_folder): new function.
|
||||
|
||||
2005-12-20 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (ref_path_cb): when called with
|
||||
!folder, check if node is the node we are looking for (can be
|
||||
triggered when we call ref_path_cb ourselves after a find_child_node),
|
||||
(_gtk_file_system_model_path_do): introduce parent_node field;
|
||||
after finding a child node in a loaded parent node, don't forget
|
||||
to call ref_path_cb,
|
||||
(get_children_get_folder_cb): don't forget to set data->node->folder
|
||||
to the newly acquired folder.
|
||||
|
||||
2005-12-20 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (show_and_select_paths_get_folder_cb):
|
||||
handle case where the folder we get already finished loading.
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (ref_path_cb),
|
||||
(_gtk_file_system_model_path_do): make this work.
|
||||
|
||||
2005-12-19 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_update_count): modify
|
||||
in such a way that it can also negatively update the count on
|
||||
failures,
|
||||
(get_file_info_finished): handle failures, update save folder
|
||||
combo box on success,
|
||||
(shortcuts_insert_path): change the boolean return value into a
|
||||
void one, also refilter the model and update the save folder combo
|
||||
box for the non-asynchronous case,
|
||||
(shortcuts_append_home), (shortcuts_append_desktop),
|
||||
(shortcuts_add_volumes), (shortcuts_add_current_folder),
|
||||
(add_shortcuts_get_info_cb): adapt to shortcuts_insert_path() updates.
|
||||
|
||||
2005-12-19 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkpathbar.[ch]: add handle fields to ButtonData and
|
||||
GtkPathBar; do correct handle bookkeeping.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (load_folder),
|
||||
(gtk_file_system_unix_get_folder),
|
||||
(gtk_file_folder_unix_is_finished_loading): add is_finished_loading
|
||||
field to GtkFileFolderUnix, which is set to true once we are
|
||||
really finished with loading (previous assumption that we are
|
||||
always finshed loading is not true anymore).
|
||||
|
||||
* gtk/gtkfilesystemmodel.c (got_root_folder_cb): if the folder is
|
||||
finished loading, list the children and update the root level.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (update_current_folder_get_info_cb):
|
||||
handle cancellation.
|
||||
|
||||
2005-12-19 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtktreeview.c: small fix to make it actually work in this
|
||||
branch.
|
||||
|
||||
* gdk/gdkevents.c: same.
|
||||
|
||||
2005-12-16 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystemunix.c: always call the callback, even when
|
||||
cancelled; ref handles passed to the callback queue functions;
|
||||
don't set cancelled to TRUE in _cancel_operation(), since operations
|
||||
in this backend are always completed,
|
||||
(get_special_icon_name): don't strdup the value of
|
||||
get_icon_name_for_directory() again.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: adapt to new cancellation policy;
|
||||
reference all objects which are passed as callback arguments; in the
|
||||
callback check if the handles match.
|
||||
|
||||
* gtk/gtkfilechooserentry.c: likewise.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: likewise. Also changed the shortcut
|
||||
loading code to be more like the code in GtkFileChooserButton, where
|
||||
we store all handles in the model and have model_row_free_data
|
||||
cancel any pending operations,
|
||||
(shortcuts_model_create): copy the error.
|
||||
|
||||
* gtk/gtkfilechooserprivate.h (struct _GtkFileChooserDefault): remove
|
||||
loading_volumes and loading_bookmarks fields.
|
||||
|
||||
* gtk/gtkfilesystem.c (gtk_file_info_free): free icon_name here...
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (edited_idle_create_folder_cb): fix
|
||||
thinko.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (dispatch_create_folder_callback),
|
||||
(queue_create_folder_callback): need to copy/free the path,
|
||||
(gtk_file_system_unix_create_folder): put the "reget folder" hack
|
||||
back in, though it's working different now.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (gtk_file_chooser_button_finalize),
|
||||
(dnd_select_folder_get_info_cb), (gtk_file_chooser_drag_data_received),
|
||||
(change_icon_theme_get_info_cb), (change_icon_theme),
|
||||
(model_add_special_get_info_cb), (model_add_special),
|
||||
(update_label_get_info_cb), (update_label_and_image): cancel existing
|
||||
operations, if any; added apprioriate fields to
|
||||
GtkFileChooserButtonPrivate.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserentry.c (gtk_file_chooser_entry_finalize): if
|
||||
there's a folder loading, cancel the operation,
|
||||
(load_directory_get_folder_callback): set the loading folder handle
|
||||
to NULL,
|
||||
(load_directory_callback): cancel any currently loading folders
|
||||
before starting a new get folder operation.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (shortcuts_insert_path): don't overwrite
|
||||
data if it's already set (for example by the "is volume" case).
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (set_info_get_info_cb),
|
||||
(set_info_for_path_at_iter): store a row reference in the temporary
|
||||
data structure and not an iter,
|
||||
(model_add_special), (model_update_current_folder),
|
||||
(gtk_file_chooser_button_add_shorcut_folder): remove unused pixbuf
|
||||
variable.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (get_file_info_finished),
|
||||
(shortcuts_insert_path): replace gtk_file_system_render_icon() call
|
||||
with gtk_file_system_get_file_info(),
|
||||
(gtk_file_chooser_default_add_shortcut_folder),
|
||||
(gtk_file_chooser_default_remove_shortcut_folder): handle shortcuts
|
||||
which are still loading.
|
||||
|
||||
* gtk/gtkfilechooserprivate.h: add shortcuts_loading field to
|
||||
struct _GtkFileChooserDefault.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (set_info_get_info_cb),
|
||||
(set_info_for_path_at_iter), (model_free_row_data): keep handle
|
||||
and path together; now supports adding/removing shortcuts
|
||||
which are still loading.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.c: make the cancelled field an GObject property.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.h: make the GError argument in the callbacks
|
||||
const.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: update callbacks,
|
||||
* gtk/gtkfilechooserentry.c: likewise,
|
||||
* gtk/gtkfilechooserdefault.c: likewise,
|
||||
* gtk/gtkfilesystemmodel.c: likewise,
|
||||
* gtk/gtkpathbar.c: likewise.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (edited_idle_create_folder_cb): copy
|
||||
the error which will be passed to error_creating_folder_dialog(),
|
||||
(action_create_folder_cb): likewise,
|
||||
(file_list_drag_data_received_get_info_cb): add forgotten GError
|
||||
declaration.
|
||||
|
||||
2005-12-13 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkpathbar.c (get_button_image), (set_button_image),
|
||||
(set_button_image_get_info_cb),
|
||||
(gtk_path_bar_update_button_appearance): update to new icon
|
||||
rendering call.
|
||||
|
||||
2005-12-09 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (file_list_drag_data_received),
|
||||
(gtk_file_chooser_default_add_shortcut_folder),
|
||||
(shortcuts_activate_get_info_cb): replace synchronous check_is_folder
|
||||
calls with an async gtk_file_system_get_info() solution.
|
||||
|
||||
2005-12-09 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilesystem.c (icon_cache_element_free), (icon_theme_changed),
|
||||
(get_cached_icon), (gtk_file_info_render_icon): implement pixbuf
|
||||
caching as found in the file system backends.
|
||||
|
||||
2005-12-09 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtk.symbols: updated.
|
||||
|
||||
* gtk/gtkfilesystem.[ch] (struct GtkFileInfo): added icon_name field,
|
||||
(enum GtkFileInfoType): added GTK_FILE_INFO_ICON,
|
||||
(gtk_file_info_set_icon_name): new function,
|
||||
(gtk_file_info_render_icon): new function,
|
||||
(gtk_file_system_render_icon): removed.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_render_icon): removed,
|
||||
(create_file_info): fill icon_name field if required,
|
||||
(get_*_icon): modified to suit create_file_info() better.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: modified to use
|
||||
gtk_file_info_render_icon() instead of gtk_file_system_render_icon().
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: likewise.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (get_file_info_finished),
|
||||
(update_current_folder_get_info_cb): fix mem leaks.
|
||||
|
||||
* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_info): ditto.
|
||||
|
||||
* gtk/gtkpathbar.c (gtk_path_bar_set_path_finish): ditto.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserbutton.c (dnd_select_folder_get_info_cb),
|
||||
(gtk_file_chooser_button_drag_data_received): make asynchronous,
|
||||
(update_label_and_image): remove unused variable.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c
|
||||
(gtk_file_chooser_default_update_current_folder): split in two
|
||||
functions, so we can have the is_folder check back.
|
||||
* gtk/gtkfilechooserprivate.h: add update_current_folder_handle
|
||||
field.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (show_and_select_paths): fixed a typo.
|
||||
|
||||
2005-12-05 Federico Mena Quintero <federico@ximian.com>
|
||||
|
||||
(merge from HEAD)
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (trap_activate_cb): "event->state &
|
||||
modifiers", not "event->state && modifiers". Patch by Sadrul
|
||||
Habib Chowdhury <imadil@gmail.com>. Fixes bug #323073.
|
||||
|
||||
2005-12-06 Kristian Rietveld <kris@imendio.com>
|
||||
|
||||
Beginnings of an asynchronous file chooser.
|
||||
|
||||
* gtk/gtkfilechooserbutton.c: display name and the is folder property
|
||||
are now asynchronously set using set_info_for_at_path_iter(), the
|
||||
is folder property is now also stored in the tree model.
|
||||
|
||||
* gtk/gtkfilechooserdefault.c: lots of changes to the shortcuts
|
||||
model code to make it operate asynchronously, check_is_folder() has
|
||||
been "disabled" for now, all other synchronous calls were
|
||||
replaced with asychronous ones.
|
||||
|
||||
* gtk/gtkfilechooserentry.c: update call to
|
||||
gtk_file_system_get_folder().
|
||||
|
||||
* gtk/gtkfilechooserprivate.h: added two fields.
|
||||
|
||||
* gtk/gtkfilesystem.[ch]: for about 85% changed to the changes
|
||||
outlined in the proposal discussed on gtk-devel-list.
|
||||
|
||||
* gtk/gtkfilesystemmodel.[ch]: updated all asynchronous calls,
|
||||
_gtk_file_system_model_path_do() basically had to be rewritten
|
||||
(and I still need to finish that).
|
||||
|
||||
* gtk/gtkfilesystemunix.c: changed to be compatible with the new
|
||||
GtkFileSystem interface.
|
||||
|
||||
* gtk/gtkpathbar.c (button_clicked_cb): block/unblock the
|
||||
button_clicked_cb callback around the call to
|
||||
gtk_toggle_button_set_active(), avoids button_clicked_cb getting
|
||||
called twice.
|
||||
(_gtk_path_bar_set_path): refactored to be asynchronous.
|
||||
|
||||
Tue Dec 6 10:32:17 2005 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gtk/gtkstatusbar.c: ported memchunk uses to g_slice, so the code
|
||||
compiles again.
|
||||
|
||||
2005-12-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c:
|
||||
* gtk/gtkuimanager.c:
|
||||
* gtk/gtktreedatalist.c:
|
||||
* gtk/gtktext.c:
|
||||
* gtk/gtkmain.c:
|
||||
* gtk/gtkitemfactory.c:
|
||||
* gtk/gtkseparator.[hc]:
|
||||
* gtk/gtkclist.[hc]:
|
||||
* gtk/gtkctree.c:
|
||||
* gtk/gtkgc.c: Use g_slice instead of mem chunks.
|
||||
|
||||
2005-12-05 Michael Natterer <mitch@imendio.com>
|
||||
|
||||
* gdk/x11/gdkevents-x11.c: map the new GtkSettings properties
|
||||
"timeout-initial", "timeout-repeat", "color-scheme" and
|
||||
"enable-enimations" to X settings.
|
||||
|
||||
2005-12-05 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gdk/gdkevents.c:
|
||||
* gdk/gdkcolor.c: Use g_slice instead of mem chunks.
|
||||
|
||||
* gtk/gtktreeview.c (gtk_tree_view_key_press): Free new_event
|
||||
after sending it to the search entry. (#323209, Crispin Flowerday)
|
||||
|
||||
|
||||
@@ -103,8 +103,6 @@ gdk_colors_store (GdkColormap *colormap,
|
||||
gdk_colormap_change (colormap, ncolors);
|
||||
}
|
||||
|
||||
static GMemChunk *color_chunk;
|
||||
|
||||
/**
|
||||
* gdk_color_copy:
|
||||
* @color: a #GdkColor.
|
||||
@@ -121,13 +119,7 @@ gdk_color_copy (const GdkColor *color)
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
if (color_chunk == NULL)
|
||||
color_chunk = g_mem_chunk_new ("colors",
|
||||
sizeof (GdkColor),
|
||||
4096,
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
new_color = g_chunk_new (GdkColor, color_chunk);
|
||||
new_color = g_slice_new (GdkColor);
|
||||
*new_color = *color;
|
||||
return new_color;
|
||||
}
|
||||
@@ -142,10 +134,9 @@ gdk_color_copy (const GdkColor *color)
|
||||
void
|
||||
gdk_color_free (GdkColor *color)
|
||||
{
|
||||
g_assert (color_chunk != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
g_mem_chunk_free (color_chunk, color);
|
||||
g_slice_free (GdkColor, color);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -255,7 +255,6 @@ gdk_event_put (GdkEvent *event)
|
||||
gdk_display_put_event (display, event);
|
||||
}
|
||||
|
||||
static GMemChunk *event_chunk = NULL;
|
||||
static GHashTable *event_hash = NULL;
|
||||
|
||||
/**
|
||||
@@ -274,18 +273,11 @@ gdk_event_new (GdkEventType type)
|
||||
{
|
||||
GdkEventPrivate *new_private;
|
||||
GdkEvent *new_event;
|
||||
|
||||
if (!event_hash)
|
||||
event_hash = g_hash_table_new (g_direct_hash, NULL);
|
||||
|
||||
if (event_chunk == NULL)
|
||||
{
|
||||
event_chunk = g_mem_chunk_new ("events",
|
||||
sizeof (GdkEventPrivate),
|
||||
4096,
|
||||
G_ALLOC_AND_FREE);
|
||||
event_hash = g_hash_table_new (g_direct_hash, NULL);
|
||||
}
|
||||
|
||||
new_private = g_chunk_new (GdkEventPrivate, event_chunk);
|
||||
memset (new_private, 0, sizeof (GdkEventPrivate));
|
||||
new_private = g_slice_new0 (GdkEventPrivate);
|
||||
|
||||
new_private->flags = 0;
|
||||
new_private->screen = NULL;
|
||||
@@ -446,8 +438,6 @@ gdk_event_free (GdkEvent *event)
|
||||
{
|
||||
g_return_if_fail (event != NULL);
|
||||
|
||||
g_assert (event_chunk != NULL); /* paranoid */
|
||||
|
||||
if (event->any.window)
|
||||
g_object_unref (event->any.window);
|
||||
|
||||
@@ -498,7 +488,7 @@ gdk_event_free (GdkEvent *event)
|
||||
}
|
||||
|
||||
g_hash_table_remove (event_hash, event);
|
||||
g_mem_chunk_free (event_chunk, event);
|
||||
g_slice_free (GdkEventPrivate, (GdkEventPrivate *) event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2824,6 +2824,10 @@ static const struct
|
||||
{ "Gtk/CursorThemeSize", "gtk-cursor-theme-size" },
|
||||
{ "Gtk/ShowInputMethodMenu", "gtk-show-input-method-menu" },
|
||||
{ "Gtk/ShowUnicodeMenu", "gtk-show-unicode-menu" },
|
||||
{ "Gtk/TimeoutInitial", "gtk-timeout-initial" },
|
||||
{ "Gtk/TimeoutRepeat", "gtk-timeout-repeat" },
|
||||
{ "Gtk/ColorScheme", "gtk-color-scheme" },
|
||||
{ "Gtk/EnableAnimations", "gtk-enable-animations" },
|
||||
{ "Xft/Antialias", "gtk-xft-antialias" },
|
||||
{ "Xft/Hinting", "gtk-xft-hinting" },
|
||||
{ "Xft/HintStyle", "gtk-xft-hintstyle" },
|
||||
|
||||
@@ -62,11 +62,8 @@ _gdk_x11_initialize_locale (void)
|
||||
g_free (last_locale);
|
||||
last_locale = g_strdup (current_locale);
|
||||
|
||||
if (!XSupportsLocale ())
|
||||
g_warning ("locale not supported by Xlib");
|
||||
|
||||
if (!XSetLocaleModifiers (""))
|
||||
g_warning ("cannot set locale modifiers");
|
||||
if (XSupportsLocale ())
|
||||
XSetLocaleModifiers ("");
|
||||
|
||||
if ((strcmp (current_locale, "C")) && (strcmp (current_locale, "POSIX")))
|
||||
{
|
||||
|
||||
@@ -1344,6 +1344,7 @@ 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_name
|
||||
gtk_file_info_get_is_folder
|
||||
gtk_file_info_get_is_hidden
|
||||
gtk_file_info_get_mime_type
|
||||
@@ -1351,7 +1352,9 @@ gtk_file_info_get_modification_time
|
||||
gtk_file_info_get_size
|
||||
gtk_file_info_get_type G_GNUC_CONST
|
||||
gtk_file_info_new
|
||||
gtk_file_info_render_icon
|
||||
gtk_file_info_set_display_name
|
||||
gtk_file_info_set_icon_name
|
||||
gtk_file_info_set_is_folder
|
||||
gtk_file_info_set_is_hidden
|
||||
gtk_file_info_set_mime_type
|
||||
@@ -1361,9 +1364,11 @@ gtk_file_path_get_type G_GNUC_CONST
|
||||
gtk_file_paths_copy
|
||||
gtk_file_paths_free
|
||||
gtk_file_paths_sort
|
||||
gtk_file_system_cancel_operation
|
||||
gtk_file_system_create_folder
|
||||
gtk_file_system_error_quark
|
||||
gtk_file_system_filename_to_path
|
||||
gtk_file_system_get_info
|
||||
gtk_file_system_get_folder
|
||||
gtk_file_system_get_parent
|
||||
gtk_file_system_get_type G_GNUC_CONST
|
||||
@@ -1377,11 +1382,11 @@ gtk_file_system_path_is_local
|
||||
gtk_file_system_path_to_filename
|
||||
gtk_file_system_path_to_uri
|
||||
gtk_file_system_remove_bookmark
|
||||
gtk_file_system_render_icon
|
||||
gtk_file_system_uri_to_path
|
||||
gtk_file_system_volume_free
|
||||
gtk_file_system_volume_get_base_path
|
||||
gtk_file_system_volume_get_display_name
|
||||
gtk_file_system_volume_get_icon_name
|
||||
gtk_file_system_volume_get_is_mounted
|
||||
gtk_file_system_volume_mount
|
||||
gtk_file_system_volume_render_icon
|
||||
|
||||
@@ -46,9 +46,6 @@
|
||||
/* length of button_actions array */
|
||||
#define MAX_BUTTON 5
|
||||
|
||||
/* the number rows memchunk expands at a time */
|
||||
#define CLIST_OPTIMUM_SIZE 64
|
||||
|
||||
/* the width of the column resize windows */
|
||||
#define DRAG_WIDTH 6
|
||||
|
||||
@@ -1014,9 +1011,6 @@ gtk_clist_init (GtkCList *clist)
|
||||
GTK_CLIST_SET_FLAG (clist, CLIST_DRAW_DRAG_LINE);
|
||||
GTK_CLIST_SET_FLAG (clist, CLIST_USE_DRAG_ICONS);
|
||||
|
||||
clist->row_mem_chunk = NULL;
|
||||
clist->cell_mem_chunk = NULL;
|
||||
|
||||
clist->freeze_count = 0;
|
||||
|
||||
clist->rows = 0;
|
||||
@@ -1092,23 +1086,6 @@ gtk_clist_constructor (GType type,
|
||||
construct_properties);
|
||||
GtkCList *clist = GTK_CLIST (object);
|
||||
|
||||
/* initalize memory chunks, if this has not been done by any
|
||||
* possibly derived widget
|
||||
*/
|
||||
if (!clist->row_mem_chunk)
|
||||
clist->row_mem_chunk = g_mem_chunk_new ("clist row mem chunk",
|
||||
sizeof (GtkCListRow),
|
||||
sizeof (GtkCListRow) *
|
||||
CLIST_OPTIMUM_SIZE,
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
if (!clist->cell_mem_chunk)
|
||||
clist->cell_mem_chunk = g_mem_chunk_new ("clist cell mem chunk",
|
||||
sizeof (GtkCell) * clist->columns,
|
||||
sizeof (GtkCell) * clist->columns *
|
||||
CLIST_OPTIMUM_SIZE,
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
/* allocate memory for columns */
|
||||
clist->column = columns_new (clist);
|
||||
|
||||
@@ -4438,9 +4415,6 @@ gtk_clist_finalize (GObject *object)
|
||||
|
||||
columns_delete (clist);
|
||||
|
||||
g_mem_chunk_destroy (clist->cell_mem_chunk);
|
||||
g_mem_chunk_destroy (clist->row_mem_chunk);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@@ -6374,8 +6348,8 @@ row_new (GtkCList *clist)
|
||||
int i;
|
||||
GtkCListRow *clist_row;
|
||||
|
||||
clist_row = g_chunk_new (GtkCListRow, clist->row_mem_chunk);
|
||||
clist_row->cell = g_chunk_new (GtkCell, clist->cell_mem_chunk);
|
||||
clist_row = g_slice_new (GtkCListRow);
|
||||
clist_row->cell = g_slice_new (GtkCell);
|
||||
|
||||
for (i = 0; i < clist->columns; i++)
|
||||
{
|
||||
@@ -6424,8 +6398,8 @@ row_delete (GtkCList *clist,
|
||||
if (clist_row->destroy)
|
||||
clist_row->destroy (clist_row->data);
|
||||
|
||||
g_mem_chunk_free (clist->cell_mem_chunk, clist_row->cell);
|
||||
g_mem_chunk_free (clist->row_mem_chunk, clist_row);
|
||||
g_slice_free (GtkCell, clist_row->cell);
|
||||
g_slice_free (GtkCListRow, clist_row);
|
||||
}
|
||||
|
||||
/* FOCUS FUNCTIONS
|
||||
|
||||
@@ -151,9 +151,8 @@ struct _GtkCList
|
||||
|
||||
guint16 flags;
|
||||
|
||||
/* mem chunks */
|
||||
GMemChunk *row_mem_chunk;
|
||||
GMemChunk *cell_mem_chunk;
|
||||
gpointer reserved1;
|
||||
gpointer reserved2;
|
||||
|
||||
guint freeze_count;
|
||||
|
||||
|
||||
@@ -567,24 +567,12 @@ gtk_ctree_set_arg (GtkObject *object,
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_N_COLUMNS: /* construct-only arg, only set at construction time */
|
||||
g_return_if_fail (clist->row_mem_chunk == NULL);
|
||||
clist->columns = MAX (1, GTK_VALUE_UINT (*arg));
|
||||
clist->row_mem_chunk = g_mem_chunk_new ("ctree row mem chunk",
|
||||
sizeof (GtkCTreeRow),
|
||||
sizeof (GtkCTreeRow)
|
||||
* CLIST_OPTIMUM_SIZE,
|
||||
G_ALLOC_AND_FREE);
|
||||
clist->cell_mem_chunk = g_mem_chunk_new ("ctree cell mem chunk",
|
||||
sizeof (GtkCell) * clist->columns,
|
||||
sizeof (GtkCell) * clist->columns
|
||||
* CLIST_OPTIMUM_SIZE,
|
||||
G_ALLOC_AND_FREE);
|
||||
ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
|
||||
break;
|
||||
case ARG_TREE_COLUMN: /* construct-only arg, only set at construction time */
|
||||
ctree->tree_column = GTK_VALUE_UINT (*arg);
|
||||
if (clist->row_mem_chunk)
|
||||
ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
|
||||
ctree->tree_column = CLAMP (ctree->tree_column, 0, clist->columns);
|
||||
break;
|
||||
case ARG_INDENT:
|
||||
gtk_ctree_set_indent (ctree, GTK_VALUE_UINT (*arg));
|
||||
@@ -3207,8 +3195,8 @@ row_new (GtkCTree *ctree)
|
||||
int i;
|
||||
|
||||
clist = GTK_CLIST (ctree);
|
||||
ctree_row = g_chunk_new (GtkCTreeRow, clist->row_mem_chunk);
|
||||
ctree_row->row.cell = g_chunk_new (GtkCell, clist->cell_mem_chunk);
|
||||
ctree_row = g_slice_new (GtkCTreeRow);
|
||||
ctree_row->row.cell = g_slice_new (GtkCell);
|
||||
|
||||
for (i = 0; i < clist->columns; i++)
|
||||
{
|
||||
@@ -3294,8 +3282,8 @@ row_delete (GtkCTree *ctree,
|
||||
dnotify (ddata);
|
||||
}
|
||||
|
||||
g_mem_chunk_free (clist->cell_mem_chunk, ctree_row->row.cell);
|
||||
g_mem_chunk_free (clist->row_mem_chunk, ctree_row);
|
||||
g_slice_free (GtkCell, ctree_row->row.cell);
|
||||
g_slice_free (GtkCListRow, ctree_row);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -720,6 +720,9 @@ gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
|
||||
file_system = _gtk_file_chooser_get_file_system (chooser);
|
||||
|
||||
path = _gtk_file_chooser_get_current_folder_path (chooser);
|
||||
if (!path)
|
||||
return NULL;
|
||||
|
||||
filename = gtk_file_system_path_to_filename (file_system, path);
|
||||
gtk_file_path_free (path);
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ enum
|
||||
DISPLAY_NAME_COLUMN,
|
||||
TYPE_COLUMN,
|
||||
DATA_COLUMN,
|
||||
IS_FOLDER_COLUMN,
|
||||
HANDLE_COLUMN,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
@@ -143,6 +145,10 @@ struct _GtkFileChooserButtonPrivate
|
||||
gulong fs_volumes_changed_id;
|
||||
gulong fs_bookmarks_changed_id;
|
||||
|
||||
GtkFileSystemHandle *dnd_select_folder_handle;
|
||||
GtkFileSystemHandle *update_button_handle;
|
||||
GSList *change_icon_theme_handles;
|
||||
|
||||
gint icon_size;
|
||||
|
||||
guint8 n_special;
|
||||
@@ -227,8 +233,9 @@ static void gtk_file_chooser_button_screen_changed (GtkWidget *wi
|
||||
|
||||
/* Utility Functions */
|
||||
static GtkIconTheme *get_icon_theme (GtkWidget *widget);
|
||||
static gchar *get_display_name_for_path (GtkFileSystem *fs,
|
||||
const GtkFilePath *path);
|
||||
static void set_info_for_path_at_iter (GtkFileChooserButton *fs,
|
||||
const GtkFilePath *path,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
static gint model_get_type_position (GtkFileChooserButton *button,
|
||||
RowType row_type);
|
||||
@@ -449,7 +456,9 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
|
||||
GDK_TYPE_PIXBUF, /* Icon */
|
||||
G_TYPE_STRING, /* Display Name */
|
||||
G_TYPE_CHAR, /* Row Type */
|
||||
G_TYPE_POINTER /* Volume || Path */));
|
||||
G_TYPE_POINTER /* Volume || Path */,
|
||||
G_TYPE_BOOLEAN /* Is Folder? */,
|
||||
G_TYPE_OBJECT /* handle */));
|
||||
|
||||
priv->combo_box = gtk_combo_box_new ();
|
||||
priv->combo_box_changed_id =
|
||||
@@ -517,30 +526,21 @@ gtk_file_chooser_button_add_shortcut_folder (GtkFileChooser *chooser,
|
||||
GtkFileChooserButtonPrivate *priv = button->priv;
|
||||
GtkTreeIter iter;
|
||||
gint pos;
|
||||
GdkPixbuf *pixbuf;
|
||||
gchar *display_name;
|
||||
|
||||
pos = model_get_type_position (button, ROW_TYPE_SHORTCUT);
|
||||
pos += priv->n_shortcuts;
|
||||
|
||||
pixbuf = gtk_file_system_render_icon (priv->fs, path,
|
||||
GTK_WIDGET (chooser),
|
||||
priv->icon_size, NULL);
|
||||
display_name = get_display_name_for_path (priv->fs, path);
|
||||
|
||||
gtk_list_store_insert (GTK_LIST_STORE (priv->model), &iter, pos);
|
||||
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
|
||||
ICON_COLUMN, pixbuf,
|
||||
DISPLAY_NAME_COLUMN, display_name,
|
||||
ICON_COLUMN, NULL,
|
||||
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
|
||||
TYPE_COLUMN, ROW_TYPE_SHORTCUT,
|
||||
DATA_COLUMN, gtk_file_path_copy (path),
|
||||
IS_FOLDER_COLUMN, FALSE,
|
||||
-1);
|
||||
set_info_for_path_at_iter (button, path, &iter);
|
||||
priv->n_shortcuts++;
|
||||
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
g_free (display_name);
|
||||
|
||||
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
|
||||
}
|
||||
|
||||
@@ -859,26 +859,10 @@ gtk_file_chooser_button_finalize (GObject *object)
|
||||
{
|
||||
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
|
||||
GtkFileChooserButtonPrivate *priv = button->priv;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (priv->old_path)
|
||||
gtk_file_path_free (priv->old_path);
|
||||
|
||||
g_assert (gtk_tree_model_get_iter_first (priv->model, &iter));
|
||||
|
||||
do
|
||||
{
|
||||
model_free_row_data (button, &iter);
|
||||
}
|
||||
while (gtk_tree_model_iter_next (priv->model, &iter));
|
||||
|
||||
g_object_unref (priv->model);
|
||||
g_object_unref (priv->filter_model);
|
||||
|
||||
g_signal_handler_disconnect (priv->fs, priv->fs_volumes_changed_id);
|
||||
g_signal_handler_disconnect (priv->fs, priv->fs_bookmarks_changed_id);
|
||||
g_object_unref (priv->fs);
|
||||
|
||||
if (G_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->finalize != NULL)
|
||||
(*G_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->finalize) (object);
|
||||
}
|
||||
@@ -892,9 +876,65 @@ gtk_file_chooser_button_destroy (GtkObject *object)
|
||||
{
|
||||
GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (object);
|
||||
GtkFileChooserButtonPrivate *priv = button->priv;
|
||||
GtkTreeIter iter;
|
||||
GSList *l;
|
||||
|
||||
if (priv->dialog != NULL)
|
||||
gtk_widget_destroy (priv->dialog);
|
||||
{
|
||||
gtk_widget_destroy (priv->dialog);
|
||||
priv->dialog = NULL;
|
||||
}
|
||||
|
||||
g_assert (gtk_tree_model_get_iter_first (priv->model, &iter));
|
||||
|
||||
do
|
||||
{
|
||||
model_free_row_data (button, &iter);
|
||||
}
|
||||
while (gtk_tree_model_iter_next (priv->model, &iter));
|
||||
|
||||
if (priv->dnd_select_folder_handle)
|
||||
{
|
||||
gtk_file_system_cancel_operation (priv->dnd_select_folder_handle);
|
||||
priv->dnd_select_folder_handle = NULL;
|
||||
}
|
||||
|
||||
if (priv->update_button_handle)
|
||||
{
|
||||
gtk_file_system_cancel_operation (priv->update_button_handle);
|
||||
priv->update_button_handle = NULL;
|
||||
}
|
||||
|
||||
if (priv->change_icon_theme_handles)
|
||||
{
|
||||
for (l = priv->change_icon_theme_handles; l; l = l->next)
|
||||
{
|
||||
GtkFileSystemHandle *handle = GTK_FILE_SYSTEM_HANDLE (l->data);
|
||||
gtk_file_system_cancel_operation (handle);
|
||||
}
|
||||
g_slist_free (priv->change_icon_theme_handles);
|
||||
priv->change_icon_theme_handles = NULL;
|
||||
}
|
||||
|
||||
if (priv->model)
|
||||
{
|
||||
g_object_unref (priv->model);
|
||||
priv->model = NULL;
|
||||
}
|
||||
|
||||
if (priv->filter_model)
|
||||
{
|
||||
g_object_unref (priv->filter_model);
|
||||
priv->filter_model = NULL;
|
||||
}
|
||||
|
||||
if (priv->fs)
|
||||
{
|
||||
g_signal_handler_disconnect (priv->fs, priv->fs_volumes_changed_id);
|
||||
g_signal_handler_disconnect (priv->fs, priv->fs_bookmarks_changed_id);
|
||||
g_object_unref (priv->fs);
|
||||
priv->fs = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->destroy != NULL)
|
||||
(*GTK_OBJECT_CLASS (gtk_file_chooser_button_parent_class)->destroy) (object);
|
||||
@@ -905,6 +945,76 @@ gtk_file_chooser_button_destroy (GtkObject *object)
|
||||
* GtkWidget Functions *
|
||||
* ********************* */
|
||||
|
||||
struct DndSelectFolderData
|
||||
{
|
||||
GtkFileChooserButton *button;
|
||||
GtkFileChooserAction action;
|
||||
GtkFilePath *path;
|
||||
gchar **uris;
|
||||
guint i;
|
||||
gboolean selected;
|
||||
};
|
||||
|
||||
static void
|
||||
dnd_select_folder_get_info_cb (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *info,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
struct DndSelectFolderData *data = user_data;
|
||||
|
||||
if (handle != data->button->priv->dnd_select_folder_handle)
|
||||
{
|
||||
g_object_unref (data->button);
|
||||
gtk_file_path_free (data->path);
|
||||
g_strfreev (data->uris);
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (handle);
|
||||
return;
|
||||
}
|
||||
|
||||
data->button->priv->dnd_select_folder_handle = NULL;
|
||||
|
||||
if (!cancelled && !error && info != NULL)
|
||||
{
|
||||
data->selected =
|
||||
(((data->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER &&
|
||||
gtk_file_info_get_is_folder (info)) ||
|
||||
(data->action == GTK_FILE_CHOOSER_ACTION_OPEN &&
|
||||
!gtk_file_info_get_is_folder (info))) &&
|
||||
_gtk_file_chooser_select_path (GTK_FILE_CHOOSER (data->button->priv->dialog),
|
||||
data->path, NULL));
|
||||
}
|
||||
else
|
||||
data->selected = FALSE;
|
||||
|
||||
if (data->selected || data->uris[++data->i] == NULL)
|
||||
{
|
||||
g_object_unref (data->button);
|
||||
gtk_file_path_free (data->path);
|
||||
g_strfreev (data->uris);
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->path)
|
||||
gtk_file_path_free (data->path);
|
||||
|
||||
data->path = gtk_file_system_uri_to_path (handle->file_system,
|
||||
data->uris[data->i]);
|
||||
|
||||
data->button->priv->dnd_select_folder_handle =
|
||||
gtk_file_system_get_info (handle->file_system, data->path,
|
||||
GTK_FILE_INFO_IS_FOLDER,
|
||||
dnd_select_folder_get_info_cb, user_data);
|
||||
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_button_drag_data_received (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
@@ -934,59 +1044,30 @@ gtk_file_chooser_button_drag_data_received (GtkWidget *widget,
|
||||
case TEXT_URI_LIST:
|
||||
{
|
||||
gchar **uris;
|
||||
GtkFilePath *base_path;
|
||||
guint i;
|
||||
gboolean selected;
|
||||
struct DndSelectFolderData *info;
|
||||
|
||||
uris = gtk_selection_data_get_uris (data);
|
||||
|
||||
if (uris == NULL)
|
||||
break;
|
||||
|
||||
selected = FALSE;
|
||||
for (i = 0; !selected && uris[i] != NULL; i++)
|
||||
{
|
||||
path = gtk_file_system_uri_to_path (priv->fs, uris[i]);
|
||||
info = g_new0 (struct DndSelectFolderData, 1);
|
||||
info->button = g_object_ref (button);
|
||||
info->i = 0;
|
||||
info->uris = uris;
|
||||
info->selected = FALSE;
|
||||
g_object_get (priv->dialog, "action", &info->action, NULL);
|
||||
|
||||
base_path = NULL;
|
||||
if (path != NULL &&
|
||||
gtk_file_system_get_parent (priv->fs, path, &base_path, NULL))
|
||||
{
|
||||
GtkFileFolder *folder;
|
||||
GtkFileInfo *info;
|
||||
info->path = gtk_file_system_uri_to_path (priv->fs,
|
||||
info->uris[info->i]);
|
||||
|
||||
folder = gtk_file_system_get_folder (priv->fs, base_path,
|
||||
GTK_FILE_INFO_IS_FOLDER,
|
||||
NULL);
|
||||
if (priv->dnd_select_folder_handle)
|
||||
gtk_file_system_cancel_operation (priv->dnd_select_folder_handle);
|
||||
|
||||
info = gtk_file_folder_get_info (folder, path, NULL);
|
||||
|
||||
if (info != NULL)
|
||||
{
|
||||
GtkFileChooserAction action;
|
||||
|
||||
g_object_get (priv->dialog, "action", &action, NULL);
|
||||
|
||||
selected =
|
||||
(((action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER &&
|
||||
gtk_file_info_get_is_folder (info)) ||
|
||||
(action == GTK_FILE_CHOOSER_ACTION_OPEN &&
|
||||
!gtk_file_info_get_is_folder (info))) &&
|
||||
_gtk_file_chooser_select_path (GTK_FILE_CHOOSER (priv->dialog),
|
||||
path, NULL));
|
||||
|
||||
gtk_file_info_free (info);
|
||||
}
|
||||
else
|
||||
selected = FALSE;
|
||||
|
||||
gtk_file_path_free (base_path);
|
||||
}
|
||||
|
||||
gtk_file_path_free (path);
|
||||
}
|
||||
|
||||
g_strfreev (uris);
|
||||
priv->dnd_select_folder_handle =
|
||||
gtk_file_system_get_info (priv->fs, info->path,
|
||||
GTK_FILE_INFO_IS_FOLDER,
|
||||
dnd_select_folder_get_info_cb, info);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1087,6 +1168,64 @@ gtk_file_chooser_button_mnemonic_activate (GtkWidget *widget,
|
||||
}
|
||||
|
||||
/* Changes the icons wherever it is needed */
|
||||
struct ChangeIconThemeData
|
||||
{
|
||||
GtkFileChooserButton *button;
|
||||
GtkTreeRowReference *row_ref;
|
||||
};
|
||||
|
||||
static void
|
||||
change_icon_theme_get_info_cb (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *info,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
GdkPixbuf *pixbuf;
|
||||
struct ChangeIconThemeData *data = user_data;
|
||||
|
||||
if (!g_slist_find (data->button->priv->change_icon_theme_handles, handle))
|
||||
goto out;
|
||||
|
||||
data->button->priv->change_icon_theme_handles =
|
||||
g_slist_remove (data->button->priv->change_icon_theme_handles, handle);
|
||||
|
||||
if (cancelled || error)
|
||||
goto out;
|
||||
|
||||
pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (data->button),
|
||||
data->button->priv->icon_size, NULL);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
gint width = 0;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
width = MAX (width, gdk_pixbuf_get_width (pixbuf));
|
||||
|
||||
path = gtk_tree_row_reference_get_path (data->row_ref);
|
||||
gtk_tree_model_get_iter (data->button->priv->model, &iter, path);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
|
||||
ICON_COLUMN, pixbuf,
|
||||
-1);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
g_object_set (data->button->priv->icon_cell,
|
||||
"width", width,
|
||||
NULL);
|
||||
}
|
||||
|
||||
out:
|
||||
g_object_unref (data->button);
|
||||
gtk_tree_row_reference_free (data->row_ref);
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static void
|
||||
change_icon_theme (GtkFileChooserButton *button)
|
||||
{
|
||||
@@ -1094,7 +1233,16 @@ change_icon_theme (GtkFileChooserButton *button)
|
||||
GtkSettings *settings;
|
||||
GtkIconTheme *theme;
|
||||
GtkTreeIter iter;
|
||||
gint width, height;
|
||||
GSList *l;
|
||||
gint width = 0, height = 0;
|
||||
|
||||
for (l = button->priv->change_icon_theme_handles; l; l = l->next)
|
||||
{
|
||||
GtkFileSystemHandle *handle = GTK_FILE_SYSTEM_HANDLE (l->data);
|
||||
gtk_file_system_cancel_operation (handle);
|
||||
}
|
||||
g_slist_free (button->priv->change_icon_theme_handles);
|
||||
button->priv->change_icon_theme_handles = NULL;
|
||||
|
||||
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (button)));
|
||||
|
||||
@@ -1129,9 +1277,25 @@ change_icon_theme (GtkFileChooserButton *button)
|
||||
case ROW_TYPE_BOOKMARK:
|
||||
case ROW_TYPE_CURRENT_FOLDER:
|
||||
if (data)
|
||||
pixbuf = gtk_file_system_render_icon (priv->fs, data,
|
||||
GTK_WIDGET (button),
|
||||
priv->icon_size, NULL);
|
||||
{
|
||||
GtkTreePath *path;
|
||||
GtkFileSystemHandle *handle;
|
||||
struct ChangeIconThemeData *info;
|
||||
|
||||
info = g_new0 (struct ChangeIconThemeData, 1);
|
||||
info->button = g_object_ref (button);
|
||||
path = gtk_tree_model_get_path (priv->model, &iter);
|
||||
info->row_ref = gtk_tree_row_reference_new (priv->model, path);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
handle =
|
||||
gtk_file_system_get_info (priv->fs, data, GTK_FILE_INFO_ICON,
|
||||
change_icon_theme_get_info_cb,
|
||||
info);
|
||||
button->priv->change_icon_theme_handles =
|
||||
g_slist_append (button->priv->change_icon_theme_handles, handle);
|
||||
pixbuf = NULL;
|
||||
}
|
||||
else
|
||||
pixbuf = gtk_icon_theme_load_icon (theme, FALLBACK_ICON_NAME,
|
||||
priv->icon_size, 0, NULL);
|
||||
@@ -1206,43 +1370,92 @@ get_icon_theme (GtkWidget *widget)
|
||||
return gtk_icon_theme_get_default ();
|
||||
}
|
||||
|
||||
static gchar *
|
||||
get_display_name_for_path (GtkFileSystem *fs,
|
||||
const GtkFilePath *path)
|
||||
|
||||
struct SetDisplayNameData
|
||||
{
|
||||
GtkFilePath *parent_path;
|
||||
GtkFileFolder *folder;
|
||||
gchar *retval;
|
||||
GtkFileChooserButton *button;
|
||||
GtkTreeRowReference *row_ref;
|
||||
};
|
||||
|
||||
parent_path = NULL;
|
||||
retval = NULL;
|
||||
static void
|
||||
set_info_get_info_cb (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *info,
|
||||
const GError *error,
|
||||
gpointer callback_data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
GtkFileSystemHandle *model_handle;
|
||||
struct SetDisplayNameData *data = callback_data;
|
||||
|
||||
gtk_file_system_get_parent (fs, path, &parent_path, NULL);
|
||||
path = gtk_tree_row_reference_get_path (data->row_ref);
|
||||
if (!path)
|
||||
/* Handle doesn't exist anymore in the model */
|
||||
goto out;
|
||||
|
||||
folder = gtk_file_system_get_folder (fs, parent_path ? parent_path : path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME, NULL);
|
||||
gtk_tree_model_get_iter (data->button->priv->model, &iter, path);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
if (folder)
|
||||
{
|
||||
GtkFileInfo *info;
|
||||
/* Validate the handle */
|
||||
gtk_tree_model_get (data->button->priv->model, &iter,
|
||||
HANDLE_COLUMN, &model_handle,
|
||||
-1);
|
||||
if (handle != model_handle)
|
||||
goto out;
|
||||
|
||||
info = gtk_file_folder_get_info (folder, path, NULL);
|
||||
g_object_unref (folder);
|
||||
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
|
||||
HANDLE_COLUMN, NULL,
|
||||
-1);
|
||||
|
||||
if (info)
|
||||
{
|
||||
retval = g_strdup (gtk_file_info_get_display_name (info));
|
||||
gtk_file_info_free (info);
|
||||
}
|
||||
}
|
||||
if (cancelled || error)
|
||||
/* There was an error, leave the fallback name in there */
|
||||
goto out;
|
||||
|
||||
if (parent_path)
|
||||
gtk_file_path_free (parent_path);
|
||||
pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (data->button),
|
||||
data->button->priv->icon_size, NULL);
|
||||
|
||||
if (!retval)
|
||||
retval = g_strdup (_(FALLBACK_DISPLAY_NAME));
|
||||
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
|
||||
ICON_COLUMN, pixbuf,
|
||||
DISPLAY_NAME_COLUMN, gtk_file_info_get_display_name (info),
|
||||
IS_FOLDER_COLUMN, gtk_file_info_get_is_folder (info),
|
||||
-1);
|
||||
|
||||
return retval;
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
out:
|
||||
g_object_unref (data->button);
|
||||
gtk_tree_row_reference_free (data->row_ref);
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static void
|
||||
set_info_for_path_at_iter (GtkFileChooserButton *button,
|
||||
const GtkFilePath *path,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
struct SetDisplayNameData *data;
|
||||
GtkTreePath *tree_path;
|
||||
GtkFileSystemHandle *handle;
|
||||
|
||||
data = g_new0 (struct SetDisplayNameData, 1);
|
||||
data->button = g_object_ref (button);
|
||||
|
||||
tree_path = gtk_tree_model_get_path (button->priv->model, iter);
|
||||
data->row_ref = gtk_tree_row_reference_new (button->priv->model, tree_path);
|
||||
gtk_tree_path_free (tree_path);
|
||||
|
||||
handle = gtk_file_system_get_info (button->priv->fs, path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_FOLDER | GTK_FILE_INFO_ICON,
|
||||
set_info_get_info_cb, data);
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (button->priv->model), iter,
|
||||
HANDLE_COLUMN, handle,
|
||||
-1);
|
||||
}
|
||||
|
||||
/* Shortcuts Model */
|
||||
@@ -1305,12 +1518,17 @@ model_free_row_data (GtkFileChooserButton *button,
|
||||
{
|
||||
gchar type;
|
||||
gpointer data;
|
||||
GtkFileSystemHandle *handle;
|
||||
|
||||
gtk_tree_model_get (button->priv->model, iter,
|
||||
TYPE_COLUMN, &type,
|
||||
DATA_COLUMN, &data,
|
||||
HANDLE_COLUMN, &handle,
|
||||
-1);
|
||||
|
||||
if (handle)
|
||||
gtk_file_system_cancel_operation (handle);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ROW_TYPE_SPECIAL:
|
||||
@@ -1327,6 +1545,58 @@ model_free_row_data (GtkFileChooserButton *button,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
model_add_special_get_info_cb (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *info,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkFileSystemHandle *model_handle;
|
||||
struct ChangeIconThemeData *data = user_data;
|
||||
|
||||
path = gtk_tree_row_reference_get_path (data->row_ref);
|
||||
if (!path)
|
||||
/* Handle doesn't exist anymore in the model */
|
||||
goto out;
|
||||
|
||||
gtk_tree_model_get_iter (data->button->priv->model, &iter, path);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
gtk_tree_model_get (data->button->priv->model, &iter,
|
||||
HANDLE_COLUMN, &model_handle,
|
||||
-1);
|
||||
if (handle != model_handle)
|
||||
goto out;
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
|
||||
HANDLE_COLUMN, NULL,
|
||||
-1);
|
||||
|
||||
if (cancelled || error)
|
||||
goto out;
|
||||
|
||||
pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (data->button),
|
||||
data->button->priv->icon_size, NULL);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
|
||||
ICON_COLUMN, pixbuf,
|
||||
-1);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
out:
|
||||
gtk_tree_row_reference_free (data->row_ref);
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static inline void
|
||||
model_add_special (GtkFileChooserButton *button)
|
||||
{
|
||||
@@ -1335,7 +1605,6 @@ model_add_special (GtkFileChooserButton *button)
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
GtkFilePath *path;
|
||||
GdkPixbuf *pixbuf;
|
||||
gint pos;
|
||||
|
||||
store = GTK_LIST_STORE (button->priv->model);
|
||||
@@ -1345,21 +1614,34 @@ model_add_special (GtkFileChooserButton *button)
|
||||
|
||||
if (homedir)
|
||||
{
|
||||
GtkTreePath *tree_path;
|
||||
GtkFileSystemHandle *handle;
|
||||
struct ChangeIconThemeData *info;
|
||||
|
||||
path = gtk_file_system_filename_to_path (button->priv->fs, homedir);
|
||||
pixbuf = gtk_file_system_render_icon (button->priv->fs, path,
|
||||
GTK_WIDGET (button),
|
||||
button->priv->icon_size, NULL);
|
||||
gtk_list_store_insert (store, &iter, pos);
|
||||
pos++;
|
||||
|
||||
info = g_new0 (struct ChangeIconThemeData, 1);
|
||||
info->button = g_object_ref (button);
|
||||
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
|
||||
info->row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store),
|
||||
tree_path);
|
||||
gtk_tree_path_free (tree_path);
|
||||
|
||||
handle = gtk_file_system_get_info (button->priv->fs, path,
|
||||
GTK_FILE_INFO_ICON,
|
||||
model_add_special_get_info_cb, info);
|
||||
|
||||
gtk_list_store_set (store, &iter,
|
||||
ICON_COLUMN, pixbuf,
|
||||
ICON_COLUMN, NULL,
|
||||
DISPLAY_NAME_COLUMN, _(HOME_DISPLAY_NAME),
|
||||
TYPE_COLUMN, ROW_TYPE_SPECIAL,
|
||||
DATA_COLUMN, path,
|
||||
IS_FOLDER_COLUMN, TRUE,
|
||||
HANDLE_COLUMN, handle,
|
||||
-1);
|
||||
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
button->priv->n_special++;
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
@@ -1373,22 +1655,34 @@ model_add_special (GtkFileChooserButton *button)
|
||||
|
||||
if (desktopdir)
|
||||
{
|
||||
GtkTreePath *tree_path;
|
||||
GtkFileSystemHandle *handle;
|
||||
struct ChangeIconThemeData *info;
|
||||
|
||||
path = gtk_file_system_filename_to_path (button->priv->fs, desktopdir);
|
||||
g_free (desktopdir);
|
||||
pixbuf = gtk_file_system_render_icon (button->priv->fs, path,
|
||||
GTK_WIDGET (button),
|
||||
button->priv->icon_size, NULL);
|
||||
gtk_list_store_insert (store, &iter, pos);
|
||||
pos++;
|
||||
|
||||
info = g_new0 (struct ChangeIconThemeData, 1);
|
||||
info->button = g_object_ref (button);
|
||||
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
|
||||
info->row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store),
|
||||
tree_path);
|
||||
gtk_tree_path_free (tree_path);
|
||||
|
||||
handle = gtk_file_system_get_info (button->priv->fs, path,
|
||||
GTK_FILE_INFO_ICON,
|
||||
model_add_special_get_info_cb, info);
|
||||
|
||||
gtk_list_store_set (store, &iter,
|
||||
TYPE_COLUMN, ROW_TYPE_SPECIAL,
|
||||
ICON_COLUMN, pixbuf,
|
||||
ICON_COLUMN, NULL,
|
||||
DISPLAY_NAME_COLUMN, _(DESKTOP_DISPLAY_NAME),
|
||||
DATA_COLUMN, path,
|
||||
IS_FOLDER_COLUMN, TRUE,
|
||||
-1);
|
||||
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
button->priv->n_special++;
|
||||
}
|
||||
}
|
||||
@@ -1426,6 +1720,7 @@ model_add_volumes (GtkFileChooserButton *button,
|
||||
DISPLAY_NAME_COLUMN, display_name,
|
||||
TYPE_COLUMN, ROW_TYPE_VOLUME,
|
||||
DATA_COLUMN, volumes->data,
|
||||
IS_FOLDER_COLUMN, TRUE,
|
||||
-1);
|
||||
|
||||
if (pixbuf)
|
||||
@@ -1461,32 +1756,24 @@ model_add_bookmarks (GtkFileChooserButton *button,
|
||||
DISPLAY_NAME_COLUMN, NULL,
|
||||
TYPE_COLUMN, ROW_TYPE_BOOKMARK_SEPARATOR,
|
||||
DATA_COLUMN, NULL,
|
||||
IS_FOLDER_COLUMN, FALSE,
|
||||
-1);
|
||||
button->priv->has_bookmark_separator = TRUE;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
gchar *display_name;
|
||||
|
||||
pos++;
|
||||
pixbuf = gtk_file_system_render_icon (button->priv->fs, bookmarks->data,
|
||||
GTK_WIDGET (button),
|
||||
button->priv->icon_size, NULL);
|
||||
display_name = get_display_name_for_path (button->priv->fs,
|
||||
bookmarks->data);
|
||||
|
||||
gtk_list_store_insert (store, &iter, pos);
|
||||
gtk_list_store_set (store, &iter,
|
||||
ICON_COLUMN, pixbuf,
|
||||
DISPLAY_NAME_COLUMN, display_name,
|
||||
ICON_COLUMN, NULL,
|
||||
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
|
||||
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
|
||||
DATA_COLUMN, gtk_file_path_copy (bookmarks->data),
|
||||
IS_FOLDER_COLUMN, FALSE,
|
||||
-1);
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
g_free (display_name);
|
||||
set_info_for_path_at_iter (button, bookmarks->data, &iter);
|
||||
|
||||
button->priv->n_bookmarks++;
|
||||
bookmarks = bookmarks->next;
|
||||
@@ -1501,8 +1788,6 @@ model_update_current_folder (GtkFileChooserButton *button,
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
gint pos;
|
||||
GdkPixbuf *pixbuf;
|
||||
gchar *display_name;
|
||||
|
||||
if (!path)
|
||||
return;
|
||||
@@ -1518,6 +1803,7 @@ model_update_current_folder (GtkFileChooserButton *button,
|
||||
DISPLAY_NAME_COLUMN, NULL,
|
||||
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER_SEPARATOR,
|
||||
DATA_COLUMN, NULL,
|
||||
IS_FOLDER_COLUMN, FALSE,
|
||||
-1);
|
||||
button->priv->has_current_folder_separator = TRUE;
|
||||
}
|
||||
@@ -1534,19 +1820,14 @@ model_update_current_folder (GtkFileChooserButton *button,
|
||||
model_free_row_data (button, &iter);
|
||||
}
|
||||
|
||||
pixbuf = gtk_file_system_render_icon (button->priv->fs, path,
|
||||
GTK_WIDGET (button),
|
||||
button->priv->icon_size, NULL);
|
||||
display_name = get_display_name_for_path (button->priv->fs, path);
|
||||
gtk_list_store_set (store, &iter,
|
||||
ICON_COLUMN, pixbuf,
|
||||
DISPLAY_NAME_COLUMN, display_name,
|
||||
ICON_COLUMN, NULL,
|
||||
DISPLAY_NAME_COLUMN, _(FALLBACK_DISPLAY_NAME),
|
||||
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
|
||||
DATA_COLUMN, gtk_file_path_copy (path),
|
||||
IS_FOLDER_COLUMN, FALSE,
|
||||
-1);
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
g_free (display_name);
|
||||
set_info_for_path_at_iter (button, path, &iter);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@@ -1565,6 +1846,7 @@ model_add_other (GtkFileChooserButton *button)
|
||||
DISPLAY_NAME_COLUMN, NULL,
|
||||
TYPE_COLUMN, ROW_TYPE_OTHER_SEPARATOR,
|
||||
DATA_COLUMN, NULL,
|
||||
IS_FOLDER_COLUMN, FALSE,
|
||||
-1);
|
||||
button->priv->has_other_separator = TRUE;
|
||||
pos++;
|
||||
@@ -1575,6 +1857,7 @@ model_add_other (GtkFileChooserButton *button)
|
||||
DISPLAY_NAME_COLUMN, _("Other..."),
|
||||
TYPE_COLUMN, ROW_TYPE_OTHER,
|
||||
DATA_COLUMN, NULL,
|
||||
IS_FOLDER_COLUMN, FALSE,
|
||||
-1);
|
||||
}
|
||||
|
||||
@@ -1608,42 +1891,17 @@ model_remove_rows (GtkFileChooserButton *button,
|
||||
static inline gboolean
|
||||
test_if_path_is_visible (GtkFileSystem *fs,
|
||||
const GtkFilePath *path,
|
||||
gboolean local_only)
|
||||
gboolean local_only,
|
||||
gboolean is_folder)
|
||||
{
|
||||
GtkFilePath *parent_path;
|
||||
GtkFileFolder *folder;
|
||||
GtkFileInfo *info;
|
||||
|
||||
if (!path)
|
||||
return FALSE;
|
||||
|
||||
if (local_only && !gtk_file_system_path_is_local (fs, path))
|
||||
return FALSE;
|
||||
|
||||
parent_path = NULL;
|
||||
gtk_file_system_get_parent (fs, path, &parent_path, NULL);
|
||||
|
||||
folder = gtk_file_system_get_folder (fs, parent_path ? parent_path : path,
|
||||
GTK_FILE_INFO_IS_FOLDER, NULL);
|
||||
gtk_file_path_free (parent_path);
|
||||
|
||||
if (folder)
|
||||
{
|
||||
info = gtk_file_folder_get_info (folder, path, NULL);
|
||||
g_object_unref (folder);
|
||||
}
|
||||
else
|
||||
info = NULL;
|
||||
|
||||
if (!info)
|
||||
if (!is_folder)
|
||||
return FALSE;
|
||||
else if (!gtk_file_info_get_is_folder (info))
|
||||
{
|
||||
gtk_file_info_free (info);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gtk_file_info_free (info);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1657,7 +1915,7 @@ filter_model_visible_func (GtkTreeModel *model,
|
||||
GtkFileChooserButtonPrivate *priv = button->priv;
|
||||
gchar type;
|
||||
gpointer data;
|
||||
gboolean local_only, retval;
|
||||
gboolean local_only, retval, is_folder;
|
||||
|
||||
type = ROW_TYPE_INVALID;
|
||||
data = NULL;
|
||||
@@ -1666,6 +1924,7 @@ filter_model_visible_func (GtkTreeModel *model,
|
||||
gtk_tree_model_get (model, iter,
|
||||
TYPE_COLUMN, &type,
|
||||
DATA_COLUMN, &data,
|
||||
IS_FOLDER_COLUMN, &is_folder,
|
||||
-1);
|
||||
|
||||
switch (type)
|
||||
@@ -1676,7 +1935,7 @@ filter_model_visible_func (GtkTreeModel *model,
|
||||
case ROW_TYPE_SPECIAL:
|
||||
case ROW_TYPE_SHORTCUT:
|
||||
case ROW_TYPE_BOOKMARK:
|
||||
retval = test_if_path_is_visible (priv->fs, data, local_only);
|
||||
retval = test_if_path_is_visible (priv->fs, data, local_only, is_folder);
|
||||
break;
|
||||
case ROW_TYPE_VOLUME:
|
||||
{
|
||||
@@ -1824,6 +2083,43 @@ update_combo_box (GtkFileChooserButton *button)
|
||||
}
|
||||
|
||||
/* Button */
|
||||
static void
|
||||
update_label_get_info_cb (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *info,
|
||||
const GError *error,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkFileChooserButton *button = data;
|
||||
GtkFileChooserButtonPrivate *priv = button->priv;
|
||||
|
||||
if (handle != priv->update_button_handle)
|
||||
goto out;
|
||||
|
||||
priv->update_button_handle = NULL;
|
||||
|
||||
if (cancelled || error)
|
||||
goto out;
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (priv->label), gtk_file_info_get_display_name (info));
|
||||
|
||||
pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (priv->image),
|
||||
priv->icon_size, NULL);
|
||||
if (!pixbuf)
|
||||
pixbuf = gtk_icon_theme_load_icon (get_icon_theme (GTK_WIDGET (priv->image)),
|
||||
FALLBACK_ICON_NAME,
|
||||
priv->icon_size, 0, NULL);
|
||||
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
out:
|
||||
g_object_unref (button);
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static void
|
||||
update_label_and_image (GtkFileChooserButton *button)
|
||||
{
|
||||
@@ -1836,11 +2132,10 @@ update_label_and_image (GtkFileChooserButton *button)
|
||||
label_text = NULL;
|
||||
pixbuf = NULL;
|
||||
|
||||
if (paths)
|
||||
if (paths && paths->data)
|
||||
{
|
||||
GtkFilePath *path, *parent_path;
|
||||
GtkFileSystemVolume *volume;
|
||||
GtkFileFolder *folder;
|
||||
GtkFilePath *path;
|
||||
GtkFileSystemVolume *volume = NULL;
|
||||
|
||||
path = paths->data;
|
||||
|
||||
@@ -1869,32 +2164,14 @@ update_label_and_image (GtkFileChooserButton *button)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!pixbuf)
|
||||
pixbuf = gtk_file_system_render_icon (priv->fs, path,
|
||||
GTK_WIDGET (button),
|
||||
priv->icon_size, NULL);
|
||||
if (priv->update_button_handle)
|
||||
gtk_file_system_cancel_operation (priv->update_button_handle);
|
||||
|
||||
parent_path = NULL;
|
||||
gtk_file_system_get_parent (priv->fs, path, &parent_path, NULL);
|
||||
|
||||
folder = gtk_file_system_get_folder (priv->fs,
|
||||
parent_path ? parent_path : path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME, NULL);
|
||||
gtk_file_path_free (parent_path);
|
||||
|
||||
if (folder)
|
||||
{
|
||||
GtkFileInfo *info;
|
||||
|
||||
info = gtk_file_folder_get_info (folder, path, NULL);
|
||||
g_object_unref (folder);
|
||||
|
||||
if (info)
|
||||
{
|
||||
label_text = g_strdup (gtk_file_info_get_display_name (info));
|
||||
gtk_file_info_free (info);
|
||||
}
|
||||
}
|
||||
priv->update_button_handle =
|
||||
gtk_file_system_get_info (priv->fs, path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_ICON,
|
||||
update_label_get_info_cb,
|
||||
g_object_ref (button));
|
||||
|
||||
out:
|
||||
gtk_file_paths_free (paths);
|
||||
@@ -1907,15 +2184,6 @@ update_label_and_image (GtkFileChooserButton *button)
|
||||
}
|
||||
else
|
||||
gtk_label_set_text (GTK_LABEL (priv->label), _(FALLBACK_DISPLAY_NAME));
|
||||
|
||||
if (!pixbuf)
|
||||
pixbuf = gtk_icon_theme_load_icon (get_icon_theme (GTK_WIDGET (button)),
|
||||
FALLBACK_ICON_NAME,
|
||||
priv->icon_size, 0, NULL);
|
||||
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -129,6 +129,7 @@ gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog)
|
||||
dialog->priv->default_height = -1;
|
||||
dialog->priv->resize_horizontally = TRUE;
|
||||
dialog->priv->resize_vertically = TRUE;
|
||||
dialog->priv->response_requested = FALSE;
|
||||
|
||||
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
|
||||
|
||||
@@ -355,6 +356,39 @@ file_chooser_widget_default_size_changed (GtkWidget *widget,
|
||||
else
|
||||
file_chooser_widget_default_unrealized_size_changed (widget, dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
file_chooser_widget_response_requested (GtkWidget *widget,
|
||||
GtkFileChooserDialog *dialog)
|
||||
{
|
||||
GList *children, *l;
|
||||
|
||||
/* There probably isn't a default widget, so make things easier for the
|
||||
* programmer by looking for a reasonable button on our own.
|
||||
*/
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area));
|
||||
|
||||
for (l = children; l; l = l->next)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
int response_id;
|
||||
|
||||
widget = GTK_WIDGET (l->data);
|
||||
response_id = gtk_dialog_get_response_for_widget (GTK_DIALOG (dialog), widget);
|
||||
if (response_id == GTK_RESPONSE_ACCEPT
|
||||
|| response_id == GTK_RESPONSE_OK
|
||||
|| response_id == GTK_RESPONSE_YES
|
||||
|| response_id == GTK_RESPONSE_APPLY)
|
||||
{
|
||||
dialog->priv->response_requested = TRUE;
|
||||
gtk_widget_activate (widget); /* Should we gtk_dialog_response (dialog, response_id) instead? */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
}
|
||||
|
||||
static GObject*
|
||||
gtk_file_chooser_dialog_constructor (GType type,
|
||||
@@ -382,6 +416,8 @@ gtk_file_chooser_dialog_constructor (GType type,
|
||||
G_CALLBACK (file_chooser_widget_file_activated), object);
|
||||
g_signal_connect (priv->widget, "default-size-changed",
|
||||
G_CALLBACK (file_chooser_widget_default_size_changed), object);
|
||||
g_signal_connect (priv->widget, "response-requested",
|
||||
G_CALLBACK (file_chooser_widget_response_requested), object);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox), priv->widget, TRUE, TRUE, 0);
|
||||
|
||||
@@ -550,8 +586,11 @@ response_cb (GtkDialog *dialog,
|
||||
|| response_id == GTK_RESPONSE_APPLY))
|
||||
return;
|
||||
|
||||
if (!_gtk_file_chooser_embed_should_respond (GTK_FILE_CHOOSER_EMBED (priv->widget)))
|
||||
g_signal_stop_emission_by_name (dialog, "response");
|
||||
if (!priv->response_requested && !_gtk_file_chooser_embed_should_respond (GTK_FILE_CHOOSER_EMBED (priv->widget)))
|
||||
{
|
||||
g_signal_stop_emission_by_name (dialog, "response");
|
||||
priv->response_requested = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
|
||||
@@ -35,6 +35,8 @@ static gboolean delegate_should_respond (GtkFileChooserEmbed *chooser_embe
|
||||
static void delegate_initial_focus (GtkFileChooserEmbed *chooser_embed);
|
||||
static void delegate_default_size_changed (GtkFileChooserEmbed *chooser_embed,
|
||||
gpointer data);
|
||||
static void delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
|
||||
gpointer data);
|
||||
|
||||
static GtkFileChooserEmbed *
|
||||
get_delegate (GtkFileChooserEmbed *receiver)
|
||||
@@ -81,6 +83,8 @@ _gtk_file_chooser_embed_set_delegate (GtkFileChooserEmbed *receiver,
|
||||
|
||||
g_signal_connect (delegate, "default_size_changed",
|
||||
G_CALLBACK (delegate_default_size_changed), receiver);
|
||||
g_signal_connect (delegate, "response_requested",
|
||||
G_CALLBACK (delegate_response_requested), receiver);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +124,13 @@ delegate_default_size_changed (GtkFileChooserEmbed *chooser_embed,
|
||||
g_signal_emit_by_name (data, "default-size-changed");
|
||||
}
|
||||
|
||||
static void
|
||||
delegate_response_requested (GtkFileChooserEmbed *chooser_embed,
|
||||
gpointer data)
|
||||
{
|
||||
g_signal_emit_by_name (data, "response-requested");
|
||||
}
|
||||
|
||||
|
||||
/* publicly callable functions */
|
||||
|
||||
@@ -160,6 +171,13 @@ gtk_file_chooser_embed_class_init (gpointer g_iface)
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
g_signal_new (_("response-requested"),
|
||||
iface_type,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkFileChooserEmbedIface, response_requested),
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -53,6 +53,7 @@ struct _GtkFileChooserEmbedIface
|
||||
/* Signals
|
||||
*/
|
||||
void (*default_size_changed) (GtkFileChooserEmbed *chooser_embed);
|
||||
void (*response_requested) (GtkFileChooserEmbed *chooser_embed);
|
||||
};
|
||||
|
||||
GType _gtk_file_chooser_embed_get_type (void) G_GNUC_CONST;
|
||||
|
||||
@@ -55,6 +55,7 @@ struct _GtkFileChooserEntry
|
||||
GSource *load_directory_idle;
|
||||
|
||||
GtkFileFolder *current_folder;
|
||||
GtkFileSystemHandle *load_folder_handle;
|
||||
|
||||
GtkListStore *completion_store;
|
||||
|
||||
@@ -75,6 +76,7 @@ static void gtk_file_chooser_entry_iface_init (GtkEditableClass *iface);
|
||||
static void gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry);
|
||||
|
||||
static void gtk_file_chooser_entry_finalize (GObject *object);
|
||||
static void gtk_file_chooser_entry_dispose (GObject *object);
|
||||
static gboolean gtk_file_chooser_entry_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
static void gtk_file_chooser_entry_activate (GtkEntry *entry);
|
||||
@@ -156,6 +158,7 @@ gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class)
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->finalize = gtk_file_chooser_entry_finalize;
|
||||
gobject_class->dispose = gtk_file_chooser_entry_dispose;
|
||||
|
||||
widget_class->focus = gtk_file_chooser_entry_focus;
|
||||
|
||||
@@ -209,8 +212,29 @@ gtk_file_chooser_entry_finalize (GObject *object)
|
||||
{
|
||||
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object);
|
||||
|
||||
gtk_file_path_free (chooser_entry->base_folder);
|
||||
gtk_file_path_free (chooser_entry->current_folder_path);
|
||||
g_free (chooser_entry->file_part);
|
||||
|
||||
parent_class->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_entry_dispose (GObject *object)
|
||||
{
|
||||
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object);
|
||||
|
||||
if (chooser_entry->completion_store)
|
||||
g_object_unref (chooser_entry->completion_store);
|
||||
{
|
||||
g_object_unref (chooser_entry->completion_store);
|
||||
chooser_entry->completion_store = NULL;
|
||||
}
|
||||
|
||||
if (chooser_entry->load_folder_handle)
|
||||
{
|
||||
gtk_file_system_cancel_operation (chooser_entry->load_folder_handle);
|
||||
chooser_entry->load_folder_handle = NULL;
|
||||
}
|
||||
|
||||
if (chooser_entry->current_folder)
|
||||
{
|
||||
@@ -219,16 +243,16 @@ gtk_file_chooser_entry_finalize (GObject *object)
|
||||
g_signal_handlers_disconnect_by_func (chooser_entry->current_folder,
|
||||
G_CALLBACK (files_deleted_cb), chooser_entry);
|
||||
g_object_unref (chooser_entry->current_folder);
|
||||
chooser_entry->current_folder = NULL;
|
||||
}
|
||||
|
||||
if (chooser_entry->file_system)
|
||||
g_object_unref (chooser_entry->file_system);
|
||||
{
|
||||
g_object_unref (chooser_entry->file_system);
|
||||
chooser_entry->file_system = NULL;
|
||||
}
|
||||
|
||||
gtk_file_path_free (chooser_entry->base_folder);
|
||||
gtk_file_path_free (chooser_entry->current_folder_path);
|
||||
g_free (chooser_entry->file_part);
|
||||
|
||||
parent_class->finalize (object);
|
||||
parent_class->dispose (object);
|
||||
}
|
||||
|
||||
/* Match functions for the GtkEntryCompletion */
|
||||
@@ -599,6 +623,41 @@ files_deleted_cb (GtkFileSystem *file_system,
|
||||
/* FIXME: gravy... */
|
||||
}
|
||||
|
||||
static void
|
||||
load_directory_get_folder_callback (GtkFileSystemHandle *handle,
|
||||
GtkFileFolder *folder,
|
||||
const GError *error,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
GtkFileChooserEntry *chooser_entry = data;
|
||||
|
||||
if (handle != chooser_entry->load_folder_handle)
|
||||
goto out;
|
||||
|
||||
chooser_entry->load_folder_handle = NULL;
|
||||
|
||||
if (cancelled || error)
|
||||
goto out;
|
||||
|
||||
chooser_entry->current_folder = folder;
|
||||
g_signal_connect (chooser_entry->current_folder, "files-added",
|
||||
G_CALLBACK (files_added_cb), chooser_entry);
|
||||
g_signal_connect (chooser_entry->current_folder, "files-removed",
|
||||
G_CALLBACK (files_deleted_cb), chooser_entry);
|
||||
|
||||
chooser_entry->completion_store = gtk_list_store_new (N_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
GTK_TYPE_FILE_PATH);
|
||||
|
||||
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
|
||||
GTK_TREE_MODEL (chooser_entry->completion_store));
|
||||
|
||||
out:
|
||||
g_object_unref (chooser_entry);
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
load_directory_callback (GtkFileChooserEntry *chooser_entry)
|
||||
{
|
||||
@@ -621,38 +680,15 @@ load_directory_callback (GtkFileChooserEntry *chooser_entry)
|
||||
g_assert (chooser_entry->completion_store == NULL);
|
||||
|
||||
/* Load the folder */
|
||||
chooser_entry->current_folder = gtk_file_system_get_folder (chooser_entry->file_system,
|
||||
chooser_entry->current_folder_path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_FOLDER,
|
||||
NULL); /* NULL-GError */
|
||||
if (chooser_entry->load_folder_handle)
|
||||
gtk_file_system_cancel_operation (chooser_entry->load_folder_handle);
|
||||
|
||||
/* There is no folder by that name */
|
||||
if (!chooser_entry->current_folder)
|
||||
goto done;
|
||||
g_signal_connect (chooser_entry->current_folder, "files-added",
|
||||
G_CALLBACK (files_added_cb), chooser_entry);
|
||||
g_signal_connect (chooser_entry->current_folder, "files-removed",
|
||||
G_CALLBACK (files_deleted_cb), chooser_entry);
|
||||
|
||||
chooser_entry->completion_store = gtk_list_store_new (N_COLUMNS,
|
||||
G_TYPE_STRING,
|
||||
GTK_TYPE_FILE_PATH);
|
||||
|
||||
if (chooser_entry->file_part_pos != -1)
|
||||
{
|
||||
gtk_file_folder_list_children (chooser_entry->current_folder,
|
||||
&child_paths,
|
||||
NULL); /* NULL-GError */
|
||||
if (child_paths)
|
||||
{
|
||||
update_current_folder_files (chooser_entry, child_paths);
|
||||
add_completion_idle (chooser_entry);
|
||||
gtk_file_paths_free (child_paths);
|
||||
}
|
||||
}
|
||||
|
||||
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)),
|
||||
GTK_TREE_MODEL (chooser_entry->completion_store));
|
||||
chooser_entry->load_folder_handle =
|
||||
gtk_file_system_get_folder (chooser_entry->file_system,
|
||||
chooser_entry->current_folder_path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_FOLDER,
|
||||
load_directory_get_folder_callback,
|
||||
g_object_ref (chooser_entry));
|
||||
|
||||
done:
|
||||
|
||||
@@ -1039,5 +1075,27 @@ _gtk_file_chooser_entry_get_action (GtkFileChooserEntry *chooser_entry)
|
||||
return chooser_entry->action;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
|
||||
const GtkFilePath *path)
|
||||
{
|
||||
gboolean retval = FALSE;
|
||||
|
||||
if (chooser_entry->current_folder)
|
||||
{
|
||||
GtkFileInfo *file_info;
|
||||
|
||||
file_info = gtk_file_folder_get_info (chooser_entry->current_folder,
|
||||
path, NULL);
|
||||
if (file_info)
|
||||
{
|
||||
retval = gtk_file_info_get_is_folder (file_info);
|
||||
gtk_file_info_free (file_info);
|
||||
}
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#define __GTK_FILE_CHOOSER_ENTRY_C__
|
||||
#include "gtkaliasdef.c"
|
||||
|
||||
@@ -46,6 +46,8 @@ void _gtk_file_chooser_entry_set_file_part (GtkFileChooserEnt
|
||||
const gchar *file_part);
|
||||
const GtkFilePath *_gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry);
|
||||
const gchar * _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry);
|
||||
gboolean _gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
|
||||
const GtkFilePath *path);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ struct _GtkFileChooserDialogPrivate
|
||||
gint default_height;
|
||||
gboolean resize_horizontally;
|
||||
gboolean resize_vertically;
|
||||
gboolean response_requested;
|
||||
};
|
||||
|
||||
|
||||
@@ -187,6 +188,17 @@ struct _GtkFileChooserDefault
|
||||
|
||||
GtkTreeModelSort *sort_model;
|
||||
|
||||
/* Handles */
|
||||
GSList *loading_shortcuts;
|
||||
GSList *reload_icon_handles;
|
||||
GtkFileSystemHandle *file_list_drag_data_received_handle;
|
||||
GtkFileSystemHandle *update_current_folder_handle;
|
||||
GtkFileSystemHandle *show_and_select_paths_handle;
|
||||
GtkFileSystemHandle *should_respond_get_info_handle;
|
||||
GtkFileSystemHandle *update_from_entry_handle;
|
||||
GtkFileSystemHandle *shortcuts_activate_iter_handle;
|
||||
GSList *pending_handles;
|
||||
|
||||
LoadState load_state;
|
||||
ReloadState reload_state;
|
||||
guint load_timeout_id;
|
||||
@@ -267,9 +279,10 @@ struct _GtkFileSystemModel
|
||||
|
||||
GSList *idle_clears;
|
||||
GSource *idle_clear_source;
|
||||
GSource *idle_finished_loading_source;
|
||||
|
||||
gushort max_depth;
|
||||
|
||||
GSList *pending_handles;
|
||||
|
||||
guint show_hidden : 1;
|
||||
guint show_folders : 1;
|
||||
@@ -300,6 +313,7 @@ struct _FileModelNode
|
||||
guint is_visible : 1;
|
||||
guint loaded : 1;
|
||||
guint idle_clear : 1;
|
||||
guint load_pending : 1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "gtkmodules.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalias.h"
|
||||
#include "gtkstock.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -35,6 +36,7 @@ struct _GtkFileInfo
|
||||
gchar *display_name;
|
||||
gchar *display_key;
|
||||
gchar *mime_type;
|
||||
gchar *icon_name;
|
||||
guint is_folder : 1;
|
||||
guint is_hidden : 1;
|
||||
};
|
||||
@@ -89,6 +91,10 @@ gtk_file_info_copy (GtkFileInfo *info)
|
||||
new_info->display_name = g_strdup (new_info->display_name);
|
||||
if (new_info->mime_type)
|
||||
new_info->mime_type = g_strdup (new_info->mime_type);
|
||||
if (new_info->icon_name)
|
||||
new_info->icon_name = g_strdup (new_info->icon_name);
|
||||
if (new_info->display_key)
|
||||
new_info->display_key = g_strdup (new_info->display_key);
|
||||
|
||||
return new_info;
|
||||
}
|
||||
@@ -104,6 +110,8 @@ gtk_file_info_free (GtkFileInfo *info)
|
||||
g_free (info->mime_type);
|
||||
if (info->display_key)
|
||||
g_free (info->display_key);
|
||||
if (info->icon_name)
|
||||
g_free (info->icon_name);
|
||||
|
||||
g_free (info);
|
||||
}
|
||||
@@ -251,6 +259,171 @@ gtk_file_info_set_size (GtkFileInfo *info,
|
||||
info->size = size;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_file_info_set_icon_name (GtkFileInfo *info,
|
||||
const gchar *icon_name)
|
||||
{
|
||||
g_return_if_fail (info != NULL);
|
||||
|
||||
if (info->icon_name)
|
||||
g_free (info->icon_name);
|
||||
|
||||
info->icon_name = g_strdup (icon_name);
|
||||
}
|
||||
|
||||
G_CONST_RETURN gchar *
|
||||
gtk_file_info_get_icon_name (const GtkFileInfo *info)
|
||||
{
|
||||
g_return_val_if_fail (info != NULL, NULL);
|
||||
|
||||
return info->icon_name;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
gtk_file_info_render_icon (const GtkFileInfo *info,
|
||||
GtkWidget *widget,
|
||||
gint pixel_size,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
g_return_val_if_fail (info != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
|
||||
if (info->icon_name)
|
||||
{
|
||||
if (g_path_is_absolute (info->icon_name))
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size (info->icon_name,
|
||||
pixel_size,
|
||||
pixel_size,
|
||||
NULL);
|
||||
else
|
||||
{
|
||||
GtkIconTheme *icon_theme;
|
||||
|
||||
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
|
||||
pixbuf = gtk_icon_theme_load_icon (icon_theme, info->icon_name,
|
||||
pixel_size, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pixbuf)
|
||||
{
|
||||
/* load a fallback icon */
|
||||
pixbuf = gtk_widget_render_icon (widget, GTK_STOCK_FILE, GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
|
||||
if (!pixbuf && error)
|
||||
g_set_error (error,
|
||||
GTK_FILE_SYSTEM_ERROR,
|
||||
GTK_FILE_SYSTEM_ERROR_FAILED,
|
||||
_("Could not get a stock icon for %s\n"),
|
||||
info->icon_name);
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* GtkFileSystemHandle *
|
||||
*****************************************/
|
||||
|
||||
static void gtk_file_system_handle_init (GtkFileSystemHandle *handle);
|
||||
static void gtk_file_system_handle_class_init (GtkFileSystemHandleClass *klass);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CANCELLED
|
||||
};
|
||||
|
||||
GType
|
||||
gtk_file_system_handle_get_type (void)
|
||||
{
|
||||
static GType file_system_handle_type = 0;
|
||||
|
||||
if (!file_system_handle_type)
|
||||
{
|
||||
static const GTypeInfo file_system_handle_info =
|
||||
{
|
||||
sizeof (GtkFileSystemHandleClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gtk_file_system_handle_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GtkFileSystemHandle),
|
||||
0,
|
||||
(GInstanceInitFunc) gtk_file_system_handle_init,
|
||||
};
|
||||
|
||||
file_system_handle_type = g_type_register_static (G_TYPE_OBJECT,
|
||||
I_("GtkFileSystemHandle"),
|
||||
&file_system_handle_info, 0);
|
||||
}
|
||||
|
||||
return file_system_handle_type;
|
||||
}
|
||||
|
||||
#if 0
|
||||
GtkFileSystemHandle *
|
||||
gtk_file_system_handle_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_FILE_SYSTEM_HANDLE, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gtk_file_system_handle_init (GtkFileSystemHandle *handle)
|
||||
{
|
||||
handle->file_system = NULL;
|
||||
handle->cancelled = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_system_handle_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_system_handle_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkFileSystemHandle *handle = GTK_FILE_SYSTEM_HANDLE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CANCELLED:
|
||||
g_value_set_boolean (value, handle->cancelled);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_system_handle_class_init (GtkFileSystemHandleClass *klass)
|
||||
{
|
||||
GObjectClass *o_class;
|
||||
|
||||
o_class = (GObjectClass *)klass;
|
||||
o_class->set_property = gtk_file_system_handle_set_property;
|
||||
o_class->get_property = gtk_file_system_handle_get_property;
|
||||
|
||||
g_object_class_install_property (o_class,
|
||||
PROP_CANCELLED,
|
||||
g_param_spec_boolean ("cancelled",
|
||||
P_("Cancelled"),
|
||||
P_("Whether or not the operation has been successfully cancelled"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* GtkFileSystem *
|
||||
@@ -315,29 +488,53 @@ gtk_file_system_list_volumes (GtkFileSystem *file_system)
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_volumes (file_system);
|
||||
}
|
||||
|
||||
GtkFileFolder *
|
||||
gtk_file_system_get_folder (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GError **error)
|
||||
GtkFileSystemHandle *
|
||||
gtk_file_system_get_folder (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GtkFileSystemGetFolderCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_folder (file_system, path, types, error);
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_folder (file_system, path, types, callback, data);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_file_system_create_folder(GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GError **error)
|
||||
GtkFileSystemHandle *
|
||||
gtk_file_system_get_info (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GtkFileSystemGetInfoCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
|
||||
g_return_val_if_fail (path != NULL, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->create_folder (file_system, path, error);
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_info (file_system, path, types, callback, data);
|
||||
}
|
||||
|
||||
GtkFileSystemHandle *
|
||||
gtk_file_system_create_folder (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileSystemCreateFolderCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->create_folder (file_system, path, callback, data);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_file_system_cancel_operation (GtkFileSystemHandle *handle)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FILE_SYSTEM_HANDLE (handle));
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (handle->file_system)->cancel_operation (handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,16 +630,18 @@ gtk_file_system_volume_get_is_mounted (GtkFileSystem *file_system,
|
||||
*
|
||||
* Return value: TRUE if the @volume was mounted successfully, FALSE otherwise.
|
||||
**/
|
||||
gboolean
|
||||
gtk_file_system_volume_mount (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GError **error)
|
||||
/* FIXME XXX: update documentation above */
|
||||
GtkFileSystemHandle *
|
||||
gtk_file_system_volume_mount (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GtkFileSystemVolumeMountCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
|
||||
g_return_val_if_fail (volume != NULL, FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (volume != NULL, NULL);
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_mount (file_system, volume, error);
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_mount (file_system, volume, callback, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,17 +685,53 @@ gtk_file_system_volume_render_icon (GtkFileSystem *file_system,
|
||||
gint pixel_size,
|
||||
GError **error)
|
||||
{
|
||||
gchar *icon_name;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (volume != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
g_return_val_if_fail (pixel_size > 0, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_render_icon (file_system,
|
||||
volume,
|
||||
widget,
|
||||
pixel_size,
|
||||
error);
|
||||
icon_name = gtk_file_system_volume_get_icon_name (file_system, volume,
|
||||
error);
|
||||
if (!icon_name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget)),
|
||||
icon_name, pixel_size, 0, NULL);
|
||||
g_free (icon_name);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_system_volume_get_icon_name:
|
||||
* @file_system: a #GtkFileSystem
|
||||
* @volume: a #GtkFileSystemVolume
|
||||
* @error: location to store error, or %NULL
|
||||
*
|
||||
* Gets an icon name suitable for a #GtkFileSystemVolume.
|
||||
*
|
||||
* Return value: An icon name which can be used for rendering an icon for
|
||||
* this volume, or %NULL if no icon name could be found. In the latter
|
||||
* case, the @error value will be set as appropriate.
|
||||
**/
|
||||
gchar *
|
||||
gtk_file_system_volume_get_icon_name (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (volume != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_get_icon_name (file_system,
|
||||
volume,
|
||||
error);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -683,21 +918,6 @@ gtk_file_system_path_is_local (GtkFileSystem *file_system,
|
||||
return result;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
gtk_file_system_render_icon (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkWidget *widget,
|
||||
gint pixel_size,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
g_return_val_if_fail (pixel_size > 0, NULL);
|
||||
|
||||
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->render_icon (file_system, path, widget, pixel_size, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_system_insert_bookmark:
|
||||
* @file_system: a #GtkFileSystem
|
||||
|
||||
@@ -55,7 +55,8 @@ typedef enum {
|
||||
GTK_FILE_INFO_MIME_TYPE = 1 << 3,
|
||||
GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
|
||||
GTK_FILE_INFO_SIZE = 1 << 5,
|
||||
GTK_FILE_INFO_ALL = (1 << 6) - 1
|
||||
GTK_FILE_INFO_ICON = 1 << 6,
|
||||
GTK_FILE_INFO_ALL = (1 << 7) - 1
|
||||
} GtkFileInfoType;
|
||||
|
||||
/* GError enumeration for GtkFileSystem
|
||||
@@ -106,6 +107,43 @@ gint64 gtk_file_info_get_size (const GtkFileInfo *in
|
||||
void gtk_file_info_set_size (GtkFileInfo *info,
|
||||
gint64 size);
|
||||
|
||||
void gtk_file_info_set_icon_name (GtkFileInfo *info,
|
||||
const gchar *con_name);
|
||||
G_CONST_RETURN gchar *gtk_file_info_get_icon_name (const GtkFileInfo *info);
|
||||
GdkPixbuf *gtk_file_info_render_icon (const GtkFileInfo *info,
|
||||
GtkWidget *widget,
|
||||
gint pixel_size,
|
||||
GError **error);
|
||||
|
||||
/* GtkFileSystemHandle
|
||||
*/
|
||||
|
||||
#define GTK_TYPE_FILE_SYSTEM_HANDLE (gtk_file_system_handle_get_type ())
|
||||
#define GTK_FILE_SYSTEM_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandle))
|
||||
#define GTK_IS_FILE_SYSTEM_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE))
|
||||
#define GTK_FILE_SYSTEM_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandleUnixClass))
|
||||
#define GTK_IS_FILE_SYSTEM_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_SYSTEM_HANDLE))
|
||||
#define GTK_FILE_SYSTEM_HANDLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandleClass))
|
||||
|
||||
typedef struct _GtkFileSystemHandle GtkFileSystemHandle;
|
||||
typedef struct _GtkFileSystemHandleClass GtkFileSystemHandleClass;
|
||||
|
||||
struct _GtkFileSystemHandle
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkFileSystem *file_system;
|
||||
|
||||
guint cancelled : 1;
|
||||
};
|
||||
|
||||
struct _GtkFileSystemHandleClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gtk_file_system_handle_get_type (void);
|
||||
|
||||
/* The base GtkFileSystem interface
|
||||
*/
|
||||
#define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
|
||||
@@ -113,6 +151,29 @@ void gtk_file_info_set_size (GtkFileInfo *in
|
||||
#define GTK_IS_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
|
||||
#define GTK_FILE_SYSTEM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
|
||||
|
||||
/* Callbacks for the asynchronous GtkFileSystem operations
|
||||
*/
|
||||
|
||||
typedef void (* GtkFileSystemGetInfoCallback) (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *file_info,
|
||||
const GError *error,
|
||||
gpointer data);
|
||||
typedef void (* GtkFileSystemGetFolderCallback) (GtkFileSystemHandle *handle,
|
||||
GtkFileFolder *folder,
|
||||
const GError *error,
|
||||
gpointer data);
|
||||
typedef void (* GtkFileSystemCreateFolderCallback) (GtkFileSystemHandle *handle,
|
||||
const GtkFilePath *path,
|
||||
const GError *error,
|
||||
gpointer data);
|
||||
typedef void (* GtkFileSystemVolumeMountCallback) (GtkFileSystemHandle *handle,
|
||||
GtkFileSystemVolume *volume,
|
||||
const GError *error,
|
||||
gpointer data);
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
struct _GtkFileSystemIface
|
||||
{
|
||||
GTypeInterface base_iface;
|
||||
@@ -123,13 +184,22 @@ struct _GtkFileSystemIface
|
||||
GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path);
|
||||
|
||||
GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GError **error);
|
||||
gboolean (*create_folder) (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GError **error);
|
||||
GtkFileSystemHandle * (*get_folder) (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GtkFileSystemGetFolderCallback callback,
|
||||
gpointer data);
|
||||
GtkFileSystemHandle * (*get_info) (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GtkFileSystemGetInfoCallback callback,
|
||||
gpointer data);
|
||||
GtkFileSystemHandle * (*create_folder) (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileSystemCreateFolderCallback callback,
|
||||
gpointer data);
|
||||
|
||||
void (*cancel_operation) (GtkFileSystemHandle *handle);
|
||||
|
||||
/* Volumes
|
||||
*/
|
||||
@@ -139,15 +209,14 @@ struct _GtkFileSystemIface
|
||||
GtkFileSystemVolume *volume);
|
||||
gboolean (*volume_get_is_mounted) (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume);
|
||||
gboolean (*volume_mount) (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GError **error);
|
||||
char * (*volume_get_display_name) (GtkFileSystem *file_system,
|
||||
GtkFileSystemHandle * (*volume_mount) (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GtkFileSystemVolumeMountCallback callback,
|
||||
gpointer data);
|
||||
char * (*volume_get_display_name) (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume);
|
||||
GdkPixbuf * (*volume_render_icon) (GtkFileSystem *file_system,
|
||||
gchar * (*volume_get_icon_name) (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GtkWidget *widget,
|
||||
gint pixel_size,
|
||||
GError **error);
|
||||
|
||||
/* Path Manipulation
|
||||
@@ -175,14 +244,6 @@ struct _GtkFileSystemIface
|
||||
GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
|
||||
const gchar *path);
|
||||
|
||||
/* Icons
|
||||
*/
|
||||
GdkPixbuf * (*render_icon) (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkWidget *widget,
|
||||
gint pixel_size,
|
||||
GError **error);
|
||||
|
||||
/* Bookmarks
|
||||
*/
|
||||
gboolean (*insert_bookmark) (GtkFileSystem *file_system,
|
||||
@@ -221,9 +282,10 @@ GtkFilePath * gtk_file_system_volume_get_base_path (GtkFileSystem
|
||||
GtkFileSystemVolume *volume);
|
||||
gboolean gtk_file_system_volume_get_is_mounted (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume);
|
||||
gboolean gtk_file_system_volume_mount (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GError **error);
|
||||
GtkFileSystemHandle *gtk_file_system_volume_mount (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GtkFileSystemVolumeMountCallback callback,
|
||||
gpointer data);
|
||||
char * gtk_file_system_volume_get_display_name (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume);
|
||||
GdkPixbuf * gtk_file_system_volume_render_icon (GtkFileSystem *file_system,
|
||||
@@ -231,18 +293,29 @@ GdkPixbuf * gtk_file_system_volume_render_icon (GtkFileSystem
|
||||
GtkWidget *widget,
|
||||
gint pixel_size,
|
||||
GError **error);
|
||||
gchar * gtk_file_system_volume_get_icon_name (GtkFileSystem *file_system,
|
||||
GtkFileSystemVolume *volume,
|
||||
GError **error);
|
||||
|
||||
gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFilePath **parent,
|
||||
GError **error);
|
||||
GtkFileFolder *gtk_file_system_get_folder (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GError **error);
|
||||
gboolean gtk_file_system_create_folder (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GError **error);
|
||||
GtkFileSystemHandle *gtk_file_system_get_folder (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GtkFileSystemGetFolderCallback callback,
|
||||
gpointer data);
|
||||
GtkFileSystemHandle *gtk_file_system_get_info (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileInfoType types,
|
||||
GtkFileSystemGetInfoCallback callback,
|
||||
gpointer data);
|
||||
GtkFileSystemHandle *gtk_file_system_create_folder (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkFileSystemCreateFolderCallback callback,
|
||||
gpointer data);
|
||||
void gtk_file_system_cancel_operation (GtkFileSystemHandle *handle);
|
||||
GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
|
||||
const GtkFilePath *base_path,
|
||||
const gchar *display_name,
|
||||
@@ -266,12 +339,6 @@ GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
|
||||
gboolean gtk_file_system_path_is_local (GtkFileSystem *filesystem,
|
||||
const GtkFilePath *path);
|
||||
|
||||
GdkPixbuf *gtk_file_system_render_icon (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
GtkWidget *widget,
|
||||
gint pixel_size,
|
||||
GError **error);
|
||||
|
||||
gboolean gtk_file_system_insert_bookmark (GtkFileSystem *file_system,
|
||||
const GtkFilePath *path,
|
||||
gint position,
|
||||
|
||||
@@ -50,6 +50,7 @@ static void gtk_file_system_model_class_init (GtkFileSystemModelClass *class);
|
||||
static void gtk_file_system_model_iface_init (GtkTreeModelIface *iface);
|
||||
static void gtk_file_system_model_init (GtkFileSystemModel *model);
|
||||
static void gtk_file_system_model_finalize (GObject *object);
|
||||
static void gtk_file_system_model_dispose (GObject *object);
|
||||
|
||||
static void drag_source_iface_init (GtkTreeDragSourceIface *iface);
|
||||
|
||||
@@ -205,6 +206,7 @@ gtk_file_system_model_class_init (GtkFileSystemModelClass *class)
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->finalize = gtk_file_system_model_finalize;
|
||||
gobject_class->dispose = gtk_file_system_model_dispose;
|
||||
|
||||
file_system_model_signals[FINISHED_LOADING] =
|
||||
g_signal_new (I_("finished-loading"),
|
||||
@@ -258,9 +260,6 @@ gtk_file_system_model_finalize (GObject *object)
|
||||
if (model->file_system)
|
||||
g_object_unref (model->file_system);
|
||||
|
||||
if (model->idle_finished_loading_source)
|
||||
g_source_destroy (model->idle_finished_loading_source);
|
||||
|
||||
children = model->roots;
|
||||
while (children)
|
||||
{
|
||||
@@ -272,6 +271,25 @@ gtk_file_system_model_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_file_system_model_dispose (GObject *object)
|
||||
{
|
||||
GtkFileSystemModel *model = GTK_FILE_SYSTEM_MODEL (object);
|
||||
|
||||
if (model->pending_handles)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
for (l = model->pending_handles; l; l = l->next)
|
||||
gtk_file_system_cancel_operation (l->data);
|
||||
g_slist_free (model->pending_handles);
|
||||
model->pending_handles = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
drag_source_iface_init (GtkTreeDragSourceIface *iface)
|
||||
{
|
||||
@@ -630,33 +648,75 @@ root_folder_finished_loading_cb (GtkFileFolder *folder,
|
||||
g_signal_emit (model, file_system_model_signals[FINISHED_LOADING], 0);
|
||||
}
|
||||
|
||||
/* Emits the "finished-loading" signal as an idle handler; see the comment in
|
||||
* _gtk_file_system_model_new()
|
||||
*/
|
||||
static gboolean
|
||||
idle_finished_loading_cb (GtkFileSystemModel *model)
|
||||
{
|
||||
GDK_THREADS_ENTER ();
|
||||
|
||||
g_signal_emit (model, file_system_model_signals[FINISHED_LOADING], 0);
|
||||
|
||||
g_source_destroy (model->idle_finished_loading_source);
|
||||
model->idle_finished_loading_source = NULL;
|
||||
|
||||
GDK_THREADS_LEAVE ();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Queues an idle handler to emit the "finished-loading" signal */
|
||||
static void
|
||||
queue_finished_loading (GtkFileSystemModel *model)
|
||||
got_root_folder_cb (GtkFileSystemHandle *handle,
|
||||
GtkFileFolder *folder,
|
||||
const GError *error,
|
||||
gpointer data)
|
||||
{
|
||||
model->idle_finished_loading_source = g_idle_source_new ();
|
||||
g_source_set_closure (model->idle_finished_loading_source,
|
||||
g_cclosure_new_object (G_CALLBACK (idle_finished_loading_cb),
|
||||
G_OBJECT (model)));
|
||||
g_source_attach (model->idle_finished_loading_source, NULL);
|
||||
GSList *roots = NULL;
|
||||
GSList *tmp_list;
|
||||
gboolean cancelled = handle->cancelled;
|
||||
GtkFileSystemModel *model = data;
|
||||
|
||||
tmp_list = g_slist_find (model->pending_handles, handle);
|
||||
if (!tmp_list)
|
||||
goto out;
|
||||
|
||||
model->pending_handles = g_slist_remove_link (model->pending_handles,
|
||||
tmp_list);
|
||||
|
||||
if (cancelled || !folder)
|
||||
goto out;
|
||||
|
||||
model->root_folder = folder;
|
||||
|
||||
if (gtk_file_folder_is_finished_loading (model->root_folder))
|
||||
g_signal_emit (model, file_system_model_signals[FINISHED_LOADING], 0);
|
||||
else
|
||||
g_signal_connect_object (model->root_folder, "finished-loading",
|
||||
G_CALLBACK (root_folder_finished_loading_cb), model, 0);
|
||||
|
||||
gtk_file_folder_list_children (model->root_folder, &roots, NULL);
|
||||
|
||||
g_signal_connect_object (model->root_folder, "deleted",
|
||||
G_CALLBACK (root_deleted_callback), model, 0);
|
||||
g_signal_connect_object (model->root_folder, "files-added",
|
||||
G_CALLBACK (root_files_added_callback), model, 0);
|
||||
g_signal_connect_object (model->root_folder, "files-changed",
|
||||
G_CALLBACK (root_files_changed_callback), model, 0);
|
||||
g_signal_connect_object (model->root_folder, "files-removed",
|
||||
G_CALLBACK (root_files_removed_callback), model, 0);
|
||||
|
||||
roots = gtk_file_paths_sort (roots);
|
||||
|
||||
for (tmp_list = roots; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
FileModelNode *node = file_model_node_new (model, tmp_list->data);
|
||||
gtk_file_path_free (tmp_list->data);
|
||||
node->is_visible = file_model_node_is_visible (model, node);
|
||||
node->next = model->roots;
|
||||
node->depth = 0;
|
||||
model->roots = node;
|
||||
|
||||
if (node->is_visible)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
iter.user_data = node;
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
|
||||
gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
}
|
||||
g_slist_free (roots);
|
||||
|
||||
model->roots = (FileModelNode *) g_slist_reverse ((GSList *)model->roots);
|
||||
|
||||
out:
|
||||
g_object_unref (model);
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,28 +751,15 @@ _gtk_file_system_model_new (GtkFileSystem *file_system,
|
||||
GError **error)
|
||||
{
|
||||
GtkFileSystemModel *model;
|
||||
GtkFileFolder *root_folder;
|
||||
GSList *roots;
|
||||
GSList *tmp_list;
|
||||
GtkFileSystemHandle *handle;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
|
||||
g_return_val_if_fail (root_path != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
/* First, try to load the folder */
|
||||
/* First, start loading the root folder */
|
||||
|
||||
types |= GTK_FILE_INFO_IS_FOLDER | GTK_FILE_INFO_IS_HIDDEN;
|
||||
|
||||
root_folder = gtk_file_system_get_folder (file_system, root_path, types, error);
|
||||
|
||||
if (!root_folder)
|
||||
return NULL;
|
||||
|
||||
if (!gtk_file_folder_list_children (root_folder, &roots, error))
|
||||
{
|
||||
g_object_unref (root_folder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Then, actually create the model and the root nodes */
|
||||
|
||||
@@ -724,39 +771,32 @@ _gtk_file_system_model_new (GtkFileSystem *file_system,
|
||||
model->max_depth = MIN (max_depth, G_MAXUSHORT);
|
||||
|
||||
model->types = types;
|
||||
model->root_folder = root_folder;
|
||||
model->root_folder = NULL;
|
||||
model->root_path = gtk_file_path_copy (root_path);
|
||||
|
||||
if (gtk_file_folder_is_finished_loading (model->root_folder))
|
||||
queue_finished_loading (model); /* done in an idle because we are being created */
|
||||
else
|
||||
g_signal_connect_object (model->root_folder, "finished-loading",
|
||||
G_CALLBACK (root_folder_finished_loading_cb), model, 0);
|
||||
model->roots = NULL;
|
||||
|
||||
g_signal_connect_object (model->root_folder, "deleted",
|
||||
G_CALLBACK (root_deleted_callback), model, 0);
|
||||
g_signal_connect_object (model->root_folder, "files-added",
|
||||
G_CALLBACK (root_files_added_callback), model, 0);
|
||||
g_signal_connect_object (model->root_folder, "files-changed",
|
||||
G_CALLBACK (root_files_changed_callback), model, 0);
|
||||
g_signal_connect_object (model->root_folder, "files-removed",
|
||||
G_CALLBACK (root_files_removed_callback), model, 0);
|
||||
|
||||
roots = gtk_file_paths_sort (roots);
|
||||
|
||||
for (tmp_list = roots; tmp_list; tmp_list = tmp_list->next)
|
||||
handle = gtk_file_system_get_folder (file_system, root_path, types,
|
||||
got_root_folder_cb,
|
||||
g_object_ref (model));
|
||||
if (!handle)
|
||||
{
|
||||
FileModelNode *node = file_model_node_new (model, tmp_list->data);
|
||||
gtk_file_path_free (tmp_list->data);
|
||||
node->is_visible = file_model_node_is_visible (model, node);
|
||||
node->next = model->roots;
|
||||
node->depth = 0;
|
||||
model->roots = node;
|
||||
}
|
||||
g_slist_free (roots);
|
||||
/* In this case got_root_folder_cb() will never be called, so we
|
||||
* need to unref model twice.
|
||||
*/
|
||||
g_object_unref (model);
|
||||
g_object_unref (model);
|
||||
|
||||
g_set_error (error,
|
||||
GTK_FILE_CHOOSER_ERROR,
|
||||
GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
|
||||
_("Could not obtain root folder"));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
model->pending_handles = g_slist_append (model->pending_handles, handle);
|
||||
|
||||
model->roots = (FileModelNode *) g_slist_reverse ((GSList *)model->roots);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -988,58 +1028,6 @@ find_child_node (GtkFileSystemModel *model,
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static FileModelNode *
|
||||
find_and_ref_path (GtkFileSystemModel *model,
|
||||
const GtkFilePath *path,
|
||||
GSList **cleanups)
|
||||
{
|
||||
GtkFilePath *parent_path;
|
||||
FileModelNode *parent_node;
|
||||
FileModelNode *child_node;
|
||||
GtkFileFolder *folder;
|
||||
|
||||
if (gtk_file_path_compare (path, model->root_path) == 0
|
||||
|| !gtk_file_system_get_parent (model->file_system, path, &parent_path, NULL))
|
||||
return NULL;
|
||||
|
||||
if (parent_path)
|
||||
{
|
||||
parent_node = find_and_ref_path (model, parent_path, cleanups);
|
||||
gtk_file_path_free (parent_path);
|
||||
}
|
||||
else
|
||||
parent_node = NULL;
|
||||
|
||||
child_node = find_child_node (model, parent_node, path);
|
||||
if (child_node)
|
||||
{
|
||||
file_model_node_ref (child_node);
|
||||
return child_node;
|
||||
}
|
||||
|
||||
folder = gtk_file_system_get_folder (model->file_system,
|
||||
path,
|
||||
model->types,
|
||||
NULL); /* NULL-GError */
|
||||
if (folder)
|
||||
{
|
||||
*cleanups = g_slist_prepend (*cleanups, folder);
|
||||
|
||||
child_node = find_child_node (model, parent_node, path);
|
||||
if (child_node)
|
||||
{
|
||||
file_model_node_ref (child_node);
|
||||
return child_node;
|
||||
}
|
||||
}
|
||||
|
||||
if (parent_node)
|
||||
unref_node_and_parents (model, parent_node);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_file_system_model_set_filter:
|
||||
@@ -1064,6 +1052,126 @@ _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
|
||||
model_refilter_all (model);
|
||||
}
|
||||
|
||||
|
||||
struct RefPathData
|
||||
{
|
||||
GtkFileSystemModel *model;
|
||||
FileModelNode *node;
|
||||
FileModelNode *parent_node;
|
||||
GSList *paths;
|
||||
GSList *cleanups;
|
||||
GtkFileSystemModelPathFunc func;
|
||||
gpointer user_data;
|
||||
};
|
||||
|
||||
/* FIXME: maybe we have to wait on finished-loading? */
|
||||
static void
|
||||
ref_path_cb (GtkFileSystemHandle *handle,
|
||||
GtkFileFolder *folder,
|
||||
const GError *error,
|
||||
gpointer data)
|
||||
{
|
||||
struct RefPathData *info = data;
|
||||
gboolean cancelled = handle->cancelled;
|
||||
|
||||
if (!g_slist_find (info->model->pending_handles, handle))
|
||||
goto out;
|
||||
|
||||
info->model->pending_handles = g_slist_remove (info->model->pending_handles, handle);
|
||||
|
||||
/* Note that !folder means that the child node was already
|
||||
* found, without using get_folder.
|
||||
*/
|
||||
if (cancelled || error)
|
||||
goto out;
|
||||
|
||||
if (folder)
|
||||
info->cleanups = g_slist_prepend (info->cleanups, folder);
|
||||
else if (g_slist_length (info->paths) == 1
|
||||
&& gtk_file_path_compare (info->node->path, info->paths->data) == 0)
|
||||
{
|
||||
/* Done, now call the function */
|
||||
if (info->node)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
iter.user_data = info->node;
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (info->model), &iter);
|
||||
|
||||
(* info->func) (info->model, path, &iter, info->user_data);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
info->node = find_child_node (info->model, info->parent_node, info->paths->data);
|
||||
if (info->node)
|
||||
file_model_node_ref (info->node);
|
||||
else
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
gtk_file_path_free (info->paths->data);
|
||||
info->paths = g_slist_remove (info->paths, info->paths->data);
|
||||
|
||||
if (g_slist_length (info->paths) < 1)
|
||||
{
|
||||
/* Done, now call the function */
|
||||
if (info->node)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
iter.user_data = info->node;
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (info->model), &iter);
|
||||
|
||||
(* info->func) (info->model, path, &iter, info->user_data);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->parent_node = info->node;
|
||||
|
||||
if (info->parent_node->loaded)
|
||||
{
|
||||
info->node = find_child_node (info->model, info->parent_node, info->paths->data);
|
||||
ref_path_cb (NULL, NULL, NULL, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkFileSystemHandle *handle;
|
||||
|
||||
handle = gtk_file_system_get_folder (info->model->file_system,
|
||||
info->paths->data,
|
||||
info->model->types,
|
||||
ref_path_cb, data);
|
||||
info->model->pending_handles =
|
||||
g_slist_append (info->model->pending_handles, handle);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
out:
|
||||
if (info->node)
|
||||
unref_node_and_parents (info->model, info->node);
|
||||
gtk_file_paths_free (info->paths);
|
||||
g_slist_foreach (info->cleanups, (GFunc)g_object_unref, NULL);
|
||||
g_slist_free (info->cleanups);
|
||||
g_object_unref (info->model);
|
||||
g_free (info);
|
||||
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_file_system_model_path_do:
|
||||
* @model: a #GtkFileSystemModel
|
||||
@@ -1090,33 +1198,90 @@ _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
|
||||
* Return value: %TRUE if the path was successfully
|
||||
* found in @model and @func was called.
|
||||
**/
|
||||
gboolean
|
||||
_gtk_file_system_model_path_do (GtkFileSystemModel *model,
|
||||
const GtkFilePath *path,
|
||||
GtkFileSystemModelPathFunc func,
|
||||
gpointer user_data)
|
||||
void
|
||||
_gtk_file_system_model_path_do (GtkFileSystemModel *model,
|
||||
const GtkFilePath *path,
|
||||
GtkFileSystemModelPathFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSList *cleanups = NULL;
|
||||
FileModelNode *node = find_and_ref_path (model, path, &cleanups);
|
||||
GtkFilePath *parent_path;
|
||||
GSList *paths = NULL;
|
||||
FileModelNode *node;
|
||||
struct RefPathData *info;
|
||||
|
||||
if (node)
|
||||
if (gtk_file_path_compare (path, model->root_path) == 0
|
||||
|| !gtk_file_system_get_parent (model->file_system, path, &parent_path, NULL))
|
||||
return;
|
||||
|
||||
paths = g_slist_prepend (paths, gtk_file_path_copy (path));
|
||||
while (gtk_file_path_compare (parent_path, model->root_path) != 0)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
iter.user_data = node;
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
|
||||
|
||||
(*func) (model, path, &iter, user_data);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
unref_node_and_parents (model, node);
|
||||
paths = g_slist_prepend (paths, parent_path);
|
||||
if (!gtk_file_system_get_parent (model->file_system, parent_path, &parent_path, NULL))
|
||||
{
|
||||
gtk_file_paths_free (paths);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_slist_foreach (cleanups, (GFunc)g_object_unref, NULL);
|
||||
g_slist_free (cleanups);
|
||||
if (g_slist_length (paths) < 1)
|
||||
return;
|
||||
|
||||
return node != NULL;
|
||||
/* Now we have all paths, except the root path */
|
||||
node = find_child_node (model, NULL, paths->data);
|
||||
if (!node)
|
||||
{
|
||||
gtk_file_paths_free (paths);
|
||||
return;
|
||||
}
|
||||
|
||||
file_model_node_ref (node);
|
||||
|
||||
gtk_file_path_free (paths->data);
|
||||
paths = g_slist_remove (paths, paths->data);
|
||||
|
||||
if (g_slist_length (paths) < 1)
|
||||
{
|
||||
/* Done, now call the function */
|
||||
if (node)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
iter.user_data = node;
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
|
||||
|
||||
(* func) (model, path, &iter, user_data);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
unref_node_and_parents (model, node);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info = g_new0 (struct RefPathData, 1);
|
||||
info->paths = paths;
|
||||
info->model = g_object_ref (model);
|
||||
info->func = func;
|
||||
info->user_data = user_data;
|
||||
info->node = node;
|
||||
|
||||
if (info->node->loaded)
|
||||
{
|
||||
info->parent_node = info->node;
|
||||
info->node = find_child_node (model, info->parent_node, info->paths->data);
|
||||
ref_path_cb (NULL, NULL, NULL, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkFileSystemHandle *handle;
|
||||
|
||||
handle = gtk_file_system_get_folder (model->file_system,
|
||||
paths->data, model->types,
|
||||
ref_path_cb, info);
|
||||
model->pending_handles = g_slist_append (model->pending_handles, handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1389,6 +1554,114 @@ file_model_node_child_unref (FileModelNode *parent)
|
||||
file_model_node_idle_clear (parent);
|
||||
}
|
||||
|
||||
struct GetChildrenData
|
||||
{
|
||||
GtkFileSystemModel *model;
|
||||
FileModelNode *node;
|
||||
};
|
||||
|
||||
static void
|
||||
get_children_get_folder_cb (GtkFileSystemHandle *handle,
|
||||
GtkFileFolder *folder,
|
||||
const GError *error,
|
||||
gpointer callback_data)
|
||||
{
|
||||
GSList *child_paths, *tmp_list;
|
||||
gboolean has_children = FALSE;
|
||||
gboolean cancelled = handle->cancelled;
|
||||
struct GetChildrenData *data = callback_data;
|
||||
|
||||
tmp_list = g_slist_find (data->model->pending_handles, handle);
|
||||
|
||||
if (!tmp_list)
|
||||
goto out;
|
||||
|
||||
data->model->pending_handles = g_slist_remove_link (data->model->pending_handles, tmp_list);
|
||||
|
||||
if (cancelled || !folder)
|
||||
{
|
||||
/* error, no folder, remove dummy child */
|
||||
if (data->node->parent && data->node->parent->has_dummy)
|
||||
{
|
||||
data->node->parent->children = NULL;
|
||||
data->node->parent->has_dummy = FALSE;
|
||||
}
|
||||
|
||||
file_model_node_free (data->node);
|
||||
|
||||
goto out;
|
||||
}
|
||||
|
||||
data->node->folder = folder;
|
||||
data->node->load_pending = FALSE;
|
||||
|
||||
if (gtk_file_folder_list_children (folder, &child_paths, NULL)) /* NULL-GError */
|
||||
{
|
||||
child_paths = gtk_file_paths_sort (child_paths);
|
||||
|
||||
for (tmp_list = child_paths; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
FileModelNode *child_node = file_model_node_new (data->model, tmp_list->data);
|
||||
gtk_file_path_free (tmp_list->data);
|
||||
child_node->next = data->node->children;
|
||||
child_node->parent = data->node;
|
||||
child_node->depth = data->node->depth + 1;
|
||||
child_node->is_visible = file_model_node_is_visible (data->model, child_node);
|
||||
|
||||
if (child_node->is_visible)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
|
||||
has_children = TRUE;
|
||||
|
||||
iter.user_data = child_node;
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (data->model), &iter);
|
||||
gtk_tree_model_row_inserted (GTK_TREE_MODEL (data->model), path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
data->node->children = child_node;
|
||||
}
|
||||
g_slist_free (child_paths);
|
||||
}
|
||||
|
||||
data->node->children = (FileModelNode *)g_slist_reverse ((GSList *)data->node->children);
|
||||
|
||||
g_signal_connect (data->node->folder, "deleted",
|
||||
G_CALLBACK (deleted_callback), data->node);
|
||||
g_signal_connect (data->node->folder, "files-added",
|
||||
G_CALLBACK (files_added_callback), data->node);
|
||||
g_signal_connect (data->node->folder, "files-changed",
|
||||
G_CALLBACK (files_changed_callback), data->node);
|
||||
g_signal_connect (data->node->folder, "files-removed",
|
||||
G_CALLBACK (files_removed_callback), data->node);
|
||||
|
||||
data->node->loaded = TRUE;
|
||||
|
||||
if (!has_children)
|
||||
{
|
||||
/* The hard case ... we claimed this folder had children, but actually
|
||||
* it didn't. We have to add a dummy child, possibly to remove later.
|
||||
*/
|
||||
FileModelNode *child_node = file_model_node_new (data->model, NULL);
|
||||
child_node->is_visible = TRUE;
|
||||
child_node->parent = data->node;
|
||||
child_node->is_dummy = TRUE;
|
||||
|
||||
data->node->children = child_node;
|
||||
data->node->has_dummy = TRUE;
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (data->node->folder), I_("model-node"), data->node);
|
||||
|
||||
out:
|
||||
g_object_unref (data->model);
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static FileModelNode *
|
||||
file_model_node_get_children (GtkFileSystemModel *model,
|
||||
FileModelNode *node)
|
||||
@@ -1396,7 +1669,7 @@ file_model_node_get_children (GtkFileSystemModel *model,
|
||||
if (node->ref_count == 0)
|
||||
return NULL;
|
||||
|
||||
if (!node->loaded)
|
||||
if (!node->loaded && !node->load_pending)
|
||||
{
|
||||
const GtkFileInfo *info = file_model_node_get_info (model, node);
|
||||
gboolean has_children = FALSE;
|
||||
@@ -1405,48 +1678,25 @@ file_model_node_get_children (GtkFileSystemModel *model,
|
||||
file_model_node_idle_clear_cancel (node);
|
||||
|
||||
if (is_folder)
|
||||
node->folder = gtk_file_system_get_folder (model->file_system,
|
||||
node->path,
|
||||
model->types,
|
||||
NULL); /* NULL-GError */
|
||||
{
|
||||
struct GetChildrenData *data;
|
||||
GtkFileSystemHandle *handle;
|
||||
|
||||
if (node->folder)
|
||||
{
|
||||
GSList *child_paths, *tmp_list;
|
||||
|
||||
if (gtk_file_folder_list_children (node->folder, &child_paths, NULL)) /* NULL-GError */
|
||||
{
|
||||
child_paths = gtk_file_paths_sort (child_paths);
|
||||
data = g_new (struct GetChildrenData, 1);
|
||||
data->model = g_object_ref (model);
|
||||
data->node = node;
|
||||
|
||||
for (tmp_list = child_paths; tmp_list; tmp_list = tmp_list->next)
|
||||
{
|
||||
FileModelNode *child_node = file_model_node_new (model, tmp_list->data);
|
||||
gtk_file_path_free (tmp_list->data);
|
||||
child_node->next = node->children;
|
||||
child_node->parent = node;
|
||||
child_node->depth = node->depth + 1;
|
||||
child_node->is_visible = file_model_node_is_visible (model, child_node);
|
||||
if (child_node->is_visible)
|
||||
has_children = TRUE;
|
||||
node->children = child_node;
|
||||
}
|
||||
g_slist_free (child_paths);
|
||||
}
|
||||
handle =
|
||||
gtk_file_system_get_folder (model->file_system,
|
||||
node->path,
|
||||
model->types,
|
||||
get_children_get_folder_cb,
|
||||
data);
|
||||
|
||||
node->children = (FileModelNode *)g_slist_reverse ((GSList *)node->children);
|
||||
|
||||
g_signal_connect (node->folder, "deleted",
|
||||
G_CALLBACK (deleted_callback), node);
|
||||
g_signal_connect (node->folder, "files-added",
|
||||
G_CALLBACK (files_added_callback), node);
|
||||
g_signal_connect (node->folder, "files-changed",
|
||||
G_CALLBACK (files_changed_callback), node);
|
||||
g_signal_connect (node->folder, "files-removed",
|
||||
G_CALLBACK (files_removed_callback), node);
|
||||
|
||||
g_object_set_data (G_OBJECT (node->folder), I_("model-node"), node);
|
||||
model->pending_handles = g_slist_append (model->pending_handles, handle);
|
||||
node->load_pending = TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (is_folder && !has_children)
|
||||
{
|
||||
/* The hard case ... we claimed this folder had children, but actually
|
||||
@@ -1460,8 +1710,6 @@ file_model_node_get_children (GtkFileSystemModel *model,
|
||||
node->children = child_node;
|
||||
node->has_dummy = TRUE;
|
||||
}
|
||||
|
||||
node->loaded = TRUE;
|
||||
}
|
||||
|
||||
return node->children;
|
||||
|
||||
@@ -71,7 +71,7 @@ typedef void (*GtkFileSystemModelPathFunc) (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean _gtk_file_system_model_path_do (GtkFileSystemModel *model,
|
||||
void _gtk_file_system_model_path_do (GtkFileSystemModel *model,
|
||||
const GtkFilePath *path,
|
||||
GtkFileSystemModelPathFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
10
gtk/gtkgc.c
10
gtk/gtkgc.c
@@ -65,8 +65,6 @@ static gint gtk_gc_drawable_equal (GtkGCDrawable *a,
|
||||
static gint initialize = TRUE;
|
||||
static GCache *gc_cache = NULL;
|
||||
|
||||
static GMemChunk *key_mem_chunk = NULL;
|
||||
|
||||
|
||||
GdkGC*
|
||||
gtk_gc_get (gint depth,
|
||||
@@ -143,11 +141,7 @@ gtk_gc_key_dup (GtkGCKey *key)
|
||||
{
|
||||
GtkGCKey *new_key;
|
||||
|
||||
if (!key_mem_chunk)
|
||||
key_mem_chunk = g_mem_chunk_new ("key mem chunk", sizeof (GtkGCKey),
|
||||
1024, G_ALLOC_AND_FREE);
|
||||
|
||||
new_key = g_chunk_new (GtkGCKey, key_mem_chunk);
|
||||
new_key = g_slice_new (GtkGCKey);
|
||||
|
||||
*new_key = *key;
|
||||
|
||||
@@ -157,7 +151,7 @@ gtk_gc_key_dup (GtkGCKey *key)
|
||||
static void
|
||||
gtk_gc_key_destroy (GtkGCKey *key)
|
||||
{
|
||||
g_mem_chunk_free (key_mem_chunk, key);
|
||||
g_slice_free (GtkGCKey, key);
|
||||
}
|
||||
|
||||
static gpointer
|
||||
|
||||
@@ -84,8 +84,6 @@ static void gtk_item_factory_finalize (GObject *object);
|
||||
static GtkItemFactoryClass *gtk_item_factory_class = NULL;
|
||||
static gpointer parent_class = NULL;
|
||||
static const gchar item_factory_string[] = "Gtk-<ItemFactory>";
|
||||
static GMemChunk *ifactory_item_chunks = NULL;
|
||||
static GMemChunk *ifactory_cb_data_chunks = NULL;
|
||||
static GQuark quark_popup_data = 0;
|
||||
static GQuark quark_if_menu_pos = 0;
|
||||
static GQuark quark_item_factory = 0;
|
||||
@@ -148,16 +146,6 @@ gtk_item_factory_class_init (GtkItemFactoryClass *class)
|
||||
object_class->destroy = gtk_item_factory_destroy;
|
||||
|
||||
class->item_ht = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
ifactory_item_chunks =
|
||||
g_mem_chunk_new ("GtkItemFactoryItem",
|
||||
sizeof (GtkItemFactoryItem),
|
||||
sizeof (GtkItemFactoryItem) * ITEM_BLOCK_SIZE,
|
||||
G_ALLOC_ONLY);
|
||||
ifactory_cb_data_chunks =
|
||||
g_mem_chunk_new ("GtkIFCBData",
|
||||
sizeof (GtkIFCBData),
|
||||
sizeof (GtkIFCBData) * ITEM_BLOCK_SIZE,
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
quark_popup_data = g_quark_from_static_string ("GtkItemFactory-popup-data");
|
||||
quark_if_menu_pos = g_quark_from_static_string ("GtkItemFactory-menu-position");
|
||||
@@ -289,7 +277,7 @@ gtk_item_factory_add_foreign (GtkWidget *accel_widget,
|
||||
item = g_hash_table_lookup (class->item_ht, full_path);
|
||||
if (!item)
|
||||
{
|
||||
item = g_chunk_new (GtkItemFactoryItem, ifactory_item_chunks);
|
||||
item = g_slice_new (GtkItemFactoryItem);
|
||||
|
||||
item->path = g_strdup (full_path);
|
||||
item->widgets = NULL;
|
||||
@@ -333,7 +321,7 @@ gtk_item_factory_add_foreign (GtkWidget *accel_widget,
|
||||
static void
|
||||
ifactory_cb_data_free (gpointer mem)
|
||||
{
|
||||
g_mem_chunk_free (ifactory_cb_data_chunks, mem);
|
||||
g_slice_free (GtkIFCBData, mem);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -369,7 +357,7 @@ gtk_item_factory_add_item (GtkItemFactory *ifactory,
|
||||
{
|
||||
GtkIFCBData *data;
|
||||
|
||||
data = g_chunk_new (GtkIFCBData, ifactory_cb_data_chunks);
|
||||
data = g_slice_new (GtkIFCBData);
|
||||
data->func = callback;
|
||||
data->callback_type = callback_type;
|
||||
data->func_data = callback_data;
|
||||
|
||||
@@ -144,8 +144,6 @@ static GList *init_functions = NULL; /* A list of init functions.
|
||||
*/
|
||||
static GList *quit_functions = NULL; /* A list of quit functions.
|
||||
*/
|
||||
static GMemChunk *quit_mem_chunk = NULL;
|
||||
|
||||
static GSList *key_snoopers = NULL;
|
||||
|
||||
guint gtk_debug_flags = 0; /* Global GTK debug flag */
|
||||
@@ -1693,11 +1691,7 @@ gtk_quit_add_full (guint main_level,
|
||||
|
||||
g_return_val_if_fail ((function != NULL) || (marshal != NULL), 0);
|
||||
|
||||
if (!quit_mem_chunk)
|
||||
quit_mem_chunk = g_mem_chunk_new ("quit mem chunk", sizeof (GtkQuitFunction),
|
||||
512, G_ALLOC_AND_FREE);
|
||||
|
||||
quitf = g_chunk_new (GtkQuitFunction, quit_mem_chunk);
|
||||
quitf = g_slice_new (GtkQuitFunction);
|
||||
|
||||
quitf->id = quit_id++;
|
||||
quitf->main_level = main_level;
|
||||
@@ -1716,7 +1710,7 @@ gtk_quit_destroy (GtkQuitFunction *quitf)
|
||||
{
|
||||
if (quitf->destroy)
|
||||
quitf->destroy (quitf->data);
|
||||
g_mem_chunk_free (quit_mem_chunk, quitf);
|
||||
g_slice_free (GtkQuitFunction, quitf);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
||||
387
gtk/gtkpathbar.c
387
gtk/gtkpathbar.c
@@ -65,6 +65,7 @@ struct _ButtonData
|
||||
GtkFilePath *path;
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
GtkFileSystemHandle *handle;
|
||||
guint ignore_changes : 1;
|
||||
guint file_is_hidden : 1;
|
||||
};
|
||||
@@ -140,6 +141,8 @@ gtk_path_bar_init (GtkPathBar *path_bar)
|
||||
GTK_WIDGET_SET_FLAGS (path_bar, GTK_NO_WINDOW);
|
||||
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
|
||||
|
||||
path_bar->set_path_handle = NULL;
|
||||
|
||||
path_bar->spacing = 3;
|
||||
path_bar->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT);
|
||||
path_bar->down_slider_button = get_slider_button (path_bar, GTK_ARROW_RIGHT);
|
||||
@@ -247,8 +250,13 @@ remove_settings_signal (GtkPathBar *path_bar,
|
||||
static void
|
||||
gtk_path_bar_dispose (GObject *object)
|
||||
{
|
||||
remove_settings_signal (GTK_PATH_BAR (object),
|
||||
gtk_widget_get_screen (GTK_WIDGET (object)));
|
||||
GtkPathBar *path_bar = GTK_PATH_BAR (object);
|
||||
|
||||
remove_settings_signal (path_bar, gtk_widget_get_screen (GTK_WIDGET (object)));
|
||||
|
||||
if (path_bar->set_path_handle)
|
||||
gtk_file_system_cancel_operation (path_bar->set_path_handle);
|
||||
path_bar->set_path_handle = NULL;
|
||||
|
||||
G_OBJECT_CLASS (gtk_path_bar_parent_class)->dispose (object);
|
||||
}
|
||||
@@ -957,7 +965,11 @@ button_clicked_cb (GtkWidget *button,
|
||||
button_list = g_list_find (path_bar->button_list, button_data);
|
||||
g_assert (button_list != NULL);
|
||||
|
||||
g_signal_handlers_block_by_func (button,
|
||||
G_CALLBACK (button_clicked_cb), data);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
g_signal_handlers_unblock_by_func (button,
|
||||
G_CALLBACK (button_clicked_cb), data);
|
||||
|
||||
if (button_list->prev)
|
||||
{
|
||||
@@ -977,22 +989,79 @@ button_clicked_cb (GtkWidget *button,
|
||||
button_data->path, child_path, child_is_hidden);
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
get_button_image (GtkPathBar *path_bar,
|
||||
ButtonType button_type)
|
||||
struct SetButtonImageData
|
||||
{
|
||||
GtkPathBar *path_bar;
|
||||
ButtonData *button_data;
|
||||
};
|
||||
|
||||
static void
|
||||
set_button_image_get_info_cb (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *info,
|
||||
const GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
GdkPixbuf *pixbuf;
|
||||
struct SetButtonImageData *data = user_data;
|
||||
|
||||
if (handle != data->button_data->handle)
|
||||
goto out;
|
||||
|
||||
data->button_data->handle = NULL;
|
||||
|
||||
if (cancelled || error)
|
||||
goto out;
|
||||
|
||||
pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (data->path_bar),
|
||||
data->path_bar->icon_size, NULL);
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (data->button_data->image), pixbuf);
|
||||
|
||||
switch (data->button_data->type)
|
||||
{
|
||||
case HOME_BUTTON:
|
||||
if (data->path_bar->home_icon)
|
||||
g_object_unref (pixbuf);
|
||||
else
|
||||
data->path_bar->home_icon = pixbuf;
|
||||
break;
|
||||
|
||||
case DESKTOP_BUTTON:
|
||||
if (data->path_bar->desktop_icon)
|
||||
g_object_unref (pixbuf);
|
||||
else
|
||||
data->path_bar->desktop_icon = pixbuf;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
out:
|
||||
g_free (data);
|
||||
g_object_unref (handle);
|
||||
}
|
||||
|
||||
static void
|
||||
set_button_image (GtkPathBar *path_bar,
|
||||
ButtonData *button_data)
|
||||
{
|
||||
GtkFileSystemVolume *volume;
|
||||
struct SetButtonImageData *data;
|
||||
|
||||
switch (button_type)
|
||||
switch (button_data->type)
|
||||
{
|
||||
case ROOT_BUTTON:
|
||||
|
||||
if (path_bar->root_icon != NULL)
|
||||
return path_bar->root_icon;
|
||||
{
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->root_icon);
|
||||
break;
|
||||
}
|
||||
|
||||
volume = gtk_file_system_get_volume_for_path (path_bar->file_system, path_bar->root_path);
|
||||
if (volume == NULL)
|
||||
return NULL;
|
||||
return;
|
||||
|
||||
path_bar->root_icon = gtk_file_system_volume_render_icon (path_bar->file_system,
|
||||
volume,
|
||||
@@ -1001,37 +1070,63 @@ get_button_image (GtkPathBar *path_bar,
|
||||
NULL);
|
||||
gtk_file_system_volume_free (path_bar->file_system, volume);
|
||||
|
||||
return path_bar->root_icon;
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->root_icon);
|
||||
break;
|
||||
|
||||
case HOME_BUTTON:
|
||||
if (path_bar->home_icon != NULL)
|
||||
return path_bar->home_icon;
|
||||
{
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->home_icon);
|
||||
break;
|
||||
}
|
||||
|
||||
data = g_new0 (struct SetButtonImageData, 1);
|
||||
data->path_bar = path_bar;
|
||||
data->button_data = button_data;
|
||||
|
||||
if (button_data->handle)
|
||||
gtk_file_system_cancel_operation (button_data->handle);
|
||||
|
||||
button_data->handle =
|
||||
gtk_file_system_get_info (path_bar->file_system,
|
||||
path_bar->home_path,
|
||||
GTK_FILE_INFO_ICON,
|
||||
set_button_image_get_info_cb,
|
||||
data);
|
||||
break;
|
||||
|
||||
path_bar->home_icon = gtk_file_system_render_icon (path_bar->file_system,
|
||||
path_bar->home_path,
|
||||
GTK_WIDGET (path_bar),
|
||||
path_bar->icon_size,
|
||||
NULL);
|
||||
return path_bar->home_icon;
|
||||
case DESKTOP_BUTTON:
|
||||
if (path_bar->desktop_icon != NULL)
|
||||
return path_bar->desktop_icon;
|
||||
{
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->desktop_icon);
|
||||
break;
|
||||
}
|
||||
|
||||
path_bar->desktop_icon = gtk_file_system_render_icon (path_bar->file_system,
|
||||
path_bar->desktop_path,
|
||||
GTK_WIDGET (path_bar),
|
||||
path_bar->icon_size,
|
||||
NULL);
|
||||
return path_bar->desktop_icon;
|
||||
data = g_new0 (struct SetButtonImageData, 1);
|
||||
data->path_bar = path_bar;
|
||||
data->button_data = button_data;
|
||||
|
||||
if (button_data->handle)
|
||||
gtk_file_system_cancel_operation (button_data->handle);
|
||||
|
||||
button_data->handle =
|
||||
gtk_file_system_get_info (path_bar->file_system,
|
||||
path_bar->desktop_path,
|
||||
GTK_FILE_INFO_ICON,
|
||||
set_button_image_get_info_cb,
|
||||
data);
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
button_data_free (ButtonData *button_data)
|
||||
{
|
||||
if (button_data->handle)
|
||||
gtk_file_system_cancel_operation (button_data->handle);
|
||||
|
||||
gtk_file_path_free (button_data->path);
|
||||
g_free (button_data->dir_name);
|
||||
g_free (button_data);
|
||||
@@ -1094,9 +1189,7 @@ gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
|
||||
|
||||
if (button_data->image != NULL)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
pixbuf = get_button_image (path_bar, button_data->type);
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), pixbuf);
|
||||
set_button_image (path_bar, button_data);
|
||||
}
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_data->button)) != current_dir)
|
||||
@@ -1294,17 +1387,136 @@ gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
struct SetPathInfo
|
||||
{
|
||||
GtkFilePath *path;
|
||||
GtkFilePath *parent_path;
|
||||
GtkPathBar *path_bar;
|
||||
GList *new_buttons;
|
||||
GList *fake_root;
|
||||
gboolean first_directory;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_path_bar_set_path_finish (struct SetPathInfo *info,
|
||||
gboolean result)
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
gtk_path_bar_clear_buttons (info->path_bar);
|
||||
info->path_bar->button_list = g_list_reverse (info->new_buttons);
|
||||
info->path_bar->fake_root = info->fake_root;
|
||||
|
||||
for (l = info->path_bar->button_list; l; l = l->next)
|
||||
{
|
||||
GtkWidget *button = BUTTON_DATA (l->data)->button;
|
||||
gtk_container_add (GTK_CONTAINER (info->path_bar), button);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = info->new_buttons; l; l = l->next)
|
||||
{
|
||||
ButtonData *button_data;
|
||||
|
||||
button_data = BUTTON_DATA (l->data);
|
||||
gtk_widget_destroy (button_data->button);
|
||||
}
|
||||
|
||||
g_list_free (info->new_buttons);
|
||||
}
|
||||
|
||||
if (info->path)
|
||||
gtk_file_path_free (info->path);
|
||||
if (info->parent_path)
|
||||
gtk_file_path_free (info->parent_path);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_get_info_callback (GtkFileSystemHandle *handle,
|
||||
const GtkFileInfo *file_info,
|
||||
const GError *error,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean cancelled = handle->cancelled;
|
||||
struct SetPathInfo *path_info = data;
|
||||
ButtonData *button_data;
|
||||
const gchar *display_name;
|
||||
gboolean is_hidden;
|
||||
gboolean valid;
|
||||
|
||||
if (handle != path_info->path_bar->set_path_handle)
|
||||
{
|
||||
gtk_path_bar_set_path_finish (path_info, FALSE);
|
||||
g_object_unref (handle);
|
||||
return;
|
||||
}
|
||||
|
||||
g_object_unref (handle);
|
||||
path_info->path_bar->set_path_handle = NULL;
|
||||
|
||||
if (cancelled || !file_info)
|
||||
{
|
||||
gtk_path_bar_set_path_finish (path_info, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
display_name = gtk_file_info_get_display_name (file_info);
|
||||
is_hidden = gtk_file_info_get_is_hidden (file_info);
|
||||
|
||||
gtk_widget_push_composite_child ();
|
||||
button_data = make_directory_button (path_info->path_bar, display_name,
|
||||
path_info->path,
|
||||
path_info->first_directory, is_hidden);
|
||||
gtk_widget_pop_composite_child ();
|
||||
gtk_file_path_free (path_info->path);
|
||||
|
||||
path_info->new_buttons = g_list_prepend (path_info->new_buttons, button_data);
|
||||
|
||||
if (BUTTON_IS_FAKE_ROOT (button_data))
|
||||
path_info->fake_root = path_info->new_buttons;
|
||||
|
||||
path_info->path = path_info->parent_path;
|
||||
path_info->first_directory = FALSE;
|
||||
|
||||
if (!path_info->path)
|
||||
{
|
||||
gtk_path_bar_set_path_finish (path_info, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
valid = gtk_file_system_get_parent (path_info->path_bar->file_system,
|
||||
path_info->path,
|
||||
&path_info->parent_path,
|
||||
NULL);
|
||||
if (!valid)
|
||||
{
|
||||
gtk_path_bar_set_path_finish (path_info, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
path_info->path_bar->set_path_handle =
|
||||
gtk_file_system_get_info (handle->file_system,
|
||||
path_info->path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN,
|
||||
gtk_path_bar_get_info_callback,
|
||||
path_info);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_path_bar_set_path (GtkPathBar *path_bar,
|
||||
const GtkFilePath *file_path,
|
||||
const gboolean keep_trail,
|
||||
GError **error)
|
||||
{
|
||||
GtkFilePath *path;
|
||||
gboolean first_directory = TRUE;
|
||||
struct SetPathInfo *info;
|
||||
gboolean result;
|
||||
GList *new_buttons = NULL;
|
||||
GList *fake_root = NULL;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PATH_BAR (path_bar), FALSE);
|
||||
g_return_val_if_fail (file_path != NULL, FALSE);
|
||||
@@ -1318,102 +1530,31 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
||||
gtk_path_bar_check_parent_path (path_bar, file_path, path_bar->file_system))
|
||||
return TRUE;
|
||||
|
||||
path = gtk_file_path_copy (file_path);
|
||||
info = g_new0 (struct SetPathInfo, 1);
|
||||
info->path = gtk_file_path_copy (file_path);
|
||||
info->path_bar = path_bar;
|
||||
info->first_directory = TRUE;
|
||||
|
||||
gtk_widget_push_composite_child ();
|
||||
|
||||
while (path != NULL)
|
||||
result = gtk_file_system_get_parent (path_bar->file_system,
|
||||
info->path, &info->parent_path, error);
|
||||
if (!result)
|
||||
{
|
||||
GtkFilePath *parent_path = NULL;
|
||||
ButtonData *button_data;
|
||||
const gchar *display_name;
|
||||
gboolean is_hidden;
|
||||
GtkFileFolder *file_folder;
|
||||
GtkFileInfo *file_info;
|
||||
gboolean valid;
|
||||
|
||||
valid = gtk_file_system_get_parent (path_bar->file_system,
|
||||
path,
|
||||
&parent_path,
|
||||
error);
|
||||
if (!valid)
|
||||
{
|
||||
result = FALSE;
|
||||
gtk_file_path_free (path);
|
||||
break;
|
||||
}
|
||||
|
||||
file_folder = gtk_file_system_get_folder (path_bar->file_system,
|
||||
parent_path ? parent_path : path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN,
|
||||
NULL);
|
||||
if (!file_folder)
|
||||
{
|
||||
result = FALSE;
|
||||
gtk_file_path_free (parent_path);
|
||||
gtk_file_path_free (path);
|
||||
break;
|
||||
}
|
||||
|
||||
file_info = gtk_file_folder_get_info (file_folder, parent_path ? path : NULL, error);
|
||||
g_object_unref (file_folder);
|
||||
|
||||
if (!file_info)
|
||||
{
|
||||
result = FALSE;
|
||||
gtk_file_path_free (parent_path);
|
||||
gtk_file_path_free (path);
|
||||
break;
|
||||
}
|
||||
|
||||
display_name = gtk_file_info_get_display_name (file_info);
|
||||
is_hidden = gtk_file_info_get_is_hidden (file_info);
|
||||
|
||||
button_data = make_directory_button (path_bar, display_name, path, first_directory, is_hidden);
|
||||
gtk_file_info_free (file_info);
|
||||
gtk_file_path_free (path);
|
||||
|
||||
new_buttons = g_list_prepend (new_buttons, button_data);
|
||||
|
||||
if (BUTTON_IS_FAKE_ROOT (button_data))
|
||||
fake_root = new_buttons;
|
||||
|
||||
path = parent_path;
|
||||
first_directory = FALSE;
|
||||
gtk_file_path_free (info->path);
|
||||
g_free (info);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
GList *l;
|
||||
if (path_bar->set_path_handle)
|
||||
gtk_file_system_cancel_operation (path_bar->set_path_handle);
|
||||
|
||||
gtk_path_bar_clear_buttons (path_bar);
|
||||
path_bar->button_list = g_list_reverse (new_buttons);
|
||||
path_bar->fake_root = fake_root;
|
||||
path_bar->set_path_handle =
|
||||
gtk_file_system_get_info (path_bar->file_system,
|
||||
info->path,
|
||||
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN,
|
||||
gtk_path_bar_get_info_callback,
|
||||
info);
|
||||
|
||||
for (l = path_bar->button_list; l; l = l->next)
|
||||
{
|
||||
GtkWidget *button = BUTTON_DATA (l->data)->button;
|
||||
gtk_container_add (GTK_CONTAINER (path_bar), button);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = new_buttons; l; l = l->next)
|
||||
{
|
||||
ButtonData *button_data;
|
||||
|
||||
button_data = BUTTON_DATA (l->data);
|
||||
gtk_widget_destroy (button_data->button);
|
||||
}
|
||||
|
||||
g_list_free (new_buttons);
|
||||
}
|
||||
|
||||
gtk_widget_pop_composite_child ();
|
||||
|
||||
return result;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* FIXME: This should be a construct-only property */
|
||||
|
||||
@@ -45,6 +45,8 @@ struct _GtkPathBar
|
||||
GtkFilePath *home_path;
|
||||
GtkFilePath *desktop_path;
|
||||
|
||||
GtkFileSystemHandle *set_path_handle;
|
||||
|
||||
GdkPixbuf *root_icon;
|
||||
GdkPixbuf *home_icon;
|
||||
GdkPixbuf *desktop_icon;
|
||||
|
||||
@@ -155,11 +155,6 @@ gtk_statusbar_class_init (GtkStatusbarClass *class)
|
||||
|
||||
widget_class->direction_changed = gtk_statusbar_direction_changed;
|
||||
|
||||
class->messages_mem_chunk = g_mem_chunk_new ("GtkStatusbar messages mem chunk",
|
||||
sizeof (GtkStatusbarMsg),
|
||||
sizeof (GtkStatusbarMsg) * 64,
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
class->text_pushed = gtk_statusbar_update;
|
||||
class->text_popped = gtk_statusbar_update;
|
||||
|
||||
@@ -300,7 +295,7 @@ gtk_statusbar_push (GtkStatusbar *statusbar,
|
||||
g_return_val_if_fail (text != NULL, 0);
|
||||
|
||||
class = GTK_STATUSBAR_GET_CLASS (statusbar);
|
||||
msg = g_chunk_new (GtkStatusbarMsg, class->messages_mem_chunk);
|
||||
msg = g_slice_new (GtkStatusbarMsg);
|
||||
msg->text = g_strdup (text);
|
||||
msg->context_id = context_id;
|
||||
msg->message_id = statusbar->seq_message_id++;
|
||||
@@ -341,7 +336,7 @@ gtk_statusbar_pop (GtkStatusbar *statusbar,
|
||||
statusbar->messages = g_slist_remove_link (statusbar->messages,
|
||||
list);
|
||||
g_free (msg->text);
|
||||
g_mem_chunk_free (class->messages_mem_chunk, msg);
|
||||
g_slice_free (GtkStatusbarMsg, msg);
|
||||
g_slist_free_1 (list);
|
||||
break;
|
||||
}
|
||||
@@ -392,7 +387,7 @@ gtk_statusbar_remove (GtkStatusbar *statusbar,
|
||||
class = GTK_STATUSBAR_GET_CLASS (statusbar);
|
||||
statusbar->messages = g_slist_remove_link (statusbar->messages, list);
|
||||
g_free (msg->text);
|
||||
g_mem_chunk_free (class->messages_mem_chunk, msg);
|
||||
g_slice_free (GtkStatusbarMsg, msg);
|
||||
g_slist_free_1 (list);
|
||||
|
||||
break;
|
||||
@@ -457,7 +452,7 @@ gtk_statusbar_destroy (GtkObject *object)
|
||||
|
||||
msg = list->data;
|
||||
g_free (msg->text);
|
||||
g_mem_chunk_free (class->messages_mem_chunk, msg);
|
||||
g_slice_free (GtkStatusbarMsg, msg);
|
||||
}
|
||||
g_slist_free (statusbar->messages);
|
||||
statusbar->messages = NULL;
|
||||
|
||||
@@ -65,7 +65,7 @@ struct _GtkStatusbarClass
|
||||
{
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
GMemChunk *messages_mem_chunk;
|
||||
gpointer reserved;
|
||||
|
||||
void (*text_pushed) (GtkStatusbar *statusbar,
|
||||
guint context_id,
|
||||
|
||||
@@ -442,10 +442,6 @@ static void gtk_text_show_props (GtkText* test,
|
||||
#define TEXT_SHOW_ADJ(text,adj,msg)
|
||||
#endif
|
||||
|
||||
/* Memory Management. */
|
||||
static GMemChunk *params_mem_chunk = NULL;
|
||||
static GMemChunk *text_property_chunk = NULL;
|
||||
|
||||
static GtkWidgetClass *parent_class = NULL;
|
||||
|
||||
|
||||
@@ -735,12 +731,6 @@ gtk_text_init (GtkText *text)
|
||||
|
||||
text->freeze_count = 0;
|
||||
|
||||
if (!params_mem_chunk)
|
||||
params_mem_chunk = g_mem_chunk_new ("LineParams",
|
||||
sizeof (LineParams),
|
||||
256 * sizeof (LineParams),
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
text->default_tab_width = 4;
|
||||
text->tab_stops = NULL;
|
||||
|
||||
@@ -2293,7 +2283,7 @@ line_params_iterate (GtkText* text,
|
||||
for (;;)
|
||||
{
|
||||
if (alloc)
|
||||
lp = g_chunk_new (LineParams, params_mem_chunk);
|
||||
lp = g_slice_new (LineParams);
|
||||
else
|
||||
lp = &lpbuf;
|
||||
|
||||
@@ -2977,15 +2967,7 @@ new_text_property (GtkText *text, GdkFont *font, const GdkColor* fore,
|
||||
{
|
||||
TextProperty *prop;
|
||||
|
||||
if (text_property_chunk == NULL)
|
||||
{
|
||||
text_property_chunk = g_mem_chunk_new ("text property mem chunk",
|
||||
sizeof(TextProperty),
|
||||
1024*sizeof(TextProperty),
|
||||
G_ALLOC_AND_FREE);
|
||||
}
|
||||
|
||||
prop = g_chunk_new(TextProperty, text_property_chunk);
|
||||
prop = g_slice_new (TextProperty);
|
||||
|
||||
prop->flags = 0;
|
||||
if (font)
|
||||
@@ -3022,7 +3004,7 @@ destroy_text_property (TextProperty *prop)
|
||||
if (prop->font)
|
||||
text_font_unref (prop->font);
|
||||
|
||||
g_mem_chunk_free (text_property_chunk, prop);
|
||||
g_slice_free (TextProperty, prop);
|
||||
}
|
||||
|
||||
/* Flop the memory between the point and the gap around like a
|
||||
@@ -3778,7 +3760,7 @@ free_cache (GtkText* text)
|
||||
}
|
||||
|
||||
for (; cache; cache = cache->next)
|
||||
g_mem_chunk_free (params_mem_chunk, cache->data);
|
||||
g_slice_free (LineParams, cache->data);
|
||||
|
||||
g_list_free (text->line_start_cache);
|
||||
|
||||
@@ -3804,7 +3786,7 @@ remove_cache_line (GtkText* text, GList* member)
|
||||
|
||||
list = member->next;
|
||||
|
||||
g_mem_chunk_free (params_mem_chunk, member->data);
|
||||
g_slice_free (LineParams, member->data);
|
||||
g_list_free_1 (member);
|
||||
|
||||
return list;
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
#include "gtktreedatalist.h"
|
||||
#include "gtkalias.h"
|
||||
#include <string.h>
|
||||
static GMemChunk *tree_chunk = NULL;
|
||||
#define TREE_CHUNK_PREALLOCS 64
|
||||
|
||||
/* node allocation
|
||||
*/
|
||||
@@ -34,14 +32,7 @@ _gtk_tree_data_list_alloc (void)
|
||||
{
|
||||
GtkTreeDataList *list;
|
||||
|
||||
if (tree_chunk == NULL)
|
||||
tree_chunk = g_mem_chunk_new ("treedatalist mem chunk",
|
||||
sizeof (GtkTreeDataList),
|
||||
sizeof (GtkTreeDataList) * TREE_CHUNK_PREALLOCS,
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
list = g_chunk_new (GtkTreeDataList, tree_chunk);
|
||||
memset (list, 0, sizeof (GtkTreeDataList));
|
||||
list = g_slice_new0 (GtkTreeDataList);
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -65,7 +56,7 @@ _gtk_tree_data_list_free (GtkTreeDataList *list,
|
||||
else if (g_type_is_a (column_headers [i], G_TYPE_BOXED) && tmp->data.v_pointer != NULL)
|
||||
g_boxed_free (column_headers [i], (gpointer) tmp->data.v_pointer);
|
||||
|
||||
g_mem_chunk_free (tree_chunk, tmp);
|
||||
g_slice_free (GtkTreeDataList, tmp);
|
||||
i++;
|
||||
tmp = next;
|
||||
}
|
||||
|
||||
@@ -4464,7 +4464,7 @@ gtk_tree_view_key_press (GtkWidget *widget,
|
||||
* during this event, we will set priv->imcontext_changed */
|
||||
tree_view->priv->imcontext_changed = FALSE;
|
||||
retval = gtk_widget_event (tree_view->priv->search_entry, new_event);
|
||||
gdk_event_free (new_event);
|
||||
/*gdk_event_free (new_event);*/
|
||||
gtk_widget_hide (tree_view->priv->search_window);
|
||||
|
||||
g_signal_handler_disconnect (tree_view->priv->search_entry,
|
||||
|
||||
@@ -166,8 +166,6 @@ enum
|
||||
static GObjectClass *parent_class = NULL;
|
||||
static guint ui_manager_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GMemChunk *merge_node_chunk = NULL;
|
||||
|
||||
GType
|
||||
gtk_ui_manager_get_type (void)
|
||||
{
|
||||
@@ -205,10 +203,6 @@ gtk_ui_manager_class_init (GtkUIManagerClass *klass)
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
if (!merge_node_chunk)
|
||||
merge_node_chunk = g_mem_chunk_create (Node, 64,
|
||||
G_ALLOC_AND_FREE);
|
||||
|
||||
gobject_class->finalize = gtk_ui_manager_finalize;
|
||||
gobject_class->set_property = gtk_ui_manager_set_property;
|
||||
gobject_class->get_property = gtk_ui_manager_get_property;
|
||||
@@ -893,7 +887,7 @@ get_child_node (GtkUIManager *self,
|
||||
{
|
||||
Node *mnode;
|
||||
|
||||
mnode = g_chunk_new0 (Node, merge_node_chunk);
|
||||
mnode = g_slice_new0 (Node);
|
||||
mnode->type = node_type;
|
||||
mnode->name = g_strndup (childname, childname_length);
|
||||
|
||||
@@ -933,7 +927,7 @@ get_child_node (GtkUIManager *self,
|
||||
{
|
||||
Node *mnode;
|
||||
|
||||
mnode = g_chunk_new0 (Node, merge_node_chunk);
|
||||
mnode = g_slice_new0 (Node);
|
||||
mnode->type = node_type;
|
||||
mnode->name = g_strndup (childname, childname_length);
|
||||
mnode->dirty = TRUE;
|
||||
@@ -1001,7 +995,7 @@ free_node (GNode *node)
|
||||
if (info->extra)
|
||||
g_object_unref (info->extra);
|
||||
g_free (info->name);
|
||||
g_chunk_free (info, merge_node_chunk);
|
||||
g_slice_free (Node, info);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,6 @@ static void gtk_widget_get_draw_rectangle (GtkWidget *widget,
|
||||
/* --- variables --- */
|
||||
static gpointer parent_class = NULL;
|
||||
static guint widget_signals[LAST_SIGNAL] = { 0 };
|
||||
static GMemChunk *aux_info_mem_chunk = NULL;
|
||||
static GtkStyle *gtk_default_style = NULL;
|
||||
static GSList *colormap_stack = NULL;
|
||||
static guint composite_child_stack = 0;
|
||||
@@ -6942,11 +6941,7 @@ _gtk_widget_get_aux_info (GtkWidget *widget,
|
||||
aux_info = g_object_get_qdata (G_OBJECT (widget), quark_aux_info);
|
||||
if (!aux_info && create)
|
||||
{
|
||||
if (!aux_info_mem_chunk)
|
||||
aux_info_mem_chunk = g_mem_chunk_new ("widget aux info mem chunk",
|
||||
sizeof (GtkWidgetAuxInfo),
|
||||
1024, G_ALLOC_AND_FREE);
|
||||
aux_info = g_chunk_new (GtkWidgetAuxInfo, aux_info_mem_chunk);
|
||||
aux_info = g_slice_new (GtkWidgetAuxInfo);
|
||||
|
||||
aux_info->width = -1;
|
||||
aux_info->height = -1;
|
||||
@@ -6971,7 +6966,7 @@ _gtk_widget_get_aux_info (GtkWidget *widget,
|
||||
static void
|
||||
gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info)
|
||||
{
|
||||
g_mem_chunk_free (aux_info_mem_chunk, aux_info);
|
||||
g_slice_free (GtkWidgetAuxInfo, aux_info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user