void nemo_application_open_location (NemoApplication *application, GFile *location, GFile *selection, const char *startup_id) { NemoWindow *window; GList *sel_list = NULL; window = nemo_application_create_window (application, gdk_screen_get_default ()); gtk_window_set_startup_id (GTK_WINDOW (window), startup_id); if (selection != NULL) { sel_list = g_list_prepend (sel_list, nemo_file_get (selection)); } nemo_window_slot_open_location (nemo_window_get_active_slot (window), location, 0, sel_list); if (sel_list != NULL) { nemo_file_list_free (sel_list); } }
void nemo_window_slot_go_home (NemoWindowSlot *slot, NemoWindowOpenFlags flags) { GFile *home; g_return_if_fail (NEMO_IS_WINDOW_SLOT (slot)); home = g_file_new_for_path (g_get_home_dir ()); nemo_window_slot_open_location (slot, home, flags); g_object_unref (home); }
static void activate_bookmark_in_menu_item (GtkAction *action, gpointer user_data) { NemoWindowSlot *slot; BookmarkHolder *holder; GFile *location; holder = (BookmarkHolder *)user_data; location = nemo_bookmark_get_location (holder->bookmark); slot = nemo_window_get_active_slot (holder->window); nemo_window_slot_open_location (slot, location, nemo_event_get_window_open_flags ()); g_object_unref (location); }
void nemo_window_slot_go_up (NemoWindowSlot *slot, NemoWindowOpenFlags flags) { GFile *parent; if (slot->location == NULL) { return; } parent = g_file_get_parent (slot->location); if (parent == NULL) { return; } nemo_window_slot_open_location (slot, parent, flags); g_object_unref (parent); }
static gboolean path_bar_button_released_callback (GtkWidget *widget, GdkEventButton *event, NemoWindowPane *pane) { NemoWindowSlot *slot; NemoWindowOpenFlags flags; GFile *location; int mask; gboolean handle_button_release; mask = event->state & gtk_accelerator_get_default_mod_mask (); flags = 0; handle_button_release = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "handle-button-release")); if (event->type == GDK_BUTTON_RELEASE && handle_button_release) { location = nemo_path_bar_get_path_for_button (NEMO_PATH_BAR (pane->path_bar), widget); if (event->button == 2 && mask == 0) { flags = NEMO_WINDOW_OPEN_FLAG_NEW_TAB; } else if (event->button == 1 && mask == GDK_CONTROL_MASK) { flags = NEMO_WINDOW_OPEN_FLAG_NEW_WINDOW; } if (flags != 0) { slot = nemo_window_get_active_slot (pane->window); nemo_window_slot_open_location (slot, location, flags, NULL); g_object_unref (location); return TRUE; } g_object_unref (location); } return FALSE; }
/* 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); }