Added two dots
This commit is contained in:
parent
733ff0c53b
commit
a60a512d59
@ -424,6 +424,13 @@ static double get_names (MooFolder *folder)
|
||||
|
||||
timer = g_timer_new ();
|
||||
|
||||
file = moo_file_new (folder->priv->path, "..");
|
||||
file->icon = get_folder_icon (NULL);
|
||||
file->flags = MOO_FILE_HAS_MIME_TYPE | MOO_FILE_HAS_ICON;
|
||||
file->info = MOO_FILE_EXISTS | MOO_FILE_IS_FOLDER;
|
||||
folder->priv->files = g_slist_prepend (folder->priv->files, file);
|
||||
added = g_slist_prepend (added, file);
|
||||
|
||||
for (name = g_dir_read_name (folder->priv->dir);
|
||||
name != NULL;
|
||||
name = g_dir_read_name (folder->priv->dir))
|
||||
@ -892,6 +899,10 @@ static void files_list_free (GSList **list)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define GNOME_HOME_ICON_NAME "gnome-fs-home"
|
||||
#define GNOME_DESKTOP_ICON_NAME "gnome-fs-desktop"
|
||||
#define GNOME_TRASH_ICON_NAME "gnome-fs-trash-full"
|
||||
#define GNOME_DIRECTORY_ICON_NAME "gnome-fs-directory"
|
||||
#define FILE_ICON_NAME "gnome-fs-regular"
|
||||
#define BLOCK_DEVICE_ICON_NAME "gnome-fs-blockdev"
|
||||
#define EXECUTABLE_ICON_NAME "gnome-fs-executable"
|
||||
@ -1059,11 +1070,14 @@ static const char *get_folder_icon (const char *path)
|
||||
static char *desktop_path = NULL;
|
||||
static char *trash_path = NULL;
|
||||
|
||||
if (!path)
|
||||
return GNOME_DIRECTORY_ICON_NAME;
|
||||
|
||||
if (!home_path)
|
||||
home_path = g_get_home_dir ();
|
||||
|
||||
if (!home_path)
|
||||
return "gnome-fs-directory";
|
||||
return GNOME_DIRECTORY_ICON_NAME;
|
||||
|
||||
if (!desktop_path)
|
||||
desktop_path = g_build_filename (home_path, "Desktop", NULL);
|
||||
@ -1072,13 +1086,13 @@ static const char *get_folder_icon (const char *path)
|
||||
trash_path = g_build_filename (desktop_path, "Trash", NULL);
|
||||
|
||||
if (strcmp (home_path, path) == 0)
|
||||
return "gnome-fs-home";
|
||||
return GNOME_HOME_ICON_NAME;
|
||||
else if (strcmp (desktop_path, path) == 0)
|
||||
return "gnome-fs-desktop";
|
||||
return GNOME_DESKTOP_ICON_NAME;
|
||||
else if (strcmp (trash_path, path) == 0)
|
||||
return "gnome-fs-trash-full";
|
||||
return GNOME_TRASH_ICON_NAME;
|
||||
else
|
||||
return "gnome-fs-directory";
|
||||
return GNOME_DIRECTORY_ICON_NAME;
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,7 +75,7 @@ struct _MooFileViewPrivate {
|
||||
MooIconView *iconview;
|
||||
|
||||
gboolean show_hidden_files;
|
||||
// gboolean show_two_dots;
|
||||
gboolean show_two_dots;
|
||||
History *history;
|
||||
char *name_to_select;
|
||||
|
||||
@ -167,8 +167,8 @@ static void goto_item_activated (GtkWidget *widget,
|
||||
MooFileView *fileview);
|
||||
static void show_hidden_toggled (GtkWidget *widget,
|
||||
MooFileView *fileview);
|
||||
// static void show_two_dots_toggled (GtkWidget *widget,
|
||||
// MooFileView *fileview);
|
||||
static void show_two_dots_toggled (GtkWidget *widget,
|
||||
MooFileView *fileview);
|
||||
static void view_type_item_toggled (GtkWidget *widget,
|
||||
MooFileView *fileview);
|
||||
|
||||
@ -1363,6 +1363,12 @@ static gboolean filter_visible_func (GtkTreeModel *model,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!strcmp (moo_file_get_basename (file), ".."))
|
||||
{
|
||||
visible = fileview->priv->show_two_dots;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!fileview->priv->show_hidden_files && moo_file_test (file, MOO_FILE_IS_HIDDEN))
|
||||
{
|
||||
visible = FALSE;
|
||||
@ -1405,12 +1411,16 @@ static int tree_compare_func (GtkTreeModel *model,
|
||||
gtk_tree_model_get (model, b, COLUMN_FILE, &f2, -1);
|
||||
g_assert (f1 != NULL && f2 != NULL);
|
||||
|
||||
if (f1 == f2)
|
||||
{
|
||||
result = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!f1 || !f2)
|
||||
{
|
||||
if (f1 < f2)
|
||||
result = -1;
|
||||
else if (f1 == f2)
|
||||
result = 0;
|
||||
else
|
||||
result = 1;
|
||||
goto out;
|
||||
@ -1428,6 +1438,18 @@ static int tree_compare_func (GtkTreeModel *model,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (is_dir1)
|
||||
{
|
||||
if (!strcmp (moo_file_get_basename (f1), ".."))
|
||||
result = -1;
|
||||
else if (!strcmp (moo_file_get_basename (f2), ".."))
|
||||
result = 1;
|
||||
else
|
||||
result = strcmp (moo_file_get_basename (f1),
|
||||
moo_file_get_basename (f2));
|
||||
goto out;
|
||||
}
|
||||
|
||||
result = strcmp (moo_file_get_basename (f1),
|
||||
moo_file_get_basename (f2));
|
||||
|
||||
@ -2130,13 +2152,13 @@ static void create_view_submenu (MooFileView *fileview,
|
||||
g_signal_connect (item, "toggled",
|
||||
G_CALLBACK (show_hidden_toggled), fileview);
|
||||
|
||||
// item = gtk_check_menu_item_new_with_label ("Show Parent Folders");
|
||||
// gtk_widget_show (item);
|
||||
// gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
|
||||
// gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
// fileview->priv->show_two_dots);
|
||||
// g_signal_connect (item, "toggled",
|
||||
// G_CALLBACK (show_two_dots_toggled), fileview);
|
||||
item = gtk_check_menu_item_new_with_label ("Show Parent Folder");
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item);
|
||||
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
|
||||
fileview->priv->show_two_dots);
|
||||
g_signal_connect (item, "toggled",
|
||||
G_CALLBACK (show_two_dots_toggled), fileview);
|
||||
|
||||
add_separator_item (submenu);
|
||||
create_view_type_items (fileview, submenu);
|
||||
@ -2270,13 +2292,13 @@ static void show_hidden_toggled (GtkWidget *widget,
|
||||
}
|
||||
|
||||
|
||||
// static void show_two_dots_toggled (GtkWidget *widget,
|
||||
// MooFileView *fileview)
|
||||
// {
|
||||
// gboolean active = fileview->priv->show_two_dots;
|
||||
// g_object_get (G_OBJECT (widget), "active", &active, NULL);
|
||||
// moo_file_view_set_show_parent (fileview, active);
|
||||
// }
|
||||
static void show_two_dots_toggled (GtkWidget *widget,
|
||||
MooFileView *fileview)
|
||||
{
|
||||
gboolean active = fileview->priv->show_two_dots;
|
||||
g_object_get (G_OBJECT (widget), "active", &active, NULL);
|
||||
moo_file_view_set_show_parent (fileview, active);
|
||||
}
|
||||
|
||||
|
||||
void moo_file_view_set_show_hidden (MooFileView *fileview,
|
||||
@ -2293,18 +2315,18 @@ void moo_file_view_set_show_hidden (MooFileView *fileview,
|
||||
}
|
||||
|
||||
|
||||
// void moo_file_view_set_show_parent (MooFileView *fileview,
|
||||
// gboolean show)
|
||||
// {
|
||||
// g_return_if_fail (MOO_IS_FILE_VIEW (fileview));
|
||||
//
|
||||
// if (fileview->priv->show_two_dots != show)
|
||||
// {
|
||||
// fileview->priv->show_two_dots = show;
|
||||
// gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (
|
||||
// fileview->priv->filter_model));
|
||||
// }
|
||||
// }
|
||||
void moo_file_view_set_show_parent (MooFileView *fileview,
|
||||
gboolean show)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_FILE_VIEW (fileview));
|
||||
|
||||
if (fileview->priv->show_two_dots != show)
|
||||
{
|
||||
fileview->priv->show_two_dots = show;
|
||||
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (
|
||||
fileview->priv->filter_model));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void toggle_show_hidden (MooFileView *fileview)
|
||||
|
Loading…
x
Reference in New Issue
Block a user