We had time, so we wrote property pages for desktop, files and children all alike -mig and federico

This commit is contained in:
Miguel de Icaza 1998-03-19 04:51:17 +00:00
parent 84013cb8d5
commit 213a417181
12 changed files with 270 additions and 38 deletions

View File

@ -1,3 +1,11 @@
Wed Mar 18 22:32:53 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gscreen.c (panel_action_properties): Make Federico's
page-properties code functional.
* gpageprop.c: New file, implements most of the page properties on
top of the gprop.c code.
Wed Mar 18 20:35:45 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gdesktop.c (desktop_create_launch_entry): Support for the "Drop"

View File

@ -30,7 +30,8 @@ GNOMESRCS = \
gview.c \
gcmd.c \
gprop.c \
gmc-chargrid.c
gmc-chargrid.c \
gpageprop.c
GNOMEHDRS = \
gmain.h \
@ -40,6 +41,7 @@ GNOMEHDRS = \
gconf.h \
gcmd.h \
gprop.h \
gpageprop.h \
gmc-chargrid.h
ICONS = \
@ -80,7 +82,8 @@ OBJS = $(LOBJS) $(OOBJS) \
gcmd.o \
gmc-chargrid.o \
gview.o \
gprop.o
gprop.o \
gpageprop.o
#
# Distribution variables

View File

