Skip to main content

Thread: Net-book Zoom


this morning wrote simple little program in freebasic zoom-out display of net-book (running unr) when need access controls on dialog box big tiny display.

think utility (written in main stream programming language) should included in net-book releases.

full source code except icon. or can lot web site. weekendcode

garvan

code:
''gnu 2 or later #include once "gtk/gtk.bi" #include once "vbcompat.bi" #include once "nr_res.bi"		'' icon resource #define null 0   type globaldata 	connected string 	currentzoom double end type  dim shared gd globaldata  declare function menuitem_zoom_out cdecl(byval widget gtkwidget ptr, byval event gdkevent, _ 		byval user_data gpointer) integer declare function menuitem_zoom_100 cdecl(byval widget gtkwidget ptr, byval event gdkevent, _ 		byval user_data gpointer) integer declare function menuitem_zoom_in cdecl(byval widget gtkwidget ptr, byval event gdkevent, _ 		byval user_data gpointer) integer declare function init() integer  ''------------------------------------------------------------------------------ '' '' function:	main() '' ''------------------------------------------------------------------------------  	dim gtkwidget ptr win 	dim gtkwidget ptr vbox1 	dim gtktoolbar ptr zoom_tools 	dim gdkpixbuf ptr pixbuf 	 	'' initialize gtk 	gtk_init( null, null )  	'' create window 	win = gtk_window_new( gtk_window_toplevel ) 	gtk_window_set_title( gtk_window(win), "zoom netbook" ) 	gtk_window_set_policy (gtk_window (win), false, false, true)   ''fixed border 	gtk_window_set_position(gtk_window(win), gtk_win_pos_center_always) 	 	pixbuf = gdk_pixbuf_new_from_xpm_data(@xpm_icon(0)) 	if pixbuf <> null gtk_window_set_icon(gtk_window(win), pixbuf) 	 	'' create vertical box (vbox) 10 pixel border 	vbox1 = gtk_vbox_new (false, 10) 	 	'' rest of gui 	gtk_container_set_border_width (gtk_container (vbox1), 10)  	''snd toolbar 	zoom_tools = g_object_new(gtk_type_toolbar, null) 	gtk_toolbar_set_style(gtk_toolbar (zoom_tools ), gtk_toolbar_icons) 	gtk_container_set_border_width (gtk_container (zoom_tools), 10) 	gtk_toolbar_insert_stock(zoom_tools, gtk_stock_zoom_out, "zoom out", null, _ 		gtk_signal_func (@menuitem_zoom_out), null, -1) 	gtk_toolbar_insert_stock(zoom_tools, gtk_stock_zoom_100, "zoom 1:1", null, _ 		gtk_signal_func (@menuitem_zoom_100), null, -1) 	gtk_toolbar_insert_stock(zoom_tools, gtk_stock_zoom_in, "zoom in", null, _ 		gtk_signal_func (@menuitem_zoom_in), null, -1) 	gtk_toolbar_insert_stock(zoom_tools, gtk_stock_quit, "quit", null, _ 		g_callback (@gtk_main_quit), null, -1)   	gtk_container_add (gtk_container (vbox1), gtk_widget(zoom_tools)) 	  	gtk_container_add( gtk_container(win), vbox1 ) 	 	'' attach signals widgets 	g_signal_connect (g_object (win), "destroy", g_callback (@gtk_main_quit), null) 	g_signal_connect (g_object (win), "delete_event", g_callback (@gtk_main_quit), null) 	 	'' show gui 	gtk_widget_show_all( win ) 	'' 	if init() = false print "call xrandr failed" 	 	' enter event loop 	gtk_main ()   '' purpose:		zoom out function menuitem_zoom_out cdecl(byval widget gtkwidget ptr, byval event gdkevent, _ 		byval user_data gpointer) integer 	if gd.connected = "" return 0 	gd.currentzoom *= 1.1 	return exec("xrandr", "--output " & gd.connected & " --scale " & str(gd.currentzoom) & "x" & str(gd.currentzoom)) end function  '' purpose:		zoom 100 function menuitem_zoom_100 cdecl(byval widget gtkwidget ptr, byval event gdkevent, _ 		byval user_data gpointer) integer 	if gd.connected = "" return 0 	gd.currentzoom = 1 	return exec("xrandr", "--output " & gd.connected & " --scale 1.0x1.0") end function  '' purpose:		zoom in function menuitem_zoom_in cdecl(byval widget gtkwidget ptr, byval event gdkevent, _ 		byval user_data gpointer) integer 	if gd.connected = "" return 0 	gd.currentzoom /= 1.1 	return exec("xrandr", "--output " & gd.connected & " --scale " & str(gd.currentzoom) & "x" & str(gd.currentzoom)) end function  '' make sure can find connected video name  function init() integer 	dim integer f1 	dim string ln, vid 	 	gd.currentzoom = 1 	 	f1 = freefile 	if (open pipe("xrandr -q", input, #f1)) 		print "couldn't run xrandr" 		return 0 	end if  	do until (eof(f1)) 		line input #f1, ln 		if (len(ln) > 0) 			if instr(ln, " connected") 				vid = left(ln, instr(ln, " connected")-1) 				if len(vid) gd.connected = vid 			end if 		end if 	loop 	close #f1  	if len(vid) return true else return false end function



Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Net-book Zoom


Ubuntu

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support