Example #1
0
void GfxSquareBrush::drawStyle(GnomeCanvasItem *rb, GdkBitmap *stipple,
			    GdkBitmap *stubble, const guint32 &black,
			    const guint32 &white, const Coord &current) {
  GnomeCanvasPoints *pts = gnome_canvas_points_new(4);
  pts->coords[0] = current(0) - size;
  pts->coords[1] = current(1) + size;
  pts->coords[2] = current(0) - size;
  pts->coords[3] = current(1) - size;
  pts->coords[4] = current(0) + size;
  pts->coords[5] = current(1) - size;
  pts->coords[6] = current(0) + size;
  pts->coords[7] = current(1) + size;
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
					  gnome_canvas_polygon_get_type(),
					  "points", pts,
					  "outline_color_rgba", black,
					  "width_pixels", 0,
					  "outline_stipple", stipple,
					  NULL);
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
					  gnome_canvas_polygon_get_type(),
					  "points", pts,
					  "outline_color_rgba", white,
					  "width_pixels", 0,
					  "outline_stipple", stubble,
					  NULL);
}
Example #2
0
static void
create_rect_and_text (ETableClickToAdd *etcta)
{
	GtkWidget *widget;
	GdkColor fg, bg;

	widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etcta)->canvas);

	e_utils_get_theme_color_color (widget, "theme_selected_fg_color", E_UTILS_DEFAULT_THEME_SELECTED_FG_COLOR, &fg);
	e_utils_get_theme_color_color (widget, "theme_selected_bg_color", E_UTILS_DEFAULT_THEME_SELECTED_BG_COLOR, &bg);

	if (!etcta->rect)
		etcta->rect = gnome_canvas_item_new (
			GNOME_CANVAS_GROUP (etcta),
			gnome_canvas_rect_get_type (),
			"x1", (gdouble) 0,
			"y1", (gdouble) 1,
			"x2", (gdouble) etcta->width,
			"y2", (gdouble) etcta->height,
			"fill_color_gdk", &bg,
			NULL);

	if (!etcta->text)
		etcta->text = gnome_canvas_item_new (
			GNOME_CANVAS_GROUP (etcta),
			e_text_get_type (),
			"text", etcta->message ? etcta->message : "",
			"width", etcta->width - 4,
			"fill_color_gdk", &fg,
			NULL);
}
Example #3
0
static gboolean
bst_canvas_link_build_async (gpointer data)
{
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (data);
  if (gnome_canvas_item_check_undisposed (item))
    {
      BstCanvasLink *clink = BST_CANVAS_LINK (item);
      if (!clink->arrow)
        clink->arrow = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                                GNOME_TYPE_CANVAS_POLYGON,
                                                                "outline_color_rgba", 0x000000ff,
                                                                "fill_color_rgba", 0xff0000ff,
                                                                NULL),
                                         "signal::destroy", gtk_widget_destroyed, &clink->arrow,
                                         "swapped_signal::event", bst_canvas_link_child_event, clink,
                                         NULL);
      if (!clink->tag_start)
        clink->tag_start = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                                    GNOME_TYPE_CANVAS_ELLIPSE,
                                                                    "outline_color_rgba", 0x000000ff, // xffff00ff,
                                                                    "fill_color_rgba", 0xffff00ff,
                                                                    NULL),
                                             "signal::destroy", gtk_widget_destroyed, &clink->tag_start,
                                             "swapped_signal::event", bst_canvas_link_child_event, clink,
                                             NULL);
      if (!clink->tag_end)
        {
          gboolean is_jchannel = FALSE;
          if (clink->icsource)
            is_jchannel = bst_canvas_source_is_jchannel (clink->icsource, clink->ichannel);
          clink->tag_end = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                                    GNOME_TYPE_CANVAS_ELLIPSE,
                                                                    "outline_color_rgba", 0x000000ff, // 0xff0000ff,
                                                                    "fill_color_rgba", is_jchannel ? 0x00ff00ff : 0xff0000ff,
                                                                    NULL),
                                             "signal::destroy", gtk_widget_destroyed, &clink->tag_end,
                                             "swapped_signal::event", bst_canvas_link_child_event, clink,
                                             NULL);
        }
      if (!clink->line)
        clink->line = g_object_connect (gnome_canvas_item_new (GNOME_CANVAS_GROUP (clink),
                                                               GNOME_TYPE_CANVAS_LINE,
                                                               "fill_color", "black",
                                                               NULL),
                                        "signal::destroy", gtk_widget_destroyed, &clink->line,
                                        "swapped_signal::notify", bst_canvas_link_adjust_arrow, clink,
                                        "swapped_signal::notify", bst_canvas_link_adjust_tags, clink,
                                        NULL);
      bst_canvas_link_update (clink);
    }
  GnomeCanvas *canvas = g_object_steal_data (item, "bst-workaround-canvas-ref");
  g_object_unref (item);
  if (canvas)
    g_object_unref (canvas);      /* canvases don't properly protect their items */
  return FALSE;
}
static ETableGroupContainerChildNode *
create_child_node (ETableGroupContainer *etgc, void *val)
{
	ETableGroup *child;
	ETableGroupContainerChildNode *child_node;
	ETableGroup *etg = E_TABLE_GROUP(etgc);

	child_node = g_new (ETableGroupContainerChildNode, 1);
	child_node->rect = gnome_canvas_item_new (GNOME_CANVAS_GROUP (etgc),
						  gnome_canvas_rect_get_type (),
						  "fill_color", "grey70",
						  "outline_color", "grey50",
						  NULL);
	child_node->text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (etgc),
						  e_text_get_type (),
						  "anchor", GTK_ANCHOR_SW,
						  "fill_color", "black",
						  "draw_background", FALSE,
						  NULL);
	child = e_table_group_new (GNOME_CANVAS_GROUP (etgc), etg->full_header,
				   etg->header, etg->model, etgc->sort_info, etgc->n + 1);
	gnome_canvas_item_set(GNOME_CANVAS_ITEM(child),
			      "alternating_row_colors", etgc->alternating_row_colors,
			      "horizontal_draw_grid", etgc->horizontal_draw_grid,
			      "vertical_draw_grid", etgc->vertical_draw_grid,
			      "drawfocus", etgc->draw_focus,
			      "cursor_mode", etgc->cursor_mode,
			      "selection_model", etgc->selection_model,
			      "length_threshold", etgc->length_threshold,
			      "uniform_row_height", etgc->uniform_row_height,
			      "minimum_width", etgc->minimum_width - GROUP_INDENT,
			      NULL);

	g_signal_connect (child, "cursor_change",
			  G_CALLBACK (child_cursor_change), etgc);
	g_signal_connect (child, "cursor_activated",
			  G_CALLBACK (child_cursor_activated), etgc);
	g_signal_connect (child, "double_click",
			  G_CALLBACK (child_double_click), etgc);
	g_signal_connect (child, "right_click",
			  G_CALLBACK (child_right_click), etgc);
	g_signal_connect (child, "click",
			  G_CALLBACK (child_click), etgc);
	g_signal_connect (child, "key_press",
			  G_CALLBACK (child_key_press), etgc);
	g_signal_connect (child, "start_drag",
			  G_CALLBACK (child_start_drag), etgc);
	child_node->child = child;
	child_node->key = e_table_model_duplicate_value (etg->model, etgc->ecol->col_idx, val);
	child_node->string = e_table_model_value_to_string (etg->model, etgc->ecol->col_idx, val);
	child_node->count = 0;

	return child_node;
}
Example #5
0
static void
e_minicard_label_realize (GnomeCanvasItem *item)
{
	EMinicardLabel *e_minicard_label;
	GnomeCanvasGroup *group;

	e_minicard_label = E_MINICARD_LABEL (item);
	group = GNOME_CANVAS_GROUP ( item );

	if (GNOME_CANVAS_ITEM_CLASS ( parent_class )->realize)
		(* GNOME_CANVAS_ITEM_CLASS ( parent_class )->realize) (item);

	e_canvas_item_request_reflow (item);

	e_minicard_label->rect =
	  gnome_canvas_item_new ( group,
				 gnome_canvas_rect_get_type (),
				 "x1", (double) 0,
				 "y1", (double) 0,
				 "x2", (double) e_minicard_label->width - 1,
				 "y2", (double) e_minicard_label->height - 1,
				 "outline_color", NULL,
				 NULL );
	e_minicard_label->fieldname =
	  gnome_canvas_item_new ( group,
				 e_text_get_type (),
				 "clip_width", (double) ( e_minicard_label->width / 2 - 4 ),
				 "clip", TRUE,
				 "use_ellipsis", TRUE,
				 "fill_color", "black",
				 "draw_background", FALSE,
				 "im_context", E_CANVAS (item->canvas)->im_context,
				 NULL );
	e_canvas_item_move_absolute (e_minicard_label->fieldname, 2, 1);

	e_minicard_label->field =
	  gnome_canvas_item_new ( group,
				 e_text_get_type (),
				 "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ),
				 "clip", TRUE,
				 "use_ellipsis", TRUE,
				 "fill_color", "black",
				 "editable", FALSE, /* e_minicard_label->editable, */
				 "draw_background", FALSE,
				 "im_context", E_CANVAS (item->canvas)->im_context,
				 NULL );
	e_canvas_item_move_absolute (e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1);

	set_colors (e_minicard_label);

	e_canvas_item_request_reflow (item);
}
Example #6
0
/* Goes through all known links and checks whether there already exists
 * a corresponding canvas_link. If not, create it.*/
