コード例 #1
0
ファイル: icon-grid.c プロジェクト: setzer22/lxpanel
static gboolean panel_icon_grid_expose(GtkWidget *widget, GdkEventExpose *event)
#endif
{
    if (gtk_widget_is_drawable(widget))
    {
        if (gtk_widget_get_has_window(widget) &&
            !gtk_widget_get_app_paintable(widget))
#if GTK_CHECK_VERSION(3, 0, 0)
            gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0,
                                  gtk_widget_get_allocated_width(widget),
                                  gtk_widget_get_allocated_height(widget));
#else
            gtk_paint_flat_box(gtk_widget_get_style(widget),
                               gtk_widget_get_window(widget),
                               gtk_widget_get_state(widget), GTK_SHADOW_NONE,
                               &event->area, widget, "panelicongrid",
                               0, 0, -1, -1);
#endif

#if GTK_CHECK_VERSION(3, 0, 0)
        GTK_WIDGET_CLASS(panel_icon_grid_parent_class)->draw(widget, cr);
#else
        GTK_WIDGET_CLASS(panel_icon_grid_parent_class)->expose_event(widget, event);
#endif
    }
    return FALSE;
}
コード例 #2
0
ファイル: mozcontainer.c プロジェクト: at13/mozilla-central
void
moz_container_map (GtkWidget *widget)
{
    MozContainer *container;
    GList *tmp_list;
    GtkWidget *tmp_child;

    g_return_if_fail (IS_MOZ_CONTAINER(widget));
    container = MOZ_CONTAINER (widget);

    gtk_widget_set_mapped(widget, TRUE);

    tmp_list = container->children;
    while (tmp_list) {
        tmp_child = ((MozContainerChild *)tmp_list->data)->widget;
    
        if (gtk_widget_get_visible(tmp_child)) {
            if (!gtk_widget_get_mapped(tmp_child))
                gtk_widget_map(tmp_child);
        }
        tmp_list = tmp_list->next;
    }

    if (gtk_widget_get_has_window (widget)) {
        gdk_window_show (gtk_widget_get_window(widget));
    }
}
コード例 #3
0
ファイル: gimpwidgetsutils.c プロジェクト: jiapei100/gimp
GdkMonitor *
gimp_widget_get_monitor (GtkWidget *widget)
{
  GdkWindow     *window;
  GtkAllocation  allocation;
  gint           x, y;

  g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);

  window = gtk_widget_get_window (widget);

  if (! window)
    return gimp_get_monitor_at_pointer ();

  gdk_window_get_origin (window, &x, &y);
  gtk_widget_get_allocation (widget, &allocation);

  if (! gtk_widget_get_has_window (widget))
    {
      x += allocation.x;
      y += allocation.y;
    }

  x += allocation.width  / 2;
  y += allocation.height / 2;

  return gdk_display_get_monitor_at_point (gdk_display_get_default (), x, y);
}
コード例 #4
0
ファイル: remmina_public.c プロジェクト: BillTheBest/Remmina
void remmina_public_popup_position(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
{
	GtkWidget *widget;
	gint tx, ty;
	GtkAllocation allocation;

	widget = GTK_WIDGET(user_data);
	if (gtk_widget_get_window(widget) == NULL)
	{
		*x = 0;
		*y = 0;
		*push_in = TRUE;
		return;
	}
	gdk_window_get_origin(gtk_widget_get_window(widget), &tx, &ty);
	gtk_widget_get_allocation(widget, &allocation);
	if (gtk_widget_get_has_window(widget))
	{
		tx += allocation.x;
		ty += allocation.y;
	}

	*x = tx;
	*y = ty + allocation.height - 1;
	*push_in = TRUE;
}
コード例 #5
0
/* Translates coordinates from dest_widget->window relative (src_x, src_y),
 * to allocation relative (dest_x, dest_y) of dest_widget.
 */
static void
window_to_alloc (GtkWidget *dest_widget,
		 gint       src_x,
		 gint       src_y,
		 gint      *dest_x,
		 gint      *dest_y)
{
  /* Translate from window relative to allocation relative */
  if (gtk_widget_get_has_window (dest_widget) && dest_widget->parent)
    {
      gint wx, wy;
      gdk_window_get_position (dest_widget->window, &wx, &wy);

      /* Offset coordinates if widget->window is smaller than
       * widget->allocation.
       */
      src_x += wx - dest_widget->allocation.x;
      src_y += wy - dest_widget->allocation.y;
    }
  else
    {
      src_x -= dest_widget->allocation.x;
      src_y -= dest_widget->allocation.y;
    }

  if (dest_x)
    *dest_x = src_x;
  if (dest_y)
    *dest_y = src_y;
}
コード例 #6
0
void
gimp_popup_show (GimpPopup *popup,
                 GtkWidget *widget)
{
    GdkScreen      *screen;
    GtkRequisition  requisition;
    GtkAllocation   allocation;
    GdkRectangle    rect;
    gint            monitor;
    gint            orig_x;
    gint            orig_y;
    gint            x;
    gint            y;

    g_return_if_fail (GIMP_IS_POPUP (popup));
    g_return_if_fail (GTK_IS_WIDGET (widget));

    gtk_widget_size_request (GTK_WIDGET (popup), &requisition);

    gtk_widget_get_allocation (widget, &allocation);
    gdk_window_get_origin (gtk_widget_get_window (widget), &orig_x, &orig_y);

    if (! gtk_widget_get_has_window (widget))
    {
        orig_x += allocation.x;
        orig_y += allocation.y;
    }

    screen = gtk_widget_get_screen (widget);

    monitor = gdk_screen_get_monitor_at_point (screen, orig_x, orig_y);
    gdk_screen_get_monitor_workarea (screen, monitor, &rect);

    if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
    {
        x = orig_x + allocation.width - requisition.width;

        if (x < rect.x)
            x -= allocation.width - requisition.width;
    }
    else
    {
        x = orig_x;

        if (x + requisition.width > rect.x + rect.width)
            x += allocation.width - requisition.width;
    }

    y = orig_y + allocation.height;

    if (y + requisition.height > rect.y + rect.height)
        y = orig_y - requisition.height;

    gtk_window_set_screen (GTK_WINDOW (popup), screen);
    gtk_window_set_transient_for (GTK_WINDOW (popup),
                                  GTK_WINDOW (gtk_widget_get_toplevel (widget)));

    gtk_window_move (GTK_WINDOW (popup), x, y);
    gtk_widget_show (GTK_WIDGET (popup));
}
コード例 #7
0
ファイル: gimpwidgetsutils.c プロジェクト: ni1son/gimp
gint
gimp_widget_get_monitor (GtkWidget *widget)
{
    GdkWindow     *window;
    GdkScreen     *screen;
    GtkAllocation  allocation;
    gint           x, y;

    g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);

    window = gtk_widget_get_window (widget);

    if (! window)
        return gimp_get_monitor_at_pointer (&screen);

    screen = gtk_widget_get_screen (widget);

    gdk_window_get_origin (window, &x, &y);
    gtk_widget_get_allocation (widget, &allocation);

    if (! gtk_widget_get_has_window (widget))
    {
        x += allocation.x;
        y += allocation.y;
    }

    x += allocation.width  / 2;
    y += allocation.height / 2;

    return gdk_screen_get_monitor_at_point (screen, x, y);
}
コード例 #8
0
ファイル: ev-document-misc.c プロジェクト: hashken/evince
void
ev_document_misc_get_pointer_position (GtkWidget *widget,
                                       gint      *x,
                                       gint      *y)
{
    GdkDeviceManager *device_manager;
    GdkDevice        *device_pointer;
    GdkRectangle      allocation;

    if (x)
        *x = -1;
    if (y)
        *y = -1;

    if (!gtk_widget_get_realized (widget))
        return;

    device_manager = gdk_display_get_device_manager (gtk_widget_get_display (widget));
    device_pointer = gdk_device_manager_get_client_pointer (device_manager);
    gdk_window_get_device_position (gtk_widget_get_window (widget),
                                    device_pointer,
                                    x, y, NULL);

    if (gtk_widget_get_has_window (widget))
        return;

    gtk_widget_get_allocation (widget, &allocation);
    if (x)
        *x -= allocation.x;
    if (y)
        *y -= allocation.y;
}
コード例 #9
0
static void
emoticon_tool_button_reposition_window (EEmoticonToolButton *button)
{
	GdkScreen *screen;
	GdkWindow *window;
	GdkRectangle monitor;
	GtkAllocation allocation;
	gint monitor_num;
	gint x, y, width, height;

	screen = gtk_widget_get_screen (GTK_WIDGET (button));
	window = gtk_widget_get_window (GTK_WIDGET (button));
	monitor_num = gdk_screen_get_monitor_at_window (screen, window);
	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);

	gdk_window_get_origin (window, &x, &y);

	if (!gtk_widget_get_has_window (GTK_WIDGET (button))) {
		gtk_widget_get_allocation (GTK_WIDGET (button), &allocation);
		x += allocation.x;
		y += allocation.y;
	}

	gtk_widget_get_allocation (button->priv->window, &allocation);
	width = allocation.width;
	height = allocation.height;

	x = CLAMP (x, monitor.x, monitor.x + monitor.width - width);
	y = CLAMP (y, monitor.y, monitor.y + monitor.height - height);

	gtk_window_move (GTK_WINDOW (button->priv->window), x, y);
}
コード例 #10
0
ファイル: ddbtabstrip.c プロジェクト: GalliumOS/deadbeef
static void
ddb_tabstrip_realize (GtkWidget *widget) {
    DdbTabStrip *darea = DDB_TABSTRIP (widget);
    GdkWindowAttr attributes;
    gint attributes_mask;

    if (!gtk_widget_get_has_window (widget))
    {
        GTK_WIDGET_CLASS (ddb_tabstrip_parent_class)->realize (widget);
    }
    else
    {
        gtk_widget_set_realized (widget, TRUE);

        attributes.window_type = GDK_WINDOW_CHILD;
        GtkAllocation a;
        gtk_widget_get_allocation (widget, &a);
        attributes.x = a.x;
        attributes.y = a.y;
        attributes.width = a.width;
        attributes.height = a.height;
        attributes.wclass = GDK_INPUT_OUTPUT;
        attributes.visual = gtk_widget_get_visual (widget);
#if !GTK_CHECK_VERSION(3,0,0)
        attributes.colormap = gtk_widget_get_colormap (widget);
#endif
        attributes.event_mask = gtk_widget_get_events (widget);
        attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK;

        attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
#if !GTK_CHECK_VERSION(3,0,0)
        attributes_mask |= GDK_WA_COLORMAP;
#endif

        GdkWindow *window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
        gtk_widget_set_window(widget, window);
        gdk_window_set_user_data (gtk_widget_get_window(widget), darea);

#if !GTK_CHECK_VERSION(3,0,0)
        widget->style = gtk_style_attach (widget->style, widget->window);
        gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
#else
        gtk_style_context_set_background (gtk_widget_get_style_context (widget), window);
#endif
    }

    ddb_tabstrip_send_configure (DDB_TABSTRIP (widget));
    GtkTargetEntry entry = {
        .target = TARGET_PLAYITEMS,
        .flags = GTK_TARGET_SAME_APP,
        .info = TARGET_SAMEWIDGET
    };
    gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
    gtk_drag_dest_add_uri_targets (widget);
    gtk_drag_dest_set_track_motion (widget, TRUE);
}
コード例 #11
0
void
uim_cand_win_horizontal_gtk_layout_sub_window(UIMCandWinHorizontalGtk *horizontal_cwin)
{
  UIMCandWinGtk *cwin;
#if GTK_CHECK_VERSION(2, 90, 0)
  gint x, y, w, h, x2, y2, w2, h2, x3, y3;
#else
  gint x, y, w, h, d, x2, y2, w2, h2, d2, x3, y3;
#endif
  struct index_button *idxbutton;

  g_return_if_fail(UIM_IS_CAND_WIN_HORIZONTAL_GTK(horizontal_cwin));
  cwin = UIM_CAND_WIN_GTK(horizontal_cwin);

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

#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);

#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 (horizontal_cwin->selected) {
    GtkWidget *button;
    idxbutton = horizontal_cwin->selected;
    button = GTK_WIDGET(idxbutton->button);
    gdk_window_get_origin(gtk_widget_get_window(button), &x3, &y3);

#if GTK_CHECK_VERSION(2, 18, 0)
    if (!gtk_widget_get_has_window(button)) {
      GtkAllocation allocation;
      gtk_widget_get_allocation(button, &allocation);
      x3 += allocation.x;
    }
#else
    if (GTK_WIDGET_NO_WINDOW(button))
      x3 += button->allocation.x;
#endif
  }
  y = y + h;

  gtk_window_move(GTK_WINDOW(cwin->sub_window.window), x3, y);
}
コード例 #12
0
ファイル: list_tooltip.c プロジェクト: abderrahim/anjuta
gboolean mw_tooltip_timeout(GtkWidget *tv)
{
	GtkAllocation allocation;
	int scr_w,scr_h, w, h, x, y;
	char *tooltiptext = NULL;

	tooltiptext = get_tooltip_text();

	tipwindow = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_widget_set_parent(tipwindow, tv);
	gtk_widget_set_app_paintable(tipwindow, TRUE);
	gtk_window_set_resizable(GTK_WINDOW(tipwindow), FALSE);
	gtk_widget_set_name(tipwindow, "gtk-tooltips");
	g_signal_connect(G_OBJECT(tipwindow), "expose_event",
			G_CALLBACK(mw_paint_tip), NULL);
	gtk_widget_ensure_style (tipwindow);

	layout = gtk_widget_create_pango_layout (tipwindow, NULL);
	pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
	pango_layout_set_width(layout, 300000);
	pango_layout_set_markup(layout, tooltiptext, strlen(tooltiptext));
	scr_w = gdk_screen_width();
	scr_h = gdk_screen_height();
	pango_layout_get_size (layout, &w, &h);
	w = PANGO_PIXELS(w) + 8;
	h = PANGO_PIXELS(h) + 8;

	gdk_window_get_pointer(NULL, &x, &y, NULL);
	if (!gtk_widget_get_has_window (mw.vbox))
	{
		gtk_widget_get_allocation (mw.vbox, &allocation);
		y += allocation.y;
	}

	x -= ((w >> 1) + 4);

	if ((x + w) > scr_w)
		x -= (x + w) - scr_w;
	else if (x < 0)
		x = 0;

	if ((y + h + 4) > scr_h)
		y = y - h;
	else
		y = y + 6;
	/*
	   g_object_unref(layout);
	   */
	g_free(tooltiptext);
	gtk_widget_set_size_request(tipwindow, w, h);
	gtk_window_move(GTK_WINDOW(tipwindow), x, y);
	gtk_widget_show(tipwindow);

	return FALSE;
}
コード例 #13
0
ファイル: mozcontainer.c プロジェクト: at13/mozilla-central
void
moz_container_unmap (GtkWidget *widget)
{
    g_return_if_fail (IS_MOZ_CONTAINER (widget));

    gtk_widget_set_mapped(widget, FALSE);

    if (gtk_widget_get_has_window (widget)) {
        gdk_window_hide (gtk_widget_get_window(widget));
    }
}
コード例 #14
0
ファイル: mozcontainer.c プロジェクト: at13/mozilla-central
void
moz_container_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
{
    MozContainer   *container;
    GList          *tmp_list;
    GtkAllocation   tmp_allocation;
    GtkRequisition  tmp_requisition;
    GtkWidget      *tmp_child;

    g_return_if_fail (IS_MOZ_CONTAINER (widget));

    /*  printf("moz_container_size_allocate %p %d %d %d %d\n",
        (void *)widget,
        allocation->x,
        allocation->y,
        allocation->width,
        allocation->height); */

    /* short circuit if you can */
    container = MOZ_CONTAINER (widget);
    gtk_widget_get_allocation(widget, &tmp_allocation);
    if (!container->children &&
        tmp_allocation.x == allocation->x &&
        tmp_allocation.y == allocation->y &&
        tmp_allocation.width == allocation->width &&
        tmp_allocation.height == allocation->height) {
        return;
    }

    gtk_widget_set_allocation(widget, allocation);

    tmp_list = container->children;

    while (tmp_list) {
        MozContainerChild *child = tmp_list->data;

        moz_container_allocate_child (container, child);

        tmp_list = tmp_list->next;
    }

    if (gtk_widget_get_has_window (widget) &&
        gtk_widget_get_realized (widget)) {

        gdk_window_move_resize(gtk_widget_get_window(widget),
                               allocation->x,
                               allocation->y,
                               allocation->width,
                               allocation->height);
    }
}
コード例 #15
0
ファイル: common-gtk.c プロジェクト: na4zagin3/uim
static void
calc_menu_position(GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
                   GtkWidget *button)
{
    gint sc_height, sc_width, menu_width, menu_height, button_height;
    GtkRequisition requisition;

    g_return_if_fail(x && y);
    g_return_if_fail(GTK_IS_BUTTON(button));

    gdk_window_get_origin(gtk_widget_get_window(button), x, y);
#if GTK_CHECK_VERSION(2, 90, 0)
    button_height = gdk_window_get_height(gtk_widget_get_window(button));
#else
    gdk_drawable_get_size(gtk_widget_get_window(button), NULL, &button_height);
#endif

#if GTK_CHECK_VERSION(2, 18, 0)
    if (!gtk_widget_get_has_window(button)) {
        GtkAllocation allocation;
        gtk_widget_get_allocation(button, &allocation);
        *x += allocation.x;
    }
#else
    if (GTK_WIDGET_NO_WINDOW(button))
        *x += button->allocation.x;
#endif

    sc_height = gdk_screen_get_height(gdk_screen_get_default());
    sc_width = gdk_screen_get_width(gdk_screen_get_default());

#if GTK_CHECK_VERSION(3, 0, 0)
    gtk_widget_get_preferred_size(GTK_WIDGET(menu), &requisition, NULL);
#else
    gtk_widget_size_request(GTK_WIDGET(menu), &requisition);
#endif

    menu_width = requisition.width;
    menu_height = requisition.height;

    if (*y + button_height + menu_height < sc_height)
        *y = *y + button_height;
    else {
        if (*y + button_height < sc_height / 2)
            *y = *y + button_height;
        else
            *y = *y - menu_height;
    }

    if (*x + menu_width > sc_width)
        *x = sc_width - menu_width;
}
コード例 #16
0
ファイル: sheet.c プロジェクト: rodolforg/oregano
/*
 * position within the sheet in pixel coordinates
 * coordinates are clamped to grid if grid is enabled
 * see snap_to_grid
 * zero point : top left corner of the window (not widget!)
 * x : horizontal, left to right
 * y : vertical, top to bottom
 * returns wether the position could be detected properly
 */
