Ejemplo n.º 1
0
static void
wire_changed_callback (Wire *wire, WireItem *item)
{
	SheetPos start_pos, length;
	GnomeCanvasPoints *points;

	wire_get_pos_and_length (wire, &start_pos, &length);

	points = gnome_canvas_points_new (2);
	points->coords[0] = 0;
	points->coords[1] = 0;
	points->coords[2] = length.x;
	points->coords[3] = length.y;

	gnome_canvas_item_set (GNOME_CANVAS_ITEM (item->priv->line),
		"points", points,
		NULL);
	gnome_canvas_points_unref (points);

	gnome_canvas_item_set (GNOME_CANVAS_ITEM (item->priv->resize1),
		"x1", -RESIZER_SIZE,
		"y1", -RESIZER_SIZE,
		"x2", RESIZER_SIZE,
		"y2", RESIZER_SIZE,
		NULL);

	gnome_canvas_item_set (GNOME_CANVAS_ITEM (item->priv->resize2),
		"x1", length.x-RESIZER_SIZE,
		"y1", length.y-RESIZER_SIZE,
		"x2", length.x+RESIZER_SIZE,
		"y2", length.y+RESIZER_SIZE,
		NULL);
}
Ejemplo n.º 2
0
static gint
e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter,
                            GdkEvent *event,
                            EMinicardView *view)
{
	GdkDragContext *context;
	GtkTargetList *target_list;
	GdkDragAction actions = GDK_ACTION_MOVE | GDK_ACTION_COPY;

	clear_drag_data (view);

	view->drag_list = e_minicard_view_get_card_list (view);

	target_list = gtk_target_list_new (drag_types, G_N_ELEMENTS (drag_types));

	context = gtk_drag_begin (
		GTK_WIDGET (GNOME_CANVAS_ITEM (view)->canvas),
		target_list, actions, 1/*XXX */, event);

	if (!view->canvas_drag_data_get_id)
		view->canvas_drag_data_get_id = g_signal_connect (
			GNOME_CANVAS_ITEM (view)->canvas, "drag_data_get",
			G_CALLBACK (e_minicard_view_drag_data_get), view);

	gtk_drag_set_icon_default (context);

	return TRUE;
}
Ejemplo n.º 3
0
/* Starts the selection state in the icon text item */
static void
iti_start_selecting (GnomeIconTextItem *iti, int idx, guint32 event_time)
{
	GnomeIconTextItemPrivate *priv;
	GtkEditable *e;
	GdkCursor *ibeam;

	priv = iti->_priv;
	e = GTK_EDITABLE (priv->entry);

	gtk_editable_select_region (e, idx, idx);
	gtk_editable_set_position (e, idx);
	ibeam = gdk_cursor_new (GDK_XTERM);
	gnome_canvas_item_grab (GNOME_CANVAS_ITEM (iti),
				GDK_BUTTON_RELEASE_MASK |
				GDK_POINTER_MOTION_MASK,
				ibeam, event_time);
	gdk_cursor_unref (ibeam);

	gtk_editable_select_region (e, idx, idx);
	priv->selecting = TRUE;
	priv->selection_start = idx;

	gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));

	g_signal_emit (iti, iti_signals[SELECTION_STARTED], 0);
}
Ejemplo n.º 4
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));
}
Ejemplo n.º 5
0
void
ghack_map_print_glyph(GtkObject *win, guint x, guint y, GdkImlibImage *im,
                      gpointer data)
{
    GnomeCanvasGroup *group;
    int i = y * COLNO + x;
    int glyph = glyph_at(x, y);
    GnomeCanvasImage *canvas_image = GNOME_CANVAS_IMAGE(ghack_map.map[i]);

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

    gnome_canvas_item_set(GNOME_CANVAS_ITEM(canvas_image), "image", im, NULL);
    gnome_canvas_item_show(GNOME_CANVAS_ITEM(canvas_image));

    canvas_image = GNOME_CANVAS_IMAGE(ghack_map.overlay[i]);

    if (x == u.ux && y == u.uy)
        ghack_map_cliparound(NULL, x, y, NULL);

    if (glyph_is_pet(glyph)
#ifdef TEXTCOLOR
            && iflags.hilite_pet
#endif
       ) {
        gnome_canvas_item_raise_to_top(GNOME_CANVAS_ITEM(canvas_image));
        gnome_canvas_item_show(GNOME_CANVAS_ITEM(canvas_image));
    } else {
        gnome_canvas_item_hide(GNOME_CANVAS_ITEM(canvas_image));
    }
}
Ejemplo n.º 6
0
static gboolean
gal_a11y_e_cell_grab_focus (AtkComponent *component)
{
	GalA11yECell *a11y;
	gint index;
	GtkWidget *toplevel;
	GalA11yETableItem *a11yTableItem;

	a11y = GAL_A11Y_E_CELL (component);

	/* for e_cell_vbox's children, we just grab the e_cell_vbox */
	if (GAL_A11Y_IS_E_CELL_VBOX (a11y->parent)) {
		return atk_component_grab_focus (ATK_COMPONENT (a11y->parent));
	}

	a11yTableItem = GAL_A11Y_E_TABLE_ITEM (a11y->parent);
	index = atk_object_get_index_in_parent (ATK_OBJECT (a11y));

	atk_selection_clear_selection (ATK_SELECTION (a11yTableItem));
	atk_selection_add_selection (ATK_SELECTION (a11yTableItem), index);

	gtk_widget_grab_focus (
		GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas));
	toplevel = gtk_widget_get_toplevel (
		GTK_WIDGET (GNOME_CANVAS_ITEM (a11y->item)->canvas));
	if (toplevel && gtk_widget_is_toplevel (toplevel))
		gtk_window_present (GTK_WINDOW (toplevel));

	return TRUE;
}
Ejemplo n.º 7
0
static void
relation_arrow_predecessor_visibility_changed (PlannerGanttRow      *row,
					       gboolean              visible,
					       PlannerRelationArrow *arrow)
{
	arrow->priv->predecessor_visible = visible;

	if (!visible) {
		gnome_canvas_item_hide (GNOME_CANVAS_ITEM (arrow));
	} else if (arrow->priv->successor_visible) {
		gnome_canvas_item_show (GNOME_CANVAS_ITEM (arrow));
	}
}
Ejemplo n.º 8
0
static void
selection_changed(WireItem *item, gboolean select, gpointer user_data)
{
	g_object_ref(G_OBJECT(item));
	if (select) {
		gtk_idle_add ((gpointer) select_idle_callback, item);
		gnome_canvas_item_show (GNOME_CANVAS_ITEM (item->priv->resize1));
		gnome_canvas_item_show (GNOME_CANVAS_ITEM (item->priv->resize2));
	} else {
		gtk_idle_add ((gpointer) deselect_idle_callback, item);
		gnome_canvas_item_hide (GNOME_CANVAS_ITEM (item->priv->resize1));
		gnome_canvas_item_hide (GNOME_CANVAS_ITEM (item->priv->resize2));
	}
}
Ejemplo n.º 9
0
void
ghack_map_clear(GtkWidget *win, gpointer data)
{
    int i;

    for (i = 0; i < ROWNO * COLNO; i++) {
        if (GNOME_IS_CANVAS_IMAGE(ghack_map.map[i])) {
            gnome_canvas_item_hide(GNOME_CANVAS_ITEM(ghack_map.map[i]));
        }
        if (GNOME_IS_CANVAS_IMAGE(ghack_map.overlay[i])) {
            gnome_canvas_item_hide(GNOME_CANVAS_ITEM(ghack_map.overlay[i]));
        }
    }
    gnome_canvas_update_now(GNOME_CANVAS(ghack_map.canvas));
}
Ejemplo n.º 10
0
/* Stops the selection state in the icon text item */
static void
iti_stop_selecting (GnomeIconTextItem *iti, guint32 event_time)
{
	GnomeIconTextItemPrivate *priv;
	GnomeCanvasItem *item;

	priv = iti->_priv;
	item = GNOME_CANVAS_ITEM (iti);

	gnome_canvas_item_ungrab (item, event_time);
	priv->selecting = FALSE;

	gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
	g_signal_emit (iti, iti_signals[SELECTION_STOPPED], 0);
}
Ejemplo n.º 11
0
/* Recomputes the bounding box of an icon text item */
static void
recompute_bounding_box (GnomeIconTextItem *iti)
{

	GnomeCanvasItem *item;
	double x1, y1, x2, y2;
	int width_c, height_c;
	int width_w, height_w;
	int max_width_w;

	item = GNOME_CANVAS_ITEM (iti);

	width_c = iti->_priv->layout_width + 2 * MARGIN_X;
	height_c = iti->_priv->layout_height + 2 * MARGIN_Y;
	width_w = ROUND (width_c / item->canvas->pixels_per_unit);
	height_w = ROUND (height_c / item->canvas->pixels_per_unit);
	max_width_w = ROUND (iti->width / item->canvas->pixels_per_unit);

	x1 = iti->x;
	y1 = iti->y;

	gnome_canvas_item_i2w (item, &x1, &y1);

	x1 += ROUND ((max_width_w - width_w) / 2);
	x2 = x1 + width_w;
	y2 = y1 + height_w;

	gnome_canvas_w2c_d (item->canvas, x1, y1, &item->x1, &item->y1);
	gnome_canvas_w2c_d (item->canvas, x2, y2, &item->x2, &item->y2);
}
Ejemplo n.º 12
0
static void
e_canvas_item_invoke_reflow (GnomeCanvasItem *item, int flags)
{
	GnomeCanvasGroup *group;
	GList *list;
	GnomeCanvasItem *child;

	if (GNOME_IS_CANVAS_GROUP (item)) {
		group = GNOME_CANVAS_GROUP (item);
		for (list = group->item_list; list; list = list->next) {
			child = GNOME_CANVAS_ITEM (list->data);
			if (child->object.flags & E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW)
				e_canvas_item_invoke_reflow (child, flags);
		}
	}

	if (item->object.flags & E_CANVAS_ITEM_NEEDS_REFLOW) {
		ECanvasItemReflowFunc func;
		func = (ECanvasItemReflowFunc)
			g_object_get_data (G_OBJECT (item),
					   "ECanvasItem::reflow_callback");
		if (func)
			func (item, flags);
	}

	item->object.flags &= ~E_CANVAS_ITEM_NEEDS_REFLOW;
	item->object.flags &= ~E_CANVAS_ITEM_DESCENDENT_NEEDS_REFLOW;
}
Ejemplo n.º 13
0
static gboolean
gnc_date_cell_enter (BasicCell *bcell,
                     int *cursor_position,
                     int *start_selection,
                     int *end_selection)
{
    DateCell *cell = (DateCell *) bcell;
    PopBox *box = bcell->gui_private;

    gnc_item_edit_set_popup (box->item_edit, GNOME_CANVAS_ITEM (box->date_picker),
                             get_popup_height, NULL, popup_set_focus,
                             NULL, NULL, NULL);

    block_picker_signals (cell);
    gnc_date_picker_set_date (box->date_picker,
                              box->date.tm_mday,
                              box->date.tm_mon,
                              box->date.tm_year + 1900);
    unblock_picker_signals (cell);

    date_picker_connect_signals ((DateCell *) bcell);

    *start_selection = 0;
    *end_selection = -1;

    return TRUE;
}
Ejemplo n.º 14
0
/**
 * e_table_group_container_construct
 * @parent: The %GnomeCanvasGroup to create a child of.
 * @etgc: The %ETableGroupContainer.
 * @full_header: The full header of the %ETable.
 * @header: The current header of the %ETable.
 * @model: The %ETableModel of the %ETable.
 * @sort_info: The %ETableSortInfo of the %ETable.
 * @n: Which grouping level this is (Starts at 0 and sends n + 1 to any child %ETableGroups.
 *
 * This routine constructs the new %ETableGroupContainer.
 */
