static void thunar_location_entry_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { switch (prop_id) { case PROP_CURRENT_DIRECTORY: thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (object), g_value_get_object (value)); break; case PROP_SELECTED_FILES: thunar_component_set_selected_files (THUNAR_COMPONENT (object), g_value_get_boxed (value)); break; case PROP_UI_MANAGER: thunar_component_set_ui_manager (THUNAR_COMPONENT (object), g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void thunar_history_go_forward (ThunarHistory *history, guint n) { _thunar_return_if_fail (THUNAR_IS_HISTORY (history)); _thunar_return_if_fail (n > 0); /* go forward up to n steps */ for (; n > 0 && history->forward_list != NULL; --n) { /* prepend the previous current directory to the "back" list */ if (G_LIKELY (history->current_directory != NULL)) history->back_list = g_list_prepend (history->back_list, history->current_directory); /* remove the first directory from the "forward" list and make it the current directory */ history->current_directory = history->forward_list->data; history->forward_list = g_list_delete_link (history->forward_list, history->forward_list); } /* tell the other modules to change the current directory */ if (G_LIKELY (history->current_directory != NULL)) thunar_navigator_change_directory (THUNAR_NAVIGATOR (history), history->current_directory); /* update the sensitivity of the actions */ gtk_action_set_sensitive (history->action_back, (history->back_list != NULL)); gtk_action_set_sensitive (history->action_forward, (history->forward_list != NULL)); }
static void thunar_location_entry_activate (GtkWidget *path_entry, ThunarLocationEntry *location_entry) { ThunarFile *file; GError *error = NULL; _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry)); _thunar_return_if_fail (location_entry->path_entry == path_entry); /* determine the current file from the path entry */ file = thunar_path_entry_get_current_file (THUNAR_PATH_ENTRY (path_entry)); if (G_LIKELY (file != NULL)) { /* check if we have a new directory or a file to launch */ if (thunar_file_is_directory (file)) { /* open the new directory */ thunar_navigator_change_directory (THUNAR_NAVIGATOR (location_entry), file); } else { /* try to launch the selected file */ if (!thunar_file_launch (file, path_entry, &error)) { thunar_dialogs_show_error (path_entry, error, _("Failed to launch \"%s\""), thunar_file_get_display_name (file)); g_error_free (error); } /* be sure to reset the current file of the path entry */ if (G_LIKELY (location_entry->current_directory != NULL)) thunar_path_entry_set_current_file (THUNAR_PATH_ENTRY (path_entry), location_entry->current_directory); } } }
static void thunar_location_entry_finalize (GObject *object) { /* disconnect from the selected files and the UI manager */ thunar_component_set_selected_files (THUNAR_COMPONENT (object), NULL); thunar_component_set_ui_manager (THUNAR_COMPONENT (object), NULL); /* disconnect from the current directory */ thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (object), NULL); (*G_OBJECT_CLASS (thunar_location_entry_parent_class)->finalize) (object); }
static void thunar_history_dispose (GObject *object) { ThunarHistory *history = THUNAR_HISTORY (object); /* disconnect from the current directory */ thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (history), NULL); /* disconnect from the action group */ thunar_history_set_action_group (history, NULL); (*G_OBJECT_CLASS (thunar_history_parent_class)->dispose) (object); }
static void thunar_location_bar_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { switch (prop_id) { case PROP_CURRENT_DIRECTORY: thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (object), g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void thunar_location_bar_set_current_directory (ThunarNavigator *navigator, ThunarFile *current_directory) { ThunarLocationBar *bar = THUNAR_LOCATION_BAR (navigator); GtkWidget *child; if (bar->current_directory) g_object_unref (bar->current_directory); bar->current_directory = current_directory; if (current_directory) g_object_ref (current_directory); if ((child = gtk_bin_get_child (GTK_BIN (bar))) && THUNAR_IS_NAVIGATOR (child)) thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (child), current_directory); g_object_notify (G_OBJECT (bar), "current-directory"); }
static void thunar_location_bar_finalize (GObject *object) { ThunarLocationBar *bar = THUNAR_LOCATION_BAR (object); _thunar_return_if_fail (THUNAR_IS_LOCATION_BAR (bar)); if (bar->locationEntry) g_object_unref (bar->locationEntry); if (bar->locationButtons) g_object_unref (bar->locationButtons); /* release from the current_directory */ thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (bar), NULL); (*G_OBJECT_CLASS (thunar_location_bar_parent_class)->finalize) (object); }
static GtkWidget * thunar_location_bar_install_widget (ThunarLocationBar *bar, GType type) { GtkWidget *installedWidget, *child; /* check if the the right type is already installed */ if ((child = gtk_bin_get_child (GTK_BIN (bar))) && G_TYPE_CHECK_INSTANCE_TYPE (child, type)) return child; if (type == THUNAR_TYPE_LOCATION_ENTRY) { if (bar->locationEntry == NULL) { bar->locationEntry = gtk_widget_new (THUNAR_TYPE_LOCATION_ENTRY, "current-directory", NULL, NULL); g_object_ref (bar->locationEntry); g_signal_connect_swapped (bar->locationEntry, "reload-requested", G_CALLBACK (thunar_location_bar_reload_requested), bar); g_signal_connect_swapped (bar->locationEntry, "change-directory", G_CALLBACK (thunar_navigator_change_directory), THUNAR_NAVIGATOR (bar)); g_signal_connect_swapped (bar->locationEntry, "open-new-tab", G_CALLBACK (thunar_navigator_open_new_tab), THUNAR_NAVIGATOR (bar)); } installedWidget = bar->locationEntry; } else { if (bar->locationButtons == NULL) { bar->locationButtons = gtk_widget_new (THUNAR_TYPE_LOCATION_BUTTONS, "current-directory", NULL, NULL); g_object_ref (bar->locationButtons); g_signal_connect_swapped (bar->locationButtons, "entry-requested", G_CALLBACK (thunar_location_bar_request_entry), bar); g_signal_connect_swapped (bar->locationButtons, "change-directory", G_CALLBACK (thunar_navigator_change_directory), THUNAR_NAVIGATOR (bar)); g_signal_connect_swapped (bar->locationButtons, "open-new-tab", G_CALLBACK (thunar_navigator_open_new_tab), THUNAR_NAVIGATOR (bar)); } installedWidget = bar->locationButtons; } thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (installedWidget), bar->current_directory); if ((child = gtk_bin_get_child (GTK_BIN (bar)))) gtk_container_remove (GTK_CONTAINER (bar), child); gtk_container_add (GTK_CONTAINER (bar), installedWidget); gtk_widget_show (installedWidget); return installedWidget; }
static void thunar_history_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { ThunarHistory *history = THUNAR_HISTORY (object); switch (prop_id) { case PROP_ACTION_GROUP: thunar_history_set_action_group (history, g_value_get_object (value)); break; case PROP_CURRENT_DIRECTORY: thunar_navigator_set_current_directory (THUNAR_NAVIGATOR (history), g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void thunar_location_entry_item_activated (GtkWidget *item, ThunarLocationEntry *location_entry) { ThunarVfsVolume *volume; ThunarFile *file; GtkWidget *window; GError *error = NULL; _thunar_return_if_fail (GTK_IS_MENU_ITEM (item)); _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry)); /* determine the toplevel window */ window = gtk_widget_get_toplevel (GTK_WIDGET (location_entry)); /* check if the item corresponds to a volume */ volume = g_object_get_data (G_OBJECT (item), "thunar-vfs-volume"); if (G_UNLIKELY (volume != NULL)) { /* check if the volume isn't already mounted */ if (G_LIKELY (!thunar_vfs_volume_is_mounted (volume))) { /* try to mount the volume */ if (!thunar_vfs_volume_mount (volume, window, &error)) { /* display an error dialog to inform the user */ thunar_dialogs_show_error (window, error, _("Failed to mount \"%s\""), thunar_vfs_volume_get_name (volume)); g_error_free (error); return; } } /* try to determine the mount point of the volume */ file = thunar_file_get_for_path (thunar_vfs_volume_get_mount_point (volume), &error); if (G_UNLIKELY (file == NULL)) { /* display an error dialog to inform the user */ thunar_dialogs_show_error (window, error, _("Failed to determine the mount point for %s"), thunar_vfs_volume_get_name (volume)); g_error_free (error); return; } } else { /* determine the file from the item */ file = g_object_get_data (G_OBJECT (item), "thunar-file"); if (G_LIKELY (file != NULL)) g_object_ref (G_OBJECT (file)); } /* check if we have a file object now */ if (G_LIKELY (file != NULL)) { /* make sure that this is actually a directory */ if (thunar_file_is_directory (file)) { /* open the new directory */ thunar_navigator_change_directory (THUNAR_NAVIGATOR (location_entry), file); } /* cleanup */ g_object_unref (G_OBJECT (file)); } }