@ -464,8 +464,7 @@ dentry_properties (desktop_icon_t *di)
static void
icon_properties (GtkWidget *widget, desktop_icon_t *di)
{
printf ("Sorry, no property pages yet\n");
gtk_main_quit ();
item_properties (di->pathname, di->dentry);
}
/*
@ -612,7 +611,6 @@ static void
icon_delete (GtkWidget *widget, desktop_icon_t *di)
{
desktop_icon_remove (di);
gtk_main_quit ();
}
/*
@ -638,11 +636,9 @@ desktop_icon_context_popup (GdkEventButton *event, desktop_icon_t *di)
gtk_widget_set_uposition (menu, event->x, event->y);
gtk_grab_add (menu);
gtk_signal_connect (GTK_OBJECT (menu), "deactivate", GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, 0, NULL, 3, event->time);
gtk_main ();
gtk_grab_remove (menu);
gtk_widget_destroy (menu);
}
static int

View File

@ -219,7 +219,7 @@ x_add_widget (Dlg_head *h, Widget_Item *w)
}
static int
gnome_dlg_send_destroy (GtkWidget *widget, Dlg_head *h)
gnome_dlg_send_destroy (GtkWidget *widget, GdkEvent *event, Dlg_head *h)
{
printf ("destruyendo\n");
h->ret_value = B_CANCEL;

View File

@ -1,13 +1,34 @@
- Drop targets on the desktop.
- Sync the screen panels with the real panels
- Use containers instead of WPanels as the toplevel window displayed
- widgets event forwarding in WInputs and WPanels.
- Split view.
- Menu organization
All:
- Intenrationalization
- All of the dialogs.
- It crashes
- It leaks objects.
- It does not object to leaks.
Possibly make a way to bind a toplevel widget to the Dlg_head part of the
system so that grab_add/ungrab and the widget destruction reuse all of that
code for NON_TED dialogs.
Desktop:
- Add special destkop entries ("Network neighborhood")
- Property pages do not work for desktop icons
Panels:
- Global bindings (some shortcuts are not implemented)
- Mini-info panel display
- Finish regular property pages
- Add a nifty toolbar
- Split view.
- External panelize hangs
Viewer:
- Toolbar
- Scrollbar
- Enable editor.
- Fix colors.
- Add cursor
- Debug monitor
Widgets:
- Push history
- Use Gnome File Entry where possible.
DND:
- Get sopwith to fix the random motion of his dnd icons.
- Check the purify stuff.

178
gnome/gpageprop.c Normal file
View File

@ -0,0 +1,178 @@
/* GNU Midnight Commander -- GNOME edition
*
* Properties for the thing.
*
* Copyright (C) 1997 The Free Software Foundation
*
* Authors: Miguel de Icaza
* Federico Mena
*/
#include <config.h>
#include <string.h>
#include <stdlib.h> /* atoi */
#include <pwd.h>
#include <grp.h>
#include <sys/types.h>
#include "fs.h"
#include "x.h"
#include "gprop.h"
#include "util.h"
#include "file.h"
#include "gpageprop.h"
static int prop_dialog_result;
static GtkWidget *
c_spacing (GtkWidget *widget)
{
gtk_container_border_width (GTK_CONTAINER (widget), 6);
return widget;
}
static void
properties_button_click (GtkWidget *widget, gpointer value)
{
prop_dialog_result = (int) value;
gtk_main_quit ();
}
static void
kill_toplevel ()
{
gtk_main_quit ();
}
void
item_properties (char *fname, GnomeDesktopEntry *dentry)
{
GtkWidget *notebook, *ok, *cancel;
GpropPerm *perm;
GpropGeneral *gene;
GpropDir *dir;
GtkDialog *toplevel;
umode_t new_mode;
char *new_group;
char *new_owner;
char *new_name;
char *base;
struct stat s;
toplevel = GTK_DIALOG (gtk_dialog_new ());
notebook = gtk_notebook_new ();
gtk_box_pack_start_defaults (GTK_BOX (toplevel->vbox), notebook);
gtk_window_set_title (GTK_WINDOW (toplevel), fname);
/* Create the property widgets */
mc_stat (fname, &s);
base = x_basename (fname);
gene = gprop_general_new (fname, base);
perm = gprop_perm_new (s.st_mode, get_owner (s.st_uid), get_group (s.st_gid));
/* 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 (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_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_show_all (GTK_WIDGET (toplevel));
gtk_grab_add (GTK_WIDGET (toplevel));
gtk_main ();
gtk_grab_remove (GTK_WIDGET (toplevel));
if (prop_dialog_result != 0){
gtk_widget_destroy (GTK_WIDGET (toplevel));
return;
}
/* Extract values */
gprop_perm_get_data (perm, &new_mode, &new_owner, &new_group);
if (new_mode != s.st_mode)
mc_chmod (fname, new_mode);
if ((strcmp (new_owner, get_owner (s.st_uid)) != 0) ||
(strcmp (new_group, get_group (s.st_gid)) != 0)){
struct passwd *p;
struct group *g;
uid_t uid;
gid_t gid;
/* Get uid */
p = getpwnam (new_owner);
if (!p){
uid = atoi (new_owner);
if (uid == 0){
int v;
v = query_dialog ("Warning",
"You entered an invalid user name, should I use `root'?",
0, 2, "Yes", "No");
if (v != 0)
goto ciao;
}
} else
uid = p->pw_uid;
/* get gid */
g = getgrnam (new_group);
if (!g){
gid = atoi (new_group);
if (gid == 0){
message (1, "Error", "You entered an invalid group name");
goto ciao2;
}
} else
gid = g->gr_gid;
mc_chown (fname, uid, gid);
ciao2:
endgrent ();
ciao:
endpwent ();
}
gprop_general_get_data (gene, &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;
*base = 0;
full_target = concat_dir_and_file (base, new_name);
*base = save;
create_op_win (OP_MOVE, 0);
file_mask_defaults ();
move_file_file (fname, full_target);
destroy_op_win ();
free (full_target);
}
/* Here quartic, you have to add the .desktop handling code */
gtk_widget_destroy (GTK_WIDGET (toplevel));
}

6
gnome/gpageprop.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef _GPAGEPROP_H
#define _GPAGEPROP_H
void item_properties (char *fname, GnomeDesktopEntry *dentry);
#endif

View File

