static gboolean overlay_enter_notify_cb (GtkWidget *parent, GdkEventCrossing *event, gpointer user_data) { GtkWidget *widget = user_data; if (event->window != gtk_widget_get_window (widget)) { return FALSE; } if (NAUTILUS_FLOATING_BAR (widget)->priv->is_interactive) { return FALSE; } if (gtk_widget_get_halign (widget) == GTK_ALIGN_START) { gtk_widget_set_halign (widget, GTK_ALIGN_END); } else { gtk_widget_set_halign (widget, GTK_ALIGN_START); } gtk_widget_queue_resize (widget); return FALSE; }
static gboolean get_child_position (GtkOverlay *overlay, GtkWidget *widget, GtkAllocation *alloc, GtkWidget *relative) { GtkRequisition req; GtkWidget *child; GtkAllocation main_alloc; gint x, y; child = gtk_bin_get_child (GTK_BIN (overlay)); gtk_widget_translate_coordinates (relative, child, 0, 0, &x, &y); main_alloc.x = x; main_alloc.y = y; main_alloc.width = gtk_widget_get_allocated_width (relative); main_alloc.height = gtk_widget_get_allocated_height (relative); gtk_widget_get_preferred_size (widget, NULL, &req); alloc->x = main_alloc.x; alloc->width = MIN (main_alloc.width, req.width); if (gtk_widget_get_halign (widget) == GTK_ALIGN_END) alloc->x += main_alloc.width - req.width; alloc->y = main_alloc.y; alloc->height = MIN (main_alloc.height, req.height); if (gtk_widget_get_valign (widget) == GTK_ALIGN_END) alloc->y += main_alloc.height - req.height; return TRUE; }
virtual bool get_halign(GtkAlign& align) { widget_attached_t detached = 0; if ((detached = this->attached_to())) { align = gtk_widget_get_halign(detached); return true; } return false; }
static void on_enter (GtkWidget *overlay, GdkEventCrossing *event, GtkWidget *child) { if (event->window != gtk_widget_get_window (child)) return; if (gtk_widget_get_halign (child) == GTK_ALIGN_START) gtk_widget_set_halign (child, GTK_ALIGN_END); else gtk_widget_set_halign (child, GTK_ALIGN_START); gtk_widget_queue_resize (overlay); }
static int halign_member(lua_State *L) { lua_label label; luaA_to(L, lua_label, &label, 1); dt_lua_align_t align; if(lua_gettop(L) > 2) { luaA_to(L, dt_lua_align_t, &align, 3); gtk_widget_set_halign(GTK_WIDGET(label->widget), align); return 0; } align = gtk_widget_get_halign(label->widget); luaA_push(L, dt_lua_align_t, &align); return 1; }
/* TODO - Optimize this a bit */ static void calculate_pupil_xy (EyesApplet *eyes_applet, gint x, gint y, gint *pupil_x, gint *pupil_y, GtkWidget* widget) { GtkAllocation allocation; double sina; double cosa; double h; double temp; double nx, ny; gfloat xalign, yalign; gint width, height; gtk_widget_get_allocation (GTK_WIDGET(widget), &allocation); width = allocation.width; height = allocation.height; xalign = gtk_align_to_gfloat (gtk_widget_get_halign (widget)); yalign = gtk_align_to_gfloat (gtk_widget_get_valign (widget)); nx = x - MAX(width - eyes_applet->eye_width, 0) * xalign - eyes_applet->eye_width / 2; ny = y - MAX(height- eyes_applet->eye_height, 0) * yalign - eyes_applet->eye_height / 2; h = hypot (nx, ny); if (h < 0.5 || abs (h) < (abs (hypot (eyes_applet->eye_height / 2, eyes_applet->eye_width / 2)) - eyes_applet->wall_thickness - eyes_applet->pupil_height)) { *pupil_x = nx + eyes_applet->eye_width / 2; *pupil_y = ny + eyes_applet->eye_height / 2; return; } sina = nx / h; cosa = ny / h; temp = hypot ((eyes_applet->eye_width / 2) * sina, (eyes_applet->eye_height / 2) * cosa); temp -= hypot ((eyes_applet->pupil_width / 2) * sina, (eyes_applet->pupil_height / 2) * cosa); temp -= hypot ((eyes_applet->wall_thickness / 2) * sina, (eyes_applet->wall_thickness / 2) * cosa); *pupil_x = temp * sina + (eyes_applet->eye_width / 2); *pupil_y = temp * cosa + (eyes_applet->eye_height / 2); }
/** This function moves a GtkWidget from one GtkGrid to another, * preserving its attachment data, etc. It is called when adding one * partial preference page to another. * * @internal * * @param widget A pointer to the widget to move. * * @param data A pointer to a data structure passed in by the caller. * This data structure contains pointers to the old and new grids * plus the row offset into the new grid. */ static void gnc_prefs_move_grid_entry (GtkWidget *child, gpointer data) { struct copy_data *copydata = data; gint top, left, height, width; gboolean hexpand, vexpand; GtkAlign halign, valign; gint topm, bottomm, leftm, rightm; ENTER("child %p, copy data %p", child, data); gtk_container_child_get(GTK_CONTAINER(copydata->grid_from), child, "left-attach", &left, "top-attach", &top, "height", &height, "width", &width, NULL); hexpand = gtk_widget_get_hexpand (child); vexpand = gtk_widget_get_vexpand (child); halign = gtk_widget_get_halign (child); valign = gtk_widget_get_valign (child); g_object_get (child, "margin-top", &topm, "margin-bottom", &bottomm, NULL); g_object_get (child, "margin-left", &leftm, "margin-right", &rightm, NULL); g_object_ref(child); gtk_container_remove(GTK_CONTAINER(copydata->grid_from), child); gtk_grid_attach(copydata->grid_to, child, left, copydata->rows + top , width, height); gtk_widget_set_hexpand (child, hexpand); gtk_widget_set_vexpand (child, vexpand); gtk_widget_set_halign (child, halign); gtk_widget_set_valign (child, valign); g_object_set (child, "margin-left", leftm, "margin-right", rightm, NULL); g_object_set (child, "margin-top", topm, "margin-bottom", bottomm, NULL); g_object_unref(child); LEAVE(" "); }
uiprivChild *uiprivNewChild(uiControl *child, uiControl *parent, GtkContainer *parentContainer) { uiprivChild *c; if (child == NULL) return NULL; c = uiprivNew(uiprivChild); c->c = child; c->widget = GTK_WIDGET(uiControlHandle(c->c)); c->oldhexpand = gtk_widget_get_hexpand(c->widget); c->oldhalign = gtk_widget_get_halign(c->widget); c->oldvexpand = gtk_widget_get_vexpand(c->widget); c->oldvalign = gtk_widget_get_valign(c->widget); uiControlSetParent(c->c, parent); uiUnixControlSetContainer(uiUnixControl(c->c), parentContainer, FALSE); c->parent = parentContainer; return c; }
static void menu_position_up_down_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, GtkMenuButton *menu_button) { GtkMenuButtonPrivate *priv = menu_button->priv; GtkWidget *widget = GTK_WIDGET (menu_button); GtkWidget *toplevel; GtkTextDirection direction; GdkRectangle monitor; gint monitor_num; GdkScreen *screen; GdkWindow *window; GtkAllocation menu_allocation, allocation, arrow_allocation; GtkAlign align; /* In the common case the menu button is showing a dropdown menu, set the * corresponding type hint on the toplevel, so the WM can omit the top side * of the shadows. */ if (priv->arrow_type == GTK_ARROW_DOWN) { toplevel = gtk_widget_get_toplevel (priv->menu); gtk_window_set_type_hint (GTK_WINDOW (toplevel), GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU); } align = gtk_widget_get_halign (priv->menu); direction = gtk_widget_get_direction (widget); window = gtk_widget_get_window (priv->align_widget ? priv->align_widget : widget); screen = gtk_widget_get_screen (GTK_WIDGET (menu)); monitor_num = gdk_screen_get_monitor_at_window (screen, window); if (monitor_num < 0) monitor_num = 0; gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor); gtk_widget_get_allocation (priv->align_widget ? priv->align_widget : widget, &allocation); gtk_widget_get_allocation (widget, &arrow_allocation); gtk_widget_get_allocation (priv->menu, &menu_allocation); gdk_window_get_origin (window, x, y); *x += allocation.x; *y += allocation.y; /* treat the default align value like START */ if (align == GTK_ALIGN_FILL) align = GTK_ALIGN_START; if (align == GTK_ALIGN_CENTER) *x -= (menu_allocation.width - allocation.width) / 2; else if ((align == GTK_ALIGN_START && direction == GTK_TEXT_DIR_LTR) || (align == GTK_ALIGN_END && direction == GTK_TEXT_DIR_RTL)) *x += MAX (allocation.width - menu_allocation.width, 0); else if (menu_allocation.width > allocation.width) *x -= menu_allocation.width - allocation.width; if (priv->arrow_type == GTK_ARROW_UP && *y - menu_allocation.height >= monitor.y) { *y -= menu_allocation.height; } else { if ((*y + arrow_allocation.height + menu_allocation.height) <= monitor.y + monitor.height) *y += arrow_allocation.height; else if ((*y - menu_allocation.height) >= monitor.y) *y -= menu_allocation.height; else if (monitor.y + monitor.height - (*y + arrow_allocation.height) > *y) *y += arrow_allocation.height; else *y -= menu_allocation.height; } *push_in = FALSE; }
/* * Class: org_java_gtk_gtk_Widget * Method: gtk_widget_get_halign * Signature: (J)I */ JNIEXPORT jint JNICALL Java_org_java_1gtk_gtk_Widget_gtk_1widget_1get_1halign (JNIEnv *env, jclass cls, jlong widget) { return (jint)gtk_widget_get_halign((GtkWidget*)widget); }
static void popup_menu (GtkMenuButton *menu_button, GdkEvent *event) { GtkMenuButtonPrivate *priv = menu_button->priv; GdkGravity widget_anchor = GDK_GRAVITY_SOUTH_WEST; GdkGravity menu_anchor = GDK_GRAVITY_NORTH_WEST; if (priv->func) priv->func (priv->user_data); if (!priv->menu) return; switch (priv->arrow_type) { case GTK_ARROW_UP: g_object_set (priv->menu, "anchor-hints", (GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE | GDK_ANCHOR_RESIZE), NULL); switch (gtk_widget_get_halign (priv->menu)) { case GTK_ALIGN_FILL: case GTK_ALIGN_START: case GTK_ALIGN_BASELINE: widget_anchor = GDK_GRAVITY_NORTH_WEST; menu_anchor = GDK_GRAVITY_SOUTH_WEST; break; case GTK_ALIGN_END: widget_anchor = GDK_GRAVITY_NORTH_EAST; menu_anchor = GDK_GRAVITY_SOUTH_EAST; break; case GTK_ALIGN_CENTER: widget_anchor = GDK_GRAVITY_NORTH; menu_anchor = GDK_GRAVITY_SOUTH; break; } break; case GTK_ARROW_DOWN: /* In the common case the menu button is showing a dropdown menu, set the * corresponding type hint on the toplevel, so the WM can omit the top side * of the shadows. */ g_object_set (priv->menu, "anchor-hints", (GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE | GDK_ANCHOR_RESIZE), "menu-type-hint", GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU, NULL); switch (gtk_widget_get_halign (priv->menu)) { case GTK_ALIGN_FILL: case GTK_ALIGN_START: case GTK_ALIGN_BASELINE: widget_anchor = GDK_GRAVITY_SOUTH_WEST; menu_anchor = GDK_GRAVITY_NORTH_WEST; break; case GTK_ALIGN_END: widget_anchor = GDK_GRAVITY_SOUTH_EAST; menu_anchor = GDK_GRAVITY_NORTH_EAST; break; case GTK_ALIGN_CENTER: widget_anchor = GDK_GRAVITY_SOUTH; menu_anchor = GDK_GRAVITY_NORTH; break; } break; case GTK_ARROW_LEFT: g_object_set (priv->menu, "anchor-hints", (GDK_ANCHOR_FLIP_X | GDK_ANCHOR_SLIDE | GDK_ANCHOR_RESIZE), NULL); switch (gtk_widget_get_valign (priv->menu)) { case GTK_ALIGN_FILL: case GTK_ALIGN_START: case GTK_ALIGN_BASELINE: widget_anchor = GDK_GRAVITY_NORTH_WEST; menu_anchor = GDK_GRAVITY_NORTH_EAST; break; case GTK_ALIGN_END: widget_anchor = GDK_GRAVITY_SOUTH_WEST; menu_anchor = GDK_GRAVITY_SOUTH_EAST; break; case GTK_ALIGN_CENTER: widget_anchor = GDK_GRAVITY_WEST; menu_anchor = GDK_GRAVITY_EAST; break; } break; case GTK_ARROW_RIGHT: g_object_set (priv->menu, "anchor-hints", (GDK_ANCHOR_FLIP_X | GDK_ANCHOR_SLIDE | GDK_ANCHOR_RESIZE), NULL); switch (gtk_widget_get_valign (priv->menu)) { case GTK_ALIGN_FILL: case GTK_ALIGN_START: case GTK_ALIGN_BASELINE: widget_anchor = GDK_GRAVITY_NORTH_EAST; menu_anchor = GDK_GRAVITY_NORTH_WEST; break; case GTK_ALIGN_END: widget_anchor = GDK_GRAVITY_SOUTH_EAST; menu_anchor = GDK_GRAVITY_SOUTH_WEST; break; case GTK_ALIGN_CENTER: widget_anchor = GDK_GRAVITY_EAST; menu_anchor = GDK_GRAVITY_WEST; break; } break; case GTK_ARROW_NONE: g_object_set (priv->menu, "anchor-hints", (GDK_ANCHOR_FLIP_Y | GDK_ANCHOR_SLIDE | GDK_ANCHOR_RESIZE), NULL); break; } gtk_menu_popup_at_widget (GTK_MENU (priv->menu), GTK_WIDGET (menu_button), widget_anchor, menu_anchor, event); }