Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring-loaded folders #110

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions libcaja-private/caja-icon-container.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ enum
SELECTION_CHANGED,
ICON_ADDED,
ICON_REMOVED,
ICON_DROP_TARGET_CHANGED,
CLEARED,
START_INTERACTIVE_SEARCH,
LAST_SIGNAL
Expand Down Expand Up @@ -6524,6 +6525,16 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);

signals[ICON_DROP_TARGET_CHANGED]
= g_signal_new ("icon_drop_target_changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CajaIconContainerClass,
icon_drop_target_changed),
NULL, NULL,
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);

signals[CLEARED]
= g_signal_new ("cleared",
G_TYPE_FROM_CLASS (class),
Expand Down Expand Up @@ -10387,6 +10398,14 @@ caja_icon_container_accessible_get_type (void)
return type;
}

void
caja_icon_container_drop_target_changed (CajaIconContainer *container,
CajaIconData *icon_data)
{
g_signal_emit (G_OBJECT (container), signals[ICON_DROP_TARGET_CHANGED],
0, icon_data);
}

#if ! defined (CAJA_OMIT_SELF_CHECK)

static char *
Expand Down
4 changes: 4 additions & 0 deletions libcaja-private/caja-icon-container.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ typedef struct
CajaIconData *data);
void (* icon_removed) (CajaIconContainer *container,
CajaIconData *data);
void (* icon_drop_target_changed) (CajaIconContainer *container,
CajaIconData *data);
void (* cleared) (CajaIconContainer *container);
gboolean (* start_interactive_search) (CajaIconContainer *container);
} CajaIconContainerClass;
Expand Down Expand Up @@ -339,6 +341,8 @@ void caja_icon_container_set_use_drop_shadows (CajaIconCon
gboolean use_drop_shadows);
char* caja_icon_container_get_icon_description (CajaIconContainer *container,
CajaIconData *data);
void caja_icon_container_drop_target_changed (CajaIconContainer *container,
CajaIconData *icon_data);
gboolean caja_icon_container_get_allow_moves (CajaIconContainer *container);
void caja_icon_container_set_allow_moves (CajaIconContainer *container,
gboolean allow_moves);
Expand Down
2 changes: 2 additions & 0 deletions libcaja-private/caja-icon-dnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,8 @@ set_drop_target (CajaIconContainer *container,
container->details->drop_target = icon;
caja_icon_container_update_icon (container, old_icon);
caja_icon_container_update_icon (container, icon);

caja_icon_container_drop_target_changed (container, icon ? icon->data : NULL);
}

static void
Expand Down
133 changes: 69 additions & 64 deletions libcaja-private/caja-mime-actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1854,76 +1854,81 @@ activate_files (ActivateParameters *parameters)
}
}

launch_desktop_files = g_list_reverse (launch_desktop_files);
for (l = launch_desktop_files; l != NULL; l = l->next)
{
file = CAJA_FILE (l->data);

activate_desktop_file (parameters, file);
}

old_working_dir = NULL;
if (parameters->activation_directory &&
(launch_files != NULL || launch_in_terminal_files != NULL))
{
old_working_dir = g_get_current_dir ();
g_chdir (parameters->activation_directory);

}

launch_files = g_list_reverse (launch_files);
for (l = launch_files; l != NULL; l = l->next)
{
file = CAJA_FILE (l->data);

uri = caja_file_get_activation_uri (file);
executable_path = g_filename_from_uri (uri, NULL, NULL);
quoted_path = g_shell_quote (executable_path);
name = caja_file_get_name (file);

caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
"directory view activate_callback launch_file window=%p: %s",
parameters->parent_window, quoted_path);

caja_launch_application_from_command (screen, name, quoted_path, FALSE, NULL);
g_free (name);
g_free (quoted_path);
g_free (executable_path);
g_free (uri);

}

launch_in_terminal_files = g_list_reverse (launch_in_terminal_files);
for (l = launch_in_terminal_files; l != NULL; l = l->next)
{
file = CAJA_FILE (l->data);

uri = caja_file_get_activation_uri (file);
executable_path = g_filename_from_uri (uri, NULL, NULL);
quoted_path = g_shell_quote (executable_path);
name = caja_file_get_name (file);

caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
"directory view activate_callback launch_in_terminal window=%p: %s",
parameters->parent_window, quoted_path);

