示例#1
0
static void
spaning_renderer_render (GtkCellRenderer      *cell,
                         cairo_t              *cr,
			 GtkWidget            *widget,
			 const GdkRectangle   *background_area,
			 const GdkRectangle   *cell_area,
			 GtkCellRendererState  flags)
{
	GiggleSpaningRendererPriv *priv = GET_PRIV (cell);
	GtkTreeViewColumn         *first_column, *last_column;
	GdkRectangle               first_area, last_area;
	int                        first = priv->first;
	int                        last = priv->last;
	GdkRectangle               real_background_area;
	GdkRectangle               real_cell_area;
	GList                     *columns;

	columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (widget));

	if (last < 0)
		last = g_list_length (columns) - 1;

	first_column = g_list_nth_data (columns, first);
	last_column = g_list_nth_data (columns, last);

	g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (first_column));
	g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (last_column));

	gtk_tree_view_get_cell_area (GTK_TREE_VIEW (widget), NULL, first_column, &first_area);
	gtk_tree_view_get_cell_area (GTK_TREE_VIEW (widget), NULL, last_column, &last_area);

	real_cell_area.x      = first_area.x;
	real_cell_area.y      = cell_area->y;
	real_cell_area.width  = last_area.x + last_area.width - first_area.x;
	real_cell_area.height = cell_area->height;

	gtk_tree_view_get_background_area (GTK_TREE_VIEW (widget), NULL, first_column, &first_area);
	gtk_tree_view_get_background_area (GTK_TREE_VIEW (widget), NULL, last_column, &last_area);

	real_background_area.x      = first_area.x;
	real_background_area.y      = cell_area->y;
	real_background_area.width  = last_area.x + last_area.width - first_area.x;
	real_background_area.height = cell_area->height;

	GTK_CELL_RENDERER_CLASS (giggle_spaning_renderer_parent_class)->render
		(cell, cr, widget, &real_background_area, &real_cell_area, flags);

	g_list_free (columns);
}
示例#2
0
static gboolean
row_motion_cb(GtkWidget *tv, GdkEventMotion *event, gpointer userdata)
{
	GtkTreePath *path;

	if (event->window != gtk_tree_view_get_bin_window(GTK_TREE_VIEW(tv)))
		return FALSE;    /* The cursor is probably on the TreeView's header. */

	initialize_tooltip_delay();
	if (!enable_tooltips)
		return FALSE;

	if (pidgin_tooltip.timeout) {
		if ((event->y >= pidgin_tooltip.tip_rect.y) && ((event->y - pidgin_tooltip.tip_rect.height) <= pidgin_tooltip.tip_rect.y))
			return FALSE;
		/* We've left the cell.  Remove the timeout and create a new one below */
		pidgin_tooltip_destroy();
	}

	gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL);

	if (path == NULL) {
		pidgin_tooltip_destroy();
		return FALSE;
	}

	gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &pidgin_tooltip.tip_rect);
	gtk_tree_path_free(path);

	pidgin_tooltip.timeout = g_timeout_add(tooltip_delay, (GSourceFunc)pidgin_tooltip_timeout, userdata);

	return FALSE;
}
示例#3
0
int wxListBox::GetCountPerPage() const
{
    wxGtkTreePath path;
    GtkTreeViewColumn *column;

    if ( !gtk_tree_view_get_path_at_pos
          (
            m_treeview,
            0,
            0,
            path.ByRef(),
            &column,
            NULL,
            NULL
          ) )
    {
        return -1;
    }

    GdkRectangle rect;
    gtk_tree_view_get_cell_area(m_treeview, path, column, &rect);

    if ( !rect.height )
        return -1;

    GdkRectangle vis;
    gtk_tree_view_get_visible_rect(m_treeview, &vis);

    return vis.height / rect.height;
}
示例#4
0
static gboolean
in_input_thumbnail (GtkWidget *widget, GdkEventMotion *event)
{
    g_assert (GTK_IS_TREE_VIEW (widget));

    gboolean result = FALSE;	/* Result to be returned. */

    GtkTreePath *tp = thumbnail_path (widget, event);

    if ( tp == NULL ) {
        return FALSE;		/* Pointer is not over a filled in row.  */
    }

    /* Check if we are over the input image thumbnail.  */
    GtkTreeViewColumn *itc = input_thumbnail_column (widget, event);
    GdkRectangle itnc_rect;	/* Input thumbnail cell rectangle.  */
    gtk_tree_view_get_cell_area (GTK_TREE_VIEW (widget), tp, itc, &itnc_rect);
    /* Here we depend on the fact that the input thumbnail is packed at
    the beginning of the cell horizontally, and centered in the cell
    vertically (FIXME: find a way to verify this with assertions).  */
    GdkRectangle itn_rect;	/* Input thumbnail rectangle.  */
    /* FIXME: fix this border hackery to be precise somehow.  */
    itn_rect.x = itnc_rect.x + 1;	/* There is probably a small border so +1.  */
    itn_rect.y = itnc_rect.y + 1;
    itn_rect.width = THUMB_SIZE;
    itn_rect.height = THUMB_SIZE;
    GdkRegion *itn_region = gdk_region_rectangle (&itn_rect);
    if ( gdk_region_point_in (itn_region, (int) event->x, (int) event->y) ) {
        result = TRUE;
        //    g_message ("Over input thumbnail!");
    }
    gdk_region_destroy (itn_region);

    return result;
}
示例#5
0
void gTreeRow::rect(int *x, int *y, int *w, int *h)
{
	GtkTreePath* path;
	GdkRectangle rect;
	GtkTreeViewColumn *column;
	gint depth;
	gint size;
	gint margin;
	
	path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree->store), dataiter);
	if (!path)
		return;
	
	column = gt_tree_view_find_column(GTK_TREE_VIEW(tree->widget), tree->columnCount() - 1);
	gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tree->widget), path, column, &rect);
	depth = gtk_tree_path_get_depth(path);
	gtk_tree_path_free(path);

	gtk_widget_style_get (tree->widget,
			"expander-size", &size,
			"vertical-separator", &margin,
			(void *)NULL);
			
	size += 4; // Constant that is hard-coded into GTK+ source code

	if (!tree->hasExpanders())
		depth--;

	*x = depth * size;
	*w = rect.x + rect.width - *x;
	*h = rect.height + margin;
	*y = rect.y;
}
示例#6
0
/* Get a new thumbnail region of GtkTreeView widget in which event
falls.  It is an error to call this function if !in_thumbnail
(widget, event).  */
static GdkRegion *
thumbnail_region (GtkWidget *widget, GdkEventMotion *event)
{
    g_assert (GTK_IS_TREE_VIEW (widget));

    g_assert (in_thumbnail (widget, event));

    GtkTreePath *tp = thumbnail_path (widget, event);
    g_assert (tp != NULL);

    /* Rectangle of region to be returned.  */
    GdkRectangle tn_rect;

    /* If over the input image thumbnail, return the input thumbnail region, */
    GtkTreeViewColumn *tc = NULL;	/* Thumbnail column we are over.  */
    if ( in_input_thumbnail (widget, event) ) {
        tc = input_thumbnail_column (widget, event);
    }

    gtk_tree_view_get_cell_area (GTK_TREE_VIEW (widget), tp, tc, &tn_rect);

    /* Here we depend on the fact that the thumbnails are packed at the
    beginning of the cell horizontally, and centered in the cell
    vertically (FIXME: find a way to verify this with assertions).  */
    GdkRectangle itn_rect;		/* Image thumbnail rectangle.  */
    /* FIXME: fix this border hackery to be precise somehow.  */
    itn_rect.x = tn_rect.x + 1;	/* There is probably a small border so +1.  */
    itn_rect.y = tn_rect.y + 1;
    itn_rect.width = THUMB_SIZE;
    itn_rect.height = THUMB_SIZE;

    return gdk_region_rectangle (&itn_rect);
}
示例#7
0
文件: file-view.c 项目: rosedu/anjuta
static gboolean
file_view_query_tooltip (GtkWidget* widget, gint x, gint y, gboolean keyboard,
						 GtkTooltip* tooltip)
{
	AnjutaFileView* view = ANJUTA_FILE_VIEW (widget);
	AnjutaFileViewPrivate* priv = ANJUTA_FILE_VIEW_GET_PRIVATE (view);
	GtkTreeModel* model_sort;
	GtkTreeModel* file_model = GTK_TREE_MODEL (priv->model);
	GtkTreePath* path;
	GtkTreeIter iter;
	GtkTreeIter real_iter;
	gchar* filename;
	gboolean result = TRUE;
	GdkRectangle visible_rect, column_rect;
	GdkScreen *screen = gdk_screen_get_default ();
	PangoContext *context;
	PangoLayout *layout;
	gint width, height;
	
	if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view),
											&x, &y, keyboard,
											&model_sort,
											&path,
											&iter))
		return FALSE;
	
	gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (model_sort),
											&real_iter, &iter);
	
	filename = file_model_get_filename (FILE_MODEL (file_model), &real_iter);

	context = gdk_pango_context_get_for_screen (screen);
	layout = pango_layout_new (context);

	pango_layout_set_text (layout, filename, -1);
	pango_layout_get_pixel_size (layout, &width, &height);

	gtk_tree_view_get_visible_rect (GTK_TREE_VIEW (view), &visible_rect);
	gtk_tree_view_get_cell_area (GTK_TREE_VIEW (view), path,
								 gtk_tree_view_get_column (GTK_TREE_VIEW (view), 0), &column_rect);

	if (column_rect.x + width > visible_rect.x + visible_rect.width ||
		column_rect.x < visible_rect.x)
	{
		gtk_tooltip_set_text (tooltip, filename);
		gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view),
									   tooltip,
									   path);
	} else
	{
		result = FALSE;
	}

	g_free (filename);
	gtk_tree_path_free (path);
	g_object_unref (layout);
	g_object_unref (context);
	
	return result;
}
示例#8
0
/* Determine where to pop up menu (if not activated by a mouse event) */
static void place_menu(GtkMenu *menu, gint *x, gint *y,
                       gboolean *push_in, gpointer data)
{
	TilemDisasmView *dv = data;
	GtkTreePath *path;
	GdkRectangle rect;
	GdkWindow *win;
	GdkScreen *screen;
	int n;

	win = gtk_tree_view_get_bin_window(GTK_TREE_VIEW(dv));
	gdk_window_get_origin(win, x, y);

	gtk_tree_view_get_cursor(GTK_TREE_VIEW(dv), &path, NULL);
	if (path) {
		gtk_tree_view_get_cell_area(GTK_TREE_VIEW(dv), path, NULL, &rect);
		gtk_tree_path_free(path);
		*y += rect.y + rect.height;
	}

	screen = gdk_drawable_get_screen(win);
	n = gdk_screen_get_monitor_at_point(screen, *x, *y);
	gtk_menu_set_monitor(menu, n);

	*push_in = FALSE;
}
示例#9
0
static void
menu_position (GtkMenu             *menu,
	       gint                *x,
	       gint                *y,
	       gboolean            *push_in,
	       PlumaDocumentsPanel *panel)
{
	GtkTreePath *path;
	GdkRectangle rect;
	gint wx, wy;
	GtkAllocation allocation;
	GtkRequisition requisition;
	GtkWidget *w;

	w = panel->priv->treeview;

#if GTK_CHECK_VERSION (3, 0, 0)
	gtk_widget_get_allocation(w, &allocation);
#else
	allocation = w->allocation;
#endif

	path = get_current_path (panel);

	gtk_tree_view_get_cell_area (GTK_TREE_VIEW (w),
				     path,
				     NULL,
				     &rect);

	wx = rect.x;
	wy = rect.y;

#if GTK_CHECK_VERSION (3, 0, 0)
	gdk_window_get_origin (gtk_widget_get_window (w), x, y);
#else
	gdk_window_get_origin (w->window, x, y);
#endif
	
	gtk_widget_size_request (GTK_WIDGET (menu), &requisition);

	if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
	{
		*x += allocation.x + allocation.width - requisition.width - 10;
	}
	else
	{
		*x += allocation.x + 10;
	}

	wy = MAX (*y + 5, *y + wy + 5);
	wy = MIN (wy, *y + allocation.height - requisition.height - 5);
	
	*y = wy;

	*push_in = TRUE;
}
示例#10
0
static VALUE
rg_get_cell_area(VALUE self, VALUE path, VALUE column)
{
    GdkRectangle rect;
    gtk_tree_view_get_cell_area(_SELF(self), 
                                NIL_P(path) ? NULL : RVAL2GTKTREEPATH(path),
                                NIL_P(column) ? NULL : TREEVIEW_COL(column), 
                                &rect);
    return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE);
}
示例#11
0
static void
menu_position_under_tree_view (GtkMenu  *menu,
			       gint     *x,
			       gint     *y,
			       gboolean *push_in,
			       gpointer  user_data)
{
	GtkTreeView *tree = GTK_TREE_VIEW (user_data);
	GtkTreeModel *model;
	GtkTreeSelection *selection;
	GtkTreeIter iter;

	model = gtk_tree_view_get_model (tree);

	g_return_if_fail (model != NULL);

	selection = gtk_tree_view_get_selection (tree);

	g_return_if_fail (selection != NULL);

	if (gtk_tree_selection_get_selected (selection, NULL, &iter)) {
		GtkTreePath *path;
		GdkRectangle rect;

		gdk_window_get_origin (gtk_widget_get_window(GTK_WIDGET (tree)),
				       x, y);

		path = gtk_tree_model_get_path (model, &iter);

		gtk_tree_view_get_cell_area (tree,
					     path,
					     gtk_tree_view_get_column (tree, 0), /* FIXME 0 for RTL ? */
					     &rect);
		gtk_tree_path_free (path);

		*x += rect.x;
		*y += rect.y + rect.height;

		if (gtk_widget_get_direction (GTK_WIDGET (tree)) == GTK_TEXT_DIR_RTL) {
			GtkRequisition requisition;

			gtk_widget_size_request (GTK_WIDGET (menu), &requisition);

			*x += rect.width - requisition.width;
		}
	} else {
		/* No selection -> regular "under widget" positioning */
		menu_position_under_widget (menu,
					    x, y, push_in,
					    tree);
	}
}
示例#12
0
static void
each_path_get_data_binder (CajaDragEachSelectedItemDataGet data_get,
                           gpointer context,
                           gpointer data)
{
    DragDataGetInfo *info;
    GList *l;
    CajaFile *file;
    GtkTreeRowReference *row;
    GtkTreePath *path;
    char *uri;
    GdkRectangle cell_area;
    GtkTreeViewColumn *column;

    info = context;

    g_return_if_fail (info->model->details->drag_view);

    column = gtk_tree_view_get_column (info->model->details->drag_view, 0);

    for (l = info->path_list; l != NULL; l = l->next)
    {
        row = l->data;

        path = gtk_tree_row_reference_get_path (row);
        file = fm_list_model_file_for_path (info->model, path);
        if (file)
        {
            gtk_tree_view_get_cell_area
            (info->model->details->drag_view,
             path,
             column,
             &cell_area);

            uri = caja_file_get_uri (file);

            (*data_get) (uri,
                         0,
                         cell_area.y - info->model->details->drag_begin_y,
                         cell_area.width, cell_area.height,
                         data);

            g_free (uri);

            caja_file_unref (file);
        }

        gtk_tree_path_free (path);
    }
}
示例#13
0
/**
 * called when we begin a drag,
 * find what cell was under the cursor and change it
 *
 * \param tree_view
 * \param drag_context
 * \param null
 *
 * \return FALSE
 * */
