| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  | #include <gio/gio.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | command_line (GApplication            *application, | 
					
						
							|  |  |  |               GApplicationCommandLine *cmdline) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   gchar **argv; | 
					
						
							|  |  |  |   gint argc; | 
					
						
							|  |  |  |   gint i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   argv = g_application_command_line_get_arguments (cmdline, &argc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_application_command_line_print (cmdline, | 
					
						
							|  |  |  |                                     "This text is written back\n" | 
					
						
							|  |  |  |                                     "to stdout of the caller\n"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (i = 0; i < argc; i++) | 
					
						
							|  |  |  |     g_print ("argument %d: %s\n", i, argv[i]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_strfreev (argv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int | 
					
						
							|  |  |  | main (int argc, char **argv) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GApplication *app; | 
					
						
							|  |  |  |   int status; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   app = g_application_new ("org.gtk.TestApplication", | 
					
						
							|  |  |  |                            G_APPLICATION_HANDLES_COMMAND_LINE); | 
					
						
							|  |  |  |   g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL); | 
					
						
							| 
									
										
										
										
											2024-02-09 10:04:14 +00:00
										 |  |  |   g_application_set_version (app, "2.3"); | 
					
						
							| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   status = g_application_run (app, argc, argv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_object_unref (app); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return status; | 
					
						
							|  |  |  | } |