kov changed gksu/trunk/gksu/gksu.c

Gustavo Noronha kov at costa.debian.org
Thu Jan 26 23:43:46 UTC 2006


Mensagem de log: 
deleted trailing whitespaces


-----


Modified: gksu/trunk/gksu/gksu.c
===================================================================
--- gksu/trunk/gksu/gksu.c	2006-01-25 01:19:57 UTC (rev 507)
+++ gksu/trunk/gksu/gksu.c	2006-01-26 23:43:46 UTC (rev 508)
@@ -41,7 +41,7 @@
 
 struct option long_opts[] = {
     /*
-     * { name  has_arg  *flag  val } 
+     * { name  has_arg  *flag  val }
      */
     {"help", no_argument, NULL, 'h'},
     {"login", no_argument, NULL, 'l'},
@@ -62,7 +62,7 @@
     {0, 0, 0, 0}
 };
 
-/* 
+/*
  * code 'stolen' from gnome-session's logout.c
  *
  * Written by Owen Taylor <otaylor at redhat.com>
@@ -139,7 +139,7 @@
 
   width = fadeout->area.width * 3;
   offset = 0;
-  
+
   for (i = 0; i < fadeout->area.height; i++)
     {
       sp = fadeout->start_p + offset;
@@ -167,12 +167,12 @@
   int width, height, rowstride;
   int i, j;
   guchar *p, *pixels;
-  
+
   width     = gdk_pixbuf_get_width (pb) * 3;
   height    = gdk_pixbuf_get_height (pb);
   rowstride = gdk_pixbuf_get_rowstride (pb);
   pixels    = gdk_pixbuf_get_pixels (pb);
-  
+
   for (i = 0; i < height; i++)
     {
       p = pixels + (i * rowstride);
@@ -226,7 +226,7 @@
 		   0, 0);
 
   gdk_flush ();
-  
+
   return TRUE;
 }
 
@@ -299,10 +299,10 @@
 		   0, 0);
 
   gdk_flush ();
-  
+
   return TRUE;
 }
-  
+
 static void
 fadeout_screen (GdkScreen *screen,
 		int        monitor)
@@ -336,7 +336,7 @@
 
   fadeout->draw_window = gdk_window_new (fadeout->root_window, &attr, attr_mask);
   fadeout_windows = g_list_prepend (fadeout_windows, fadeout->draw_window);
-  
+
   fadeout->start_pb = gdk_pixbuf_get_from_drawable (NULL,
 						    fadeout->root_window,
 						    NULL,
@@ -345,17 +345,17 @@
 						    0, 0,
 						    fadeout->area.width,
 						    fadeout->area.height);
-  
+
   fadeout->end_pb = gdk_pixbuf_copy (fadeout->start_pb);
   darken_pixbuf (fadeout->end_pb);
-  
+
   fadeout->frame = gdk_pixbuf_copy (fadeout->start_pb);
   fadeout->rowstride = gdk_pixbuf_get_rowstride (fadeout->start_pb);
 
   fadeout->start_p = gdk_pixbuf_get_pixels (fadeout->start_pb);
   fadeout->end_p   = gdk_pixbuf_get_pixels (fadeout->end_pb);
   fadeout->frame_p = gdk_pixbuf_get_pixels (fadeout->frame);
-  
+
   values.subwindow_mode = GDK_INCLUDE_INFERIORS;
 
   fadeout->gc = gdk_gc_new_with_values (fadeout->root_window, &values, GDK_GC_SUBWINDOW);
@@ -371,7 +371,7 @@
 		   fadeout->area.height,
 		   GDK_RGB_DITHER_NONE,
 		   0, 0);
-  
+
   g_get_current_time (&fadeout->start_time);
   g_idle_add ((GSourceFunc) fadeout_callback, fadeout);
 
@@ -383,7 +383,7 @@
 
 /**
  * help:
- * @cmdname:  name of the command which was called by the user 
+ * @cmdname:  name of the command which was called by the user
  * (argv[0])
  *
  * This function is a simple 'usage'-style printing function.
@@ -391,7 +391,7 @@
  */
 void
 help (gchar *cmdname)
