Esempio n. 1
0
static void
cpufreq_applet_popup_position_menu (GtkMenu  *menu,
                                    int      *x,
                                    int      *y,
                                    gboolean *push_in,
                                    gpointer  gdata)
{
        GtkWidget      *widget;
        GtkRequisition  requisition;
        GtkAllocation   allocation;
        gint            menu_xpos;
        gint            menu_ypos;

        widget = GTK_WIDGET (gdata);

        gtk_widget_size_request (GTK_WIDGET (menu), &requisition);

        gdk_window_get_origin (gtk_widget_get_window (widget), &menu_xpos, &menu_ypos);

	gtk_widget_get_allocation (widget, &allocation);

        menu_xpos += allocation.x;
        menu_ypos += allocation.y;

        switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (widget))) {
        case MATE_PANEL_APPLET_ORIENT_DOWN:
        case MATE_PANEL_APPLET_ORIENT_UP:
                if (menu_ypos > gdk_screen_get_height (gtk_widget_get_screen (widget)) / 2)
                        menu_ypos -= requisition.height;
                else
                        menu_ypos += allocation.height;
                break;
        case MATE_PANEL_APPLET_ORIENT_RIGHT:
        case MATE_PANEL_APPLET_ORIENT_LEFT:
                if (menu_xpos > gdk_screen_get_width (gtk_widget_get_screen (widget)) / 2)
                        menu_xpos -= requisition.width;
                else
                        menu_xpos += allocation.width;
                break;
        default:
                g_assert_not_reached ();
        }

        *x = menu_xpos;
        *y = menu_ypos;
        *push_in = TRUE;
}
Esempio n. 2
0
void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event)
{
    int width, height;
    GetClientSize(&width, &height);

    GtkWidget* ancestor = gtk_widget_get_toplevel(m_widget);
#ifdef __WXGTK3__
    GdkRectangle rect;
    if (ancestor && gtk_window_get_resize_grip_area(GTK_WINDOW(ancestor), &rect) &&
        rect.width && rect.height)
    {
        ancestor = NULL;
    }
#endif

    if (ancestor && ShowsSizeGrip() && event.GetX() > width - height)
    {
        GdkWindow *source = GTKGetDrawingWindow();

        int org_x = 0;
        int org_y = 0;
        gdk_window_get_origin( source, &org_x, &org_y );

        if (GetLayoutDirection() == wxLayout_RightToLeft)
        {
            gtk_window_begin_resize_drag (GTK_WINDOW (ancestor),
                                  GDK_WINDOW_EDGE_SOUTH_WEST,
                                  1,
                                  org_x - event.GetX() + GetSize().x ,
                                  org_y + event.GetY(),
                                  0);
        }
        else
        {
            gtk_window_begin_resize_drag (GTK_WINDOW (ancestor),
                                  GDK_WINDOW_EDGE_SOUTH_EAST,
                                  1,
                                  org_x + event.GetX(),
                                  org_y + event.GetY(),
                                  0);
        }
    }
    else
    {
        event.Skip( true );
    }
}
Esempio n. 3
0
void wxStatusBarGeneric::OnLeftDown(wxMouseEvent& event)
{
#ifdef __WXGTK20__
    int width, height;
    GetClientSize(&width, &height);

    if (HasFlag( wxST_SIZEGRIP ) && (event.GetX() > width-height))
    {
        GtkWidget *ancestor = gtk_widget_get_toplevel( m_widget );

        if (!GTK_IS_WINDOW (ancestor))
            return;

        GdkWindow *source = GTK_PIZZA(m_wxwindow)->bin_window;

        int org_x = 0;
        int org_y = 0;
        gdk_window_get_origin( source, &org_x, &org_y );

        if (GetLayoutDirection() == wxLayout_RightToLeft)
        {
            gtk_window_begin_resize_drag (GTK_WINDOW (ancestor),
                                  GDK_WINDOW_EDGE_SOUTH_WEST,
                                  1,
                                  org_x - event.GetX() + GetSize().x ,
                                  org_y + event.GetY(),
                                  0);
        }
        else
        {
            gtk_window_begin_resize_drag (GTK_WINDOW (ancestor),
                                  GDK_WINDOW_EDGE_SOUTH_EAST,
                                  1,
                                  org_x + event.GetX(),
                                  org_y + event.GetY(),
                                  0);
        }
    }
    else
    {
        event.Skip( true );
    }
#else
    event.Skip( true );
#endif
}
Esempio n. 4
0
File: gdl-dock.c Progetto: vldm/gdl
/**
 * gdl_dock_show_preview:
 * @dock: A #GdlDock widget
 * @rect: The position and the size of the preview window
 *
 * Show a preview window used to materialize the dock target.
 */
