Beispiel #1
0
static void
add_dock_item (GladeXML *xml, 
	       GtkWidget *parent,
	       GladeWidgetInfo *info,
	       GladeChildInfo *childinfo)
{
	BonoboDockPlacement placement;
	guint band, offset;
	int position;
	int i;
	GtkWidget *child;
	
	band = offset = position = 0;
	placement = BONOBO_DOCK_TOP;
	
	for (i = 0; i < childinfo->n_properties; i++) {
		const char *name  = childinfo->properties[i].name;
		const char *value = childinfo->properties[i].value;
		
		if (!strcmp (name, "placement"))
			placement = glade_enum_from_string (
				BONOBO_TYPE_DOCK_PLACEMENT,
				value);
		else if (!strcmp (name, "band"))
			band = UINT (value);
		else if (!strcmp (name, "position"))
			position = INT (value);
		else if (!strcmp (name, "offset"))
			offset = UINT (value);
	}

	child = glade_xml_build_widget (xml, childinfo->child);

	bonobo_dock_add_item (BONOBO_DOCK (parent),
			      BONOBO_DOCK_ITEM (child),
			      placement, band, position, offset, 
			      FALSE);
}
Beispiel #2
0
static void
gb_bonobo_dock_item_add_item (BonoboDockItem * existing_dock_item,
			     gboolean after)
{
  BonoboDock *dock;
  BonoboDockBand *dock_band;
  GtkWidget *dock_item, *placeholder;
  BonoboDockPlacement placement;
  gint band_num, position, offset;

  if (!gb_bonobo_dock_item_find_position (BONOBO_DOCK_ITEM (existing_dock_item),
					 &placement, &band_num,
					 &position, &offset))
    {
      g_warning ("Dock band not found");
      return;
    }

  dock_band = BONOBO_DOCK_BAND (GTK_WIDGET (existing_dock_item)->parent);
  dock = BONOBO_DOCK (GTK_WIDGET (dock_band)->parent);

  /* Create the new dock item. */
  dock_item = gb_widget_new ("BonoboDockItem", NULL);

  placeholder = editor_new_placeholder ();
  gtk_container_add (GTK_CONTAINER (dock_item), placeholder);

  /* Now add it at the required position. */
  if (after)
    position++;
  bonobo_dock_add_item (dock, BONOBO_DOCK_ITEM (dock_item), placement, band_num,
		       position, 0, FALSE);

  gtk_widget_show (dock_item);

  /* Show the properties of the new dock item. */
  gb_widget_show_properties (dock_item);
}