/* This function exists because GDK retrieves client coordinates, not window ones. (Kevin: GDK uses GetClientRect and ClientToScreen). We need that to save and restore windows position. */ void window_get_rect(GtkWidget *widget, GdkRect *rect) { gtk_window_get_size(GTK_WINDOW(widget), &rect->w, &rect->h); #ifdef __WIN32__ { BOOL bResult; HWND hWnd = GDK_WINDOW_HWND(widget->window); RECT lpRect; GdkRectangle gdkRect; bResult = GetWindowRect(hWnd, &lpRect); rect->x = lpRect.left; rect->y = lpRect.top; // Now obtain and add the offset between GDK and Win32 coordinates // (in the multi-screen case). gdk_screen_get_monitor_geometry(gdk_screen_get_default(), 0, &gdkRect); rect->x += gdkRect.x; rect->y += gdkRect.y; } #else gdk_window_get_position(widget->window, &rect->x, &rect->y); #endif }
void gimmix_save_window_pos (void) { gint x,y; gchar xpos[4]; gchar ypos[4]; gchar width[4]; gchar height[4]; /* save position and geometry */ gtk_window_get_position (GTK_WINDOW(main_window), &x, &y); sprintf (xpos, "%d", x); sprintf (ypos, "%d", y); gtk_window_get_size (GTK_WINDOW(main_window), &x, &y); sprintf (width, "%d", x); sprintf (height, "%d", y); cfg_add_key (&conf, "window_xpos", xpos); cfg_add_key (&conf, "window_ypos", ypos); cfg_add_key (&conf, "window_width", width); cfg_add_key (&conf, "window_height", height); /* save mode */ if (GTK_WIDGET_VISIBLE (GTK_WIDGET(playlist_box))) cfg_add_key (&conf, "full_view_mode", "true"); else cfg_add_key (&conf, "full_view_mode", "false"); gimmix_config_save (); return; }
static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, gpointer user_data) { cr = gdk_cairo_create(gtk_widget_get_window(widget)); int width, height; gtk_window_get_size(GTK_WINDOW(widget), &width, &height); int separation = width/10; // Set background color set_background(cr, width, height); // Set font cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, 24.0); // draw circles int n = 9; n_circles(cr, n, separation); // text //cairo_text_extents_t te; //const char *utf8 = "cairo"; //set_color_black(cr); //cairo_text_extents (cr, utf8, &te); //cairo_move_to (cr, 0, 0); //cairo_show_text (cr, "CAIRO"); // Done cairo_destroy(cr); return FALSE; }
gboolean resize_list(GtkWidget *window, GdkEvent *event, GtkWidget *widget) { gint width, height; iGameCnt = 1; gtk_window_get_size(GTK_WINDOW(window), &width, &height); gtk_widget_set_size_request(widget, 440, height - (118+41)); }
/* panel_window_get_width */ int panel_window_get_width(PanelWindow * panel) { gint width; gtk_window_get_size(GTK_WINDOW(panel->window), &width, NULL); return width; }
static void remove_sliders() { if (window_list) { GSList *tmp = window_list; while (tmp) { slider_win *slidwin = (slider_win*) tmp->data; if (slidwin != NULL && GTK_IS_WINDOW(slidwin->win)) { #if 0 GtkRequisition slidereq; gint width, height; /* Figure out how tall the slider was */ gtk_widget_size_request( slidwin->slider, &slidereq); gtk_window_get_size( GTK_WINDOW(slidwin->win), &width, &height); #endif gtk_widget_destroy(slidwin->slider); #if 0 gtk_window_resize( GTK_WINDOW(slidwin->win), width, (height - slidereq.height)); #endif } g_free(slidwin); tmp = tmp->next; } g_slist_free(window_list); window_list = NULL; } }
static void resize_window(GtkWidget *widget, guint width, guint height, gpointer data) { VteTerminal *terminal; if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) { gint owidth, oheight, char_width, char_height, column_count, row_count; GtkBorder padding; terminal = VTE_TERMINAL(widget); gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight); /* Take into account border overhead. */ char_width = vte_terminal_get_char_width (terminal); char_height = vte_terminal_get_char_height (terminal); column_count = vte_terminal_get_column_count (terminal); row_count = vte_terminal_get_row_count (terminal); gtk_style_context_get_padding(gtk_widget_get_style_context(widget), gtk_widget_get_state_flags(widget), &padding); owidth -= char_width * column_count + padding.left + padding.right; oheight -= char_height * row_count + padding.top + padding.bottom; gtk_window_resize(GTK_WINDOW(data), width + owidth, height + oheight); } }
static void adjust_font_size(GtkWidget *widget, gpointer data, gdouble factor) { VteTerminal *terminal; gdouble scale; glong char_width, char_height; gint columns, rows, owidth, oheight; /* Read the screen dimensions in cells. */ terminal = VTE_TERMINAL(widget); columns = vte_terminal_get_column_count(terminal); rows = vte_terminal_get_row_count(terminal); /* Take into account padding and border overhead. */ gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight); char_width = vte_terminal_get_char_width (terminal); char_height = vte_terminal_get_char_height (terminal); owidth -= char_width * columns; oheight -= char_height * rows; scale = vte_terminal_get_font_scale(terminal); vte_terminal_set_font_scale(terminal, scale * factor); /* This above call will have changed the char size! */ char_width = vte_terminal_get_char_width (terminal); char_height = vte_terminal_get_char_height (terminal); gtk_window_resize(GTK_WINDOW(data), columns * char_width + owidth, rows * char_height + oheight); }
static void shoes_app_gtk_paint (GtkWidget *widget, GdkEventExpose *event, gpointer data) { shoes_app *app = (shoes_app *)data; gtk_window_get_size(GTK_WINDOW(app->os.window), &app->width, &app->height); shoes_canvas_size(app->canvas, app->width, app->height); }
static void configuration_save(running_machine &machine, int config_type, xml_data_node *parentnode) { /* we only care about game files */ if (config_type != CONFIG_TYPE_GAME) return; // Loop over all the nodes for(win_i *p = win_list; p != NULL; p = p->next) { /* create a node */ xml_data_node *debugger_node; debugger_node = xml_add_child(parentnode, "window", NULL); xml_set_attribute_int(debugger_node, "type", p->type); if (debugger_node != NULL) { int x, y; gtk_window_get_position(GTK_WINDOW(p->win), &x, &y); xml_set_attribute_int(debugger_node, "position_x", x); xml_set_attribute_int(debugger_node, "position_y", y); gtk_window_get_size(GTK_WINDOW(p->win), &x, &y); xml_set_attribute_int(debugger_node, "size_x", x); xml_set_attribute_int(debugger_node, "size_y", y); } } }
ModelSelector::ModelSelector () : _widget(gtk_window_new(GTK_WINDOW_TOPLEVEL)), _treeStore(gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_PIXBUF)), _infoStore(gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING)), _lastModel(""), _lastSkin(-1) { // Window properties gtk_window_set_transient_for(GTK_WINDOW(_widget), GlobalRadiant().getMainWindow()); gtk_window_set_modal(GTK_WINDOW(_widget), TRUE); gtk_window_set_title(GTK_WINDOW(_widget), MODELSELECTOR_TITLE); gtk_window_set_position(GTK_WINDOW(_widget), GTK_WIN_POS_CENTER_ON_PARENT); // Set the default size of the window GtkWindow* mainWindow = GlobalRadiant().getMainWindow(); gint w; gint h; gtk_window_get_size(mainWindow,&w,&h); gtk_window_set_default_size(GTK_WINDOW(_widget), gint(w * 0.75), gint(h * 0.8)); // Create the model preview widget float previewHeightFactor = GlobalRegistry().getFloat("user/ui/ModelSelector/previewSizeFactor"); gint glSize = gint(h * previewHeightFactor); _modelPreview.setSize(glSize); // Signals g_signal_connect(G_OBJECT(_widget), "delete_event", G_CALLBACK(callbackHide), this); // Main window contains a VBox GtkWidget* vbx = gtk_vbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(vbx), createTreeView(), TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbx), createPreviewAndInfoPanel(), FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(vbx), createButtons(), FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(_widget), vbx); }
static void ol_scroll_window_begin_move_resize (GtkWidget *widget, GdkEventButton *event) { gint width, height; GtkWindow *window = GTK_WINDOW (widget); OlScrollWindowPrivate *priv = OL_SCROLL_WINDOW_GET_PRIVATE (widget); GdkWindowEdge edge; gtk_window_get_size (window, &width, &height); if (!_get_pointer_edge (event->x, event->y, width, height, priv->frame_width, priv->frame_width, priv->frame_width, priv->frame_width, &edge)) gtk_window_begin_move_drag (window, event->button, (gint)event->x_root, (gint)event->y_root, event->time); else gtk_window_begin_resize_drag (window, edge, event->button, (gint)event->x_root, (gint)event->y_root, event->time); }
void meta_fixed_tip_show (Display *xdisplay, int screen_number, int root_x, int root_y, const char *markup_text) { int w, h; if (tip == NULL) { tip = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_type_hint (GTK_WINDOW(tip), GDK_WINDOW_TYPE_HINT_TOOLTIP); { GdkScreen *gdk_screen; GdkRectangle monitor; gint mon_num; gdk_screen = gdk_display_get_screen (gdk_display_get_default (), screen_number); gtk_window_set_screen (GTK_WINDOW (tip), gdk_screen); mon_num = gdk_screen_get_monitor_at_point (gdk_screen, root_x, root_y); gdk_screen_get_monitor_geometry (gdk_screen, mon_num, &monitor); screen_right_edge = monitor.x + monitor.width; screen_bottom_edge = monitor.y + monitor.height; } gtk_widget_set_app_paintable (tip, TRUE); gtk_window_set_resizable (GTK_WINDOW (tip), FALSE); gtk_widget_set_name (tip, "gtk-tooltips"); gtk_container_set_border_width (GTK_CONTAINER (tip), 4); g_signal_connect_swapped (tip, "expose_event", G_CALLBACK (expose_handler), NULL); label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); gtk_widget_show (label); gtk_container_add (GTK_CONTAINER (tip), label); g_signal_connect (tip, "destroy", G_CALLBACK (gtk_widget_destroyed), &tip); } gtk_label_set_markup (GTK_LABEL (label), markup_text); gtk_window_get_size (GTK_WINDOW (tip), &w, &h); if (meta_ui_get_direction() == META_UI_DIRECTION_RTL) root_x = MAX(0, root_x - w); if ((root_x + w) > screen_right_edge) root_x -= (root_x + w) - screen_right_edge; gtk_window_move (GTK_WINDOW (tip), root_x, root_y); gtk_widget_show (tip); }
static gboolean dcc_configure_cb (GtkWindow *win, GdkEventConfigure *event, gpointer data) { /* remember the window size */ gtk_window_get_size (win, &win_width, &win_height); return FALSE; }
void iupdrvDialogGetSize(InativeHandle* handle, int *w, int *h) { int width, height; gtk_window_get_size((GtkWindow*)handle, &width, &height); if (w) *w = width; if (h) *h = height; }
void iupdrvDialogUpdateSize(Ihandle* ih) { int width, height; gtk_window_get_size((GtkWindow*)ih->handle, &width, &height); ih->currentwidth = width; ih->currentheight = height; }
void xmr_waiting_wnd_show(XmrWaitingWnd *wnd) { GdkWindow *gdk_window; gboolean is_iconify = TRUE; g_return_if_fail(wnd != NULL); if (g_slist_length(wnd->priv->tasks) == 0) { gtk_widget_hide(GTK_WIDGET(wnd)); return ; } if (wnd->priv->parent == NULL) { gtk_window_set_position(GTK_WINDOW(wnd), GTK_WIN_POS_CENTER); } else { gint px, py; gint pw, ph; gint x, y; gint w, h; gtk_window_get_position(wnd->priv->parent, &px, &py); gtk_window_get_size(wnd->priv->parent, &pw, &ph); gtk_window_get_size(GTK_WINDOW(wnd), &w, &h); x = px + (pw - w) / 2; y = py + (ph - h) / 2; gtk_window_move(GTK_WINDOW(wnd), x, y); } // only do this when parent visible gdk_window = gtk_widget_get_window(GTK_WIDGET(wnd->priv->parent)); is_iconify = gdk_window_get_state(gdk_window) & GDK_WINDOW_STATE_ICONIFIED; if (!is_iconify && gtk_widget_get_visible(GTK_WIDGET(wnd->priv->parent))) { gtk_widget_show(GTK_WIDGET(wnd)); gtk_widget_queue_draw(GTK_WIDGET(wnd)); } }
static void _resize_video_window(GtkWidget *video_window, MSVideoSize vsize){ MSVideoSize cur; gtk_window_get_size(GTK_WINDOW(video_window),&cur.width,&cur.height); if (vsize.width*vsize.height > cur.width*cur.height || ms_video_size_get_orientation(vsize)!=ms_video_size_get_orientation(cur) ){ gtk_window_resize(GTK_WINDOW(video_window),vsize.width,vsize.height); } }
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 fullyear_window_close_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) { GUI *appGUI = (GUI *) user_data; gtk_window_get_size (GTK_WINDOW (appGUI->cal->fullyear_window), &config.fy_window_size_x, &config.fy_window_size_y); gtk_widget_destroy (appGUI->cal->fullyear_window); }
static void hippo_window_gtk_get_size(HippoWindow *window, int *width_p, int *height_p) { HippoWindowGtk *window_gtk = HIPPO_WINDOW_GTK(window); gtk_window_get_size(GTK_WINDOW(window_gtk), width_p, height_p); }
static void hippo_window_wrapper_get_size(HippoWindow *window, int *width_p, int *height_p) { HippoWindowWrapper *wrapper = HIPPO_WINDOW_WRAPPER(window); gtk_window_get_size(GTK_WINDOW(wrapper->window), width_p, height_p); }
void cid_get_data () { /* On récupère la position de cid */ gtk_window_get_position(GTK_WINDOW (cid->pWindow), &cid->iPosX, &cid->iPosY); /* On récupère la taille de cid */ gtk_window_get_size(GTK_WINDOW (cid->pWindow), &cid->iWidth, &cid->iHeight); }
void save_config_file(void) //not called in gint main { FILE *fp; gchar *path; GtkItemFactory *ifactory; //GtkItemFactory ?? gint width, height; gchar *fontname; gboolean wordwrap, linenumbers, autoindent; gtk_window_get_size(GTK_WINDOW(pub->mw->window), &width, &height); fontname = get_font_name_from_widget(pub->mw->view); ifactory = gtk_item_factory_from_widget(pub->mw->menubar); wordwrap = gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(ifactory, "/Options/Word Wrap"))); linenumbers = gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(ifactory, "/Options/Line Numbers"))); autoindent = gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(ifactory, "/Options/Auto Indent"))); //saves the variables for conf file #if GLIB_CHECK_VERSION(2, 6, 0) path = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL); //fetches the address for conf and makes a dir for first if (!g_file_test(path, G_FILE_TEST_IS_DIR)) { //use if not present # if GLIB_CHECK_VERSION(2, 8, 0) g_mkdir_with_parents(path, 0700); # else g_mkdir(g_get_user_config_dir(), 0700); g_mkdir(path, 0700); # endif } g_free(path); path = g_build_filename(g_get_user_config_dir(), PACKAGE, PACKAGE "rc", NULL); #else path = g_build_filename(g_get_home_dir(), "." PACKAGE, NULL); #endif fp = fopen(path, "w"); if (!fp) { g_print("%s: can't save config file - %s\n", PACKAGE, path); return; } g_free(path); fprintf(fp, "%s\n", PACKAGE_VERSION); fprintf(fp, "%d\n", width); fprintf(fp, "%d\n", height); fprintf(fp, "%s\n", fontname); fprintf(fp, "%d\n", wordwrap); fprintf(fp, "%d\n", linenumbers); fprintf(fp, "%d\n", autoindent); fclose(fp); g_free(fontname); }
/** * \brief the initial resize of the warning needs to be done a little time * after the display of the dialog, so the actual size of the components * can be determined. Therefor this is done through a timed function. */ void auto_resize_warning_dialog () { #undef DEBUGFUNCTION #define DEBUGFUNCTION "auto_resize_warning_dialog()" GtkRequisition vp_size; int set_size = 0, orig_vp_size = 0; gint win_width = 0; gint win_height = 0; GtkWidget *vbox = NULL, *viewport = NULL, *eitem = NULL; GList *elist = NULL; int ind = 0, height = 0; GladeXML *xml = NULL; #ifdef DEBUG printf ("%s %s: Entering\n", DEBUGFILE, DEBUGFUNCTION); #endif // DEBUG g_assert (xvc_warn_main_window); xml = glade_get_widget_tree (GTK_WIDGET (xvc_warn_main_window)); vbox = glade_xml_get_widget (xml, "xvc_warn_errors_vbox"); g_assert (vbox); elist = gtk_container_get_children (GTK_CONTAINER (vbox)); eitem = g_list_nth_data (elist, 0); // the hack keeps getting uglier ... if (eitem->allocation.height > 1) { for (ind = 0; ind < g_list_length (elist); ind++) { eitem = g_list_nth_data (elist, ind); g_assert (eitem); height += (eitem->allocation.height + 1); } set_size = (height > 400 ? 400 : height); viewport = glade_xml_get_widget (xml, "xvc_warn_errors_viewport"); g_assert (viewport); gtk_widget_size_request (viewport, &vp_size); orig_vp_size = vp_size.height; gtk_widget_set_size_request (viewport, -1, set_size); gtk_widget_size_request (viewport, &vp_size); gtk_window_get_size (GTK_WINDOW (xvc_warn_main_window), &win_width, &win_height); gtk_window_resize (GTK_WINDOW (xvc_warn_main_window), win_width, win_height - (orig_vp_size - vp_size.height) + 1); g_source_remove (scheduled_warning_resize_id); } #ifdef DEBUG printf ("%s %s: Leaving\n", DEBUGFILE, DEBUGFUNCTION); #endif // DEBUG }
void cid_get_data (CidMainContainer **pCid) { CidMainContainer *cid = *pCid; /* On récupère la position de cid */ gtk_window_get_position(GTK_WINDOW (cid->pWindow), &cid->config->iPosX, &cid->config->iPosY); /* On récupère la taille de cid */ gtk_window_get_size(GTK_WINDOW (cid->pWindow), &cid->config->iWidth, &cid->config->iHeight); }
static char* gtkDialogGetClientSizeAttrib(Ihandle *ih) { int width, height; gtk_window_get_size((GtkWindow*)ih->handle, &width, &height); /* remove the menu because it is placed inside the client area */ height -= gtkDialogGetMenuSize(ih); return iupStrReturnIntInt(width, height, 'x'); }
int aifp_window_close(GtkWidget * widget, gpointer * data) { aifp_close_device(); gtk_window_get_size(GTK_WINDOW(aifp_window), &options.ifpmanager_size_x, &options.ifpmanager_size_y); gtk_widget_destroy(aifp_window); aifp_window = NULL; return 0; }
void birthdays_window_close_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data) { GUI *appGUI = (GUI *) user_data; gtk_window_get_size (GTK_WINDOW(appGUI->cnt->birthdays_window), &config.contacts_birthdays_win_w, &config.contacts_birthdays_win_h); gtk_widget_destroy (appGUI->cnt->birthdays_window); }
static void gui_get_widget_size(GtkWidget* window, gint* width, gint* height) { if(GTK_IS_WINDOW(window)) { gtk_window_get_size(GTK_WINDOW(window), width, height); } else { GtkRequisition requisition; gtk_widget_size_request(window, &requisition); *width = requisition.width; *height = requisition.height; } }