static void update_bookmarks (NemoWindow *window) { NemoBookmarkList *bookmarks; NemoBookmark *bookmark; guint bookmark_count; guint index; GtkUIManager *ui_manager; g_assert (NEMO_IS_WINDOW (window)); g_assert (window->details->bookmarks_merge_id == 0); g_assert (window->details->bookmarks_action_group == NULL); if (window->details->bookmark_list == NULL) { window->details->bookmark_list = nemo_bookmark_list_new (); } bookmarks = window->details->bookmark_list; ui_manager = nemo_window_get_ui_manager (NEMO_WINDOW (window)); window->details->bookmarks_merge_id = gtk_ui_manager_new_merge_id (ui_manager); window->details->bookmarks_action_group = gtk_action_group_new ("BookmarksGroup"); g_signal_connect (window->details->bookmarks_action_group, "connect-proxy", G_CALLBACK (connect_proxy_cb), NULL); gtk_ui_manager_insert_action_group (ui_manager, window->details->bookmarks_action_group, -1); g_object_unref (window->details->bookmarks_action_group); /* append new set of bookmarks */ bookmark_count = nemo_bookmark_list_length (bookmarks); for (index = 0; index < bookmark_count; ++index) { bookmark = nemo_bookmark_list_item_at (bookmarks, index); if (!nemo_bookmark_get_exists (bookmark)) { continue; } nemo_menus_append_bookmark_to_menu (NEMO_WINDOW (window), bookmark, MENU_PATH_BOOKMARKS_PLACEHOLDER, "dynamic", index, window->details->bookmarks_action_group, window->details->bookmarks_merge_id, G_CALLBACK (refresh_bookmarks_menu), show_bogus_bookmark_window); } }
static void action_split_view_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; gboolean is_active; window = NEMO_WINDOW (user_data); is_active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); if (is_active != nemo_window_split_view_showing (window)) { NemoWindowSlot *slot; if (is_active) { nemo_window_split_view_on (window); } else { nemo_window_split_view_off (window); } slot = nemo_window_get_active_slot (window); if (slot != NULL) { nemo_view_update_menus (slot->content_view); } } }
/* FIXME remove when gtknotebook's func for this becomes public, bug #.... */ static NemoNotebook * find_notebook_at_pointer (gint abs_x, gint abs_y) { GdkDeviceManager *manager; GdkDevice *pointer; GdkWindow *win_at_pointer, *toplevel_win; gpointer toplevel = NULL; gint x, y; /* FIXME multi-head */ manager = gdk_display_get_device_manager (gdk_display_get_default ()); pointer = gdk_device_manager_get_client_pointer (manager); win_at_pointer = gdk_device_get_window_at_position (pointer, &x, &y); if (win_at_pointer == NULL) { /* We are outside all windows containing a notebook */ return NULL; } toplevel_win = gdk_window_get_toplevel (win_at_pointer); /* get the GtkWidget which owns the toplevel GdkWindow */ gdk_window_get_user_data (toplevel_win, &toplevel); /* toplevel should be an NemoWindow */ if (toplevel != NULL && NEMO_IS_WINDOW (toplevel)) { return NEMO_NOTEBOOK (NEMO_WINDOW (toplevel)->details->active_pane->notebook); } return NULL; }
static void action_places_toggle_callback (GtkButton *button, NemoStatusBar *bar) { nemo_window_set_sidebar_id (NEMO_WINDOW (bar->window), NEMO_WINDOW_SIDEBAR_PLACES); nemo_status_bar_sync_button_states (bar); }
static void action_forward_callback (GtkAction *action, gpointer user_data) { nemo_window_back_or_forward (NEMO_WINDOW (user_data), FALSE, 0, nemo_event_should_open_in_new_tab ()); }
static void action_new_tab_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; window = NEMO_WINDOW (user_data); nemo_window_new_tab (window); }
static void action_reload_callback (GtkAction *action, gpointer user_data) { NemoWindowSlot *slot; slot = nemo_window_get_active_slot (NEMO_WINDOW (user_data)); nemo_window_slot_reload (slot); }
static void action_connect_to_server_callback (GtkAction *action, gpointer user_data) { NemoWindow *window = NEMO_WINDOW (user_data); GtkWidget *dialog; dialog = nemo_connect_server_dialog_new (window); gtk_widget_show (dialog); }
static void action_stop_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowSlot *slot; window = NEMO_WINDOW (user_data); slot = nemo_window_get_active_slot (window); nemo_window_slot_stop_loading (slot); }
static gboolean nemo_window_delete_event_callback (GtkWidget *widget, GdkEvent *event, gpointer user_data) { NemoWindow *window; window = NEMO_WINDOW (widget); nemo_window_close (window); return TRUE; }
static void action_close_window_slot_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowSlot *slot; window = NEMO_WINDOW (user_data); slot = nemo_window_get_active_slot (window); nemo_window_pane_slot_close (slot->pane, slot); }
static void action_home_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowSlot *slot; window = NEMO_WINDOW (user_data); slot = nemo_window_get_active_slot (window); nemo_window_slot_go_home (slot, nemo_event_should_open_in_new_tab ()); }
void nemo_status_bar_sync_button_states (NemoStatusBar *bar) { const gchar *sidebar_id = nemo_window_get_sidebar_id (NEMO_WINDOW (bar->window)); gboolean sidebar_visible = nemo_window_get_show_sidebar (NEMO_WINDOW (bar->window)); if (sidebar_visible) { gtk_widget_show (bar->tree_button); gtk_widget_show (bar->places_button); gtk_widget_show (bar->separator); gtk_widget_show (bar->hide_button); gtk_widget_hide (bar->show_button); } else { gtk_widget_hide (bar->tree_button); gtk_widget_hide (bar->places_button); gtk_widget_hide (bar->hide_button); gtk_widget_hide (bar->separator); gtk_widget_show (bar->show_button); } g_signal_handlers_block_by_func (GTK_BUTTON (bar->tree_button), action_treeview_toggle_callback, bar); if (g_strcmp0 (sidebar_id, NEMO_WINDOW_SIDEBAR_TREE) == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->tree_button), TRUE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->tree_button), FALSE); } g_signal_handlers_unblock_by_func (GTK_BUTTON (bar->tree_button), action_treeview_toggle_callback, bar); g_signal_handlers_block_by_func (GTK_BUTTON (bar->places_button), action_places_toggle_callback, bar); if (g_strcmp0 (sidebar_id, NEMO_WINDOW_SIDEBAR_PLACES) == 0) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->places_button), TRUE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->places_button), FALSE); } g_signal_handlers_unblock_by_func (GTK_BUTTON (bar->places_button), action_places_toggle_callback, bar); }
static void action_show_hide_sidebar_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; window = NEMO_WINDOW (user_data); if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { nemo_window_show_sidebar (window); } else { nemo_window_hide_sidebar (window); } }
void nemo_desktop_window_update_directory (NemoDesktopWindow *window) { GFile *location; g_assert (NEMO_IS_DESKTOP_WINDOW (window)); window->details->loaded = FALSE; location = g_file_new_for_uri (EEL_DESKTOP_URI); nemo_window_go_to (NEMO_WINDOW (window), location); window->details->loaded = TRUE; g_object_unref (location); }
static void action_nemo_manual_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; GError *error; GtkWidget *dialog; const char* helpuri; const char* name = gtk_action_get_name (action); error = NULL; window = NEMO_WINDOW (user_data); if (g_str_equal (name, "NemoHelpSearch")) { helpuri = "help:gnome-help/files-search"; } else if (g_str_equal (name,"NemoHelpSort")) { helpuri = "help:gnome-help/files-sort"; } else if (g_str_equal (name, "NemoHelpLost")) { helpuri = "help:gnome-help/files-lost"; } else if (g_str_equal (name, "NemoHelpShare")) { helpuri = "help:gnome-help/files-share"; } else { helpuri = "help:gnome-help/files"; } if (NEMO_IS_DESKTOP_WINDOW (window)) { nemo_launch_application_from_command (gtk_window_get_screen (GTK_WINDOW (window)), "gnome-help", FALSE, NULL); } else { gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)), helpuri, gtk_get_current_event_time (), &error); } if (error) { dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("There was an error displaying help: \n%s"), error->message); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_widget_show (dialog); g_error_free (error); } }
static void action_new_window_callback (GtkAction *action, gpointer user_data) { NemoApplication *application; NemoWindow *current_window, *new_window; current_window = NEMO_WINDOW (user_data); application = nemo_application_get_singleton (); new_window = nemo_application_create_window ( application, gtk_window_get_screen (GTK_WINDOW (current_window))); nemo_window_slot_go_home (nemo_window_get_active_slot (new_window), FALSE); }
void nemo_application_close_all_windows (NemoApplication *self) { GList *list_copy; GList *l; list_copy = g_list_copy (gtk_application_get_windows (GTK_APPLICATION (self))); for (l = list_copy; l != NULL; l = l->next) { NemoWindow *window; window = NEMO_WINDOW (l->data); nemo_window_close (window); } g_list_free (list_copy); }
static void action_go_to_trash_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowSlot *slot; GFile *trash; window = NEMO_WINDOW (user_data); slot = nemo_window_get_active_slot (window); trash = g_file_new_for_uri ("trash:///"); nemo_window_slot_go_to (slot, trash, nemo_event_should_open_in_new_tab ()); g_object_unref (trash); }
static void action_go_to_network_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowSlot *slot; GFile *network; window = NEMO_WINDOW (user_data); slot = nemo_window_get_active_slot (window); network = g_file_new_for_uri (NETWORK_URI); nemo_window_slot_go_to (slot, network, nemo_event_should_open_in_new_tab ()); g_object_unref (network); }
static void action_show_hidden_files_callback (GtkAction *action, gpointer callback_data) { NemoWindow *window; NemoWindowShowHiddenFilesMode mode; window = NEMO_WINDOW (callback_data); if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { mode = NEMO_WINDOW_SHOW_HIDDEN_FILES_ENABLE; } else { mode = NEMO_WINDOW_SHOW_HIDDEN_FILES_DISABLE; } nemo_window_set_hidden_files_mode (window, mode); }
static void action_go_to_computer_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowSlot *slot; GFile *computer; window = NEMO_WINDOW (user_data); slot = nemo_window_get_active_slot (window); computer = g_file_new_for_uri (COMPUTER_URI); nemo_window_slot_go_to (slot, computer, nemo_event_should_open_in_new_tab ()); g_object_unref (computer); }
static void nemo_desktop_window_constructed (GObject *obj) { GtkActionGroup *action_group; GtkAction *action; AtkObject *accessible; NemoDesktopWindow *window = NEMO_DESKTOP_WINDOW (obj); NemoWindow *nwindow = NEMO_WINDOW (obj); G_OBJECT_CLASS (nemo_desktop_window_parent_class)->constructed (obj); g_object_set_data (G_OBJECT (window), "monitor_number", GINT_TO_POINTER (window->details->monitor)); gtk_widget_hide (nwindow->details->statusbar); gtk_widget_hide (nwindow->details->menubar); action_group = nemo_window_get_main_action_group (nwindow); /* Don't allow close action on desktop */ action = gtk_action_group_get_action (action_group, NEMO_ACTION_CLOSE); gtk_action_set_sensitive (action, FALSE); /* Don't allow new tab on desktop */ action = gtk_action_group_get_action (action_group, NEMO_ACTION_NEW_TAB); gtk_action_set_sensitive (action, FALSE); /* Set the accessible name so that it doesn't inherit the cryptic desktop URI. */ accessible = gtk_widget_get_accessible (GTK_WIDGET (window)); if (accessible) { atk_object_set_name (accessible, _("Desktop")); } nemo_desktop_window_update_geometry (window); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); gtk_window_set_decorated (GTK_WINDOW (window), FALSE); gtk_widget_show (GTK_WIDGET (window)); }
/** * refresh_go_menu: * * Refresh list of bookmarks at end of Go menu to match centralized history list. * @window: The NemoWindow whose Go menu will be refreshed. **/ static void nemo_window_initialize_go_menu (NemoWindow *window) { GtkUIManager *ui_manager; GtkWidget *menuitem; int i; ui_manager = nemo_window_get_ui_manager (NEMO_WINDOW (window)); for (i = 0; i < G_N_ELEMENTS (icon_entries); i++) { menuitem = gtk_ui_manager_get_widget ( ui_manager, icon_entries[i]); gtk_image_menu_item_set_always_show_image ( GTK_IMAGE_MENU_ITEM (menuitem), TRUE); } }
static void action_go_to_templates_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowSlot *slot; char *path; GFile *location; window = NEMO_WINDOW (user_data); slot = nemo_window_get_active_slot (window); path = nemo_get_templates_directory (); location = g_file_new_for_path (path); g_free (path); nemo_window_slot_go_to (slot, location, nemo_event_should_open_in_new_tab ()); g_object_unref (location); }
static void action_split_view_same_location_callback (GtkAction *action, gpointer user_data) { NemoWindow *window; NemoWindowPane *next_pane; GFile *location; window = NEMO_WINDOW (user_data); next_pane = nemo_window_get_next_pane (window); if (!next_pane) { return; } location = nemo_window_slot_get_location (next_pane->active_slot); if (location) { nemo_window_slot_go_to (nemo_window_get_active_slot (window), location, FALSE); g_object_unref (location); } }
static void nemo_desktop_window_constructed (GObject *obj) { GtkActionGroup *action_group; GtkAction *action; AtkObject *accessible; NemoDesktopWindow *window = NEMO_DESKTOP_WINDOW (obj); NemoWindow *nwindow = NEMO_WINDOW (obj); G_OBJECT_CLASS (nemo_desktop_window_parent_class)->constructed (obj); gtk_widget_hide (nwindow->details->statusbar); gtk_widget_hide (nwindow->details->menubar); action_group = nemo_window_get_main_action_group (nwindow); /* Don't allow close action on desktop */ action = gtk_action_group_get_action (action_group, NEMO_ACTION_CLOSE); gtk_action_set_sensitive (action, FALSE); /* Don't allow new tab on desktop */ action = gtk_action_group_get_action (action_group, NEMO_ACTION_NEW_TAB); gtk_action_set_sensitive (action, FALSE); /* Set the accessible name so that it doesn't inherit the cryptic desktop URI. */ accessible = gtk_widget_get_accessible (GTK_WIDGET (window)); if (accessible) { atk_object_set_name (accessible, _("Desktop")); } /* Monitor the preference to have the desktop */ /* point to the Unix home folder */ g_signal_connect_swapped (nemo_preferences, "changed::" NEMO_PREFERENCES_DESKTOP_IS_HOME_DIR, G_CALLBACK (nemo_desktop_window_update_directory), window); }
static void show_hidden_files_preference_callback (gpointer callback_data) { NemoWindow *window; GtkAction *action; window = NEMO_WINDOW (callback_data); if (window->details->show_hidden_files_mode == NEMO_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { action = gtk_action_group_get_action (nemo_window_get_main_action_group (window), NEMO_ACTION_SHOW_HIDDEN_FILES); /* update button */ g_signal_handlers_block_by_func (action, action_show_hidden_files_callback, window); gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_SHOW_HIDDEN_FILES)); g_signal_handlers_unblock_by_func (action, action_show_hidden_files_callback, window); /* inform views */ nemo_window_set_hidden_files_mode (window, NEMO_WINDOW_SHOW_HIDDEN_FILES_DEFAULT); } }
static NemoWindow * nemo_location_bar_get_window (GtkWidget *bar) { return NEMO_WINDOW (gtk_widget_get_ancestor (bar, NEMO_TYPE_WINDOW)); }
/* Called whenever a mount is unmounted. Check and see if there are * any windows open displaying contents on the mount. If there are, * close them. It would also be cool to save open window and position * info. */ static void mount_removed_callback (GVolumeMonitor *monitor, GMount *mount, NemoMainApplication *application) { GList *window_list, *node, *close_list; NemoWindow *window; NemoWindowSlot *slot; NemoWindowSlot *force_no_close_slot; GFile *root, *computer; gchar *uri; guint n_slots; close_list = NULL; force_no_close_slot = NULL; n_slots = 0; /* Check and see if any of the open windows are displaying contents from the unmounted mount */ window_list = gtk_application_get_windows (GTK_APPLICATION (application)); root = g_mount_get_root (mount); uri = g_file_get_uri (root); DEBUG ("Removed mount at uri %s", uri); g_free (uri); /* Construct a list of windows to be closed. Do not add the non-closable windows to the list. */ for (node = window_list; node != NULL; node = node->next) { window = NEMO_WINDOW (node->data); if (window != NULL) { GList *l; GList *lp; for (lp = window->details->panes; lp != NULL; lp = lp->next) { NemoWindowPane *pane; pane = (NemoWindowPane*) lp->data; for (l = pane->slots; l != NULL; l = l->next) { slot = l->data; n_slots++; if (nemo_window_slot_should_close_with_mount (slot, mount)) { close_list = g_list_prepend (close_list, slot); } } /* for all slots */ } /* for all panes */ } } /* Handle the windows in the close list. */ for (node = close_list; node != NULL; node = node->next) { slot = node->data; if (slot != force_no_close_slot) { if (g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_CLOSE_DEVICE_VIEW_ON_EJECT)) nemo_window_pane_close_slot (slot->pane, slot); else nemo_window_slot_go_home (slot, FALSE); } else { computer = g_file_new_for_path (g_get_home_dir ()); nemo_window_slot_open_location (slot, computer, 0); g_object_unref(computer); } } g_list_free (close_list); }