void
e_table_group_container_construct (GnomeCanvasGroup *parent, ETableGroupContainer *etgc,
				   ETableHeader *full_header,
				   ETableHeader     *header,
				   ETableModel *model, ETableSortInfo *sort_info, int n)
{
	ETableCol *col;
	ETableSortColumn column = e_table_sort_info_grouping_get_nth(sort_info, n);
	GtkStyle *style;

	col = e_table_header_get_column_by_col_idx(full_header, column.column);
	if (col == NULL)
		col = e_table_header_get_column (full_header, e_table_header_count (full_header) - 1);

	e_table_group_construct (parent, E_TABLE_GROUP (etgc), full_header, header, model);
	etgc->ecol = col;
	g_object_ref (etgc->ecol);
	etgc->sort_info = sort_info;
	g_object_ref (etgc->sort_info);
	etgc->n = n;
	etgc->ascending = column.ascending;

	style = GTK_WIDGET (GNOME_CANVAS_ITEM (etgc)->canvas)->style;
	etgc->font_desc = pango_font_description_copy (style->font_desc);

	etgc->open = TRUE;
}
Ejemplo n.º 15
0
static gboolean
ea_addressbook_focus_watcher (GSignalInvocationHint *ihint,
                              guint n_param_values,
                              const GValue *param_values,
                              gpointer data)
{
	GObject *object;
	GdkEvent *event;
	AtkObject *ea_event = NULL;

	object = g_value_get_object (param_values + 0);
	event = g_value_get_boxed (param_values + 1);

	if (E_IS_MINICARD (object)) {
		GnomeCanvasItem *item = GNOME_CANVAS_ITEM (object);
		ea_event = atk_gobject_accessible_for_object (object);
		if (event->type == GDK_FOCUS_CHANGE) {
			if (E_IS_MINICARD (item->canvas->focused_item))
				atk_object_notify_state_change (ea_event,
					ATK_STATE_FOCUSED,
					event->focus_change.in);
		}
	}

	return TRUE;
}
Ejemplo n.º 16
0
static void
etcta_style_updated (ETableClickToAdd *etcta)
{
	GtkWidget *widget;
	GdkColor fg, bg, text;

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

	e_utils_get_theme_color_color (widget, "theme_fg_color", E_UTILS_DEFAULT_THEME_FG_COLOR, &fg);
	e_utils_get_theme_color_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg);
	e_utils_get_theme_color_color (widget, "theme_text_color,theme_fg_color", E_UTILS_DEFAULT_THEME_TEXT_COLOR, &text);

	if (etcta->rect)
		gnome_canvas_item_set (
			etcta->rect,
			"outline_color_gdk", &fg,
			"fill_color_gdk", &bg,
			NULL);

	if (etcta->text)
		gnome_canvas_item_set (
			etcta->text,
			"fill_color_gdk", &text,
			NULL);
}
Ejemplo n.º 17
0
static gboolean
week_view_event_item_button_release (EWeekViewEventItem *event_item,
                                     GdkEvent *event)
{
	EWeekView *week_view;
	GnomeCanvasItem *item;
	GtkWidget *parent;

	item = GNOME_CANVAS_ITEM (event_item);

	parent = gtk_widget_get_parent (GTK_WIDGET (item->canvas));
	g_return_val_if_fail (E_IS_WEEK_VIEW (parent), FALSE);

	week_view = E_WEEK_VIEW (parent);

	if (week_view->pressed_event_num != -1
	    && week_view->pressed_event_num == event_item->priv->event_num
	    && week_view->pressed_span_num == event_item->priv->span_num) {
		e_week_view_start_editing_event (week_view,
						 event_item->priv->event_num,
						 event_item->priv->span_num,
						 NULL);
		week_view->pressed_event_num = -1;
		return TRUE;
	}

	week_view->pressed_event_num = -1;

	return FALSE;
}
Ejemplo n.º 18
0
static gboolean
do_adjustment (gpointer user_data)
{
	int row;
	GtkAdjustment *adj ;
	gfloat value, min_value, max_value;
	EReflow *reflow = user_data;

	row = reflow->cursor_row;
	if (row == -1)
		return FALSE;

	adj = gtk_layout_get_hadjustment (GTK_LAYOUT (GNOME_CANVAS_ITEM (reflow)->canvas));
	value = adj->value;

	if ((!reflow->items) || (!reflow->items[row]))
		return TRUE;
	min_value = reflow->items[row]->x2 - adj->page_size;
	max_value = reflow->items[row]->x1;

	if (value < min_value)
		value = min_value;

	if (value > max_value)
		value = max_value;

	if (value != adj->value) {
		adj->value = value;
		gtk_adjustment_value_changed (adj);
	}

	reflow->do_adjustment_idle_id = 0;

	return FALSE;
}
Ejemplo n.º 19
0
void
gnucash_cursor_set (GnucashCursor *cursor, VirtualLocation virt_loc)
{
    GnucashSheet *sheet;

    g_return_if_fail (cursor != NULL);
    g_return_if_fail (GNUCASH_IS_CURSOR (cursor));

    sheet = cursor->sheet;

    gnucash_cursor_request_redraw (cursor);

    gnucash_cursor_set_block (cursor, virt_loc.vcell_loc);
    gnucash_cursor_set_cell (cursor,
                             virt_loc.phys_row_offset,
                             virt_loc.phys_col_offset);

    gnucash_cursor_configure (cursor);

    gnome_canvas_item_set (GNOME_CANVAS_ITEM(sheet->header_item),
                           "cursor_name",
                           cursor->style->cursor->cursor_name,
                           NULL);

    gnucash_cursor_request_redraw (cursor);
}
Ejemplo n.º 20
0
static gboolean
etgc_remove (ETableGroup *etg, gint row)
{
	ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER(etg);
	GList *list;

	for (list = etgc->children ; list; list = g_list_next (list)) {
		ETableGroupContainerChildNode *child_node = list->data;
		ETableGroup                   *child = child_node->child;

		if (e_table_group_remove (child, row)) {
			child_node->count --;
			if (child_node->count == 0) {
				e_table_group_container_child_node_free (etgc, child_node);
				etgc->children = g_list_remove (etgc->children, child_node);
				g_free (child_node);
			} else
				compute_text (etgc, child_node);

			e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etgc));

			return TRUE;
		}
	}
	return FALSE;
}
Ejemplo n.º 21
0
static ECalendarViewPosition
week_view_event_item_get_position (EWeekViewEventItem *event_item,
                                   gdouble x,
                                   gdouble y)
{
	EWeekView *week_view;
	GnomeCanvasItem *item;
	GtkWidget *parent;

	item = GNOME_CANVAS_ITEM (event_item);

	parent = gtk_widget_get_parent (GTK_WIDGET (item->canvas));
	g_return_val_if_fail (E_IS_WEEK_VIEW (parent), E_CALENDAR_VIEW_POS_NONE);

	week_view = E_WEEK_VIEW (parent);

	if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD
	    || x >= item->x2 - E_WEEK_VIEW_EVENT_R_PAD)
		return E_CALENDAR_VIEW_POS_NONE;

	/* Support left/right edge for long events only. */
	if (!e_week_view_is_one_day_event (week_view, event_item->priv->event_num)) {
		if (x < item->x1 + E_WEEK_VIEW_EVENT_L_PAD
		    + E_WEEK_VIEW_EVENT_BORDER_WIDTH
		    + E_WEEK_VIEW_EVENT_EDGE_X_PAD)
			return E_CALENDAR_VIEW_POS_LEFT_EDGE;

		if (x >= item->x2 + 1 - E_WEEK_VIEW_EVENT_R_PAD
		    - E_WEEK_VIEW_EVENT_BORDER_WIDTH
		    - E_WEEK_VIEW_EVENT_EDGE_X_PAD)
			return E_CALENDAR_VIEW_POS_RIGHT_EDGE;
	}

	return E_CALENDAR_VIEW_POS_EVENT;
}
Ejemplo n.º 22
0
/* Hide the userlist if there are no users displayed */
void
greeter_item_ulist_check_show_userlist (void)
{
	/*
	 * If there are no users,
	 * then hide the rectangle used to contain the userlist.  The
	 * userlist-rect id allows a rectangle to be defined with alpha
	 * behind the userlist that also goes away when the list is empty.
	 */
	if (num_users == 0) {

		GreeterItemInfo *urinfo = greeter_lookup_id ("userlist-rect");

		if (user_list != NULL)
			gtk_widget_hide (user_list);

		if (urinfo) {
			GnomeCanvasItem *item;

			if (urinfo->group_item != NULL)
				item = GNOME_CANVAS_ITEM (urinfo->group_item);
			else
				item = urinfo->item;

			gnome_canvas_item_hide (item);
		}
	}
}
Ejemplo n.º 23
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);
}
Ejemplo n.º 24
0
/* Accepts the text in the off-screen entry of an icon text item */
static void
iti_edition_accept (GnomeIconTextItem *iti)
{
	GnomeIconTextItemPrivate *priv;
	gboolean accept;

	priv = iti->_priv;
	accept = TRUE;

	g_signal_emit (iti, iti_signals [TEXT_CHANGED], 0, &accept);

	if (iti->editing){
		if (accept) {
			if (iti->is_text_allocated)
				g_free (iti->text);

			iti->text = g_strdup (gtk_entry_get_text (GTK_ENTRY(priv->entry)));
			iti->is_text_allocated = 1;
		}

		iti_stop_editing (iti);
	}
	update_pango_layout (iti);
	priv->need_text_update = TRUE;

	gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (iti));
}
static void
etfci_reflow (GnomeCanvasItem *item,
              gint flags)
{
	ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
	gdouble old_height;
	gint i;
	gint count;
	gdouble height = 0;

	etfci_rebuild_combined (etfci);

	old_height = etfci->height;

	count = e_table_header_count (etfci->combined_header);
	for (i = 0; i < count; i++) {
		ETableCol *ecol;

		ecol = e_table_header_get_column (etfci->combined_header, i);
		if (ecol->spec->disabled)
			continue;
		height += e_table_header_compute_height (
			ecol, GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas));
	}

	etfci->height = height;

	if (old_height != etfci->height)
		e_canvas_item_request_parent_reflow (item);

	gnome_canvas_item_request_update (item);
}
static void
table_header_dimension_changed (ETableHeader *header,
                                gint col,
                                ETableFieldChooserItem *etfci)
{
	e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}