@ -260,7 +260,7 @@ perm_owner_new (char *owner)
if (strcmp (passwd->pw_name, owner) == 0)
sel = i;
}
endpwent ();
gtk_list_select_item (GTK_LIST (list), sel);
entry = gnome_entry_gtk_entry (GNOME_ENTRY (gentry));
@ -295,7 +295,8 @@ perm_group_new (char *group)
if (strcmp (grp->gr_name, group) == 0)
sel = i;
}
endgrent ();
gtk_list_select_item (GTK_LIST (list), sel);
entry = gnome_entry_gtk_entry (GNOME_ENTRY (gentry));

View File

@ -28,7 +28,7 @@
#include "dir.h"
#include "dialog.h"
#include "gdesktop.h"
#include "gprop.h"
#include "gpageprop.h"
/* The pixmaps */
#include "directory.xpm"
@ -311,23 +311,33 @@ panel_action_view_unfiltered (GtkWidget *widget, WPanel *panel)
view_simple_cmd (panel);
}
void
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 ();
free (full_name);
}
static struct {
char *text;
int flags;
context_menu_callback callback;
} file_actions [] = {
#if 0
{ "Info", 0, NULL },
{ "", 0, NULL },
#endif
{ "Open", F_ALL, panel_action_open },
{ "Open with", F_ALL, panel_action_open_with },
{ "View", F_ALL, panel_action_view },
{ "View unfiltered", F_ALL, panel_action_view_unfiltered },
{ "", 0, NULL },
{ "Properties", F_SINGLE, panel_action_properties },
{ "", F_SINGLE, NULL },
{ "Open", F_ALL, panel_action_open },
{ "Open with", F_ALL, panel_action_open_with },
{ "View", F_ALL, panel_action_view },
{ "View unfiltered", F_ALL, panel_action_view_unfiltered },
{ "", 0, NULL },
{ "Link...", F_REGULAR | F_SINGLE, (context_menu_callback) link_cmd },
{ "Symlink...", F_SINGLE, (context_menu_callback) symlink_cmd },
{ "Edit symlink...", F_SYMLINK, (context_menu_callback) edit_symlink_cmd },
{ "Symlink...", F_SINGLE, (context_menu_callback) symlink_cmd },
{ "Edit symlink...", F_SYMLINK, (context_menu_callback) edit_symlink_cmd },
{ NULL, 0, NULL },
};

View File

@ -1,3 +1,9 @@
Wed Mar 18 22:08:34 1998 Miguel de Icaza <miguel@nuclecu.unam.mx>
* achown.c (do_enter_key): call endgrent, endpwent.
* chown.c (init_chown): call endgrent, endpwent.
Tue Mar 17 23:58:40 1998 Pavel Machek <pavel@elf.ucw.cz>
* src/file.c: Fix for the case where the disk gets full.

View File

@ -278,7 +278,7 @@ static void do_enter_key (Dlg_head *h, int f_pos)
setpwent ();
while ((chl_pass = getpwent ()))
listbox_add_item (chl_list, 0, 0, chl_pass->pw_name, NULL);
endpwent ();
fe = listbox_search_text (chl_list, get_owner (sf_stat->st_uid));
}
else
@ -288,6 +288,7 @@ static void do_enter_key (Dlg_head *h, int f_pos)
while ((chl_grp = getgrent ())) {
listbox_add_item (chl_list, 0, 0, chl_grp->gr_name, NULL);
}
endgrent ();
fe = listbox_search_text (chl_list, get_group (sf_stat->st_gid));
}

View File

@ -195,12 +195,14 @@ static void init_chown (void)
while ((l_pass = getpwent ())) {
listbox_add_item (l_user, 0, 0, l_pass->pw_name, NULL);
}
endpwent ();
setgrent (); /* get and put group names in the listbox */
while ((l_grp = getgrent ())) {
listbox_add_item (l_group, 0, 0, l_grp->gr_name, NULL);
}
endgrent ();
tk_new_frame (ch_dlg, "f.");
add_widget (ch_dlg, l_group);
tk_new_frame (ch_dlg, "g.");