Commit 603052e9 authored by Ramiro Estrugo's avatar Ramiro Estrugo
Browse files

libnautilus-extensions/nautilus-icon-container.c, Implement missing

* libnautilus-extensions/nautilus-icon-container.c,
* libnautilus-extensions/nautilus-icon-container.h:
(destroy), (nautilus_icon_container_initialize),
(nautilus_icon_container_new),
(nautilus_icon_container_set_label_font_for_zoom_level),
(nautilus_icon_container_set_single_click_mode):
Implement missing set_single_click_mode function.

Its up to users of this widget to setup click policy and other
attributes. We shouldnt peek/poke nautilus specific preferences
in the icon container widget.

* libnautilus-extensions/nautilus-list.c:
* libnautilus-extensions/nautilus-list.h,
(nautilus_list_set_single_click_mode), (nautilus_list_initialize),
(nautilus_list_destroy), (nautilus_list_clear):
Implement missing set_single_click_mode function.

Its up to users of this widget to setup click policy and other
attributes. We shouldnt peek/poke nautilus specific preferences
in the list widget.

* src/file-manager/fm-icon-view.c: (fm_icon_view_destroy),
(text_attribute_names_changed_callback),
(click_policy_changed_callback),
(anti_aliased_mode_changed_callback), (fm_icon_view_initialize),
(fm_icon_view_update_click_mode),
(fm_icon_view_update_anti_aliased_mode), (create_icon_container):
Keep track of changes in preferences that affect the icon
container and update it when needed.

