#include <gtk/gtk.h>
#include "filemodel.h"
Go to the source code of this file.
Enumerations | |
enum | ctb_viewtypes_t { CTB_ICONVIEW = 0, CTB_LISTVIEW, CTB_CONTENTVIEW, CTB_AUTOSELECT, N_CTB_VIEWS } |
Functions | |
void | fileview_init () |
Initialisation. | |
void | fileview_update_screen_texts () |
Update screen texts, using current language setting. | |
void | fileview_create () |
void | fileview_set_view_type (const ctb_viewtypes_t view, gboolean do_cursor) |
Select which view to use for displaying the files. | |
void | fileview_save_view_type () |
void | fileview_set_sort_order (const ctb_sort_order_t sort_order) |
Set sorting order for items in view. | |
void | fileview_dir_up () |
void | fileview_dir_down (const gchar *dir, const char *cursorname) |
void | fileview_show_desktop () |
Show content of the desktop. | |
void | fileview_stop_update_display () |
void | fileview_media_mounted (const gchar *mountpoint) |
Notification that a storage device has been mounted. | |
void | fileview_media_unmounted () |
Notification that the storage device will be (has been) unmounted. | |
void | fileview_refresh (gboolean force_reload) |
Refresh the current screen data, keep cursor at same item if possible. | |
void | fileview_show_search_dialog () |
void | fileview_show_prev_page () |
void | fileview_show_next_page () |
void | fileview_toggle_delete_mode () |
void | fileview_create_shortcut () |
Create desktop shortcut(s) for the currently selected item(s). | |
void | fileview_grab_focus (void) |
Grab focus for current view. | |
void | show_error_dialog (const gchar *msg) |
int | fileview_get_xid () |
void | fileview_set_on_top (gboolean ontop) |
void | fileview_move_up (guint delta) |
void | fileview_move_undo () |
enum ctb_viewtypes_t |
File Name : fileview.h
Description: Content browser screens to display files for both portrait and landscape mode Copyright (C) 2008 iRex Technologies B.V. All rights reserved.
Definition at line 61 of file fileview.h.
00062 { 00063 CTB_ICONVIEW = 0, 00064 CTB_LISTVIEW, 00065 CTB_CONTENTVIEW, 00066 CTB_AUTOSELECT, 00067 N_CTB_VIEWS 00068 } ctb_viewtypes_t;
void fileview_create | ( | ) |
Definition at line 1938 of file fileview.c.
References create_screen_layout(), fileview_set_view_type(), fileview_show_desktop(), g_is_user_selected_view, g_main_window, get_viewtype_from_registry(), on_destroy(), and widget.
Referenced by main().
01939 { 01940 // create the top level window 01941 GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 01942 gtk_window_set_title(GTK_WINDOW(window), PACKAGE " " VERSION); 01943 gtk_window_maximize(GTK_WINDOW(window)); 01944 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); 01945 gtk_container_set_border_width(GTK_CONTAINER(window), 0); 01946 gtk_window_set_modal(GTK_WINDOW(window), TRUE); 01947 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(on_destroy), NULL); 01948 g_main_window = window; 01949 01950 GtkWidget *widget = create_screen_layout(); 01951 gtk_container_add(GTK_CONTAINER(window), widget); 01952 01953 ctb_viewtypes_t view = get_viewtype_from_registry(); 01954 fileview_set_view_type(view, FALSE); 01955 g_is_user_selected_view = FALSE; 01956 01957 fileview_show_desktop(); 01958 gtk_widget_show(window); 01959 }
void fileview_create_shortcut | ( | ) |
Create desktop shortcut(s) for the currently selected item(s).
---------------------------------------------------------------------------
Name : fileview_create_shortcut
-- |
--------------------------------------------------------------------------
Definition at line 1453 of file fileview.c.
References create_shortcut_item(), filelist_entry_free(), and get_entry_at_cursor().
Referenced by menu_on_item_activated().
01454 { 01455 filelist_entry_t *entry = get_entry_at_cursor(); 01456 if (entry) { 01457 create_shortcut_item(entry); 01458 filelist_entry_free(entry); 01459 } 01460 }
void fileview_dir_down | ( | const gchar * | dir, | |
const char * | cursorname | |||
) |
Definition at line 308 of file fileview.c.
References BROWSE_MODE, filemodel_chdir_down(), g_viewmode, LOGPRINTF, set_cursor(), and update_gui().
Referenced by activate_item(), activate_shortcut(), fileview_show_search_dialog(), and set_special_viewmode().
00309 { 00310 LOGPRINTF("dir=%s cursor=%s", dir, cursorname ? cursorname : "NULL"); 00311 g_assert(g_viewmode == BROWSE_MODE); 00312 00313 filemodel_chdir_down(dir, cursorname); 00314 00315 update_gui(); 00316 set_cursor(0, 0); 00317 }
void fileview_dir_up | ( | ) |
Definition at line 285 of file fileview.c.
References alphabar_select(), BROWSE_MODE, ERRORPRINTF, filemodel_chdir_up(), filemodel_get_dir_depth(), filemodel_get_first_alpha_index(), g_viewmode, set_cursor_at_filename(), update_gui(), and update_view_for_desktop().
Referenced by handle_special_item().
00286 { 00287 g_assert(g_viewmode == BROWSE_MODE); 00288 gchar* cursor_item = NULL; 00289 00290 if (filemodel_get_dir_depth() == 1) 00291 { 00292 // next dir up is the desktop 00293 update_view_for_desktop(); 00294 } 00295 00296 cursor_item = filemodel_chdir_up(); 00297 update_gui(); 00298 00299 if (cursor_item) { 00300 alphabar_select(filemodel_get_first_alpha_index()); 00301 set_cursor_at_filename(cursor_item); 00302 g_free(cursor_item); 00303 } else 00304 ERRORPRINTF("no cursor set!"); 00305 }
int fileview_get_xid | ( | ) |
Definition at line 1582 of file fileview.c.
References g_main_window.
Referenced by ipc_sys_startup_complete().
01583 { 01584 return GDK_WINDOW_XID(g_main_window->window); 01585 }
void fileview_grab_focus | ( | void | ) |
Grab focus for current view.
---------------------------------------------------------------------------
Name : fileview_grab_focus
-- |
--------------------------------------------------------------------------
Definition at line 218 of file fileview.c.
References CTB_CONTENTVIEW, CTB_ICONVIEW, CTB_LISTVIEW, g_current_view, g_iconview, and g_listview.
Referenced by fileview_show_search_dialog(), and on_window_activated().
00219 { 00220 switch (g_current_view) 00221 { 00222 case CTB_ICONVIEW: 00223 gtk_widget_grab_focus(GTK_WIDGET(g_iconview)); 00224 break; 00225 case CTB_LISTVIEW: 00226 case CTB_CONTENTVIEW: 00227 gtk_widget_grab_focus(GTK_WIDGET(g_listview)); 00228 break; 00229 default: 00230 break; 00231 } 00232 }
void fileview_init | ( | ) |
Initialisation.
---------------------------------------------------------------------------
Name : fileview_init
-- |
--------------------------------------------------------------------------
Definition at line 1962 of file fileview.c.
References filemodel_init(), and reset_delete_state().
Referenced by main().
01963 { 01964 filemodel_init(); 01965 reset_delete_state(); 01966 }
void fileview_media_mounted | ( | const gchar * | mountpoint | ) |
Notification that a storage device has been mounted.
---------------------------------------------------------------------------
Name : fileview_media_mounted
-- |
--------------------------------------------------------------------------
Definition at line 382 of file fileview.c.
References CTB_AUTOSELECT, fileview_set_view_type(), fileview_show_desktop(), g_is_user_selected_view, get_viewtype_from_registry(), and LOGPRINTF.
Referenced by main().
00383 { 00384 LOGPRINTF("entry: mountpoint [%s]", mountpoint); 00385 g_assert(mountpoint && *mountpoint); 00386 00387 ctb_viewtypes_t view = get_viewtype_from_registry(); 00388 if (view != CTB_AUTOSELECT) 00389 { 00390 fileview_set_view_type(view, FALSE); 00391 g_is_user_selected_view = FALSE; 00392 } 00393 00394 fileview_show_desktop(); 00395 }
void fileview_media_unmounted | ( | ) |
Notification that the storage device will be (has been) unmounted.
---------------------------------------------------------------------------
Name : fileview_media_unmounted
-- |
--------------------------------------------------------------------------
Definition at line 452 of file fileview.c.
References BROWSE_MODE, filemodel_chdir_desktop(), fileview_save_view_type(), g_search_dialog, and setViewMode().
Referenced by main().
00453 { 00454 fileview_save_view_type(); 00455 if (g_search_dialog) { 00456 gtk_widget_destroy(g_search_dialog); 00457 g_search_dialog = NULL; 00458 } 00459 setViewMode(BROWSE_MODE, FALSE); 00460 filemodel_chdir_desktop(); 00461 }
void fileview_move_undo | ( | ) |
Definition at line 1601 of file fileview.c.
References g_background, WINDOW_BOTTOM_PADDING, WINDOW_H_PADDING, and WINDOW_TOP_PADDING.
Referenced by on_changed_orientation().
01602 { 01603 gtk_alignment_set_padding( GTK_ALIGNMENT(g_background), 01604 WINDOW_TOP_PADDING, 01605 WINDOW_BOTTOM_PADDING, 01606 WINDOW_H_PADDING, 01607 WINDOW_H_PADDING ); 01608 }
void fileview_move_up | ( | guint | delta | ) |
Definition at line 1588 of file fileview.c.
References g_background, WINDOW_BOTTOM_PADDING, WINDOW_H_PADDING, and WINDOW_TOP_PADDING.
Referenced by on_changed_orientation().
01589 { 01590 if (delta > WINDOW_TOP_PADDING ) 01591 { 01592 delta = WINDOW_TOP_PADDING; 01593 } 01594 gtk_alignment_set_padding( GTK_ALIGNMENT(g_background), 01595 (WINDOW_TOP_PADDING - delta), 01596 WINDOW_BOTTOM_PADDING, 01597 WINDOW_H_PADDING, 01598 WINDOW_H_PADDING ); 01599 }
void fileview_refresh | ( | gboolean | force_reload | ) |
Refresh the current screen data, keep cursor at same item if possible.
---------------------------------------------------------------------------
Name : fileview_refresh
-- |
--------------------------------------------------------------------------
Definition at line 1361 of file fileview.c.
References alphabar_select(), alphabar_update(), BROWSE_MODE, filemodel_get_first_alpha_index(), filemodel_resync(), filemodel_scroll_to_filename(), filemodel_window_is_on_top(), fileview_stop_update_display(), get_filename_at_cursor(), LOGPRINTF, set_cursor_at_filename(), and setViewMode().
Referenced by fileview_update_screen_texts(), on_filesystem_change(), and on_window_activated().
01362 { 01363 LOGPRINTF(""); 01364 01365 if (filemodel_window_is_on_top()) fileview_stop_update_display(); 01366 01367 // cancel possible DELETE_MODE 01368 setViewMode(BROWSE_MODE, FALSE); 01369 01370 gchar *cursor_item = get_filename_at_cursor(); 01371 if (filemodel_resync(force_reload)) { 01372 alphabar_update(); 01373 filemodel_scroll_to_filename(cursor_item); 01374 alphabar_select(filemodel_get_first_alpha_index()); 01375 } 01376 01377 set_cursor_at_filename(cursor_item); 01378 g_free(cursor_item); 01379 }
void fileview_save_view_type | ( | ) |
Definition at line 442 of file fileview.c.
References g_current_view, g_is_user_selected_view, and save_viewtype_to_registry().
Referenced by fileview_media_unmounted(), and on_prepare_standby().
00443 { 00444 if (g_is_user_selected_view) 00445 { 00446 save_viewtype_to_registry(g_current_view); 00447 g_is_user_selected_view = FALSE; 00448 } 00449 }
void fileview_set_on_top | ( | gboolean | ontop | ) |
Definition at line 1382 of file fileview.c.
References filemodel_set_window_is_on_top(), START_TIMER, and STOP_TIMER.
Referenced by on_window_activated(), and on_window_deactivated().
01383 { 01384 if (ontop) { 01385 START_TIMER(); 01386 } else { 01387 STOP_TIMER(); 01388 } 01389 filemodel_set_window_is_on_top(ontop); 01390 }
void fileview_set_sort_order | ( | const ctb_sort_order_t | sort_order | ) |
Set sorting order for items in view.
---------------------------------------------------------------------------
Name : fileview_set_sort_order
[in] | sort_order | - requested sorting order |
--------------------------------------------------------------------------
Definition at line 261 of file fileview.c.
References alphabar_update(), filemodel_get_subtitle(), filemodel_set_sortorder(), fileview_stop_update_display(), g_subtitle_label, get_filename_at_cursor(), and set_cursor_at_filename().
Referenced by menu_on_item_activated().
00262 { 00263 fileview_stop_update_display(); 00264 gchar *cursor_item = get_filename_at_cursor(); 00265 00266 gboolean order_has_changed = filemodel_set_sortorder( sort_order, cursor_item, TRUE); 00267 if (order_has_changed) { 00268 gtk_label_set_text(GTK_LABEL(g_subtitle_label), filemodel_get_subtitle()); 00269 alphabar_update(); 00270 } 00271 set_cursor_at_filename(cursor_item); 00272 g_free(cursor_item); 00273 }
void fileview_set_view_type | ( | const ctb_viewtypes_t | view, | |
gboolean | do_cursor | |||
) |
Select which view to use for displaying the files.
---------------------------------------------------------------------------
Name : fileview_set_view_type
[in] | view | - requested view type |
--------------------------------------------------------------------------
Definition at line 1851 of file fileview.c.
References create_contentview(), create_iconview(), create_listview(), CTB_CONTENTVIEW, CTB_ICONVIEW, CTB_LISTVIEW, DELETE_MODE, filemodel_set_thumbsize(), fileview_set_cursor_at_filename(), fileview_stop_update_display(), g_current_view, g_eventbox, g_height, g_iconview, g_is_user_selected_view, g_listview, g_operation_in_progress, g_viewmode, g_width, get_filename_at_cursor(), listview_set_column_headers(), LOGPRINTF, menu_select_view_type(), MODTHUMB_MEDIUM, MODTHUMB_MINI, MODTHUMB_SMALL, update_padding(), WARNPRINTF, and widget.
Referenced by fileview_create(), fileview_media_mounted(), menu_on_item_activated(), and update_view_for_desktop().
01852 { 01853 if (g_viewmode == DELETE_MODE) { 01854 WARNPRINTF("cannot switch viewtype in delete mode"); 01855 return; 01856 } 01857 01858 LOGPRINTF("old=%d -> new=%d", g_current_view, view); 01859 g_is_user_selected_view = TRUE; 01860 if ( view == g_current_view ) return; 01861 fileview_stop_update_display(); 01862 01863 gchar *cursor_item = NULL; 01864 if (do_cursor) cursor_item = get_filename_at_cursor(); 01865 01866 // delete old view 01867 switch (g_current_view) { 01868 case CTB_ICONVIEW: 01869 if (g_iconview) { 01870 gtk_widget_destroy(g_iconview); 01871 g_iconview = NULL; 01872 } 01873 break; 01874 case CTB_LISTVIEW: 01875 case CTB_CONTENTVIEW: 01876 if (g_listview) { 01877 gtk_widget_destroy(g_listview); 01878 g_listview = NULL; 01879 } 01880 break; 01881 default: 01882 break; 01883 } 01884 01885 g_current_view = view; 01886 01887 // create new view 01888 GtkWidget *widget = NULL; 01889 switch (view) 01890 { 01891 case CTB_ICONVIEW: 01892 filemodel_set_thumbsize(MODTHUMB_MEDIUM, do_cursor); 01893 widget = create_iconview(); 01894 g_iconview = widget; 01895 g_signal_connect(widget, "destroy", G_CALLBACK(gtk_widget_destroyed), &widget); 01896 gtk_widget_show(widget); 01897 gtk_container_add(GTK_CONTAINER(g_eventbox), widget); 01898 if (g_width != 0) gtk_widget_set_size_request(widget, g_width, g_height); 01899 break; 01900 case CTB_LISTVIEW: 01901 filemodel_set_thumbsize(MODTHUMB_MINI, do_cursor); 01902 widget = create_listview(); 01903 g_listview = widget; 01904 g_signal_connect(widget, "destroy", G_CALLBACK(gtk_widget_destroyed), &widget); 01905 gtk_widget_show(widget); 01906 gtk_container_add(GTK_CONTAINER(g_eventbox), widget); 01907 listview_set_column_headers(); 01908 break; 01909 case CTB_CONTENTVIEW: 01910 filemodel_set_thumbsize(MODTHUMB_SMALL, do_cursor); 01911 widget = create_contentview(); 01912 g_listview = widget; 01913 g_signal_connect(widget, "destroy", G_CALLBACK(gtk_widget_destroyed), &widget); 01914 gtk_widget_show(widget); 01915 gtk_container_add(GTK_CONTAINER(g_eventbox), widget); 01916 if (g_width != 0) gtk_widget_set_size_request(widget, g_width, g_height); 01917 break; 01918 default: 01919 break; 01920 } 01921 01922 update_padding(); 01923 menu_select_view_type(view); 01924 if (do_cursor) { 01925 g_operation_in_progress = TRUE; 01926 fileview_set_cursor_at_filename(cursor_item); 01927 g_free(cursor_item); 01928 } 01929 }
void fileview_show_desktop | ( | ) |
Show content of the desktop.
---------------------------------------------------------------------------
Name : fileview_show_desktop
-- |
--------------------------------------------------------------------------
Definition at line 320 of file fileview.c.
References BROWSE_MODE, filemodel_chdir_desktop(), fileview_stop_update_display(), set_cursor(), setViewMode(), update_gui(), and update_view_for_desktop().
Referenced by fileview_create(), fileview_media_mounted(), and menu_on_goto_location().
00321 { 00322 fileview_stop_update_display(); 00323 // cancel possible DELETE_MODE 00324 setViewMode(BROWSE_MODE, FALSE); 00325 update_view_for_desktop(); 00326 filemodel_chdir_desktop(); 00327 00328 update_gui(); 00329 set_cursor(0, 0); 00330 }
void fileview_show_next_page | ( | ) |
Definition at line 1484 of file fileview.c.
References fileview_page_next(), get_cursor(), and START_TIMER.
Referenced by on_page_change().
01485 { 01486 START_TIMER(); 01487 gint row = 0; 01488 gint column = 0; 01489 get_cursor(&row, &column); 01490 fileview_page_next(row, column); 01491 }
void fileview_show_prev_page | ( | ) |
Definition at line 1474 of file fileview.c.
References fileview_page_previous(), get_cursor(), and START_TIMER.
Referenced by on_page_change().
01475 { 01476 START_TIMER(); 01477 gint row = 0; 01478 gint column = 0; 01479 get_cursor(&row, &column); 01480 fileview_page_previous(row, column); 01481 }
void fileview_show_search_dialog | ( | ) |
Definition at line 1324 of file fileview.c.
References DIR_LIBRARY, DM_HINT_FULL, filefind_dialog_create(), filefind_get_text(), filemodel_chdir_desktop(), filemodel_current_is_desktop(), filemodel_set_search_filter(), filemodel_set_viewmode2(), fileview_dir_down(), fileview_grab_focus(), fileview_stop_update_display(), g_main_window, g_search_dialog, ipc_menu_block(), ipc_menu_unblock(), on_idle_update_display(), SEARCH_VIEW, and SPECIAL_SEARCH.
Referenced by handle_special_item(), and on_file_search_clicked().
01325 { 01326 ipc_menu_block(); 01327 GtkWidget* dialog = filefind_dialog_create(g_main_window); 01328 g_search_dialog = dialog; 01329 gint result = gtk_dialog_run(GTK_DIALOG(dialog)); 01330 if (result != GTK_RESPONSE_NONE) fileview_stop_update_display(); 01331 switch (result) 01332 { 01333 case GTK_RESPONSE_ACCEPT: 01334 { 01335 if (!filemodel_current_is_desktop()) { 01336 filemodel_chdir_desktop(); 01337 } 01338 const gchar* search_string = filefind_get_text(); 01339 filemodel_set_search_filter(search_string); 01340 filemodel_set_viewmode2(SEARCH_VIEW); 01341 fileview_dir_down(DIR_LIBRARY, SPECIAL_SEARCH); 01342 } 01343 break; 01344 default: 01345 // do nothing 01346 break; 01347 } 01348 ipc_menu_unblock(); 01349 if (g_search_dialog) { 01350 gtk_widget_destroy(dialog); 01351 g_search_dialog = NULL; 01352 } 01353 fileview_grab_focus(); 01354 if (result != GTK_RESPONSE_ACCEPT && result != GTK_RESPONSE_NONE) { 01355 // Note: sometimes we only get partial update, force fullscreen one 01356 on_idle_update_display(DM_HINT_FULL); 01357 } 01358 }
void fileview_stop_update_display | ( | ) |
Definition at line 485 of file fileview.c.
References display_gain_control(), g_got_display_control, and LOGPRINTF.
Referenced by activate_item(), activate_shortcut(), fileview_page_next(), fileview_page_previous(), fileview_refresh(), fileview_set_sort_order(), fileview_set_view_type(), fileview_show_desktop(), fileview_show_search_dialog(), fileview_toggle_delete_mode(), handle_delete_activated(), handle_special_item(), on_letter_click(), on_window_activated(), set_special_viewmode(), and show_error_dialog().
00486 { 00487 LOGPRINTF("got_control=%d", g_got_display_control); 00488 if (!g_got_display_control) { 00489 g_got_display_control = TRUE; 00490 display_gain_control(); 00491 } 00492 }
void fileview_toggle_delete_mode | ( | ) |
Definition at line 1393 of file fileview.c.
References BROWSE_MODE, DELETE_MODE, fileview_stop_update_display(), g_viewmode, and setViewMode().
Referenced by menu_on_item_activated().
01394 { 01395 fileview_stop_update_display(); 01396 ctb_viewmodes_t newmode = BROWSE_MODE; 01397 switch (g_viewmode) { 01398 case BROWSE_MODE: 01399 newmode = DELETE_MODE; 01400 break; 01401 case DELETE_MODE: // fallthrough 01402 default: 01403 newmode = BROWSE_MODE; 01404 break; 01405 } 01406 setViewMode(newmode, TRUE); 01407 }
void fileview_update_screen_texts | ( | ) |
Update screen texts, using current language setting.
---------------------------------------------------------------------------
Name : fileview_update_screen_texts
-- |
--------------------------------------------------------------------------
Definition at line 209 of file fileview.c.
References filemodel_set_delete_text(), fileview_refresh(), listview_set_column_headers(), and update_titles().
Referenced by main_set_locale().
00210 { 00211 listview_set_column_headers(); 00212 fileview_refresh(TRUE); 00213 filemodel_set_delete_text(_("Finish Delete")); 00214 update_titles(); 00215 }
void show_error_dialog | ( | const gchar * | msg | ) |
Definition at line 1305 of file fileview.c.
References DM_HINT_FULL, fileview_stop_update_display(), g_main_window, ipc_menu_block(), ipc_menu_unblock(), and on_idle_update_display().
Referenced by activate_item(), activate_shortcut(), activate_shortcut_to_application(), activate_shortcut_to_web_location(), and create_shortcut_item().
01306 { 01307 GtkWidget *dialog = gtk_message_dialog_new( 01308 GTK_WINDOW(g_main_window), 01309 GTK_DIALOG_DESTROY_WITH_PARENT, 01310 GTK_MESSAGE_ERROR, 01311 GTK_BUTTONS_OK, 01312 msg ); 01313 gtk_window_set_deletable( GTK_WINDOW(dialog), FALSE ); 01314 ipc_menu_block(); 01315 gtk_dialog_run( GTK_DIALOG(dialog) ); 01316 fileview_stop_update_display(); 01317 ipc_menu_unblock(); 01318 gtk_widget_destroy( dialog ); 01319 // Note: sometimes we only get partial update, force fullscreen one 01320 on_idle_update_display(DM_HINT_FULL); 01321 }