void nemo_window_pane_slot_close (NemoWindowPane *pane, NemoWindowSlot *slot) { NemoWindowSlot *next_slot; DEBUG ("Requesting to remove slot %p from pane %p", slot, pane); if (pane->window) { NemoWindow *window; window = pane->window; if (pane->active_slot == slot) { next_slot = get_first_inactive_slot (NEMO_WINDOW_PANE (pane)); nemo_window_set_active_slot (window, next_slot); } nemo_window_pane_close_slot (pane, slot); /* If that was the last slot in the pane, close the pane or even the whole window. */ if (pane->slots == NULL) { if (nemo_window_split_view_showing (window)) { NemoWindowPane *new_pane; DEBUG ("Last slot removed from the pane %p, closing it", pane); nemo_window_close_pane (window, pane); new_pane = g_list_nth_data (window->details->panes, 0); if (new_pane->active_slot == NULL) { new_pane->active_slot = get_first_inactive_slot (new_pane); } DEBUG ("Calling set_active_pane, new slot %p", new_pane->active_slot); nemo_window_set_active_pane (window, new_pane); nemo_window_update_show_hide_menu_items (window); } else { DEBUG ("Last slot removed from the last pane, close the window"); nemo_window_close (window); } } } }
static void notebook_page_added_cb (GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data) { NemoWindowPane *pane; NemoWindowSlot *slot; NemoWindowSlot *dummy_slot; gboolean dnd_slot; pane = NEMO_WINDOW_PANE (user_data); slot = NEMO_WINDOW_SLOT (page); //Slot has been dropped onto another pane (new window or tab bar of other window) //So reassociate the pane if needed. if (slot->pane != pane) { slot->pane->slots = g_list_remove (slot->pane->slots, slot); slot->pane = pane; pane->slots = g_list_append (pane->slots, slot); g_signal_emit_by_name (slot, "changed-pane"); nemo_window_set_active_slot (nemo_window_slot_get_window (slot), slot); } dnd_slot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (slot), "dnd-window-slot")); if (!dnd_slot) { //Slot does not come from dnd window creation. return; } g_object_set_data (G_OBJECT (page), "dnd-window-slot", GINT_TO_POINTER (FALSE)); dummy_slot = g_list_nth_data (pane->slots, 0); if (dummy_slot != NULL) { nemo_window_pane_close_slot (dummy_slot->pane, dummy_slot); } gtk_widget_show (GTK_WIDGET (pane)); gtk_widget_show (GTK_WIDGET (pane->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); }