void qtcScrolledWindowSetup(GtkWidget *widget) { if (widget && GTK_IS_SCROLLED_WINDOW(widget) && !g_object_get_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_SET")) { GtkScrolledWindow *scrolledWindow=GTK_SCROLLED_WINDOW(widget); GtkWidget *child; if((child=gtk_scrolled_window_get_hscrollbar(scrolledWindow))) qtcScrolledWindowSetupConnections(child, widget); if((child=gtk_scrolled_window_get_vscrollbar(scrolledWindow))) qtcScrolledWindowSetupConnections(child, widget); if((child=gtk_bin_get_child(GTK_BIN(widget)))) { if(GTK_IS_TREE_VIEW(child) || GTK_IS_TEXT_VIEW(child) || GTK_IS_ICON_VIEW(child)) qtcScrolledWindowSetupConnections(child, widget); else { const gchar *type=g_type_name(qtcWidgetType(child)); if(type && (0==strcmp(type, "ExoIconView") || 0==strcmp(type, "FMIconContainer"))) qtcScrolledWindowSetupConnections(child, widget); } } g_object_set_data(G_OBJECT(widget), "QTC_SCROLLED_WINDOW_SET", (gpointer)1); } }
void qtcScrolledWindowRegisterChild(GtkWidget *child) { GtkWidget *parent=child ? qtcWidgetGetParent(child) : NULL; if(parent && GTK_IS_SCROLLED_WINDOW(parent) && g_object_get_data(G_OBJECT(parent), "QTC_SCROLLED_WINDOW_SET")) qtcScrolledWindowSetupConnections(child, parent); }
void setup(GtkWidget *widget) { GtkWidgetProps props(widget); if (widget && GTK_IS_SCROLLED_WINDOW(widget) && !props->scrolledWindowHacked) { GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(widget); GtkWidget *child; if ((child = gtk_scrolled_window_get_hscrollbar(scrolledWindow))) { setupConnections(child, widget); } if ((child = gtk_scrolled_window_get_vscrollbar(scrolledWindow))) { setupConnections(child, widget); } if ((child = gtk_bin_get_child(GTK_BIN(widget)))) { if (GTK_IS_TREE_VIEW(child) || GTK_IS_TEXT_VIEW(child) || GTK_IS_ICON_VIEW(child)) { setupConnections(child, widget); } else if (oneOf(gTypeName(child), "ExoIconView", "FMIconContainer")) { setupConnections(child, widget); } } props->scrolledWindowHacked = true; } }
void ChromeClient::scrollbarsModeDidChange() const { WebKitWebFrame* webFrame = webkit_web_view_get_main_frame(m_webView); g_object_notify(G_OBJECT(webFrame), "horizontal-scrollbar-policy"); g_object_notify(G_OBJECT(webFrame), "vertical-scrollbar-policy"); gboolean isHandled; g_signal_emit_by_name(webFrame, "scrollbars-policy-changed", &isHandled); if (isHandled) return; GtkWidget* parent = gtk_widget_get_parent(GTK_WIDGET(m_webView)); if (!parent || !GTK_IS_SCROLLED_WINDOW(parent)) return; GtkPolicyType horizontalPolicy = webkit_web_frame_get_horizontal_scrollbar_policy(webFrame); GtkPolicyType verticalPolicy = webkit_web_frame_get_vertical_scrollbar_policy(webFrame); // ScrolledWindow doesn't like to display only part of a widget if // the scrollbars are completely disabled; We have a disparity // here on what the policy requested by the web app is and what we // can represent; the idea is not to show scrollbars, only. if (horizontalPolicy == GTK_POLICY_NEVER) horizontalPolicy = GTK_POLICY_AUTOMATIC; if (verticalPolicy == GTK_POLICY_NEVER) verticalPolicy = GTK_POLICY_AUTOMATIC; gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(parent), horizontalPolicy, verticalPolicy); }
/* * gets the sheets parent adjustments * returns TRUE on success */ gboolean sheet_get_adjustments (const Sheet *sheet, GtkAdjustment **hadj, GtkAdjustment **vadj) { GtkWidget *parent; GtkScrolledWindow *scrolled; if (__unlikely (!sheet)) return FALSE; if (__unlikely (!vadj || !hadj)) return FALSE; parent = gtk_widget_get_parent (GTK_WIDGET (sheet)); if (__unlikely (!parent || !GTK_IS_SCROLLED_WINDOW (parent))) return FALSE; scrolled = GTK_SCROLLED_WINDOW (parent); *hadj = gtk_scrolled_window_get_hadjustment (scrolled); if (__unlikely (!*hadj || !GTK_IS_ADJUSTMENT (*hadj))) return FALSE; *vadj = gtk_scrolled_window_get_vadjustment (scrolled); if (__unlikely (!*vadj || !GTK_IS_ADJUSTMENT (*vadj))) return FALSE; return TRUE; }
static gboolean is_combo_window (GtkWidget *widget) { GtkWidget *child; AtkObject *obj; child = gtk_bin_get_child (GTK_BIN (widget)); if (!GTK_IS_EVENT_BOX (child)) return FALSE; child = gtk_bin_get_child (GTK_BIN (child)); if (!GTK_IS_FRAME (child)) return FALSE; child = gtk_bin_get_child (GTK_BIN (child)); if (!GTK_IS_SCROLLED_WINDOW (child)) return FALSE; obj = gtk_widget_get_accessible (child); obj = atk_object_get_parent (obj); return FALSE; }
static void ephy_push_scroller_scroll_pixels (EphyEmbed *embed, int scroll_x, int scroll_y) { GtkAdjustment *adj; gdouble value; gdouble new_value; gdouble page_size; gdouble upper; gdouble lower; GtkWidget *sw; sw = gtk_widget_get_parent (GTK_WIDGET (ephy_embed_get_web_view (embed))); g_return_if_fail (GTK_IS_SCROLLED_WINDOW (sw)); adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (sw)); upper = gtk_adjustment_get_upper (adj); lower = gtk_adjustment_get_lower (adj); value = gtk_adjustment_get_value (adj); page_size = gtk_adjustment_get_page_size (adj); new_value = CLAMP (value - scroll_x, lower, upper - page_size); gtk_adjustment_set_value (adj, new_value); adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw)); upper = gtk_adjustment_get_upper (adj); lower = gtk_adjustment_get_lower (adj); value = gtk_adjustment_get_value (adj); page_size = gtk_adjustment_get_page_size (adj); new_value = CLAMP (value - scroll_y, lower, upper - page_size); gtk_adjustment_set_value (adj, new_value); }
static bool childrenUseEvent(GtkWidget *widget, GdkEventButton *event, bool inNoteBook) { // accept, by default bool usable = true; // get children and check GList *children = gtk_container_get_children(GTK_CONTAINER(widget)); for (GList *child = children;child && usable;child = g_list_next(child)) { // cast child to GtkWidget if (GTK_IS_WIDGET(child->data)) { GtkWidget *childWidget = GTK_WIDGET(child->data); GdkWindow *window = nullptr; // check widget state and type if (gtk_widget_get_state(childWidget) == GTK_STATE_PRELIGHT) { // if widget is prelight, we don't need to check where event // happen, any prelight widget indicate we can't do a move usable = false; continue; } window = gtk_widget_get_window(childWidget); if (!(window && gdk_window_is_visible(window))) continue; if (GTK_IS_NOTEBOOK(childWidget)) inNoteBook = true; if(!(event && withinWidget(childWidget, event))) continue; // check special cases for which grab should not be enabled if((isBlackListed(G_OBJECT(childWidget))) || (GTK_IS_NOTEBOOK(widget) && Tab::isLabel(GTK_NOTEBOOK(widget), childWidget)) || (GTK_IS_BUTTON(childWidget) && gtk_widget_get_state(childWidget) != GTK_STATE_INSENSITIVE) || (gtk_widget_get_events(childWidget) & (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)) || (GTK_IS_MENU_ITEM(childWidget)) || (GTK_IS_SCROLLED_WINDOW(childWidget) && (!inNoteBook || gtk_widget_is_focus(childWidget)))) { usable = false; } // if child is a container and event has been accepted so far, // also check it, recursively if (usable && GTK_IS_CONTAINER(childWidget)) { usable = childrenUseEvent(childWidget, event, inNoteBook); } } } if (children) { g_list_free(children); } return usable; }
/** * hildon_helper_set_thumb_scrollbar: * @win: A #GtkScrolledWindow to use as target * @thumb: TRUE to enable the thumb scrollbar, FALSE to disable * * This function enables a thumb scrollbar on a given scrolled window. It'll convert the * existing normal scrollbar into a larger, finger-usable scrollbar that works without a stylus. * As fingerable list rows are fairly high, consider using the whole available vertical space * of your application for the content in order to have as many rows as possible * visible on the screen at once. * * Finger-Sized scrollbar should always be used together with finger-sized content. **/ void hildon_helper_set_thumb_scrollbar (GtkScrolledWindow *win, gboolean thumb) { g_return_if_fail (GTK_IS_SCROLLED_WINDOW (win)); if (win->vscrollbar) gtk_widget_set_name (win->vscrollbar, (thumb) ? "hildon-thumb-scrollbar" : NULL); }
/** * callback for fullscreen mode gtk_container_foreach() */ static void fullscreen_toggle_widget_visible(GtkWidget *wid, gpointer user_data) { gchar* data_label; struct FullscreenData *fdata; gboolean old_v; gchar *propName; fdata = user_data; // remove shadow of scrolled window if (GTK_IS_SCROLLED_WINDOW(wid)) { GtkShadowType shadow_type; data_label = "fullscreen_shadow_type"; propName = "shadow-type"; if (fdata->visible == FALSE) { g_object_get(G_OBJECT(wid), propName, &shadow_type, NULL); g_object_set(G_OBJECT(wid), propName, GTK_SHADOW_NONE, NULL); g_object_set_data(G_OBJECT(wid), data_label, GINT_TO_POINTER(shadow_type)); } else { shadow_type = GPOINTER_TO_INT(g_object_steal_data( G_OBJECT(wid), data_label)); if (shadow_type && shadow_type != GTK_SHADOW_NONE) { g_object_set(G_OBJECT(wid), propName, shadow_type, NULL); } } } if (wid == fdata->me && !GTK_IS_NOTEBOOK(wid)) { return; } data_label = "fullscreen_visible"; if (GTK_IS_NOTEBOOK(wid)) { propName = "show-tabs"; } else { propName = "visible"; } if (fdata->visible == FALSE) { g_object_get(G_OBJECT(wid), propName, &old_v, NULL); g_object_set(G_OBJECT(wid), propName, FALSE, NULL); g_object_set_data(G_OBJECT(wid), data_label, GINT_TO_POINTER(old_v)); } else { old_v = GPOINTER_TO_INT(g_object_steal_data( G_OBJECT(wid), data_label)); if (old_v == TRUE) { g_object_set(G_OBJECT(wid), propName, TRUE, NULL); } } }
static gboolean leave(GtkWidget *widget, GdkEventMotion*, void *data) { GtkWidget *w = data ? (GtkWidget*)data : widget; if (GTK_IS_SCROLLED_WINDOW(w) && hoverWidget == w) { hoverWidget = nullptr; gtk_widget_queue_draw(w); } return false; }
static gboolean qtcScrolledWindowFocusIn(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { GtkWidget *w=user_data ? (GtkWidget *)user_data : widget; if(GTK_IS_SCROLLED_WINDOW(w) && qtcScrolledWindowFocus!=w) { qtcScrolledWindowFocus=w; gtk_widget_queue_draw(w); } return FALSE; }
static gboolean focusIn(GtkWidget *widget, GdkEventMotion*, void *data) { GtkWidget *w = data ? (GtkWidget*)data : widget; if (GTK_IS_SCROLLED_WINDOW(w) && focusWidget != w) { focusWidget = w; gtk_widget_queue_draw(w); } return false; }
void registerChild(GtkWidget *child) { GtkWidget *parent = child ? gtk_widget_get_parent(child) : nullptr; GtkWidgetProps parentProps(parent); if (parent && GTK_IS_SCROLLED_WINDOW(parent) && parentProps->scrolledWindowHacked) { setupConnections(child, parent); } }
static int gtkListSetBgColorAttrib(Ihandle* ih, const char* value) { unsigned char r, g, b; GtkScrolledWindow* scrolled_window = (GtkScrolledWindow*)iupAttribGet(ih, "_IUP_EXTRAPARENT"); if (scrolled_window && !ih->data->is_dropdown) { /* ignore given value, must use only from parent for the scrollbars */ char* parent_value = iupBaseNativeParentGetBgColor(ih); if (iupStrToRGB(parent_value, &r, &g, &b)) { GtkWidget* sb; if (!GTK_IS_SCROLLED_WINDOW(scrolled_window)) scrolled_window = (GtkScrolledWindow*)iupAttribGet(ih, "_IUPGTK_SCROLLED_WINDOW"); iupgtkBaseSetBgColor((GtkWidget*)scrolled_window, r, g, b); #if GTK_CHECK_VERSION(2, 8, 0) sb = gtk_scrolled_window_get_hscrollbar(scrolled_window); if (sb) iupgtkBaseSetBgColor(sb, r, g, b); sb = gtk_scrolled_window_get_vscrollbar(scrolled_window); if (sb) iupgtkBaseSetBgColor(sb, r, g, b); #endif } } if (!iupStrToRGB(value, &r, &g, &b)) return 0; if (ih->data->has_editbox) { GtkWidget* entry = (GtkWidget*)iupAttribGet(ih, "_IUPGTK_ENTRY"); iupgtkBaseSetBgColor(entry, r, g, b); } { GtkCellRenderer* renderer = (GtkCellRenderer*)iupAttribGet(ih, "_IUPGTK_RENDERER"); GdkColor color = {0L,0,0,0}; color.red = iupCOLOR8TO16(r); color.green = iupCOLOR8TO16(g); color.blue = iupCOLOR8TO16(b); if (renderer) g_object_set(G_OBJECT(renderer), "cell-background-gdk", &color, NULL); } return iupdrvBaseSetBgColorAttrib(ih, value); }
static GtkWidget * textarea_get_widget (GtkWidget *widget) { GtkWidget *wid; g_assert (GTK_IS_EVENT_BOX (widget)); wid = gtk_bin_get_child (GTK_BIN (widget)); g_assert (GTK_IS_SCROLLED_WINDOW (wid)); wid = gtk_bin_get_child (GTK_BIN (wid)); return wid; }
gboolean gtk_inspector_prop_editor_should_expand (GtkInspectorPropEditor *editor) { if (GTK_IS_SCROLLED_WINDOW (editor->priv->editor)) { GtkPolicyType policy; g_object_get (editor->priv->editor, "vscrollbar-policy", &policy, NULL); if (policy != GTK_POLICY_NEVER) return TRUE; } return FALSE; }
void photos_utils_scrolled_window_scroll (GtkScrolledWindow *scrolled_window, gdouble delta_x, gdouble delta_y) { GtkAdjustment *adjustment; g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); g_return_if_fail (photos_utils_scrolled_window_can_scroll (scrolled_window)); adjustment = gtk_scrolled_window_get_hadjustment (scrolled_window); photos_utils_adjustment_scroll (adjustment, delta_x); adjustment = gtk_scrolled_window_get_vadjustment (scrolled_window); photos_utils_adjustment_scroll (adjustment, delta_y); }
void on_size_request( GtkWidget *widget, GtkRequisition *requisition, gpointer data ) { GtkWidget *parent = gtk_widget_get_parent( widget ); GtkPolicyType hpolicy; if ( !parent || !GTK_IS_SCROLLED_WINDOW( parent ) ) return; hpolicy = ( requisition->height > 0 ) ? GTK_POLICY_ALWAYS : GTK_POLICY_NEVER; gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( parent ), GTK_POLICY_AUTOMATIC, hpolicy ); return; }
//____________________________________________________________________________________________ gboolean Animations::innerShadowHook( GSignalInvocationHint*, guint, const GValue* params, gpointer data ) { #if GTK_CHECK_VERSION(2,24,2) // get widget from params GtkWidget* widget( GTK_WIDGET( g_value_get_object( params ) ) ); // check type if( !GTK_IS_WIDGET( widget ) ) return FALSE; // check enabled state Animations& animations( *static_cast<Animations*>(data) ); if( !animations.innerShadowsEnabled() ) return TRUE; // blacklist if( Gtk::g_object_is_a( G_OBJECT( widget ), "SwtFixed" ) ) return TRUE; if( Gtk::g_object_is_a( G_OBJECT( widget ), "GtkPizza" ) ) return TRUE; GtkWidget* parent(gtk_widget_get_parent(widget)); if( !GTK_IS_SCROLLED_WINDOW( parent ) ) return TRUE; GtkWidget* child(gtk_bin_get_child(GTK_BIN(parent))); if(child!=widget) return TRUE; #if OXYGEN_DEBUG std::cerr << "Oxygen::Animations::innerShadowHook -" << " widget: " << widget << " (" << G_OBJECT_TYPE_NAME(widget) << ")" << " parent: " << parent << " (" << G_OBJECT_TYPE_NAME(parent) << ")" << " widget path: " << Gtk::gtk_widget_path( widget ) << " isTreeView: " << (GTK_IS_TREE_VIEW(widget)?"true":"false") << " isTextView: " << (GTK_IS_TEXT_VIEW(widget)?"true":"false") << std::endl; #endif // force shadow type on known windows if( Gtk::gtk_scrolled_window_force_sunken( parent ) ) { gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( parent ), GTK_SHADOW_IN ); } animations.innerShadowEngine().registerWidget( parent ); animations.innerShadowEngine().registerChild( parent, widget ); #endif // Gtk version return TRUE; }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetParent (JNIEnv *env, jobject obj, jobject parent) { void *ptr; void *parent_ptr; GtkWidget *widget; GtkWidget *parent_widget; gdk_threads_enter (); ptr = gtkpeer_get_widget (env, obj); parent_ptr = gtkpeer_get_widget (env, parent); widget = GTK_WIDGET (ptr); parent_widget = get_widget(GTK_WIDGET (parent_ptr)); if (widget->parent == NULL) { if (GTK_IS_WINDOW (parent_widget)) { GList *children = gtk_container_get_children (GTK_CONTAINER (parent_widget)); if (GTK_IS_MENU_BAR (children->data)) gtk_fixed_put (GTK_FIXED (children->next->data), widget, 0, 0); else gtk_fixed_put (GTK_FIXED (children->data), widget, 0, 0); } else if (GTK_IS_SCROLLED_WINDOW (parent_widget)) { gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (parent_widget), widget); gtk_viewport_set_shadow_type (GTK_VIEWPORT (widget->parent), GTK_SHADOW_NONE); } else { if (widget->parent == NULL) gtk_fixed_put (GTK_FIXED (parent_widget), widget, 0, 0); } } gdk_threads_leave (); }
gboolean greeter_item_ulist_setup (void) { GreeterItemInfo *info; info = greeter_lookup_id ("user-pw-entry"); if (info && info->item && GNOME_IS_CANVAS_WIDGET (info->item) && GTK_IS_ENTRY (GNOME_CANVAS_WIDGET (info->item)->widget)) { pam_entry = GNOME_CANVAS_WIDGET (info->item)->widget; } info = greeter_lookup_id ("userlist"); if (info && info->item && GNOME_IS_CANVAS_WIDGET (info->item)) { GtkWidget *sw = GNOME_CANVAS_WIDGET (info->item)->widget; if (GTK_IS_SCROLLED_WINDOW (sw) && GTK_IS_TREE_VIEW (GTK_BIN (sw)->child)) { GtkRequisition req; gdouble height; user_list = GTK_BIN (sw)->child; force_no_tree_separators (user_list); greeter_generate_userlist (user_list, info); /* Reset size of the widget canvas item so it * is the same size as the userlist. This * avoids the ugly white background displayed * below the Face Browser when the list isn't * as large as the rectangle defined in the * MDM theme file. */ gtk_widget_size_request (user_list, &req); g_object_get (info->item, "height", &height, NULL); if (req.height < height) g_object_set (info->item, "height", (double)req.height, NULL); } } return TRUE; }
void qtcTreeViewSetup(GtkWidget *widget) { QTC_DEF_WIDGET_PROPS(props, widget); if (widget && !qtcWidgetProps(props)->treeViewHacked) { QtCTreeView *tv = qtcTreeViewLookupHash(widget, true); GtkTreeView *treeView = GTK_TREE_VIEW(widget); GtkWidget *parent = gtk_widget_get_parent(widget); if (tv) { qtcWidgetProps(props)->treeViewHacked = true; int x, y; #if GTK_CHECK_VERSION(2, 90, 0) /* Gtk3:TODO !!! */ tv->fullWidth = true; #else gtk_widget_style_get(widget, "row_ending_details", &tv->fullWidth, NULL); #endif gdk_window_get_pointer(gtk_widget_get_window(widget), &x, &y, 0L); gtk_tree_view_convert_widget_to_bin_window_coords(treeView, x, y, &x, &y); qtcTreeViewUpdatePosition(widget, x, y); qtcConnectToProp(props, treeViewDestroy, "destroy-event", qtcTreeViewDestroy, NULL); qtcConnectToProp(props, treeViewUnrealize, "unrealize", qtcTreeViewDestroy, NULL); qtcConnectToProp(props, treeViewStyleSet, "style-set", qtcTreeViewStyleSet, NULL); qtcConnectToProp(props, treeViewMotion, "motion-notify-event", qtcTreeViewMotion, NULL); qtcConnectToProp(props, treeViewLeave, "leave-notify-event", qtcTreeViewLeave, NULL); } if (!gtk_tree_view_get_show_expanders(treeView)) gtk_tree_view_set_show_expanders(treeView, true); if (gtk_tree_view_get_enable_tree_lines(treeView)) gtk_tree_view_set_enable_tree_lines(treeView, false); if (GTK_IS_SCROLLED_WINDOW(parent) && gtk_scrolled_window_get_shadow_type(GTK_SCROLLED_WINDOW(parent)) != GTK_SHADOW_IN) { gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(parent), GTK_SHADOW_IN); } } }
void bjb_main_view_disconnect_scrolled_window (BjbMainView *self) { GtkAdjustment *vadjustment; GtkWidget *vscrollbar; BjbMainViewPriv *priv = self->priv; if (priv->view == NULL || !GTK_IS_SCROLLED_WINDOW (priv->view)) return; vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->view)); vscrollbar = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->view)); g_signal_handlers_disconnect_by_func (vadjustment, bjb_main_view_view_changed, self); g_signal_handlers_disconnect_by_func (vscrollbar, bjb_main_view_view_changed, self); }
/** * inf_text_gtk_viewport_new: * @scroll: A #GtkScrolledWindow. * @user_table: The #InfUserTable for the text session displayed in @viewport. * * Creates a new #InfTextGtkViewport for @scroll. This draws the position of * remote user's cursors into the scrollbars of @scroll. * * Returns: A new #InfTextGtkViewport. */ InfTextGtkViewport* inf_text_gtk_viewport_new(GtkScrolledWindow* scroll, InfUserTable* user_table) { GObject* object; g_return_val_if_fail(GTK_IS_SCROLLED_WINDOW(scroll), NULL); g_return_val_if_fail(INF_IS_USER_TABLE(user_table), NULL); object = g_object_new( INF_TEXT_GTK_TYPE_VIEWPORT, "scrolled-window", scroll, "user-table", user_table, NULL ); return INF_TEXT_GTK_VIEWPORT(object); }
static gboolean chat_text_view_is_scrolled_down (EmpathyChatTextView *view) { GtkWidget *sw; sw = gtk_widget_get_parent (GTK_WIDGET (view)); if (GTK_IS_SCROLLED_WINDOW (sw)) { GtkAdjustment *vadj; vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw)); if (vadj->value + vadj->page_size / 2 < vadj->upper - vadj->page_size) { return FALSE; } } return TRUE; }
/** * * init_web_browser * * Initialise the webkit browser * * @parent: Widget to house the browser */ WebBrowser *init_web_browser(GtkWidget *parent) { browser = g_new0(WebBrowser, 1); create_menubar(); create_toolbar(); create_browser(); create_statusbar(); GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start(GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), browser->toolbar, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX (vbox), browser->browser_window, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET(browser->statusbar), FALSE, FALSE, 0); if (GTK_IS_SCROLLED_WINDOW(parent)) gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(parent), vbox); else gtk_container_add(GTK_CONTAINER (parent), vbox); return browser; }
gboolean photos_utils_scrolled_window_can_scroll (GtkScrolledWindow *scrolled_window) { GtkAdjustment *adjustment; gboolean ret_val = TRUE; g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), FALSE); adjustment = gtk_scrolled_window_get_hadjustment (scrolled_window); if (photos_utils_adjustment_can_scroll (adjustment)) goto out; adjustment = gtk_scrolled_window_get_vadjustment (scrolled_window); if (photos_utils_adjustment_can_scroll (adjustment)) goto out; ret_val = FALSE; out: return ret_val; }
/* * This function initializes all custom lists aside from * the userlist (face browser), which is handled * separately. */ gboolean greeter_item_customlist_setup (void) { const GList *custom_items = greeter_custom_items (); const GList *li; for (li = custom_items; li != NULL; li = li->next) { GreeterItemInfo *info = li->data; if (info != NULL && info->item_type == GREETER_ITEM_TYPE_LIST && info->item != NULL && GNOME_IS_CANVAS_WIDGET (info->item)) { GtkWidget *sw = GNOME_CANVAS_WIDGET (info->item)->widget; /* * Store these so that when the values change in the * F10 session/language dialogs, we can easily modify * them. */ if (strcmp (info->id, "session") == 0) session_widget = sw; else if (strcmp (info->id, "language") == 0) language_widget = sw; /* If combo or list style, process appropriately */ if (GTK_IS_SCROLLED_WINDOW (sw) && GTK_IS_TREE_VIEW (GTK_BIN (sw)->child)) { setup_customlist (GTK_BIN (sw)->child, info); } else if (GTK_IS_COMBO_BOX (sw)) { setup_combo_customlist (GTK_COMBO_BOX (sw), info); } } } return TRUE; }
static gboolean i7_goo_canvas_item_get_onscreen_coordinates(GooCanvasItem *item, GooCanvas *canvas, gint *x, gint *y) { GooCanvasBounds bounds; GtkAllocation allocation; gdouble canvas_x, canvas_y; gdouble top, bottom, left, right, item_x, item_y; /* Find out the size and coordinates of the current viewport */ goo_canvas_get_bounds(canvas, &canvas_x, &canvas_y, NULL, NULL); GtkWidget *scrolled_window = gtk_widget_get_parent(GTK_WIDGET(canvas)); g_assert(GTK_IS_SCROLLED_WINDOW(scrolled_window)); GtkAdjustment *adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window)); left = canvas_x + gtk_adjustment_get_value(adj); right = left + gtk_adjustment_get_page_size(adj); adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window)); top = canvas_y + gtk_adjustment_get_value(adj); bottom = top + gtk_adjustment_get_page_size(adj); /* Make sure item is currently displayed */ goo_canvas_item_get_bounds(item, &bounds); if(bounds.x1 > right || bounds.x2 < left || bounds.y1 > bottom || bounds.y2 < top) { g_warning("Node not onscreen in canvas"); return FALSE; } /* Find out the onscreen coordinates of the canvas viewport */ gtk_widget_get_allocation(GTK_WIDGET(canvas), &allocation); if(x) { item_x = bounds.x1; *x = (gint)(item_x - left) + allocation.x; } if(y) { item_y = bounds.y1; *y = (gint)(item_y - top) + allocation.y; } return TRUE; }