From ba28af93d46f267d3c1ca386a7697a4cc061c3b6 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Sun, 23 Dec 2012 09:15:10 +0100 Subject: [PATCH] changes needed to make it compile, remove some win32 stuff --- src/common/cfgfiles.c | 80 -------- src/common/identd.c | 89 --------- src/common/network.c | 2 - src/common/outbound.c | 15 -- src/common/ssl.c | 4 - src/common/util.c | 10 - src/common/xchat.h | 64 +----- src/fe-gtk/{chanview-tabs.c => chanview-tabs.h} | 0 src/fe-gtk/{chanview-tree.c => chanview-tree.h} | 0 src/fe-gtk/chanview.c | 4 +- src/fe-gtk/custom-list.c | 2 +- src/fe-gtk/custom-list.h | 1 + src/fe-gtk/fe-gtk.c | 95 +-------- src/fe-gtk/fe-gtk.h | 29 +-- src/fe-gtk/xtext.c | 246 +----------------------- src/fe-text/fe-text.c | 6 - src/{common => }/make-te.c | 0 17 files changed, 19 insertions(+), 628 deletions(-) delete mode 100644 src/common/identd.c rename src/fe-gtk/{chanview-tabs.c => chanview-tabs.h} (100%) rename src/fe-gtk/{chanview-tree.c => chanview-tree.h} (100%) rename src/{common => }/make-te.c (100%) diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 83f50e3..57a4e35 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -31,11 +31,7 @@ #include "text.h" #include "xchatc.h" -#ifdef WIN32 -#define XCHAT_DIR "X-Chat 2" -#else #define XCHAT_DIR ".xchat2" -#endif #define DEF_FONT "Monospace 9" void @@ -276,50 +272,6 @@ cfg_get_int (char *cfg, char *var) char *xdir_fs = NULL; /* file system encoding */ char *xdir_utf = NULL; /* utf-8 encoding */ -#ifdef WIN32 - -#include - -static gboolean -get_reg_str (const char *sub, const char *name, char *out, DWORD len) -{ - HKEY hKey; - DWORD t; - - if (RegOpenKeyEx (HKEY_CURRENT_USER, sub, 0, KEY_READ, &hKey) == - ERROR_SUCCESS) - { - if (RegQueryValueEx (hKey, name, NULL, &t, out, &len) != ERROR_SUCCESS || - t != REG_SZ) - { - RegCloseKey (hKey); - return FALSE; - } - out[len-1] = 0; - RegCloseKey (hKey); - return TRUE; - } - - return FALSE; -} - -char * -get_xdir_fs (void) -{ - if (!xdir_fs) - { - char out[256]; - - if (!get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\" - "Explorer\\Shell Folders", "AppData", out, sizeof (out))) - return "./config"; - xdir_fs = g_strdup_printf ("%s\\" XCHAT_DIR, out); - } - return xdir_fs; -} - -#else - char * get_xdir_fs (void) { @@ -329,8 +281,6 @@ get_xdir_fs (void) return xdir_fs; } -#endif /* !WIN32 */ - char * get_xdir_utf8 (void) { @@ -346,11 +296,7 @@ check_prefs_dir (void) char *dir = get_xdir_fs (); if (access (dir, F_OK) != 0) { -#ifdef WIN32 - if (mkdir (dir) != 0) -#else if (mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR) != 0) -#endif fe_message (_("Cannot create ~/.xchat2"), FE_MSG_ERROR); } } @@ -459,9 +405,6 @@ const struct prefs vars[] = { {"gui_win_top", P_OFFINT (mainwindow_top), TYPE_INT}, {"gui_win_width", P_OFFINT (mainwindow_width), TYPE_INT}, -#ifdef WIN32 - {"identd", P_OFFINT (identd), TYPE_BOOL}, -#endif {"input_balloon_chans", P_OFFINT (input_balloon_chans), TYPE_BOOL}, {"input_balloon_hilight", P_OFFINT (input_balloon_hilight), TYPE_BOOL}, {"input_balloon_priv", P_OFFINT (input_balloon_priv), TYPE_BOOL}, @@ -684,9 +627,6 @@ load_config (void) prefs.autodccsend = 2; /* browse mode */ prefs.url_grabber = 1; prefs.url_grabber_limit = 0; /* 0 means unlimited for backcompat */ -#ifdef WIN32 - prefs.identd = 1; -#endif strcpy (prefs.stamp_format, "[%H:%M] "); strcpy (prefs.timestamp_log_format, "%b %d %H:%M:%S "); strcpy (prefs.logmask, "%n-%c.log"); @@ -699,21 +639,8 @@ load_config (void) strcat (prefs.nick3, "__"); strcpy (prefs.realname, realname); strcpy (prefs.username, username); -#ifdef WIN32 - strcpy (prefs.sounddir, "./sounds"); - { - char out[256]; - - if (get_reg_str ("Software\\Microsoft\\Windows\\CurrentVersion\\" - "Explorer\\Shell Folders", "Personal", out, sizeof (out))) - snprintf (prefs.dccdir, sizeof (prefs.dccdir), "%s\\Downloads", out); - else - snprintf (prefs.dccdir, sizeof (prefs.dccdir), "%s\\Downloads", get_xdir_utf8 ()); - } -#else snprintf (prefs.sounddir, sizeof (prefs.sounddir), "%s/sounds", get_xdir_utf8 ()); snprintf (prefs.dccdir, sizeof (prefs.dccdir), "%s/downloads", get_xdir_utf8 ()); -#endif strcpy (prefs.doubleclickuser, "QUOTE WHOIS %s %s"); strcpy (prefs.awayreason, _("I'm busy")); strcpy (prefs.quitreason, _("Leaving")); @@ -759,14 +686,10 @@ load_config (void) } else { -#ifndef WIN32 -#ifndef __EMX__ /* OS/2 uses UID 0 all the time */ if (getuid () == 0) fe_message (_("* Running IRC as root is stupid! You should\n" " create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT); -#endif -#endif /* !WIN32 */ mkdir_utf8 (prefs.dccdir); mkdir_utf8 (prefs.dcc_completed_dir); @@ -876,9 +799,6 @@ save_config (void) return 0; } -#ifdef WIN32 - unlink (config); /* win32 can't rename to an existing file */ -#endif if (rename (new_config, config) == -1) { free (new_config); diff --git a/src/common/identd.c b/src/common/identd.c deleted file mode 100644 index 919282e..0000000 --- a/src/common/identd.c +++ /dev/null @@ -1,89 +0,0 @@ -/* simple identd server for xchat under win32 */ - - -static int identd_is_running = FALSE; - - -static int -identd (char *username) -{ - int sok, read_sok, len; - char *p; - char buf[256]; - char outbuf[256]; - struct sockaddr_in addr; - - sok = socket (AF_INET, SOCK_STREAM, 0); - if (sok == INVALID_SOCKET) - { - free (username); - return 0; - } - - len = 1; - setsockopt (sok, SOL_SOCKET, SO_REUSEADDR, (char *) &len, sizeof (len)); - - memset (&addr, 0, sizeof (addr)); - addr.sin_family = AF_INET; - addr.sin_port = htons (113); - - if (bind (sok, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR) - { - closesocket (sok); - free (username); - return 0; - } - - if (listen (sok, 1) == SOCKET_ERROR) - { - closesocket (sok); - free (username); - return 0; - } - - len = sizeof (addr); - read_sok = accept (sok, (struct sockaddr *) &addr, &len); - closesocket (sok); - if (read_sok == INVALID_SOCKET) - { - free (username); - return 0; - } - - identd_is_running = FALSE; - - snprintf (outbuf, sizeof (outbuf), "%%\tServicing ident request from %s\n", - inet_ntoa (addr.sin_addr)); - PrintText (current_sess, outbuf); - - recv (read_sok, buf, sizeof (buf) - 1, 0); - buf[sizeof (buf) - 1] = 0; /* ensure null termination */ - - p = strchr (buf, ','); - if (p) - { - snprintf (outbuf, sizeof (outbuf) - 1, "%d, %d : USERID : UNIX : %s\r\n", - atoi (buf), atoi (p + 1), username); - outbuf[sizeof (outbuf) - 1] = 0; /* ensure null termination */ - send (read_sok, outbuf, strlen (outbuf), 0); - } - - sleep (1); - closesocket (read_sok); - free (username); - - return 0; -} - -static void -identd_start (char *username) -{ - DWORD tid; - - if (identd_is_running == FALSE) - { - identd_is_running = TRUE; - CloseHandle (CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) identd, - strdup (username), 0, &tid)); - } -} diff --git a/src/common/network.c b/src/common/network.c index 0c40950..0def866 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -24,8 +24,6 @@ #include #include -#include "../../config.h" /* grab USE_IPV6 and LOOKUPD defines */ - #define WANTSOCKET #define WANTARPA #define WANTDNS diff --git a/src/common/outbound.c b/src/common/outbound.c index 6326924..1c545b4 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -28,9 +28,7 @@ #define WANTARPA #include "inet.h" -#ifndef WIN32 #include -#endif #include #include @@ -1647,19 +1645,6 @@ norm: nbuf[j] = buf[i]; free (nbuf); } -#ifndef HAVE_MEMRCHR -static void * -memrchr (const void *block, int c, size_t size) -{ - unsigned char *p; - - for (p = (unsigned char *)block + size; p != block; p--) - if (*p == c) - return p; - return 0; -} -#endif - static gboolean exec_data (GIOChannel *source, GIOCondition condition, struct nbexec *s) { diff --git a/src/common/ssl.c b/src/common/ssl.c index a18ad47..65cb5c4 100644 --- a/src/common/ssl.c +++ b/src/common/ssl.c @@ -23,11 +23,7 @@ #include /* strncpy() */ #include "ssl.h" /* struct cert_info */ #include "inet.h" -#include "../../config.h" /* HAVE_SNPRINTF */ -#ifndef HAVE_SNPRINTF -#define snprintf g_snprintf -#endif /* globals */ static struct chiper_info chiper_info; /* static buffer for _SSL_get_cipher_info() */ diff --git a/src/common/util.c b/src/common/util.c index 5a0ab6c..220613b 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -25,15 +25,10 @@ #include #include #include -#ifdef WIN32 -#include -#include -#else #include #include #include #include -#endif #include #include #include @@ -42,7 +37,6 @@ #include #include #include "util.h" -#include "../../config.h" #define WANTSOCKET #include "inet.h" @@ -54,10 +48,6 @@ #include #endif -#ifndef HAVE_SNPRINTF -#define snprintf g_snprintf -#endif - #ifdef USE_DEBUG #undef free diff --git a/src/common/xchat.h b/src/common/xchat.h index 3a5af0e..3ba3d69 100644 --- a/src/common/xchat.h +++ b/src/common/xchat.h @@ -1,20 +1,14 @@ -#include "../../config.h" +#ifndef XCHAT_H +#define XCHAT_H #include #include /* need time_t */ -#ifndef XCHAT_H -#define XCHAT_H - +#include "version.h" #include "history.h" -#ifndef HAVE_SNPRINTF -#define snprintf g_snprintf -#endif - -#ifndef HAVE_VSNPRINTF -#define vsnprintf g_vsnprintf -#endif +#define N_(String) (String) +#define _(x) (x) #ifdef USE_DEBUG #define malloc(n) xchat_malloc(n, __FILE__, __LINE__) @@ -27,46 +21,14 @@ void xchat_dfree (void *buf, char *file, int line); void *xchat_realloc (char *old, int len, char *file, int line); #endif -#ifdef SOCKS -#ifdef __sgi -#include -#define INCLUDE_PROTOTYPES 1 -#endif -#include -#endif - -#ifdef USE_OPENSSL #include /* SSL_() */ -#endif - -#ifdef __EMX__ /* for o/s 2 */ -#define OFLAGS O_BINARY -#define strcasecmp stricmp -#define strncasecmp strnicmp -#define PATH_MAX MAXPATHLEN -#define FILEPATH_LEN_MAX MAXPATHLEN -#endif /* force a 32bit CMP.L */ #define CMPL(a, c0, c1, c2, c3) (a == (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))) #define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24)) #define WORDW(c0, c1) (guint16)(c0 | (c1 << 8)) -#ifdef WIN32 /* for win32 */ -#define OFLAGS O_BINARY -#define sleep(t) _sleep(t*1000) -#include -#define F_OK 0 -#define X_OK 1 -#define W_OK 2 -#define R_OK 4 -#ifndef S_ISDIR -#define S_ISDIR(m) ((m) & _S_IFDIR) -#endif -#define NETWORK_PRIVATE -#else /* for unix */ #define OFLAGS 0 -#endif #define FONTNAMELEN 127 #define PATHLEN 255 @@ -77,20 +39,6 @@ void *xchat_realloc (char *old, int len, char *file, int line); #define USERNAMELEN 10 #define HIDDEN_CHAR 8 /* invisible character for xtext */ -#if defined(ENABLE_NLS) && !defined(_) -# include -# define _(x) gettext(x) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#endif -#if !defined(_) -# define N_(String) (String) -# define _(x) (x) -#endif - struct nbexec { int myfd; @@ -524,10 +472,8 @@ typedef struct server unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */ unsigned int using_irc:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */ unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */ -#ifdef USE_OPENSSL unsigned int use_ssl:1; /* is server SSL capable? */ unsigned int accept_invalid_cert:1;/* ignore result of server's cert. verify */ -#endif } server; typedef int (*cmd_callback) (struct session * sess, char *tbuf, char *word[], diff --git a/src/fe-gtk/chanview-tabs.c b/src/fe-gtk/chanview-tabs.h similarity index 100% rename from src/fe-gtk/chanview-tabs.c rename to src/fe-gtk/chanview-tabs.h diff --git a/src/fe-gtk/chanview-tree.c b/src/fe-gtk/chanview-tree.h similarity index 100% rename from src/fe-gtk/chanview-tree.c rename to src/fe-gtk/chanview-tree.h diff --git a/src/fe-gtk/chanview.c b/src/fe-gtk/chanview.c index e90c4df..03c409f 100644 --- a/src/fe-gtk/chanview.c +++ b/src/fe-gtk/chanview.c @@ -74,12 +74,12 @@ static int cv_find_number_of_chan (chanview *cv, chan *find_ch); /* ======= TABS ======= */ -#include "chanview-tabs.c" +#include "chanview-tabs.h" /* ======= TREE ======= */ -#include "chanview-tree.c" +#include "chanview-tree.h" /* ==== ABSTRACT CHANVIEW ==== */ diff --git a/src/fe-gtk/custom-list.c b/src/fe-gtk/custom-list.c index ac20e0f..0c3c40b 100644 --- a/src/fe-gtk/custom-list.c +++ b/src/fe-gtk/custom-list.c @@ -106,7 +106,7 @@ custom_list_sortable_init (GtkTreeSortableIface * iface) * *****************************************************************************/ -static GType +GType custom_list_get_type (void) { static GType custom_list_type = 0; diff --git a/src/fe-gtk/custom-list.h b/src/fe-gtk/custom-list.h index d9e4f09..b0bd5a4 100644 --- a/src/fe-gtk/custom-list.h +++ b/src/fe-gtk/custom-list.h @@ -81,5 +81,6 @@ CustomList *custom_list_new (void); void custom_list_append (CustomList *, chanlistrow *); void custom_list_resort (CustomList *); void custom_list_clear (CustomList *); +GType custom_list_get_type (void); #endif /* _custom_list_h_included_ */ diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index f81e8cb..9a78bb3 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -142,14 +142,8 @@ fe_args (int argc, char *argv[]) GError *error = NULL; GOptionContext *context; -#ifdef ENABLE_NLS - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); -#endif - context = g_option_context_new (NULL); - g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE); + //g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (FALSE)); g_option_context_parse (context, &argc, &argv, &error); @@ -170,18 +164,7 @@ fe_args (int argc, char *argv[]) if (arg_show_autoload) { -#ifdef WIN32 - /* see the chdir() below */ - char *sl, *exe = strdup (argv[0]); - sl = strrchr (exe, '\\'); - if (sl) - { - *sl = 0; - printf ("%s\\plugins\n", exe); - } -#else printf ("%s\n", XCHATLIBDIR"/plugins"); -#endif return 0; } @@ -191,25 +174,6 @@ fe_args (int argc, char *argv[]) return 0; } -#ifdef WIN32 - /* this is mainly for irc:// URL handling. When windows calls us from */ - /* I.E, it doesn't give an option of "Start in" directory, like short */ - /* cuts can. So we have to set the current dir manually, to the path */ - /* of the exe. */ - { - char *tmp = strdup (argv[0]); - char *sl; - - sl = strrchr (tmp, '\\'); - if (sl) - { - *sl = 0; - chdir (tmp); - } - free (tmp); - } -#endif - if (arg_cfgdir) /* we want filesystem encoding */ { xdir_fs = strdup (arg_cfgdir); @@ -320,30 +284,6 @@ fe_timeout_remove (int tag) g_source_remove (tag); } -#ifdef WIN32 - -static void -log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer unused_data) -{ - session *sess; - - if (getenv ("XCHAT_WARNING_IGNORE")) - return; - - sess = find_dialog (serv_list->data, "(warnings)"); - if (!sess) - sess = new_ircwindow (serv_list->data, "(warnings)", SESS_DIALOG, 0); - - PrintTextf (sess, "%s\t%s\n", log_domain, message); - if (getenv ("XCHAT_WARNING_ABORT")) - abort (); -} - -#endif - /* install tray stuff */ static int @@ -378,13 +318,6 @@ fe_new_window (session *sess, int focus) mg_changui_new (sess, NULL, tab, focus); -#ifdef WIN32 - g_log_set_handler ("GLib", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING, (GLogFunc)log_handler, 0); - g_log_set_handler ("GLib-GObject", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING, (GLogFunc)log_handler, 0); - g_log_set_handler ("Gdk", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING, (GLogFunc)log_handler, 0); - g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING, (GLogFunc)log_handler, 0); -#endif - if (!sess_list->next) g_idle_add (fe_idle, NULL); } @@ -439,14 +372,7 @@ fe_input_add (int sok, int flags, void *func, void *data) int tag, type = 0; GIOChannel *channel; -#ifdef WIN32 - if (flags & FIA_FD) - channel = g_io_channel_win32_new_fd (sok); - else - channel = g_io_channel_win32_new_socket (sok); -#else channel = g_io_channel_unix_new (sok); -#endif if (flags & FIA_READ) type |= G_IO_IN | G_IO_HUP | G_IO_ERR; @@ -625,9 +551,7 @@ lastlog_regex_cmp (char *a, regex_t *reg) void fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gboolean regexp) { -#ifndef WIN32 regex_t reg; -#endif if (gtk_xtext_is_empty (sess->res->buffer)) { @@ -642,14 +566,12 @@ fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gboolean regexp) return; } -#ifndef WIN32 if (regcomp (®, sstr, REG_ICASE | REG_EXTENDED | REG_NOSUB) == 0) { gtk_xtext_lastlog (lastlog_sess->res->buffer, sess->res->buffer, (void *) lastlog_regex_cmp, ®); regfree (®); } -#endif } void @@ -839,13 +761,8 @@ fe_gui_info_ptr (session *sess, int info_type) switch (info_type) { case 0: /* native window pointer (for plugins) */ -#ifdef WIN32 - return GDK_WINDOW_HWND (sess->gui->window->window); -#else return sess->gui->window; -#endif break; - case 1: /* GtkWindow * (for plugins) */ return sess->gui->window; } @@ -902,8 +819,6 @@ fe_set_inputbox_contents (session *sess, char *text) } } -#ifndef WIN32 - static gboolean try_browser (const char *browser, const char *arg, const char *url) { @@ -928,14 +843,9 @@ try_browser (const char *browser, const char *arg, const char *url) return 1; } -#endif - static void fe_open_url_inner (const char *url) { -#ifdef WIN32 - ShellExecute (0, "open", url, NULL, NULL, SW_SHOWNORMAL); -#else /* universal desktop URL opener (from xdg-utils). Supports gnome,kde,xfce4. */ if (try_browser ("xdg-open", NULL, url)) return; @@ -960,13 +870,11 @@ fe_open_url_inner (const char *url) /* fresh out of ideas... */ try_browser ("mozilla", NULL, url); -#endif } static void fe_open_url_locale (const char *url) { -#ifndef WIN32 if (url[0] != '/' && strchr (url, ':') == NULL) { url = g_strdup_printf ("http://%s", url); @@ -974,7 +882,6 @@ fe_open_url_locale (const char *url) g_free ((char *)url); return; } -#endif fe_open_url_inner (url); } diff --git a/src/fe-gtk/fe-gtk.h b/src/fe-gtk/fe-gtk.h index 1251625..bd2c848 100644 --- a/src/fe-gtk/fe-gtk.h +++ b/src/fe-gtk/fe-gtk.h @@ -1,33 +1,10 @@ -#include "../../config.h" - -#ifdef WIN32 -/* If you're compiling this for Windows, your release is un-official - * and not condoned. Please don't use the XChat name. Make up your - * own name! */ -#define DISPLAY_NAME "XChat-Unofficial" -#else #define DISPLAY_NAME "XChat" -#endif -#ifndef WIN32 #include #include -#endif -#if defined(ENABLE_NLS) && !defined(_) -# include -# define _(x) gettext(x) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#endif -#if !defined(ENABLE_NLS) && defined(_) -# undef _ -# define N_(String) (String) -# define _(x) (x) -#endif +#define N_(String) (String) +#define _(x) (x) #include #include @@ -78,10 +55,8 @@ struct server_gui gboolean chanlist_match_wants_channel; /* match in channel name */ gboolean chanlist_match_wants_topic; /* match in topic */ -#ifndef WIN32 regex_t chanlist_match_regex; /* compiled regular expression here */ unsigned int have_regex; -#endif guint chanlist_users_found_count; /* users total for all channels */ guint chanlist_users_shown_count; /* users total for displayed channels */ diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 992546c..0e13e92 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -51,7 +51,6 @@ #include #ifdef XCHAT -#include "../../config.h" /* can define USE_XLIB here */ #else #define USE_XLIB #endif @@ -62,18 +61,10 @@ #include #endif -#ifdef USE_MMX -#include "mmx_cmod.h" -#endif - #include "xtext.h" #define charlen(str) g_utf8_skip[*(guchar *)(str)] -#ifdef WIN32 -#include -#include -#endif /* is delimiter */ #define is_del(c) \ @@ -188,50 +179,7 @@ gtk_xtext_text_width_8bit (GtkXText *xtext, unsigned char *str, int len) return width; } -#ifdef WIN32 - -static void -win32_draw_bg (GtkXText *xtext, int x, int y, int width, int height) -{ - HDC hdc; - HWND hwnd; - HRGN rgn; - - if (xtext->shaded) - { - /* xtext->pixmap is really a GdkImage, created in win32_tint() */ - gdk_draw_image (xtext->draw_buf, xtext->bgc, (GdkImage*)xtext->pixmap, - x, y, x, y, width, height); - } else - { - hwnd = GDK_WINDOW_HWND (xtext->draw_buf); - hdc = GetDC (hwnd); - - rgn = CreateRectRgn (x, y, x + width, y + height); - SelectClipRgn (hdc, rgn); - - PaintDesktop (hdc); - - ReleaseDC (hwnd, hdc); - DeleteObject (rgn); - } -} - -static void -xtext_draw_bg (GtkXText *xtext, int x, int y, int width, int height) -{ - if (xtext->transparent) - win32_draw_bg (xtext, x, y, width, height); - else - gdk_draw_rectangle (xtext->draw_buf, xtext->bgc, 1, x, y, width, height); -} - -#else - -#define xtext_draw_bg(xt,x,y,w,h) gdk_draw_rectangle(xt->draw_buf, xt->bgc, \ - 1,x,y,w,h); - -#endif +#define xtext_draw_bg(xt,x,y,w,h) gdk_draw_rectangle(xt->draw_buf, xt->bgc, 1,x,y,w,h); /* ========================================= */ /* ========== XFT 1 and 2 BACKEND ========== */ @@ -2743,9 +2691,6 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str, } #ifdef USE_DB -#ifdef WIN32 - if (!xtext->transparent) -#endif { pix = gdk_pixmap_new (xtext->draw_buf, str_width, xtext->fontsize, xtext->depth); if (pix) @@ -3445,32 +3390,6 @@ shade_image (GdkVisual *visual, void *data, int bpl, int bpp, int w, int h, bg_g = bg & visual->green_mask; bg_b = bg & visual->blue_mask; -#ifdef USE_MMX - /* the MMX routines are about 50% faster at 16-bit. */ - /* only use MMX routines with a pure black background */ - if (bg_r == 0 && bg_g == 0 && bg_b == 0 && have_mmx ()) /* do a runtime check too! */ - { - switch (depth) - { - case 15: - shade_ximage_15_mmx (data, bpl, w, h, rm, gm, bm); - break; - case 16: - shade_ximage_16_mmx (data, bpl, w, h, rm, gm, bm); - break; - case 24: - if (bpp != 32) - goto generic; - case 32: - shade_ximage_32_mmx (data, bpl, w, h, rm, gm, bm); - break; - default: - goto generic; - } - } else - { -generic: -#endif switch (depth) { case 15: @@ -3488,9 +3407,6 @@ generic: case 32: shade_ximage_32 (data, bpl, w, h, rm, gm, bm, bg); } -#ifdef USE_MMX - } -#endif } #ifdef USE_XLIB @@ -3674,151 +3590,12 @@ gtk_xtext_free_trans (GtkXText * xtext) #endif -#ifdef WIN32 - -static GdkPixmap * -win32_tint (GtkXText *xtext, GdkImage *img, int width, int height) -{ - guchar *pixelp; - int x, y; - GdkPixmap *pix; - GdkVisual *visual = gdk_drawable_get_visual (GTK_WIDGET (xtext)->window); - guint32 pixel; - int r, g, b; - - if (img->depth <= 14) - { - /* slow generic routine */ - for (y = 0; y < height; y++) - { - for (x = 0; x < width; x++) - { - if (img->depth == 1) - { - pixel = (((guchar *) img->mem)[y * img->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0; - goto here; - } - - if (img->depth == 4) - { - pixelp = (guchar *) img->mem + y * img->bpl + (x >> 1); - if (x&1) - { - pixel = (*pixelp) & 0x0F; - goto here; - } - - pixel = (*pixelp) >> 4; - goto here; - } - - pixelp = (guchar *) img->mem + y * img->bpl + x * img->bpp; - - switch (img->bpp) - { - case 1: - pixel = *pixelp; break; - - /* Windows is always LSB, no need to check img->byte_order. */ - case 2: - pixel = pixelp[0] | (pixelp[1] << 8); break; - - case 3: - pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16); break; - - case 4: - pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16); break; - } - -here: - r = (pixel & visual->red_mask) >> visual->red_shift; - g = (pixel & visual->green_mask) >> visual->green_shift; - b = (pixel & visual->blue_mask) >> visual->blue_shift; - - /* actual tinting is only these 3 lines */ - pixel = ((r * xtext->tint_red) >> 8) << visual->red_shift | - ((g * xtext->tint_green) >> 8) << visual->green_shift | - ((b * xtext->tint_blue) >> 8) << visual->blue_shift; - - if (img->depth == 1) - if (pixel & 1) - ((guchar *) img->mem)[y * img->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7))); - else - ((guchar *) img->mem)[y * img->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7))); - else if (img->depth == 4) - { - pixelp = (guchar *) img->mem + y * img->bpl + (x >> 1); - - if (x&1) - { - *pixelp &= 0xF0; - *pixelp |= (pixel & 0x0F); - } else - { - *pixelp &= 0x0F; - *pixelp |= (pixel << 4); - } - } else - { - pixelp = (guchar *) img->mem + y * img->bpl + x * img->bpp; - - /* Windows is always LSB, no need to check img->byte_order. */ - switch (img->bpp) - { - case 4: - pixelp[3] = 0; - case 3: - pixelp[2] = ((pixel >> 16) & 0xFF); - case 2: - pixelp[1] = ((pixel >> 8) & 0xFF); - case 1: - pixelp[0] = (pixel & 0xFF); - } - } - } - } - } else - { - shade_image (visual, img->mem, img->bpl, img->bpp, width, height, - xtext->tint_red, xtext->tint_green, xtext->tint_blue, - xtext->palette[XTEXT_BG], visual->depth); - } - - /* no need to dump it to a Pixmap, it's one and the same on win32 */ - pix = (GdkPixmap *)img; - - return pix; -} - -#endif /* !WIN32 */ - /* grab pixmap from root window and set xtext->pixmap */ -#if defined(USE_XLIB) || defined(WIN32) +#if defined(USE_XLIB) static void gtk_xtext_load_trans (GtkXText * xtext) { -#ifdef WIN32 - GdkImage *img; - int width, height; - HDC hdc; - HWND hwnd; - - /* if not shaded, we paint directly with PaintDesktop() */ - if (!xtext->shaded) - return; - - hwnd = GDK_WINDOW_HWND (GTK_WIDGET (xtext)->window); - hdc = GetDC (hwnd); - PaintDesktop (hdc); - ReleaseDC (hwnd, hdc); - - gdk_window_get_size (GTK_WIDGET (xtext)->window, &width, &height); - img = gdk_image_get (GTK_WIDGET (xtext)->window, 0, 0, width+128, height); - xtext->pixmap = win32_tint (xtext, img, img->width, img->height); - -#else - Pixmap rootpix; GtkWidget *widget = GTK_WIDGET (xtext); int x, y; @@ -3857,10 +3634,9 @@ noshade: xtext->ts_y = -y; } gdk_gc_set_fill (xtext->bgc, GDK_TILED); -#endif /* !WIN32 */ } -#endif /* ! XLIB || WIN32 */ +#endif /* XLIB */ /* walk through str until this line doesn't fit anymore */ @@ -4298,14 +4074,14 @@ gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap, gboolean trans) if (trans && (xtext->tint_red != 255 || xtext->tint_green != 255 || xtext->tint_blue != 255)) shaded = TRUE; -#if !defined(USE_XLIB) && !defined(WIN32) +#if !defined(USE_XLIB) shaded = FALSE; trans = FALSE; #endif if (xtext->pixmap) { -#if defined(USE_XLIB) || defined(WIN32) +#if defined(USE_XLIB) if (xtext->transparent) gtk_xtext_free_trans (xtext); else @@ -4316,7 +4092,7 @@ gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap, gboolean trans) xtext->transparent = trans; -#if defined(USE_XLIB) || defined(WIN32) +#if defined(USE_XLIB) if (trans) { xtext->shaded = shaded; @@ -4632,19 +4408,11 @@ gtk_xtext_render_page (GtkXText * xtext) xtext->buffer->last_pixel_pos = pos; #ifdef USE_DB -#ifdef WIN32 - if (!xtext->transparent && !xtext->pixmap && abs (overlap) < height) -#else if (!xtext->pixmap && abs (overlap) < height) -#endif #else /* dont scroll PageUp/Down without a DB, it looks ugly */ -#ifdef WIN32 - if (!xtext->transparent && !xtext->pixmap && abs (overlap) < height - (3*xtext->fontsize)) -#else if (!xtext->pixmap && abs (overlap) < height - (3*xtext->fontsize)) #endif -#endif { /* so the obscured regions are exposed */ gdk_gc_set_exposures (xtext->fgc, TRUE); @@ -4710,7 +4478,7 @@ gtk_xtext_refresh (GtkXText * xtext, int do_trans) { if (GTK_WIDGET_REALIZED (GTK_WIDGET (xtext))) { -#if defined(USE_XLIB) || defined(WIN32) +#if defined(USE_XLIB) if (xtext->transparent && do_trans) { gtk_xtext_free_trans (xtext); diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index 2bc2e64..f91cd19 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -427,12 +427,6 @@ fe_main (void) if (!sess_list) new_ircwindow (NULL, NULL, SESS_SERVER, 0); -#ifdef ENABLE_NLS - bindtextdomain (GETTEXT_PACKAGE, PREFIX"/share/locale"); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); -#endif - while (!done) { FD_ZERO (&rd); diff --git a/src/common/make-te.c b/src/make-te.c similarity index 100% rename from src/common/make-te.c rename to src/make-te.c -- 2.11.4.GIT