LCOV - code coverage report
Current view: top level - glib/gio/tests - gapplication-example-cmdline2.c (source / functions) Hit Total Coverage
Test: unnamed Lines: 0 39 0.0 %
Date: 2024-04-23 05:16:05 Functions: 0 10 0.0 %
Branches: 0 20 0.0 %

           Branch data     Line data    Source code
       1                 :            : #include <gio/gio.h>
       2                 :            : #include <stdlib.h>
       3                 :            : #include <string.h>
       4                 :            : 
       5                 :            : static int
       6                 :          0 : command_line (GApplication            *application,
       7                 :            :               GApplicationCommandLine *cmdline)
       8                 :            : {
       9                 :            :   gchar **argv;
      10                 :            :   gint argc;
      11                 :            :   gint i;
      12                 :            : 
      13                 :          0 :   argv = g_application_command_line_get_arguments (cmdline, &argc);
      14                 :            : 
      15         [ #  # ]:          0 :   for (i = 0; i < argc; i++)
      16                 :          0 :     g_print ("handling argument %s remotely\n", argv[i]);
      17                 :            : 
      18                 :          0 :   g_strfreev (argv);
      19                 :            : 
      20                 :          0 :   return 0;
      21                 :            : }
      22                 :            : 
      23                 :            : static gboolean
      24                 :          0 : test_local_cmdline (GApplication   *application,
      25                 :            :                     gchar        ***arguments,
      26                 :            :                     gint           *exit_status)
      27                 :            : {
      28                 :            :   gint i, j;
      29                 :            :   gchar **argv;
      30                 :            : 
      31                 :          0 :   argv = *arguments;
      32                 :            : 
      33                 :          0 :   i = 1;
      34         [ #  # ]:          0 :   while (argv[i])
      35                 :            :     {
      36   [ #  #  #  #  :          0 :       if (g_str_has_prefix (argv[i], "--local-"))
             #  #  #  # ]
      37                 :            :         {
      38                 :          0 :           g_print ("handling argument %s locally\n", argv[i]);
      39                 :          0 :           g_free (argv[i]);
      40         [ #  # ]:          0 :           for (j = i; argv[j]; j++)
      41                 :          0 :             argv[j] = argv[j + 1];
      42                 :            :         }
      43                 :            :       else
      44                 :            :         {
      45                 :          0 :           g_print ("not handling argument %s locally\n", argv[i]);
      46                 :          0 :           i++;
      47                 :            :         }
      48                 :            :     }
      49                 :            : 
      50                 :          0 :   *exit_status = 0;
      51                 :            : 
      52                 :          0 :   return FALSE;
      53                 :            : }
      54                 :            : 
      55                 :            : typedef GApplication TestApplication;
      56                 :            : typedef GApplicationClass TestApplicationClass;
      57                 :            : 
      58                 :            : static GType test_application_get_type (void);
      59   [ #  #  #  #  :          0 : G_DEFINE_TYPE (TestApplication, test_application, G_TYPE_APPLICATION)
                   #  # ]
      60                 :            : 
      61                 :            : static void
      62                 :          0 : test_application_finalize (GObject *object)
      63                 :            : {
      64                 :          0 :   G_OBJECT_CLASS (test_application_parent_class)->finalize (object);
      65                 :          0 : }
      66                 :            : 
      67                 :            : static void
      68                 :          0 : test_application_init (TestApplication *app)
      69                 :            : {
      70                 :          0 : }
      71                 :            : 
      72                 :            : static void
      73                 :          0 : test_application_class_init (TestApplicationClass *class)
      74                 :            : {
      75                 :          0 :   G_OBJECT_CLASS (class)->finalize = test_application_finalize;
      76                 :          0 :   G_APPLICATION_CLASS (class)->local_command_line = test_local_cmdline;
      77                 :          0 : }
      78                 :            : 
      79                 :            : static GApplication *
      80                 :          0 : test_application_new (const gchar       *application_id,
      81                 :            :                       GApplicationFlags  flags)
      82                 :            : {
      83                 :          0 :   g_return_val_if_fail (g_application_id_is_valid (application_id), NULL);
      84                 :            : 
      85                 :          0 :   return g_object_new (test_application_get_type (),
      86                 :            :                        "application-id", application_id,
      87                 :            :                        "flags", flags,
      88                 :            :                        NULL);
      89                 :            : }
      90                 :            : 
      91                 :            : int
      92                 :          0 : main (int argc, char **argv)
      93                 :            : {
      94                 :            :   GApplication *app;
      95                 :            :   int status;
      96                 :            : 
      97                 :          0 :   app = test_application_new ("org.gtk.TestApplication", 0);
      98                 :          0 :   g_application_set_inactivity_timeout (app, 10000);
      99                 :          0 :   g_signal_connect (app, "command-line", G_CALLBACK (command_line), NULL);
     100                 :            : 
     101                 :          0 :   status = g_application_run (app, argc, argv);
     102                 :            : 
     103                 :          0 :   g_object_unref (app);
     104                 :            : 
     105                 :          0 :   return status;
     106                 :            : }

Generated by: LCOV version 1.14