Re: Checking HOSTNAME in an ipelet

Otfried Cheong <[email protected]>
Newsgroups gmane.comp.graphics.ipe.general
Organization Ipe Headquarters
Message-ID <[email protected]>
On 11/09/2010 01:59 PM, Otfried Cheong wrote:
> I guess Ipe could provide the screen geometry to the lua environment,
> then you wouldn't have to play such tricks.

Here is a patch for src/ipe/main.cpp, which sets config.screen_geometry.

So you can get the screen width in an ipelet using _G.config.screen_width.

This will be in the next release.

Cheers,
  Otfried

_______________________________________________
Ipe-discuss mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/ipe-discuss
patch.txt (text/plain, 705 B)
Index: main.cpp
===================================================================
--- main.cpp	(revision 440)
+++ main.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include <QApplication>
 #include <QLocale>
 #include <QDir>
+#include <QDesktopWidget>
 
 extern int luaopen_ipeui(lua_State *L);
 extern int luaopen_appui(lua_State *L);
@@ -132,6 +133,14 @@
 		  IPELIB_VERSION % 100);
   lua_setfield(L, -2, "version");
 
+  QRect r = a.desktop()->screenGeometry();
+  lua_createtable(L, 0, 2);
+  lua_pushinteger(L, r.width());
+  lua_rawseti(L, -2, 1);
+  lua_pushinteger(L, r.height());
+  lua_rawseti(L, -2, 2);
+  lua_setfield(L, -2, "screen_geometry");
+
   lua_setglobal(L, "config");
   
   // run Ipe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.