Vanilla Development Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS update: Vanilla/gum



Date:	Friday July 30, 1999 @ 3:14
Author:	tanner

Update of /home/netrek/cvsroot/Vanilla/gum
In directory cvs.castle.real-time.com:/var/tmp/cvs-serv16548

Modified Files:
	ChangeLog gum.xml id.c main.c main.h signals.c test-id.c 
Added Files:
	id.h 
Log Message:
** WARNING **

This is my first attempt at using glade and gtk+, so I am not sure if I broke
anything or how bad. If glade is like mrm from motif, I did not write the 
event handler functions, so this may not even compile.

	* gum.xml:  Used glade tool to create an invalid group permission
	dialog box, which I'll display if the group permission do not
	allow the user to write to the netrek configuration files.

	* id.c: Moved functional prototypes into id.h, included id.h.



****************************************

Index: Vanilla/gum/ChangeLog
diff -u Vanilla/gum/ChangeLog:1.6 Vanilla/gum/ChangeLog:1.7
--- Vanilla/gum/ChangeLog:1.6	Thu Jul 29 11:10:48 1999
+++ Vanilla/gum/ChangeLog	Fri Jul 30 03:14:22 1999
@@ -1,3 +1,11 @@
+Fri Jul 30 03:10:01 1999  Bob Tanner  <tanner@real-time.com>
+
+	* gum.xml:  Used glade tool to create an invalid group permission
+	dialog box, which I'll display if the group permission do not
+	allow the user to write to the netrek configuration files.
+
+	* id.c: Moved functional prototypes into id.h, included id.h.
+
 Thu Jul 29 00:05:45 1999  Bob Tanner  <tanner@real-time.com>
 
 	* id.c: Added some functional prototypes to get some of the
@@ -44,6 +52,6 @@
 	* signals.c (on_About_activate): revise about screen to show who
 	to complain to.
 
-	$Id: ChangeLog,v 1.6 1999/07/29 16:10:48 tanner Exp $	
+	$Id: ChangeLog,v 1.7 1999/07/30 08:14:22 tanner Exp $	
 
 
Index: Vanilla/gum/gum.xml
diff -u Vanilla/gum/gum.xml:1.5 Vanilla/gum/gum.xml:1.6
--- Vanilla/gum/gum.xml:1.5	Sun Jul 18 09:49:53 1999
+++ Vanilla/gum/gum.xml	Fri Jul 30 03:14:22 1999
@@ -7416,4 +7416,80 @@
   </widget>
 </widget>
 
+<widget>
+  <class>GnomeDialog</class>
+  <name>perms</name>
+  <title>Invalid Group Permissions</title>
+  <auto_close>False</auto_close>
+  <hide_on_close>True</hide_on_close>
+  <allow_shrink>False</allow_shrink>
+  <allow_grow>False</allow_grow>
+  <auto_shrink>False</auto_shrink>
+
+  <widget>
+    <class>GtkVBox</class>
+    <child_name>GnomeDialog:vbox</child_name>
+    <name>dialog-vbox3</name>
+    <child>
+      <padding>4</padding>
+      <expand>True</expand>
+      <fill>True</fill>
+    </child>
+    <homogeneous>False</homogeneous>
+    <spacing>8</spacing>
+
+    <widget>
+      <class>GtkText</class>
+      <name>perms_message</name>
+      <child>
+	<padding>0</padding>
+	<expand>True</expand>
+	<fill>True</fill>
+      </child>
+      <can_focus>True</can_focus>
+      <editable>False</editable>
+      <text>I have detected that you are not in the &quot;games&quot; group. 
+
+Using the root account please issue the follow 
+command to add yourself to the &quot;games&quot; group.
+
+# usermod -G games &lt;username&gt;
+
+Replace &lt;username&gt; with your account name.
+
+Clicking the Cancel button will exit the program and allow
+you to make the above change. After making the change
+re-run this application and everything should work
+correctly.
+</text>
+    </widget>
+
+    <widget>
+      <class>GtkHButtonBox</class>
+      <child_name>GnomeDialog:action_area</child_name>
+      <name>dialog-action_area3</name>
+      <child>
+	<padding>0</padding>
+	<expand>False</expand>
+	<fill>True</fill>
+	<pack>GTK_PACK_END</pack>
+      </child>
+      <layout_style>GTK_BUTTONBOX_END</layout_style>
+      <spacing>8</spacing>
+      <child_min_width>85</child_min_width>
+      <child_min_height>27</child_min_height>
+      <child_ipad_x>7</child_ipad_x>
+      <child_ipad_y>0</child_ipad_y>
+
+      <widget>
+	<class>GtkButton</class>
+	<name>perms_cancel</name>
+	<can_default>True</can_default>
+	<can_focus>True</can_focus>
+	<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
+      </widget>
+    </widget>
+  </widget>
+</widget>
+
 </GTK-Interface>
