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

Marc-André Lureau marcandre.lureau at gmail.com
Thu Oct 6 12:00:30 PDT 2011


On Thu, Oct 6, 2011 at 8:07 PM, Hans de Goede <hdegoede at redhat.com> wrote:
> 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 2ee9855..b52a2fa 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_by_pspec(G_OBJECT(display), pspec);
> +}
> +

Didn't try it is this really working?

pspec here is the pspec of GtkSession and you are reusing it for
Display. You should put the Display one instead.

Perhaps the name of the function can be tad misleading too, something
more specific would help.

>  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 a118ecd..bf77a9f 100644
> --- a/gtk/spicy.c
> +++ b/gtk/spicy.c
> @@ -423,6 +423,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;
> @@ -1129,9 +1143,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
>



-- 
Marc-André Lureau


More information about the Spice-devel mailing list