caja_launch_application_from_command (screen, name, quoted_path, TRUE, NULL);
g_free (name);
g_free (quoted_path);
g_free (executable_path);
g_free (uri);
}
flags = parameters->flags;

if (old_working_dir != NULL)
{
g_chdir (old_working_dir);
g_free (old_working_dir);
/* If spring loading, we want to ignore anything but folders*/
if ((flags & CAJA_WINDOW_OPEN_FLAG_SPRING_LOADED) == 0)
{
launch_desktop_files = g_list_reverse (launch_desktop_files);
for (l = launch_desktop_files; l != NULL; l = l->next)
{
file = CAJA_FILE (l->data);

activate_desktop_file (parameters, file);
}

old_working_dir = NULL;
if (parameters->activation_directory &&
(launch_files != NULL || launch_in_terminal_files != NULL))
{
old_working_dir = g_get_current_dir ();
g_chdir (parameters->activation_directory);

}

launch_files = g_list_reverse (launch_files);
for (l = launch_files; l != NULL; l = l->next)
{
file = CAJA_FILE (l->data);

uri = caja_file_get_activation_uri (file);
executable_path = g_filename_from_uri (uri, NULL, NULL);
quoted_path = g_shell_quote (executable_path);
name = caja_file_get_name (file);

caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
"directory view activate_callback launch_file window=%p: %s",
parameters->parent_window, quoted_path);

caja_launch_application_from_command (screen, name, quoted_path, FALSE, NULL);
g_free (name);
g_free (quoted_path);
g_free (executable_path);
g_free (uri);

}

launch_in_terminal_files = g_list_reverse (launch_in_terminal_files);
for (l = launch_in_terminal_files; l != NULL; l = l->next)
{
file = CAJA_FILE (l->data);

uri = caja_file_get_activation_uri (file);
executable_path = g_filename_from_uri (uri, NULL, NULL);
quoted_path = g_shell_quote (executable_path);
name = caja_file_get_name (file);

caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER,
"directory view activate_callback launch_in_terminal window=%p: %s",
parameters->parent_window, quoted_path);

caja_launch_application_from_command (screen, name, quoted_path, TRUE, NULL);
g_free (name);
g_free (quoted_path);
g_free (executable_path);
g_free (uri);
}

if (old_working_dir != NULL)
{
g_chdir (old_working_dir);
g_free (old_working_dir);
}
}

open_in_view_files = g_list_reverse (open_in_view_files);
count = g_list_length (open_in_view_files);

flags = parameters->flags;
if (count > 1)
{
if ((parameters->flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0)
Expand Down
10 changes: 10 additions & 0 deletions libcaja-private/caja-window-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum
SELECTION_CHANGED,
TITLE_CHANGED,
HIDDEN_FILES_MODE_CHANGED,
SPRING_LOADED_DONE,
LAST_SIGNAL
};

Expand Down Expand Up @@ -81,6 +82,15 @@ caja_window_info_base_init (gpointer g_class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);

caja_window_info_signals[SPRING_LOADED_DONE] =
g_signal_new ("spring_loaded_done",
CAJA_TYPE_WINDOW_INFO,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (CajaWindowInfoIface, spring_loaded_done),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);

initialized = TRUE;
}
}
Expand Down
4 changes: 3 additions & 1 deletion libcaja-private/caja-window-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ extern "C" {
CAJA_WINDOW_OPEN_FLAG_CLOSE_BEHIND = 1<<0,
/* used in navigation mode */
CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW = 1<<1,
CAJA_WINDOW_OPEN_FLAG_NEW_TAB = 1<<2
CAJA_WINDOW_OPEN_FLAG_NEW_TAB = 1<<2,
CAJA_WINDOW_OPEN_FLAG_SPRING_LOADED = 1<<3
} CajaWindowOpenFlags;