Ejemplo n.º 27
0
static void
gnc_header_set_property (GObject *object,
                         guint param_id,
                         const GValue *value,
                         GParamSpec *pspec)
{
    GncHeader *header = GNC_HEADER (object);
    GtkLayout *layout = GTK_LAYOUT (GNOME_CANVAS_ITEM (header)->canvas);
    gboolean needs_update = FALSE;
    gchar *old_name;

    switch (param_id)
    {
    case PROP_SHEET:
        header->sheet = GNUCASH_SHEET (g_value_get_object (value));
        gtk_layout_set_hadjustment (layout, header->sheet->hadj);
        needs_update = TRUE;
        break;
    case PROP_CURSOR_NAME:
        old_name = header->cursor_name;

        header->cursor_name = g_value_dup_string (value);
        needs_update = !old_name || !header->cursor_name ||
                       strcmp (old_name, header->cursor_name) != 0;
        g_free (old_name);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
        break;
    }

    if ((header->sheet != NULL) && needs_update)
        gnc_header_reconfigure (header);
}
static void
etfci_start_drag (ETableFieldChooserItem *etfci,
                  GdkEvent *event,
                  gdouble x,
                  gdouble y)
{
	GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas);
	GtkTargetList *list;
	GdkDragContext *context;
	ETableCol *ecol;
	cairo_surface_t *cs;
	cairo_t *cr;
	gint drag_col;
	gint button_height;

	GtkTargetEntry  etfci_drag_types[] = {
		{ (gchar *) TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER },
	};

	if (etfci->combined_header == NULL)
		return;

	drag_col = etfci_find_button (etfci, y);

	if (drag_col < 0 || drag_col > e_table_header_count (etfci->combined_header))
		return;

	ecol = e_table_header_get_column (etfci->combined_header, drag_col);

	if (ecol->spec->disabled)
		return;

	etfci->drag_col = ecol->spec->model_col;

	etfci_drag_types[0].target = g_strdup_printf (
		"%s-%s", etfci_drag_types[0].target, etfci->dnd_code);
	d (g_print ("etfci - %s\n", etfci_drag_types[0].target));
	list = gtk_target_list_new (etfci_drag_types, G_N_ELEMENTS (etfci_drag_types));
	context = gtk_drag_begin (widget, list, GDK_ACTION_MOVE, 1, event);
	g_free ((gpointer) etfci_drag_types[0].target);

	button_height = e_table_header_compute_height (ecol, widget);
	cs = cairo_image_surface_create (
		CAIRO_FORMAT_ARGB32,
		etfci->width, button_height);
	cr = cairo_create (cs);

	e_table_header_draw_button (
		cr, ecol,
		widget, 0, 0,
		etfci->width, button_height,
		etfci->width, button_height,
		E_TABLE_COL_ARROW_NONE);

	gtk_drag_set_icon_surface (context, cs);

	cairo_surface_destroy (cs);
	cairo_destroy (cr);
	etfci->maybe_drag = FALSE;
}
Ejemplo n.º 29
0
static gboolean
idle_move_item (gpointer data)
{
  BstCanvasSource *self = data;
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (self);

  GDK_THREADS_ENTER ();
  if (self->source && item->canvas)
    {
      SfiReal x, y;
      bse_proxy_get (self->source,
                     "pos-x", &x,
                     "pos-y", &y,
                     NULL);
      x *= BST_CANVAS_SOURCE_PIXEL_SCALE;
      y *= -BST_CANVAS_SOURCE_PIXEL_SCALE;
      gnome_canvas_item_w2i (item, &x, &y);
      g_object_freeze_notify (G_OBJECT (self));
      gnome_canvas_item_move (item, x, y);
      /* canvas notification bug workaround */
      g_object_notify (self, "x");
      g_object_notify (self, "y");
      g_object_thaw_notify (G_OBJECT (self));
    }
  self->idle_reposition = FALSE;
  g_object_unref (self);
  GDK_THREADS_LEAVE ();
  return FALSE;
}
static gboolean
idle_do_action (gpointer data)
{
	GtkLayout *layout;
	GdkEventButton event;
	ETableClickToAdd * etcta;
	gint finished;

	g_return_val_if_fail (data!= NULL, FALSE);

	etcta = E_TABLE_CLICK_TO_ADD (
		atk_gobject_accessible_get_object (
		ATK_GOBJECT_ACCESSIBLE (data)));
	g_return_val_if_fail (etcta, FALSE);

	layout = GTK_LAYOUT (GNOME_CANVAS_ITEM (etcta)->canvas);

	event.x = 0;
	event.y = 0;
	event.type = GDK_BUTTON_PRESS;
	event.window = gtk_layout_get_bin_window (layout);
	event.button = 1;
	event.send_event = TRUE;
	event.time = GDK_CURRENT_TIME;
	event.axes = NULL;

	g_signal_emit_by_name (etcta, "event", &event, &finished);

	return FALSE;
}