gboolean gsb_form_config_drag_begin ( GtkWidget *tree_view,
				      GdkDragContext *drag_context,
				      gpointer null )
{
    gint x, y;
    GtkTreePath *path;
    GtkTreeViewColumn *tree_column;
    GdkWindow *drawable;
    GdkRectangle rectangle;
    GdkPixbuf *pixbuf_cursor;

    /* get the cell coord */
    gdk_window_get_pointer ( gtk_tree_view_get_bin_window ( GTK_TREE_VIEW ( tree_view )),
			     &x,
			     &y,
			     FALSE );
    gtk_tree_view_get_path_at_pos ( GTK_TREE_VIEW ( tree_view ),
				    x,
				    y,
				    &path,
				    &tree_column,
				    NULL, NULL );

    if ( !path
	 ||
	 !tree_column )
	return FALSE;

    start_drag_column = g_list_index ( gtk_tree_view_get_columns ( GTK_TREE_VIEW ( tree_view )),
				       tree_column );
    start_drag_row = utils_str_atoi ( gtk_tree_path_to_string ( path ));

    /* draw the new cursor */
    drawable = gtk_tree_view_get_bin_window (GTK_TREE_VIEW ( tree_view ));
    gtk_tree_view_get_cell_area ( GTK_TREE_VIEW ( tree_view ),
				  path,
				  tree_column,
				  &rectangle );
    pixbuf_cursor = gdk_pixbuf_get_from_drawable ( NULL,
						   GDK_DRAWABLE (drawable),
						   gdk_colormap_get_system (),
						   rectangle.x, rectangle.y,
						   0, 0,
						   rectangle.width, rectangle.height );
    gtk_drag_source_set_icon_pixbuf ( tree_view,
				      pixbuf_cursor );
    g_object_unref (pixbuf_cursor);

    return FALSE;
}
示例#14
0
void
uim_cand_win_gtk_real_layout_sub_window(UIMCandWinGtk *cwin)
{
#if GTK_CHECK_VERSION(2, 90, 0)
    gint x, y, w, h, sw, sh, x2, y2, w2, h2;
#else
    gint x, y, w, h, d, sw, sh, x2, y2, w2, h2, d2;
#endif
    GdkRectangle rect;
    GtkTreePath *path;
    GtkTreeViewColumn *focus_column;

    if (!cwin->sub_window.window)
        return;

    gtk_tree_view_get_cursor(GTK_TREE_VIEW(cwin->view), &path, &focus_column);
    gtk_tree_view_get_cell_area(GTK_TREE_VIEW(cwin->view), path, NULL, &rect);
    gtk_tree_path_free(path);

#if GTK_CHECK_VERSION(2, 90, 0)
    gdk_window_get_geometry(gtk_widget_get_window(GTK_WIDGET(cwin)),
                            &x, &y, &w, &h);
#else
    gdk_window_get_geometry(gtk_widget_get_window(GTK_WIDGET(cwin)),
                            &x, &y, &w, &h, &d);
#endif
    gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(cwin)), &x, &y);

    sw = gdk_screen_get_width  (gdk_screen_get_default ());
    sh = gdk_screen_get_height (gdk_screen_get_default ());
