static void init_data_sheet (PsppireDataEditor *de) { GtkAdjustment *vadj0, *hadj0; GtkAdjustment *vadj1, *hadj1; GtkWidget *sheet ; de->vaxis[0] = psppire_axis_new (); de->vaxis[1] = psppire_axis_new (); /* There's only one horizontal axis, since the column widths are parameters of the variables */ de->haxis = psppire_axis_new (); de->split = TRUE; de->paned = gtk_xpaned_new (); init_sheet (de, 0, NULL, NULL, de->vaxis[0], de->haxis); gtk_widget_show (de->sheet_bin[0]); vadj0 = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (de->sheet_bin[0])); hadj0 = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (de->sheet_bin[0])); g_object_set (de->sheet_bin[0], "vscrollbar-policy", GTK_POLICY_NEVER, NULL); g_object_set (de->sheet_bin[0], "hscrollbar-policy", GTK_POLICY_NEVER, NULL); init_sheet (de, 1, NULL, vadj0, de->vaxis[0], de->haxis); gtk_widget_show (de->sheet_bin[1]); sheet = gtk_bin_get_child (GTK_BIN (de->sheet_bin[1])); psppire_sheet_hide_row_titles (PSPPIRE_SHEET (sheet)); hadj1 = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (de->sheet_bin[1])); g_object_set (de->sheet_bin[1], "vscrollbar-policy", GTK_POLICY_ALWAYS, NULL); g_object_set (de->sheet_bin[1], "hscrollbar-policy", GTK_POLICY_NEVER, NULL); init_sheet (de, 2, hadj0, NULL, de->vaxis[1], de->haxis); gtk_widget_show (de->sheet_bin[2]); sheet = gtk_bin_get_child (GTK_BIN (de->sheet_bin[2])); psppire_sheet_hide_column_titles (PSPPIRE_SHEET (sheet)); g_object_set (de->sheet_bin[2], "vscrollbar-policy", GTK_POLICY_NEVER, NULL); g_object_set (de->sheet_bin[2], "hscrollbar-policy", GTK_POLICY_ALWAYS, NULL); vadj1 = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (de->sheet_bin[2])); init_sheet (de, 3, hadj1, vadj1, de->vaxis[1], de->haxis); gtk_widget_show (de->sheet_bin[3]); sheet = gtk_bin_get_child (GTK_BIN (de->sheet_bin[3])); psppire_sheet_hide_column_titles (PSPPIRE_SHEET (sheet)); psppire_sheet_hide_row_titles (PSPPIRE_SHEET (sheet)); g_object_set (de->sheet_bin[3], "vscrollbar-policy", GTK_POLICY_ALWAYS, NULL); g_object_set (de->sheet_bin[3], "hscrollbar-policy", GTK_POLICY_ALWAYS, NULL); gtk_xpaned_pack_top_left (GTK_XPANED (de->paned), de->sheet_bin[0], TRUE, TRUE); gtk_xpaned_pack_top_right (GTK_XPANED (de->paned), de->sheet_bin[1], TRUE, TRUE); gtk_xpaned_pack_bottom_left (GTK_XPANED (de->paned), de->sheet_bin[2], TRUE, TRUE); gtk_xpaned_pack_bottom_right (GTK_XPANED (de->paned), de->sheet_bin[3], TRUE, TRUE); gtk_xpaned_set_position_y (GTK_XPANED (de->paned), 150); gtk_xpaned_set_position_x (GTK_XPANED (de->paned), 350); }
static GObject * carrick_list_constructor (GType gtype, guint n_properties, GObjectConstructParam *properties) { GObject *obj; GObjectClass *parent_class; CarrickListPrivate *priv; GtkWidget *viewport, *box; parent_class = G_OBJECT_CLASS (carrick_list_parent_class); obj = parent_class->constructor (gtype, n_properties, properties); priv = LIST_PRIVATE (obj); priv->adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (obj)); g_signal_connect (priv->adjustment, "value-changed", G_CALLBACK (_adjustment_value_changed_cb), obj); viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (obj)), gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (obj))); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE); gtk_widget_show (viewport); gtk_container_add (GTK_CONTAINER (obj), viewport); box = gtk_vbox_new (FALSE, 0); gtk_widget_show (box); gtk_container_add (GTK_CONTAINER (viewport), box); gtk_label_set_line_wrap (GTK_LABEL (priv->fallback), TRUE); gtk_widget_set_size_request (priv->fallback, 550, -1); gtk_widget_show (priv->fallback); gtk_misc_set_padding (GTK_MISC (priv->fallback), 0, 12); gtk_box_pack_start (GTK_BOX (box), priv->fallback, FALSE, FALSE, 2); priv->box = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (box), priv->box); return obj; }
/* Parse a line of output, which may actually be more than one line. To handle * multiple lines, the string is split with g_strsplit(). */ void output (gchar *line, gboolean free_it) { static GtkBuilder *builder = NULL; static GtkWidget *textview = NULL; GtkTextBuffer * textbuffer = NULL; GtkTextIter iter; GtkWidget *parent = NULL; GtkAdjustment * adj = NULL; if (!builder) builder = (GtkBuilder *)DATA_GET(global_data,"builder"); g_return_if_fail(builder); if (!textview) textview = GTK_WIDGET(gtk_builder_get_object(builder, "textview")); g_return_if_fail(textview); textbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); gtk_text_buffer_get_end_iter (textbuffer, &iter); gtk_text_buffer_insert(textbuffer,&iter,line,-1); parent = gtk_widget_get_parent(textview); if (parent != NULL) { adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(parent)); gtk_adjustment_set_value(adj,gtk_adjustment_get_upper(adj)); } if (free_it) g_free(line); }
void gui_logfunction(int log_level, const char* str) { GtkTextIter iter; GtkAdjustment* adj; const char* tag; if (!TEXT_BUFFER) return; switch (log_level) { case LOG_INFO: tag = "green_text"; break; case LOG_DEBUG: tag = "green_text"; break; case LOG_WARNING: tag = "purple_text"; break; case LOG_ERROR: tag = "red_text"; break; } gtk_text_buffer_get_iter_at_offset (TEXT_BUFFER,&iter,-1); gtk_text_buffer_insert_with_tags_by_name(TEXT_BUFFER,&iter,str,-1,tag,NULL); if (SCROLL_TEXT) { adj = gtk_scrolled_window_get_vadjustment(SCROLL_TEXT); adj -> value = adj -> upper; gtk_adjustment_value_changed(adj); } }
/* Update our geometry from the fixed widget. */ static void workspaceview_scroll_update( Workspaceview *wview ) { Workspace *ws = WORKSPACE( VOBJECT( wview )->iobject ); GtkAdjustment *hadj = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW( wview->window ) ); GtkAdjustment *vadj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW( wview->window ) ); wview->vp.left = hadj->value; wview->vp.top = vadj->value; wview->vp.width = hadj->page_size; wview->vp.height = vadj->page_size; wview->width = hadj->upper; wview->height = vadj->upper; /* Update vp hint in model too. */ ws->vp = wview->vp; #ifdef DEBUG printf( "workspaceview_scroll_update: %s\n", IOBJECT( ws )->name ); printf( " wview->vp: l=%d, t=%d, w=%d, h=%d; fixed w=%d; h=%d\n", wview->vp.left, wview->vp.top, wview->vp.width, wview->vp.height, wview->width, wview->height ); #endif /*DEBUG*/ }
GtkWidget * picture_create_widget (GtkWidget * dlg) { GtkWidget *sw; sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), options.hscroll_policy, options.vscroll_policy); viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (sw)), gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw))); gtk_container_add (GTK_CONTAINER (sw), viewport); picture = gtk_image_new (); gtk_container_add (GTK_CONTAINER (viewport), picture); /* load picture */ if (options.common_data.uri && g_file_test (options.common_data.uri, G_FILE_TEST_EXISTS)) load_picture (options.common_data.uri); else gtk_image_set_from_stock (GTK_IMAGE (picture), "gtk-missing-image", GTK_ICON_SIZE_DIALOG); if (loaded && !animated) { create_popup_menu (); g_signal_connect (G_OBJECT (viewport), "button-press-event", G_CALLBACK (button_handler), NULL); g_signal_connect (G_OBJECT (viewport), "key-press-event", G_CALLBACK (key_handler), NULL); } return sw; }
void cb_refresh_view(GtkWidget* GIRARA_UNUSED(view), gpointer data) { zathura_t* zathura = data; if (zathura == NULL || zathura->document == NULL) { return; } unsigned int page_id = zathura_document_get_current_page_number(zathura->document); zathura_page_t* page = zathura_document_get_page(zathura->document, page_id); if (page == NULL) { return; } GtkAdjustment* vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); GtkAdjustment* hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); double position_x = zathura_document_get_position_x(zathura->document); double position_y = zathura_document_get_position_y(zathura->document); zathura_adjustment_set_value_from_ratio(vadj, position_y); zathura_adjustment_set_value_from_ratio(hadj, position_x); statusbar_page_number_update(zathura); }
/** * gs_shell_overview_switch_to: **/ void gs_shell_overview_switch_to (GsShellOverview *self, gboolean scroll_up) { GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self); GtkWidget *widget; GtkAdjustment *adj; if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_OVERVIEW) { g_warning ("Called switch_to(overview) when in mode %s", gs_shell_get_mode_string (priv->shell)); return; } widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main")); gtk_widget_show (widget); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar")); gtk_widget_show (widget); widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "entry_search")); gtk_entry_set_text (GTK_ENTRY (widget), ""); if (scroll_up) { adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolledwindow_overview)); gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj)); } gs_grab_focus_when_mapped (priv->scrolledwindow_overview); if (priv->cache_valid || priv->refresh_count > 0) return; gs_shell_overview_load (self); }
/* * 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 gint luaH_webview_scroll_index(lua_State *L) { webview_data_t *d = luaH_checkwvdata(L, lua_upvalueindex(1)); const gchar *prop = luaL_checkstring(L, 2); luakit_token_t t = l_tokenize(prop); GtkAdjustment *a = (*prop == 'x') ? gtk_scrolled_window_get_hadjustment(d->win) : gtk_scrolled_window_get_vadjustment(d->win); if (t == L_TK_X || t == L_TK_Y) { lua_pushnumber(L, gtk_adjustment_get_value(a)); return 1; } else if (t == L_TK_XMAX || t == L_TK_YMAX) { lua_pushnumber(L, gtk_adjustment_get_upper(a) - gtk_adjustment_get_page_size(a)); return 1; } else if (t == L_TK_XPAGE_SIZE || t == L_TK_YPAGE_SIZE) { lua_pushnumber(L, gtk_adjustment_get_page_size(a)); return 1; } return 0; }
static gint luaH_webview_get_vscroll(lua_State *L) { widget_t *w = luaH_checkudata(L, 1, &widget_class); GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(w->widget)); return push_adjustment_values(L, adjustment); }
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); }
void gs_shell_category_setup (GsShellCategory *shell_category, GsShell *shell, GsPluginLoader *plugin_loader, GtkBuilder *builder, GCancellable *cancellable) { GsShellCategoryPrivate *priv = shell_category->priv; GtkAdjustment *adj; priv->plugin_loader = g_object_ref (plugin_loader); priv->builder = g_object_ref (builder); priv->shell = shell; g_signal_connect (priv->listbox_filter, "row-selected", G_CALLBACK (filter_selected), shell_category); adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolledwindow_category)); gtk_container_set_focus_vadjustment (GTK_CONTAINER (priv->category_detail_grid), adj); g_signal_connect (priv->listbox_filter, "key-press-event", G_CALLBACK (key_event), shell_category); /* chain up */ gs_page_setup (GS_PAGE (shell_category), shell, plugin_loader, cancellable); }
/** * Scroll page down (via shortcut key) * * Copied from gtkhtml/gtkhtml.c */ static gboolean liferea_webkit_scroll_pagedown (GtkWidget *scrollpane) { GtkScrolledWindow *itemview; GtkAdjustment *vertical_adjustment; gdouble old_value; gdouble new_value; gdouble limit; itemview = GTK_SCROLLED_WINDOW (scrollpane); g_assert (NULL != itemview); vertical_adjustment = gtk_scrolled_window_get_vadjustment (itemview); old_value = gtk_adjustment_get_value (vertical_adjustment); new_value = old_value + gtk_adjustment_get_page_increment (vertical_adjustment); limit = gtk_adjustment_get_upper (vertical_adjustment) - gtk_adjustment_get_page_size (vertical_adjustment); if (new_value > limit) { new_value = limit; } gtk_adjustment_set_value (vertical_adjustment, new_value); gtk_scrolled_window_set_vadjustment ( GTK_SCROLLED_WINDOW (itemview), vertical_adjustment ); return (new_value > old_value); }
/* Scroll to make an xywh area visible. If the area is larger than the * viewport, position the view at the bottom left if the xywh area ... * this is usually right for workspaces. */ void workspaceview_scroll( Workspaceview *wview, int x, int y, int w, int h ) { GtkAdjustment *hadj = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW( wview->window ) ); GtkAdjustment *vadj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW( wview->window ) ); Rect *vp = &wview->vp; int nx, ny; nx = hadj->value; if( x + w > IM_RECT_RIGHT( vp ) ) nx = IM_MAX( 0, (x + w) - vp->width ); if( x < nx ) nx = x; ny = vadj->value; if( y + h > IM_RECT_BOTTOM( vp ) ) ny = IM_MAX( 0, (y + h) - vp->height ); if( y < ny ) ny = y; #ifdef DEBUG printf( "workspaceview_scroll: x=%d, y=%d, w=%d, h=%d, " "nx = %d, ny = %d\n", x, y, w, h, nx, ny ); #endif /*DEBUG*/ adjustments_set_value( hadj, vadj, nx, ny ); }
/* FIXME: call this if the view is already loaded before it's added to * main window. Update title and tab label using dir_fi of the FmFolder object. */ static void on_folder_view_loaded(FmFolderView* view, FmPath* path, FmTabPage* page) { FmIcon* icon; const FmNavHistoryItem* item; FmFolder* folder; folder = fm_folder_view_get_folder(view); if(folder) { #if 0 if(folder->dir_fi) { icon = folder->dir_fi->icon; if(icon) { icon->gicon; /* FIXME: load icon. we need to change window icon when switching pages. */ gtk_window_set_icon_name(GTK_WINDOW(win), "folder"); } } #endif fm_folder_query_filesystem_info(folder); } /* scroll to recorded position */ item = fm_nav_history_get_cur(page->nav_history); gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(view)), item->scroll_pos); /* update status text */ g_free(page->status_text[FM_STATUS_TEXT_NORMAL]); page->status_text[FM_STATUS_TEXT_NORMAL] = format_status_text(page); g_signal_emit(page, signals[STATUS], 0, FM_STATUS_TEXT_NORMAL, page->status_text[FM_STATUS_TEXT_NORMAL]); }
static gboolean on_timeout_scroll(gpointer data) { GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(data)); gtk_adjustment_set_value(adj, gtk_adjustment_get_upper(adj)); return FALSE; }
void scrolling(GtkWidget *widget, gpointer data) { GtkAdjustment *adjustment; adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(widget)); adjustment->value = adjustment->upper; gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(widget),adjustment); }
static void test_webkit_web_view_grab_focus() { char* uri = g_strconcat(base_uri, "iframe.html", NULL); GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget* scrolled_window = gtk_scrolled_window_new(NULL, NULL); WebKitWebView* view = WEBKIT_WEB_VIEW(webkit_web_view_new()); GtkAdjustment* adjustment; gtk_window_set_default_size(GTK_WINDOW(window), 400, 200); gtk_container_add(GTK_CONTAINER(window), scrolled_window); gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(view)); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); loop = g_main_loop_new(NULL, TRUE); g_signal_connect(view, "notify::load-status", G_CALLBACK(idle_quit_loop_cb), NULL); /* Wait for window to show up */ gtk_widget_show_all(window); g_signal_connect(window, "map-event", G_CALLBACK(map_event_cb), loop); g_main_loop_run(loop); /* Load a page with a big div that will cause scrollbars to appear */ webkit_web_view_load_uri(view, uri); g_main_loop_run(loop); adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window)); g_assert_cmpfloat(gtk_adjustment_get_value(adjustment), ==, 0.0); /* Since webkit_web_view_execute_script does not return a value, it is impossible to know if an inner document has focus after a node of it was focused via .focus() method. The code below is an workaround: if the node has focus, a scroll action is performed and afterward it is checked if the adjustment has to be different from 0. */ char script[] = "var innerDoc = document.defaultView.frames[0].document; \ innerDoc.getElementById(\"link\").focus(); \ if (innerDoc.hasFocus()) \ window.scrollBy(0, 100);"; /* Focus an element using JavaScript */ webkit_web_view_execute_script(view, script); /* Adjustments update asynchronously, so we must wait a bit. */ g_timeout_add(100, quit_after_short_delay_cb, loop); g_main_loop_run(loop); /* Make sure the ScrolledWindow noticed the scroll */ g_assert_cmpfloat(gtk_adjustment_get_value(adjustment), !=, 0.0); g_free(uri); gtk_widget_destroy(window); }
GtkWidget * cc_input_chooser_new (GtkWindow *main_window, GnomeXkbInfo *xkb_info, GHashTable *ibus_engines) { GtkBuilder *builder; GtkWidget *chooser; CcInputChooserPrivate *priv; gint width; GError *error = NULL; builder = gtk_builder_new (); if (gtk_builder_add_from_resource (builder, "/org/gnome/initial-setup/input-chooser.ui", &error) == 0) { g_object_unref (builder); g_warning ("failed to load input chooser: %s", error->message); g_error_free (error); return NULL; } chooser = WID ("input-dialog"); priv = g_new0 (CcInputChooserPrivate, 1); g_object_set_data_full (G_OBJECT (chooser), "private", priv, cc_input_chooser_private_free); g_object_set_data_full (G_OBJECT (chooser), "builder", builder, g_object_unref); priv->xkb_info = xkb_info; priv->ibus_engines = ibus_engines; priv->add_button = WID ("add-button"); priv->filter_entry = WID ("filter-entry"); priv->list = WID ("list"); priv->scrolledwindow = WID ("scrolledwindow"); priv->adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolledwindow)); priv->more_item = g_object_ref_sink (more_widget_new ()); priv->no_results = g_object_ref_sink (no_results_widget_new ()); gtk_list_box_set_filter_func (GTK_LIST_BOX (priv->list), list_filter, chooser, NULL); gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->list), list_sort, chooser, NULL); g_signal_connect (priv->list, "row-activated", G_CALLBACK (row_activated), chooser); g_signal_connect (priv->list, "row-selected", G_CALLBACK (row_selected), chooser); g_signal_connect_swapped (priv->filter_entry, "changed", G_CALLBACK (filter_changed), chooser); get_locale_infos (chooser); #ifdef HAVE_IBUS get_ibus_locale_infos (chooser); #endif /* HAVE_IBUS */ show_locale_widgets (chooser); /* Try to come up with a sensible width */ gtk_window_get_size (main_window, &width, NULL); gtk_widget_set_size_request (chooser, width * MAIN_WINDOW_WIDTH_RATIO, -1); gtk_window_set_resizable (GTK_WINDOW (chooser), TRUE); gtk_window_set_transient_for (GTK_WINDOW (chooser), main_window); return chooser; }
void ui_playlist_notebook_create_tab(gint playlist) { GtkWidget *scrollwin, *treeview; GtkWidget *label, *entry, *ebox, *hbox; GtkAdjustment *vscroll; gint position = aud_playlist_get_position (playlist); scrollwin = gtk_scrolled_window_new(NULL, NULL); vscroll = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrollwin)); treeview = ui_playlist_widget_new(playlist); g_object_set_data(G_OBJECT(scrollwin), "treeview", treeview); gtk_container_add(GTK_CONTAINER(scrollwin), treeview); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_widget_show_all(scrollwin); ebox = gtk_event_box_new(); gtk_event_box_set_visible_window ((GtkEventBox *) ebox, FALSE); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); label = gtk_label_new (""); set_tab_label (playlist, (GtkLabel *) label); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(ebox), hbox); gtk_widget_show_all(ebox); gtk_widget_hide(entry); gtk_box_pack_end ((GtkBox *) hbox, make_close_button (playlist), FALSE, FALSE, 0); g_object_set_data(G_OBJECT(ebox), "label", label); g_object_set_data(G_OBJECT(ebox), "entry", entry); g_object_set_data(G_OBJECT(ebox), "page", scrollwin); gtk_notebook_insert_page (UI_PLAYLIST_NOTEBOOK, scrollwin, ebox, playlist); gtk_notebook_set_tab_reorderable(UI_PLAYLIST_NOTEBOOK, scrollwin, TRUE); g_object_set_data ((GObject *) treeview, "playlist-id", GINT_TO_POINTER (aud_playlist_get_unique_id (playlist))); if (position >= 0) { aud_playlist_select_all (playlist, FALSE); aud_playlist_entry_set_selected (playlist, position, TRUE); audgui_list_set_highlight (treeview, position); audgui_list_set_focus (treeview, position); } g_signal_connect(ebox, "button-press-event", G_CALLBACK(tab_button_press_cb), NULL); g_signal_connect(ebox, "key-press-event", G_CALLBACK(tab_key_press_cb), NULL); g_signal_connect(entry, "activate", G_CALLBACK(tab_title_save), ebox); g_signal_connect_swapped (vscroll, "value-changed", G_CALLBACK(ui_playlist_widget_scroll), treeview); }
static void add_row(GtkWidget *table, gint *row_p, const gchar *name, const gchar *value, gboolean multiline, gboolean expand) { gchar *bold_name; GtkWidget *name_w; bold_name = g_strconcat("<b>", name, "</b>", NULL); name_w = gtk_label_new(bold_name); g_free(bold_name); gtk_misc_set_alignment(GTK_MISC(name_w), 0.0, 0.0); gtk_label_set_use_markup(GTK_LABEL(name_w), TRUE); gtk_table_attach(GTK_TABLE(table), name_w, 0, 1, *row_p, *row_p + 1, GTK_FILL, GTK_FILL, 0, 0); if (multiline) { GtkWidget *label, *viewport; GtkScrolledWindow *swin; guint flags; label = gtk_label_new (value); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_label_set_selectable (GTK_LABEL (label), TRUE); gtk_widget_set_size_request (label, 200, -1); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); swin = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL)); gtk_scrolled_window_set_policy(swin, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (swin), gtk_scrolled_window_get_vadjustment (swin)); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE); gtk_container_add (GTK_CONTAINER(swin), viewport); (*row_p)++; if (expand) flags = GTK_FILL|GTK_EXPAND; else flags = GTK_FILL; gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(swin), 0, 2, *row_p, *row_p + 1, GTK_FILL|GTK_EXPAND, flags, 0, 0); gtk_container_add (GTK_CONTAINER (viewport), label); } else { GtkWidget *label = gtk_label_new(value); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_table_attach(GTK_TABLE(table), label, 1, 2, *row_p, *row_p + 1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0); } (*row_p)++; }
void thunar_progress_dialog_add_job (ThunarProgressDialog *dialog, ThunarJob *job, const gchar *icon_name, const gchar *title) { GtkWidget *viewport; GtkWidget *view; _thunar_return_if_fail (THUNAR_IS_PROGRESS_DIALOG (dialog)); _thunar_return_if_fail (THUNAR_IS_JOB (job)); _thunar_return_if_fail (g_utf8_validate (title, -1, NULL)); view = thunar_progress_view_new_with_job (job); thunar_progress_view_set_icon_name (THUNAR_PROGRESS_VIEW (view), icon_name); thunar_progress_view_set_title (THUNAR_PROGRESS_VIEW (view), title); gtk_box_pack_start (GTK_BOX (dialog->content_box), view, FALSE, TRUE, 0); gtk_widget_show (view); /* use the first job's icon-name for the dialog */ if (dialog->views == NULL) gtk_window_set_icon_name (GTK_WINDOW (dialog), icon_name); /* add the view to the list of known views */ dialog->views = g_list_prepend (dialog->views, view); /* check if we need to wrap the views in a scroll window (starting * at SCROLLVIEW_THRESHOLD parallel operations */ if (g_list_length (dialog->views) == SCROLLVIEW_THRESHOLD) { /* create a scrolled window and add it to the dialog */ dialog->scrollwin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (dialog->scrollwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (dialog->vbox), dialog->scrollwin); gtk_widget_show (dialog->scrollwin); /* create a viewport for the content box */ viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (dialog->scrollwin)), gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (dialog->scrollwin))); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE); gtk_container_add (GTK_CONTAINER (dialog->scrollwin), viewport); gtk_widget_show (viewport); /* move the content box into the viewport */ gtk_widget_reparent (dialog->content_box, viewport); } g_signal_connect_swapped (view, "need-attention", G_CALLBACK (thunar_progress_dialog_view_needs_attention), dialog); g_signal_connect_swapped (view, "finished", G_CALLBACK (thunar_progress_dialog_job_finished), dialog); if (dialog->status_icon != NULL) thunar_progress_dialog_update_status_icon (dialog); }
void nsgtk_history_scroll_top (GtkScrolledWindow *scrolled_window) { GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(scrolled_window); gtk_adjustment_set_value(adjustment, 0); gtk_scrolled_window_set_vadjustment(scrolled_window, adjustment); }
static void tab_scroll_down(Chattab *tab) { GtkAdjustment *adj; gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tab->tview), tab->mk, 0.0, FALSE, 0.0, 0.0); adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(tab->scrolled)); gtk_adjustment_set_value(adj, adj->upper); } /* tab_scroll_down */
static gint luaH_webview_set_scroll_vert(lua_State *L) { widget_t *w = luaH_checkudata(L, 1, &widget_class); gdouble value = (gdouble) luaL_checknumber(L, 2); GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(w->widget)); set_adjustment(adjustment, value); return 0; }
void appendTextToBuffer(char *text){ GtkTextBuffer *textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(chatview)); GtkTextIter iter; GtkTextMark *mark= gtk_text_buffer_get_insert (textbuffer); gtk_text_buffer_get_iter_at_mark (textbuffer, &iter, mark); gtk_text_buffer_insert (textbuffer, &iter, text, -1); GtkAdjustment *vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolledwindow)); gtk_adjustment_set_value(vadj, vadj->upper); }
bool sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t) { g_return_val_if_fail(session != NULL, false); g_return_val_if_fail(session->global.data != NULL, false); zathura_t* zathura = session->global.data; g_return_val_if_fail(argument != NULL, false); g_return_val_if_fail(event != NULL, false); if (zathura->document == NULL) { return false; } static int x = 0; static int y = 0; GtkAdjustment* x_adj = NULL; GtkAdjustment* y_adj = NULL; switch (event->type) { /* scroll */ case GIRARA_EVENT_SCROLL_UP: case GIRARA_EVENT_SCROLL_DOWN: case GIRARA_EVENT_SCROLL_LEFT: case GIRARA_EVENT_SCROLL_RIGHT: return sc_scroll(session, argument, NULL, t); /* drag */ case GIRARA_EVENT_BUTTON_PRESS: x = event->x; y = event->y; break; case GIRARA_EVENT_BUTTON_RELEASE: x = 0; y = 0; break; case GIRARA_EVENT_MOTION_NOTIFY: x_adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); y_adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); if (x_adj == NULL || y_adj == NULL) { return false; } zathura_adjustment_set_value(x_adj, gtk_adjustment_get_value(x_adj) - (event->x - x)); zathura_adjustment_set_value(y_adj, gtk_adjustment_get_value(y_adj) - (event->y - y)); break; /* unhandled events */ default: break; } return false; }
void cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpointer data) { zathura_t* zathura = data; if (zathura == NULL || zathura->document == NULL || zathura->ui.page_widget == NULL) { return; } GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); GdkRectangle view_rect; /* get current adjustment values */ view_rect.y = 0; view_rect.height = gtk_adjustment_get_page_size(view_vadjustment); view_rect.x = 0; view_rect.width = gtk_adjustment_get_page_size(view_hadjustment); int page_padding = 1; girara_setting_get(zathura->ui.session, "page-padding", &page_padding); GdkRectangle center; center.x = (view_rect.width + 1) / 2; center.y = (view_rect.height + 1) / 2; center.height = center.width = (2 * page_padding) + 1; unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document); double scale = zathura_document_get_scale(zathura->document); bool updated = false; /* find page that fits */ for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) { zathura_page_t* page = zathura_document_get_page(zathura->document, page_id); GdkRectangle page_rect; GtkWidget* page_widget = zathura_page_get_widget(zathura, page); gtk_widget_translate_coordinates(page_widget, zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y); page_rect.width = zathura_page_get_width(page) * scale; page_rect.height = zathura_page_get_height(page) * scale; if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) { zathura_page_set_visibility(page, true); if (zathura->global.update_page_number == true && updated == false && gdk_rectangle_intersect(¢er, &page_rect, NULL) == TRUE) { zathura_document_set_current_page_number(zathura->document, page_id); updated = true; } } else { zathura_page_set_visibility(page, false); } zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget)); } statusbar_page_number_update(zathura); }
static void on_history_item(GtkMenuItem* mi, FmMainWin* win) { GList* l = g_object_get_qdata(G_OBJECT(mi), fm_qdata_id); const FmNavHistoryItem* item = (FmNavHistoryItem*)l->data; int scroll_pos = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(win->folder_view))); fm_nav_history_jump(win->nav_history, l, scroll_pos); item = fm_nav_history_get_cur(win->nav_history); /* FIXME: should this be driven by a signal emitted on FmNavHistory? */ fm_main_win_chdir_without_history(win, item->path); }