1999-02-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdesktop.c (desktop_icon_info_open): Launch a panel at the location of the mount point. * gmount.c (setup_devices): Use g_list_free, not g_free. Fed, test your fixes to my code ;-) * glayout.c (create_container): Add a Desktop menu if the WM is not GNOME compliant.
Этот коммит содержится в:
родитель
0cacebab2a
Коммит
aca0afd352
@ -1,5 +1,14 @@
|
|||||||
1999-02-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
1999-02-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||||
|
|
||||||
|
* gdesktop.c (desktop_icon_info_open): Launch a panel at the
|
||||||
|
location of the mount point.
|
||||||
|
|
||||||
|
* gmount.c (setup_devices): Use g_list_free, not g_free. Fed,
|
||||||
|
test your fixes to my code ;-)
|
||||||
|
|
||||||
|
* glayout.c (create_container): Add a Desktop menu if the WM is
|
||||||
|
not GNOME compliant.
|
||||||
|
|
||||||
* gdesktop.c (setup_motif_dnd_proxy): Use Window instead of
|
* gdesktop.c (setup_motif_dnd_proxy): Use Window instead of
|
||||||
gint32, fix from George Lebl.
|
gint32, fix from George Lebl.
|
||||||
(setup_xdnd_proxy): ditto.
|
(setup_xdnd_proxy): ditto.
|
||||||
|
@ -57,6 +57,9 @@ static int layout_cols;
|
|||||||
static int layout_rows;
|
static int layout_rows;
|
||||||
static struct layout_slot *layout_slots;
|
static struct layout_slot *layout_slots;
|
||||||
|
|
||||||
|
|
||||||
|
int desktop_wm_is_gnome_compliant = -1;
|
||||||
|
|
||||||
#define l_slots(u, v) (layout_slots[(u) * layout_rows + (v)])
|
#define l_slots(u, v) (layout_slots[(u) * layout_rows + (v)])
|
||||||
|
|
||||||
/* The last icon to be selected */
|
/* The last icon to be selected */
|
||||||
@ -369,8 +372,8 @@ typedef struct {
|
|||||||
* specified position if user_pos is TRUE. If it is FALSE, the icons will be
|
* specified position if user_pos is TRUE. If it is FALSE, the icons will be
|
||||||
* auto-placed.
|
* auto-placed.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
reload_desktop_icons (int user_pos, int xpos, int ypos)
|
desktop_reload_icons (int user_pos, int xpos, int ypos)
|
||||||
{
|
{
|
||||||
struct dirent *dirent;
|
struct dirent *dirent;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
@ -569,8 +572,8 @@ reload_desktop_icons (int user_pos, int xpos, int ypos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Perform automatic arrangement of the desktop icons */
|
/* Perform automatic arrangement of the desktop icons */
|
||||||
static void
|
void
|
||||||
arrange_desktop_icons (void)
|
desktop_arrange_icons (void)
|
||||||
{
|
{
|
||||||
GList *icons, *l;
|
GList *icons, *l;
|
||||||
int xpos, ypos;
|
int xpos, ypos;
|
||||||
@ -902,12 +905,15 @@ find_command (char **known_locations)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
is_mountable (char *filename, file_entry *fe, int *is_mounted)
|
is_mountable (char *filename, file_entry *fe, int *is_mounted, char **point)
|
||||||
{
|
{
|
||||||
char buffer [128];
|
char buffer [128], *p;
|
||||||
umode_t mode;
|
umode_t mode;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
|
if (point)
|
||||||
|
*point = NULL;
|
||||||
|
|
||||||
if (!S_ISLNK (fe->buf.st_mode))
|
if (!S_ISLNK (fe->buf.st_mode))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -921,9 +927,13 @@ is_mountable (char *filename, file_entry *fe, int *is_mounted)
|
|||||||
if (readlink (filename, buffer, sizeof (buffer)) == -1)
|
if (readlink (filename, buffer, sizeof (buffer)) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!is_block_device_mountable (buffer))
|
p = is_block_device_mountable (buffer);
|
||||||
|
if (!p)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (point)
|
||||||
|
*point = p;
|
||||||
|
|
||||||
*is_mounted = is_block_device_mounted (buffer);
|
*is_mounted = is_block_device_mounted (buffer);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1021,13 +1031,12 @@ try_to_mount (char *filename, file_entry *fe)
|
|||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (!is_mountable (filename, fe, &x))
|
if (!is_mountable (filename, fe, &x, NULL))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return do_mount_umount (filename, TRUE);
|
return do_mount_umount (filename, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* desktop_icon_info_open:
|
* desktop_icon_info_open:
|
||||||
* @dii: The desktop icon to open.
|
* @dii: The desktop icon to open.
|
||||||
@ -1051,7 +1060,20 @@ desktop_icon_info_open (DesktopIconInfo *dii)
|
|||||||
if (S_ISDIR (fe->buf.st_mode) || link_isdir (fe))
|
if (S_ISDIR (fe->buf.st_mode) || link_isdir (fe))
|
||||||
new_panel_at (filename);
|
new_panel_at (filename);
|
||||||
else {
|
else {
|
||||||
if (!try_to_mount (filename, fe)) {
|
int is_mounted;
|
||||||
|
char *point;
|
||||||
|
int launch = FALSE;
|
||||||
|
|
||||||
|
if (is_mountable (filename, fe, &is_mounted, &point)){
|
||||||
|
if (!is_mounted){
|
||||||
|
if (try_to_mount (filename, fe))
|
||||||
|
launch = TRUE;
|
||||||
|
} else
|
||||||
|
launch = TRUE;
|
||||||
|
|
||||||
|
if (launch)
|
||||||
|
new_panel_at (point);
|
||||||
|
} else {
|
||||||
if (is_exe (fe->buf.st_mode) && if_link_is_exe (desktop_directory, fe))
|
if (is_exe (fe->buf.st_mode) && if_link_is_exe (desktop_directory, fe))
|
||||||
my_system (EXECUTE_AS_SHELL, shell, filename);
|
my_system (EXECUTE_AS_SHELL, shell, filename);
|
||||||
else
|
else
|
||||||
@ -1108,7 +1130,7 @@ do_popup_menu (DesktopIconInfo *dii, GdkEventButton *event)
|
|||||||
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
|
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
|
||||||
|
|
||||||
if (gpopup_do_popup (event, NULL, dii, 0, filename) != -1)
|
if (gpopup_do_popup (event, NULL, dii, 0, filename) != -1)
|
||||||
reload_desktop_icons (FALSE, 0, 0);
|
desktop_reload_icons (FALSE, 0, 0);
|
||||||
|
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
}
|
}
|
||||||
@ -1423,7 +1445,7 @@ drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *sel
|
|||||||
static void
|
static void
|
||||||
drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data)
|
drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data)
|
||||||
{
|
{
|
||||||
reload_desktop_icons (FALSE, 0, 0);
|
desktop_reload_icons (FALSE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up a desktop icon as a DnD source */
|
/* Set up a desktop icon as a DnD source */
|
||||||
@ -1587,7 +1609,7 @@ icon_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gin
|
|||||||
return; /* eeeek */
|
return; /* eeeek */
|
||||||
|
|
||||||
if (gdnd_perform_drop (context, data, desktop_directory, fe))
|
if (gdnd_perform_drop (context, data, desktop_directory, fe))
|
||||||
reload_desktop_icons (FALSE, 0, 0);
|
desktop_reload_icons (FALSE, 0, 0);
|
||||||
|
|
||||||
file_entry_free (fe);
|
file_entry_free (fe);
|
||||||
}
|
}
|
||||||
@ -1966,7 +1988,7 @@ desktop_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x,
|
|||||||
directory = g_strndup (desktop_directory, p - desktop_directory);
|
directory = g_strndup (desktop_directory, p - desktop_directory);
|
||||||
|
|
||||||
if (gdnd_perform_drop (context, data, directory, desktop_fe))
|
if (gdnd_perform_drop (context, data, directory, desktop_fe))
|
||||||
reload_desktop_icons (TRUE, x, y);
|
desktop_reload_icons (TRUE, x, y);
|
||||||
|
|
||||||
g_free (directory);
|
g_free (directory);
|
||||||
file_entry_free (desktop_fe);
|
file_entry_free (desktop_fe);
|
||||||
@ -2074,7 +2096,7 @@ find_click_proxy_window (void)
|
|||||||
static void
|
static void
|
||||||
handle_arrange_icons (GtkWidget *widget, gpointer data)
|
handle_arrange_icons (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
arrange_desktop_icons ();
|
desktop_arrange_icons ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for creating a new panel window */
|
/* Callback for creating a new panel window */
|
||||||
@ -2084,23 +2106,29 @@ handle_new_window (GtkWidget *widget, gpointer data)
|
|||||||
new_panel_at (gnome_user_home_dir);
|
new_panel_at (gnome_user_home_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
desktop_rescan_devices (void)
|
||||||
|
{
|
||||||
|
gmount_setup_devices (TRUE);
|
||||||
|
desktop_reload_icons (FALSE, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Callback for rescanning the mountable devices */
|
/* Callback for rescanning the mountable devices */
|
||||||
static void
|
static void
|
||||||
handle_rescan_devices (GtkWidget *widget, gpointer data)
|
handle_rescan_devices (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
gmount_setup_devices (TRUE);
|
desktop_rescan_devices ();
|
||||||
reload_desktop_icons (FALSE, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for rescanning the desktop directory */
|
/* Callback for rescanning the desktop directory */
|
||||||
static void
|
static void
|
||||||
handle_rescan_desktop (GtkWidget *widget, gpointer data)
|
handle_rescan_desktop (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
reload_desktop_icons (FALSE, 0, 0);
|
desktop_reload_icons (FALSE, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The popup menu for the desktop */
|
/* The popup menu for the desktop */
|
||||||
static GnomeUIInfo desktop_popup_items[] = {
|
GnomeUIInfo desktop_popup_items[] = {
|
||||||
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, handle_arrange_icons),
|
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, handle_arrange_icons),
|
||||||
GNOMEUIINFO_SEPARATOR,
|
GNOMEUIINFO_SEPARATOR,
|
||||||
GNOMEUIINFO_ITEM_NONE (N_("Create New Window"), NULL, handle_new_window),
|
GNOMEUIINFO_ITEM_NONE (N_("Create New Window"), NULL, handle_new_window),
|
||||||
@ -2402,9 +2430,11 @@ setup_desktop_click_proxy_window (void)
|
|||||||
{
|
{
|
||||||
click_proxy_gdk_window = find_click_proxy_window ();
|
click_proxy_gdk_window = find_click_proxy_window ();
|
||||||
if (!click_proxy_gdk_window) {
|
if (!click_proxy_gdk_window) {
|
||||||
|
desktop_wm_is_gnome_compliant = 0;
|
||||||
g_warning ("Root window clicks will not work as no GNOME-compliant window manager could be found!");
|
g_warning ("Root window clicks will not work as no GNOME-compliant window manager could be found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
desktop_wm_is_gnome_compliant = 1;
|
||||||
|
|
||||||
/* Make the proxy window send events to the invisible proxy widget */
|
/* Make the proxy window send events to the invisible proxy widget */
|
||||||
gdk_window_set_user_data (click_proxy_gdk_window, proxy_invisible);
|
gdk_window_set_user_data (click_proxy_gdk_window, proxy_invisible);
|
||||||
@ -2524,7 +2554,7 @@ desktop_init (void)
|
|||||||
gicon_init ();
|
gicon_init ();
|
||||||
create_layout_info ();
|
create_layout_info ();
|
||||||
create_desktop_dir ();
|
create_desktop_dir ();
|
||||||
reload_desktop_icons (FALSE, 0, 0);
|
desktop_reload_icons (FALSE, 0, 0);
|
||||||
|
|
||||||
/* Create the proxy window and initialize all proxying stuff */
|
/* Create the proxy window and initialize all proxying stuff */
|
||||||
|
|
||||||
|
@ -52,7 +52,12 @@ void desktop_icon_info_delete (DesktopIconInfo *dii);
|
|||||||
file_entry *file_entry_from_file (char *filename);
|
file_entry *file_entry_from_file (char *filename);
|
||||||
void file_entry_free (file_entry *fe);
|
void file_entry_free (file_entry *fe);
|
||||||
|
|
||||||
gboolean is_mountable (char *filename, file_entry *fe, int *is_mounted);
|
gboolean is_mountable (char *filename, file_entry *fe, int *is_mounted, char **mount_point);
|
||||||
gboolean do_mount_umount (char *filename, gboolean is_mount);
|
gboolean do_mount_umount (char *filename, gboolean is_mount);
|
||||||
|
|
||||||
|
void desktop_arrange_icons (void);
|
||||||
|
void desktop_rescan_devices (void);
|
||||||
|
void desktop_reload_icons (int user_pos, int xpos, int ypos);
|
||||||
|
|
||||||
|
extern int desktop_wm_is_gnome_compliant;
|
||||||
#endif
|
#endif
|
||||||
|
@ -267,6 +267,12 @@ run_cmd (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_desktop_rescan_devices (void)
|
||||||
|
{
|
||||||
|
desktop_reload_icons (FALSE, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void configure_box (void);
|
void configure_box (void);
|
||||||
|
|
||||||
GtkCheckMenuItem *gnome_toggle_snap (void);
|
GtkCheckMenuItem *gnome_toggle_snap (void);
|
||||||
@ -360,12 +366,21 @@ GnomeUIInfo gnome_panel_about_menu [] = {
|
|||||||
GNOMEUIINFO_END
|
GNOMEUIINFO_END
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GnomeUIInfo gnome_panel_desktop_menu [] = {
|
||||||
|
GNOMEUIINFO_ITEM_NONE (N_("Arrange Icons"), NULL, desktop_arrange_icons),
|
||||||
|
GNOMEUIINFO_SEPARATOR,
|
||||||
|
GNOMEUIINFO_ITEM_NONE (N_("Rescan Mountable Devices"), NULL, desktop_rescan_devices),
|
||||||
|
GNOMEUIINFO_ITEM_NONE (N_("Rescan Desktop"), NULL, do_desktop_rescan_devices),
|
||||||
|
GNOMEUIINFO_END
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GNOME_PANEL_MENU_DESKTOP_INDEX 5
|
||||||
GnomeUIInfo gnome_panel_menu [] = {
|
GnomeUIInfo gnome_panel_menu [] = {
|
||||||
GNOMEUIINFO_MENU_FILE_TREE(gnome_panel_file_menu),
|
GNOMEUIINFO_MENU_FILE_TREE(gnome_panel_file_menu),
|
||||||
GNOMEUIINFO_MENU_EDIT_TREE(gnome_panel_edit_menu),
|
GNOMEUIINFO_MENU_EDIT_TREE(gnome_panel_edit_menu),
|
||||||
GNOMEUIINFO_SUBTREE(N_("_Layout"),gnome_panel_layout_menu),
|
GNOMEUIINFO_SUBTREE(N_("_Layout"),gnome_panel_layout_menu),
|
||||||
GNOMEUIINFO_SUBTREE(N_("_Commands"),gnome_panel_commands_menu),
|
GNOMEUIINFO_SUBTREE(N_("_Commands"),gnome_panel_commands_menu),
|
||||||
GNOMEUIINFO_MENU_HELP_TREE(gnome_panel_about_menu),
|
GNOMEUIINFO_SUBTREE(N_("_Desktop"), gnome_panel_desktop_menu),
|
||||||
GNOMEUIINFO_END
|
GNOMEUIINFO_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -516,6 +531,10 @@ create_container (Dlg_head *h, char *name, char *geometry)
|
|||||||
vbox = gtk_vbox_new (FALSE, 0);
|
vbox = gtk_vbox_new (FALSE, 0);
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 0);
|
||||||
gnome_app_set_contents (GNOME_APP (app), vbox);
|
gnome_app_set_contents (GNOME_APP (app), vbox);
|
||||||
|
|
||||||
|
if (desktop_wm_is_gnome_compliant == 1)
|
||||||
|
gnome_panel_menu [GNOME_PANEL_MENU_DESKTOP_INDEX].type = GNOME_APP_UI_ENDOFINFO;
|
||||||
|
|
||||||
gnome_app_create_menus_with_data (GNOME_APP (app), gnome_panel_menu, panel);
|
gnome_app_create_menus_with_data (GNOME_APP (app), gnome_panel_menu, panel);
|
||||||
create_new_menu (GNOME_APP (app), panel);
|
create_new_menu (GNOME_APP (app), panel);
|
||||||
|
|
||||||
|
@ -96,12 +96,17 @@ void free (void *ptr);
|
|||||||
|
|
||||||
#ifdef MOUNTED_GETMNTENT1
|
#ifdef MOUNTED_GETMNTENT1
|
||||||
|
|
||||||
gboolean
|
/*
|
||||||
|
* Returns wheter devname is mountable:
|
||||||
|
* NULL if it is not or
|
||||||
|
* g_strdup()ed string with the mount point
|
||||||
|
*/
|
||||||
|
char *
|
||||||
is_block_device_mountable (char *devname)
|
is_block_device_mountable (char *devname)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
struct mntent *mnt;
|
struct mntent *mnt;
|
||||||
gboolean retval = FALSE;
|
char *retval = NULL;
|
||||||
|
|
||||||
if (getuid () == 0)
|
if (getuid () == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -112,7 +117,7 @@ is_block_device_mountable (char *devname)
|
|||||||
|
|
||||||
while ((mnt = getmntent (f))){
|
while ((mnt = getmntent (f))){
|
||||||
if (strstr (mnt->mnt_opts, "user")){
|
if (strstr (mnt->mnt_opts, "user")){
|
||||||
retval = TRUE;
|
retval = g_strdup (mnt->mnt_dir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,10 +167,10 @@ get_mountable_devices (void)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
gboolean
|
char *
|
||||||
is_block_device_mountable (char *devname)
|
is_block_device_mountable (char *devname)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
@ -285,7 +290,7 @@ setup_devices (void)
|
|||||||
g_free (l->data);
|
g_free (l->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (list);
|
g_list_free (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -13,9 +13,7 @@
|
|||||||
|
|
||||||
void gmount_setup_devices (int cleanup);
|
void gmount_setup_devices (int cleanup);
|
||||||
|
|
||||||
#if 0
|
char *is_block_device_mountable (char *devname);
|
||||||
gboolean is_block_device_mountable (char *devname);
|
|
||||||
gboolean is_block_device_mounted (char *devname);
|
gboolean is_block_device_mounted (char *devname);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user