1 /* 2 * Copyright (C) 2008-2010 Nick Schermer <nick@xfce.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 #ifndef __PANEL_PRIVATE_H__ 20 #define __PANEL_PRIVATE_H__ 21 22 /* support macros for debugging (improved macro for better position indication) */ 23 /*#ifndef NDEBUG*/ 24 #define panel_assert(expr) g_assert (expr) 25 #define panel_assert_not_reached() g_assert_not_reached () 26 #define panel_return_if_fail(expr) G_STMT_START { \ 27 if (G_UNLIKELY (!(expr))) \ 28 { \ 29 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ 30 "%s (%s): expression '%s' failed.", G_STRLOC, G_STRFUNC, \ 31 #expr); \ 32 return; \ 33 }; }G_STMT_END 34 #define panel_return_val_if_fail(expr,val) G_STMT_START { \ 35 if (G_UNLIKELY (!(expr))) \ 36 { \ 37 g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ 38 "%s (%s): expression '%s' failed.", G_STRLOC, G_STRFUNC, \ 39 #expr); \ 40 return (val); \ 41 }; }G_STMT_END 42 /*#else 43 #define panel_assert(expr) G_STMT_START{ (void)0; }G_STMT_END 44 #define panel_assert_not_reached() G_STMT_START{ (void)0; }G_STMT_END 45 #define panel_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END 46 #define panel_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END 47 #endif*/ 48 49 /* handling flags */ 50 #define PANEL_SET_FLAG(flags,flag) G_STMT_START{ ((flags) |= (flag)); }G_STMT_END 51 #define PANEL_UNSET_FLAG(flags,flag) G_STMT_START{ ((flags) &= ~(flag)); }G_STMT_END 52 #define PANEL_HAS_FLAG(flags,flag) (((flags) & (flag)) != 0) 53 54 /* relative path to the plugin directory */ 55 #define PANEL_PLUGIN_RELATIVE_PATH "xfce4" G_DIR_SEPARATOR_S "panel" 56 57 /* relative plugin's rc filename (printf format) */ 58 #define PANEL_PLUGIN_RC_RELATIVE_PATH PANEL_PLUGIN_RELATIVE_PATH G_DIR_SEPARATOR_S "%s-%d.rc" 59 60 /* xfconf property base (printf format) */ 61 #define PANEL_PLUGIN_PROPERTY_BASE "/plugins/plugin-%d" 62 63 /* minimum time in seconds between automatic restarts of panel plugins 64 * without asking the user what to do */ 65 #define PANEL_PLUGIN_AUTO_RESTART (60) 66 67 /* integer swap functions */ 68 #define SWAP_INTEGER(a,b) G_STMT_START { gint swp = a; a = b; b = swp; } G_STMT_END 69 #define TRANSPOSE_AREA(area) G_STMT_START { SWAP_INTEGER (area.width, area.height); \ 70 SWAP_INTEGER (area.x, area.y); } G_STMT_END 71 72 /* to avoid exo for gtk3 testing */ 73 #define panel_str_is_empty(string) ((string) == NULL || *(string) == '\0') 74 75 /* quick GList and GSList counting without traversing */ 76 #define LIST_HAS_ONE_ENTRY(l) ((l) != NULL && (l)->next == NULL) 77 #define LIST_HAS_ONE_OR_NO_ENTRIES(l) ((l) == NULL || (l)->next == NULL) 78 #define LIST_HAS_TWO_OR_MORE_ENTRIES(l) ((l) != NULL && (l)->next != NULL) 79 80 /* make this easier to read */ 81 #define PANEL_GDKCOLOR_TO_DOUBLE(gdk_color) gdk_color->red / 65535.00, \ 82 gdk_color->green / 65535.00, \ 83 gdk_color->blue / 65535.00 84 85 #endif /* !__PANEL_PRIVATE_H__ */ 86