-{ 
+{
   g_print (_(
 "GKsu version %s\n\n"
 "Usage: %s [-u <user>] [-k] [-l] <command>\n\n"
@@ -432,7 +432,7 @@
 "  --desktop <file>, -D <file>\n"
 "    Use a .desktop file to get the name of the application"
 "    and the icon from.\n"
-"\n" 
+"\n"
 "  --preserve-env, -k\n"
 "    Preserve the current environments, does not set $HOME\n"
 "    nor $PATH, for example.\n"
@@ -503,7 +503,7 @@
    if(FD < 0) {
       if(errno == ENOENT) {
 	 // File does not exist
-	 return 0; 
+	 return 0;
       } else {
 	 perror("open");
 	 return(-1);
@@ -538,13 +538,13 @@
 	 g_warning(_("Not using locking for read only lock file %s"),File);
 	 return dup(0);       // Need something for the caller to close
       }
-      
+
       // Feh.. We do this to distinguish the lock vs open case..
       errno = EPERM;
       return -1;
    }
    fcntl(FD,F_SETFD, FD_CLOEXEC);
-      
+
    // Aquire a write lock
    struct flock fl;
    fl.l_type = F_WRLCK;
@@ -558,9 +558,9 @@
 	 g_warning(_("Not using locking for nfs mounted lock file %s"), File);
 	 unlink(File);
 	 close(FD);
-	 return dup(0);       // Need something for the caller to close	 
-      }      
-      
+	 return dup(0);       // Need something for the caller to close
+      }
+
       int Tmp = errno;
       close(FD);
       errno = Tmp;
@@ -605,7 +605,7 @@
   attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
   attribute.value.string = g_strdup ("gksu");
   g_array_append_val (attributes, attribute);
-      
+
   list = g_list_alloc();
   keyring_has_password = FALSE;
 
@@ -631,12 +631,12 @@
       gksu_context_set_command (context, keyring_command);
     }
 
-  if (keyring_has_password) 
+  if (keyring_has_password)
     {
       gchar *password;
 
-      password = g_locale_from_utf8 (keyring_password, 
-				     strlen (keyring_password), 
+      password = g_locale_from_utf8 (keyring_password,
+				     strlen (keyring_password),
 				     NULL, NULL, NULL);
       gksu_context_set_password (context, password);
       return FALSE; /* we do not need a password */
@@ -660,19 +660,19 @@
       g_warning ("Lock taken by pid: %i. Exiting.", pid);
       exit (0);
     }
-  
+
   lock = get_lock(fname);
   if( lock < 0)
     g_warning ("Unable to create lock file.");
   g_free (fname);
-  
+
   fadeout_screen (gdk_screen_get_default (), 0);
   gtk_widget_show_all (dialog);
 
   /* reset cursor */
   gdk_window_set_cursor(dialog->window, gdk_cursor_new(GDK_LEFT_PTR));
 
-  for(;;) 
+  for(;;)
     {
       status = gdk_pointer_grab ((GTK_WIDGET(dialog))->window, TRUE, 0, NULL,
 				 NULL, GDK_CURRENT_TIME);
@@ -689,17 +689,17 @@
 	  break;
 	}
     }
-  
-  for(;;) 
+
+  for(;;)
     {
       status = gdk_keyboard_grab ((GTK_WIDGET(dialog))->window,
 				  FALSE, GDK_CURRENT_TIME);
       if (status == GDK_GRAB_SUCCESS)
 	break;
-      
+
       usleep(GRAB_WAIT * 1000);
-      
-      if (++grab_tries > GRAB_TRIES) 
+
+      if (++grab_tries > GRAB_TRIES)
 	{
 	  gtk_widget_hide (dialog);
 	  g_get_current_time (&fade_data->start_time);
@@ -709,9 +709,9 @@
 	  break;
 	}
     }
-  
+
   /* we "raise" the window because there is a race here for
-   * focus-follow-mouse and auto-raise WMs that may put the window 
+   * focus-follow-mouse and auto-raise WMs that may put the window
    * in the background and confuse users
    */
   gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE);
@@ -747,13 +747,13 @@
 				     NULL);
   prompt = gconf_client_get_bool (gconf_client, BASE_PATH "prompt",
 				  NULL);
-  always_ask_pass = gconf_client_get_bool (gconf_client, 
+  always_ask_pass = gconf_client_get_bool (gconf_client,
 					   BASE_PATH "always-ask-password",
 					   NULL);
 }
 
 gboolean
-su_ask_password (GksuContext *context, gchar *prompt, 
+su_ask_password (GksuContext *context, gchar *prompt,
 		 gpointer data, GError **error)
 {
   GtkWidget *dialog = GTK_WIDGET(data);
@@ -777,7 +777,7 @@
 				 "enter the %s password</b>"),
 			       gksu_context_get_command (context),
 			       gksu_context_get_user (context));