#if GTK_CHECK_VERSION(2, 90, 0)
    gdk_window_get_geometry(gtk_widget_get_window(cwin->sub_window.window),
                            &x2, &y2, &w2, &h2);
#else
    gdk_window_get_geometry(gtk_widget_get_window(cwin->sub_window.window),
                            &x2, &y2, &w2, &h2, &d2);
#endif
    if (x + w + w2 > sw)
        x = x - w2;
    else
        x = x + w;

    if ((y + rect.y + h2) > sh)
        y = sh - h2;
    else
        y = y + rect.y;

    gtk_window_move(GTK_WINDOW(cwin->sub_window.window), x, y);
}
示例#15
0
文件: list.c 项目: testfarm/testfarm
static int row_is_visible(GtkTreeView *tree, GtkTreeIter *iter)
{
  GtkTreeModel *model = gtk_tree_view_get_model(tree);
  GtkTreePath *path;
  GdkRectangle rect;
  GdkRectangle visible;

  path = gtk_tree_model_get_path(model, iter);
  gtk_tree_view_get_cell_area(tree, path, gtk_tree_view_get_column(tree, 0), &rect);
  gtk_tree_path_free(path);

  gtk_tree_view_get_visible_rect(tree, &visible);
  //fprintf(stderr, "-- visible.height=%d rect.y=%d => %s\n", visible.height, rect.y, ((rect.y > 0) && ((rect.y - 1) <= visible.height)) ? "visible":"hidden");

 return (rect.y > 0) && ((rect.y - 1) <= visible.height);
}
示例#16
0
static void
menu_position (GtkMenu             *menu,
	       gint                *x,
	       gint                *y,
	       gboolean            *push_in,
	       GeditDocumentsPanel *panel)
{
	GtkTreePath *path;
	GdkRectangle rect;
	gint wy;
	GtkRequisition requisition;
	GtkWidget *w;
	GtkAllocation allocation;

	gedit_debug (DEBUG_PANEL);

	w = panel->priv->treeview;

	path = get_current_path (panel);
	gtk_tree_view_get_cell_area (GTK_TREE_VIEW (w),
				     path,
				     NULL,
				     &rect);
	gtk_tree_path_free (path);

	wy = rect.y;

	gdk_window_get_origin (gtk_widget_get_window (w), x, y);
	gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
	gtk_widget_get_allocation (w, &allocation);

	if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
	{
		*x += allocation.x + allocation.width - requisition.width - 10;
	}
	else
	{
		*x += allocation.x + 10;
	}

	wy = MAX (*y + 5, *y + wy + 5);
	wy = MIN (wy, *y + allocation.height - requisition.height - 5);

	*y = wy;

	*push_in = TRUE;
}
示例#17
0
文件: tasks.c 项目: rosedu/osmo
void
show_tasks_desc_panel (gboolean enable, GUI *appGUI) {

GtkTreeIter  iter;
GdkRectangle rect, visible_rect;
GtkTreePath  *visible_path;
GtkTreeModel *model;

    if(enable == TRUE) {

        if (gtk_tree_selection_get_selected (appGUI->tsk->tasks_list_selection, &model, &iter)) {

            gtk_paned_set_position(GTK_PANED(appGUI->tsk->tasks_paned), config.tasks_pane_pos);

            while (g_main_context_iteration(NULL, FALSE));

            visible_path = gtk_tree_model_get_path (model, &iter);

            if (visible_path) {

                gtk_tree_view_get_cell_area (GTK_TREE_VIEW (appGUI->tsk->tasks_list), visible_path, NULL, &rect);
                gtk_tree_view_get_visible_rect (GTK_TREE_VIEW (appGUI->tsk->tasks_list), &visible_rect);

                if (rect.y < visible_rect.y || rect.y > visible_rect.y + visible_rect.height) {
                        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (appGUI->tsk->tasks_list), visible_path, NULL, TRUE, 0.5, 0.0);
                }

                gtk_tree_path_free(visible_path);
            }

        } else {
            enable = FALSE;
        }

    } else {

        config.tasks_pane_pos = gtk_paned_get_position(GTK_PANED(appGUI->tsk->tasks_paned));
        gtk_paned_set_position(GTK_PANED(appGUI->tsk->tasks_paned), 99999);

    }

    appGUI->tsk->tasks_panel_status = enable;
}
示例#18
0
gboolean mw_motion_cb (GtkWidget *tv, GdkEventMotion *event, gpointer null)
{
	GtkTreePath *path;
	if(!gconf_client_get_bool(client, "/apps/gtodo/prefs/show-tooltip",NULL)) return FALSE;

	if(rect.y == 0 && rect.height == 0 && gtodo_timeout)
	{
		g_source_remove(gtodo_timeout);
		gtodo_timeout = 0;
		if (tipwindow) {
			gtk_widget_destroy(tipwindow);
			tipwindow = NULL;
		}
		return FALSE;

	}
	if (gtodo_timeout) {
		if (((int)event->y > rect.y) && (((int)event->y - rect.height) < rect.y))
			return FALSE;

		if(event->y == 0)
		{
			g_source_remove(gtodo_timeout);
			return FALSE;

		}
		/* We've left the cell.  Remove the timeout and create a new one below */
		if (tipwindow) {
			gtk_widget_destroy(tipwindow);
			tipwindow = NULL;
		}

		g_source_remove(gtodo_timeout);
	}

	if(gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL))
	{
		gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, NULL, &rect);
		gtk_tree_path_free(path);
		if(rect.y != 0 && rect.height != 0) gtodo_timeout = g_timeout_add(500, (GSourceFunc)mw_tooltip_timeout, tv);
	}
	return FALSE;
}
示例#19
0
static gint row_number (void)
{
    gint nbrow;
    GtkAdjustment *vadj;
    GdkRectangle rect;
    GtkTreePath *path;

    gtk_tree_view_get_cursor (GTK_TREE_VIEW (main_gui.displayed_list), &path, NULL);
    gtk_tree_view_get_cell_area (GTK_TREE_VIEW (main_gui.displayed_list),
                                 path,
                                 NULL, &rect);

    /* Getting the vertical window area */
    vadj=gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (main_gui.scrolled_window_games));

    nbrow = (gint) ((gint)vadj->page_size / (gint)rect.height) - 1;

    return nbrow;
}
示例#20
0
/* Position function for the popup menu.
 * It positions the popup below the selected row, or above if it doesn't fit.
 * If there is no selection, positions on the top left corner. */