Index: Vanilla/gum/id.c
diff -u Vanilla/gum/id.c:1.3 Vanilla/gum/id.c:1.4
--- Vanilla/gum/id.c:1.3	Thu Jul 29 11:10:48 1999
+++ Vanilla/gum/id.c	Fri Jul 30 03:14:23 1999
@@ -4,18 +4,8 @@
 #include <pwd.h>
 #include <grp.h>
 #include <getopt.h>
+#include "id.h"
 
-#define GETGROUPS_T gid_t
-static void print_user __P ((uid_t uid));
-static char* uid_to_string(uid_t uid);
-static void print_group __P ((gid_t gid));
-static char* gid_to_string(uid_t gid);
-static void print_group_list __P ((char *username));
-int getugroups (int, gid_t *, char *);
-int get_all_groups(char*, gid_t **);
-int search_4group(gid_t, int, gid_t *);
-void *xmalloc (size_t n);
-
 int
 search_4group(gid_t group, int count, gid_t *supp_groups)
 {
@@ -75,13 +65,11 @@
 
 /* Send me a uid and I'll print you the username */
 
-static 
 void print_user(uid_t uid) 
 {
   printf("%s", uid_to_string(uid));
 }
 
-static
 char *uid_to_string(uid_t uid)
 {
   struct passwd *pwd = NULL;
@@ -95,13 +83,11 @@
 
 /* Send me a guid and I'll print you the group name */
 
-static 
 void print_group(gid_t gid)
 {
   printf("%s", gid_to_string(gid));
 }
 
-static
 char *gid_to_string(gid_t gid)
 {
   struct group *grp = NULL;
Index: Vanilla/gum/main.c
diff -u Vanilla/gum/main.c:1.4 Vanilla/gum/main.c:1.5
--- Vanilla/gum/main.c:1.4	Sun Jul 18 09:49:54 1999
+++ Vanilla/gum/main.c	Fri Jul 30 03:14:23 1999
@@ -3420,3 +3420,45 @@
   return welcome;
 }
 
+GtkWidget*
+create_perms ()
+{
+  GtkWidget *perms;
+  GtkWidget *dialog_vbox3;
+  GtkWidget *perms_message;
+  GtkWidget *dialog_action_area3;
+  GtkWidget *perms_cancel;
+
+  perms = gnome_dialog_new ("Invalid Group Permissions", NULL);
+  gtk_object_set_data (GTK_OBJECT (perms), "perms", perms);
+  gnome_dialog_close_hides (GNOME_DIALOG (perms), TRUE);
+  gtk_window_set_policy (GTK_WINDOW (perms), FALSE, FALSE, FALSE);
+
+  dialog_vbox3 = GNOME_DIALOG (perms)->vbox;
+  gtk_object_set_data (GTK_OBJECT (perms), "dialog_vbox3", dialog_vbox3);
+  gtk_widget_show (dialog_vbox3);
+
+  perms_message = gtk_text_new (NULL, NULL);
+  gtk_object_set_data (GTK_OBJECT (perms), "perms_message", perms_message);
+  gtk_widget_show (perms_message);
+  gtk_box_pack_start (GTK_BOX (dialog_vbox3), perms_message, TRUE, TRUE, 0);
+  gtk_widget_realize (perms_message);
+  gtk_text_insert (GTK_TEXT (perms_message), NULL, NULL, NULL,
+                   "I have detected that you are not in the \"games\" group. \n\nUsing the root account please issue the follow \ncommand to add yourself to the \"games\" group.\n\n# usermod -G games <username>\n\nReplace <username> with your account name.\n\nClicking the Cancel button will exit the program and allow\nyou to make the above change. After making the change\nre-run this application and everything should work\ncorrectly.\n", 402);
+
+  dialog_action_area3 = GNOME_DIALOG (perms)->action_area;
+  gtk_object_set_data (GTK_OBJECT (perms), "dialog_action_area3", dialog_action_area3);
+  gtk_widget_show (dialog_action_area3);
+  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area3), GTK_BUTTONBOX_END);
+  gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area3), 8);
+
+  gnome_dialog_append_button (GNOME_DIALOG (perms), GNOME_STOCK_BUTTON_CANCEL);
+  perms_cancel = g_list_last (GNOME_DIALOG (perms)->buttons)->data;
+  gtk_object_set_data (GTK_OBJECT (perms), "perms_cancel", perms_cancel);
+  gtk_widget_show (perms_cancel);
+  GTK_WIDGET_SET_FLAGS (perms_cancel, GTK_CAN_DEFAULT);
+
+
+  return perms;
+}
+
Index: Vanilla/gum/main.h
diff -u Vanilla/gum/main.h:1.3 Vanilla/gum/main.h:1.4
--- Vanilla/gum/main.h:1.3	Sun Jul 18 09:49:54 1999
+++ Vanilla/gum/main.h	Fri Jul 30 03:14:24 1999
@@ -8,3 +8,4 @@
 GtkWidget* create_open (void);
 GtkWidget* create_saveas (void);
 GtkWidget* create_welcome (void);