-	  
+
       gksuui_dialog_set_message (GKSUUI_DIALOG(dialog), msg);
       g_free (msg);
     }
@@ -867,7 +867,7 @@
   if (!toggled)
     return;
 
-  dialog = gtk_message_dialog_new_with_markup (NULL, 0, 
+  dialog = gtk_message_dialog_new_with_markup (NULL, 0,
 					       GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
 					       _("<b>The \"%s\" program was started with "
 						 "the privileges of the %s user without "
@@ -891,20 +891,20 @@
   gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), alignment, TRUE, TRUE, 2);
 
   check_button = gtk_check_button_new_with_mnemonic (_("Do _not display this message again"));
-  g_signal_connect (G_OBJECT(check_button), "toggled", 
+  g_signal_connect (G_OBJECT(check_button), "toggled",
 		    G_CALLBACK(cb_toggled_cb), "display-no-pass-info");
   gtk_container_add (GTK_CONTAINER(alignment), check_button);
 
   gtk_widget_show_all (dialog);
   gtk_dialog_run (GTK_DIALOG(dialog));
   gtk_widget_destroy (GTK_WIDGET(dialog));
-  
+
   while (gtk_events_pending ())
     gtk_main_iteration ();
 }
 
 void
-set_dialog_from_desktop (GksuuiDialog *dialog, GksuContext *context, 
+set_dialog_from_desktop (GksuuiDialog *dialog, GksuContext *context,
 			 gchar *file_name)
 {
   GKeyFile *desktop;
@@ -918,7 +918,7 @@
     {
       gchar *error_msg;
 
-      error_msg = g_strdup_printf ("Could not load desktop file: %s", 
+      error_msg = g_strdup_printf ("Could not load desktop file: %s",
 				   error->message);
       g_warning (error_msg);
       g_free (error_msg);
@@ -926,7 +926,7 @@
       return;
     }
 
-  buffer = g_key_file_get_locale_string (desktop, "Desktop Entry", 
+  buffer = g_key_file_get_locale_string (desktop, "Desktop Entry",
 					 "Name", NULL, NULL);
   if (buffer)
     {
@@ -948,7 +948,7 @@
       message_changed = TRUE;
     }
 
-  buffer = g_key_file_get_locale_string (desktop, "Desktop Entry", 
+  buffer = g_key_file_get_locale_string (desktop, "Desktop Entry",
 					 "Icon", NULL, NULL);
   if (buffer)
     {
@@ -973,8 +973,8 @@
       if (error)
 	{
 	  gchar *error_msg;
-	  
-	  error_msg = g_strdup_printf ("Could not load icon file: %s", 
+
+	  error_msg = g_strdup_printf ("Could not load icon file: %s",
 				       error->message);
 	  g_warning (error_msg);
 	  g_free (error_msg);
@@ -1013,13 +1013,13 @@
   int c = 0;
 
   setlocale (LC_ALL, "");
-  bindtextdomain(PACKAGE_NAME, LOCALEDIR);  
+  bindtextdomain(PACKAGE_NAME, LOCALEDIR);
   bind_textdomain_codeset (PACKAGE_NAME, "UTF-8");
   textdomain(PACKAGE_NAME);
 
-  /* 
+  /*
    * bad, bad code... adds a second -- right after the first one,
-   * because gtk_init will remove one of them... 
+   * because gtk_init will remove one of them...
    */
   {
     /* to check whether a -- was already found when parsing arguments */
@@ -1032,7 +1032,7 @@
 	    newargv = g_realloc (newargv, sizeof(char*) * (newargc + 2));
 	    newargv[newargc] = g_strdup (argv[c]);
 	    newargv[newargc + 1] = g_strdup (argv[c]);
-	    
+
 	    newargc = newargc + 2;
 	    separator_found = TRUE;
 	  }
@@ -1040,7 +1040,7 @@
 	  {
 	    newargv = g_realloc (newargv, sizeof(char*) * (newargc + 1));
 	    newargv[newargc] = g_strdup (argv[c]);
-	    
+
 	    newargc++;
 	  }
       }
@@ -1168,7 +1168,7 @@
   if (prompt)
     {
       GtkWidget *d;
-      
+
       d = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_QUESTION,
 					      GTK_BUTTONS_YES_NO,
 					      _("<b>Would you like your screen to be \"grabbed\"\n"
@@ -1177,12 +1177,12 @@
 						"This means all applications will be paused to avoid\n"
 						"the eavesdropping of your password by a a malicious\n"
 						"application while you type it."));
-      
+
       if (gtk_dialog_run (GTK_DIALOG(d)) == GTK_RESPONSE_NO)
 	grab = FALSE;
       else
 	grab = TRUE;
-      
+
       gtk_widget_destroy (d);
     }
 
@@ -1208,7 +1208,7 @@
     {
       if (!gksuui_dialog_get_message (GKSUUI_DIALOG(dialog)))
 	{
-	  gchar *msg = 
+	  gchar *msg =
 	    g_strdup_printf (_("<b>Please enter %s's password</b>"),
 			     gksu_context_get_user (context));
 
@@ -1224,9 +1224,9 @@
       if (grab)
 	ungrab_keyboard_and_mouse (lock);
 
-      /* 
+      /*
 	 the user may have pressed cancel or
-	 closed the window 
+	 closed the window
       */
       if (retvalue != GTK_RESPONSE_OK)
 	  return 2;
@@ -1299,11 +1299,11 @@
 
   if (sudo_mode)
     {
-      gksu_context_sudo_run_full (context, su_ask_password, (gpointer)dialog, 
+      gksu_context_sudo_run_full (context, su_ask_password, (gpointer)dialog,
 				  no_pass, NULL, &error);
       if (error)
 	{
-	  gk_dialog (GTK_MESSAGE_ERROR, 
+	  gk_dialog (GTK_MESSAGE_ERROR,
 		     _("<b>Failed to run %s as user %s.</b>\n\n%s"),
 		     gksu_context_get_command (context),
 		     gksu_context_get_user (context),
@@ -1334,7 +1334,7 @@
 	  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(check_button), remember_password);
 	  gtk_box_pack_start (GTK_BOX(vbox), check_button, TRUE, TRUE, 0);
 	  gtk_widget_show (check_button);
-      
+
 	  alignment = gtk_alignment_new (0.5, 0.5, 0.6, 1);
 	  gtk_box_pack_start (GTK_BOX(vbox), alignment, TRUE, TRUE, 2);
 	  gtk_widget_show (alignment);
@@ -1364,12 +1364,12 @@
 	    try_gnome_keyring_password (context);
 	}
 
-      gksu_context_run_full (context, su_ask_password, (gpointer)dialog, 
+      gksu_context_run_full (context, su_ask_password, (gpointer)dialog,
 			     no_pass, NULL, &error);
 
-      if (error) 
+      if (error)
 	{
-	  gk_dialog (GTK_MESSAGE_ERROR, 
+	  gk_dialog (GTK_MESSAGE_ERROR,
 		     _("Failed to run %s as user %s:\n %s"),
 		     gksu_context_get_command (context),
 		     gksu_context_get_user (context),
@@ -1387,17 +1387,17 @@
 	      static GMainLoop *keyring_loop = NULL;
 	      GnomeKeyringAttributeList *attributes;
 	      GnomeKeyringAttribute attribute;
-		      
+
 	      gchar *keyring_name;
 	      gchar *key_name;
-		      
+
 	      attributes = gnome_keyring_attribute_list_new ();
-		      
+
 	      attribute.name = g_strdup ("user");
 	      attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
 	      attribute.value.string = g_strdup (gksu_context_get_user (context));
 	      g_array_append_val (attributes, attribute);
-		    
+
 	      attribute.name = g_strdup ("type");
 	      attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
 	      attribute.value.string = g_strdup ("local");
@@ -1407,10 +1407,10 @@
 	      attribute.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
 	      attribute.value.string = g_strdup ("gksu");
 	      g_array_append_val (attributes, attribute);
-      
+
 	      key_name = g_strdup_printf ("Local password for user %s",
 					  gksu_context_get_user (context));
-      
+
 	      keyring_loop = g_main_loop_new (NULL, FALSE);
 
 	      keyring_name = gconf_client_get_string (gconf_client, BASE_PATH"save-keyring", NULL);
@@ -1422,7 +1422,7 @@
 					 attributes,
 					 gksu_context_get_password (context),
 					 TRUE,
-					 keyring_create_item_cb, 
+					 keyring_create_item_cb,
 					 keyring_loop, NULL);
 	      gnome_keyring_attribute_list_free (attributes);
 	      g_free (keyring_name);
@@ -1430,6 +1430,6 @@
 	    }
 	}
     }
-  
+
   return 0;
 }




More information about the gksu-commits mailing list