static void
tree_view_popup_menu_position_func (GtkMenu     *menu,
                                    gint        *x,
                                    gint        *y,
                                    gboolean    *push_in,
                                    GguTreeView *self)
{
  GtkTreeView      *view = GTK_TREE_VIEW (self);
  GtkTreeSelection *selection;
  GtkTreeModel     *model;
  GtkTreeIter       iter;
  
  gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (self)), x, y);
  /* We let GTK do whatever it wants, so we just give a reasonable
   * suggestion without the need to check if we really end up with something
   * valuable (though we try hard) */
  *push_in = TRUE;
  
  selection = gtk_tree_view_get_selection (view);
  if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
    GdkScreen      *screen = gtk_widget_get_screen (GTK_WIDGET (self));
    GtkTreePath    *path;
    GdkRectangle    rect;
    GtkRequisition  menu_req;
    
    gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
    
    path = gtk_tree_model_get_path (model, &iter);
    gtk_tree_view_get_cell_area (view, path, NULL, &rect);
    gtk_tree_view_convert_bin_window_to_widget_coords (view, 0, rect.y,
                                                       NULL, &rect.y);
    gtk_tree_path_free (path);
    
    (*y) += rect.y + rect.height;
    /* If the menu doesn't fit below the row, try above */
    if ((*y) + menu_req.height > gdk_screen_get_height (screen)) {
      (*y) -= rect.height + menu_req.height;
    }
  } else {
    gtk_tree_view_convert_bin_window_to_widget_coords (view, 0, *y, NULL, y);
  }
}
示例#21
0
文件: gul-gui.c 项目: GNOME/galeon
void
gul_gui_menu_position_tree_selection (GtkMenu	*menu,
				      gint	*x,
				      gint	*y,
				      gboolean	*push_in,
				      gpointer	user_data)
{
	GtkTreeSelection *selection;
	GList *selected_rows;
	GtkTreeModel *model;
	GtkTreeView *tree_view = GTK_TREE_VIEW (user_data);
	GtkWidget *widget = GTK_WIDGET (user_data);
	GtkRequisition req;
	GdkRectangle visible;

	gtk_widget_size_request (GTK_WIDGET (menu), &req);
	gdk_window_get_origin (widget->window, x, y);

	*x += (widget->allocation.width - req.width) / 2;

	/* Add on height for the treeview title */
	gtk_tree_view_get_visible_rect (tree_view, &visible);
	*y += widget->allocation.height - visible.height;

	selection = gtk_tree_view_get_selection (tree_view);
	selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
	if (selected_rows)
	{
		GdkRectangle cell_rect;

		gtk_tree_view_get_cell_area (tree_view, selected_rows->data,
					     NULL, &cell_rect);

		*y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height);
		
		g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL);
		g_list_free (selected_rows);
	}

	gul_gui_sanitise_popup_position (menu, widget, x, y);
}
示例#22
0
static gboolean
_dtv_query_tooltip (GtkWidget  *widget,
                    gint        x,
                    gint        y,
                    gboolean    keyboard_mode,
                    GtkTooltip *tooltip)
{
  int                    bin_x, bin_y;
  GtkTreePath           *path = NULL;
  GtkTreeViewColumn     *column;
  GtkTreeIter            iter;
  GtkTreeModel          *model;
  GdkRectangle           cell_area;
  GString               *markup;
  gboolean               had_info = FALSE;

  gtk_tree_view_convert_widget_to_bin_window_coords (
	GTK_TREE_VIEW (widget), x, y, &bin_x, &bin_y);

  if (gtk_tree_view_get_path_at_pos
	(GTK_TREE_VIEW (widget), bin_x, bin_y, &path, &column, NULL, NULL)) {

    model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
    if (gtk_tree_model_get_iter (model, &iter, path)) {
      /* show some useful  information */
      Diagram   *diagram;
      Layer     *layer;
      DiaObject *object;


      gtk_tree_model_get (model, &iter, DIAGRAM_COLUMN, &diagram, -1);
      gtk_tree_model_get (model, &iter, LAYER_COLUMN, &layer, -1);
      gtk_tree_model_get (model, &iter, OBJECT_COLUMN, &object, -1);

      markup = g_string_new (NULL);

      if (diagram) {
        gchar *em = g_markup_printf_escaped ("<b>%s</b>: %s\n", _("Diagram"), diagram->filename);
        g_string_append (markup, em);
        g_free (em);
      }

      if (layer) {
        gchar *name = layer_get_name (layer);
        gchar *em = g_markup_printf_escaped ("<b>%s</b>: %s\n", _("Layer"), name);
        g_string_append (markup, em);
        g_free (em);
        g_free (name);
      } else if (diagram) {
	int layers = data_layer_count (DIA_DIAGRAM_DATA (diagram));
	g_string_append_printf (markup, g_dngettext (GETTEXT_PACKAGE, "%d Layer", "%d Layers",
			        layers), layers);
      }
      if (object) {
        gchar *em = g_markup_printf_escaped ("<b>%s</b>: %s\n", _("Type"), object->type->name);
        g_string_append (markup, em);
        g_free (em);
        g_string_append_printf (markup, "<b>%s</b>: %g,%g\n", Q_("object|Position"), 
			        object->position.x, object->position.y);
	g_string_append_printf (markup, "%d %s", 
	                        g_list_length (object->children), _("Children"));
        /* and some dia_object_get_meta ? */
      } else if (layer) {
	int objects = layer_object_count (layer);
	g_string_append_printf (markup, g_dngettext (GETTEXT_PACKAGE, "%d Object", "%d Objects",
	                        objects), objects);
      }

      if (markup->len > 0) {
        gtk_tree_view_get_cell_area (GTK_TREE_VIEW (widget), path, column, &cell_area);

        gtk_tree_view_convert_bin_window_to_widget_coords
			(GTK_TREE_VIEW (widget), cell_area.x, cell_area.y,
			 &cell_area.x, &cell_area.y);

        gtk_tooltip_set_tip_area (tooltip, &cell_area);
        gtk_tooltip_set_markup (tooltip, markup->str);
	had_info = TRUE;
      }

      /* drop references */
      if (diagram)
        g_object_unref (diagram);
      g_string_free (markup, TRUE);
    }
    gtk_tree_path_free (path);
    if (had_info)
      return TRUE;
  }

  return GTK_WIDGET_CLASS (_dtv_parent_class)->query_tooltip 
						(widget, x, y, keyboard_mode, tooltip);
}
static gboolean
gimp_container_tree_view_drop_status (GimpContainerTreeView    *tree_view,
                                      GdkDragContext           *context,
                                      gint                      x,
                                      gint                      y,
                                      guint                     time,
                                      GtkTreePath             **return_path,
                                      GdkAtom                  *return_atom,
                                      GimpDndType              *return_src_type,
                                      GimpViewable            **return_src,
                                      GimpViewable            **return_dest,
                                      GtkTreeViewDropPosition  *return_pos)
{
  GimpViewable            *src_viewable  = NULL;
  GimpViewable            *dest_viewable = NULL;
  GtkTreePath             *drop_path     = NULL;
  GtkTargetList           *target_list;
  GdkAtom                  target_atom;
  GimpDndType              src_type;
  GtkTreeViewDropPosition  drop_pos      = GTK_TREE_VIEW_DROP_BEFORE;
  GdkDragAction            drag_action   = 0;

  if (! gimp_container_view_get_container (GIMP_CONTAINER_VIEW (tree_view)) ||
      ! gimp_container_view_get_reorderable (GIMP_CONTAINER_VIEW (tree_view)))
    goto drop_impossible;

  target_list = gtk_drag_dest_get_target_list (GTK_WIDGET (tree_view->view));
  target_atom = gtk_drag_dest_find_target (GTK_WIDGET (tree_view->view),
                                           context, target_list);
  if (! gtk_target_list_find (target_list, target_atom, &src_type))
    goto drop_impossible;

  switch (src_type)
    {
    case GIMP_DND_TYPE_URI_LIST:
    case GIMP_DND_TYPE_TEXT_PLAIN:
    case GIMP_DND_TYPE_NETSCAPE_URL:
    case GIMP_DND_TYPE_COLOR:
    case GIMP_DND_TYPE_SVG:
    case GIMP_DND_TYPE_SVG_XML:
    case GIMP_DND_TYPE_COMPONENT:
    case GIMP_DND_TYPE_PIXBUF:
      break;

    default:
      {
        GtkWidget *src_widget = gtk_drag_get_source_widget (context);

        if (! src_widget)
          goto drop_impossible;

        src_viewable = gimp_dnd_get_drag_data (src_widget);

        if (! GIMP_IS_VIEWABLE (src_viewable))
          goto drop_impossible;
      }
      break;
    }

  if (gtk_tree_view_get_path_at_pos (tree_view->view, x, y,
                                     &drop_path, NULL, NULL, NULL))
    {
      GimpViewRenderer *renderer;
      GtkTreeIter       iter;
      GdkRectangle      cell_area;

      gtk_tree_model_get_iter (tree_view->model, &iter, drop_path);

      gtk_tree_model_get (tree_view->model, &iter,
                          GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &renderer,
                          -1);

      dest_viewable = renderer->viewable;

      g_object_unref (renderer);

      gtk_tree_view_get_cell_area (tree_view->view, drop_path, NULL, &cell_area);

      if (gimp_viewable_get_children (dest_viewable))
        {
          if (gtk_tree_view_row_expanded (tree_view->view, drop_path))
            {
              if (y >= (cell_area.y + cell_area.height / 2))
                drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
              else
                drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
            }
          else
            {
              if (y >= (cell_area.y + 2 * (cell_area.height / 3)))
                drop_pos = GTK_TREE_VIEW_DROP_AFTER;
              else if (y <= (cell_area.y + cell_area.height / 3))
                drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
              else
                drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
            }
        }
      else
        {
          if (y >= (cell_area.y + cell_area.height / 2))
            drop_pos = GTK_TREE_VIEW_DROP_AFTER;
          else
            drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
        }
    }
  else
    {
      GtkTreeIter iter;
      gint        n_children;

      n_children = gtk_tree_model_iter_n_children (tree_view->model, NULL);

      if (n_children > 0 &&
          gtk_tree_model_iter_nth_child (tree_view->model, &iter,
                                         NULL, n_children - 1))
        {
          GimpViewRenderer *renderer;

          gtk_tree_model_get (tree_view->model, &iter,
                              GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER,
                              &renderer,
                              -1);

          drop_path     = gtk_tree_model_get_path (tree_view->model, &iter);
          dest_viewable = renderer->viewable;
          drop_pos      = GTK_TREE_VIEW_DROP_AFTER;

          g_object_unref (renderer);
        }
    }

  if (dest_viewable || tree_view->priv->dnd_drop_to_empty)
    {
      if (GIMP_CONTAINER_TREE_VIEW_GET_CLASS (tree_view)->drop_possible (tree_view,
                                                                         src_type,
                                                                         src_viewable,
                                                                         dest_viewable,
                                                                         drop_path,
                                                                         drop_pos,
                                                                         &drop_pos,
                                                                         &drag_action))
        {
          gdk_drag_status (context, drag_action, time);

          if (return_path)
            *return_path = drop_path;
          else
            gtk_tree_path_free (drop_path);

          if (return_atom)
            *return_atom = target_atom;

          if (return_src)
            *return_src = src_viewable;

          if (return_dest)
            *return_dest = dest_viewable;

          if (return_pos)
            *return_pos = drop_pos;

          return TRUE;
        }

      gtk_tree_path_free (drop_path);
    }

 drop_impossible:

  gdk_drag_status (context, 0, time);

  return FALSE;
}