void
gdl_dock_show_preview (GdlDock      *dock,
                       cairo_rectangle_int_t *rect)
{
    gint x, y;
    GdkWindow* window = gtk_widget_get_window (GTK_WIDGET (dock));
    gdk_window_get_origin (window, &x, &y);

    if (!dock->priv->area_window) {
        dock->priv->area_window = gdl_preview_window_new ();
    }

    rect->x += x;
    rect->y += y;

    gdl_preview_window_update (GDL_PREVIEW_WINDOW (dock->priv->area_window), rect);
}
Esempio n. 5
0
static gboolean
gimp_pick_button_mouse_motion (GtkWidget      *invisible,
                               GdkEventMotion *event,
                               GimpPickButton *button)
{
  gint x_root;
  gint y_root;

  gdk_window_get_origin (event->window, &x_root, &y_root);
  x_root += event->x;
  y_root += event->y;

  gimp_pick_button_pick (gdk_event_get_screen ((GdkEvent *) event),
                         x_root, y_root, button);

  return TRUE;
}
Esempio n. 6
0
void set_to_corner(GtkMenu* menu, gint *x, gint *y, gboolean *set_to_false, gpointer data)
{
	pqi const inst = (pqi)data; /* Wrap for beauty */
	
	/* Get some information about our widget */
	struct xy mxy;
	GdkWindow *window; GdkRectangle monitor; GtkAllocation alloc; GtkRequisition smenu;
	
	*set_to_false = FALSE; /* Don't touch my menu. */
	window = gtk_widget_get_parent_window(inst->box); /* getting parent window */
	gdk_window_get_origin(window, &mxy.x1, &mxy.y1); /* parent's left-top screen coordinates */
	gdk_screen_get_monitor_geometry(gtk_widget_get_screen(inst->box), gtk_menu_get_monitor(menu), &monitor); /* Get the coordinates of the rectangle this screen displays */
	mxy.x2 = mxy.x1, mxy.y2 = mxy.y1;
	
	gtk_widget_get_allocation(inst->box, &alloc); /* Get the dimensions of our widget */
	switch (mate_panel_applet_get_orient(inst->applet)) /* Which points we use depends on the orientation of our panel */
	{
		case MATE_PANEL_APPLET_ORIENT_UP:    mxy.x2 += alloc.width;  break;
		case MATE_PANEL_APPLET_ORIENT_RIGHT: mxy.x1 += alloc.width;  mxy.x2 += alloc.width;  mxy.y2 += alloc.height; break;
		case MATE_PANEL_APPLET_ORIENT_DOWN:  mxy.y1 += alloc.height; mxy.y2 += alloc.height; mxy.x2 += alloc.width;  break;
		case MATE_PANEL_APPLET_ORIENT_LEFT:  mxy.y2 += alloc.height; break;
	}
	
	mxy.x1 += monitor.x, mxy.x2 += monitor.x,
	mxy.y1 += monitor.y, mxy.y2 += monitor.y; /* Account for x and y offsets if this screen isn't at the top-left corner */
	
	gtk_widget_size_request(GTK_WIDGET(menu), &smenu); /* Get the dimensions of our menu */
	
	if (mxy.x1 + smenu.width > monitor.x + monitor.width)
	{
		if (mxy.x2 - smenu.width > monitor.x)
			mxy.x1 = mxy.x2 - smenu.width;
		else
			mxy.x1 = monitor.x + monitor.width - smenu.width;
	}
	if (mxy.y1 + smenu.height > monitor.y + monitor.height)
	{
		if (mxy.y2 - smenu.height > monitor.y)
			mxy.y1 = mxy.y2 - smenu.height;
		else
			mxy.y1 = monitor.y + monitor.height - smenu.height;
	}
	
	*x = mxy.x1, *y = mxy.y1; /* Just use the position we logged earlier */
}
Esempio n. 7
0
void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
{
    ASSERT(client());

    if (!m_popup) {
        m_popup = GTK_MENU(gtk_menu_new());
        g_object_ref(G_OBJECT(m_popup));
        gtk_object_sink(GTK_OBJECT(m_popup));
        g_signal_connect(m_popup, "unmap", G_CALLBACK(menuUnmapped), this);
    } else
        gtk_container_foreach(GTK_CONTAINER(m_popup), reinterpret_cast<GtkCallback>(menuRemoveItem), this);

    int x, y;
    gdk_window_get_origin(GTK_WIDGET(view->containingWindow())->window, &x, &y);
    m_menuPosition = view->contentsToWindow(rect.location());
    m_menuPosition = IntPoint(m_menuPosition.x() + x, m_menuPosition.y() + y + rect.height());
    m_indexMap.clear();

    const int size = client()->listSize();
    for (int i = 0; i < size; ++i) {
        GtkWidget* item;
        if (client()->itemIsSeparator(i))
            item = gtk_separator_menu_item_new();
        else
            item = gtk_menu_item_new_with_label(client()->itemText(i).utf8().data());

        m_indexMap.add(item, i);
        g_signal_connect(item, "activate", G_CALLBACK(menuItemActivated), this);

        // FIXME: Apply the RenderStyle from client()->itemStyle(i)
        gtk_widget_set_sensitive(item, client()->itemIsEnabled(i));
        gtk_menu_shell_append(GTK_MENU_SHELL(m_popup), item);
        gtk_widget_show(item);
    }

    gtk_menu_set_active(m_popup, index);


    // The size calls are directly copied from gtkcombobox.c which is LGPL
    GtkRequisition requisition;
    gtk_widget_set_size_request(GTK_WIDGET(m_popup), -1, -1);
    gtk_widget_size_request(GTK_WIDGET(m_popup), &requisition);
    gtk_widget_set_size_request(GTK_WIDGET(m_popup), MAX(rect.width(), requisition.width), -1);
    gtk_menu_popup(m_popup, NULL, NULL, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 0, gtk_get_current_event_time());
}
static int
xfapplet_panel_near (GtkWidget *widget, GtkOrientation orientation)
{
	GdkScreen	*screen;
	gint		 x, y, ret = 0;

	screen = gtk_widget_get_screen (widget);
	gdk_window_get_origin (widget->window, &x, &y);

	if (orientation == GTK_ORIENTATION_HORIZONTAL)
		ret = y > (gdk_screen_get_height (screen) - y) ? PANEL_NEAR_BOTTOM : PANEL_NEAR_TOP;
	else if (orientation == GTK_ORIENTATION_VERTICAL)
		ret = x > (gdk_screen_get_width (screen) - x) ? PANEL_NEAR_RIGHT : PANEL_NEAR_LEFT;
	else
		g_assert_not_reached ();

	return ret;
}
Esempio n. 9
0
static void
_preset_popup_posistion(GtkMenu *menu, gint *x,gint *y,gboolean *push_in, gpointer data)
{
  gint w,h;
  gint ww,wh;
  GtkRequisition requisition;
  gdk_window_get_size(GTK_WIDGET(data)->window,&w,&h);
  gdk_window_get_size(dt_ui_main_window(darktable.gui->ui)->window,&ww,&wh);
  gdk_window_get_origin (GTK_WIDGET(data)->window, x, y);

  gtk_widget_size_request (GTK_WIDGET (menu), &requisition);

  /* align left panel popupmenu to right edge */
  if (*x < ww/2)
    (*x)+=w-requisition.width;

  (*y)+=GTK_WIDGET(data)->allocation.height;
}
gboolean
rf_mixer_mouse_motion (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) {
	
	gint ex, ey, x, y, w, h;
	RfMixer *rmix = RF_MIXER (user_data);
	
	ex = event->x;
	ey = event->y;
	gdk_window_get_origin (GDK_WINDOW (widget->window), &x, &y);
	gdk_drawable_get_size (gtk_widget_get_parent_window (widget), &w, &h);
	
	//if (event->x < x || event->y < y || event->x > x+w || event->y > y+h)
	//	gtk_widget_hide (GTK_WIDGET (user_data));
	
	//g_printf ("ex: %d ey: %d x: %d  y: %d wx: %d hy: %d\n", ex, ey, x, y, x+w, y+h);

	return TRUE;
}
Esempio n. 11
0
static void
gtk_ui_popup_dialog(int index) {
	GtkWidget *popup;
	int tx, ty, tw, th;
	int px, py, pw, ph;

	popup = dialogs[index];

	gdk_window_get_origin(toplevel->window, &tx, &ty);
	gdk_window_get_size(toplevel->window, &tw, &th);
	gdk_window_get_size(popup->window, &pw, &ph);
	px = tx + (tw - pw) / 2;
	py = ty + (th - ph) / 2;
	gtk_window_set_position(GTK_WINDOW(popup), GTK_WIN_POS_NONE);
	gtk_widget_set_uposition(popup, px, py);
	gtk_widget_show_all(popup);
	gtk_main();
}
Esempio n. 12
0
char* iupdrvBaseGetYAttrib(Ihandle *ih)
{
  GdkWindow* window = ih->handle->window;
  GtkWidget* container = (GtkWidget*)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (container) window = container->window;

  if (window)
  {
    char* str = iupStrGetMemory(20);
    int x, y;
    gdk_window_get_origin(window, &x, &y);
    y += ih->handle->allocation.y;
    sprintf(str, "%d", y);
    return str;
  }
  else
    return NULL;
}
Esempio n. 13
0
static gboolean
gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
{
    if (gdk_event->window != gtk_widget_get_window(widget))
        return false;
    if (g_blockEventsOnDrag) return TRUE;
    if (g_blockEventsOnScroll) return TRUE;

    int x = int(gdk_event->x);
    int y = int(gdk_event->y);

    if (gdk_event->is_hint)
    {
#ifdef __WXGTK3__
       gdk_window_get_device_position(gdk_event->window, gdk_event->device, &x, &y, NULL);
#else
       gdk_window_get_pointer(gdk_event->window, &x, &y, NULL);
#endif
    }

    if (!win->m_isDragging)
    {
        if (win->GetWindowStyle() & wxRESIZE_BORDER)
        {
            if ((x > win->m_width-14) && (y > win->m_height-14))
               gdk_window_set_cursor(gtk_widget_get_window(widget), gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER));
            else
               gdk_window_set_cursor(gtk_widget_get_window(widget), NULL);
        }
        return TRUE;
    }

    win->m_oldX = x - win->m_diffX;
    win->m_oldY = y - win->m_diffY;

    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin(gtk_widget_get_window(widget), &org_x, &org_y);
    x += org_x - win->m_diffX;
    y += org_y - win->m_diffY;
    gtk_window_move( GTK_WINDOW(win->m_widget), x, y );

    return TRUE;
}
Esempio n. 14
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);
}
Esempio n. 15
0
static void menu_position_under (GtkMenu *menu, 
                                 int *x, int *y,
                                 gboolean *push_in,
                                 gpointer user_data)
{
    GtkWidget *widget;
    
    g_return_if_fail (GTK_IS_BUTTON (user_data));
    g_return_if_fail (GTK_WIDGET_NO_WINDOW (user_data));

    widget = GTK_WIDGET (user_data);
    
    gdk_window_get_origin (widget->window, x, y);
    
    *x += widget->allocation.x;
    *y += widget->allocation.y + widget->allocation.height;

    *push_in = FALSE;
}
Esempio n. 16
0
static void menu_cardview_analyzer_cb_pos_func(GtkMenu *menu,
        gint *x,
        gint *y,
        gboolean *push_in,
        gpointer user_data)
{
    GtkWidget *button=(GtkWidget *)user_data;
    GtkAllocation allocation;
    UNUSED(menu);

    gtk_widget_get_allocation(button,&allocation);

    *push_in = TRUE;

    gdk_window_get_origin(gtk_widget_get_window(button), x, y);
    *x += allocation.x;
    *y += allocation.y;
    *y += allocation.height;
}
Esempio n. 17
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);
  }
}
Esempio n. 18
0
static gboolean
cb_ccombo_popup_motion (G_GNUC_UNUSED GtkWidget *widget, GdkEventMotion *event,
			GtkTreeView *list)
{
	int base, dir = 0;
	GtkAllocation la;

	gtk_widget_get_allocation (GTK_WIDGET (list), &la);

	gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (list)),
			       NULL, &base);
	if (event->y_root < base)
		dir = -1;
	else if (event->y_root >= (base + la.height))
		dir = 1;
	else
		dir = 0;
	ccombo_autoscroll_set (G_OBJECT (list), dir);
	return FALSE;
}
void
stickynotes_applet_panel_icon_get_geometry (int *x, int *y, int *width, int *height)
{
	GtkWidget *widget;
        GtkAllocation allocation;
	GtkRequisition requisition;
	StickyNotesApplet *applet;

	applet = stickynotes->applets->data;

	widget = GTK_WIDGET (applet->w_image);

	gtk_widget_size_request (widget, &requisition);

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

	gtk_widget_get_allocation (widget, &allocation);
	*width = allocation.x;
	*height = allocation.y;
}
Esempio n. 20
0
static void _preset_popup_posistion(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
{
  gint w;
  gint ww;
  GtkRequisition requisition = { 0 };

  w = gdk_window_get_width(gtk_widget_get_window(GTK_WIDGET(data)));
  ww = gdk_window_get_width(gtk_widget_get_window(dt_ui_main_window(darktable.gui->ui)));

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

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

  /* align left panel popupmenu to right edge */
  if(*x < ww / 2) (*x) += w - requisition.width;

  GtkAllocation allocation_data;
  gtk_widget_get_allocation(GTK_WIDGET(data), &allocation_data);
  (*y) += allocation_data.height;
}
static void
menu_position_func (GtkMenu * menu, int *x, int *y, gboolean * push_in, gpointer picker)
{
	GtkWidget *widget = GTK_WIDGET (picker);
	GtkAllocation allocation;

	gtk_widget_get_allocation (widget, &allocation);
	gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
	*x += allocation.x;
	*y += allocation.y + allocation.height;

	if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
	{
		GtkRequisition req;
		gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
		*x += allocation.width - req.width;
	}

	*push_in = FALSE;
}
Esempio n. 22
0
static gboolean
dt_bauhaus_root_button_press(GtkWidget *wd, GdkEventButton *event, gpointer user_data)
{
  if(darktable.bauhaus->current)
  {
    const float tol = 100;
    gint wx, wy;
    GtkWidget *widget = darktable.bauhaus->popup_window;
    gdk_window_get_origin (gtk_widget_get_window (widget), &wx, &wy);
    if((event->x_root > wx + widget->allocation.width + tol || event->y_root > wy + widget->allocation.height + tol ||
        event->x_root < (int)wx - tol || event->y_root < (int)wy - tol))
    {
      dt_bauhaus_widget_reject(darktable.bauhaus->current);
      dt_bauhaus_hide_popup();
      return TRUE;
    }
  }
  // make sure to propagate the event further
  return FALSE;
}
Esempio n. 23
0
/*
 * Find best location for displaying
 */
/* protected */ void
go_combo_box_get_pos (GOComboBox *combo_box, int *x, int *y)
{
	GtkWidget *wcombo = GTK_WIDGET (combo_box);
	GdkScreen *screen = gtk_widget_get_screen (wcombo);
	int ph, pw;

	gdk_window_get_origin (wcombo->window, x, y);
	*y += wcombo->allocation.height + wcombo->allocation.y;
	*x += wcombo->allocation.x;

	ph = combo_box->priv->popup->allocation.height;
	pw = combo_box->priv->popup->allocation.width;

	if ((*y + ph) > gdk_screen_get_height (screen))
		*y = gdk_screen_get_height (screen) - ph;

	if ((*x + pw) > gdk_screen_get_width (screen))
		*x = gdk_screen_get_width (screen) - pw;
}
Esempio n. 24
0
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);
}
Esempio n. 25
0
static void
dma_data_view_goto_position_func (DmaDataView *view)
{
	gint x, y;
	gint win_x, win_y;
	GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (view));
	GdkScreen *screen = gdk_window_get_screen (window);
	gint monitor_num;
	GdkRectangle monitor;

	monitor_num = gdk_screen_get_monitor_at_window (screen, window);
	gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);

	gtk_widget_realize (view->goto_window);

	gdk_window_get_origin (window, &win_x, &win_y);
	x = MAX(12, win_x + 12);
	y = MAX(12, win_y + 12);
	
	gtk_window_move (GTK_WINDOW (view->goto_window), x, y);
}
Esempio n. 26
0
void
gtk_widget_get_extends(GtkWidget* widget, gint* x, gint* y, gint* w, gint* h) {
    GdkWindow* window = widget->window;
    gdk_window_get_origin(window, x, y);

    if(x) {
        *x += widget->allocation.x;
    }

    if(y) {
        *y += widget->allocation.y;
    }

    if(w) {
        *w =  widget->allocation.width;
    }

    if(h) {
        *h =  widget->allocation.height;
    }
}
}


