[Spice-devel] spicy: add --title=<title> command line option

Submitted by Uri Lublin on Sept. 5, 2012, 9:35 a.m.

Details

Message ID 0e5e090436fe66bf19fc7b78985db0d9616682bb.1346837502.git.uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin Sept. 5, 2012, 9:35 a.m.
---

This simplifies using Alon's copy/paste test script, which requires
the window title string

---
 gtk/spicy.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/gtk/spicy.c b/gtk/spicy.c
index 8b3b087..1fc544b 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -123,6 +123,7 @@  static void del_window(spice_connection *conn, SpiceWindow *win);
 /* options */
 static gboolean fullscreen = false;
 static gboolean version = false;
+static char *spicy_title = NULL;
 /* globals */
 static GMainLoop     *mainloop = NULL;
 static int           connections = 0;
@@ -1173,7 +1174,12 @@  static SpiceWindow *create_spice_window(spice_connection *conn, SpiceChannel *ch
 
     /* toplevel */
     win->toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    snprintf(title, sizeof(title), _("spice display %d:%d"), id, monitor_id);
+    if (spicy_title == NULL) {
+        snprintf(title, sizeof(title), _("spice display %d:%d"), id, monitor_id);
+    } else {
+        snprintf(title, sizeof(title), "%s", spicy_title);
+    }
+
     gtk_window_set_title(GTK_WINDOW(win->toplevel), title);
     g_signal_connect(G_OBJECT(win->toplevel), "window-state-event",
                      G_CALLBACK(window_state_cb), win);
@@ -1741,6 +1747,12 @@  static GOptionEntry cmd_entries[] = {
         .arg_data         = &version,
         .description      = N_("Display version and quit"),
     },{
+        .long_name        = "title",
+        .arg              = G_OPTION_ARG_STRING,
+        .arg_data         = &spicy_title,
+        .description      = N_("Set the window title"),
+        .arg_description  = N_("<title>"),
+    },{
         /* end of list */
     }
 };
@@ -1907,5 +1919,9 @@  int main(int argc, char *argv[])
     g_free(conf);
     g_key_file_free(keyfile);
 
+    if (spicy_title) {
+        g_free(spicy_title);
+    }
+
     return 0;
 }

Comments

ack

----- Original Message -----
> ---
> 
> This simplifies using Alon's copy/paste test script, which requires
> the window title string
> 
> ---
>  gtk/spicy.c |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/gtk/spicy.c b/gtk/spicy.c
> index 8b3b087..1fc544b 100644
> --- a/gtk/spicy.c
> +++ b/gtk/spicy.c
> @@ -123,6 +123,7 @@ static void del_window(spice_connection *conn,
> SpiceWindow *win);
>  /* options */
>  static gboolean fullscreen = false;
>  static gboolean version = false;
> +static char *spicy_title = NULL;
>  /* globals */
>  static GMainLoop     *mainloop = NULL;
>  static int           connections = 0;
> @@ -1173,7 +1174,12 @@ static SpiceWindow
> *create_spice_window(spice_connection *conn, SpiceChannel *ch
>  
>      /* toplevel */
>      win->toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> -    snprintf(title, sizeof(title), _("spice display %d:%d"), id,
> monitor_id);
> +    if (spicy_title == NULL) {
> +        snprintf(title, sizeof(title), _("spice display %d:%d"), id,
> monitor_id);
> +    } else {
> +        snprintf(title, sizeof(title), "%s", spicy_title);
> +    }
> +
>      gtk_window_set_title(GTK_WINDOW(win->toplevel), title);
>      g_signal_connect(G_OBJECT(win->toplevel), "window-state-event",
>                       G_CALLBACK(window_state_cb), win);
> @@ -1741,6 +1747,12 @@ static GOptionEntry cmd_entries[] = {
>          .arg_data         = &version,
>          .description      = N_("Display version and quit"),
>      },{
> +        .long_name        = "title",
> +        .arg              = G_OPTION_ARG_STRING,
> +        .arg_data         = &spicy_title,
> +        .description      = N_("Set the window title"),
> +        .arg_description  = N_("<title>"),
> +    },{
>          /* end of list */
>      }
>  };
> @@ -1907,5 +1919,9 @@ int main(int argc, char *argv[])
>      g_free(conf);
>      g_key_file_free(keyfile);
>  
> +    if (spicy_title) {
> +        g_free(spicy_title);
> +    }
> +
>      return 0;
>  }
> --
> 1.7.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
2012/9/5 Uri Lublin <uril@redhat.com>:
> ---
>
> This simplifies using Alon's copy/paste test script, which requires
> the window title string
>
> ---
>  gtk/spicy.c |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
>
> diff --git a/gtk/spicy.c b/gtk/spicy.c
> index 8b3b087..1fc544b 100644
> --- a/gtk/spicy.c
> +++ b/gtk/spicy.c
> @@ -123,6 +123,7 @@ static void del_window(spice_connection *conn, SpiceWindow *win);
>  /* options */
>  static gboolean fullscreen = false;
>  static gboolean version = false;
> +static char *spicy_title = NULL;
>  /* globals */
>  static GMainLoop     *mainloop = NULL;
>  static int           connections = 0;
> @@ -1173,7 +1174,12 @@ static SpiceWindow *create_spice_window(spice_connection *conn, SpiceChannel *ch
>
>      /* toplevel */
>      win->toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> -    snprintf(title, sizeof(title), _("spice display %d:%d"), id, monitor_id);
> +    if (spicy_title == NULL) {
> +        snprintf(title, sizeof(title), _("spice display %d:%d"), id, monitor_id);
> +    } else {
> +        snprintf(title, sizeof(title), "%s", spicy_title);
> +    }
> +
>      gtk_window_set_title(GTK_WINDOW(win->toplevel), title);
>      g_signal_connect(G_OBJECT(win->toplevel), "window-state-event",
>                       G_CALLBACK(window_state_cb), win);
> @@ -1741,6 +1747,12 @@ static GOptionEntry cmd_entries[] = {
>          .arg_data         = &version,
>          .description      = N_("Display version and quit"),
>      },{
> +        .long_name        = "title",
> +        .arg              = G_OPTION_ARG_STRING,
> +        .arg_data         = &spicy_title,
> +        .description      = N_("Set the window title"),
> +        .arg_description  = N_("<title>"),
> +    },{
>          /* end of list */
>      }
>  };
> @@ -1907,5 +1919,9 @@ int main(int argc, char *argv[])
>      g_free(conf);
>      g_key_file_free(keyfile);
>
> +    if (spicy_title) {
> +        g_free(spicy_title);
> +    }
g_free() dont need to check for NULL pointer
> +
>      return 0;
>  }
> --
> 1.7.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
On 09/05/2012 12:42 PM, Dunrong Huang wrote:
> 2012/9/5 Uri Lublin<uril@redhat.com>:
>> @@ -1907,5 +1919,9 @@ int main(int argc, char *argv[])
>>       g_free(conf);
>>       g_key_file_free(keyfile);
>>
>> +    if (spicy_title) {
>> +        g_free(spicy_title);
>> +    }
> g_free() dont need to check for NULL pointer

Thanks, pushed without checking for NULL pointer.