gboolean
sheet_get_pointer_pixel (Sheet *sheet, gdouble *x, gdouble *y)
{
	GtkAdjustment *hadj, *vadj;
	gdouble x1, y1;
	gint _x, _y;
	GdkDeviceManager *device_manager;
	GdkDevice *device_pointer;
	GdkRectangle allocation;


	// deprecated gtk_widget_get_pointer (GTK_WIDGET (sheet), &_x, &_y);
	// replaced by a code copied from evince

	if (G_UNLIKELY (!sheet || !gtk_widget_get_realized (GTK_WIDGET (sheet)))) {
		NG_DEBUG ("widget not realized");
		return FALSE;
	}

	device_manager = gdk_display_get_device_manager (
			gtk_widget_get_display (GTK_WIDGET (sheet)));
	device_pointer = gdk_device_manager_get_client_pointer (device_manager);
	//FIXME add another check based on the following functions return val
	//FIXME gtkdoc says this shall not be used in event handlers
	gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (sheet)),
					device_pointer,
					&_x, &_y, NULL);

	if (!gtk_widget_get_has_window (GTK_WIDGET (sheet))) {
		NG_DEBUG ("some weird gtk window shit failed");
		return FALSE;
	}
	
	gtk_widget_get_allocation (GTK_WIDGET (sheet), &allocation);

	_x -= allocation.x;
	_y -= allocation.y;

	x1 = (gdouble) _x;
	y1 = (gdouble) _y;

	if (!sheet_get_adjustments (sheet, &hadj, &vadj))
	      return FALSE;

	x1 += gtk_adjustment_get_value (hadj);
	y1 += gtk_adjustment_get_value (vadj);

	*x = x1;
	*y = y1;
	return TRUE;
}
コード例 #17
0
ファイル: sheet.c プロジェクト: dionysos-sf/oregano
void		
sheet_get_pointer (Sheet *sheet, gdouble *x, gdouble *y)
{
	GtkWidget        *widget;
	GtkAdjustment    *hadjustment;
	GtkAdjustment    *vadjustment;
	gdouble           value, x1, y1;
	gint              _x, _y;
	GdkDeviceManager *device_manager;
    GdkDevice        *device_pointer;
    GdkRectangle      allocation;


	// gtk_widget_get_pointer (GTK_WIDGET (sheet), &_x, &_y);
	// replaced by a code copied from evince
	
    if (!gtk_widget_get_realized (GTK_WIDGET (sheet)))
    	return;
	
	device_manager = gdk_display_get_device_manager (
	                gtk_widget_get_display (GTK_WIDGET (sheet)));
    device_pointer = gdk_device_manager_get_client_pointer (device_manager);
    gdk_window_get_device_position (gtk_widget_get_window (GTK_WIDGET (sheet)),
                    device_pointer,
                    &_x, &_y, NULL);
	if (!gtk_widget_get_has_window (GTK_WIDGET (sheet)))
    	return;
	
	gtk_widget_get_allocation (GTK_WIDGET (sheet), &allocation);
	
	_x -= allocation.x;
	_y -= allocation.y;

	x1 = (gdouble) _x;
	y1 = (gdouble) _y;
	
	widget = gtk_widget_get_parent (GTK_WIDGET (sheet));
	hadjustment =  gtk_scrolled_window_get_hadjustment (
	                 GTK_SCROLLED_WINDOW (widget));
	value = gtk_adjustment_get_value (hadjustment);

	x1 += value;
	vadjustment =  gtk_scrolled_window_get_vadjustment (
	                 GTK_SCROLLED_WINDOW (widget));
	value = gtk_adjustment_get_value (vadjustment);
	y1 += value;
	*x = x1;
	*y = y1;
	goo_canvas_convert_from_pixels (GOO_CANVAS (sheet), x, y);
	snap_to_grid (sheet->grid, x, y);
}
コード例 #18
0
static void
gctt_combott_menu_position (GtkMenu  *menu,
                            gint     *x,
                            gint     *y,
                            gint     *push_in,
                            gpointer  user_data)
{
    GncCombott *combott = GNC_COMBOTT (user_data);
    GncCombottPrivate *priv = GNC_COMBOTT_GET_PRIVATE (combott);
    gint sx, sy;
    GtkWidget *child;
    GtkRequisition req;
    GtkAllocation alloc;
    GtkBorder padding;
    GtkStyleContext *sc = gtk_widget_get_style_context (GTK_WIDGET (priv->button));
    GtkStateFlags state_flags = gtk_style_context_get_state (sc);

    child = gtk_bin_get_child (GTK_BIN (priv->button));

    sx = sy = 0;

    if (!gtk_widget_get_has_window (child))
    {
        gtk_widget_get_allocation (child, &alloc);
        sx += alloc.x;
        sy += alloc.y;
    }

    gdk_window_get_root_coords (gtk_widget_get_window (child), sx, sy, &sx, &sy);

    gtk_style_context_get_padding (sc, state_flags, &padding);

    sx -= padding.left;

    gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);

    if (gtk_widget_get_direction (GTK_WIDGET (priv->button)) == GTK_TEXT_DIR_LTR)
        *x = sx;
    else
    {
        gtk_widget_get_allocation (child, &alloc);
        *x = sx + alloc.width - req.width;
    }

    if(priv->active == -1 || priv->active == 0)
        *y = sy;
    else
        *y = sy - ((req.height / priv->num_items) * (priv->active - 1));

    *push_in = FALSE;
}
コード例 #19
0
static void
popup_button_position (PlannerPopupButton *button,
		       gint               *x,
		       gint               *y)
{
	PlannerPopupButtonPriv *priv;
	GtkWidget              *button_widget;
	GtkRequisition          popup_req;
	GdkScreen              *screen;
	gint                    monitor_num;
	GdkRectangle            monitor;

	priv = GET_PRIV (button);

	button_widget = GTK_WIDGET (button);

	gdk_window_get_origin (button_widget->window, x, y);

	if (! gtk_widget_get_has_window (button_widget)) {
		*x += button_widget->allocation.x;
		*y += button_widget->allocation.y;
	}

	/* The popup should be placed below the button, right-aligned to it. */
	*y += button_widget->allocation.height;
	*x += button_widget->allocation.width;

	gtk_widget_size_request (priv->popup_widget, &popup_req);

	*x -= popup_req.width;

	/* Don't popup outside the monitor edges. */
	screen = gtk_widget_get_screen (GTK_WIDGET (button));
	monitor_num = gdk_screen_get_monitor_at_window (
		screen, GTK_WIDGET (button)->window);
	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);

	if (*x < monitor.x) {
		*x = monitor.x;
	}
	else if (*x + popup_req.width > monitor.x + monitor.width) {
		*x = monitor.x + monitor.width - popup_req.width;
	}

	if (*y + popup_req.height > monitor.y + monitor.height) {
		*y -= popup_req.height + button_widget->allocation.height;
	}
}
コード例 #20
0
ファイル: mozcontainer.c プロジェクト: at13/mozilla-central
void
moz_container_realize (GtkWidget *widget)
{
    GdkWindow *parent = gtk_widget_get_parent_window (widget);
    GdkWindow *window;

    gtk_widget_set_realized(widget, TRUE);

    if (gtk_widget_get_has_window (widget)) {
        GdkWindowAttr attributes;
        gint attributes_mask = GDK_WA_VISUAL | GDK_WA_X | GDK_WA_Y;
        GtkAllocation allocation;

        gtk_widget_get_allocation (widget, &allocation);
        attributes.event_mask = gtk_widget_get_events (widget);
        attributes.x = allocation.x;
        attributes.y = allocation.y;
        attributes.width = allocation.width;
        attributes.height = allocation.height;
        attributes.wclass = GDK_INPUT_OUTPUT;
        attributes.visual = gtk_widget_get_visual (widget);
        attributes.window_type = GDK_WINDOW_CHILD;

#if (MOZ_WIDGET_GTK == 2)
        attributes.colormap = gtk_widget_get_colormap (widget);
        attributes_mask |= GDK_WA_COLORMAP;
#endif

        window = gdk_window_new (parent, &attributes, attributes_mask);
        gdk_window_set_user_data (window, widget);
#if (MOZ_WIDGET_GTK == 2)
        /* TODO GTK3? */
        /* set the back pixmap to None so that you don't end up with the gtk
           default which is BlackPixel */
        gdk_window_set_back_pixmap (window, NULL, FALSE);
#endif
    } else {
        window = parent;
        g_object_ref (window);
    }

    gtk_widget_set_window (widget, window);

#if (MOZ_WIDGET_GTK == 2)
    widget->style = gtk_style_attach (widget->style, widget->window);
#endif
}
コード例 #21
0
ファイル: gimpruler.c プロジェクト: AjayRamanathan/gimp
/* Returns TRUE if a translation should be done */
static gboolean
gtk_widget_get_translation_to_window (GtkWidget *widget,
                                      GdkWindow *window,
                                      int       *x,
                                      int       *y)
{
  GdkWindow *w, *widget_window;

  if (! gtk_widget_get_has_window (widget))
    {
      GtkAllocation allocation;

      gtk_widget_get_allocation (widget, &allocation);

      *x = -allocation.x;
      *y = -allocation.y;
    }
  else
    {
      *x = 0;
      *y = 0;
    }

  widget_window = gtk_widget_get_window (widget);

  for (w = window;
       w && w != widget_window;
       w = gdk_window_get_effective_parent (w))
    {
      gdouble px, py;

      gdk_window_coords_to_parent (w, *x, *y, &px, &py);

      *x += px;
      *y += py;
    }

  if (w == NULL)
    {
      *x = 0;
      *y = 0;
      return FALSE;
    }

  return TRUE;
}
コード例 #22
0
ファイル: gnc-combott.c プロジェクト: goodvibes2/gnucash
static void
gctt_combott_menu_position (GtkMenu  *menu,
                            gint     *x,
                            gint     *y,
                            gint     *push_in,
                            gpointer  user_data)
{
    GncCombott *combott = GNC_COMBOTT (user_data);
    GncCombottPrivate *priv = GNC_COMBOTT_GET_PRIVATE (combott);
    gint sx, sy;
    GtkWidget *child;
    GtkRequisition req;
    GtkAllocation alloc;

    child = gtk_bin_get_child (GTK_BIN (priv->button));

    sx = sy = 0;

    if (!gtk_widget_get_has_window (child))
    {
        gtk_widget_get_allocation (child, &alloc);
        sx += alloc.x;
        sy += alloc.y;
    }

    gdk_window_get_root_coords (gtk_widget_get_window (child), sx, sy, &sx, &sy);

    sx -= gtk_widget_get_style (GTK_WIDGET (priv->button))->xthickness;

    gtk_widget_size_request (GTK_WIDGET (menu), &req);

    if (gtk_widget_get_direction (GTK_WIDGET (priv->button)) == GTK_TEXT_DIR_LTR)
        *x = sx;
    else
    {
        gtk_widget_get_allocation (child, &alloc);
        *x = sx + alloc.width - req.width;
    }

    if(priv->active == -1 || priv->active == 0)
        *y = sy;
    else
        *y = sy - ((req.height / priv->num_items) * (priv->active - 1));

    *push_in = FALSE;
}
コード例 #23
0
ファイル: glade-cursor.c プロジェクト: GNOME/glade
static void
set_cursor (GladeProject *project,
            GdkCursor    *gdk_cursor)
{
  GList *list;

  for (list = (GList *) glade_project_get_objects (project);
       list; list = list->next)
    {
      GObject *object = list->data;

      if (GTK_IS_WIDGET (object) &&
          gtk_widget_get_has_window (GTK_WIDGET (object)))
        {
          set_cursor_recurse (GTK_WIDGET (object), gdk_cursor);
        }
    }
}
コード例 #24
0
wxWindowDCImpl::wxWindowDCImpl(wxWindowDC* owner, wxWindow* window)
    : wxGTKCairoDCImpl(owner, window)
{
    GtkWidget* widget = window->m_wxwindow;
    if (widget == NULL)
        widget = window->m_widget;
    GdkWindow* gdkWindow = NULL;
    if (widget)
    {
        gdkWindow = gtk_widget_get_window(widget);
        m_ok = true;
    }
    if (gdkWindow)
    {
        cairo_t* cr = gdk_cairo_create(gdkWindow);
        wxGraphicsContext* gc = wxGraphicsContext::CreateFromNative(cr);
        cairo_destroy(cr);
        gc->EnableOffset(m_contentScaleFactor <= 1);
        SetGraphicsContext(gc);
        GtkAllocation a;
        gtk_widget_get_allocation(widget, &a);
        int x, y;
        if (gtk_widget_get_has_window(widget))
        {
            m_size.x = gdk_window_get_width(gdkWindow);
            m_size.y = gdk_window_get_height(gdkWindow);
            x = m_size.x - a.width;
            y = m_size.y - a.height;
        }
        else
        {
            m_size.x = a.width;
            m_size.y = a.height;
            x = a.x;
            y = a.y;
            cairo_rectangle(cr, a.x, a.y, a.width, a.height);
            cairo_clip(cr);
        }
        if (x || y)
            SetDeviceLocalOrigin(x, y);
    }
    else
        SetGraphicsContext(wxGraphicsContext::Create());
}
コード例 #25
0
static void
launcher_do_zoom_animation (GtkWidget *widget)
{
	GdkScreen *screen;
	GtkSettings *settings;
	gboolean enable_animations;
	ButtonWidget *button_widget;
	GdkPixbuf *pixbuf;
	PanelOrientation orientation;
	gint x, y;
	GtkAllocation allocation;

	screen = gtk_widget_get_screen (widget);
	settings = gtk_widget_get_settings (widget);

	enable_animations = TRUE;
	g_object_get (settings,
		      "gtk-enable-animations", &enable_animations,
		      NULL);

	if (!enable_animations || !gdk_screen_is_composited (screen))
		return;

	button_widget = BUTTON_WIDGET (widget);
	pixbuf = button_widget_get_pixbuf (button_widget);
	orientation = button_widget_get_orientation (button_widget);

	if (!pixbuf)
		return;

	gdk_window_get_origin (gtk_widget_get_window (widget), &x, &y);
	gtk_widget_get_allocation (widget, &allocation);

	if (!gtk_widget_get_has_window (widget)) {
		x += allocation.x;
		y += allocation.y;
	}

	draw_zoom_animation_composited (screen, x,  y,
	                                allocation.width, allocation.height,
	                                pixbuf, orientation);

	g_object_unref (pixbuf);
}
コード例 #26
0
ファイル: ddbtabstrip.c プロジェクト: GalliumOS/deadbeef
static void
ddb_tabstrip_size_allocate (GtkWidget     *widget,
                            GtkAllocation *allocation)
{
    g_return_if_fail (DDB_IS_TABSTRIP (widget));
    g_return_if_fail (allocation != NULL);

    gtk_widget_set_allocation (widget, allocation);

    if (gtk_widget_get_realized (widget))
    {
        if (gtk_widget_get_has_window (widget))
            gdk_window_move_resize (gtk_widget_get_window(widget),
                                    allocation->x, allocation->y,
                                    allocation->width, allocation->height);

        ddb_tabstrip_send_configure (DDB_TABSTRIP (widget));
    }
}
コード例 #27
0
ファイル: ev-document-misc.c プロジェクト: Piiit/xreader
void
ev_document_misc_get_pointer_position (GtkWidget *widget,
                                       gint      *x,
                                       gint      *y)
{
#if GTK_CHECK_VERSION (3, 20, 0)
		GdkSeat *seat;
#else
        GdkDeviceManager *device_manager;
#endif
        GdkDevice        *device_pointer;
        GdkRectangle      allocation;

        if (x)
                *x = -1;
        if (y)
                *y = -1;

        if (!gtk_widget_get_realized (widget))
                return;

#if GTK_CHECK_VERSION(3, 20, 0)
        seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
        device_pointer = gdk_seat_get_pointer (seat);
#else
        device_manager = gdk_display_get_device_manager (gtk_widget_get_display (widget));
        device_pointer = gdk_device_manager_get_client_pointer (device_manager);
#endif
        gdk_window_get_device_position (gtk_widget_get_window (widget),
                                        device_pointer,
                                        x, y, NULL);

        if (gtk_widget_get_has_window (widget))
                return;

        gtk_widget_get_allocation (widget, &allocation);
        if (x)
                *x -= allocation.x;
        if (y)
                *y -= allocation.y;
}
コード例 #28
0
ファイル: dc.cpp プロジェクト: Kaoswerk/newton-dynamics
wxClientDCImpl::wxClientDCImpl(wxClientDC* owner, wxWindow* window)
    : base_type(owner, window)
{
    GtkWidget* widget = window->m_wxwindow;
    if (widget == NULL)
        widget = window->m_widget;
    GdkWindow* gdkWindow = NULL;
    if (widget)
    {
        gdkWindow = gtk_widget_get_window(widget);
        m_ok = true;
    }
    if (gdkWindow)
    {
        cairo_t* cr = gdk_cairo_create(gdkWindow);
        SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
        if (gtk_widget_get_has_window(widget))
        {
            m_width = gdk_window_get_width(gdkWindow);
            m_height = gdk_window_get_height(gdkWindow);
        }
        else
        {
            GtkAllocation a;
            gtk_widget_get_allocation(widget, &a);
            m_width = a.width;
            m_height = a.height;
            cairo_rectangle(cr, a.x, a.y, a.width, a.height);
            cairo_clip(cr);
            SetDeviceLocalOrigin(a.x, a.y);
        }
    }
    else
    {
        // create something that can be used for measuring, but not drawing
        cairo_t* cr = gdk_cairo_create(gdk_get_default_root_window());
        cairo_rectangle(cr, 0, 0, 0, 0);
        cairo_clip(cr);
        SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
    }
}
コード例 #29
0
static void
gimp_container_grid_view_menu_position (GtkMenu  *menu,
                                        gint     *x,
                                        gint     *y,
                                        gpointer  data)
{
  GimpContainerGridView *grid_view = GIMP_CONTAINER_GRID_VIEW (data);
  GtkWidget             *widget;
  GtkAllocation          allocation;

  if (grid_view->selected_item)
    widget = GTK_WIDGET (grid_view->selected_item);
  else
    widget = GTK_WIDGET (grid_view->wrap_box);

  gtk_widget_get_allocation (widget, &allocation);

  gdk_window_get_origin (gtk_widget_get_window (widget), x, y);

  if (! gtk_widget_get_has_window (widget))
    {
      *x += allocation.x;
      *y += allocation.y;
    }

  if (grid_view->selected_item)
    {
      *x += allocation.width  / 2;
      *y += allocation.height / 2;
    }
  else
    {
      GtkStyle *style = gtk_widget_get_style (widget);

      *x += style->xthickness;
      *y += style->ythickness;
    }

  gimp_menu_position (menu, x, y);
}
コード例 #30
0
ファイル: dc.cpp プロジェクト: Kaoswerk/newton-dynamics
wxWindowDCImpl::wxWindowDCImpl(wxWindowDC* owner, wxWindow* window)
    : base_type(owner, window)
{
    GtkWidget* widget = window->m_wxwindow;
    if (widget == NULL)
        widget = window->m_widget;
    GdkWindow* gdkWindow = NULL;
    if (widget)
    {
        gdkWindow = gtk_widget_get_window(widget);
        m_ok = true;
    }
    if (gdkWindow)
    {
        cairo_t* cr = gdk_cairo_create(gdkWindow);
        SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
        GtkAllocation a;
        gtk_widget_get_allocation(widget, &a);
        int x, y;
        if (gtk_widget_get_has_window(widget))
        {
            m_width = gdk_window_get_width(gdkWindow);
            m_height = gdk_window_get_height(gdkWindow);
            x = m_width - a.width;
            y = m_height - a.height;
        }
        else
        {
            m_width = a.width;
            m_height = a.height;
            x = a.x;
            y = a.y;
            cairo_rectangle(cr, a.x, a.y, a.width, a.height);
            cairo_clip(cr);
        }
        if (x || y)
            SetDeviceLocalOrigin(x, y);
    }
}