* src/file-manager/fm-list-view.c: (fm_list_view_initialize_class),
(fm_list_view_initialize), (fm_list_view_destroy), (create_list),
(update_icons), (fm_list_view_update_click_mode),
(click_policy_changed_callback):
Keep track of changes in preferences that affect the list and
update it when needed.
parent 1a3bf03d
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-icon-container.c,
* libnautilus-extensions/nautilus-icon-container.h:
(destroy), (nautilus_icon_container_initialize),
(nautilus_icon_container_new),
(nautilus_icon_container_set_label_font_for_zoom_level),
(nautilus_icon_container_set_single_click_mode):
Implement missing set_single_click_mode function.
Its up to users of this widget to setup click policy and other
attributes. We shouldnt peek/poke nautilus specific preferences
in the icon container widget.
* libnautilus-extensions/nautilus-list.c:
* libnautilus-extensions/nautilus-list.h,
(nautilus_list_set_single_click_mode), (nautilus_list_initialize),
(nautilus_list_destroy), (nautilus_list_clear):
Implement missing set_single_click_mode function.
Its up to users of this widget to setup click policy and other
attributes. We shouldnt peek/poke nautilus specific preferences
in the list widget.
* src/file-manager/fm-icon-view.c: (fm_icon_view_destroy),
(text_attribute_names_changed_callback),
(click_policy_changed_callback),
(anti_aliased_mode_changed_callback), (fm_icon_view_initialize),
(fm_icon_view_update_click_mode),
(fm_icon_view_update_anti_aliased_mode), (create_icon_container):
Keep track of changes in preferences that affect the icon
container and update it when needed.
* src/file-manager/fm-list-view.c: (fm_list_view_initialize_class),
(fm_list_view_initialize), (fm_list_view_destroy), (create_list),
(update_icons), (fm_list_view_update_click_mode),
(click_policy_changed_callback):
Keep track of changes in preferences that affect the list and
update it when needed.
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-icon-container.c,
......
......@@ -38,7 +38,6 @@
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-global-preferences.h"
#include "nautilus-gnome-extensions.h"
#include "nautilus-gtk-extensions.h"
#include "nautilus-gtk-macros.h"
......@@ -101,8 +100,6 @@ static void end_renaming_mode (NautilusIconConta
gboolean commit);
static void hide_rename_widget (NautilusIconContainer *container,
NautilusIcon *icon);
static void anti_aliased_preferences_changed (gpointer user_data);
static void click_policy_changed_callback (gpointer user_data);
static void finish_adding_new_icons (NautilusIconContainer *container);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
......@@ -1641,14 +1638,6 @@ destroy (GtkObject *object)
if (container->details->label_font[i] != NULL)
gdk_font_unref (container->details->label_font[i]);
}
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
container);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_preferences_changed,
container);
nautilus_icon_container_flush_typeselect_state (container);
......@@ -2400,7 +2389,6 @@ static void
nautilus_icon_container_initialize (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
int mode;
details = g_new0 (NautilusIconContainerDetails, 1);
......@@ -2430,27 +2418,6 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
container->details->rename_widget = NULL;
container->details->original_text = NULL;
container->details->type_select_state = NULL;
/* FIXME: Settings should be supplied by the caller and not
* hard-wired calls from NautilusIconContainer to preferences.
*/
/* Initialize the single click mode from preferences */
mode = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_CLICK_POLICY_SINGLE);
details->single_click_mode =
mode == NAUTILUS_CLICK_POLICY_SINGLE;
/* Keep track of changes in clicking policy */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
container);
/* Keep track of changes in graphics trade offs */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_preferences_changed,
container);
}
/* NautilusIcon event handling. */
......@@ -2571,23 +2538,17 @@ item_event_callback (GnomeCanvasItem *item,
GtkWidget *
nautilus_icon_container_new (void)
{
GnomeCanvas *canvas;
GtkWidget *new;
GtkWidget *container;
gtk_widget_push_visual (gdk_rgb_get_visual ());
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
new = gtk_type_new (nautilus_icon_container_get_type ());
container = gtk_type_new (nautilus_icon_container_get_type ());
gtk_widget_pop_visual ();
gtk_widget_pop_colormap ();
canvas = GNOME_CANVAS(new);
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS, FALSE)) {
canvas->aa = TRUE;
}
return new;
return container;
}
/* Clear all of the icons in the container. */
......@@ -3650,37 +3611,6 @@ nautilus_icon_container_emit_preview_signal (NautilusIconContainer *icon_contain
return result;
}
/* preferences callbacks */
static void
click_policy_changed_callback (gpointer user_data)
{
NautilusIconContainer *container;
int mode;
container = NAUTILUS_ICON_CONTAINER (user_data);
mode = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_CLICK_POLICY_SINGLE);
container->details->single_click_mode =
mode == NAUTILUS_CLICK_POLICY_SINGLE;
}
static void
anti_aliased_preferences_changed (gpointer user_data)
{
NautilusIconContainer *container;
gboolean aa_mode;
container = NAUTILUS_ICON_CONTAINER (user_data);
aa_mode = nautilus_preferences_get_boolean
(NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
FALSE);
nautilus_icon_container_set_anti_aliased_mode(container, aa_mode);
}
gboolean
nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *container)
{
......@@ -3725,6 +3655,16 @@ nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *co
container->details->label_font[zoom_level] = font;
}
void
nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container,
gboolean single_click_mode)
{
g_return_if_fail (container != NULL);
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
container->details->single_click_mode = single_click_mode;
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
......
......@@ -167,7 +167,7 @@ gboolean nautilus_icon_container_is_renaming (NautilusIconCo
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view,
int new_zoom_level);
void nautilus_icon_container_set_single_click_mode (NautilusIconContainer *view,
void nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container,
gboolean single_click_mode);
void nautilus_icon_container_enable_linger_selection (NautilusIconContainer *view,
gboolean enable);
......
......@@ -42,7 +42,6 @@
#include "nautilus-gdk-extensions.h"
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-global-preferences.h"
#include "nautilus-gtk-extensions.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-list-column-title.h"
......@@ -56,7 +55,7 @@
struct NautilusListDetails
{
/* Preferences */
/* Single click mode ? */
gboolean single_click_mode;
/* The anchor row for range selections */
......@@ -260,7 +259,6 @@ static gboolean row_set_selected (NautilusList *l
gboolean select);
static gboolean select_row_unselect_others (NautilusList *list,
int row_to_select);
static void click_policy_changed_callback (gpointer user_data);
static void nautilus_list_flush_typeselect_state (NautilusList *container);
static int insert_row (GtkCList *list,
int row,
......@@ -429,27 +427,11 @@ event_state_modifies_selection (guint event_state)
return (event_state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
static void
set_single_click_mode (NautilusList *list,
gboolean single_click_mode)
void
nautilus_list_set_single_click_mode (NautilusList *list,
gboolean single_click_mode)
{
if (list->details->single_click_mode == single_click_mode) {
return;
}
list->details->single_click_mode = single_click_mode;
gtk_widget_queue_draw (GTK_WIDGET (list));
}
static void
update_single_click_mode_from_preferences (NautilusList *list)
{
int click_policy;
click_policy = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_CLICK_POLICY_SINGLE);
set_single_click_mode (list, click_policy == NAUTILUS_CLICK_POLICY_SINGLE);
}
/* Standard object initialization function */
......@@ -488,14 +470,6 @@ nautilus_list_initialize (NautilusList *list)
list->details->type_select_pattern = NULL;
list->details->last_typeselect_time = 0LL;
/* Initialize the single click mode from preferences */
update_single_click_mode_from_preferences (list);
/* Keep track of changes in clicking policy */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list);
}
static void
......@@ -509,10 +483,6 @@ nautilus_list_destroy (GtkObject *object)
unschedule_keyboard_row_reveal (list);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
g_free (list->details->type_select_pattern);
......@@ -2552,12 +2522,6 @@ nautilus_list_clear (GtkCList *clist)
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, clear, (clist));
}
static void
click_policy_changed_callback (gpointer user_data)
{
update_single_click_mode_from_preferences (NAUTILUS_LIST (user_data));
}
/**
* nautilus_list_new_with_titles:
......
......@@ -117,29 +117,29 @@ struct NautilusListClass {
typedef gboolean (* NautilusEachRowFunction) (GtkCListRow *, gpointer);
GtkType nautilus_list_get_type (void);
GtkWidget *nautilus_list_new_with_titles (int columns,
const char * const *titles);
GList * nautilus_list_get_selection (NautilusList *list);
void nautilus_list_set_selection (NautilusList *list,
GList *selection);
gboolean nautilus_list_is_row_selected (NautilusList *list,
int row);
void nautilus_list_set_pixbuf_list (NautilusList *list,
gint row,
gint column,
GList *pixbufs);
void nautilus_list_mark_cell_as_link (NautilusList *list,
gint row,
gint column);
void nautilus_list_set_single_click_mode (NautilusList *list,
gboolean single_click_mode);
void nautilus_list_select_row (NautilusList *list,
int row);
GtkCListRow *nautilus_list_row_at (NautilusList *list,
int y);
void nautilus_list_each_selected_row (NautilusList *list,
NautilusEachRowFunction function,
gpointer data);
GtkType nautilus_list_get_type (void);
GtkWidget * nautilus_list_new_with_titles (int columns,
const char * const *titles);
GList * nautilus_list_get_selection (NautilusList *list);
void nautilus_list_set_selection (NautilusList *list,
GList *selection);
gboolean nautilus_list_is_row_selected (NautilusList *list,
int row);
void nautilus_list_set_pixbuf_list (NautilusList *list,
gint row,
gint column,
GList *pixbufs);
void nautilus_list_mark_cell_as_link (NautilusList *list,
gint row,
gint column);
void nautilus_list_set_single_click_mode (NautilusList *list,
gboolean single_click_mode);
void nautilus_list_select_row (NautilusList *list,
int row);
GtkCListRow *nautilus_list_row_at (NautilusList *list,
int y);
void nautilus_list_each_selected_row (NautilusList *list,
NautilusEachRowFunction function,
gpointer data);
#endif /* NAUTILUS_LIST_H */
......@@ -38,7 +38,6 @@
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-global-preferences.h"
#include "nautilus-gnome-extensions.h"
#include "nautilus-gtk-extensions.h"
#include "nautilus-gtk-macros.h"
......@@ -101,8 +100,6 @@ static void end_renaming_mode (NautilusIconConta
gboolean commit);
static void hide_rename_widget (NautilusIconContainer *container,
NautilusIcon *icon);
static void anti_aliased_preferences_changed (gpointer user_data);
static void click_policy_changed_callback (gpointer user_data);
static void finish_adding_new_icons (NautilusIconContainer *container);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer, nautilus_icon_container, GNOME_TYPE_CANVAS)
......@@ -1641,14 +1638,6 @@ destroy (GtkObject *object)
if (container->details->label_font[i] != NULL)
gdk_font_unref (container->details->label_font[i]);
}
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
container);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_preferences_changed,
container);
nautilus_icon_container_flush_typeselect_state (container);
......@@ -2400,7 +2389,6 @@ static void
nautilus_icon_container_initialize (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
int mode;
details = g_new0 (NautilusIconContainerDetails, 1);
......@@ -2430,27 +2418,6 @@ nautilus_icon_container_initialize (NautilusIconContainer *container)
container->details->rename_widget = NULL;
container->details->original_text = NULL;
container->details->type_select_state = NULL;
/* FIXME: Settings should be supplied by the caller and not
* hard-wired calls from NautilusIconContainer to preferences.
*/
/* Initialize the single click mode from preferences */
mode = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_CLICK_POLICY_SINGLE);
details->single_click_mode =
mode == NAUTILUS_CLICK_POLICY_SINGLE;
/* Keep track of changes in clicking policy */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
container);
/* Keep track of changes in graphics trade offs */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
anti_aliased_preferences_changed,
container);
}
/* NautilusIcon event handling. */
......@@ -2571,23 +2538,17 @@ item_event_callback (GnomeCanvasItem *item,
GtkWidget *
nautilus_icon_container_new (void)
{
GnomeCanvas *canvas;
GtkWidget *new;
GtkWidget *container;
gtk_widget_push_visual (gdk_rgb_get_visual ());
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
new = gtk_type_new (nautilus_icon_container_get_type ());
container = gtk_type_new (nautilus_icon_container_get_type ());
gtk_widget_pop_visual ();
gtk_widget_pop_colormap ();
canvas = GNOME_CANVAS(new);
if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS, FALSE)) {
canvas->aa = TRUE;
}
return new;
return container;
}
/* Clear all of the icons in the container. */
......@@ -3650,37 +3611,6 @@ nautilus_icon_container_emit_preview_signal (NautilusIconContainer *icon_contain
return result;
}
/* preferences callbacks */
static void
click_policy_changed_callback (gpointer user_data)
{
NautilusIconContainer *container;
int mode;
container = NAUTILUS_ICON_CONTAINER (user_data);
mode = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_CLICK_POLICY_SINGLE);
container->details->single_click_mode =
mode == NAUTILUS_CLICK_POLICY_SINGLE;
}
static void
anti_aliased_preferences_changed (gpointer user_data)
{
NautilusIconContainer *container;
gboolean aa_mode;
container = NAUTILUS_ICON_CONTAINER (user_data);
aa_mode = nautilus_preferences_get_boolean
(NAUTILUS_PREFERENCES_ANTI_ALIASED_CANVAS,
FALSE);
nautilus_icon_container_set_anti_aliased_mode(container, aa_mode);
}
gboolean
nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *container)
{
......@@ -3725,6 +3655,16 @@ nautilus_icon_container_set_label_font_for_zoom_level (NautilusIconContainer *co
container->details->label_font[zoom_level] = font;
}
void
nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container,
gboolean single_click_mode)
{
g_return_if_fail (container != NULL);
g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
container->details->single_click_mode = single_click_mode;
}
#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
static char *
......
......@@ -167,7 +167,7 @@ gboolean nautilus_icon_container_is_renaming (NautilusIconCo
int nautilus_icon_container_get_zoom_level (NautilusIconContainer *view);
void nautilus_icon_container_set_zoom_level (NautilusIconContainer *view,
int new_zoom_level);
void nautilus_icon_container_set_single_click_mode (NautilusIconContainer *view,
void nautilus_icon_container_set_single_click_mode (NautilusIconContainer *container,
gboolean single_click_mode);
void nautilus_icon_container_enable_linger_selection (NautilusIconContainer *view,
gboolean enable);
......
......@@ -42,7 +42,6 @@
#include "nautilus-gdk-extensions.h"
#include "nautilus-gdk-pixbuf-extensions.h"
#include "nautilus-glib-extensions.h"
#include "nautilus-global-preferences.h"
#include "nautilus-gtk-extensions.h"
#include "nautilus-gtk-macros.h"
#include "nautilus-list-column-title.h"
......@@ -56,7 +55,7 @@
struct NautilusListDetails
{
/* Preferences */
/* Single click mode ? */
gboolean single_click_mode;
/* The anchor row for range selections */
......@@ -260,7 +259,6 @@ static gboolean row_set_selected (NautilusList *l
gboolean select);
static gboolean select_row_unselect_others (NautilusList *list,
int row_to_select);
static void click_policy_changed_callback (gpointer user_data);
static void nautilus_list_flush_typeselect_state (NautilusList *container);
static int insert_row (GtkCList *list,
int row,
......@@ -429,27 +427,11 @@ event_state_modifies_selection (guint event_state)
return (event_state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
}
static void
set_single_click_mode (NautilusList *list,
gboolean single_click_mode)
void
nautilus_list_set_single_click_mode (NautilusList *list,
gboolean single_click_mode)
{
if (list->details->single_click_mode == single_click_mode) {
return;
}
list->details->single_click_mode = single_click_mode;
gtk_widget_queue_draw (GTK_WIDGET (list));
}
static void
update_single_click_mode_from_preferences (NautilusList *list)
{
int click_policy;
click_policy = nautilus_preferences_get_enum
(NAUTILUS_PREFERENCES_CLICK_POLICY,
NAUTILUS_CLICK_POLICY_SINGLE);
set_single_click_mode (list, click_policy == NAUTILUS_CLICK_POLICY_SINGLE);
}
/* Standard object initialization function */
......@@ -488,14 +470,6 @@ nautilus_list_initialize (NautilusList *list)
list->details->type_select_pattern = NULL;
list->details->last_typeselect_time = 0LL;
/* Initialize the single click mode from preferences */
update_single_click_mode_from_preferences (list);
/* Keep track of changes in clicking policy */
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list);
}
static void
......@@ -509,10 +483,6 @@ nautilus_list_destroy (GtkObject *object)
unschedule_keyboard_row_reveal (list);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
list);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
g_free (list->details->type_select_pattern);
......@@ -2552,12 +2522,6 @@ nautilus_list_clear (GtkCList *clist)
NAUTILUS_CALL_PARENT_CLASS (GTK_CLIST_CLASS, clear, (clist));
}
static void
click_policy_changed_callback (gpointer user_data)
{
update_single_click_mode_from_preferences (NAUTILUS_LIST (user_data));
}
/**
* nautilus_list_new_with_titles:
......
......@@ -117,29 +117,29 @@ struct NautilusListClass {
typedef gboolean (* NautilusEachRowFunction) (GtkCListRow *, gpointer);
GtkType nautilus_list_get_type (void);
GtkWidget *nautilus_list_new_with_titles (int columns,
const char * const *titles);
GList * nautilus_list_get_selection (NautilusList *list);
void nautilus_list_set_selection (NautilusList *list,
GList *selection);
gboolean nautilus_list_is_row_selected (NautilusList *list,
int row);
void nautilus_list_set_pixbuf_list (NautilusList *list,
gint row,
gint column,
GList *pixbufs);
void nautilus_list_mark_cell_as_link (NautilusList *list,