typedef enum
Expand Down Expand Up @@ -105,6 +106,7 @@ extern "C" {
void (* title_changed) (CajaWindowInfo *window,
const char *title);
void (* hidden_files_mode_changed)(CajaWindowInfo *window);
void (* spring_loaded_done) (CajaWindowInfo *window);

/* VTable: */
/* A view calls this once after a load_location, once it starts loading the
Expand Down
44 changes: 40 additions & 4 deletions src/caja-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ static GList *caja_application_desktop_windows;
/* Keeps track of all the caja windows. */
static GList *caja_application_window_list;

/* Keeps track of all spring loaded windows */
static GList *caja_application_spring_loaded_window_list;

/* Keeps track of all the object windows */
static GList *caja_application_spatial_window_list;

Expand Down Expand Up @@ -219,6 +222,12 @@ caja_application_get_spatial_window_list (void)
return caja_application_spatial_window_list;
}

GList *
caja_application_get_spring_loaded_window_list (void)
{
return caja_application_spatial_window_list;
}

unsigned int
caja_application_get_n_windows (void)
{
Expand Down Expand Up @@ -810,7 +819,8 @@ open_window (CajaApplication *application,
startup_id,
location,
screen,
NULL);
NULL,
FALSE);
}

caja_window_go_to (window, location);
Expand Down Expand Up @@ -1348,6 +1358,25 @@ caja_application_close_parent_windows (CajaSpatialWindow *window)
}
}

void
caja_application_close_all_spring_loaded_windows (void)
{
GList *l;

/* Not hiding them first as below, because having the spring stay open
after the snap feels comfortable. */
for (l = caja_application_spring_loaded_window_list; l != NULL; l = l->next)
{
CajaWindow *window;

window = CAJA_WINDOW (l->data);

caja_window_close (window);
}
g_list_free (caja_application_spring_loaded_window_list);
caja_application_spring_loaded_window_list = NULL;
}

void
caja_application_close_all_spatial_windows (void)
{
Expand Down Expand Up @@ -1456,7 +1485,8 @@ caja_application_get_spatial_window (CajaApplication *application,
const char *startup_id,
GFile *location,
GdkScreen *screen,
gboolean *existing)
gboolean *existing,
gboolean spring_loaded)
{
CajaWindow *window;
gchar *uri;
Expand Down Expand Up @@ -1504,6 +1534,10 @@ caja_application_get_spatial_window (CajaApplication *application,
}

caja_application_spatial_window_list = g_list_prepend (caja_application_spatial_window_list, window);

if (spring_loaded)
caja_application_spring_loaded_window_list = g_list_prepend (caja_application_spring_loaded_window_list, window);

g_object_weak_ref (G_OBJECT (window),
spatial_window_destroyed_callback, NULL);

Expand Down Expand Up @@ -1720,7 +1754,8 @@ autorun_show_window (GMount *mount, gpointer user_data)
NULL,
location,
gdk_screen_get_default (),
NULL);
NULL,
FALSE);
}

caja_window_go_to (window, location);
Expand Down Expand Up @@ -2287,7 +2322,8 @@ caja_application_load_session (CajaApplication *application)
location = g_file_new_for_uri (location_uri);
window = caja_application_get_spatial_window (application, NULL, NULL,
location, gdk_screen_get_default (),
NULL);
NULL,
FALSE);

caja_window_go_to (window, location);

Expand Down
5 changes: 4 additions & 1 deletion src/caja-application.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ void caja_application_startup (CajaApplication *applic
char **urls);
GList * caja_application_get_window_list (void);
GList * caja_application_get_spatial_window_list (void);
GList * caja_application_get_spring_loaded_window_list (void);
unsigned int caja_application_get_n_windows (void);

CajaWindow * caja_application_get_spatial_window (CajaApplication *application,
CajaWindow *requesting_window,
const char *startup_id,
GFile *location,
GdkScreen *screen,
gboolean *existing);
gboolean *existing,
gboolean spring_loaded);

CajaWindow * caja_application_create_navigation_window (CajaApplication *application,
const char *startup_id,
Expand All @@ -102,6 +104,7 @@ CajaWindow * caja_application_create_navigation_window (CajaApplication
void caja_application_close_all_navigation_windows (void);
void caja_application_close_parent_windows (CajaSpatialWindow *window);
void caja_application_close_all_spatial_windows (void);
void caja_application_close_all_spring_loaded_windows (void);
void caja_application_open_desktop (CajaApplication *application);
void caja_application_close_desktop (void);
gboolean caja_application_save_accel_map (gpointer data);
Expand Down
Loading