gboolean
some_object_get_tuple (SomeObject *obj, GValueArray **ret, GError **error)
{
  *ret = g_value_array_new (6);
  g_value_array_prepend (*ret, NULL);
  g_value_init (g_value_array_get_nth (*ret, 0), G_TYPE_STRING);
  g_value_set_string (g_value_array_get_nth (*ret, 0), "hello");
  g_value_array_prepend (*ret, NULL);
  g_value_init (g_value_array_get_nth (*ret, 0), G_TYPE_UINT);
  g_value_set_uint (g_value_array_get_nth (*ret, 0), 42);
  
  return TRUE;
}
Example #2
0
static void
change_background(PanelApplet * widget,
                  PanelAppletBackgroundType type,
                  GdkColor * color,
                  GdkPixmap * pixmap,
                  void *data)
{
  static GdkPixmap *keep = NULL;
  long xid = 0;
  GValueArray *val = g_value_array_new(4);

  if (type == PANEL_NO_BACKGROUND)
    {
      GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(widget));

      if (style->bg_pixmap[GTK_STATE_NORMAL])
        {
          pixmap = style->bg_pixmap[GTK_STATE_NORMAL];
          type = PANEL_PIXMAP_BACKGROUND;
        }
      else
        {
          color = &style->bg[GTK_STATE_NORMAL];
          if (color != NULL)
            {
              type = PANEL_COLOR_BACKGROUND;
            }
        }
    }
  
  if (type == PANEL_COLOR_BACKGROUND && color != NULL)
    {
      g_value_array_append(val, NULL);
      g_value_init(g_value_array_get_nth(val, 0), G_TYPE_UINT);
      g_value_set_uint(g_value_array_get_nth(val, 0), color->pixel);
 
      g_value_array_append(val, NULL);
      g_value_init(g_value_array_get_nth(val, 1), G_TYPE_UINT);
      g_value_set_uint(g_value_array_get_nth(val, 1), color->red);
      
      g_value_array_append(val, NULL);
      g_value_init(g_value_array_get_nth(val, 2), G_TYPE_UINT);
      g_value_set_uint(g_value_array_get_nth(val, 2), color->green);

      g_value_array_append(val, NULL);
      g_value_init(g_value_array_get_nth(val, 3), G_TYPE_UINT);
      g_value_set_uint(g_value_array_get_nth(val, 3), color->blue);
    }
  else
    {
      int i;
      for (i = 0; i < 4; i++)
        {
          g_value_array_prepend(val, NULL);
          g_value_init(g_value_array_get_nth(val, 0), G_TYPE_UINT);
          g_value_set_uint(g_value_array_get_nth(val, 0), 0);
        }
    }
  
  if (type == PANEL_PIXMAP_BACKGROUND)
    {
      if (keep != NULL)
        {
          gdk_pixmap_unref(keep);
          keep = pixmap;
        }
      if (pixmap != NULL)
        {
          gdk_pixmap_ref(pixmap);
        }

      xid = GDK_PIXMAP_XID(pixmap);
    }

  if (g_applet->support != NULL && workrave_is_running())
    {
      dbus_g_proxy_begin_call(g_applet->support, "SetBackground", dbus_callback, NULL, NULL,
                              G_TYPE_UINT, type,
                              G_TYPE_VALUE_ARRAY, val,
                              G_TYPE_UINT, xid,
                              G_TYPE_INVALID);
      

    }

  g_value_array_free(val);
}