1998-03-19 04:22:32 +03:00
|
|
|
/* Properties dialog for the Gnome edition of the Midnight Commander
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998 The Free Software Foundation
|
|
|
|
*
|
|
|
|
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
1998-05-20 10:49:08 +04:00
|
|
|
*
|
|
|
|
* Known bug: the problem with the multiple entries in the Properties
|
|
|
|
* is a problem with the hisotry code.
|
1998-03-19 04:22:32 +03:00
|
|
|
*/
|
|
|
|
|
1998-03-19 05:32:03 +03:00
|
|
|
#include <grp.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <sys/types.h>
|
1998-03-19 04:22:32 +03:00
|
|
|
#include <gnome.h>
|
|
|
|
#include "gprop.h"
|
|
|
|
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
label_new (char *text, double xalign, double yalign)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
label = gtk_label_new (text);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
|
|
|
|
gtk_widget_show (label);
|
1998-05-20 09:49:16 +04:00
|
|
|
|
1998-03-19 04:22:32 +03:00
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
1998-03-20 05:00:09 +03:00
|
|
|
static void
|
|
|
|
free_stuff (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
if (data)
|
|
|
|
g_free (data);
|
|
|
|
}
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
/***** Filename *****/
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
GpropFilename *
|
1999-02-25 07:08:43 +03:00
|
|
|
gprop_filename_new (const char *complete_filename, const char *filename)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
1998-03-21 02:38:43 +03:00
|
|
|
GpropFilename *gp;
|
1998-03-19 04:22:32 +03:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
g_return_val_if_fail (complete_filename != NULL, NULL);
|
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp = g_new (GpropFilename, 1);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp->top = gtk_vbox_new (FALSE, 6);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gp->top), "destroy",
|
1998-03-20 05:00:09 +03:00
|
|
|
(GtkSignalFunc) free_stuff,
|
1998-03-21 02:38:43 +03:00
|
|
|
gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
frame = gtk_frame_new (_("Filename"));
|
1998-03-21 02:38:43 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (gp->top), frame, FALSE, FALSE, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 6);
|
1998-12-01 08:13:40 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
1998-12-30 23:29:12 +03:00
|
|
|
s = g_strconcat (_("Full name: "), complete_filename, NULL);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label_new (s, 0.0, 0.5), FALSE, FALSE, 0);
|
|
|
|
g_free (s);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label_new (_("Filename"), 0.0, 0.5), FALSE, FALSE, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-05-20 10:49:08 +04:00
|
|
|
gp->filename = gnome_entry_new (NULL);
|
1998-03-21 02:38:43 +03:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (gp->filename))), filename);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gp->filename, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (gp->filename);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
return gp;
|
1998-03-19 04:22:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-03-21 02:38:43 +03:00
|
|
|
gprop_filename_get_data (GpropFilename *gp, char **filename)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
g_return_if_fail (gp != NULL);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
if (filename) {
|
1998-03-21 02:38:43 +03:00
|
|
|
entry = gnome_entry_gtk_entry (GNOME_ENTRY (gp->filename));
|
1998-03-19 04:22:32 +03:00
|
|
|
*filename = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-20 09:49:16 +04:00
|
|
|
/* Executable */
|
|
|
|
GpropExec *
|
|
|
|
gprop_exec_new (GnomeDesktopEntry *dentry)
|
|
|
|
{
|
|
|
|
GpropExec *ge;
|
|
|
|
GtkWidget *frame, *table;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
ge = g_new (GpropExec, 1);
|
|
|
|
ge->top = gtk_vbox_new (FALSE, 6);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (_("Command"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (ge->top), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
table = gtk_table_new (0, 0, 0);
|
1998-12-01 08:13:40 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
|
1998-05-20 09:49:16 +04:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
|
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label_new (_("Command:"), 0.0, 0.5),
|
|
|
|
0, 1, 0, 1,
|
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
|
|
|
|
1998-05-20 10:49:08 +04:00
|
|
|
ge->entry = gnome_entry_new (NULL);
|
1998-05-20 09:49:16 +04:00
|
|
|
s = gnome_config_assemble_vector (dentry->exec_length, (const char * const *) dentry->exec);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (ge->entry))), s);
|
|
|
|
g_free (s);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), ge->entry,
|
|
|
|
1, 2, 0, 1, 0, 0, 0, 0);
|
|
|
|
ge->check = gtk_check_button_new_with_label (_("Use terminal"));
|
|
|
|
GTK_TOGGLE_BUTTON (ge->check)->active = dentry->terminal ? 1 : 0;
|
|
|
|
gtk_table_attach (GTK_TABLE (table), ge->check,
|
|
|
|
1, 2, 1, 2, 0, 0, 0, 0);
|
|
|
|
gtk_widget_show_all (ge->top);
|
|
|
|
return ge;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gprop_exec_get_data (GpropExec *ge, GnomeDesktopEntry *dentry)
|
|
|
|
{
|
|
|
|
GtkEntry *entry;
|
|
|
|
|
|
|
|
entry = GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (ge->entry)));
|
1998-11-04 22:03:44 +03:00
|
|
|
g_strfreev (dentry->exec);
|
1998-05-20 09:49:16 +04:00
|
|
|
gnome_config_make_vector (gtk_entry_get_text (entry),
|
|
|
|
&dentry->exec_length, &dentry->exec);
|
|
|
|
dentry->terminal = GTK_TOGGLE_BUTTON (ge->check)->active;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***** permissions *****/
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
static umode_t
|
1998-03-21 02:38:43 +03:00
|
|
|
perm_get_umode (GpropPerm *gp)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
|
|
|
umode_t umode;
|
|
|
|
|
|
|
|
#define SETBIT(widget, flag) umode |= GTK_TOGGLE_BUTTON (widget)->active ? flag : 0
|
|
|
|
|
|
|
|
umode = 0;
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
SETBIT (gp->suid, S_ISUID);
|
|
|
|
SETBIT (gp->sgid, S_ISGID);
|
|
|
|
SETBIT (gp->svtx, S_ISVTX);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
SETBIT (gp->rusr, S_IRUSR);
|
|
|
|
SETBIT (gp->wusr, S_IWUSR);
|
|
|
|
SETBIT (gp->xusr, S_IXUSR);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
SETBIT (gp->rgrp, S_IRGRP);
|
|
|
|
SETBIT (gp->wgrp, S_IWGRP);
|
|
|
|
SETBIT (gp->xgrp, S_IXGRP);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
SETBIT (gp->roth, S_IROTH);
|
|
|
|
SETBIT (gp->woth, S_IWOTH);
|
|
|
|
SETBIT (gp->xoth, S_IXOTH);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
return umode;
|
|
|
|
|
|
|
|
#undef SETBIT
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
perm_set_mode_label (GtkWidget *widget, gpointer data)
|
|
|
|
{
|
|
|
|
umode_t umode;
|
1998-03-21 02:38:43 +03:00
|
|
|
GpropPerm *gp;
|
1998-03-19 04:22:32 +03:00
|
|
|
char s_mode[5];
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp = data;
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
umode = perm_get_umode (gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
s_mode[0] = '0' + ((umode & (S_ISUID | S_ISGID | S_ISVTX)) >> 9);
|
|
|
|
s_mode[1] = '0' + ((umode & (S_IRUSR | S_IWUSR | S_IXUSR)) >> 6);
|
|
|
|
s_mode[2] = '0' + ((umode & (S_IRGRP | S_IWGRP | S_IXGRP)) >> 3);
|
|
|
|
s_mode[3] = '0' + ((umode & (S_IROTH | S_IWOTH | S_IXOTH)) >> 0);
|
|
|
|
s_mode[4] = 0;
|
|
|
|
|
1998-12-28 06:38:33 +03:00
|
|
|
gtk_label_set_text (GTK_LABEL (gp->mode_label), s_mode);
|
1998-03-19 04:22:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
1998-03-21 02:38:43 +03:00
|
|
|
perm_check_new (char *text, int state, GpropPerm *gp)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
|
|
|
GtkWidget *check;
|
|
|
|
|
|
|
|
if (text)
|
|
|
|
check = gtk_check_button_new_with_label (text);
|
|
|
|
else
|
|
|
|
check = gtk_check_button_new ();
|
|
|
|
|
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (check), FALSE);
|
1999-01-13 23:37:47 +03:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), state ? TRUE : FALSE);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (check), "toggled",
|
|
|
|
(GtkSignalFunc) perm_set_mode_label,
|
1998-03-21 02:38:43 +03:00
|
|
|
gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
gtk_widget_show (check);
|
|
|
|
return check;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ATTACH(table, widget, left, right, top, bottom) \
|
|
|
|
gtk_table_attach (GTK_TABLE (table), widget, \
|
|
|
|
left, right, top, bottom, \
|
|
|
|
GTK_FILL | GTK_SHRINK, \
|
|
|
|
GTK_FILL | GTK_SHRINK, \
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
#define PERMSET(name, r, w, x, rmask, wmask, xmask, y) do { \
|
1998-03-21 02:38:43 +03:00
|
|
|
r = perm_check_new (NULL, umode & rmask, gp); \
|
|
|
|
w = perm_check_new (NULL, umode & wmask, gp); \
|
|
|
|
x = perm_check_new (NULL, umode & xmask, gp); \
|
1998-03-19 04:22:32 +03:00
|
|
|
\
|
|
|
|
ATTACH (table, label_new (name, 0.0, 0.5), 0, 1, y, y + 1); \
|
|
|
|
ATTACH (table, r, 1, 2, y, y + 1); \
|
|
|
|
ATTACH (table, w, 2, 3, y, y + 1); \
|
|
|
|
ATTACH (table, x, 3, 4, y, y + 1); \
|
|
|
|
} while (0);
|
|
|
|
|
|
|
|
static GtkWidget *
|
1998-03-21 02:38:43 +03:00
|
|
|
perm_mode_new (GpropPerm *gp, umode_t umode)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
frame = gtk_frame_new (_("File mode (permissions)"));
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
1998-12-01 08:13:40 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label_new (_("Current mode: "), 0.0, 0.5), FALSE, FALSE, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp->mode_label = label_new ("0000", 0.0, 0.5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gp->mode_label, FALSE, FALSE, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
table = gtk_table_new (4, 5, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* Headings */
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
ATTACH (table, label_new (_("Read"), 0.0, 0.5), 1, 2, 0, 1);
|
|
|
|
ATTACH (table, label_new (_("Write"), 0.0, 0.5), 2, 3, 0, 1);
|
|
|
|
ATTACH (table, label_new (_("Exec"), 0.0, 0.5), 3, 4, 0, 1);
|
|
|
|
ATTACH (table, label_new (_("Special"), 0.0, 0.5), 4, 5, 0, 1);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
/* Permissions */
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
PERMSET (_("User"), gp->rusr, gp->wusr, gp->xusr, S_IRUSR, S_IWUSR, S_IXUSR, 1);
|
|
|
|
PERMSET (_("Group"), gp->rgrp, gp->wgrp, gp->xgrp, S_IRGRP, S_IWGRP, S_IXGRP, 2);
|
|
|
|
PERMSET (_("Other"), gp->roth, gp->woth, gp->xoth, S_IROTH, S_IWOTH, S_IXOTH, 3);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
/* Special */
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gp->suid = perm_check_new (_("Set UID"), umode & S_ISUID, gp);
|
|
|
|
gp->sgid = perm_check_new (_("Set GID"), umode & S_ISGID, gp);
|
|
|
|
gp->svtx = perm_check_new (_("Sticky"), umode & S_ISVTX, gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
ATTACH (table, gp->suid, 4, 5, 1, 2);
|
|
|
|
ATTACH (table, gp->sgid, 4, 5, 2, 3);
|
|
|
|
ATTACH (table, gp->svtx, 4, 5, 3, 4);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
perm_set_mode_label (NULL, gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef ATTACH
|
|
|
|
#undef PERMSET
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
perm_owner_new (char *owner)
|
|
|
|
{
|
|
|
|
GtkWidget *gentry;
|
|
|
|
GtkWidget *entry;
|
1998-03-19 05:32:03 +03:00
|
|
|
GtkWidget *list;
|
|
|
|
struct passwd *passwd;
|
|
|
|
int i, sel;
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-05-20 10:49:08 +04:00
|
|
|
gentry = gnome_entry_new (NULL);
|
1998-03-19 05:32:03 +03:00
|
|
|
|
|
|
|
list = GTK_COMBO (gentry)->list;
|
|
|
|
|
|
|
|
/* We can't use 0 as the intial element because the gnome entry may already
|
|
|
|
* have loaded some history from a file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
i = g_list_length (GTK_LIST (list)->children);
|
|
|
|
sel = i;
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, _("<Unknown>"));
|
1998-03-19 05:32:03 +03:00
|
|
|
|
|
|
|
for (setpwent (); (passwd = getpwent ()) != NULL; i++) {
|
|
|
|
gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, passwd->pw_name);
|
|
|
|
if (strcmp (passwd->pw_name, owner) == 0)
|
|
|
|
sel = i;
|
|
|
|
}
|
1998-03-19 07:51:17 +03:00
|
|
|
endpwent ();
|
1998-03-19 05:32:03 +03:00
|
|
|
gtk_list_select_item (GTK_LIST (list), sel);
|
|
|
|
|
1998-03-19 04:22:32 +03:00
|
|
|
entry = gnome_entry_gtk_entry (GNOME_ENTRY (gentry));
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), owner);
|
|
|
|
|
|
|
|
return gentry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
perm_group_new (char *group)
|
|
|
|
{
|
|
|
|
GtkWidget *gentry;
|
|
|
|
GtkWidget *entry;
|
1998-03-19 05:32:03 +03:00
|
|
|
GtkWidget *list;
|
|
|
|
struct group *grp;
|
|
|
|
int i, sel;
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
gentry = gnome_entry_new ("gprop_perm_group");
|
1998-03-25 08:16:00 +03:00
|
|
|
gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, _("<Unknown>"));
|
1998-03-19 05:32:03 +03:00
|
|
|
|
|
|
|
list = GTK_COMBO (gentry)->list;
|
|
|
|
|
|
|
|
/* We can't use 0 as the intial element because the gnome entry may already
|
|
|
|
* have loaded some history from a file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
i = g_list_length (GTK_LIST (list)->children);
|
|
|
|
sel = i;
|
|
|
|
|
|
|
|
for (setgrent (); (grp = getgrent ()) != NULL; i++) {
|
|
|
|
gnome_entry_append_history (GNOME_ENTRY (gentry), FALSE, grp->gr_name);
|
|
|
|
if (strcmp (grp->gr_name, group) == 0)
|
|
|
|
sel = i;
|
|
|
|
}
|
1998-03-19 07:51:17 +03:00
|
|
|
endgrent ();
|
|
|
|
|
1998-03-19 05:32:03 +03:00
|
|
|
gtk_list_select_item (GTK_LIST (list), sel);
|
|
|
|
|
1998-03-19 04:22:32 +03:00
|
|
|
entry = gnome_entry_gtk_entry (GNOME_ENTRY (gentry));
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), group);
|
|
|
|
|
|
|
|
return gentry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
1998-03-21 02:38:43 +03:00
|
|
|
perm_ownership_new (GpropPerm *gp, char *owner, char *group)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *table;
|
|
|
|
|
|
|
|
frame = gtk_frame_new ("File ownership");
|
|
|
|
|
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
1998-12-01 08:13:40 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* Owner */
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label_new (_("Owner"), 0.0, 0.5),
|
1998-03-19 04:22:32 +03:00
|
|
|
0, 1, 0, 1,
|
|
|
|
GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp->owner = perm_owner_new (owner);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), gp->owner,
|
1998-03-19 04:22:32 +03:00
|
|
|
1, 2, 0, 1,
|
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
1998-03-21 02:38:43 +03:00
|
|
|
gtk_widget_show (gp->owner);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
/* Group */
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label_new (_("Group"), 0.0, 0.5),
|
1998-03-19 04:22:32 +03:00
|
|
|
0, 1, 1, 2,
|
|
|
|
GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp->group = perm_group_new (group);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), gp->group,
|
1998-03-19 04:22:32 +03:00
|
|
|
1, 2, 1, 2,
|
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
1998-03-21 02:38:43 +03:00
|
|
|
gtk_widget_show (gp->group);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
GpropPerm *
|
|
|
|
gprop_perm_new (umode_t umode, char *owner, char *group)
|
|
|
|
{
|
1998-03-21 02:38:43 +03:00
|
|
|
GpropPerm *gp;
|
1998-03-19 04:22:32 +03:00
|
|
|
GtkWidget *w;
|
|
|
|
|
|
|
|
g_return_val_if_fail (owner != NULL, NULL);
|
|
|
|
g_return_val_if_fail (group != NULL, NULL);
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp = g_new (GpropPerm, 1);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp->top = gtk_vbox_new (FALSE, 6);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gp->top), "destroy",
|
1998-03-20 05:00:09 +03:00
|
|
|
(GtkSignalFunc) free_stuff,
|
1998-03-21 02:38:43 +03:00
|
|
|
gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
w = perm_mode_new (gp, umode);
|
|
|
|
gtk_box_pack_start (GTK_BOX (gp->top), w, FALSE, FALSE, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_widget_show (w);
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
w = perm_ownership_new (gp, owner, group);
|
|
|
|
gtk_box_pack_start (GTK_BOX (gp->top), w, FALSE, FALSE, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_widget_show (w);
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
return gp;
|
1998-03-19 04:22:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-03-21 02:38:43 +03:00
|
|
|
gprop_perm_get_data (GpropPerm *gp, umode_t *umode, char **owner, char **group)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
1998-03-21 02:38:43 +03:00
|
|
|
g_return_if_fail (gp != NULL);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
if (umode)
|
1998-03-21 02:38:43 +03:00
|
|
|
*umode = perm_get_umode (gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
if (owner)
|
1998-03-21 02:38:43 +03:00
|
|
|
*owner = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (gp->owner)))));
|
1998-03-19 04:22:32 +03:00
|
|
|
|
|
|
|
if (group)
|
1998-03-21 02:38:43 +03:00
|
|
|
*group = g_strdup (gtk_entry_get_text (GTK_ENTRY (gnome_entry_gtk_entry (GNOME_ENTRY (gp->group)))));
|
1998-03-19 04:22:32 +03:00
|
|
|
}
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
/***** General *****/
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-04-30 08:04:39 +04:00
|
|
|
static void
|
|
|
|
change_icon (GtkEntry *entry, GpropGeneral *gp)
|
|
|
|
{
|
|
|
|
char *filename;
|
|
|
|
|
|
|
|
filename = gtk_entry_get_text (entry);
|
|
|
|
|
1998-05-20 06:12:06 +04:00
|
|
|
if (g_file_exists (filename) && gp->icon_pixmap){
|
1998-04-30 08:04:39 +04:00
|
|
|
gnome_pixmap_load_file (GNOME_PIXMAP (gp->icon_pixmap), gtk_entry_get_text (entry));
|
1998-05-20 06:12:06 +04:00
|
|
|
}
|
1998-04-30 08:04:39 +04:00
|
|
|
}
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
GpropGeneral *
|
1999-02-25 07:08:43 +03:00
|
|
|
gprop_general_new (const char *title, const char *icon_filename)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
1998-03-21 02:38:43 +03:00
|
|
|
GpropGeneral *gp;
|
1998-03-19 04:22:32 +03:00
|
|
|
GtkWidget *frame;
|
1998-03-21 02:38:43 +03:00
|
|
|
GtkWidget *table;
|
1998-03-19 04:22:32 +03:00
|
|
|
GtkWidget *entry;
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
g_return_val_if_fail (title != NULL, NULL);
|
|
|
|
|
|
|
|
gp = g_new (GpropGeneral, 1);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
gp->top = gtk_vbox_new (FALSE, 6);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gp->top), "destroy",
|
1998-03-20 05:00:09 +03:00
|
|
|
(GtkSignalFunc) free_stuff,
|
1998-03-21 02:38:43 +03:00
|
|
|
gp);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
frame = gtk_frame_new (_("General"));
|
1998-03-21 02:38:43 +03:00
|
|
|
gtk_box_pack_start (GTK_BOX (gp->top), frame, FALSE, FALSE, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
1998-04-30 08:04:39 +04:00
|
|
|
table = gtk_table_new (3, 2, FALSE);
|
1998-12-01 08:13:40 +03:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 6);
|
1998-03-21 02:38:43 +03:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), table);
|
|
|
|
gtk_widget_show (table);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label_new (_("Title"), 0.0, 0.5),
|
1998-03-21 02:38:43 +03:00
|
|
|
0, 1, 0, 1,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
|
|
|
|
|
|
|
gp->title = gnome_entry_new ("gprop_general_title");
|
|
|
|
entry = gnome_entry_gtk_entry (GNOME_ENTRY (gp->title));
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), title);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), gp->title,
|
|
|
|
1, 2, 0, 1,
|
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (gp->title);
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label_new (_("Icon"), 0.0, 0.5),
|
1998-03-21 02:38:43 +03:00
|
|
|
0, 1, 1, 2,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-04-30 08:04:39 +04:00
|
|
|
gp->icon_pixmap = gnome_pixmap_new_from_file (icon_filename);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), gp->icon_pixmap,
|
|
|
|
1, 2, 2, 3,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (gp->icon_pixmap);
|
|
|
|
|
1998-03-25 08:16:00 +03:00
|
|
|
gp->icon_filename = gnome_file_entry_new ("gprop_general_icon_filename", _("Select icon"));
|
1998-03-21 02:38:43 +03:00
|
|
|
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gp->icon_filename));
|
1998-04-30 08:04:39 +04:00
|
|
|
gtk_signal_connect (GTK_OBJECT (entry), "changed",
|
|
|
|
(GtkSignalFunc) change_icon,
|
|
|
|
gp);
|
1998-03-21 02:38:43 +03:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), icon_filename);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), gp->icon_filename,
|
|
|
|
1, 2, 1, 2,
|
|
|
|
GTK_EXPAND | GTK_FILL | GTK_SHRINK,
|
|
|
|
GTK_FILL | GTK_SHRINK,
|
|
|
|
0, 0);
|
|
|
|
gtk_widget_show (gp->icon_filename);
|
|
|
|
|
|
|
|
return gp;
|
1998-03-19 04:22:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-03-21 02:38:43 +03:00
|
|
|
gprop_general_get_data (GpropGeneral *gp, char **title, char **icon_filename)
|
1998-03-19 04:22:32 +03:00
|
|
|
{
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
g_return_if_fail (gp != NULL);
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
if (title) {
|
|
|
|
entry = gnome_entry_gtk_entry (GNOME_ENTRY (gp->title));
|
|
|
|
*title = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
|
|
|
|
}
|
1998-03-19 04:22:32 +03:00
|
|
|
|
1998-03-21 02:38:43 +03:00
|
|
|
if (icon_filename) {
|
|
|
|
entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (gp->icon_filename));
|
1998-03-19 04:22:32 +03:00
|
|
|
*icon_filename = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
|
1998-03-21 02:38:43 +03:00
|
|
|
}
|
1998-03-19 04:22:32 +03:00
|
|
|
}
|