Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
Files
Commits
f9a9b1eb
Commit
f9a9b1eb
authored
Jan 27, 2000
by
John Sullivan
Browse files
Made zooming work in list view.
parent
2350369c
Changes
5
Hide whitespace changes
Inline
Side-by-side
ChangeLog-20000414
View file @
f9a9b1eb
2000-01-28 John Sullivan <sullivan@eazel.com>
Made zooming work in directory list view. Also made
right-click menu on a directory view always include
the non-icon-specific items.
* src/file-manager/fm-icon-cache.h:
* src/file-manager/fm-icon-cache.c:
(nautilus_icon_size_for_zoom_level): New function, maps
between NautilusZoomLevel and nominal icon sizes.
* src/file-manager/fm-directory-view.c:
(append_background_items): New utility function, adds the
non-file-specific context menu items to a menu.
(create_background_context_menu): Moved most of guts to
new append_background_items, which this now calls.
(create_item_context_menu): Now adds a separator and then
calls append_background_items. This means right-clicking on
an icon will show the icon-specific commands followed by the
non-icon-specific ones. This makes the non-icon-specific ones
easier to discover and access, especially in list view where
anywhere you click in a long list gives the item's context menu.
* src/file-manager/fm-directory-view-list.c:
Now stores zoom level rather than icon size in details structure.
(fm_directory_view_list_bump_zoom_level),
(fm_directory_view_list_set_zoom_level): New functions for setting
the zoom level.
(fm_directory_view_list_initialize_class): Wire up bump_zoom_level to
slot in parent class structure.
(compare_rows), (add_to_flist): Changed mechanism that temporarily
stores pending row data to use object data rather than a static variable
so it will work with multiple list views at the same time.
(fm_directory_view_list_get_icon_size): New function, gets icon size
from zoom level stored in details structure.
(create_flist): Deploy fm_directory_view_list_get_icon_size where
details structure was examined before.
(install_icon): Removed NautilusFile and column parameters; made function
compute these internally.
2000-01-28 Elliot Lee <sopwith@redhat.com>
* components/html/ntl-web-browser.c: Remove use of gtk_html_parse() - deprecated
in latest GtkHTML.
...
...
src/file-manager/fm-directory-view-list.c
View file @
f9a9b1eb
...
...
@@ -43,7 +43,7 @@ struct _FMDirectoryViewListDetails
{
gint
sort_column
;
gboolean
sort_reversed
;
guint
icon_size
;
guint
zoom_level
;
};
#define DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/FFFF"
...
...
@@ -59,6 +59,7 @@ struct _FMDirectoryViewListDetails
/* special values for get_data and set_data */
#define PENDING_USER_DATA_KEY "pending user data"
#define SORT_INDICATOR_KEY "sort indicator"
#define UP_INDICATOR_VALUE 1
#define DOWN_INDICATOR_VALUE 2
...
...
@@ -90,13 +91,18 @@ static void fm_directory_view_list_background_changed_cb
FMDirectoryViewList
*
list_view
);
static
void
fm_directory_view_list_begin_adding_entries
(
FMDirectoryView
*
view
);
static
void
fm_directory_view_list_bump_zoom_level
(
FMDirectoryView
*
view
,
gint
zoom_increment
);
static
void
fm_directory_view_list_clear
(
FMDirectoryView
*
view
);
static
guint
fm_directory_view_list_get_icon_size
(
FMDirectoryViewList
*
list_view
);
static
GList
*
fm_directory_view_list_get_selection
(
FMDirectoryView
*
view
);
static
void
fm_directory_view_list_initialize
(
gpointer
object
,
gpointer
klass
);
static
void
fm_directory_view_list_initialize_class
(
gpointer
klass
);
static
void
fm_directory_view_list_destroy
(
GtkObject
*
object
);
static
void
fm_directory_view_list_done_adding_entries
(
FMDirectoryView
*
view
);
static
void
fm_directory_view_list_set_zoom_level
(
FMDirectoryViewList
*
list_view
,
NautilusZoomLevel
new_level
);
static
void
fm_directory_view_list_sort_items
(
FMDirectoryViewList
*
list_view
,
int
column
,
gboolean
reversed
);
...
...
@@ -106,9 +112,7 @@ static GtkWidget *get_sort_indicator (GtkFList *flist,
gboolean
reverse
);
static
void
hide_sort_indicator
(
GtkFList
*
flist
,
gint
column
);
static
void
install_icon
(
FMDirectoryViewList
*
list_view
,
NautilusFile
*
file
,
guint
row
,
guint
column
);
guint
row
);
static
void
show_sort_indicator
(
GtkFList
*
flist
,
gint
column
,
gboolean
sort_reversed
);
...
...
@@ -134,8 +138,6 @@ static char * up_xpm[] = {
" "
,
"......"
};
static
NautilusFile
*
pending_row_data
=
NULL
;
NAUTILUS_DEFINE_CLASS_BOILERPLATE
(
FMDirectoryViewList
,
fm_directory_view_list
,
FM_TYPE_DIRECTORY_VIEW
);
...
...
@@ -159,6 +161,7 @@ fm_directory_view_list_initialize_class (gpointer klass)
fm_directory_view_class
->
add_entry
=
fm_directory_view_list_add_entry
;
fm_directory_view_class
->
done_adding_entries
=
fm_directory_view_list_done_adding_entries
;
fm_directory_view_class
->
get_selection
=
fm_directory_view_list_get_selection
;
fm_directory_view_class
->
bump_zoom_level
=
fm_directory_view_list_bump_zoom_level
;
}
static
void
...
...
@@ -176,7 +179,7 @@ fm_directory_view_list_initialize (gpointer object, gpointer klass)
/* FIXME: These should be read from metadata */
list_view
->
details
->
sort_column
=
LIST_VIEW_COLUMN_NAME
;
list_view
->
details
->
sort_reversed
=
FALSE
;
list_view
->
details
->
icon_size
=
NAUTILUS_
ICON_SIZE
_SMALLER
;
list_view
->
details
->
zoom_level
=
NAUTILUS_
ZOOM_LEVEL
_SMALLER
;
create_flist
(
list_view
);
}
...
...
@@ -239,9 +242,13 @@ compare_rows (GtkCList *clist,
*/
g_assert
(
file1
!=
NULL
||
file2
!=
NULL
);
if
(
file1
==
NULL
)
file1
=
pending_row_data
;
{
file1
=
(
NautilusFile
*
)
gtk_object_get_data
(
GTK_OBJECT
(
clist
),
PENDING_USER_DATA_KEY
);
}
else
if
(
file2
==
NULL
)
file2
=
pending_row_data
;
{
file2
=
(
NautilusFile
*
)
gtk_object_get_data
(
GTK_OBJECT
(
clist
),
PENDING_USER_DATA_KEY
);
}
g_assert
(
file1
!=
NULL
&&
file2
!=
NULL
);
sort_criterion
=
sort_criterion_from_column
(
clist
->
sort_column
);
...
...
@@ -286,7 +293,7 @@ create_flist (FMDirectoryViewList *list_view)
_
(
"Date Modified"
),
};
uint
widths
[]
=
{
list_view
->
details
->
icon_size
,
/* Icon */
fm_directory_view_list_get_icon_size
(
list_view
)
,
/* Icon */
130
,
/* Name */
55
,
/* Size */
95
,
/* Type */
...
...
@@ -365,7 +372,7 @@ create_flist (FMDirectoryViewList *list_view)
list_view
->
details
->
sort_reversed
);
/* Make height tall enough for icons to look good */
gtk_clist_set_row_height
(
clist
,
list_view
->
details
->
icon_size
);
gtk_clist_set_row_height
(
clist
,
fm_directory_view_list_get_icon_size
(
list_view
)
);
GTK_WIDGET_SET_FLAGS
(
flist
,
GTK_CAN_FOCUS
);
...
...
@@ -454,19 +461,16 @@ add_to_flist (FMDirectoryViewList *list_view, NautilusFile *file)
clist
=
GTK_CLIST
(
get_flist
(
list_view
));
/* Temporarily set
static variable
value as hack for the problem
/* Temporarily set
user data
value as hack for the problem
* that compare_rows is called before the row data can be set.
*/
pending_row_data
=
file
;
gtk_object_set_data
(
GTK_OBJECT
(
clist
),
PENDING_USER_DATA_KEY
,
file
)
;
/* Note that since list is auto-sorted new_row isn't necessarily last row. */
new_row
=
gtk_clist_append
(
clist
,
text
);
gtk_clist_set_row_data
(
clist
,
new_row
,
file
);
pending_row_data
=
NULL
;
gtk_object_set_data
(
GTK_OBJECT
(
clist
),
PENDING_USER_DATA_KEY
,
NULL
)
;
install_icon
(
list_view
,
file
,
new_row
,
LIST_VIEW_COLUMN_ICON
);
install_icon
(
list_view
,
new_row
);
g_free
(
name
);
g_free
(
size_string
);
...
...
@@ -483,6 +487,29 @@ get_flist (FMDirectoryViewList *list_view)
return
GTK_FLIST
(
GTK_BIN
(
list_view
)
->
child
);
}
static
void
fm_directory_view_list_bump_zoom_level
(
FMDirectoryView
*
view
,
gint
zoom_increment
)
{
FMDirectoryViewList
*
list_view
;
NautilusZoomLevel
new_level
;
g_return_if_fail
(
FM_IS_DIRECTORY_VIEW
(
view
));
list_view
=
FM_DIRECTORY_VIEW_LIST
(
view
);
if
(
zoom_increment
<
0
&&
0
-
zoom_increment
>
list_view
->
details
->
zoom_level
)
{
new_level
=
NAUTILUS_ZOOM_LEVEL_SMALLEST
;
}
else
{
new_level
=
MIN
(
list_view
->
details
->
zoom_level
+
zoom_increment
,
NAUTILUS_ZOOM_LEVEL_LARGEST
);
}
fm_directory_view_list_set_zoom_level
(
list_view
,
new_level
);
}
static
void
fm_directory_view_list_clear
(
FMDirectoryView
*
view
)
{
...
...
@@ -529,6 +556,14 @@ fm_directory_view_list_done_adding_entries (FMDirectoryView *view)
gtk_clist_thaw
(
GTK_CLIST
(
get_flist
(
FM_DIRECTORY_VIEW_LIST
(
view
))));
}
static
guint
fm_directory_view_list_get_icon_size
(
FMDirectoryViewList
*
list_view
)
{
g_return_val_if_fail
(
FM_IS_DIRECTORY_VIEW_LIST
(
list_view
),
NAUTILUS_ICON_SIZE_STANDARD
);
return
nautilus_icon_size_for_zoom_level
(
list_view
->
details
->
zoom_level
);
}
static
GList
*
fm_directory_view_list_get_selection
(
FMDirectoryView
*
view
)
{
...
...
@@ -537,6 +572,40 @@ fm_directory_view_list_get_selection (FMDirectoryView *view)
return
gtk_flist_get_selection
(
get_flist
(
FM_DIRECTORY_VIEW_LIST
(
view
)));
}
static
void
fm_directory_view_list_set_zoom_level
(
FMDirectoryViewList
*
list_view
,
NautilusZoomLevel
new_level
)
{
GtkCList
*
clist
;
int
row
;
g_return_if_fail
(
FM_IS_DIRECTORY_VIEW_LIST
(
list_view
));
g_return_if_fail
(
new_level
>=
NAUTILUS_ZOOM_LEVEL_SMALLEST
&&
new_level
<=
NAUTILUS_ZOOM_LEVEL_LARGEST
);
if
(
new_level
==
list_view
->
details
->
zoom_level
)
return
;
list_view
->
details
->
zoom_level
=
new_level
;
clist
=
GTK_CLIST
(
get_flist
(
list_view
));
gtk_clist_freeze
(
clist
);
gtk_clist_set_row_height
(
GTK_CLIST
(
get_flist
(
list_view
)),
fm_directory_view_list_get_icon_size
(
list_view
));
gtk_clist_set_column_width
(
GTK_CLIST
(
get_flist
(
list_view
)),
LIST_VIEW_COLUMN_ICON
,
fm_directory_view_list_get_icon_size
(
list_view
));
clist
=
GTK_CLIST
(
get_flist
(
list_view
));
for
(
row
=
0
;
row
<
clist
->
rows
;
++
row
)
{
install_icon
(
list_view
,
row
);
}
gtk_clist_thaw
(
clist
);
}
static
void
fm_directory_view_list_sort_items
(
FMDirectoryViewList
*
list_view
,
int
column
,
...
...
@@ -649,33 +718,33 @@ hide_sort_indicator (GtkFList *flist, gint column)
*
* Put an icon for a file into the specified cell.
* @list_view: FMDirectoryView in which to install icon.
* @file: NautilusFile representing file whose icon should be installed.
* @row: row index of target cell
* @column: column index of target cell
*
**/
static
void
install_icon
(
FMDirectoryViewList
*
list_view
,
NautilusFile
*
file
,
guint
row
,
guint
column
)
install_icon
(
FMDirectoryViewList
*
list_view
,
guint
row
)
{
NautilusFile
*
file
;
GtkCList
*
clist
;
GdkPixbuf
*
pixbuf
;
GdkPixmap
*
pixmap
;
GdkBitmap
*
bitmap
;
g_return_if_fail
(
FM_IS_DIRECTORY_VIEW_LIST
(
list_view
));
g_return_if_fail
(
file
!=
NULL
);
g_return_if_fail
(
column
>=
0
);
g_return_if_fail
(
column
<
GTK_CLIST
(
get_flist
(
list_view
))
->
rows
);
clist
=
GTK_CLIST
(
get_flist
(
list_view
));
file
=
gtk_clist_get_row_data
(
clist
,
row
);
g_assert
(
file
!=
NULL
);
pixbuf
=
fm_icon_cache_get_icon_for_file
(
fm_get_current_icon_cache
(),
file
,
list_view
->
details
->
icon_size
);
fm_directory_view_list_get_icon_size
(
list_view
)
);
/* GtkCList requires a pixmap & mask rather than a pixbuf */
gdk_pixbuf_render_pixmap_and_mask
(
pixbuf
,
&
pixmap
,
&
bitmap
,
100
);
gtk_clist_set_pixmap
(
GTK_CLIST
(
get_flist
(
list_view
)),
row
,
column
,
pixmap
,
bitmap
);
gtk_clist_set_pixmap
(
clist
,
row
,
LIST_VIEW_COLUMN_ICON
,
pixmap
,
bitmap
);
gdk_pixbuf_unref
(
pixbuf
);
}
...
...
src/file-manager/fm-directory-view.c
View file @
f9a9b1eb
...
...
@@ -84,6 +84,7 @@ static void display_selection_info (FMDirectoryView *view);
static
void
fm_directory_view_initialize_class
(
FMDirectoryViewClass
*
klass
);
static
void
fm_directory_view_initialize
(
FMDirectoryView
*
view
);
static
void
fm_directory_view_destroy
(
GtkObject
*
object
);
static
void
append_background_items
(
FMDirectoryView
*
view
,
GtkMenu
*
menu
);
static
GtkMenu
*
create_item_context_menu
(
FMDirectoryView
*
view
,
NautilusFile
*
file
);
static
GtkMenu
*
create_background_context_menu
(
FMDirectoryView
*
view
);
...
...
@@ -647,8 +648,32 @@ popup_temporary_context_menu (GtkMenu *menu)
gtk_object_unref
(
GTK_OBJECT
(
menu
));
}
/* FIXME - need better architecture for setting these. Also need to
merge per-view items. */
static
void
append_background_items
(
FMDirectoryView
*
view
,
GtkMenu
*
menu
)
{
GtkWidget
*
menu_item
;
menu_item
=
gtk_menu_item_new_with_label
(
"Select all"
);
gtk_widget_set_sensitive
(
menu_item
,
FALSE
);
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
menu_item
=
gtk_menu_item_new_with_label
(
"Zoom in"
);
gtk_signal_connect
(
GTK_OBJECT
(
menu_item
),
"activate"
,
GTK_SIGNAL_FUNC
(
zoom_in_cb
),
view
);
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
menu_item
=
gtk_menu_item_new_with_label
(
"Zoom out"
);
gtk_signal_connect
(
GTK_OBJECT
(
menu_item
),
"activate"
,
GTK_SIGNAL_FUNC
(
zoom_out_cb
),
view
);
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
}
/* FIXME - need better architecture for setting these. */
static
GtkMenu
*
create_item_context_menu
(
FMDirectoryView
*
view
,
...
...
@@ -669,6 +694,17 @@ create_item_context_menu (FMDirectoryView *view,
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
/* separator between item-specific and view-general menu items */
menu_item
=
gtk_menu_item_new
();
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
/* Show commands not specific to this item also, since it might
* be hard (especially in list view) to find a place to click
* that's not on an item.
*/
append_background_items
(
view
,
menu
);
return
menu
;
}
...
...
@@ -678,29 +714,11 @@ static GtkMenu *
create_background_context_menu
(
FMDirectoryView
*
view
)
{
GtkMenu
*
menu
;
GtkWidget
*
menu_item
;
menu
=
GTK_MENU
(
gtk_menu_new
());
menu_item
=
gtk_menu_item_new_with_label
(
"Select all"
);
gtk_widget_set_sensitive
(
menu_item
,
FALSE
);
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
menu_item
=
gtk_menu_item_new_with_label
(
"Zoom in"
);
gtk_signal_connect
(
GTK_OBJECT
(
menu_item
),
"activate"
,
GTK_SIGNAL_FUNC
(
zoom_in_cb
),
view
);
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
menu_item
=
gtk_menu_item_new_with_label
(
"Zoom out"
);
gtk_signal_connect
(
GTK_OBJECT
(
menu_item
),
"activate"
,
GTK_SIGNAL_FUNC
(
zoom_out_cb
),
view
);
append_background_items
(
view
,
menu
);
gtk_widget_show
(
menu_item
);
gtk_menu_append
(
menu
,
menu_item
);
gtk_object_ref
(
GTK_OBJECT
(
menu
));
gtk_object_sink
(
GTK_OBJECT
(
menu
));
return
menu
;
...
...
src/file-manager/fm-icon-cache.c
View file @
f9a9b1eb
...
...
@@ -449,3 +449,36 @@ fm_icon_cache_scale (FMIconCache *factory,
return
result
;
}
/*
* Return nominal icon size for given zoom level.
* @zoom_level: zoom level for which to find matching icon size.
*
* Return value: icon size between NAUTILUS_ICON_SIZE_SMALLEST and
* NAUTILUS_ICON_SIZE_LARGEST, inclusive.
*/
guint
nautilus_icon_size_for_zoom_level
(
NautilusZoomLevel
zoom_level
)
{
switch
(
zoom_level
)
{
case
NAUTILUS_ZOOM_LEVEL_SMALLEST
:
return
NAUTILUS_ICON_SIZE_SMALLEST
;
case
NAUTILUS_ZOOM_LEVEL_SMALLER
:
return
NAUTILUS_ICON_SIZE_SMALLER
;
case
NAUTILUS_ZOOM_LEVEL_SMALL
:
return
NAUTILUS_ICON_SIZE_SMALL
;
case
NAUTILUS_ZOOM_LEVEL_STANDARD
:
return
NAUTILUS_ICON_SIZE_STANDARD
;
case
NAUTILUS_ZOOM_LEVEL_LARGE
:
return
NAUTILUS_ICON_SIZE_LARGE
;
case
NAUTILUS_ZOOM_LEVEL_LARGER
:
return
NAUTILUS_ICON_SIZE_LARGER
;
case
NAUTILUS_ZOOM_LEVEL_LARGEST
:
return
NAUTILUS_ICON_SIZE_LARGEST
;
default:
g_assert_not_reached
();
return
NAUTILUS_ICON_SIZE_STANDARD
;
}
}
src/file-manager/fm-icon-cache.h
View file @
f9a9b1eb
...
...
@@ -51,16 +51,18 @@ typedef enum {
typedef
struct
_FMIconCache
FMIconCache
;
FMIconCache
*
fm_icon_cache_new
(
const
char
*
theme_name
);
void
fm_icon_cache_destroy
(
FMIconCache
*
factory
);
void
fm_icon_cache_set_theme
(
FMIconCache
*
factory
,
const
char
*
theme_name
);
FMIconCache
*
fm_get_current_icon_cache
(
void
);
FMIconCache
*
fm_icon_cache_new
(
const
char
*
theme_name
);
void
fm_icon_cache_destroy
(
FMIconCache
*
factory
);
void
fm_icon_cache_set_theme
(
FMIconCache
*
factory
,
const
char
*
theme_name
);
FMIconCache
*
fm_get_current_icon_cache
(
void
);
guint
nautilus_icon_size_for_zoom_level
(
NautilusZoomLevel
zoom_level
);
/* Ownership of a ref. count in this pixbuf comes with the deal */
GdkPixbuf
*
fm_icon_cache_get_icon_for_file
(
FMIconCache
*
factory
,
NautilusFile
*
file
,
guint
size_in_pixels
);
GdkPixbuf
*
fm_icon_cache_get_icon_for_file
(
FMIconCache
*
factory
,
NautilusFile
*
file
,
guint
size_in_pixels
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment