[Spice-devel] [PATCH spice-gtk 1/3] SpiceDisplay: Pass on notify signal from GtkSession for GtkSession properties

Marc-André Lureau mlureau at redhat.com
Fri Oct 7 05:37:30 PDT 2011


ack

----- Original Message -----
> Since some SpiceDisplay properties are now just a pass through to the
> equivalent SpiceGtkSession property, we also need to pass on the
> notify
> signal for these, so interested users can get notified of them
> changing.
> 
> Use this in spicy to ensure that changes to SpiceGtkSession (and thus
> per
> session rather then per window) properties get reflected in all
> windows for
> a multimonitor guest.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  gtk/spice-widget.c |   12 ++++++++++++
>  gtk/spicy.c        |   20 ++++++++++++++++++++
>  2 files changed, 32 insertions(+), 0 deletions(-)
> 
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index 5b53caf..06e5113 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -226,6 +226,15 @@ static void spice_display_set_property(GObject
>      *object,
>      }
>  }
>  
> +static void gtk_session_property_changed(GObject    *gobject,
> +                                         GParamSpec *pspec,
> +                                         gpointer    user_data)
> +{
> +    SpiceDisplay *display = user_data;
> +
> +    g_object_notify(G_OBJECT(display),
> g_param_spec_get_name(pspec));
> +}
> +
>  static void spice_display_dispose(GObject *obj)
>  {
>      SpiceDisplay *display = SPICE_DISPLAY(obj);
> @@ -329,6 +338,9 @@ spice_display_constructor(GType
>                  gtype,
>      }
>      g_list_free(list);
>  
> +    g_signal_connect(d->gtk_session, "notify::auto-clipboard",
> +                     G_CALLBACK(gtk_session_property_changed),
> display);
> +
>      return obj;
>  }
>  
> diff --git a/gtk/spicy.c b/gtk/spicy.c
> index 77f339c..533d7f7 100644
> --- a/gtk/spicy.c
> +++ b/gtk/spicy.c
> @@ -427,6 +427,20 @@ static void menu_cb_bool_prop(GtkToggleAction
> *action, gpointer data)
>      g_object_set(G_OBJECT(win->spice), name, state, NULL);
>  }
>  
> +static void menu_cb_bool_prop_changed(GObject    *gobject,
> +                                      GParamSpec *pspec,
> +                                      gpointer    user_data)
> +{
> +    struct spice_window *win = user_data;
> +    const gchar *property = g_param_spec_get_name(pspec);
> +    GtkAction *toggle;
> +    gboolean state;
> +
> +    toggle = gtk_action_group_get_action(win->ag, property);
> +    g_object_get(win->spice, property, &state, NULL);
> +    gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggle), state);
> +}
> +
>  static void menu_cb_toolbar(GtkToggleAction *action, gpointer data)
>  {
>      struct spice_window *win = data;
> @@ -1133,9 +1147,15 @@ static spice_window
> *create_spice_window(spice_connection *conn, int id, SpiceCh
>  
>      /* init toggle actions */
>      for (i = 0; i < G_N_ELEMENTS(spice_properties); i++) {
> +        char notify[64];
> +
>          toggle = gtk_action_group_get_action(win->ag,
>          spice_properties[i]);
>          g_object_get(win->spice, spice_properties[i], &state, NULL);
>          gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggle),
>          state);
> +
> +        snprintf(notify, sizeof(notify), "notify::%s",
> spice_properties[i]);
> +        g_signal_connect(win->spice, notify,
> +                         G_CALLBACK(menu_cb_bool_prop_changed),
> win);
>      }
>  
>      toggle = gtk_action_group_get_action(win->ag, "Toolbar");
> --
> 1.7.6.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list