mirror of https://github.com/MidnightCommander/mc
1998-03-19 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gdesktop.c (get_transparent_window_for_dentry): New function, creates the proper transparent icon window for a dentry. (post_setup_desktop_icon): New function, does post-setup stuff for a desktop icon (setting it as a drop target, positioning it, etc.). * gpageprop.c (item_properties): Now the dentry parameter is a desktop_icon_t instead. We now return a bitmask that indicates what stuff changed. The caller can use this information to decide what to update, repaint, etc. * gdesktop.h: Moved the icon_t and desktop_icon_t structures here. * gpageprop.c (item_properties): Insert icon control if appropriate. * gprop.c (gprop_icon_new): (gprop_icon_get_data): Renamed from gprop_dir_*(). * gscreen.c (panel_action_properties): Re-reads panel only if necessary. *gpageprop.c (item_properties): now returns TRUE if something got changed, FALSE otherwise. This should be used to decide whether to re-read the panel or not. * gpageprop.c: #include "../vfs/vfs.h". #include "dialog.h". * gprop.c (gprop_dir_new): (gprop_perm_new): (gprop_general_new): Connect to the destroy signal of the toplevel widget and destroy the Gprop structure on the callback.
This commit is contained in:
parent
d37d663f15
commit
442ad09caf
|
@ -1,3 +1,36 @@
|
|||
1998-03-19 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* gdesktop.c (get_transparent_window_for_dentry): New function,
|
||||
creates the proper transparent icon window for a dentry.
|
||||
(post_setup_desktop_icon): New function, does post-setup stuff for
|
||||
a desktop icon (setting it as a drop target, positioning it, etc.).
|
||||
|
||||
* gpageprop.c (item_properties): Now the dentry parameter is a
|
||||
desktop_icon_t instead.
|
||||
We now return a bitmask that indicates what stuff changed. The
|
||||
caller can use this information to decide what to update, repaint, etc.
|
||||
|
||||
* gdesktop.h: Moved the icon_t and desktop_icon_t structures here.
|
||||
|
||||
* gpageprop.c (item_properties): Insert icon control if appropriate.
|
||||
|
||||
* gprop.c (gprop_icon_new):
|
||||
(gprop_icon_get_data): Renamed from gprop_dir_*().
|
||||
|
||||
* gscreen.c (panel_action_properties): Re-reads panel only if necessary.
|
||||
|
||||
*gpageprop.c (item_properties): now returns TRUE if something got
|
||||
changed, FALSE otherwise. This should be used to decide whether
|
||||
to re-read the panel or not.
|
||||
|
||||
* gpageprop.c: #include "../vfs/vfs.h".
|
||||
#include "dialog.h".
|
||||
|
||||
* gprop.c (gprop_dir_new):
|
||||
(gprop_perm_new):
|
||||
(gprop_general_new): Connect to the destroy signal of the toplevel
|
||||
widget and destroy the Gprop structure on the callback.
|
||||
|
||||
Wed Mar 18 23:09:35 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gscreen.c (panel_file_list_select_row): Use control/shift click
|
||||
|
|
283
gnome/gdesktop.c
283
gnome/gdesktop.c
|
@ -17,36 +17,11 @@
|
|||
#include "panel.h"
|
||||
#include "gscreen.h"
|
||||
#include "ext.h"
|
||||
#include "dialog.h"
|
||||
#include "gpageprop.h"
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdkprivate.h>
|
||||
|
||||
/* Types of desktop icons:
|
||||
*
|
||||
* o Application: Double click: start up application;
|
||||
* Dropping: start up program with arguments.
|
||||
*
|
||||
* o Directory: Double click: opens the directory in a panel.
|
||||
* Double click: copies/moves files.
|
||||
*
|
||||
* o File: Opens the application according to regex_command
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
application,
|
||||
directory,
|
||||
file
|
||||
} icon_t;
|
||||
|
||||
/* A structure that describes each icon on the desktop */
|
||||
typedef struct {
|
||||
GnomeDesktopEntry *dentry;
|
||||
GtkWidget *widget;
|
||||
icon_t type;
|
||||
int x, y;
|
||||
char *title;
|
||||
char *pathname;
|
||||
} desktop_icon_t;
|
||||
|
||||
/* operations on drops */
|
||||
enum {
|
||||
OPER_COPY,
|
||||
|
@ -61,6 +36,7 @@ static GnomeRootWin *root_window;
|
|||
char *desktop_directory;
|
||||
|
||||
static void desktop_reload (char *desktop_dir);
|
||||
static void desktop_icon_context_popup (GdkEventButton *event, desktop_icon_t *di);
|
||||
|
||||
/* The list with the filenames we have actually loaded */
|
||||
static GList *desktop_icons;
|
||||
|
@ -359,7 +335,6 @@ void
|
|||
drop_on_directory (GdkEventDropDataAvailable *event, char *dest, int force_manually)
|
||||
{
|
||||
WPanel *source_panel;
|
||||
int x, y;
|
||||
int operation;
|
||||
|
||||
operation = get_operation (event->timestamp, event->coords.x, event->coords.y);
|
||||
|
@ -416,8 +391,7 @@ url_dropped (GtkWidget *widget, GdkEventDropDataAvailable *event, desktop_icon_t
|
|||
printf ("[%s], ", p);
|
||||
p += len;
|
||||
} while (count);
|
||||
printf ("\nReceiving: %s %d\n", event->data, event->data_numbytes);
|
||||
|
||||
printf ("\nReceiving: %s %d\n", (char *) event->data, (int) event->data_numbytes);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -454,40 +428,6 @@ dentry_execute (desktop_icon_t *di)
|
|||
gnome_desktop_entry_launch (dentry);
|
||||
}
|
||||
|
||||
static void
|
||||
dentry_properties (desktop_icon_t *di)
|
||||
{
|
||||
printf ("Edit this widget properties\n");
|
||||
}
|
||||
|
||||
/* Pops up the icon properties pages */
|
||||
static void
|
||||
icon_properties (GtkWidget *widget, desktop_icon_t *di)
|
||||
{
|
||||
item_properties (di->pathname, di->dentry);
|
||||
}
|
||||
|
||||
/*
|
||||
* destroys a desktop_icon_t structure and anything that was held there,
|
||||
* including the desktop widget.
|
||||
*/
|
||||
static void
|
||||
desktop_release_desktop_icon_t (desktop_icon_t *di)
|
||||
{
|
||||
if (di->dentry){
|
||||
gnome_desktop_entry_free (di->dentry);
|
||||
} else {
|
||||
free (di->pathname);
|
||||
di->pathname = 0;
|
||||
}
|
||||
|
||||
if (di->widget){
|
||||
gtk_widget_destroy (di->widget);
|
||||
di->widget = 0;
|
||||
}
|
||||
free (di);
|
||||
}
|
||||
|
||||
static void
|
||||
start_icon_drag (GtkWidget *wi, GdkEventMotion *event)
|
||||
{
|
||||
|
@ -549,17 +489,17 @@ desktop_icon_drag_start (GtkWidget *widget, GdkEvent *event, desktop_icon_t *di)
|
|||
|
||||
/* This should not happen, as the drag end routine should destroy those widgets */
|
||||
destroy_shaped_dnd_windows ();
|
||||
|
||||
|
||||
if (di->dentry)
|
||||
fname = strdup (di->dentry->icon);
|
||||
else
|
||||
fname = get_desktop_icon (di->pathname);
|
||||
|
||||
|
||||
if (fname){
|
||||
/* FIXME: we are using the same icon for ok and not ok drags */
|
||||
root_drag_ok_window = make_transparent_window (fname);
|
||||
root_drag_not_ok_window = make_transparent_window (fname);
|
||||
|
||||
|
||||
gdk_dnd_set_drag_shape (root_drag_ok_window->window, &root_icon_drag_hotspot,
|
||||
root_drag_not_ok_window->window, &root_icon_drag_hotspot);
|
||||
gtk_widget_show (root_drag_not_ok_window);
|
||||
|
@ -594,6 +534,27 @@ desktop_icon_make_draggable (desktop_icon_t *di)
|
|||
gtk_signal_connect (obj, "drag_end_event", GTK_SIGNAL_FUNC (desktop_icon_drag_end), di);
|
||||
}
|
||||
|
||||
/*
|
||||
* destroys a desktop_icon_t structure and anything that was held there,
|
||||
* including the desktop widget.
|
||||
*/
|
||||
static void
|
||||
desktop_release_desktop_icon_t (desktop_icon_t *di)
|
||||
{
|
||||
if (di->dentry){
|
||||
gnome_desktop_entry_free (di->dentry);
|
||||
} else {
|
||||
free (di->pathname);
|
||||
di->pathname = 0;
|
||||
}
|
||||
|
||||
if (di->widget){
|
||||
gtk_widget_destroy (di->widget);
|
||||
di->widget = 0;
|
||||
}
|
||||
free (di);
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes an icon from the desktop and kills the ~/desktop file associated with it
|
||||
*/
|
||||
|
@ -613,6 +574,112 @@ icon_delete (GtkWidget *widget, desktop_icon_t *di)
|
|||
desktop_icon_remove (di);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
my_create_transparent_text_window (char *file, char *text)
|
||||
{
|
||||
GtkWidget *w;
|
||||
int events = GDK_BUTTON_PRESS_MASK | GDK_BUTTON1_MOTION_MASK;
|
||||
|
||||
w = create_transparent_text_window (file, text, events);
|
||||
if (!w){
|
||||
static char *default_pix;
|
||||
|
||||
if (!default_pix){
|
||||
default_pix = gnome_unconditional_pixmap_file ("launcher-program.xpm");
|
||||
}
|
||||
w = create_transparent_text_window (default_pix, text, events);
|
||||
if (!w)
|
||||
return NULL;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_transparent_window_for_dentry (GnomeDesktopEntry *dentry)
|
||||
{
|
||||
GtkWidget *window;
|
||||
char *icon_label;
|
||||
|
||||
icon_label = dentry->name ? dentry->name : x_basename (dentry->exec);
|
||||
|
||||
if (dentry->icon)
|
||||
window = my_create_transparent_text_window (dentry->icon, icon_label);
|
||||
else {
|
||||
static char *default_icon_path;
|
||||
static char exists;
|
||||
|
||||
if (!default_icon_path) {
|
||||
default_icon_path = gnome_unconditional_pixmap_file ("launcher-program.xpm");
|
||||
if (g_file_exists (default_icon_path))
|
||||
exists = 1;
|
||||
}
|
||||
|
||||
if (exists)
|
||||
window = my_create_transparent_text_window (default_icon_path, icon_label);
|
||||
else {
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_usize (window, 20, 20);
|
||||
}
|
||||
}
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
static int
|
||||
dentry_button_click (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di)
|
||||
{
|
||||
if (event->type == GDK_2BUTTON_PRESS && event->button == 1){
|
||||
dentry_execute (di);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (event->type == GDK_BUTTON_PRESS && event->button == 3){
|
||||
desktop_icon_context_popup (event, di);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *drop_types [] = {
|
||||
"text/plain",
|
||||
"url:ALL",
|
||||
};
|
||||
|
||||
static void
|
||||
post_setup_desktop_icon (desktop_icon_t *di)
|
||||
{
|
||||
desktop_icon_set_position (di);
|
||||
desktop_icon_make_draggable (di);
|
||||
|
||||
/* Setup the widget to make it useful: */
|
||||
|
||||
/* 1. Drag and drop functionality */
|
||||
connect_drop_signals (di->widget, di);
|
||||
gtk_widget_dnd_drop_set (di->widget, TRUE, drop_types, ELEMENTS (drop_types), FALSE);
|
||||
|
||||
/* 2. Double clicking executes the command */
|
||||
gtk_signal_connect (GTK_OBJECT (di->widget), "button_press_event", GTK_SIGNAL_FUNC (dentry_button_click), di);
|
||||
|
||||
gtk_widget_show (di->widget);
|
||||
}
|
||||
|
||||
/* Pops up the icon properties pages */
|
||||
static void
|
||||
icon_properties (GtkWidget *widget, desktop_icon_t *di)
|
||||
{
|
||||
int retval;
|
||||
|
||||
retval = item_properties (di->widget, di->pathname, di);
|
||||
|
||||
if (retval & GPROP_ICON) {
|
||||
gtk_widget_destroy (di->widget);
|
||||
|
||||
di->widget = get_transparent_window_for_dentry (di->dentry);
|
||||
|
||||
post_setup_desktop_icon (di);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Activates the context sensitive menu for this icon
|
||||
*/
|
||||
|
@ -641,101 +708,30 @@ desktop_icon_context_popup (GdkEventButton *event, desktop_icon_t *di)
|
|||
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, 0, NULL, 3, event->time);
|
||||
}
|
||||
|
||||
static int
|
||||
dentry_button_click (GtkWidget *widget, GdkEventButton *event, desktop_icon_t *di)
|
||||
{
|
||||
if (event->type == GDK_2BUTTON_PRESS && event->button == 1){
|
||||
dentry_execute (di);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (event->type == GDK_BUTTON_PRESS && event->button == 3){
|
||||
desktop_icon_context_popup (event, di);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
char *drop_types [] = {
|
||||
"text/plain",
|
||||
"url:ALL",
|
||||
};
|
||||
|
||||
char *root_drop_types [] = {
|
||||
"icon/root",
|
||||
"url:ALL"
|
||||
};
|
||||
|
||||
GtkWidget *
|
||||
my_create_transparent_text_window (char *file, char *text)
|
||||
{
|
||||
GtkWidget *w;
|
||||
int events = GDK_BUTTON_PRESS_MASK | GDK_BUTTON1_MOTION_MASK;
|
||||
|
||||
w = create_transparent_text_window (file, text, events);
|
||||
if (!w){
|
||||
static char *default_pix;
|
||||
|
||||
if (!default_pix){
|
||||
default_pix = gnome_unconditional_pixmap_file ("launcher-program.xpm");
|
||||
}
|
||||
w = create_transparent_text_window (default_pix, text, events);
|
||||
if (!w)
|
||||
return NULL;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
static void
|
||||
desktop_load_from_dentry (GnomeDesktopEntry *dentry)
|
||||
{
|
||||
desktop_icon_t *di;
|
||||
GtkWidget *window;
|
||||
char *icon_label;
|
||||
desktop_icon_t *di;
|
||||
|
||||
icon_label = dentry->name ? dentry->name : x_basename (dentry->exec);
|
||||
if (dentry->icon)
|
||||
window = my_create_transparent_text_window (dentry->icon, icon_label);
|
||||
else {
|
||||
static char *default_icon_path;
|
||||
static char exists;
|
||||
|
||||
if (!default_icon_path){
|
||||
default_icon_path = gnome_unconditional_pixmap_file ("launcher-program.xpm");
|
||||
if (g_file_exists (default_icon_path))
|
||||
exists = 1;
|
||||
}
|
||||
window = get_transparent_window_for_dentry (dentry);
|
||||
|
||||
if (exists)
|
||||
window = my_create_transparent_text_window (default_icon_path, icon_label);
|
||||
else {
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_usize (window, 20, 20);
|
||||
}
|
||||
}
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
|
||||
di = xmalloc (sizeof (desktop_icon_t), "desktop_load_entry");
|
||||
di->dentry = dentry;
|
||||
di->widget = window;
|
||||
di->pathname = dentry->location;
|
||||
|
||||
desktop_icon_set_position (di);
|
||||
desktop_icon_make_draggable (di);
|
||||
|
||||
desktop_icons = g_list_prepend (desktop_icons, (gpointer) di);
|
||||
|
||||
/* Setup the widget to make it useful: */
|
||||
|
||||
/* 1. Drag and drop functionality */
|
||||
connect_drop_signals (window, di);
|
||||
gtk_widget_dnd_drop_set (window, TRUE, drop_types, ELEMENTS (drop_types), FALSE);
|
||||
|
||||
/* 2. Double clicking executes the command */
|
||||
gtk_signal_connect (GTK_OBJECT (window), "button_press_event", GTK_SIGNAL_FUNC (dentry_button_click), di);
|
||||
desktop_icons = g_list_prepend (desktop_icons, di);
|
||||
|
||||
gtk_widget_show (window);
|
||||
post_setup_desktop_icon (di);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -975,7 +971,6 @@ desktop_reload (char *desktop_dir)
|
|||
{
|
||||
struct dirent *dent;
|
||||
DIR *dir;
|
||||
GnomeDesktopEntry *entry;
|
||||
|
||||
dir = mc_opendir (desktop_dir);
|
||||
if (dir == NULL){
|
||||
|
|
|
@ -1,5 +1,37 @@
|
|||
#ifndef _GDESKTOP_H
|
||||
#define _GDESKTOP_H
|
||||
|
||||
#define MC_LIB_DESKTOP "mc.desktop"
|
||||
|
||||
|
||||
/* Types of desktop icons:
|
||||
*
|
||||
* o Application: Double click: start up application;
|
||||
* Dropping: start up program with arguments.
|
||||
*
|
||||
* o Directory: Double click: opens the directory in a panel.
|
||||
* Double click: copies/moves files.
|
||||
*
|
||||
* o File: Opens the application according to regex_command
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
application,
|
||||
directory,
|
||||
file
|
||||
} icon_t;
|
||||
|
||||
/* A structure that describes each icon on the desktop */
|
||||
typedef struct {
|
||||
GnomeDesktopEntry *dentry;
|
||||
GtkWidget *widget;
|
||||
icon_t type;
|
||||
int x, y;
|
||||
char *title;
|
||||
char *pathname;
|
||||
} desktop_icon_t;
|
||||
|
||||
|
||||
/* gtrans.c */
|
||||
GtkWidget *create_transparent_text_window (char *file, char *text, int extra_events);
|
||||
GtkWidget *make_transparent_window (char *file);
|
||||
|
@ -7,3 +39,5 @@ GtkWidget *make_transparent_window (char *file);
|
|||
/* gdesktop.c */
|
||||
void drop_on_directory (GdkEventDropDataAvailable *event, char *dest, int force_manually);
|
||||
void artificial_drag_start (GdkWindow *source_window, int x, int y);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* GNU Midnight Commander -- GNOME edition
|
||||
*
|
||||
* Properties for the thing.
|
||||
* Properties dialog for files and desktop icons.
|
||||
*
|
||||
* Copyright (C) 1997 The Free Software Foundation
|
||||
*
|
||||
|
@ -18,7 +18,9 @@
|
|||
#include "x.h"
|
||||
#include "gprop.h"
|
||||
#include "util.h"
|
||||
#include "dialog.h"
|
||||
#include "file.h"
|
||||
#include "../vfs/vfs.h"
|
||||
#include "gpageprop.h"
|
||||
|
||||
static int prop_dialog_result;
|
||||
|
@ -43,23 +45,34 @@ kill_toplevel ()
|
|||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
void
|
||||
item_properties (char *fname, GnomeDesktopEntry *dentry)
|
||||
int
|
||||
item_properties (GtkWidget *parent, char *fname, desktop_icon_t *di)
|
||||
{
|
||||
GtkWidget *parent_window;
|
||||
GdkCursor *clock_cursor;
|
||||
GtkWidget *notebook, *ok, *cancel;
|
||||
GpropPerm *perm;
|
||||
GtkWidget *vbox;
|
||||
GpropGeneral *gene;
|
||||
GpropDir *dir;
|
||||
GpropPerm *perm;
|
||||
GpropIcon *icon;
|
||||
GtkDialog *toplevel;
|
||||
|
||||
umode_t new_mode;
|
||||
|
||||
umode_t new_mode;
|
||||
char *new_group;
|
||||
char *new_owner;
|
||||
char *new_name;
|
||||
char *new_icon;
|
||||
char *base;
|
||||
|
||||
|
||||
struct stat s;
|
||||
|
||||
int retval = 0;
|
||||
|
||||
/* Set a clock cursor while we create stuff and read users/groups */
|
||||
|
||||
parent_window = gtk_widget_get_toplevel (parent);
|
||||
clock_cursor = gdk_cursor_new (GDK_WATCH);
|
||||
gdk_window_set_cursor (parent_window->window, clock_cursor);
|
||||
|
||||
toplevel = GTK_DIALOG (gtk_dialog_new ());
|
||||
notebook = gtk_notebook_new ();
|
||||
gtk_box_pack_start_defaults (GTK_BOX (toplevel->vbox), notebook);
|
||||
|
@ -68,48 +81,64 @@ item_properties (char *fname, GnomeDesktopEntry *dentry)
|
|||
/* Create the property widgets */
|
||||
mc_stat (fname, &s);
|
||||
base = x_basename (fname);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 6);
|
||||
gene = gprop_general_new (fname, base);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), gene->top, FALSE, FALSE, 0);
|
||||
|
||||
perm = gprop_perm_new (s.st_mode, get_owner (s.st_uid), get_group (s.st_gid));
|
||||
|
||||
if (di && di->dentry) {
|
||||
icon = gprop_icon_new (di->dentry->icon);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), icon->top, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
/* Pack them into nice notebook */
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), c_spacing (gene->top), gtk_label_new ("Name"));
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), c_spacing (vbox), gtk_label_new ("General"));
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), c_spacing (perm->top), gtk_label_new ("Permissions"));
|
||||
|
||||
/* Ok, Cancel */
|
||||
ok = gnome_stock_button (GNOME_STOCK_BUTTON_OK);
|
||||
GTK_WIDGET_SET_FLAGS (ok, GTK_CAN_DEFAULT);
|
||||
gtk_widget_grab_default (ok);
|
||||
|
||||
|
||||
cancel = gnome_stock_button (GNOME_STOCK_BUTTON_CANCEL);
|
||||
GTK_WIDGET_SET_FLAGS (cancel, GTK_CAN_DEFAULT);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (toplevel->action_area), ok, 0, 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (toplevel->action_area), cancel, 0, 0, 0);
|
||||
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (ok), "clicked", GTK_SIGNAL_FUNC (properties_button_click), (gpointer) 0);
|
||||
gtk_signal_connect (GTK_OBJECT (cancel), "clicked", GTK_SIGNAL_FUNC (properties_button_click), (gpointer) 1);
|
||||
gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event", GTK_SIGNAL_FUNC (kill_toplevel), toplevel);
|
||||
|
||||
|
||||
/* Start the dialog box */
|
||||
prop_dialog_result = -1;
|
||||
|
||||
|
||||
gtk_widget_grab_default (ok);
|
||||
gtk_widget_show_all (GTK_WIDGET (toplevel));
|
||||
|
||||
gdk_window_set_cursor (parent_window->window, NULL);
|
||||
gtk_grab_add (GTK_WIDGET (toplevel));
|
||||
gtk_main ();
|
||||
gtk_grab_remove (GTK_WIDGET (toplevel));
|
||||
gdk_cursor_destroy (clock_cursor);
|
||||
|
||||
if (prop_dialog_result != 0){
|
||||
if (prop_dialog_result != 0) {
|
||||
gtk_widget_destroy (GTK_WIDGET (toplevel));
|
||||
return;
|
||||
return 0; /* nothing changed */
|
||||
}
|
||||
|
||||
/* Extract values */
|
||||
/* Check and change permissions */
|
||||
|
||||
gprop_perm_get_data (perm, &new_mode, &new_owner, &new_group);
|
||||
|
||||
if (new_mode != s.st_mode)
|
||||
if (new_mode != s.st_mode) {
|
||||
mc_chmod (fname, new_mode);
|
||||
|
||||
retval |= GPROP_MODE;
|
||||
}
|
||||
|
||||
if ((strcmp (new_owner, get_owner (s.st_uid)) != 0) ||
|
||||
(strcmp (new_group, get_group (s.st_gid)) != 0)){
|
||||
(strcmp (new_group, get_group (s.st_gid)) != 0)) {
|
||||
struct passwd *p;
|
||||
struct group *g;
|
||||
uid_t uid;
|
||||
|
@ -117,9 +146,9 @@ item_properties (char *fname, GnomeDesktopEntry *dentry)
|
|||
|
||||
/* Get uid */
|
||||
p = getpwnam (new_owner);
|
||||
if (!p){
|
||||
if (!p) {
|
||||
uid = atoi (new_owner);
|
||||
if (uid == 0){
|
||||
if (uid == 0) {
|
||||
int v;
|
||||
v = query_dialog ("Warning",
|
||||
"You entered an invalid user name, should I use `root'?",
|
||||
|
@ -132,32 +161,35 @@ item_properties (char *fname, GnomeDesktopEntry *dentry)
|
|||
|
||||
/* get gid */
|
||||
g = getgrnam (new_group);
|
||||
if (!g){
|
||||
if (!g) {
|
||||
gid = atoi (new_group);
|
||||
if (gid == 0){
|
||||
if (gid == 0) {
|
||||
message (1, "Error", "You entered an invalid group name");
|
||||
goto ciao2;
|
||||
}
|
||||
} else
|
||||
gid = g->gr_gid;
|
||||
|
||||
|
||||
mc_chown (fname, uid, gid);
|
||||
|
||||
retval |= GPROP_UID | GPROP_GID;
|
||||
|
||||
ciao2:
|
||||
endgrent ();
|
||||
ciao:
|
||||
endpwent ();
|
||||
}
|
||||
|
||||
/* Check and change filename */
|
||||
|
||||
gprop_general_get_data (gene, &new_name);
|
||||
if (strchr (new_name, '/')){
|
||||
|
||||
if (strchr (new_name, '/'))
|
||||
message (1, "Error", "The new name includes the `/' character");
|
||||
} else if (strcmp (new_name, base) != 0){
|
||||
else if (strcmp (new_name, base) != 0) {
|
||||
char *base = x_basename (fname);
|
||||
char save = *base;
|
||||
char *full_target;
|
||||
|
||||
|
||||
*base = 0;
|
||||
full_target = concat_dir_and_file (base, new_name);
|
||||
*base = save;
|
||||
|
@ -166,13 +198,30 @@ item_properties (char *fname, GnomeDesktopEntry *dentry)
|
|||
file_mask_defaults ();
|
||||
move_file_file (fname, full_target);
|
||||
destroy_op_win ();
|
||||
|
||||
if (di) {
|
||||
free (di->pathname);
|
||||
di->pathname = full_target;
|
||||
} else
|
||||
free (full_target);
|
||||
|
||||
free (full_target);
|
||||
retval |= GPROP_FILENAME;
|
||||
}
|
||||
|
||||
/* Check and change icon -- change is handled by caller */
|
||||
|
||||
if (di && di->dentry) {
|
||||
gprop_icon_get_data (icon, &new_icon);
|
||||
|
||||
if (strcmp (new_icon, di->dentry->icon) != 0) {
|
||||
g_free (di->dentry->icon);
|
||||
|
||||
di->dentry->icon = new_icon;
|
||||
retval |= GPROP_ICON;
|
||||
}
|
||||
}
|
||||
|
||||
/* Here quartic, you have to add the .desktop handling code */
|
||||
|
||||
gtk_widget_destroy (GTK_WIDGET (toplevel));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,33 @@
|
|||
/* GNU Midnight Commander -- GNOME edition
|
||||
*
|
||||
* Properties dialog for files and desktop icons.
|
||||
*
|
||||
* Copyright (C) 1997 The Free Software Foundation
|
||||
*
|
||||
* Authors: Miguel de Icaza
|
||||
* Federico Mena
|
||||
*/
|
||||
|
||||
#ifndef _GPAGEPROP_H
|
||||
#define _GPAGEPROP_H
|
||||
|
||||
void item_properties (char *fname, GnomeDesktopEntry *dentry);
|
||||
|
||||
|
||||
#include <gnome.h>
|
||||
#include "gdesktop.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
GPROP_FILENAME = 1 << 0,
|
||||
GPROP_MODE = 1 << 1,
|
||||
GPROP_UID = 1 << 2,
|
||||
GPROP_GID = 1 << 3,
|
||||
GPROP_ICON = 1 << 4
|
||||
} GpropChanged;
|
||||
|
||||
/* Returns a mask of the above specifying what changed.
|
||||
*/
|
||||
|
||||
int item_properties (GtkWidget *parent, char *fname, desktop_icon_t *di);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,13 @@ label_new (char *text, double xalign, double yalign)
|
|||
return label;
|
||||
}
|
||||
|
||||
static void
|
||||
free_stuff (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
if (data)
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
/***** General *****/
|
||||
|
||||
GpropGeneral *
|
||||
|
@ -40,6 +47,9 @@ gprop_general_new (char *complete_filename, char *filename)
|
|||
gpg = g_new (GpropGeneral, 1);
|
||||
|
||||
gpg->top = gtk_vbox_new (FALSE, 6);
|
||||
gtk_signal_connect (GTK_OBJECT (gpg->top), "destroy",
|
||||
(GtkSignalFunc) free_stuff,
|
||||
gpg);
|
||||
|
||||
frame = gtk_frame_new ("Name");
|
||||
gtk_box_pack_start (GTK_BOX (gpg->top), frame, FALSE, FALSE, 0);
|
||||
|
@ -365,6 +375,9 @@ gprop_perm_new (umode_t umode, char *owner, char *group)
|
|||
gpp = g_new (GpropPerm, 1);
|
||||
|
||||
gpp->top = gtk_vbox_new (FALSE, 6);
|
||||
gtk_signal_connect (GTK_OBJECT (gpp->top), "destroy",
|
||||
(GtkSignalFunc) free_stuff,
|
||||
gpp);
|
||||
|
||||
w = perm_mode_new (gpp, umode);
|
||||
gtk_box_pack_start (GTK_BOX (gpp->top), w, FALSE, FALSE, 0);
|
||||
|
@ -392,22 +405,25 @@ gprop_perm_get_data (GpropPerm *gpp, umode_t *umode, char **owner, char **group)
|
|||
*group = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (gpp->group)))));
|
||||
}
|
||||
|
||||
/***** Directory *****/
|
||||
/***** Icon *****/
|
||||
|
||||
GpropDir *
|
||||
gprop_dir_new (char *icon_filename)
|
||||
GpropIcon *
|
||||
gprop_icon_new (char *icon_filename)
|
||||
{
|
||||
GpropDir *gpd;
|
||||
GpropIcon *gpi;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *entry;
|
||||
|
||||
gpd = g_new (GpropDir, 1);
|
||||
gpi = g_new (GpropIcon, 1);
|
||||
|
||||
gpd->top = gtk_vbox_new (FALSE, 6);
|
||||
gpi->top = gtk_vbox_new (FALSE, 6);
|
||||
gtk_signal_connect (GTK_OBJECT (gpi->top), "destroy",
|
||||
(GtkSignalFunc) free_stuff,
|
||||
gpi);
|
||||
|
||||
frame = gtk_frame_new ("Directory icon");
|
||||
gtk_box_pack_start (GTK_BOX (gpd->top), frame, FALSE, FALSE, 0);
|
||||
frame = gtk_frame_new ("Icon");
|
||||
gtk_box_pack_start (GTK_BOX (gpi->top), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 6);
|
||||
|
@ -415,23 +431,23 @@ gprop_dir_new (char *icon_filename)
|
|||
gtk_container_add(GTK_CONTAINER (frame), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
gpd->icon_filename = gnome_file_entry_new ("gprop_dir_icon_filename", "Select directory icon");
|
||||
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gpd->icon_filename));
|
||||
gpi->icon_filename = gnome_file_entry_new ("gprop_icon_filename", "Select icon");
|
||||
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gpi->icon_filename));
|
||||
gtk_entry_set_text (GTK_ENTRY (entry), icon_filename ? icon_filename : "");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), gpd->icon_filename, FALSE, FALSE, 0);
|
||||
gtk_widget_show (gpd->icon_filename);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), gpi->icon_filename, FALSE, FALSE, 0);
|
||||
gtk_widget_show (gpi->icon_filename);
|
||||
|
||||
return gpd;
|
||||
return gpi;
|
||||
}
|
||||
|
||||
void
|
||||
gprop_dir_get_data (GpropDir *gpd, char **icon_filename)
|
||||
gprop_icon_get_data (GpropIcon *gpi, char **icon_filename)
|
||||
{
|
||||
GtkWidget *entry;
|
||||
|
||||
g_return_if_fail (gpd != NULL);
|
||||
g_return_if_fail (gpi != NULL);
|
||||
|
||||
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gpd->icon_filename));
|
||||
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gpi->icon_filename));
|
||||
|
||||
if (icon_filename)
|
||||
*icon_filename = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
|
||||
|
|
|
@ -44,15 +44,15 @@ typedef struct {
|
|||
GpropPerm *gprop_perm_new (umode_t umode, char *owner, char *group);
|
||||
void gprop_perm_get_data (GpropPerm *gpp, umode_t *umode, char **owner, char **group);
|
||||
|
||||
/***** Directory *****/
|
||||
/***** Icon *****/
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *top;
|
||||
|
||||
GtkWidget *icon_filename;
|
||||
} GpropDir;
|
||||
} GpropIcon;
|
||||
|
||||
GpropDir *gprop_dir_new (char *icon_filename);
|
||||
void gprop_dir_get_data (GpropDir *gpd, char **icon_filename);
|
||||
GpropIcon *gprop_icon_new (char *icon_filename);
|
||||
void gprop_icon_get_data (GpropIcon *gpi, char **icon_filename);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -317,8 +317,8 @@ panel_action_properties (GtkWidget *widget, WPanel *panel)
|
|||
file_entry *fe = &panel->dir.list [panel->selected];
|
||||
char *full_name = concat_dir_and_file (panel->cwd, fe->fname);
|
||||
|
||||
item_properties (full_name, NULL);
|
||||
reread_cmd ();
|
||||
if (item_properties (GTK_WIDGET (panel->list), full_name, NULL) != 0)
|
||||
reread_cmd ();
|
||||
|
||||
free (full_name);
|
||||
}
|
||||
|
@ -967,10 +967,12 @@ static GtkWidget *filter_menu;
|
|||
static void
|
||||
filter_item_select (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
/* FIXME: the hintbar resizes horribly and screws the panel */
|
||||
#if 0
|
||||
struct filter_item *fi = gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
|
||||
/* FIXME: the hintbar resizes horribly and screws the panel */
|
||||
/* set_hintbar (easy_patterns ? fi->glob : fi->regexp); */
|
||||
set_hintbar (easy_patterns ? fi->glob : fi->regexp);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -984,7 +986,6 @@ filter_item_activate (GtkWidget *widget, gpointer data)
|
|||
{
|
||||
struct filter_item *fi = gtk_object_get_user_data (GTK_OBJECT (widget));
|
||||
WPanel *panel = data;
|
||||
int tmp;
|
||||
char *pattern;
|
||||
|
||||
if (easy_patterns)
|
||||
|
|
Loading…
Reference in New Issue