mirror of https://github.com/MidnightCommander/mc
1999-08-23 Federico Mena Quintero <federico@redhat.com>
* gdesktop-prefs.[ch]: New files that handle the desktop preferences page. Now we have a nice way to configure the position of desktop icons. * gprefs.c (create_prop_box): Use desktop_prefs_new() to create the desktop preferences page. (apply_page_changes): Do not update the desktop here. (apply_callback): Take the desktop page into account. * gdesktop.c (desktop_use_shaped_text): Renamed from desktop_use_transparent_text. * Makefile.in: Added gdesktop-prefs.[ch] to the list of sources.
This commit is contained in:
parent
35e31e95eb
commit
af568f447e
|
@ -1,3 +1,50 @@
|
|||
1999-08-23 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
* gdesktop-prefs.[ch]: New files that handle the desktop
|
||||
preferences page. Now we have a nice way to configure the
|
||||
position of desktop icons.
|
||||
|
||||
* gprefs.c (create_prop_box): Use desktop_prefs_new() to create
|
||||
the desktop preferences page.
|
||||
(apply_page_changes): Do not update the desktop here.
|
||||
(apply_callback): Take the desktop page into account.
|
||||
|
||||
* gdesktop.c (desktop_use_shaped_text): Renamed from
|
||||
desktop_use_transparent_text.
|
||||
|
||||
* Makefile.in: Added gdesktop-prefs.[ch] to the list of sources.
|
||||
|
||||
1999-08-19 Richard Hestilow <hestgray@ionet.net>
|
||||
|
||||
* gicon.h: define ICON_IMAGE_WIDTH and ICON_IMAGE_HEIGHT
|
||||
for default icon size. Currently set at 48 by 48.
|
||||
|
||||
* gicon.c (gicon_get_icon_for_file): Scale down images that are too
|
||||
large. Scales down to a size <= DESKTOP_ICON_WIDTH by
|
||||
DESKTOP_ICON_HEIGHT. Correctly composites arrows on user-selected
|
||||
icons. Shows gnome-warning for unreachable symlinks with no user
|
||||
selected icon.
|
||||
|
||||
* gdesktop-icon.c (desktop_icon_reshape): dicon->height is now a
|
||||
MAX of total height (icon height + spacing + text height) and
|
||||
DESKTOP_SNAP_X, so that all icons are of a uniform height and small
|
||||
icons center nicely. Rest of function modified to take this into
|
||||
account. create_window_shape is now called last of all,
|
||||
so dicon's various x/y/width/height fields are up to date.
|
||||
(create_window_shape): Determine drawing coordinates based on
|
||||
dicon->icon & dicon->text coordinates, instead of calculating them
|
||||
by hand (Needed for size changes).
|
||||
(set_text): Modified to take the size changes into acount.
|
||||
|
||||
PATCH FROM volker.braun@physik.hu-berlin.de:
|
||||
|
||||
* gprefs.c, setup.c, gdesktop.[ch]: Added option
|
||||
desktop_use_transparent_text (Default is FALSE)
|
||||
|
||||
* gdesktop-icon.c (create_window_shape:
|
||||
* gdesktop.c (click_button_proxy_press): Modified to take into
|
||||
account transparent text.
|
||||
|
||||
1999-08-16 Federico Mena Quintero <federico@redhat.com>
|
||||
|
||||
* gmain.c (default_edition_colors): "brightred" is not a standard
|
||||
|
|
|
@ -36,6 +36,7 @@ GNOMESRCS = \
|
|||
gcorba.c \
|
||||
gdesktop-icon.c \
|
||||
gdesktop-init.c \
|
||||
gdesktop-prefs.c \
|
||||
gdesktop.c \
|
||||
gdialogs.c \
|
||||
gdnd.c \
|
||||
|
@ -75,6 +76,7 @@ GNOMEHDRS = \
|
|||
gcustom-layout.h \
|
||||
gdesktop-icon.h \
|
||||
gdesktop-init.h \
|
||||
gdesktop-prefs.h \
|
||||
gdesktop.h \
|
||||
gdnd.h \
|
||||
gicon.h \
|
||||
|
@ -150,6 +152,7 @@ OBJS = \
|
|||
gcustom-layout.o \
|
||||
gdesktop-icon.o \
|
||||
gdesktop-init.o \
|
||||
gdesktop-prefs.o \
|
||||
gdesktop.o \
|
||||
gdnd.o \
|
||||
ghelp.o \
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
/* GNU Midnight Commander -- GNOME edition
|
||||
*
|
||||
* Preferences page for custom list view
|
||||
/* Custom layout preferences box for the Midnight Commander
|
||||
*
|
||||
* Copyright (C) 1999 The Free Software Foundation
|
||||
*
|
||||
* Author: Owen Taylor
|
||||
* Author: Owen Taylor <otaylor@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* Custom layout preferences box for the Midnight Commander
|
||||
*
|
||||
* Copyright (C) 1999 The Free Software Foundation
|
||||
*
|
||||
* Author: Owen Taylor <otaylor@redhat.com>
|
||||
*/
|
||||
|
||||
typedef struct _GCustomLayout GCustomLayout;
|
||||
|
||||
GCustomLayout *custom_layout_create_page (GnomePropertyBox *prop_box,
|
||||
|
|
|
@ -203,18 +203,17 @@ set_icon (DesktopIcon *dicon, GdkImlibImage *im)
|
|||
static void
|
||||
set_text (DesktopIcon *dicon, char *text)
|
||||
{
|
||||
GtkArg arg;
|
||||
int icon_height;
|
||||
|
||||
arg.name = "height";
|
||||
gtk_object_getv (GTK_OBJECT (dicon->icon), 1, &arg);
|
||||
icon_height = GTK_VALUE_DOUBLE (arg);
|
||||
|
||||
int text_height;
|
||||
double x1, y1, x2, y2;
|
||||
|
||||
gnome_canvas_item_get_bounds (dicon->text, &x1, &y1, &x2, &y2);
|
||||
text_height = y2 = y1;
|
||||
|
||||
gtk_signal_handler_block (GTK_OBJECT (dicon->text), dicon->w_changed_id);
|
||||
gtk_signal_handler_block (GTK_OBJECT (dicon->text), dicon->h_changed_id);
|
||||
|
||||
gnome_icon_text_item_configure (GNOME_ICON_TEXT_ITEM (dicon->text),
|
||||
0, icon_height + SPACING,
|
||||
0, dicon->height - text_height,
|
||||
DESKTOP_SNAP_X,
|
||||
DESKTOP_ICON_FONT,
|
||||
text,
|
||||
|
@ -297,6 +296,7 @@ create_window_shape (DesktopIcon *dicon, int icon_width, int icon_height, int te
|
|||
GdkBitmap *im_mask;
|
||||
GdkGC *mgc;
|
||||
GdkColor c;
|
||||
GnomeIconTextItem *i;
|
||||
|
||||
/* Create the initial mask and clear it */
|
||||
|
||||
|
@ -321,21 +321,29 @@ create_window_shape (DesktopIcon *dicon, int icon_width, int icon_height, int te
|
|||
mgc,
|
||||
im_mask,
|
||||
0, 0,
|
||||
(dicon->width - icon_width) / 2, 0,
|
||||
dicon->icon_x, dicon->icon_y,
|
||||
icon_width, icon_height);
|
||||
gdk_imlib_free_bitmap (im_mask);
|
||||
} else
|
||||
gdk_draw_rectangle (mask, mgc, TRUE,
|
||||
(dicon->width - icon_width) / 2, 0,
|
||||
dicon->icon_x, dicon->icon_y,
|
||||
icon_width, icon_height);
|
||||
|
||||
/* Fill the area for the text */
|
||||
|
||||
gdk_draw_rectangle (mask, mgc, TRUE,
|
||||
(dicon->width - text_width) / 2,
|
||||
icon_height + SPACING,
|
||||
text_width, text_height);
|
||||
|
||||
i = GNOME_ICON_TEXT_ITEM (dicon->text);
|
||||
if (desktop_use_shaped_text && !i->editing && !i->selected)
|
||||
gnome_icon_paint_text (i->ti,
|
||||
mask, mgc,
|
||||
dicon->text_x + 2,
|
||||
dicon->text_y + 2,
|
||||
GTK_JUSTIFY_CENTER);
|
||||
else
|
||||
gdk_draw_rectangle (mask, mgc, TRUE,
|
||||
dicon->text_x,
|
||||
dicon->text_y,
|
||||
text_width, text_height);
|
||||
|
||||
if (!GTK_WIDGET_REALIZED (dicon))
|
||||
gtk_widget_realize (GTK_WIDGET (dicon));
|
||||
|
||||
|
@ -357,6 +365,7 @@ desktop_icon_reshape (DesktopIcon *dicon)
|
|||
GtkArg args[2];
|
||||
int icon_width, icon_height;
|
||||
int text_width, text_height;
|
||||
int total_height;
|
||||
double x1, y1, x2, y2;
|
||||
|
||||
g_return_if_fail (dicon != NULL);
|
||||
|
@ -377,40 +386,39 @@ desktop_icon_reshape (DesktopIcon *dicon)
|
|||
text_width = x2 - x1;
|
||||
text_height = y2 - y1;
|
||||
|
||||
total_height = icon_height + SPACING + text_height;
|
||||
|
||||
/* Calculate new size of widget */
|
||||
|
||||
dicon->width = MAX (icon_width, DESKTOP_SNAP_X);
|
||||
dicon->height = icon_height + SPACING + text_height;
|
||||
dicon->height = MAX (total_height, DESKTOP_SNAP_Y);
|
||||
|
||||
/* Set new position of children */
|
||||
|
||||
gnome_canvas_item_set (dicon->icon,
|
||||
"x", (dicon->width - icon_width) / 2.0,
|
||||
"y", 0.0,
|
||||
"y", (dicon->height - total_height) / 2.0,
|
||||
NULL);
|
||||
gnome_canvas_item_set (dicon->stipple,
|
||||
"x1", 0.0,
|
||||
"y1", 0.0,
|
||||
"x2", (double) dicon->width,
|
||||
"y2", (double) icon_height,
|
||||
"y2", (double) dicon->height - text_height - SPACING,
|
||||
NULL);
|
||||
|
||||
if (dicon->width <= DESKTOP_SNAP_X)
|
||||
gnome_icon_text_item_setxy (GNOME_ICON_TEXT_ITEM (dicon->text),
|
||||
0,
|
||||
icon_height + SPACING);
|
||||
dicon->height - text_height);
|
||||
else
|
||||
gnome_icon_text_item_setxy (GNOME_ICON_TEXT_ITEM (dicon->text),
|
||||
(dicon->width - DESKTOP_SNAP_X) / 2,
|
||||
icon_height + SPACING);
|
||||
|
||||
/* Create and set the window shape */
|
||||
|
||||
dicon->height - text_height);
|
||||
|
||||
gtk_widget_set_usize (GTK_WIDGET (dicon), dicon->width, dicon->height);
|
||||
create_window_shape (dicon, icon_width, icon_height, text_width, text_height);
|
||||
|
||||
dicon->icon_x = (int) ((dicon->width - icon_width) / 2.0 + 0.5);
|
||||
dicon->icon_y = 0;
|
||||
dicon->icon_y = (int) ((dicon->height - total_height) / 2.0 + 0.5);
|
||||
dicon->icon_w = icon_width;
|
||||
dicon->icon_h = icon_height;
|
||||
|
||||
|
@ -420,6 +428,11 @@ desktop_icon_reshape (DesktopIcon *dicon)
|
|||
dicon->text_y = y1;
|
||||
dicon->text_w = text_width;
|
||||
dicon->text_h = text_height;
|
||||
|
||||
/* Create and set the window shape */
|
||||
|
||||
create_window_shape (dicon, icon_width, icon_height, text_width, text_height);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -436,10 +449,13 @@ desktop_icon_select (DesktopIcon *dicon, int sel)
|
|||
g_return_if_fail (dicon != NULL);
|
||||
g_return_if_fail (IS_DESKTOP_ICON (dicon));
|
||||
|
||||
gnome_icon_text_item_select (GNOME_ICON_TEXT_ITEM (dicon->text), sel);
|
||||
|
||||
if (desktop_use_shaped_text)
|
||||
desktop_icon_reshape (dicon);
|
||||
|
||||
if (sel)
|
||||
gnome_canvas_item_show (dicon->stipple);
|
||||
else
|
||||
gnome_canvas_item_hide (dicon->stipple);
|
||||
|
||||
gnome_icon_text_item_select (GNOME_ICON_TEXT_ITEM (dicon->text), sel);
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ struct layout_slot {
|
|||
/* Configuration options for the desktop */
|
||||
|
||||
int desktop_use_shaped_icons = TRUE;
|
||||
int desktop_use_shaped_text = FALSE;
|
||||
int desktop_auto_placement = FALSE;
|
||||
int desktop_snap_icons = FALSE;
|
||||
int desktop_arr_r2l = FALSE;
|
||||
|
@ -2840,7 +2841,6 @@ update_drag_selection (int x, int y)
|
|||
desktop_icon_select (DESKTOP_ICON (dii->dicon), dii->tmp_selected);
|
||||
dii->selected = dii->tmp_selected;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2850,6 +2850,29 @@ click_proxy_button_press (GtkWidget *widget, GdkEventButton *event, gpointer dat
|
|||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
/* maybe the user wants to click on the icon text */
|
||||
if (event->button == 1 && desktop_use_shaped_text) {
|
||||
int x = event->x;
|
||||
int y = event->y;
|
||||
GList *l, *icons = get_all_icons ();
|
||||
DesktopIconInfo *clicked = NULL;
|
||||
for (l = icons; l; l = l->next) {
|
||||
DesktopIconInfo *dii = l->data;
|
||||
DesktopIcon *di = DESKTOP_ICON (dii->dicon);
|
||||
int x1 = dii->x + di->text_x;
|
||||
int y1 = dii->y + di->text_y;
|
||||
int x2 = x1 + di->text_w;
|
||||
int y2 = y1 + di->text_h;
|
||||
if (x>=x1 && y>=y1 && x<=x2 && y<=y2)
|
||||
clicked = dii;
|
||||
}
|
||||
g_list_free (icons);
|
||||
if (clicked) {
|
||||
select_icon (clicked, event->state);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (event->button == 1) {
|
||||
click_start_x = event->x;
|
||||
click_start_y = event->y;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
/* Configuration options for the desktop */
|
||||
|
||||
extern int desktop_use_shaped_icons; /* Whether to use shaped icons or not (for slow X servers) */
|
||||
extern int desktop_use_shaped_text; /* Shaped text for the icons on the desktop */
|
||||
extern int desktop_auto_placement; /* Whether to auto-place icons or not (user placement) */
|
||||
extern int desktop_snap_icons; /* Whether to snap icons to the grid or not */
|
||||
extern int desktop_arr_r2l; /* Arrange from right to left */
|
||||
|
|
134
gnome/gicon.c
134
gnome/gicon.c
|
@ -117,6 +117,71 @@ ensure_icon_image (IconSet *iset, IconType type)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
compute_scaled_size (int width, int height, int *nwidth, int *nheight)
|
||||
{
|
||||
g_return_if_fail (nwidth != NULL);
|
||||
g_return_if_fail (nheight != NULL);
|
||||
|
||||
if (width <= ICON_IMAGE_WIDTH && height <= ICON_IMAGE_HEIGHT) {
|
||||
*nheight = height;
|
||||
*nwidth = width;
|
||||
} else if (width < height) {
|
||||
*nheight = ICON_IMAGE_HEIGHT;
|
||||
*nwidth = *nheight * width / height;
|
||||
} else {
|
||||
*nwidth = ICON_IMAGE_WIDTH;
|
||||
*nheight = *nwidth * height / width;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns a newly allocated, correctly scaled image */
|
||||
static GdkImlibImage *
|
||||
get_scaled_image (GdkImlibImage *orig)
|
||||
{
|
||||
GdkImlibImage *im;
|
||||
int width, height;
|
||||
|
||||
g_return_val_if_fail (orig != NULL, NULL);
|
||||
|
||||
compute_scaled_size (orig->rgb_width, orig->rgb_height,
|
||||
&width, &height);
|
||||
im = gdk_imlib_clone_scaled_image (orig, width, height);
|
||||
|
||||
return im;
|
||||
}
|
||||
|
||||
/* Returns the icon set corresponding to the specified image.
|
||||
* If we create a new IconSet, iset->plain is set to a new scaled
|
||||
* image, so _WE FREE THE IM PARAMETER_. */
|
||||
static IconSet *
|
||||
get_icon_set_from_image (GdkImlibImage *im)
|
||||
{
|
||||
IconSet *iset;
|
||||
|
||||
g_return_val_if_fail (im != NULL, NULL);
|
||||
|
||||
iset = g_hash_table_lookup (image_hash, im);
|
||||
if (iset)
|
||||
return iset;
|
||||
|
||||
iset = g_new (IconSet, 1);
|
||||
iset->plain = get_scaled_image (im);
|
||||
iset->symlink = NULL;
|
||||
iset->stalled = NULL;
|
||||
iset->filename = NULL;
|
||||
|
||||
|
||||
/* Insert the icon information into the hash tables */
|
||||
|
||||
g_hash_table_remove (image_hash, im);
|
||||
g_hash_table_insert (image_hash, iset->plain, iset);
|
||||
|
||||
gdk_imlib_destroy_image (im);
|
||||
|
||||
return iset;
|
||||
}
|
||||
|
||||
/* Returns the icon set corresponding to the specified icon filename, or NULL if
|
||||
* the file could not be loaded.
|
||||
*/
|
||||
|
@ -125,7 +190,7 @@ get_icon_set (const char *filename)
|
|||
{
|
||||
GdkImlibImage *im;
|
||||
IconSet *iset;
|
||||
|
||||
|
||||
iset = g_hash_table_lookup (name_hash, filename);
|
||||
if (iset)
|
||||
return iset;
|
||||
|
@ -133,17 +198,16 @@ get_icon_set (const char *filename)
|
|||
im = gdk_imlib_load_image ((char *) filename);
|
||||
if (!im)
|
||||
return NULL;
|
||||
|
||||
iset = get_icon_set_from_image (im);
|
||||
im = NULL;
|
||||
|
||||
iset = g_new (IconSet, 1);
|
||||
iset->plain = im;
|
||||
iset->symlink = NULL;
|
||||
iset->filename = g_strdup (filename);
|
||||
|
||||
/* Insert the icon information into the hash tables */
|
||||
|
||||
g_hash_table_insert (name_hash, iset->filename, iset);
|
||||
g_hash_table_insert (image_hash, iset->plain, iset);
|
||||
|
||||
|
||||
return iset;
|
||||
}
|
||||
|
||||
|
@ -234,29 +298,30 @@ get_icon_from_metadata (char *filename)
|
|||
{
|
||||
int size;
|
||||
char *buf;
|
||||
GdkImlibImage *im;
|
||||
IconSet *iset;
|
||||
|
||||
IconSet *iset = NULL;
|
||||
|
||||
/* Try the inlined icon */
|
||||
|
||||
if (gnome_metadata_get (filename, "icon-inline-png", &size, &buf) == 0) {
|
||||
GdkImlibImage *im;
|
||||
im = gdk_imlib_inlined_png_to_image (buf, size);
|
||||
g_free (buf);
|
||||
|
||||
if (im)
|
||||
return im;
|
||||
if (im) {
|
||||
iset = get_icon_set_from_image (im);
|
||||
im = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Try the non-inlined icon */
|
||||
|
||||
if (gnome_metadata_get (filename, "icon-filename", &size, &buf) == 0) {
|
||||
if (!iset && gnome_metadata_get (filename, "icon-filename", &size, &buf) == 0) {
|
||||
iset = get_icon_set (buf);
|
||||
g_free (buf);
|
||||
|
||||
if (iset) {
|
||||
ensure_icon_image (iset, ICON_TYPE_PLAIN);
|
||||
return iset->plain;
|
||||
}
|
||||
}
|
||||
|
||||
if (iset) {
|
||||
ensure_icon_image (iset, ICON_TYPE_PLAIN);
|
||||
return iset->plain;
|
||||
}
|
||||
|
||||
return NULL; /* nothing is available */
|
||||
|
@ -355,6 +420,7 @@ gicon_get_icon_for_file (char *directory, file_entry *fe, gboolean do_quick)
|
|||
IconSet *iset;
|
||||
mode_t mode;
|
||||
const char *mime_type;
|
||||
gboolean is_user_set = FALSE;
|
||||
|
||||
g_return_val_if_fail (directory != NULL, NULL);
|
||||
g_return_val_if_fail (fe != NULL, NULL);
|
||||
|
@ -372,13 +438,31 @@ gicon_get_icon_for_file (char *directory, file_entry *fe, gboolean do_quick)
|
|||
full_name = g_concat_dir_and_file (directory, fe->fname);
|
||||
im = get_icon_from_metadata (full_name);
|
||||
g_free (full_name);
|
||||
|
||||
if (im) {
|
||||
iset = get_icon_set_from_image (im);
|
||||
im = NULL;
|
||||
is_user_set = TRUE;
|
||||
goto add_link;
|
||||
}
|
||||
}
|
||||
|
||||
/* 2. Before we do anything else, make sure the
|
||||
* pointed-to file exists if a link */
|
||||
|
||||
if (S_ISLNK (mode) && fe->f.stalled_link) {
|
||||
const char *icon_name;
|
||||
|
||||
if (im)
|
||||
return im;
|
||||
icon_name = gnome_unconditional_pixmap_file ("gnome-warning.png");
|
||||
if (icon_name) {
|
||||
iset = get_icon_set (icon_name);
|
||||
if (iset)
|
||||
goto add_link;
|
||||
}
|
||||
}
|
||||
|
||||
/* 2. See if it is a directory */
|
||||
|
||||
/* 3. See if it is a directory */
|
||||
|
||||
if (S_ISDIR (mode)) {
|
||||
if (can_access_directory (fe))
|
||||
iset = iset_directory;
|
||||
|
@ -388,7 +472,7 @@ gicon_get_icon_for_file (char *directory, file_entry *fe, gboolean do_quick)
|
|||
goto add_link;
|
||||
}
|
||||
|
||||
/* 3. Try MIME-types */
|
||||
/* 4. Try MIME-types */
|
||||
|
||||
mime_type = gnome_mime_type_or_default (fe->fname, NULL);
|
||||
if (mime_type) {
|
||||
|
@ -402,7 +486,7 @@ gicon_get_icon_for_file (char *directory, file_entry *fe, gboolean do_quick)
|
|||
}
|
||||
}
|
||||
|
||||
/* 4. Get an icon from the file mode */
|
||||
/* 5. Get an icon from the file mode */
|
||||
|
||||
iset = get_default_icon (fe);
|
||||
|
||||
|
@ -411,7 +495,7 @@ gicon_get_icon_for_file (char *directory, file_entry *fe, gboolean do_quick)
|
|||
g_assert (iset != NULL);
|
||||
|
||||
if (S_ISLNK (mode)) {
|
||||
if (fe->f.link_to_dir)
|
||||
if (fe->f.link_to_dir && !is_user_set)
|
||||
iset = iset_directory;
|
||||
|
||||
if (fe->f.stalled_link) {
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#include <gdk_imlib.h>
|
||||
#include "dir.h"
|
||||
|
||||
/* Standard icon sizes */
|
||||
#define ICON_IMAGE_WIDTH 48
|
||||
#define ICON_IMAGE_HEIGHT 48
|
||||
|
||||
void gicon_init (void);
|
||||
|
||||
|
|
158
gnome/gprefs.c
158
gnome/gprefs.c
|
@ -21,9 +21,9 @@
|
|||
#include "dialog.h"
|
||||
#include "layout.h"
|
||||
#include "gcustom-layout.h"
|
||||
#include "gdesktop-prefs.h"
|
||||
#include "../vfs/vfs.h"
|
||||
#include "gprefs.h"
|
||||
#include "gdesktop.h"
|
||||
|
||||
/* Orphan confirmation options */
|
||||
/* Auto save setup */
|
||||
|
@ -56,21 +56,25 @@ typedef struct
|
|||
gpointer property_variable;
|
||||
gpointer extra_data1;
|
||||
gpointer extra_data2;
|
||||
|
||||
GtkWidget *widget;
|
||||
} Property;
|
||||
|
||||
typedef struct
|
||||
GtkWidget *widget;
|
||||
} Property;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gchar *title;
|
||||
Property *props;
|
||||
Property *props;
|
||||
} PrefsPage;
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
WPanel *panel;
|
||||
GtkWidget *prop_box;
|
||||
PrefsPage *prefs_pages;
|
||||
|
||||
GDesktopPrefs *desktop_prefs;
|
||||
gint desktop_prefs_page;
|
||||
|
||||
GCustomLayout *custom_layout;
|
||||
gint custom_layout_page;
|
||||
} PrefsDlg;
|
||||
|
@ -82,14 +86,14 @@ typedef struct
|
|||
typedef GtkWidget* (*CustomCreateFunc) (PrefsDlg *dlg, Property *prop);
|
||||
typedef void (*CustomApplyFunc) (PrefsDlg *dlg, Property *prop);
|
||||
|
||||
static Property file_display_props [] =
|
||||
static Property file_display_props [] =
|
||||
{
|
||||
{
|
||||
N_("Show backup files"), PROPERTY_BOOL,
|
||||
N_("Show backup files"), PROPERTY_BOOL,
|
||||
&show_backups, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Show hidden files"), PROPERTY_BOOL,
|
||||
N_("Show hidden files"), PROPERTY_BOOL,
|
||||
&show_dot_files, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
|
@ -103,22 +107,22 @@ static Property file_display_props [] =
|
|||
PROPERTIES_DONE
|
||||
};
|
||||
|
||||
static Property confirmation_props [] =
|
||||
static Property confirmation_props [] =
|
||||
{
|
||||
{
|
||||
N_("Confirm when deleting file"), PROPERTY_BOOL,
|
||||
N_("Confirm when deleting file"), PROPERTY_BOOL,
|
||||
&confirm_delete, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Confirm when overwriting files"), PROPERTY_BOOL,
|
||||
N_("Confirm when overwriting files"), PROPERTY_BOOL,
|
||||
&confirm_overwrite, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Confirm when executing files"), PROPERTY_BOOL,
|
||||
N_("Confirm when executing files"), PROPERTY_BOOL,
|
||||
&confirm_execute, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Show progress while operations are being performed"), PROPERTY_BOOL,
|
||||
N_("Show progress while operations are being performed"), PROPERTY_BOOL,
|
||||
&verbose, NULL, NULL, NULL
|
||||
},
|
||||
PROPERTIES_DONE
|
||||
|
@ -140,8 +144,8 @@ static Property vfs_props [] =
|
|||
},
|
||||
PROPERTIES_DONE
|
||||
};
|
||||
|
||||
static Property caching_and_optimization_props [] =
|
||||
|
||||
static Property caching_and_optimization_props [] =
|
||||
{
|
||||
{
|
||||
N_("Fast directory reload"), PROPERTY_BOOL,
|
||||
|
@ -162,40 +166,12 @@ static Property caching_and_optimization_props [] =
|
|||
PROPERTIES_DONE
|
||||
};
|
||||
|
||||
static Property desktop_props [] = {
|
||||
{
|
||||
N_("Use shaped icons"), PROPERTY_BOOL,
|
||||
&desktop_use_shaped_icons, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Auto place icons"), PROPERTY_BOOL,
|
||||
&desktop_auto_placement, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Snap icons to grid"), PROPERTY_BOOL,
|
||||
&desktop_snap_icons, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Layout icons from right to left"), PROPERTY_BOOL,
|
||||
&desktop_arr_r2l, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Layout icons from bottom to top"), PROPERTY_BOOL,
|
||||
&desktop_arr_b2t, NULL, NULL, NULL
|
||||
},
|
||||
{
|
||||
N_("Layout icons in rows instead of columns"), PROPERTY_BOOL,
|
||||
&desktop_arr_rows, NULL, NULL, NULL
|
||||
},
|
||||
PROPERTIES_DONE
|
||||
};
|
||||
|
||||
static PrefsPage prefs_pages [] =
|
||||
{
|
||||
{
|
||||
N_("File display"),
|
||||
file_display_props
|
||||
},
|
||||
},
|
||||
{
|
||||
N_("Confirmation"),
|
||||
confirmation_props
|
||||
|
@ -208,23 +184,19 @@ static PrefsPage prefs_pages [] =
|
|||
N_("Caching"),
|
||||
caching_and_optimization_props
|
||||
},
|
||||
{
|
||||
N_("Desktop"),
|
||||
desktop_props
|
||||
},
|
||||
PREFSPAGES_DONE
|
||||
};
|
||||
|
||||
static void
|
||||
static void
|
||||
apply_changes_bool (PrefsDlg *dlg, Property *cur_prop)
|
||||
{
|
||||
GtkWidget *checkbox;
|
||||
|
||||
|
||||
checkbox = cur_prop->widget;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (checkbox)->active)
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (checkbox)->active)
|
||||
*( (int*) cur_prop->property_variable) = TRUE;
|
||||
else
|
||||
else
|
||||
*( (int*) cur_prop->property_variable) = FALSE;
|
||||
}
|
||||
|
||||
|
@ -235,7 +207,7 @@ apply_changes_string (PrefsDlg *dlg, Property *cur_prop)
|
|||
gchar *text;
|
||||
|
||||
entry = cur_prop->widget;
|
||||
|
||||
|
||||
text = gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry))));
|
||||
|
||||
*( (char**) cur_prop->property_variable) = g_strdup (text);
|
||||
|
@ -255,7 +227,7 @@ apply_changes_int (PrefsDlg *dlg, Property *cur_prop)
|
|||
*( (int*) cur_prop->property_variable) = (gint) val;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
apply_changes_custom (PrefsDlg *dlg, Property *cur_prop)
|
||||
{
|
||||
CustomApplyFunc apply = (CustomApplyFunc) cur_prop->extra_data2;
|
||||
|
@ -278,7 +250,7 @@ apply_page_changes (PrefsDlg *dlg, gint pagenum)
|
|||
case PROPERTY_NONE :
|
||||
g_warning ("Invalid case in gprefs.c: apply_page_changes");
|
||||
break;
|
||||
case PROPERTY_BOOL :
|
||||
case PROPERTY_BOOL :
|
||||
apply_changes_bool (dlg, &cur_prop);
|
||||
break;
|
||||
case PROPERTY_STRING :
|
||||
|
@ -296,22 +268,21 @@ apply_page_changes (PrefsDlg *dlg, gint pagenum)
|
|||
}
|
||||
|
||||
static void
|
||||
apply_callback (GtkWidget *prop_box, gint pagenum, PrefsDlg *dlg)
|
||||
apply_callback (GtkWidget *prop_box, gint pagenum, PrefsDlg *dlg)
|
||||
{
|
||||
if (pagenum == dlg->custom_layout_page) {
|
||||
if (pagenum == dlg->desktop_prefs_page)
|
||||
desktop_prefs_apply (dlg->desktop_prefs);
|
||||
else if (pagenum == dlg->custom_layout_page)
|
||||
custom_layout_apply (dlg->custom_layout);
|
||||
} else if (pagenum != -1) {
|
||||
else if (pagenum != -1)
|
||||
apply_page_changes (dlg, pagenum);
|
||||
} else {
|
||||
/* FIXME: can be optimized. Only if some of the
|
||||
* boolean flags changed this makes sense
|
||||
*/
|
||||
else {
|
||||
update_panels (UP_RELOAD, UP_KEEPSEL);
|
||||
save_setup ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
changed_callback (GtkWidget *widget, PrefsDlg *dlg)
|
||||
{
|
||||
if (dlg->prop_box)
|
||||
|
@ -322,9 +293,9 @@ static GtkWidget*
|
|||
create_prop_bool (PrefsDlg *dlg, Property *prop)
|
||||
{
|
||||
GtkWidget *checkbox;
|
||||
|
||||
|
||||
checkbox = gtk_check_button_new_with_label (_(prop->label));
|
||||
|
||||
|
||||
if (*((int*) prop->property_variable)) {
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox),
|
||||
TRUE);
|
||||
|
@ -333,7 +304,7 @@ create_prop_bool (PrefsDlg *dlg, Property *prop)
|
|||
FALSE);
|
||||
}
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (checkbox), "clicked",
|
||||
gtk_signal_connect (GTK_OBJECT (checkbox), "clicked",
|
||||
changed_callback, (gpointer) dlg);
|
||||
|
||||
prop->widget = checkbox;
|
||||
|
@ -351,9 +322,9 @@ create_prop_string (PrefsDlg *dlg, Property *prop)
|
|||
gint max_length;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||
|
||||
|
||||
label = gtk_label_new (_(prop->label));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label,
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
entry = gnome_entry_new (_(prop->label));
|
||||
|
@ -367,20 +338,20 @@ create_prop_string (PrefsDlg *dlg, Property *prop)
|
|||
|
||||
gtk_entry_set_text (GTK_ENTRY (gtk_entry),
|
||||
(gchar*) *( (gchar**) prop->property_variable));
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (gtk_entry),
|
||||
"changed",
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (gtk_entry),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (changed_callback),
|
||||
(gpointer) dlg,
|
||||
GTK_OBJECT (dlg->prop_box));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), entry,
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), entry,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
|
||||
prop->widget = entry;
|
||||
gtk_widget_show_all (hbox);
|
||||
return hbox;
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget*
|
||||
create_prop_int (PrefsDlg *dlg, Property *prop)
|
||||
{
|
||||
|
@ -390,9 +361,9 @@ create_prop_int (PrefsDlg *dlg, Property *prop)
|
|||
gchar buffer [10];
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||
|
||||
|
||||
label = gtk_label_new (_(prop->label));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label,
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
entry = gnome_entry_new (_(prop->label));
|
||||
|
@ -401,34 +372,34 @@ create_prop_int (PrefsDlg *dlg, Property *prop)
|
|||
|
||||
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (entry))),
|
||||
buffer);
|
||||
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (gnome_entry_gtk_entry (GNOME_ENTRY (entry))),
|
||||
"changed",
|
||||
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (gnome_entry_gtk_entry (GNOME_ENTRY (entry))),
|
||||
"changed",
|
||||
GTK_SIGNAL_FUNC (changed_callback),
|
||||
(gpointer) dlg,
|
||||
GTK_OBJECT (dlg->prop_box));
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), entry,
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), entry,
|
||||
FALSE, FALSE, 0);
|
||||
if (prop->extra_data1) {
|
||||
label = gtk_label_new (_((gchar *)prop->extra_data1));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label,
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label,
|
||||
FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
|
||||
prop->widget = entry;
|
||||
gtk_widget_show_all (hbox);
|
||||
return hbox;
|
||||
}
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
static GtkWidget*
|
||||
create_prop_custom (PrefsDlg *dlg, Property *prop)
|
||||
{
|
||||
CustomCreateFunc create = (CustomCreateFunc) prop->extra_data1;
|
||||
|
||||
if (!create)
|
||||
return create_prop_bool (dlg, prop);
|
||||
|
||||
|
||||
return create (dlg, prop);
|
||||
}
|
||||
|
||||
|
@ -454,7 +425,7 @@ create_prop_widget (PrefsDlg *dlg, Property *prop)
|
|||
|
||||
static void
|
||||
create_page (PrefsDlg *dlg, PrefsPage *page)
|
||||
{
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *prop_widget;
|
||||
Property *cur_prop;
|
||||
|
@ -468,7 +439,7 @@ create_page (PrefsDlg *dlg, PrefsPage *page)
|
|||
while (cur_prop->label != NULL) {
|
||||
cur_prop = &(page->props [i]);
|
||||
prop_widget = create_prop_widget (dlg, cur_prop);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), prop_widget,
|
||||
gtk_box_pack_start (GTK_BOX (vbox), prop_widget,
|
||||
FALSE, FALSE, 0);
|
||||
i++;
|
||||
cur_prop = &(page->props [i]);
|
||||
|
@ -510,7 +481,10 @@ create_prop_box (PrefsDlg *dlg)
|
|||
cur_page = &(dlg->prefs_pages [i]);
|
||||
}
|
||||
|
||||
dlg->custom_layout = custom_layout_create_page (GNOME_PROPERTY_BOX (dlg->prop_box),
|
||||
dlg->desktop_prefs = desktop_prefs_new (GNOME_PROPERTY_BOX (dlg->prop_box));
|
||||
dlg->desktop_prefs_page = i++;
|
||||
|
||||
dlg->custom_layout = custom_layout_create_page (GNOME_PROPERTY_BOX (dlg->prop_box),
|
||||
dlg->panel);
|
||||
dlg->custom_layout_page = i;
|
||||
|
||||
|
|
Loading…
Reference in New Issue