+GtkWidget* create_perms (void);
Index: Vanilla/gum/signals.c
diff -u Vanilla/gum/signals.c:1.3 Vanilla/gum/signals.c:1.4
--- Vanilla/gum/signals.c:1.3	Sun Jul 18 09:49:54 1999
+++ Vanilla/gum/signals.c	Fri Jul 30 03:14:24 1999
@@ -1459,6 +1459,7 @@
 {
   int i;
   GtkWidget *welcome;
+  
 
   /* initialise sysdef buffer */
   for (i=0; i<MAXLINES; i++) { lines[i] = NULL; defs[i] = -1; }
Index: Vanilla/gum/test-id.c
diff -u Vanilla/gum/test-id.c:1.1 Vanilla/gum/test-id.c:1.2
--- Vanilla/gum/test-id.c:1.1	Wed Jul 28 03:26:56 1999
+++ Vanilla/gum/test-id.c	Fri Jul 30 03:14:24 1999
@@ -1,4 +1,11 @@
 #include <stdio.h>
+#include <stdlib.h>
+#include <pwd.h>
+#include <sys/types.h>
+#include <gdk/gdkprivate.h> /* for gdk_display */
+#include <gtk/gtk.h>
+#include "id.h"
+#include "main.h"
 
 /* The real and effective IDs of the user to print. */
 static uid_t ruid, euid;
@@ -10,8 +17,9 @@
   gid_t *groups;
   int group_count;
   int i;
+  struct passwd *pwd;
 
-  struct passwd *pwd = getpwnam("tanner");
+  pwd  = getpwnam("tanner");
   if (pwd == NULL) {
     printf("No such user");
     exit(1);
@@ -45,4 +53,15 @@
 
 
   free(groups);
+}
+
+void message(char *title, char *text)
+{
+  GtkWidget *w, *x;
+
+  w = create_message ();
+  gtk_window_set_title (GTK_WINDOW (w), title);
+  x = widgie(w, "message_label");
+  gtk_label_set (GTK_LABEL(x), text);
+  gtk_widget_show (w);
 }