void scim_bridge_client_imcontext_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
{
    scim_bridge_pdebugln (4, "scim_bridge_client_imcontext_set_cursor_location ()");

    ScimBridgeClientIMContext *imcontext = SCIM_BRIDGE_CLIENT_IMCONTEXT (context);
    if (imcontext->preedit_cursor_flicking)
        return;

    if (imcontext != NULL && imcontext->client_window != NULL) {
        const int new_cursor_x = area->x + area->width;
        const int new_cursor_y = area->y + area->height + 8;

        int new_window_x;
        int new_window_y;
        gdk_window_get_origin (imcontext->client_window, &new_window_x, &new_window_y);

        if (set_cursor_location (imcontext, new_window_x, new_window_y, new_cursor_x, new_cursor_y)) {
            scim_bridge_perrorln ("An IOException occurred at scim_bridge_client_imcontext_set_cursor_location ()");
Esempio n. 28
0
static void menu_position_under(GtkMenu *menu, int *x, int *y,
				gboolean *push_in, gpointer user_data)
{
	GtkWidget *widget;
	GtkAllocation allocation;

	g_return_if_fail(GTK_IS_BUTTON(user_data));
#if defined(HAVE_GTK_220) || defined(USE_GTK_3)
	g_return_if_fail(gtk_widget_get_window(user_data));
#else
	g_return_if_fail(GTK_WIDGET_NO_WINDOW(user_data));
#endif
	widget = GTK_WIDGET(user_data);

	gdk_window_get_origin(gtk_widget_get_window(widget), x, y);
	gtk_widget_get_allocation(widget, &allocation);
	*x += allocation.x;
	*y += allocation.y + allocation.height;

	*push_in = FALSE;
}
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);
}
Esempio n. 30
0
void insert_open_brace(GtkWidget **tip_win, GtkWidget *text_view, GtkTextIter *arg1)
{
	GdkWindow *win;
	GtkTextIter start;
	GdkRectangle buf_loc;
	gint x, y;
	gint win_x, win_y;
	gchar *text;
	gchar *tip_text;

	start = *arg1;
	if (!gtk_text_iter_backward_word_start (&start))
		return;
	text = gtk_text_iter_get_text (&start, arg1);
	g_strstrip (text);

	tip_text = get_tip(text);  
	if (tip_text == NULL)
		return;

	gtk_text_view_get_iter_location (GTK_TEXT_VIEW (text_view), arg1, &buf_loc);
	g_printf ("Buffer: %d, %d\n", buf_loc.x, buf_loc.y);
	gtk_text_view_buffer_to_window_coords (GTK_TEXT_VIEW (text_view),
	GTK_TEXT_WINDOW_WIDGET,
	buf_loc.x, buf_loc.y,
	&win_x, &win_y);
	g_printf ("Window: %d, %d\n", win_x, win_y);
	win = gtk_text_view_get_window (GTK_TEXT_VIEW (text_view), 
	GTK_TEXT_WINDOW_WIDGET);
	gdk_window_get_origin (win, &x, &y);

	if (*tip_win != NULL)
		gtk_widget_destroy (GTK_WIDGET (*tip_win));  

	*tip_win = tip_window_new (tip_text);
	g_free(tip_text);
	gtk_window_move (GTK_WINDOW (*tip_win), win_x + x, 
	win_y + y + buf_loc.height);
	gtk_widget_show_all (*tip_win);
}