static gint
check_new_link (link_id_t * link_id, link_t * link, GtkWidget * canvas)
{
  canvas_link_t *new_canvas_link;
  GnomeCanvasGroup *group;
  GnomeCanvasPoints *points;
  guint i = 0;

  if (!g_tree_lookup (canvas_links, link_id))
    {
      group = gnome_canvas_root (GNOME_CANVAS (canvas));

      new_canvas_link = g_malloc (sizeof (canvas_link_t));
      g_assert(new_canvas_link);
      new_canvas_link->canvas_link_id = *link_id;

      /* We set the lines position using groups positions */
      points = gnome_canvas_points_new (3);

      for (; i <= 5; i++)
	points->coords[i] = 0.0;

      new_canvas_link->src_item
	= gnome_canvas_item_new (group,
				 gnome_canvas_polygon_get_type (),
				 "points", points, "fill_color", "tan", NULL);
      addref_canvas_obj(G_OBJECT (new_canvas_link->src_item));

      new_canvas_link->dst_item
	= gnome_canvas_item_new (group,
				 gnome_canvas_polygon_get_type (),
				 "points", points, "fill_color", "tan", NULL);
      addref_canvas_obj(G_OBJECT (new_canvas_link->dst_item));

      g_tree_insert (canvas_links,
		     &new_canvas_link->canvas_link_id, new_canvas_link);
      gnome_canvas_item_lower_to_bottom (new_canvas_link->src_item);
      gnome_canvas_item_lower_to_bottom (new_canvas_link->dst_item);

      gnome_canvas_points_unref (points);

      g_signal_connect (G_OBJECT (new_canvas_link->src_item), "event",
			(GtkSignalFunc) link_item_event, new_canvas_link);
      g_signal_connect (G_OBJECT (new_canvas_link->dst_item), "event",
			(GtkSignalFunc) link_item_event, new_canvas_link);

    }

  return FALSE;
}				/* check_new_link */
Example #7
0
File: about.c Project: timxx/zenity
static GtkWidget *
zenity_create_monk (void)
{
  GtkWidget *canvas_board;
  GnomeCanvasItem *canvas_item;
  GdkPixbuf *pixbuf;
  GdkColor color = { 0, 0xffff, 0xffff, 0xffff };

  canvas_board = gnome_canvas_new ();

  gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0,
                                  ZENITY_CANVAS_X, ZENITY_CANVAS_Y);

  gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y);

  gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)),
                            &color, FALSE, TRUE);

  gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color);

  pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL);

  canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
                                       GNOME_TYPE_CANVAS_PIXBUF,
                                       "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0,
                                       "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0,
                                       "pixbuf", pixbuf,
                                       "anchor", GTK_ANCHOR_NW,
                                       NULL);

  zenity_create_clothes (canvas_board);

  return canvas_board;
}
Example #8
0
void
ghack_map_cursor_to(GtkWidget *win, int x, int y, gpointer data)
{
    GnomeCanvasGroup *group;
    static GnomeCanvasRE *cursor = NULL;

    double x1, y1, x2, y2;
    float hp;
    guint r, g, b;

    x1 = x * ghack_glyph_width() - 1;
    y1 = y * ghack_glyph_height() - 1;
    x2 = x1 + ghack_glyph_width() + 2;
    y2 = y1 + ghack_glyph_height() + 2;
    hp = u.mtimedone ? (u.mhmax ? (float) u.mh / u.mhmax : 1)
         : (u.uhpmax ? (float) u.uhp / u.uhpmax : 1);

    r = 255;
    g = (hp >= 0.75) ? 255 : (hp >= 0.25 ? 255 * 2 * (hp - 0.25) : 0);
    b = (hp >= 0.75) ? 255 * 4 * (hp - 0.75)
        : (hp >= 0.25 ? 0 : 255 * 4 * (0.25 - hp));

    group = gnome_canvas_root(GNOME_CANVAS(ghack_map.canvas));

    if (!cursor) {
        cursor = GNOME_CANVAS_RE(gnome_canvas_item_new(
                                     group, gnome_canvas_rect_get_type(), "width_units", 1.0, NULL));
    }
    gnome_canvas_item_set(GNOME_CANVAS_ITEM(cursor), "outline_color_rgba",
                          GNOME_CANVAS_COLOR(r, g, b), "x1", x1, "y1", y1,
                          "x2", x2, "y2", y2, NULL);

    gnome_canvas_item_raise_to_top(GNOME_CANVAS_ITEM(cursor));
    gnome_canvas_item_show(GNOME_CANVAS_ITEM(cursor));
}
Example #9
0
void start_selectregion(GdkEvent *event)
{
  double pt[2];
  reset_selection();
  
  ui.cur_item_type = ITEM_SELECTREGION;
  ui.selection = g_new(struct Selection, 1);
  ui.selection->type = ITEM_SELECTREGION;
  ui.selection->items = NULL;
  ui.selection->layer = ui.cur_layer;

  get_pointer_coords(event, pt);
  ui.selection->bbox.left = ui.selection->bbox.right = pt[0];
  ui.selection->bbox.top = ui.selection->bbox.bottom = pt[1];
  
  realloc_cur_path(1);
  ui.cur_path.num_points = 1;
  ui.cur_path.coords[0] = ui.cur_path.coords[2] = pt[0];
  ui.cur_path.coords[1] = ui.cur_path.coords[3] = pt[1];
 
  ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group,
      gnome_canvas_polygon_get_type(), "width-pixels", 1, 
      "outline-color-rgba", 0x000000ff,
      "fill-color-rgba", 0x80808040,
      NULL);
  make_dashed(ui.selection->canvas_item);
  update_cursor();
}
Example #10
0
GnomeCanvasItem*
bst_canvas_source_new (GnomeCanvasGroup *group,
		       SfiProxy		 source)
{
  BstCanvasSource *csource;
  GnomeCanvasItem *item;

  g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (group), NULL);
  g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);

  item = gnome_canvas_item_new (group,
				BST_TYPE_CANVAS_SOURCE,
				NULL);
  csource = BST_CANVAS_SOURCE (item);
  csource->source = bse_item_use (source);
  bse_proxy_connect (csource->source,
		     "swapped_signal::release", gtk_object_destroy, csource,
		     "swapped_signal::io_changed", source_channels_changed, csource,
		     "swapped_signal::property-notify::uname", source_name_changed, csource,
		     "swapped_signal::property-notify::pos-x", source_pos_changed, csource,
		     "swapped_signal::property-notify::pos-y", source_pos_changed, csource,
		     "swapped_signal::icon-changed", source_icon_changed, csource,
		     NULL);

  canvas_source_set_position (csource);
  bst_canvas_source_build (csource);
  
  GNOME_CANVAS_NOTIFY (item);
  
  return item;
}
Example #11
0
SkinStatusBar *
skin_status_bar_new(GnomeCanvasGroup *root, const gchar *first_arg_name, ...)
{
	SkinStatusBar *status_bar;
	SkinStatusBarPrivate *priv;
	GnomeCanvasItem *item;
	va_list args;

	g_return_val_if_fail(GNOME_IS_CANVAS_GROUP(root), NULL);
	
	item = gnome_canvas_item_new(root,
			skin_status_bar_get_type(),
			NULL);

	g_return_val_if_fail(GNOME_IS_CANVAS_ITEM(item), NULL);

	status_bar = SKIN_STATUS_BAR(item);
	priv = status_bar->priv;

	va_start(args, first_arg_name);
	skin_status_bar_construct(status_bar, root, first_arg_name, args);
	va_end(args);

	return status_bar;
}
Example #12
0
GtkWidget *
gnc_header_new (GnucashSheet *sheet)
{
    GnomeCanvasGroup *group;
    GnomeCanvasItem *item;
    GtkWidget *canvas;

    canvas = gnome_canvas_new ();

    g_signal_connect (G_OBJECT (canvas), "realize",
                      G_CALLBACK (gnc_header_realized),
                      NULL);

    group = GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas)->root);

    item = gnome_canvas_item_new (group,
                                  gnc_header_get_type (),
                                  "sheet", sheet,
                                  "cursor_name", CURSOR_HEADER,
                                  NULL);

    sheet->header_item = item;

    gtk_widget_show (canvas);

    return canvas;
}
Example #13
0
static void
etgl_realize (GnomeCanvasItem *item)
{
	ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (item);

	if (GNOME_CANVAS_ITEM_CLASS (e_table_group_leaf_parent_class)->realize)
		GNOME_CANVAS_ITEM_CLASS (e_table_group_leaf_parent_class)->realize (item);

	etgl->item = E_TABLE_ITEM (gnome_canvas_item_new (
		GNOME_CANVAS_GROUP (etgl),
		e_table_item_get_type (),
		"ETableHeader", E_TABLE_GROUP (etgl)->header,
		"ETableModel", etgl->ets,
		"alternating_row_colors", etgl->alternating_row_colors,
		"horizontal_draw_grid", etgl->horizontal_draw_grid,
		"vertical_draw_grid", etgl->vertical_draw_grid,
		"drawfocus", etgl->draw_focus,
		"cursor_mode", etgl->cursor_mode,
		"minimum_width", etgl->minimum_width,
		"length_threshold", etgl->length_threshold,
		"selection_model", etgl->selection_model,
		"uniform_row_height", etgl->uniform_row_height,
		NULL));

	etgl->etgl_cursor_change_id = g_signal_connect (
		etgl->item, "cursor_change",
		G_CALLBACK (etgl_cursor_change), etgl);

	etgl->etgl_cursor_activated_id = g_signal_connect (
		etgl->item, "cursor_activated",
		G_CALLBACK (etgl_cursor_activated), etgl);

	etgl->etgl_double_click_id = g_signal_connect (
		etgl->item, "double_click",
		G_CALLBACK (etgl_double_click), etgl);

	etgl->etgl_right_click_id = g_signal_connect (
		etgl->item, "right_click",
		G_CALLBACK (etgl_right_click), etgl);

	etgl->etgl_click_id = g_signal_connect (
		etgl->item, "click",
		G_CALLBACK (etgl_click), etgl);

	etgl->etgl_key_press_id = g_signal_connect (
		etgl->item, "key_press",
		G_CALLBACK (etgl_key_press), etgl);

	etgl->etgl_start_drag_id = g_signal_connect (
		etgl->item, "start_drag",
		G_CALLBACK (etgl_start_drag), etgl);

	etgl->notify_is_editing_id = e_signal_connect_notify (
		etgl->item, "notify::is-editing",
		G_CALLBACK (etgl_item_is_editing_changed_cb), etgl);

	e_canvas_item_request_reflow (item);
}
Example #14
0
// paste external text
void clipboard_paste_text(gchar *text)
{
  struct Item *item;
  double pt[2];

  reset_selection();
  get_current_pointer_coords(pt);
  set_current_page(pt);  

  ui.selection = g_new(struct Selection, 1);
  ui.selection->type = ITEM_SELECTRECT;
  ui.selection->layer = ui.cur_layer;
  ui.selection->items = NULL;

  item = g_new(struct Item, 1);
  ui.selection->items = g_list_append(ui.selection->items, item);
  ui.cur_layer->items = g_list_append(ui.cur_layer->items, item);
  ui.cur_layer->nitems++;
  item->type = ITEM_TEXT;
  g_memmove(&(item->brush), &(ui.brushes[ui.cur_mapping][TOOL_PEN]), sizeof(struct Brush));
  item->text = text; // text was newly allocated, we keep it
  item->font_name = g_strdup(ui.font_name);
  item->font_size = ui.font_size;
  item->bbox.left = pt[0]; item->bbox.top = pt[1];
  make_canvas_item_one(ui.cur_layer->group, item);
  update_item_bbox(item);

  // move the text to fit on the page if needed
  if (item->bbox.right > ui.cur_page->width) item->bbox.left += ui.cur_page->width-item->bbox.right;
  if (item->bbox.left < 0) item->bbox.left = 0;
  if (item->bbox.bottom > ui.cur_page->height) item->bbox.top += ui.cur_page->height-item->bbox.bottom;
  if (item->bbox.top < 0) item->bbox.top = 0;
  gnome_canvas_item_set(item->canvas_item, "x", item->bbox.left, "y", item->bbox.top, NULL);
  update_item_bbox(item);
  
  ui.selection->bbox = item->bbox;
  ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group,
      gnome_canvas_rect_get_type(), "width-pixels", 1,
      "outline-color-rgba", 0x000000ff,
      "fill-color-rgba", 0x80808040,
      "x1", ui.selection->bbox.left, "x2", ui.selection->bbox.right, 
      "y1", ui.selection->bbox.top, "y2", ui.selection->bbox.bottom, NULL);
  make_dashed(ui.selection->canvas_item);

  prepare_new_undo();
  undo->type = ITEM_PASTE;
  undo->layer = ui.cur_layer;
  undo->itemlist = g_list_copy(ui.selection->items);  
  
  update_copy_paste_enabled();
  update_color_menu();
  update_thickness_buttons();
  update_color_buttons();
  update_font_button();  
  update_cursor(); // FIXME: can't know if pointer is within selection!
}
Example #15
0
void GfxCircleBrush::drawStyle(GnomeCanvasItem *rb, GdkBitmap *stipple,
			    GdkBitmap *stubble, const guint32 &black,
			    const guint32 &white, const Coord &current) {
  // Circle
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
 		      gnome_canvas_ellipse_get_type(),
 		      "x1", current(0)-r, "y1", (current(1)-r),
 		      "x2", current(0)+r, "y2", (current(1)+r),
 		      "outline_color_rgba", black,
 		      "outline_stipple", stipple,
 		      "width_pixels", 0,
 		      NULL);
  gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb),
 		      gnome_canvas_ellipse_get_type(),
 		      "x1", current(0)-r, "y1", (current(1)-r),
 		      "x2", current(0)+r, "y2", (current(1)+r),
 		      "outline_color_rgba", white,
 		      "outline_stipple", stubble,
 		      "width_pixels", 0,
 		      NULL);
}
Example #16
0
void create_image_from_pixbuf(GdkPixbuf *pixbuf, double *pt)
{
  double scale;
  struct Item *item;

  item = g_new(struct Item, 1);
  item->type = ITEM_IMAGE;
  item->canvas_item = NULL;
  item->bbox.left = pt[0];
  item->bbox.top = pt[1];
  item->image = pixbuf;
  item->image_png = NULL;
  item->image_png_len = 0;

  // Scale at native size, unless that won't fit, in which case we shrink it down.
  scale = 1 / ui.zoom;
  if ((scale * gdk_pixbuf_get_width(item->image)) > ui.cur_page->width - item->bbox.left)
    scale = (ui.cur_page->width - item->bbox.left) / gdk_pixbuf_get_width(item->image);
  if ((scale * gdk_pixbuf_get_height(item->image)) > ui.cur_page->height - item->bbox.top)
    scale = (ui.cur_page->height - item->bbox.top) / gdk_pixbuf_get_height(item->image);

  item->bbox.right = item->bbox.left + scale * gdk_pixbuf_get_width(item->image);
  item->bbox.bottom = item->bbox.top + scale * gdk_pixbuf_get_height(item->image);
  ui.cur_layer->items = g_list_append(ui.cur_layer->items, item);
  ui.cur_layer->nitems++;
  
  make_canvas_item_one(ui.cur_layer->group, item);

  // add undo information
  prepare_new_undo();
  undo->type = ITEM_IMAGE;
  undo->item = item;
  undo->layer = ui.cur_layer;
  ui.cur_item = NULL;
  ui.cur_item_type = ITEM_NONE;

  // select image
  reset_selection();
  ui.selection = g_new0(struct Selection, 1);
  ui.selection->type = ITEM_SELECTRECT;
  ui.selection->layer = ui.cur_layer;
  ui.selection->bbox = item->bbox;
  ui.selection->items = g_list_append(ui.selection->items, item);
  ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group,
      gnome_canvas_rect_get_type(), "width-pixels", 1,
      "outline-color-rgba", 0x000000ff,
      "fill-color-rgba", 0x80808040,
      "x1", ui.selection->bbox.left, "x2", ui.selection->bbox.right, 
      "y1", ui.selection->bbox.top, "y2", ui.selection->bbox.bottom, NULL);
  make_dashed(ui.selection->canvas_item);
  update_copy_paste_enabled();
}
Example #17
0
static void
finish_editing (ETableClickToAdd *etcta)
{
	if (etcta->row) {
		ETableModel *one;

		e_table_item_leave_edit (E_TABLE_ITEM (etcta->row));
		e_table_one_commit (E_TABLE_ONE (etcta->one));
		etcta_drop_one (etcta);
		g_object_run_dispose (G_OBJECT (etcta->row));
		etcta->row = NULL;

		if (etcta->text) {
			g_object_run_dispose (G_OBJECT (etcta->text));
			etcta->text = NULL;
		}
		if (etcta->rect) {
			g_object_run_dispose (G_OBJECT (etcta->rect));
			etcta->rect = NULL;
		}

		one = e_table_one_new (etcta->model);
		etcta_add_one (etcta, one);
		g_object_unref (one);

		e_selection_model_clear (E_SELECTION_MODEL (etcta->selection));

		etcta->row = gnome_canvas_item_new (
			GNOME_CANVAS_GROUP (etcta),
			e_table_item_get_type (),
			"ETableHeader", etcta->eth,
			"ETableModel", etcta->one,
			"minimum_width", etcta->width,
			"horizontal_draw_grid", TRUE,
			"vertical_draw_grid", TRUE,
			"selection_model", etcta->selection,
			"cursor_mode", E_CURSOR_SPREADSHEET,
			NULL);

		g_signal_connect (
			etcta->row, "key_press",
			G_CALLBACK (item_key_press), etcta);

		e_signal_connect_notify (
			etcta->row, "notify::is-editing",
			G_CALLBACK (table_click_to_add_row_is_editing_changed_cb), etcta);

		set_initial_selection (etcta);

		g_object_notify (G_OBJECT (etcta), "is-editing");
	}
}
Example #18
0
void G_cont_create( int cont, GnomeCanvasGroup *root )
{
	if(!initialized)
		G_cont_init();

	G_conts[cont].cont_group = GNOME_CANVAS_GROUP(
			gnome_canvas_item_new (
				root,
				gnome_canvas_group_get_type (),
				"x", (double) G_conts[cont].x,
				"y", (double) G_conts[cont].y,
				NULL));
}
Example #19
0
Gnocl_CanvasItemInfo *gnoclCanvasCreateBPath( Tcl_Interp *interp,
      int objc, Tcl_Obj * const objv[], GnomeCanvasGroup *group )
{
   Gnocl_CanvasItemInfo *info = g_new( Gnocl_CanvasItemInfo, 1 );
   info->options = bPathOptions;
   info->setOptions = &setOptions;
   info->getOption = &cget;
   info->command = command;
   info->item = gnome_canvas_item_new( group, 
         gnome_canvas_bpath_get_type( ), 
         "fill_color", "black", "outline_color", "black", NULL );

   return info;
}
Example #20
0
GnomeCanvasItem *
gnucash_cursor_new (GnomeCanvasGroup *parent)
{
    GnomeCanvasItem *item;
    GnomeCanvasItem *cursor_item;
    GnucashCursor *cursor;
    GnucashItemCursor *item_cursor;

    g_return_val_if_fail (parent != NULL, NULL);
    g_return_val_if_fail (GNOME_IS_CANVAS_GROUP(parent), NULL);

    item = gnome_canvas_item_new (parent,
                                  gnucash_cursor_get_type(),
                                  NULL);

    cursor = GNUCASH_CURSOR(item);

    cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
                                         gnucash_item_cursor_get_type(),
                                         NULL);

    item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
    item_cursor->type = GNUCASH_CURSOR_CELL;

    cursor->cursor[GNUCASH_CURSOR_CELL] = cursor_item;

    cursor_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(item),
                                         gnucash_item_cursor_get_type(),
                                         NULL);

    item_cursor = GNUCASH_ITEM_CURSOR (cursor_item);
    item_cursor->type = GNUCASH_CURSOR_BLOCK;

    cursor->cursor[GNUCASH_CURSOR_BLOCK] = cursor_item;

    return item;
}
Example #21
0
GnomeCanvasItem*
bst_canvas_link_new (GnomeCanvasGroup *group)
{
  GnomeCanvasItem *item;
  
  g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (group), NULL);
  
  item = gnome_canvas_item_new (group,
				BST_TYPE_CANVAS_LINK,
				NULL);

  /* work around stale canvas pointers, see #340437 */
  g_object_set_data_full (item, "bst-workaround-canvas-ref", g_object_ref (item->canvas), g_object_unref);
  bst_background_handler1_add (bst_canvas_link_build_async, g_object_ref (item), NULL);
  return item;
}
Example #22
0
static TEG_STATUS canvas_create_map( void )
{
	char *filename;
	GnomeCanvasGroup* root;
	GdkPixbuf *im;
	GnomeCanvasItem *image;

	gtk_widget_push_colormap (gdk_rgb_get_cmap ());
	canvas_map = gnome_canvas_new ();
	root = gnome_canvas_root(GNOME_CANVAS(canvas_map));

	filename = theme_load_file( gui_theme.board );

	im = gdk_pixbuf_new_from_file(filename, NULL);

	if (im){
		image = gnome_canvas_item_new (
				root,
				gnome_canvas_pixbuf_get_type (),
				"pixbuf", im,
				"x", 0.0,
				"y", 0.0,
				"width", (double) gdk_pixbuf_get_width(im),
				"height", (double) gdk_pixbuf_get_height(im),
				"anchor", GTK_ANCHOR_NW,
				NULL);
		canvas_create_countries(root);
		armies_init(root);
		dices_init(root);
		gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas_map),0,0,gdk_pixbuf_get_width(im),gdk_pixbuf_get_height(im));

		gdk_pixbuf_unref(im);

	} else {
		g_warning (_("Could not find the %s file"),gui_theme.board);
		return TEG_STATUS_ERROR;
	}


	gtk_widget_pop_colormap ();
	gtk_widget_pop_visual ();

	return TEG_STATUS_SUCCESS;
}
Example #23
0
static void
set_empty(EReflow *reflow)
{
	if (reflow->count == 0) {
		if (reflow->empty_text) {
			if (reflow->empty_message) {
				gnome_canvas_item_set(reflow->empty_text,
						      "width", reflow->minimum_width,
						      "text", reflow->empty_message,
						      NULL);
				e_canvas_item_move_absolute(reflow->empty_text,
							    reflow->minimum_width / 2,
							    0);
			} else {
				gtk_object_destroy(GTK_OBJECT(reflow->empty_text));
				reflow->empty_text = NULL;
			}
		} else {
			if (reflow->empty_message) {
				reflow->empty_text =
					gnome_canvas_item_new(GNOME_CANVAS_GROUP(reflow),
							      e_text_get_type(),
							      "anchor", GTK_ANCHOR_N,
							      "width", reflow->minimum_width,
							      "clip", TRUE,
							      "use_ellipsis", TRUE,
							      "justification", GTK_JUSTIFY_CENTER,
							      "text", reflow->empty_message,
							      "draw_background", FALSE,
							      NULL);
				e_canvas_item_move_absolute(reflow->empty_text,
							    reflow->minimum_width / 2,
							    0);
			}
		}
	} else {
		if (reflow->empty_text) {
			gtk_object_destroy(GTK_OBJECT(reflow->empty_text));
			reflow->empty_text = NULL;
		}
	}
}
Example #24
0
void start_selectrect(GdkEvent *event)
{
  double pt[2];
  reset_selection();
  
  ui.cur_item_type = ITEM_SELECTRECT;
  ui.selection = g_new(struct Selection, 1);
  ui.selection->type = ITEM_SELECTRECT;
  ui.selection->items = NULL;
  ui.selection->layer = ui.cur_layer;

  get_pointer_coords(event, pt);
  ui.selection->bbox.left = ui.selection->bbox.right = pt[0];
  ui.selection->bbox.top = ui.selection->bbox.bottom = pt[1];
 
  ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group,
      gnome_canvas_rect_get_type(), "width-pixels", 1, 
      "outline-color-rgba", 0x000000ff,
      "fill-color-rgba", 0x80808040,
      "x1", pt[0], "x2", pt[0], "y1", pt[1], "y2", pt[1], NULL);
  update_cursor();
}
Example #25
0
PlannerRelationArrow *
planner_relation_arrow_new (PlannerGanttRow *successor,
			    PlannerGanttRow *predecessor,
			    MrpRelationType  type)
{
	PlannerRelationArrow *arrow;
	GnomeCanvasGroup     *root;

	root = gnome_canvas_root (GNOME_CANVAS_ITEM (successor)->canvas);

	arrow = PLANNER_RELATION_ARROW (
		gnome_canvas_item_new (root,
				       PLANNER_TYPE_RELATION_ARROW,
				       NULL));

	arrow->priv->type = type;

	planner_relation_arrow_set_successor (arrow, successor);
	planner_relation_arrow_set_predecessor (arrow, predecessor);

	return arrow;
}
static GnomeCanvasItem *
addressbook_incarnate (EReflowModel *erm, int i, GnomeCanvasGroup *parent)
{
	EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm);
	EAddressbookReflowAdapterPrivate *priv = adapter->priv;
	GnomeCanvasItem *item;

	item = gnome_canvas_item_new(parent,
				     e_minicard_get_type(),
				     "contact", eab_model_contact_at (priv->model, i),
				     "editable", eab_model_editable (priv->model),
				     NULL);

