Use new interface to obtain available screen space
* Use scr_gettext* to detect available screen space
* Use new module structs with api
--- a/CMakeLists.txt Thu Mar 04 19:50:02 2010 +0200
+++ b/CMakeLists.txt Sun Mar 14 21:27:23 2010 +0200
@@ -16,6 +16,7 @@
cmake_minimum_required(VERSION 2.6)
project(avatar C)
+set(PROJECT_VERSION "0.0.1")
## User settable options
@@ -65,7 +66,7 @@
## Packaging information
set(CPACK_PACKAGE_NAME libmcabber-avatar)
-set(CPACK_PACKAGE_VERSION "0.0.1")
+set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "IsBear")
set(CPACK_PACKAGE_CONTACT "Myhailo Danylenko <isbear@ukrpost.net>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mcabber module for PEP avatar events handling")
--- a/avatar.c Thu Mar 04 19:50:02 2010 +0200
+++ b/avatar.c Sun Mar 14 21:27:23 2010 +0200
@@ -52,12 +52,32 @@
static void avatar_init (void);
static void avatar_uninit (void);
+#define DESCRIPTION ( \
+ "PEP avatars handling\n" \
+ "Recognizes options avatar_directory, avatar_font_height, avatar_font_width, avatar_max_height, avatar_max_width and avatar_background\n" \
+ "Provides command /avatar" )
static const gchar *deps[] = { "pep", NULL };
+
+static module_info_t info_avatar_experimental = {
+ .branch = "experimental",
+ .api = 5,
+ .version = PROJECT_VERSION,
+ .description = DESCRIPTION,
+ .requires = deps,
+ .init = avatar_init,
+ .uninit = avatar_uninit,
+ .next = NULL,
+};
+
module_info_t info_avatar = {
- .mcabber_version = "0.10.0",
- .requires = deps,
- .init = avatar_init,
- .uninit = avatar_uninit,
+ .branch = "dev",
+ .api = 4,
+ .version = PROJECT_VERSION,
+ .description = DESCRIPTION,
+ .requires = deps,
+ .init = avatar_init,
+ .uninit = avatar_uninit,
+ .next = &info_avatar_experimental,
};
// globals
@@ -651,28 +671,12 @@
int fonth = settings_opt_get_int ("avatar_font_height");
int fontw = settings_opt_get_int ("avatar_font_width");
- // if not set explicitly, try to calculate available space
- if (!maxcharh) {
- char *var = getenv ("LINES");
-
- if (var)
- maxcharh = atoi (var);
- else
- maxcharh = 25;
+ // if not set explicitly, calculate available space
+ if (!maxcharh)
+ maxcharh = scr_gettextheight() - 1; // -1 due to avatar header line
- maxcharh -= settings_opt_get_int ("log_win_height") + 3 + 1; // +1 due to avatar header line
- }
-
- if (!maxcharw) {
- char *var = getenv ("COLUMNS");
-
- if (var)
- maxcharw = atoi (var);
- else
- maxcharw = 80;
-
- maxcharw -= settings_opt_get_int ("roster_width") + scr_getprefixwidth ();
- }
+ if (!maxcharw)
+ maxcharw = scr_gettextwidth();
if (!fonth)
fonth = 16;
--- a/avatar.rc Thu Mar 04 19:50:02 2010 +0200
+++ b/avatar.rc Sun Mar 14 21:27:23 2010 +0200
@@ -17,8 +17,8 @@
# will be autodetected based on COLUMNS and LINES variables (they
# must exist in mcabber's environment, i.e. you should export them
# or you will be limited to 80x25).
-set avatar_max_width = 110
-set avatar_max_height = 40
+#set avatar_max_width = 110
+#set avatar_max_height = 40
# Background color to use for transparent images.
# In fact in range 0..65535, but looks like actually matter only
--- a/config.h.in Thu Mar 04 19:50:02 2010 +0200
+++ b/config.h.in Sun Mar 14 21:27:23 2010 +0200
@@ -4,5 +4,7 @@
#cmakedefine HAVE_LM_CONNECTION_UNREGISTER_REPLY_HANDLER
+#define PROJECT_VERSION ( "${PROJECT_VERSION}" )
+
#endif