| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  | #include <gio/gio.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | activate (GApplication *application) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   g_print ("activated\n"); | 
					
						
							| 
									
										
										
										
											2010-11-02 22:39:58 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   /* Note: when doing a longer-lasting action here that returns
 | 
					
						
							|  |  |  |    * to the mainloop, you should use g_application_hold() and | 
					
						
							|  |  |  |    * g_application_release() to keep the application alive until | 
					
						
							|  |  |  |    * the action is completed. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											2023-05-20 12:39:46 +02:00
										 |  |  | app_open (GApplication  *application, | 
					
						
							|  |  |  |           GFile        **files, | 
					
						
							|  |  |  |           gint           n_files, | 
					
						
							|  |  |  |           const gchar   *hint) | 
					
						
							| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   gint i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (i = 0; i < n_files; i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       gchar *uri = g_file_get_uri (files[i]); | 
					
						
							|  |  |  |       g_print ("open %s\n", uri); | 
					
						
							|  |  |  |       g_free (uri); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-02 22:39:58 -04:00
										 |  |  |   /* Note: when doing a longer-lasting action here that returns
 | 
					
						
							|  |  |  |    * to the mainloop, you should use g_application_hold() and | 
					
						
							|  |  |  |    * g_application_release() to keep the application alive until | 
					
						
							|  |  |  |    * the action is completed. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int | 
					
						
							|  |  |  | main (int argc, char **argv) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GApplication *app; | 
					
						
							|  |  |  |   int status; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   app = g_application_new ("org.gtk.TestApplication", | 
					
						
							|  |  |  |                            G_APPLICATION_HANDLES_OPEN); | 
					
						
							|  |  |  |   g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); | 
					
						
							| 
									
										
										
										
											2023-05-20 12:39:46 +02:00
										 |  |  |   g_signal_connect (app, "open", G_CALLBACK (app_open), NULL); | 
					
						
							| 
									
										
										
										
											2010-10-23 02:27:39 +02:00
										 |  |  |   g_application_set_inactivity_timeout (app, 10000); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   status = g_application_run (app, argc, argv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   g_object_unref (app); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return status; | 
					
						
							|  |  |  | } |