well, it does 'open' and 'properties' on the desktop icons, SLIGHTLY.

gmc is a big piece of junk.
This commit is contained in:
Elliot Lee 1998-12-21 23:29:46 +00:00
parent a1d41bb385
commit 913f34276e
8 changed files with 119 additions and 92 deletions

View File

@ -48,19 +48,6 @@
#define DESKTOP_DIR_NAME "desktop"
/* This structure defines the information carried by a desktop icon */
struct desktop_icon_info {
GtkWidget *dicon; /* The desktop icon widget */
int x, y; /* Position in the desktop */
int slot; /* Index of the slot the icon is in, or -1 for none */
char *filename; /* The file this icon refers to (relative to the desktop_directory) */
int selected : 1; /* Is the icon selected? */
int tmp_selected : 1; /* Temp storage for original selection while rubberbanding */
int finishing_selection : 1; /* Flag set while we are releasing
* button after selecting in the text
*/
};
struct layout_slot {
int num_icons; /* Number of icons in this slot */
GList *icons; /* The list of icons in this slot */
@ -696,7 +683,7 @@ do_popup_menu (struct desktop_icon_info *dii, GdkEventButton *event)
filename = g_concat_dir_and_file (desktop_directory, dii->filename);
if (gpopup_do_popup (event, NULL, 0, filename) != -1)
if (gpopup_do_popup (event, NULL, dii, 0, filename) != -1)
reload_desktop_icons (FALSE, 0, 0); /* bleah */
g_free (filename);

View File

@ -32,7 +32,18 @@ void desktop_init (void);
/* Shuts the desktop down by destroying the desktop icons. */
void desktop_destroy (void);
/* This structure defines the information carried by a desktop icon */
typedef struct desktop_icon_info {
GtkWidget *dicon; /* The desktop icon widget */
int x, y; /* Position in the desktop */
int slot; /* Index of the slot the icon is in, or -1 for none */
char *filename; /* The file this icon refers to (relative to the desktop_directory) */
int selected : 1; /* Is the icon selected? */
int tmp_selected : 1; /* Temp storage for original selection while rubberbanding */
int finishing_selection : 1; /* Flag set while we are releasing
* button after selecting in the text
*/
} desktop_icon_info;

View File

@ -21,6 +21,8 @@
#include "dialog.h"
#include "file.h"
#include "../vfs/vfs.h"
#include "gdesktop.h"
#include "gdesktop-icon.h"
#include "gpageprop.h"
static int prop_dialog_result;
@ -46,7 +48,7 @@ kill_toplevel ()
}
int
item_properties (GtkWidget *parent, char *fname, desktop_icon_t *di)
item_properties (GtkWidget *parent, char *fname, desktop_icon_info *di)
{
GtkWidget *parent_window;
GdkCursor *cursor;
@ -55,14 +57,12 @@ item_properties (GtkWidget *parent, char *fname, desktop_icon_t *di)
GpropFilename *name;
GpropPerm *perm;
GpropGeneral *gene;
GpropExec *exec;
GtkDialog *toplevel;
umode_t new_mode;
char *new_group;
char *new_owner;
char *new_title;
char *new_icon;
char *new_name;
char *base;
@ -87,15 +87,11 @@ item_properties (GtkWidget *parent, char *fname, desktop_icon_t *di)
vbox = gtk_vbox_new (FALSE, 6);
if (di && di->dentry) {
gene = gprop_general_new (di->dentry->name, di->dentry->icon);
gtk_box_pack_start (GTK_BOX (vbox), gene->top, FALSE, FALSE, 0);
exec = gprop_exec_new (di->dentry);
gtk_box_pack_start (GTK_BOX (vbox), exec->top, FALSE, FALSE, 0);
} else {
name = gprop_filename_new (fname, base);
gtk_box_pack_start (GTK_BOX (vbox), name->top, FALSE, FALSE, 0);
name = gprop_filename_new (fname, base);
gtk_box_pack_start (GTK_BOX (vbox), name->top, FALSE, FALSE, 0);
if(di) {
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));
@ -192,57 +188,43 @@ item_properties (GtkWidget *parent, char *fname, desktop_icon_t *di)
/* Check and change filename */
if (di && di->dentry){
gprop_exec_get_data (exec, di->dentry);
} else {
gprop_filename_get_data (name, &new_name);
gprop_filename_get_data (name, &new_name);
if (strchr (new_name, '/'))
message (1, "Error", "The new name includes the `/' character");
else if (strcmp (new_name, base) != 0) {
char *base = x_basename (fname);
char save = *base;
char *full_target;
long count = 0;
double bytes = 0;
if (strchr (new_name, '/'))
message (1, "Error", "The new name includes the `/' character");
else if (strcmp (new_name, base) != 0) {
char *base = x_basename (fname);
char save = *base;
char *full_target;
long count = 0;
double bytes = 0;
*base = 0;
full_target = concat_dir_and_file (fname, new_name);
*base = save;
*base = 0;
full_target = concat_dir_and_file (fname, new_name);
*base = save;
create_op_win (OP_MOVE, 0);
file_mask_defaults ();
move_file_file (fname, full_target, &count, &bytes);
destroy_op_win ();
create_op_win (OP_MOVE, 0);
file_mask_defaults ();
move_file_file (fname, full_target, &count, &bytes);
destroy_op_win ();
if (di) {
free (di->pathname);
di->pathname = full_target;
} else
free (full_target);
if (di) {
free (di->filename);
di->filename = full_target;
} else
free (full_target);
retval |= GPROP_FILENAME;
}
retval |= GPROP_FILENAME;
}
/* Check and change title and icon -- change is handled by caller */
if (di && di->dentry) {
gprop_general_get_data (gene, &new_title, &new_icon);
if (di) {
gprop_general_get_data (gene, &new_title, NULL);
desktop_icon_set_text(DESKTOP_ICON(di->dicon), new_title);
g_free(new_title);
if (strcmp (new_title, di->dentry->name) != 0) {
g_free (di->dentry->name);
di->dentry->name = new_title;
retval |= GPROP_TITLE;
}
if (strcmp (new_icon, di->dentry->icon) != 0) {
g_free (di->dentry->icon);
di->dentry->icon = new_icon;
retval |= GPROP_ICON;
}
retval |= GPROP_TITLE;
}
gtk_widget_destroy (GTK_WIDGET (toplevel));

View File

@ -28,7 +28,7 @@ typedef enum {
/* Returns a mask of the above specifying what changed.
*/
int item_properties (GtkWidget *parent, char *fname, desktop_icon_t *di);
int item_properties (GtkWidget *parent, char *fname, desktop_icon_info *di);
#endif

View File

@ -79,6 +79,44 @@ panel_action_edit (GtkWidget *widget, WPanel *panel)
edit_cmd (panel);
}
static void
desktop_icon_view(GtkWidget *widget, desktop_icon_info *dii)
{
g_warning("NYI");
}
/* Pops up the icon properties pages */
void
desktop_icon_properties (GtkWidget *widget, desktop_icon_info *dii)
{
int retval;
char *path;
path = g_copy_strings(getenv("HOME"), "/desktop/", dii->filename, NULL);
retval = item_properties (dii->dicon, path, dii);
g_free(path);
if(retval)
reread_cmd(); /* Lame. Slow. Works. */
}
void
desktop_icon_execute (GtkWidget *ignored, desktop_icon_info *dii)
{
char *path;
/* Ultra lame-o execute. This should be replaced by the fixed regexp_command
* invocation
*/
path = g_copy_strings(getenv("HOME"), "/desktop/", dii->filename, NULL);
if (g_file_test(path, G_FILE_TEST_ISDIR))
new_panel_at (path);
else
gnome_desktop_entry_launch (path);
g_free(path);
}
static void
panel_action_properties (GtkWidget *widget, WPanel *panel)
{
@ -92,19 +130,19 @@ panel_action_properties (GtkWidget *widget, WPanel *panel)
}
static void
dicon_move (GtkWidget *widget, char *filename)
dicon_move (GtkWidget *widget, desktop_icon_info *dii)
{
g_warning ("Implement this function!");
}
static void
dicon_copy (GtkWidget *widget, char *filename)
dicon_copy (GtkWidget *widget, desktop_icon_info *dii)
{
g_warning ("Implement this function!");
}
static void
dicon_delete (GtkWidget *widget, char *filename)
dicon_delete (GtkWidget *widget, desktop_icon_info *dii)
{
g_warning ("Implement this function!");
}
@ -177,14 +215,10 @@ fill_menu (GtkMenuShell *menu_shell, GnomeUIInfo *uiinfo, int pos)
*/
static struct action file_actions[] = {
{ N_("Properties"), F_SINGLE | F_PANEL, (GtkSignalFunc) panel_action_properties },
#if 0
{ N_("Properties"), F_SINGLE | F_DICON, (GtkSignalFunc) desktop_icon_properties },
#endif
{ "", F_SINGLE, NULL },
{ N_("Open"), F_PANEL | F_ALL, (GtkSignalFunc) panel_action_open },
#if 0
{ N_("Open"), F_DICON | F_ALL, (GtkSignalFunc) desktop_icon_execute },
#endif
{ N_("Open with"), F_PANEL | F_ALL, (GtkSignalFunc) panel_action_open_with },
{ N_("View"), F_PANEL | F_NOTDIR, (GtkSignalFunc) panel_action_view },
{ N_("View unfiltered"), F_PANEL | F_NOTDIR, (GtkSignalFunc) panel_action_view_unfiltered },
@ -221,7 +255,9 @@ static GnomeUIInfo desktop_icon_actions[] = {
* items should be inserted.
*/
static int
create_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *filename)
create_actions (GtkWidget *menu, WPanel *panel,
desktop_icon_info *dii,
int panel_row, char *filename)
{
gpointer closure;
struct action *action;
@ -231,7 +267,7 @@ create_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *filename)
GNOMEUIINFO_END
};
closure = panel ? (gpointer) panel : (gpointer) filename;
closure = panel ? (gpointer) panel : (gpointer) dii;
pos = 0;
@ -241,7 +277,7 @@ create_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *filename)
if (!panel && (action->flags & F_PANEL))
continue;
if (panel && (action->flags & F_DICON))
if (!dii && (action->flags & F_DICON))
continue;
/* Items with F_ALL bypass any other condition */
@ -367,7 +403,9 @@ mime_command_from_desktop_icon (GtkMenuItem *item, char *filename)
* regexp_command() actions.
*/
static void
create_regexp_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *filename, int insert_pos)
create_regexp_actions (GtkWidget *menu, WPanel *panel,
desktop_icon_info *dii,
int panel_row, char *filename, int insert_pos)
{
gpointer closure, regex_closure;
GnomeUIInfo *a_uiinfo;
@ -387,7 +425,7 @@ create_regexp_actions (GtkWidget *menu, WPanel *panel, int panel_row, char *file
regex_closure = filename;
} else {
a_uiinfo = desktop_icon_actions;
closure = filename;
closure = dii;
regex_callback = mime_command_from_desktop_icon;
regex_closure = filename;
}
@ -476,18 +514,23 @@ get_active_index (GtkMenu *menu)
* be set to NULL.
*/
int
gpopup_do_popup (GdkEventButton *event, WPanel *from_panel, int panel_row, char *filename)
gpopup_do_popup (GdkEventButton *event,
WPanel *from_panel,
struct desktop_icon_info *dii,
int panel_row,
char *filename)
{
GtkWidget *menu;
int pos;
guint id;
g_return_val_if_fail (event != NULL, -1);
g_return_val_if_fail (from_panel != NULL || filename != NULL, -1);
g_return_val_if_fail (from_panel != NULL || dii != NULL || filename != NULL, -1);
menu = gtk_menu_new ();
/* Connect to the deactivation signal to be able to quit our modal main loop */
/* Connect to the deactivation signal to be able to quit our
modal main loop */
id = gtk_signal_connect (GTK_OBJECT (menu), "deactivate",
(GtkSignalFunc) menu_shell_deactivated,
@ -495,8 +538,10 @@ gpopup_do_popup (GdkEventButton *event, WPanel *from_panel, int panel_row, char
/* Fill the menu */
pos = create_actions (menu, from_panel, panel_row, filename);
create_regexp_actions (menu, from_panel, panel_row, filename, pos);
pos = create_actions (menu, from_panel, dii,
panel_row, filename);
create_regexp_actions (menu, from_panel, dii,
panel_row, filename, pos);
/* Run it */

View File

@ -12,9 +12,11 @@
#include <gdk/gdktypes.h>
#include "panel.h"
#include "gdesktop.h"
int gpopup_do_popup (GdkEventButton *event, WPanel *from_panel, int panel_row, char *filename);
int gpopup_do_popup (GdkEventButton *event, WPanel *from_panel,
desktop_icon_info *dii,
int panel_row, char *filename);
#endif

View File

@ -483,7 +483,7 @@ panel_file_list_select_row (GtkWidget *file_list, int row, int column, GdkEvent
break;
case 3:
gpopup_do_popup ((GdkEventButton *) event, panel, row, panel->dir.list[row].fname);
gpopup_do_popup ((GdkEventButton *) event, panel, NULL, row, panel->dir.list[row].fname);
break;
}
@ -1133,7 +1133,7 @@ panel_icon_list_select_icon (GtkWidget *widget, int index, GdkEvent *event, WPan
if (event->button.button != 3)
return;
gpopup_do_popup ((GdkEventButton *) event, panel, index, panel->dir.list[index].fname);
gpopup_do_popup ((GdkEventButton *) event, panel, NULL, index, panel->dir.list[index].fname);
return;
case GDK_2BUTTON_PRESS:

View File

@ -249,7 +249,7 @@ static void do_view_cmd (WPanel *panel, int normal)
/* Directories are viewed by changing to them */
if (S_ISDIR (selection (panel)->buf.st_mode) ||
link_isdir (selection (panel))){
link_isdir (selection (panel))) {
if (confirm_view_dir && (panel->marked || panel->dirs_marked)){
if (query_dialog (_(" CD "), _("Files tagged, want to cd?"),
0, 2, _("&Yes"), _("&No")) == 1){