#if 0
	g_signal_connect (item, "selected",
			  G_CALLBACK(card_selected), 0, emvm);
#endif

	g_signal_connect (item, "drag_begin",
			  G_CALLBACK(adapter_drag_begin), adapter);

	return item;
}
Example #27
0
File: about.c Project: timxx/zenity
static void
zenity_create_clothes (GtkWidget *canvas_board)
{
  GdkPixbuf *pixbuf;
  GnomeCanvasItem *canvas_item;
  gchar *pixbuf_path;
  size_t i;

  for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) {
    pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL); 
    pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL);

    canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
                                         GNOME_TYPE_CANVAS_PIXBUF,
                                         "x", monk_clothes[i].x,
                                         "y", monk_clothes[i].y,
                                         "pixbuf", pixbuf,
                                         "anchor", GTK_ANCHOR_NW,
                                          NULL);
    g_signal_connect (G_OBJECT (canvas_item), "event",
                      G_CALLBACK (zenity_move_clothes_event), NULL);
  }
}
Example #28
0
void start_vertspace(GdkEvent *event)
{
  double pt[2];
  GList *itemlist;
  struct Item *item;

  reset_selection();
  ui.cur_item_type = ITEM_MOVESEL_VERT;
  ui.selection = g_new(struct Selection, 1);
  ui.selection->type = ITEM_MOVESEL_VERT;
  ui.selection->items = NULL;
  ui.selection->layer = ui.cur_layer;

  get_pointer_coords(event, pt);
  ui.selection->bbox.top = ui.selection->bbox.bottom = pt[1];
  for (itemlist = ui.cur_layer->items; itemlist!=NULL; itemlist = itemlist->next) {
    item = (struct Item *)itemlist->data;
    if (item->bbox.top >= pt[1]) {
      ui.selection->items = g_list_append(ui.selection->items, item); 
      if (item->bbox.bottom > ui.selection->bbox.bottom)
        ui.selection->bbox.bottom = item->bbox.bottom;
    }
  }

  ui.selection->anchor_x = ui.selection->last_x = 0;
  ui.selection->anchor_y = ui.selection->last_y = pt[1];
  ui.selection->orig_pageno = ui.pageno;
  ui.selection->move_pageno = ui.pageno;
  ui.selection->move_layer = ui.selection->layer;
  ui.selection->move_pagedelta = 0.;
  ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group,
      gnome_canvas_rect_get_type(), "width-pixels", 1, 
      "outline-color-rgba", 0x000000ff,
      "fill-color-rgba", 0x80808040,
      "x1", -100.0, "x2", ui.cur_page->width+100, "y1", pt[1], "y2", pt[1], NULL);
  update_cursor();
}
Example #29
0
static void
bst_canvas_source_build (BstCanvasSource *csource)
{
  GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (csource);
  /* put an outer rectangle, make it transparent in aa mode,
   * so we can receive mouse events everywhere
   */
  GnomeCanvasItem *rect = gnome_canvas_item_new (group,
                                                 GNOME_TYPE_CANVAS_RECT,
                                                 "outline_color_rgba", RGBA_BLACK, /* covers buggy canvas lines */
                                                 "x1", 0.0,
                                                 "y1", 0.0,
                                                 "x2", TOTAL_WIDTH (csource),
                                                 "y2", TOTAL_HEIGHT (csource),
                                                 (GNOME_CANVAS_ITEM (csource)->canvas->aa
                                                  ? "fill_color_rgba"
                                                  : NULL), 0x00000000,
                                                 NULL);
  g_object_connect (rect,
                    "swapped_signal::event", bst_canvas_source_child_event, csource,
                    NULL);
  /* make sure no items are left over */
  while (csource->channel_items)
    gtk_object_destroy (csource->channel_items->data);
  while (csource->channel_hints)
    gtk_object_destroy (csource->channel_hints->data);
  csource->built_ichannels = FALSE;
  csource->built_ochannels = FALSE;
  csource->built_ihints = FALSE;
  csource->built_ohints = FALSE;
  /* asynchronously rebuild contents */
  GnomeCanvasItem *csource_item = GNOME_CANVAS_ITEM (csource);
  /* work around stale canvas pointers, see #340437 */
  g_object_set_data_full (csource_item, "bst-workaround-canvas-ref", g_object_ref (csource_item->canvas), g_object_unref);
  bst_background_handler2_add (bst_canvas_source_build_async, g_object_ref (csource), NULL);
}
Example #30
0
static gboolean
bst_canvas_source_build_async (gpointer data)
{
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (data);
  if (gnome_canvas_item_check_undisposed (item))
    {
      BstCanvasSource *csource = BST_CANVAS_SOURCE (item);
      GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (csource);
      
      /* keep in mind, that creation order affects stacking */

      /* add input and output channel items */
      if (!csource->built_ichannels)
        {
          csource->built_ichannels = TRUE;
          bst_canvas_source_build_channels (csource,
                                            TRUE,               /* input channels */
                                            0xffff00, 0x808000,	/* ichannels */
                                            0x00afff, 0x005880, /* jchannels */
                                            TRUE, FALSE);
          return TRUE;
        }
      if (!csource->built_ochannels)
        {
          csource->built_ochannels = TRUE;
          bst_canvas_source_build_channels (csource,
                                            FALSE,              /* output channels */
                                            0xff0000, 0x800000, /* ochannels */
                                            0, 0,               /* unused */
                                            TRUE, FALSE);
          return TRUE;
        }

      /* add icon to group */
      if (!csource->icon_item)
        {
          csource->icon_item = g_object_connect (gnome_canvas_item_new (group,
                                                                        GNOME_TYPE_CANVAS_PIXBUF,
                                                                        "x", ICON_X (csource),
                                                                        "y", ICON_Y (csource),
                                                                        "width", ICON_WIDTH (csource),
                                                                        "height", ICON_HEIGHT (csource),
                                                                        NULL),
                                                 "signal::destroy", gtk_widget_destroyed, &csource->icon_item,
                                                 "swapped_signal::event", bst_canvas_source_child_event, csource,
                                                 NULL);
          source_icon_changed (csource);
          return TRUE;
        }
      
      if (!csource->text)
        {
          /* add text item, invoke name_changed callback to setup the text value */
          guint ocolor = csource->source && bse_item_internal (csource->source) ? RGBA_INTERNAL : RGBA_BLACK;
          csource->text = gnome_canvas_item_new (group,
                                                 GNOME_TYPE_CANVAS_TEXT,
                                                 "fill_color_rgba", ocolor,
                                                 "anchor", GTK_ANCHOR_NORTH,
                                                 "justification", GTK_JUSTIFY_CENTER,
                                                 "x", TEXT_X (csource),
                                                 "y", TEXT_Y (csource),
                                                 "font", TEXT_FONT,
                                                 NULL);
          g_object_connect (csource->text,
                            "signal::destroy", gtk_widget_destroyed, &csource->text,
                            "swapped_signal::event", bst_canvas_source_child_event, csource,
                            NULL);
          gnome_canvas_text_set_zoom_size (GNOME_CANVAS_TEXT (csource->text), FONT_HEIGHT);
          source_name_changed (csource);
          return TRUE;
        }

      /* add input and output channel hints */
      if (!csource->built_ihints)
        {
          csource->built_ihints = TRUE;
          bst_canvas_source_build_channels (csource,
                                            TRUE,               /* input channels */
                                            0xffff00, 0x808000,	/* ichannels */
                                            0x00afff, 0x005880, /* jchannels */
                                            FALSE, TRUE);
          return TRUE;
        }
      if (!csource->built_ohints)
        {
          csource->built_ohints = TRUE;
          bst_canvas_source_build_channels (csource,
                                            FALSE,              /* output channels */
                                            0xff0000, 0x800000, /* ochannels */
                                            0, 0,               /* unused */
                                            FALSE, TRUE);
          return TRUE;
        }
    }
  GnomeCanvas *canvas = g_object_steal_data (item, "bst-workaround-canvas-ref");
  g_object_unref (item);
  if (canvas)
    g_object_unref (canvas);      /* canvases don't properly protect their items */
  return FALSE;
}