static void gtk_notification_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height) { GtkNotification *notification = GTK_NOTIFICATION (widget); GtkNotificationPrivate *priv = notification->priv; GtkBin *bin = GTK_BIN (widget); gint child_min, child_nat; GtkWidget *child; GtkBorder padding; gint minimum, natural; get_padding_and_border (notification, &padding); gtk_widget_get_preferred_height (priv->close_button, &minimum, &natural); child = gtk_bin_get_child (bin); if (child && gtk_widget_get_visible (child)) { gtk_widget_get_preferred_height (child, &child_min, &child_nat); minimum = MAX (minimum, child_min); natural = MAX (natural, child_nat); } minimum += padding.top + padding.top + SHADOW_OFFSET_Y; natural += padding.top + padding.top + SHADOW_OFFSET_Y; if (minimum_height) *minimum_height = minimum; if (natural_height) *natural_height = natural; }
void wxFrame::DoGetClientSize( int *width, int *height ) const { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); wxFrameBase::DoGetClientSize(width, height); if (m_useCachedClientSize) return; if (height) { #if wxUSE_MENUS_NATIVE // menu bar if (m_frameMenuBar && m_frameMenuBar->IsShown()) { int h; gtk_widget_get_preferred_height(m_frameMenuBar->m_widget, NULL, &h); #if !wxUSE_LIBHILDON && !wxUSE_LIBHILDON2 *height -= h; #endif } #endif // wxUSE_MENUS_NATIVE #if wxUSE_STATUSBAR // status bar if (m_frameStatusBar && m_frameStatusBar->IsShown()) *height -= m_frameStatusBar->m_height; #endif // wxUSE_STATUSBAR } #if wxUSE_TOOLBAR // tool bar if (m_frameToolBar && m_frameToolBar->IsShown()) { if (m_frameToolBar->IsVertical()) { if (width) { int w; gtk_widget_get_preferred_width(m_frameToolBar->m_widget, NULL, &w); *width -= w; } } else { if (height) { int h; gtk_widget_get_preferred_height(m_frameToolBar->m_widget, NULL, &h); *height -= h; } } } #endif // wxUSE_TOOLBAR if (width != NULL && *width < 0) *width = 0; if (height != NULL && *height < 0) *height = 0; }
static void anjuta_tabber_get_preferred_height (GtkWidget* widget, gint* minimum, gint* preferred) { g_return_if_fail (ANJUTA_IS_TABBER (widget)); AnjutaTabber* tabber = ANJUTA_TABBER (widget); GList* child; gint focus_width; gtk_widget_style_get (GTK_WIDGET (tabber), "focus-line-width", &focus_width, NULL); for (child = tabber->priv->children; child != NULL; child = g_list_next (child)) { gint child_min; gint child_preferred; gtk_widget_get_preferred_height (GTK_WIDGET (child->data), &child_min, &child_preferred); if (minimum) { *minimum = MAX(*minimum, child_min + 2 * (focus_width + tabber->priv->tab_vborder)); } if (preferred) { *preferred = MAX(*preferred, child_preferred + 2 * (focus_width + tabber->priv->tab_vborder)); } } }
static void apply_background_to_window (GSManager *manager, GSWindow *window) { cairo_surface_t *surface; int width; int height; mate_bg_load_from_preferences (manager->priv->bg); if (manager->priv->bg == NULL) { gs_debug ("No background available"); gs_window_set_background_surface (window, NULL); } gtk_widget_get_preferred_width (GTK_WIDGET (window), &width, NULL); gtk_widget_get_preferred_height (GTK_WIDGET (window), &height, NULL); gs_debug ("Creating background w:%d h:%d", width, height); surface = mate_bg_create_surface (manager->priv->bg, gs_window_get_gdk_window (window), width, height, FALSE); gs_window_set_background_surface (window, surface); cairo_surface_destroy (surface); }
static void gdl_dock_get_size (GtkWidget *widget, GtkOrientation orientation, gint *minimum, gint *natural) { GdlDock *dock; GtkContainer *container; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); dock = GDL_DOCK (widget); container = GTK_CONTAINER (widget); *minimum = *natural = 0; /* make request to root */ if (dock->priv->root && gtk_widget_get_visible (GTK_WIDGET (dock->priv->root))) { if (orientation == GTK_ORIENTATION_HORIZONTAL) { gtk_widget_get_preferred_width (GTK_WIDGET (dock->priv->root), minimum, natural); } else { gtk_widget_get_preferred_height (GTK_WIDGET (dock->priv->root), minimum, natural); } } }
static GtkWidget * build_gcr_widget (EmpathyTLSDialog *self) { GcrCertificateWidget *widget; GcrCertificate *certificate; GPtrArray *cert_chain = NULL; GArray *first_cert; int height; EmpathyTLSDialogPriv *priv = GET_PRIV (self); g_object_get (priv->certificate, "cert-data", &cert_chain, NULL); first_cert = g_ptr_array_index (cert_chain, 0); certificate = gcr_simple_certificate_new ((const guchar *) first_cert->data, first_cert->len); widget = gcr_certificate_widget_new (certificate); /* FIXME: make this widget bigger by default -- GTK+ should really handle * this sort of thing for us */ gtk_widget_get_preferred_height (GTK_WIDGET (widget), NULL, &height); /* force the widget to at least 150 pixels high */ gtk_widget_set_size_request (GTK_WIDGET (widget), -1, MAX (height, 150)); g_object_unref (certificate); g_ptr_array_unref (cert_chain); return GTK_WIDGET (widget); }
void dash_box_push (DashBox* self, GreeterList* l) { GreeterList* _tmp0_; GtkWidget* _tmp1_; DashBoxMode _tmp2_; gint _tmp3_ = 0; GreeterList* _tmp4_; GreeterList* _tmp5_; GreeterList* _tmp6_; FadeTracker* _tmp7_; g_return_if_fail (self != NULL); g_return_if_fail (l != NULL); _tmp0_ = self->priv->pushed; g_return_if_fail (_tmp0_ == NULL); _tmp1_ = self->priv->orig; g_return_if_fail (_tmp1_ != NULL); _tmp2_ = self->priv->mode; g_return_if_fail (_tmp2_ == DASH_BOX_MODE_NORMAL); gtk_widget_get_preferred_height ((GtkWidget*) self, NULL, &_tmp3_); self->priv->orig_height = _tmp3_; _tmp4_ = l; _tmp5_ = _g_object_ref0 (_tmp4_); _g_object_unref0 (self->priv->pushed); self->priv->pushed = _tmp5_; _tmp6_ = self->priv->pushed; g_signal_connect_object ((FadableBox*) _tmp6_, "fade-done", (GCallback) _dash_box_fade_done_cb_fadable_box_fade_done, self, 0); self->priv->mode = DASH_BOX_MODE_PUSH_FADE_OUT; _tmp7_ = self->priv->orig_tracker; fade_tracker_reset (_tmp7_, FADE_TRACKER_MODE_FADE_OUT); gtk_widget_queue_resize ((GtkWidget*) self); }
static void pnl_dock_revealer_get_child_preferred_height (PnlDockRevealer *self, gint *min_height, gint *nat_height) { PnlDockRevealerPrivate *priv = pnl_dock_revealer_get_instance_private (self); GtkWidget *child; g_assert (PNL_IS_DOCK_REVEALER (self)); g_assert (min_height != NULL); g_assert (nat_height != NULL); *min_height = 0; *nat_height = 0; if (NULL == (child = gtk_bin_get_child (GTK_BIN (self)))) return; if (!gtk_widget_get_child_visible (child) || !gtk_widget_get_visible (child)) return; gtk_widget_get_preferred_height (child, min_height, nat_height); if (IS_VERTICAL (priv->transition_type) && priv->position_set) { if (priv->position > *min_height) *nat_height = priv->position; else *nat_height = *min_height; } }
static void gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget, gint height, gint *minimum_width, gint *natural_width) { GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget); gint menubar_height; if (window->priv->menubar != NULL) gtk_widget_get_preferred_height (window->priv->menubar, &menubar_height, NULL); else menubar_height = 0; GTK_WIDGET_CLASS (gtk_application_window_parent_class) ->get_preferred_width_for_height (widget, height - menubar_height, minimum_width, natural_width); if (window->priv->menubar != NULL) { gint menubar_min_width, menubar_nat_width; gtk_widget_get_preferred_width_for_height (window->priv->menubar, menubar_height, &menubar_min_width, &menubar_nat_width); *minimum_width = MAX (*minimum_width, menubar_min_width); *natural_width = MAX (*natural_width, menubar_nat_width); } }
static void gtk_bubble_window_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height) { GtkBubbleWindowPrivate *priv; GtkWidget *child; gint min, nat; GtkBorder border; priv = GTK_BUBBLE_WINDOW (widget)->priv; child = gtk_bin_get_child (GTK_BIN (widget)); min = nat = 0; if (child) gtk_widget_get_preferred_height (child, &min, &nat); get_padding_and_border (widget, &border); min += border.top + border.bottom; nat += border.top + border.bottom; if (POS_IS_VERTICAL (priv->final_position)) { min += TAIL_HEIGHT; nat += TAIL_HEIGHT; } if (minimum_height) *minimum_height = MAX (min, TAIL_GAP_WIDTH); if (natural_height) *natural_height = MAX (nat, TAIL_GAP_WIDTH); }
static void gstyle_color_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height) { GstyleColorWidget *self = (GstyleColorWidget *)widget; GtkWidget *child; gint spacing; g_assert (GSTYLE_IS_COLOR_WIDGET (self)); *min_height = 1; *nat_height = 1; update_border_and_margin (self); child = gtk_bin_get_child (GTK_BIN (self)); if (child && gtk_widget_get_visible (child)) gtk_widget_get_preferred_height (child, min_height, nat_height); spacing = self->cached_border.top + self->cached_border.bottom + self->cached_margin.top + self->cached_margin.bottom; *min_height += spacing; *nat_height += spacing; }
wxSize wxControl::DoGetBestSize() const { // Do not return any arbitrary default value... wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") ); wxSize best; if (m_wxwindow) { // this is not a native control, size_request is likely to be (0,0) best = wxControlBase::DoGetBestSize(); } else { GtkRequisition req; #ifdef __WXGTK3__ if (gtk_widget_get_request_mode(m_widget) != GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH) { gtk_widget_get_preferred_height(m_widget, NULL, &req.height); gtk_widget_get_preferred_width_for_height(m_widget, req.height, NULL, &req.width); } else { gtk_widget_get_preferred_width(m_widget, NULL, &req.width); gtk_widget_get_preferred_height_for_width(m_widget, req.width, NULL, &req.height); } #else GTK_WIDGET_GET_CLASS(m_widget)->size_request(m_widget, &req); #endif best.Set(req.width, req.height); } CacheBestSize(best); return best; }
static void gdl_dock_tablabel_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) { GtkBin *bin; gint child_min, child_nat; GdlDockTablabel *tablabel; guint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_TABLABEL (widget)); tablabel = GDL_DOCK_TABLABEL (widget); bin = GTK_BIN (widget); *minimum = *natural = 0; if (gtk_bin_get_child (bin)) gtk_widget_get_preferred_height (gtk_bin_get_child (bin), &child_min, &child_nat); else child_min = child_nat = 0; *minimum = child_min; *natural = child_nat; border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); *minimum += border_width * 2; *natural += border_width * 2; }
static void gb_slider_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height) { GbSlider *self = (GbSlider *)widget; GbSliderPrivate *priv = gb_slider_get_instance_private (self); gint real_min_height = 0; gint real_nat_height = 0; gsize i; g_assert (GB_IS_SLIDER (self)); for (i = 0; i < priv->children->len; i++) { GbSliderChild *child; gint child_min_height = 0; gint child_nat_height = 0; child = g_ptr_array_index (priv->children, i); if ((child->position == GB_SLIDER_NONE) && gtk_widget_get_visible (child->widget)) { gtk_widget_get_preferred_height (child->widget, &child_min_height, &child_nat_height); real_min_height = MAX (real_min_height, child_min_height); real_nat_height = MAX (real_nat_height, child_nat_height); } } *min_height = real_min_height; *nat_height = real_nat_height; }
static void gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget, gint height, gint *minimum_width, gint *natural_width) { GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget); gint menubar_height; if (window->priv->menubar != NULL) gtk_widget_get_preferred_height (window->priv->menubar, &menubar_height, NULL); else menubar_height = 0; GTK_WIDGET_CLASS (gtk_application_window_parent_class) ->get_preferred_width_for_height (widget, height - menubar_height, minimum_width, natural_width); if (window->priv->menubar != NULL) { gint menubar_min_width, menubar_nat_width; gint border_width; GtkBorder border = { 0 }; gtk_widget_get_preferred_width_for_height (window->priv->menubar, menubar_height, &menubar_min_width, &menubar_nat_width); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); _gtk_window_get_shadow_width (GTK_WINDOW (widget), &border); menubar_min_width += 2 * border_width + border.left + border.right; menubar_nat_width += 2 * border_width + border.left + border.right; *minimum_width = MAX (*minimum_width, menubar_min_width); *natural_width = MAX (*natural_width, menubar_nat_width); } }
static void panel_frame_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height) { PanelFrame *frame = (PanelFrame *) widget; GtkBin *bin = (GtkBin *) widget; GtkStyleContext *context; GtkWidget *child; GtkBorder padding; int border_width; context = gtk_widget_get_style_context (widget); gtk_style_context_get_padding (context, gtk_widget_get_state_flags (widget), &padding); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); *minimal_height = 1; *natural_height = 1; child = gtk_bin_get_child (bin); if (child && gtk_widget_get_visible (child)) gtk_widget_get_preferred_height (child, minimal_height, natural_height); *minimal_height += border_width; *natural_height += border_width; if (frame->edges & PANEL_EDGE_TOP) { *minimal_height += padding.top; *natural_height += padding.top; } if (frame->edges & PANEL_EDGE_BOTTOM) { *minimal_height += padding.bottom; *natural_height += padding.bottom; } }
static void update_scrubber_position (GtkSourceMap *map) { GtkSourceMapPrivate *priv; GtkTextIter iter; GdkRectangle visible_area; GdkRectangle iter_area; GdkRectangle scrubber_area; GtkAllocation alloc; GtkAllocation view_alloc; gint child_height; gint view_height; gint y; priv = gtk_source_map_get_instance_private (map); if (priv->view == NULL) { return; } gtk_widget_get_allocation (GTK_WIDGET (priv->view), &view_alloc); gtk_widget_get_allocation (GTK_WIDGET (map), &alloc); gtk_widget_get_preferred_height (GTK_WIDGET (priv->view), NULL, &view_height); gtk_widget_get_preferred_height (GTK_WIDGET (priv->child_view), NULL, &child_height); gtk_text_view_get_visible_rect (GTK_TEXT_VIEW (priv->view), &visible_area); gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (priv->view), &iter, visible_area.x, visible_area.y); gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->child_view), &iter, &iter_area); gtk_text_view_buffer_to_window_coords (GTK_TEXT_VIEW (priv->child_view), GTK_TEXT_WINDOW_WIDGET, iter_area.x, iter_area.y, NULL, &y); scrubber_area.x = 0; scrubber_area.width = alloc.width; scrubber_area.y = y; scrubber_area.height = (gdouble)view_alloc.height / (gdouble)view_height * (gdouble)child_height; if (memcmp (&scrubber_area, &priv->scrubber_area, sizeof scrubber_area) != 0) { priv->scrubber_area = scrubber_area; gtk_widget_queue_draw (GTK_WIDGET (map)); } }
static gboolean can_hold_vertical_labels_with_height (GcalEventWidget *self, gint height) { gint total_height; gtk_widget_get_preferred_height (self->vertical_grid, &total_height, NULL); return height >= total_height; }
static void import_widget_add_accounts_to_model (EmpathyImportWidget *self) { TpAccountManager *manager; GtkTreeModel *model; GList *l; EmpathyImportWidgetPriv *priv = GET_PRIV (self); gint min, natural; manager = tp_account_manager_dup (); model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); for (l = priv->accounts; l; l = l->next) { GValue *value; EmpathyImportAccountData *data = l->data; gboolean import; GList *accounts; TpConnectionManager *cm = NULL; if (!empathy_import_protocol_is_supported (data->protocol, &cm)) continue; data->connection_manager = g_strdup ( tp_connection_manager_get_name (cm)); value = g_hash_table_lookup (data->settings, "account"); accounts = tp_account_manager_dup_valid_accounts (manager); /* Only set the "Import" cell to be active if there isn't already an * account set up with the same account id. */ import = !import_widget_account_id_in_list (accounts, g_value_get_string (value)); g_list_free_full (accounts, g_object_unref); gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, -1, COL_IMPORT, import, COL_PROTOCOL, data->protocol, COL_NAME, g_value_get_string (value), COL_SOURCE, data->source, COL_ACCOUNT_DATA, data, -1); } /* Display as much rows as possible */ gtk_widget_get_preferred_height (priv->treeview, &min, &natural); gtk_widget_set_size_request (priv->scrolledwindow, -1, MIN (natural, MAX_TREEVIEW_HEIGHT)); g_object_unref (manager); }
static void color_swatch_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height) { GtkhtmlColorSwatchPrivate *priv; priv = GTKHTML_COLOR_SWATCH (widget)->priv; gtk_widget_get_preferred_height ( priv->frame, minimum_height, natural_height); }
static void hd_status_plugin_item_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height) { GtkWidget *child; child = gtk_bin_get_child (GTK_BIN (widget)); if (child) gtk_widget_get_preferred_height (child, minimal_height, natural_height); }
static void panel_applet_get_preferred_height (GtkWidget *widget, int *minimum_height, int *natural_height) { PanelApplet *applet = PANEL_APPLET (widget); GtkBin *bin = GTK_BIN (widget); GtkWidget *child = NULL; gint focus_width = 0; guint border_width = 0; if (!applet->priv->has_handle) { GTK_WIDGET_CLASS (panel_applet_parent_class)->get_preferred_height (widget, minimum_height, natural_height); } else { child = gtk_bin_get_child (bin); if (child && gtk_widget_get_visible (child)) gtk_widget_get_preferred_height (child, minimum_height, natural_height); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); *minimum_height += border_width; *natural_height += border_width; switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: *minimum_height += HANDLE_SIZE; *natural_height += HANDLE_SIZE; break; case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: break; default: g_assert_not_reached (); break; } } if (!panel_applet_can_focus (widget)) return; /* We are deliberately ignoring focus-padding here to * save valuable panel real estate. */ gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL); *minimum_height += 2 * focus_width; *natural_height += 2 * focus_width; }
static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) { GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); GtkStyle *style = gtk_widget_get_style(widget); if (child) { gtk_widget_get_preferred_height(GTK_WIDGET(child), minimal_height, natural_height); } else { *minimal_height = 0; *natural_height = 0; } *minimal_height += 2 + 2 * MAX(2, style->ythickness); *natural_height += 2 + 2 * MAX(2, style->ythickness); }
static void anjuta_tabber_get_preferred_height (GtkWidget* widget, gint* minimum, gint* preferred) { g_return_if_fail (ANJUTA_IS_TABBER (widget)); AnjutaTabber* tabber = ANJUTA_TABBER (widget); GtkStyleContext* context; GList* child; gint focus_width; gint focus_pad; gtk_widget_style_get (GTK_WIDGET (tabber), "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); context = gtk_widget_get_style_context (widget); for (child = tabber->priv->children; child != NULL; child = g_list_next (child)) { GtkStateFlags state; GtkBorder tab_padding; gint ypadding; gint child_min; gint child_preferred; /* Get the padding of the tab */ gtk_style_context_save (context); anjuta_tabber_setup_style_context (tabber, context, child, &state, NULL); gtk_style_context_get_padding (context, state, &tab_padding); gtk_style_context_restore (context); ypadding = 2 * (focus_width + focus_pad) + tab_padding.top + tab_padding.bottom; gtk_widget_get_preferred_height (GTK_WIDGET (child->data), &child_min, &child_preferred); if (minimum) { *minimum = MAX(*minimum, child_min + ypadding); } if (preferred) { *preferred = MAX(*preferred, child_preferred + ypadding); } } }
/** * gtk_widget_get_preferred_size: * @widget: a #GtkWidget instance * @minimum_size: (out) (allow-none): location for storing the minimum size, or %NULL * @natural_size: (out) (allow-none): location for storing the natural size, or %NULL * * Retrieves the minimum and natural size of a widget, taking * into account the widget's preference for height-for-width management. * * This is used to retrieve a suitable size by container widgets which do * not impose any restrictions on the child placement. It can be used * to deduce toplevel window and menu sizes as well as child widgets in * free-form containers such as GtkLayout. * * <note><para>Handle with care. Note that the natural height of a height-for-width * widget will generally be a smaller size than the minimum height, since the required * height for the natural width is generally smaller than the required height for * the minimum width.</para></note> * * Since: 3.0 */ void gtk_widget_get_preferred_size (GtkWidget *widget, GtkRequisition *minimum_size, GtkRequisition *natural_size) { gint min_width, nat_width; gint min_height, nat_height; g_return_if_fail (GTK_IS_WIDGET (widget)); if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH) { gtk_widget_get_preferred_width (widget, &min_width, &nat_width); if (minimum_size) { minimum_size->width = min_width; gtk_widget_get_preferred_height_for_width (widget, min_width, &minimum_size->height, NULL); } if (natural_size) { natural_size->width = nat_width; gtk_widget_get_preferred_height_for_width (widget, nat_width, NULL, &natural_size->height); } } else /* GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT or CONSTANT_SIZE */ { gtk_widget_get_preferred_height (widget, &min_height, &nat_height); if (minimum_size) { minimum_size->height = min_height; gtk_widget_get_preferred_width_for_height (widget, min_height, &minimum_size->width, NULL); } if (natural_size) { natural_size->height = nat_height; gtk_widget_get_preferred_width_for_height (widget, nat_height, NULL, &natural_size->width); } } }
static gboolean overlay_get_child_position_cb (GtkOverlay *overlay, GtkWidget *widget, GdkRectangle *allocation, gpointer user_data) { GtkAllocation main_alloc; gtk_widget_get_allocation (gtk_bin_get_child (GTK_BIN (overlay)), &main_alloc); allocation->x = 0; allocation->y = 0; allocation->width = main_alloc.width; gtk_widget_get_preferred_height (widget, NULL, &allocation->height); return TRUE; }
static void gd_notification_get_preferred_height_for_width (GtkWidget *widget, gint width, gint *minimum_height, gint *natural_height) { GdNotification *notification = GD_NOTIFICATION (widget); GdNotificationPrivate *priv = notification->priv; GtkBin *bin = GTK_BIN (widget); gint child_min, child_nat, child_width, button_width = 0; GtkWidget *child; GtkBorder padding; gint minimum = 0, natural = 0; get_padding_and_border (notification, &padding); if (priv->show_close_button) { gtk_widget_get_preferred_height (priv->close_button, &minimum, &natural); gtk_widget_get_preferred_width (priv->close_button, NULL, &button_width); } child = gtk_bin_get_child (bin); if (child && gtk_widget_get_visible (child)) { child_width = width - button_width - 2 * SHADOW_OFFSET_X - padding.left - padding.right; gtk_widget_get_preferred_height_for_width (child, child_width, &child_min, &child_nat); minimum = MAX (minimum, child_min); natural = MAX (natural, child_nat); } minimum += padding.top + padding.bottom + SHADOW_OFFSET_Y; natural += padding.top + padding.bottom + SHADOW_OFFSET_Y; if (minimum_height) *minimum_height = minimum; if (natural_height) *natural_height = natural; }
static void gtk_application_window_real_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height) { GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget); GTK_WIDGET_CLASS (gtk_application_window_parent_class) ->get_preferred_height (widget, minimum_height, natural_height); if (window->priv->menubar != NULL) { gint menubar_min_height, menubar_nat_height; gtk_widget_get_preferred_height (window->priv->menubar, &menubar_min_height, &menubar_nat_height); *minimum_height += menubar_min_height; *natural_height += menubar_nat_height; } }
int gMainWindow::menuBarHeight() { int h = 0; if (menuBar) { //gtk_widget_show(GTK_WIDGET(menuBar)); //fprintf(stderr, "menuBarHeight: gtk_widget_get_visible: %d\n", gtk_widget_get_visible(GTK_WIDGET(menuBar))); #ifdef GTK3 gtk_widget_get_preferred_height(GTK_WIDGET(menuBar), NULL, &h); #else GtkRequisition req = { 0, 0 }; gtk_widget_size_request(GTK_WIDGET(menuBar), &req); h = req.height; #endif //fprintf(stderr, "menuBarHeight: %d\n", h); } return h; }
static void gtk_source_map_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height) { GtkSourceMap *map = GTK_SOURCE_MAP (widget); GtkSourceMapPrivate *priv; priv = gtk_source_map_get_instance_private (map); if (priv->view == NULL) { *minimum_height = *natural_height = 0; return; } gtk_widget_get_preferred_height (GTK_WIDGET (priv->child_view), minimum_height, natural_height); *minimum_height = 0; }