diff options
-rw-r--r-- | ChangeLog | 35 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 35 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 35 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 35 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 35 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 35 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 35 | ||||
-rw-r--r-- | gdk/gdk.c | 1686 | ||||
-rw-r--r-- | gdk/gdkcc.c | 954 | ||||
-rw-r--r-- | gdk/gdkdnd.c | 44 | ||||
-rw-r--r-- | gdk/gdkfont.c | 4 | ||||
-rw-r--r-- | gdk/gdkvisual.c | 6 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 9 | ||||
-rw-r--r-- | gdk/x11/gdkcc-x11.c | 954 | ||||
-rw-r--r-- | gdk/x11/gdkdnd-x11.c | 44 | ||||
-rw-r--r-- | gdk/x11/gdkfont-x11.c | 4 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 1686 | ||||
-rw-r--r-- | gdk/x11/gdkvisual-x11.c | 6 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 9 | ||||
-rw-r--r-- | gtk/gtkfontsel.c | 690 | ||||
-rw-r--r-- | gtk/gtkmain.c | 60 | ||||
-rw-r--r-- | gtk/gtkobject.c | 16 | ||||
-rw-r--r-- | gtk/gtkpreview.c | 22 | ||||
-rw-r--r-- | gtk/gtkselection.c | 280 | ||||
-rw-r--r-- | gtk/gtktext.c | 1498 | ||||
-rw-r--r-- | gtk/gtktree.c | 426 | ||||
-rw-r--r-- | gtk/gtktreeitem.c | 4 | ||||
-rw-r--r-- | gtk/gtktypeutils.c | 16 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 2 |
29 files changed, 4450 insertions, 4215 deletions
@@ -1,3 +1,38 @@ +Tue Aug 18 03:54:43 1998 Tim Janik <timj@gtk.org> + + * gtk/gtkmain.c (gtk_init): restricted the --g*fatal-* arguments + to --g-fatal-warnings again. this option now causes log levels of + WARNING and CRITICAL to abort(). + + * gdk/gdk.c: + * gdk/gdkdnd.c: + * gdk/gdkcc.c: + * gdk/gdkfont.c: + * gdk/gdkwindow.c: + * gdk/gdkvisual.c: + * gtk/gtkwidget.c: + * gtk/gtktypeutils.c: + * gtk/gtktree.c: + * gtk/gtkfontsel.c: + * gtk/gtkmain.c: + * gtk/gtkobject.c: + * gtk/gtkpreview.c: + * gtk/gtkselection.c: + * gtk/gtktext.c: + * gtk/gtktree.c: + * gtk/gtktreeitem.c: + did a global search&replace to substitute g_print() calls with + g_message(). libraries shouldn't use printf(), g_print() or + g_printerr() at all. + a bunch of the replacements should probably be wrapped into the + G{D|T}K_NOTE() macros, so they are special cased for debugging + purposes in a sane way, avoiding all the nasty #ifdef DEBUG_MY_TEDDY + things. + + * gdk/gdkrgb.c: left this out currently. + + * gdk/gdkdnd.c: added copyright notice. + Mon Aug 17 17:28:00 Raph Levien <raph@gtk.org> * gdk/gdkrgb.c: Further speedups of the 565_d case. It's diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 388b6ec14e..6df7e4d270 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,38 @@ +Tue Aug 18 03:54:43 1998 Tim Janik <timj@gtk.org> + + * gtk/gtkmain.c (gtk_init): restricted the --g*fatal-* arguments + to --g-fatal-warnings again. this option now causes log levels of + WARNING and CRITICAL to abort(). + + * gdk/gdk.c: + * gdk/gdkdnd.c: + * gdk/gdkcc.c: + * gdk/gdkfont.c: + * gdk/gdkwindow.c: + * gdk/gdkvisual.c: + * gtk/gtkwidget.c: + * gtk/gtktypeutils.c: + * gtk/gtktree.c: + * gtk/gtkfontsel.c: + * gtk/gtkmain.c: + * gtk/gtkobject.c: + * gtk/gtkpreview.c: + * gtk/gtkselection.c: + * gtk/gtktext.c: + * gtk/gtktree.c: + * gtk/gtktreeitem.c: + did a global search&replace to substitute g_print() calls with + g_message(). libraries shouldn't use printf(), g_print() or + g_printerr() at all. + a bunch of the replacements should probably be wrapped into the + G{D|T}K_NOTE() macros, so they are special cased for debugging + purposes in a sane way, avoiding all the nasty #ifdef DEBUG_MY_TEDDY + things. + + * gdk/gdkrgb.c: left this out currently. + + * gdk/gdkdnd.c: added copyright notice. + Mon Aug 17 17:28:00 Raph Levien <raph@gtk.org> * gdk/gdkrgb.c: Further speedups of the 565_d case. It's diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 388b6ec14e..6df7e4d270 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,38 @@ +Tue Aug 18 03:54:43 1998 Tim Janik <timj@gtk.org> + + * gtk/gtkmain.c (gtk_init): restricted the --g*fatal-* arguments + to --g-fatal-warnings again. this option now causes log levels of + WARNING and CRITICAL to abort(). + + * gdk/gdk.c: + * gdk/gdkdnd.c: + * gdk/gdkcc.c: + * gdk/gdkfont.c: + * gdk/gdkwindow.c: + * gdk/gdkvisual.c: + * gtk/gtkwidget.c: + * gtk/gtktypeutils.c: + * gtk/gtktree.c: + * gtk/gtkfontsel.c: + * gtk/gtkmain.c: + * gtk/gtkobject.c: + * gtk/gtkpreview.c: + * gtk/gtkselection.c: + * gtk/gtktext.c: + * gtk/gtktree.c: + * gtk/gtktreeitem.c: + did a global search&replace to substitute g_print() calls with + g_message(). libraries shouldn't use printf(), g_print() or + g_printerr() at all. + a bunch of the replacements should probably be wrapped into the + G{D|T}K_NOTE() macros, so they are special cased for debugging + purposes in a sane way, avoiding all the nasty #ifdef DEBUG_MY_TEDDY + things. + + * gdk/gdkrgb.c: left this out currently. + + * gdk/gdkdnd.c: added copyright notice. + Mon Aug 17 17:28:00 Raph Levien <raph@gtk.org> * gdk/gdkrgb.c: Further speedups of the 565_d case. It's diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 388b6ec14e..6df7e4d270 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,38 @@ +Tue Aug 18 03:54:43 1998 Tim Janik <timj@gtk.org> + + * gtk/gtkmain.c (gtk_init): restricted the --g*fatal-* arguments + to --g-fatal-warnings again. this option now causes log levels of + WARNING and CRITICAL to abort(). + + * gdk/gdk.c: + * gdk/gdkdnd.c: + * gdk/gdkcc.c: + * gdk/gdkfont.c: + * gdk/gdkwindow.c: + * gdk/gdkvisual.c: + * gtk/gtkwidget.c: + * gtk/gtktypeutils.c: + * gtk/gtktree.c: + * gtk/gtkfontsel.c: + * gtk/gtkmain.c: + * gtk/gtkobject.c: + * gtk/gtkpreview.c: + * gtk/gtkselection.c: + * gtk/gtktext.c: + * gtk/gtktree.c: + * gtk/gtktreeitem.c: + did a global search&replace to substitute g_print() calls with + g_message(). libraries shouldn't use printf(), g_print() or + g_printerr() at all. + a bunch of the replacements should probably be wrapped into the + G{D|T}K_NOTE() macros, so they are special cased for debugging + purposes in a sane way, avoiding all the nasty #ifdef DEBUG_MY_TEDDY + things. + + * gdk/gdkrgb.c: left this out currently. + + * gdk/gdkdnd.c: added copyright notice. + Mon Aug 17 17:28:00 Raph Levien <raph@gtk.org> * gdk/gdkrgb.c: Further speedups of the 565_d case. It's diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 388b6ec14e..6df7e4d270 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,38 @@ +Tue Aug 18 03:54:43 1998 Tim Janik <timj@gtk.org> + + * gtk/gtkmain.c (gtk_init): restricted the --g*fatal-* arguments + to --g-fatal-warnings again. this option now causes log levels of + WARNING and CRITICAL to abort(). + + * gdk/gdk.c: + * gdk/gdkdnd.c: + * gdk/gdkcc.c: + * gdk/gdkfont.c: + * gdk/gdkwindow.c: + * gdk/gdkvisual.c: + * gtk/gtkwidget.c: + * gtk/gtktypeutils.c: + * gtk/gtktree.c: + * gtk/gtkfontsel.c: + * gtk/gtkmain.c: + * gtk/gtkobject.c: + * gtk/gtkpreview.c: + * gtk/gtkselection.c: + * gtk/gtktext.c: + * gtk/gtktree.c: + * gtk/gtktreeitem.c: + did a global search&replace to substitute g_print() calls with + g_message(). libraries shouldn't use printf(), g_print() or + g_printerr() at all. + a bunch of the replacements should probably be wrapped into the + G{D|T}K_NOTE() macros, so they are special cased for debugging + purposes in a sane way, avoiding all the nasty #ifdef DEBUG_MY_TEDDY + things. + + * gdk/gdkrgb.c: left this out currently. + + * gdk/gdkdnd.c: added copyright notice. + Mon Aug 17 17:28:00 Raph Levien <raph@gtk.org> * gdk/gdkrgb.c: Further speedups of the 565_d case. It's diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 388b6ec14e..6df7e4d270 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,38 @@ +Tue Aug 18 03:54:43 1998 Tim Janik <timj@gtk.org> + + * gtk/gtkmain.c (gtk_init): restricted the --g*fatal-* arguments + to --g-fatal-warnings again. this option now causes log levels of + WARNING and CRITICAL to abort(). + + * gdk/gdk.c: + * gdk/gdkdnd.c: + * gdk/gdkcc.c: + * gdk/gdkfont.c: + * gdk/gdkwindow.c: + * gdk/gdkvisual.c: + * gtk/gtkwidget.c: + * gtk/gtktypeutils.c: + * gtk/gtktree.c: + * gtk/gtkfontsel.c: + * gtk/gtkmain.c: + * gtk/gtkobject.c: + * gtk/gtkpreview.c: + * gtk/gtkselection.c: + * gtk/gtktext.c: + * gtk/gtktree.c: + * gtk/gtktreeitem.c: + did a global search&replace to substitute g_print() calls with + g_message(). libraries shouldn't use printf(), g_print() or + g_printerr() at all. + a bunch of the replacements should probably be wrapped into the + G{D|T}K_NOTE() macros, so they are special cased for debugging + purposes in a sane way, avoiding all the nasty #ifdef DEBUG_MY_TEDDY + things. + + * gdk/gdkrgb.c: left this out currently. + + * gdk/gdkdnd.c: added copyright notice. + Mon Aug 17 17:28:00 Raph Levien <raph@gtk.org> * gdk/gdkrgb.c: Further speedups of the 565_d case. It's diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 388b6ec14e..6df7e4d270 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,38 @@ +Tue Aug 18 03:54:43 1998 Tim Janik <timj@gtk.org> + + * gtk/gtkmain.c (gtk_init): restricted the --g*fatal-* arguments + to --g-fatal-warnings again. this option now causes log levels of + WARNING and CRITICAL to abort(). + + * gdk/gdk.c: + * gdk/gdkdnd.c: + * gdk/gdkcc.c: + * gdk/gdkfont.c: + * gdk/gdkwindow.c: + * gdk/gdkvisual.c: + * gtk/gtkwidget.c: + * gtk/gtktypeutils.c: + * gtk/gtktree.c: + * gtk/gtkfontsel.c: + * gtk/gtkmain.c: + * gtk/gtkobject.c: + * gtk/gtkpreview.c: + * gtk/gtkselection.c: + * gtk/gtktext.c: + * gtk/gtktree.c: + * gtk/gtktreeitem.c: + did a global search&replace to substitute g_print() calls with + g_message(). libraries shouldn't use printf(), g_print() or + g_printerr() at all. + a bunch of the replacements should probably be wrapped into the + G{D|T}K_NOTE() macros, so they are special cased for debugging + purposes in a sane way, avoiding all the nasty #ifdef DEBUG_MY_TEDDY + things. + + * gdk/gdkrgb.c: left this out currently. + + * gdk/gdkdnd.c: added copyright notice. + Mon Aug 17 17:28:00 Raph Levien <raph@gtk.org> * gdk/gdkrgb.c: Further speedups of the 565_d case. It's @@ -8,7 +8,7 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public @@ -68,7 +68,7 @@ # define SELECT_MASK fd_set #else # ifndef _AIX - typedef long fd_mask; +typedef long fd_mask; # endif # if defined(_IBMR2) # define SELECT_MASK void @@ -101,120 +101,120 @@ struct _GdkPredicate * Private function declarations */ -static GdkEvent *gdk_event_new (void); -static gint gdk_event_wait (void); -static gint gdk_event_apply_filters (XEvent *xevent, +static GdkEvent *gdk_event_new (void); +static gint gdk_event_wait (void); +static gint gdk_event_apply_filters (XEvent *xevent, GdkEvent *event, GList *filters); -static gint gdk_event_translate (GdkEvent *event, - XEvent *xevent); +static gint gdk_event_translate (GdkEvent *event, + XEvent *xevent); #if 0 -static Bool gdk_event_get_type (Display *display, - XEvent *xevent, +static Bool gdk_event_get_type (Display *display, + XEvent *xevent, XPointer arg); #endif -static void gdk_synthesize_click (GdkEvent *event, - gint nclicks); +static void gdk_synthesize_click (GdkEvent *event, + gint nclicks); -static void gdk_dnd_drag_begin (GdkWindow *initial_window); -static void gdk_dnd_drag_enter (Window dest); -static void gdk_dnd_drag_leave (Window dest); -static void gdk_dnd_drag_end (Window dest, +static void gdk_dnd_drag_begin (GdkWindow *initial_window); +static void gdk_dnd_drag_enter (Window dest); +static void gdk_dnd_drag_leave (Window dest); +static void gdk_dnd_drag_end (Window dest, GdkPoint coords); -static GdkAtom gdk_dnd_check_types (GdkWindow *window, - XEvent *xevent); +static GdkAtom gdk_dnd_check_types (GdkWindow *window, + XEvent *xevent); #ifdef DEBUG_DND -static void gdk_print_atom (GdkAtom anatom); +static void gdk_print_atom (GdkAtom anatom); #endif #ifndef HAVE_XCONVERTCASE -static void gdkx_XConvertCase (KeySym symbol, - KeySym *lower, - KeySym *upper); +static void gdkx_XConvertCase (KeySym symbol, + KeySym *lower, + KeySym *upper); #define XConvertCase gdkx_XConvertCase #endif /* * old junk from offix, we might use it though so leave it */ -Window gdk_get_client_window (Display *dpy, - Window win); +Window gdk_get_client_window (Display *dpy, + Window win); #ifdef WE_HAVE_MOTIF_DROPS_DONE -static GdkWindow * gdk_drop_get_real_window (GdkWindow *w, +static GdkWindow * gdk_drop_get_real_window (GdkWindow *w, guint16 *x, guint16 *y); #endif -static void gdk_exit_func (void); -static int gdk_x_error (Display *display, +static void gdk_exit_func (void); +static int gdk_x_error (Display *display, XErrorEvent *error); -static int gdk_x_io_error (Display *display); -static RETSIGTYPE gdk_signal (int signum); +static int gdk_x_io_error (Display *display); +static RETSIGTYPE gdk_signal (int signum); #ifdef USE_XIM -static guint gdk_im_va_count (va_list list); +static guint gdk_im_va_count (va_list list); static XVaNestedList gdk_im_va_to_nested (va_list list, - guint count); + guint count); static GdkIM gdk_im_get (void); static gint gdk_im_open (XrmDatabase db, gchar* res_name, gchar* rec_class); static void gdk_im_close (void); -static void gdk_ic_cleanup (void); +static void gdk_ic_cleanup (void); #endif /* USE_XIM */ /* Private variable declarations */ -static int gdk_initialized = 0; /* 1 if the library is initialized, +static int gdk_initialized = 0; /* 1 if the library is initialized, * 0 otherwise. */ -static int connection_number = 0; /* The file descriptor number of our - * connection to the X server. This - * is used so that we may determine - * when events are pending by using - * the "select" system call. +static int connection_number = 0; /* The file descriptor number of our + * connection to the X server. This + * is used so that we may determine + * when events are pending by using + * the "select" system call. */ -static struct timeval start; /* The time at which the library was - * last initialized. +static struct timeval start; /* The time at which the library was + * last initialized. */ -static struct timeval timer; /* Timeout interval to use in the call - * to "select". This is used in - * conjunction with "timerp" to create - * a maximum time to wait for an event - * to arrive. +static struct timeval timer; /* Timeout interval to use in the call + * to "select". This is used in + * conjunction with "timerp" to create + * a maximum time to wait for an event + * to arrive. */ -static struct timeval *timerp; /* The actual timer passed to "select" - * This may be NULL, in which case - * "select" will block until an event - * arrives. +static struct timeval *timerp; /* The actual timer passed to "select" + * This may be NULL, in which case + * "select" will block until an event + * arrives. */ -static guint32 timer_val; /* The timeout length as specified by - * the user in milliseconds. +static guint32 timer_val; /* The timeout length as specified by + * the user in milliseconds. */ -static GList *inputs; /* A list of the input file descriptors - * that we care about. Each list node - * contains a GdkInput struct that describes - * when we are interested in the specified - * file descriptor. That is, when it is - * available for read, write or has an - * exception pending. +static GList *inputs; /* A list of the input file descriptors + * that we care about. Each list node + * contains a GdkInput struct that describes + * when we are interested in the specified + * file descriptor. That is, when it is + * available for read, write or has an + * exception pending. */ -static guint32 button_click_time[2]; /* The last 2 button click times. Used - * to determine if the latest button click - * is part of a double or triple click. +static guint32 button_click_time[2]; /* The last 2 button click times. Used + * to determine if the latest button click + * is part of a double or triple click. */ -static GdkWindow *button_window[2]; /* The last 2 windows to receive button presses. - * Also used to determine if the latest button - * click is part of a double or triple click. +static GdkWindow *button_window[2]; /* The last 2 windows to receive button presses. + * Also used to determine if the latest button + * click is part of a double or triple click. */ -static guint button_number[2]; /* The last 2 buttons to be pressed. +static guint button_number[2]; /* The last 2 buttons to be pressed. */ static GdkWindowPrivate *xgrab_window = NULL; /* Window that currently holds the - * x pointer grab + * x pointer grab */ #ifdef USE_XIM @@ -235,11 +235,11 @@ static gint autorepeat; #ifdef G_ENABLE_DEBUG static GDebugKey gdk_debug_keys[] = { - {"events", GDK_DEBUG_EVENTS}, - {"misc", GDK_DEBUG_MISC}, - {"dnd", GDK_DEBUG_DND}, + {"events", GDK_DEBUG_EVENTS}, + {"misc", GDK_DEBUG_MISC}, + {"dnd", GDK_DEBUG_DND}, {"color-context", GDK_DEBUG_COLOR_CONTEXT}, - {"xim", GDK_DEBUG_XIM} + {"xim", GDK_DEBUG_XIM} }; static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey); @@ -268,7 +268,7 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey); */ void -gdk_init (int *argc, +gdk_init (int *argc, char ***argv) { XKeyboardState keyboard_state; @@ -277,10 +277,10 @@ gdk_init (int *argc, XClassHint *class_hint; gchar **argv_orig = NULL; gint argc_orig = 0; - + if (gdk_initialized) return; - + if (argc && argv) { argc_orig = *argc; @@ -290,9 +290,9 @@ gdk_init (int *argc, argv_orig[i] = g_strdup ((*argv)[i]); argv_orig[argc_orig] = NULL; } - + X_GETTIMEOFDAY (&start); - + #ifndef I_NEED_TO_ACTUALLY_DEBUG_MY_PROGRAMS signal (SIGHUP, gdk_signal); signal (SIGINT, gdk_signal); @@ -302,14 +302,14 @@ gdk_init (int *argc, signal (SIGPIPE, gdk_signal); signal (SIGTERM, gdk_signal); #endif - + gdk_display_name = NULL; - + XSetErrorHandler (gdk_x_error); XSetIOErrorHandler (gdk_x_io_error); - + synchronize = FALSE; - + #ifdef G_ENABLE_DEBUG { gchar *debug_string = getenv("GDK_DEBUG"); @@ -319,20 +319,20 @@ gdk_init (int *argc, gdk_ndebug_keys); } #endif /* G_ENABLE_DEBUG */ - + if (argc && argv) { if (*argc > 0) { gchar *d; - + d = strrchr((*argv)[0],'/'); if (d != NULL) gdk_progname = g_strdup (d + 1); else gdk_progname = g_strdup ((*argv)[0]); } - + for (i = 1; i < *argc;) { #ifdef G_ENABLE_DEBUG @@ -361,7 +361,7 @@ gdk_init (int *argc, (strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0)) { gchar *equal_pos = strchr ((*argv)[i], '='); - + if (equal_pos != NULL) { gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1, @@ -381,108 +381,108 @@ gdk_init (int *argc, else #endif /* G_ENABLE_DEBUG */ if (strcmp ("--display", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - - if ((i + 1) < *argc && (*argv)[i + 1]) - { - gdk_display_name = g_strdup ((*argv)[i + 1]); - (*argv)[i + 1] = NULL; - i += 1; - } - } - else if (strcmp ("--sync", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - synchronize = TRUE; - } - else if (strcmp ("--no-xshm", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - gdk_use_xshm = FALSE; - } - else if (strcmp ("--name", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_progname = (*argv)[i]; - (*argv)[i] = NULL; - } - } - else if (strcmp ("--class", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_progclass = (*argv)[i]; - (*argv)[i] = NULL; - } - } + { + (*argv)[i] = NULL; + + if ((i + 1) < *argc && (*argv)[i + 1]) + { + gdk_display_name = g_strdup ((*argv)[i + 1]); + (*argv)[i + 1] = NULL; + i += 1; + } + } + else if (strcmp ("--sync", (*argv)[i]) == 0) + { + (*argv)[i] = NULL; + synchronize = TRUE; + } + else if (strcmp ("--no-xshm", (*argv)[i]) == 0) + { + (*argv)[i] = NULL; + gdk_use_xshm = FALSE; + } + else if (strcmp ("--name", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_progname = (*argv)[i]; + (*argv)[i] = NULL; + } + } + else if (strcmp ("--class", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_progclass = (*argv)[i]; + (*argv)[i] = NULL; + } + } #ifdef XINPUT_GXI - else if (strcmp ("--gxid_host", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_input_gxid_host = ((*argv)[i]); - (*argv)[i] = NULL; - } - } - else if (strcmp ("--gxid_port", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_input_gxid_port = atoi ((*argv)[i]); - (*argv)[i] = NULL; - } - } + else if (strcmp ("--gxid_host", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_input_gxid_host = ((*argv)[i]); + (*argv)[i] = NULL; + } + } + else if (strcmp ("--gxid_port", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_input_gxid_port = atoi ((*argv)[i]); + (*argv)[i] = NULL; + } + } #endif #ifdef USE_XIM - else if (strcmp ("--xim-preedit", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - if (strcmp ("none", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditNone); - else if (strcmp ("nothing", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditNothing); - else if (strcmp ("area", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditArea); - else if (strcmp ("position", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditPosition); - else if (strcmp ("callbacks", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditCallbacks); - } - } - else if (strcmp ("--xim-status", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - if (strcmp ("none", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusNone); - else if (strcmp ("nothing", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusNothing); - else if (strcmp ("area", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusArea); - else if (strcmp ("callbacks", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusCallbacks); - } - } + else if (strcmp ("--xim-preedit", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + if (strcmp ("none", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditNone); + else if (strcmp ("nothing", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditNothing); + else if (strcmp ("area", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditArea); + else if (strcmp ("position", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditPosition); + else if (strcmp ("callbacks", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditCallbacks); + } + } + else if (strcmp ("--xim-status", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + if (strcmp ("none", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusNone); + else if (strcmp ("nothing", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusNothing); + else if (strcmp ("area", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusArea); + else if (strcmp ("callbacks", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusCallbacks); + } + } #endif - + i += 1; } - + for (i = 1; i < *argc; i++) { for (k = i; k < *argc; k++) if ((*argv)[k] != NULL) break; - + if (k > i) { k -= i; @@ -496,34 +496,34 @@ gdk_init (int *argc, { gdk_progname = "<unknown>"; } - - GDK_NOTE (MISC, g_print ("Gdk: progname: \"%s\"\n", gdk_progname)); - + + GDK_NOTE (MISC, g_message ("progname: \"%s\"", gdk_progname)); + gdk_display = XOpenDisplay (gdk_display_name); if (!gdk_display) { g_warning ("cannot open display: %s", XDisplayName (gdk_display_name)); exit(1); } - + /* This is really crappy. We have to look into the display structure * to find the base resource id. This is only needed for recording * and playback of events. */ /* base_id = RESOURCE_BASE; */ base_id = 0; - GDK_NOTE (EVENTS, g_print ("base id: %lu\n", base_id)); - + GDK_NOTE (EVENTS, g_message ("base id: %lu", base_id)); + connection_number = ConnectionNumber (gdk_display); GDK_NOTE (MISC, - g_print ("Gdk: connection number: %d\n", connection_number)); - + g_message ("connection number: %d", connection_number)); + if (synchronize) XSynchronize (gdk_display, True); - + gdk_screen = DefaultScreen (gdk_display); gdk_root_window = RootWindow (gdk_display, gdk_screen); - + gdk_leader_window = XCreateSimpleWindow(gdk_display, gdk_root_window, 10, 10, 10, 10, 0, 0 , 0); class_hint = XAllocClassHint(); @@ -548,7 +548,7 @@ gdk_init (int *argc, gdk_wm_window_protocols[0] = gdk_wm_delete_window; gdk_wm_window_protocols[1] = gdk_wm_take_focus; gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False); - + gdk_dnd.gdk_XdeEnter = gdk_atom_intern("_XDE_ENTER", FALSE); gdk_dnd.gdk_XdeLeave = gdk_atom_intern("_XDE_LEAVE", FALSE); gdk_dnd.gdk_XdeRequest = gdk_atom_intern("_XDE_REQUEST", FALSE); @@ -556,29 +556,29 @@ gdk_init (int *argc, gdk_dnd.gdk_XdeTypelist = gdk_atom_intern("_XDE_TYPELIST", FALSE); gdk_dnd.c->gdk_cursor_dragdefault = XCreateFontCursor(gdk_display, XC_bogosity); gdk_dnd.c->gdk_cursor_dragok = XCreateFontCursor(gdk_display, XC_heart); - + XGetKeyboardControl (gdk_display, &keyboard_state); autorepeat = keyboard_state.global_auto_repeat; - + timer.tv_sec = 0; timer.tv_usec = 0; timerp = NULL; - + button_click_time[0] = 0; button_click_time[1] = 0; button_window[0] = NULL; button_window[1] = NULL; button_number[0] = -1; button_number[1] = -1; - + if (ATEXIT (gdk_exit_func)) g_warning ("unable to register exit function"); - + gdk_visual_init (); gdk_window_init (); gdk_image_init (); gdk_input_init (); - + #ifdef USE_XIM /* initialize XIM Protocol variables */ xim_using = FALSE; @@ -590,10 +590,10 @@ gdk_init (int *argc, gdk_im_set_best_style (GdkIMStatusCallbacks); xim_ic = NULL; xim_window = (GdkWindow*)NULL; - + gdk_im_open (NULL, NULL, NULL); #endif - + gdk_initialized = 1; } @@ -619,9 +619,9 @@ gdk_init (int *argc, void gdk_exit (int errorcode) { - /* de-initialisation is done by the gdk_exit_funct(), - no need to do this here (Alex J.) */ - exit (errorcode); + /* de-initialisation is done by the gdk_exit_funct(), + no need to do this here (Alex J.) */ + exit (errorcode); } /* @@ -641,19 +641,19 @@ gchar* gdk_set_locale (void) { if (!setlocale (LC_ALL,"")) - g_print ("locale not supported by C library\n"); - + g_message ("locale not supported by C library"); + if (!XSupportsLocale ()) { - g_print ("locale not supported by Xlib, locale set to C\n"); + g_message ("locale not supported by Xlib, locale set to C"); setlocale (LC_ALL, "C"); } - + if (!XSetLocaleModifiers ("")) { - g_print ("can not set locale modifiers\n"); + g_message ("can not set locale modifiers"); } - + return setlocale (LC_ALL,NULL); } @@ -680,9 +680,9 @@ gdk_events_pending (void) { gint result; GList *tmp_list; - + result = XPending (gdk_display); - + tmp_list = putback_events; while (tmp_list) { @@ -717,7 +717,7 @@ graphics_expose_predicate (Display *display, GdkWindowPrivate *private = (GdkWindowPrivate *)arg; g_return_val_if_fail (private != NULL, False); - + if ((xevent->xany.window == private->xwindow) && ((xevent->xany.type == GraphicsExpose) || (xevent->xany.type == NoExpose))) @@ -733,20 +733,20 @@ gdk_event_get_graphics_expose (GdkWindow *window) GdkEvent *event; g_return_val_if_fail (window != NULL, NULL); - + XIfEvent (gdk_display, &xevent, graphics_expose_predicate, (XPointer)window); - + if (xevent.xany.type == GraphicsExpose) { event = gdk_event_new (); - + if (gdk_event_translate (event, &xevent)) return event; else gdk_event_free (event); } - return NULL; + return NULL; } /* @@ -775,7 +775,7 @@ gdk_event_get (void) GdkEvent *event; GList *temp_list; XEvent xevent; - + #if 0 if (pred) { @@ -783,7 +783,7 @@ gdk_event_get (void) while (temp_list) { temp_event = temp_list->data; - + if ((* pred) (temp_event, data)) { if (event) @@ -792,29 +792,29 @@ gdk_event_get (void) g_list_free (temp_list); return TRUE; } - + temp_list = temp_list->next; } - + event_pred.func = pred; event_pred.data = data; - + if (XCheckIfEvent (gdk_display, &xevent, gdk_event_get_type, (XPointer) & event_pred)) if (event) return gdk_event_translate (event, &xevent); } else #endif - if (putback_events) - { - event = putback_events->data; - - temp_list = putback_events; - putback_events = g_list_remove_link (putback_events, temp_list); - g_list_free_1 (temp_list); - - return event; - } + if (putback_events) + { + event = putback_events->data; + + temp_list = putback_events; + putback_events = g_list_remove_link (putback_events, temp_list); + g_list_free_1 (temp_list); + + return event; + } /* Wait for an event to occur or the timeout to elapse. * If an event occurs "gdk_event_wait" will return TRUE. @@ -841,7 +841,7 @@ gdk_event_get (void) XNextEvent (gdk_display, &xevent); #endif event = gdk_event_new (); - + event->any.type = GDK_NOTHING; event->any.window = NULL; event->any.send_event = FALSE; @@ -852,7 +852,7 @@ gdk_event_get (void) else gdk_event_free (event); } - + return NULL; } @@ -860,11 +860,11 @@ void gdk_event_put (GdkEvent *event) { GdkEvent *new_event; - + g_return_if_fail (event != NULL); - + new_event = gdk_event_copy (event); - + putback_events = g_list_prepend (putback_events, new_event); } @@ -898,9 +898,9 @@ gdk_event_new (void) sizeof (GdkEvent), 4096, G_ALLOC_AND_FREE); - + new_event = g_chunk_new (GdkEvent, event_chunk); - + return new_event; } @@ -910,25 +910,25 @@ gdk_event_copy (GdkEvent *event) GdkEvent *new_event; g_return_val_if_fail (event != NULL, NULL); - + new_event = gdk_event_new (); - + *new_event = *event; gdk_window_ref (new_event->any.window); - + switch (event->any.type) { case GDK_KEY_PRESS: case GDK_KEY_RELEASE: new_event->key.string = g_strdup (event->key.string); break; - + case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: if (event->crossing.subwindow != NULL) gdk_window_ref (event->crossing.subwindow); break; - + case GDK_DROP_DATA_AVAIL: new_event->dropdataavailable.data_type = g_strdup (event->dropdataavailable.data_type); new_event->dropdataavailable.data = g_malloc (event->dropdataavailable.data_numbytes); @@ -936,11 +936,11 @@ gdk_event_copy (GdkEvent *event) event->dropdataavailable.data, event->dropdataavailable.data_numbytes); break; - + default: break; } - + return new_event; } @@ -967,36 +967,36 @@ gdk_event_free (GdkEvent *event) { g_assert (event_chunk != NULL); g_return_if_fail (event != NULL); - + if (event->any.window) gdk_window_unref (event->any.window); - + switch (event->any.type) { case GDK_KEY_PRESS: case GDK_KEY_RELEASE: g_free (event->key.string); break; - + case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: if (event->crossing.subwindow != NULL) gdk_window_unref (event->crossing.subwindow); break; - + case GDK_DROP_DATA_AVAIL: g_free (event->dropdataavailable.data_type); g_free (event->dropdataavailable.data); break; - + case GDK_DRAG_REQUEST: g_free (event->dragrequest.data_type); break; - + default: break; } - + g_mem_chunk_free (event_chunk, event); } @@ -1073,9 +1073,9 @@ gdk_time_get (void) struct timeval end; struct timeval elapsed; guint32 milliseconds; - + X_GETTIMEOFDAY (&end); - + if (start.tv_usec > end.tv_usec) { end.tv_usec += 1000000; @@ -1083,9 +1083,9 @@ gdk_time_get (void) } elapsed.tv_sec = end.tv_sec - start.tv_sec; elapsed.tv_usec = end.tv_usec - start.tv_usec; - + milliseconds = (elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000); - + return milliseconds; } @@ -1138,7 +1138,7 @@ gdk_timer_set (guint32 milliseconds) timer_val = milliseconds; timer.tv_sec = milliseconds / 1000; timer.tv_usec = (milliseconds % 1000) * 1000; - + } void @@ -1154,25 +1154,25 @@ gdk_timer_disable (void) } gint -gdk_input_add_full (gint source, +gdk_input_add_full (gint source, GdkInputCondition condition, GdkInputFunction function, - gpointer data, + gpointer data, GdkDestroyNotify destroy) { static gint next_tag = 1; GList *list; GdkInput *input; gint tag; - + tag = 0; list = inputs; - + while (list) { input = list->data; list = list->next; - + if ((input->source == source) && (input->condition == condition)) { if (input->destroy) @@ -1183,7 +1183,7 @@ gdk_input_add_full (gint source, tag = input->tag; } } - + if (!tag) { input = g_new (GdkInput, 1); @@ -1194,18 +1194,18 @@ gdk_input_add_full (gint source, input->data = data; input->destroy = destroy; tag = input->tag; - + inputs = g_list_prepend (inputs, input); } - + return tag; } gint -gdk_input_add (gint source, +gdk_input_add (gint source, GdkInputCondition condition, - GdkInputFunction function, - gpointer data) + GdkInputFunction function, + gpointer data) { return gdk_input_add_interp (source, condition, function, data, NULL); } @@ -1215,23 +1215,23 @@ gdk_input_remove (gint tag) { GList *list; GdkInput *input; - + list = inputs; while (list) { input = list->data; - + if (input->tag == tag) { if (input->destroy) (input->destroy) (input->data); - - input->tag = 0; /* do not free it here */ - input->condition = 0; /* it's done in gdk_event_wait */ - + + input->tag = 0; /* do not free it here */ + input->condition = 0; /* it's done in gdk_event_wait */ + break; } - + list = list->next; } } @@ -1260,17 +1260,17 @@ gdk_input_remove (gint tag) */ gint -gdk_pointer_grab (GdkWindow * window, - gint owner_events, - GdkEventMask event_mask, - GdkWindow * confine_to, - GdkCursor * cursor, - guint32 time) +gdk_pointer_grab (GdkWindow * window, + gint owner_events, + GdkEventMask event_mask, + GdkWindow * confine_to, + GdkCursor * cursor, + guint32 time) { - /* From gdkwindow.c */ + /* From gdkwindow.c */ extern int nevent_masks; extern int event_mask_table[]; - + gint return_val; GdkWindowPrivate *window_private; GdkWindowPrivate *confine_to_private; @@ -1280,33 +1280,33 @@ gdk_pointer_grab (GdkWindow * window, Window xconfine_to; Cursor xcursor; int i; - + g_return_val_if_fail (window != NULL, 0); - + window_private = (GdkWindowPrivate*) window; confine_to_private = (GdkWindowPrivate*) confine_to; cursor_private = (GdkCursorPrivate*) cursor; - + xwindow = window_private->xwindow; - + if (!confine_to || confine_to_private->destroyed) xconfine_to = None; else xconfine_to = confine_to_private->xwindow; - + if (!cursor) xcursor = None; else xcursor = cursor_private->xcursor; - - + + xevent_mask = 0; for (i = 0; i < nevent_masks; i++) { if (event_mask & (1 << (i + 1))) xevent_mask |= event_mask_table[i]; } - + if (((GdkWindowPrivate *)window)->extension_events && gdk_input_vtable.grab_pointer) return_val = gdk_input_vtable.grab_pointer (window, @@ -1331,7 +1331,7 @@ gdk_pointer_grab (GdkWindow * window, else return_val = AlreadyGrabbed; } - + if (return_val == GrabSuccess) xgrab_window = window_private; @@ -1358,7 +1358,7 @@ gdk_pointer_ungrab (guint32 time) { if (gdk_input_vtable.ungrab_pointer) gdk_input_vtable.ungrab_pointer (time); - + XUngrabPointer (gdk_display, time); xgrab_window = NULL; } @@ -1405,18 +1405,18 @@ gdk_pointer_is_grabbed (void) */ gint -gdk_keyboard_grab (GdkWindow * window, - gint owner_events, - guint32 time) +gdk_keyboard_grab (GdkWindow * window, + gint owner_events, + guint32 time) { GdkWindowPrivate *window_private; Window xwindow; - + g_return_val_if_fail (window != NULL, 0); - + window_private = (GdkWindowPrivate*) window; xwindow = window_private->xwindow; - + if (!window_private->destroyed) return XGrabKeyboard (window_private->xdisplay, xwindow, @@ -1467,9 +1467,9 @@ gint gdk_screen_width (void) { gint return_val; - + return_val = DisplayWidth (gdk_display, gdk_screen); - + return return_val; } @@ -1492,9 +1492,9 @@ gint gdk_screen_height (void) { gint return_val; - + return_val = DisplayHeight (gdk_display, gdk_screen); - + return return_val; } @@ -1517,9 +1517,9 @@ gint gdk_screen_width_mm (void) { gint return_val; - + return_val = DisplayWidthMM (gdk_display, gdk_screen); - + return return_val; } @@ -1542,9 +1542,9 @@ gint gdk_screen_height_mm (void) { gint return_val; - + return_val = DisplayHeightMM (gdk_display, gdk_screen); - + return return_val; } @@ -1624,7 +1624,7 @@ gdk_event_wait (void) SELECT_MASK exceptfds; int max_input; int nfd; - + /* If there are no events pending we will wait for an event. * The time we wait is dependant on the "timer". If no timer * has been specified then we'll block until an event arrives. @@ -1632,21 +1632,21 @@ gdk_event_wait (void) * arrives or the timer expires. (This is all done using the * "select" system call). */ - + if (XPending (gdk_display) == 0) { FD_ZERO (&readfds); FD_ZERO (&writefds); FD_ZERO (&exceptfds); - + FD_SET (connection_number, &readfds); max_input = connection_number; - + list = inputs; while (list) { input = list->data; - + if (input->tag) { if (input->condition & GDK_INPUT_READ) @@ -1655,14 +1655,14 @@ gdk_event_wait (void) FD_SET (input->source, &writefds); if (input->condition & GDK_INPUT_EXCEPTION) FD_SET (input->source, &exceptfds); - + max_input = MAX (max_input, input->source); list = list->next; } - else /* free removed inputs */ + else /* free removed inputs */ { temp_list = list; - + if (list->next) list->next->prev = list->prev; if (list->prev) @@ -1671,28 +1671,28 @@ gdk_event_wait (void) inputs = list->next; list = list->next; - + temp_list->next = NULL; temp_list->prev = NULL; - + g_free (temp_list->data); g_list_free (temp_list); } } - + #ifdef USE_PTHREADS if (gdk_using_threads) { gdk_select_waiting = TRUE; - + FD_SET (gdk_threads_pipe[0], &readfds); max_input = MAX (max_input, gdk_threads_pipe[0]); gdk_threads_leave (); } #endif - + nfd = select (max_input+1, &readfds, &writefds, &exceptfds, timerp); - + #ifdef USE_PTHREADS if (gdk_using_threads) { @@ -1704,10 +1704,10 @@ gdk_event_wait (void) read (gdk_threads_pipe[0], &c, 1); } #endif - + timerp = NULL; timer_val = 0; - + if (nfd > 0) { if (FD_ISSET (connection_number, &readfds)) @@ -1724,13 +1724,13 @@ gdk_event_wait (void) else return TRUE; } - + list = inputs; while (list) { input = list->data; list = list->next; - + condition = 0; if (FD_ISSET (input->source, &readfds)) condition |= GDK_INPUT_READ; @@ -1738,7 +1738,7 @@ gdk_event_wait (void) condition |= GDK_INPUT_WRITE; if (FD_ISSET (input->source, &exceptfds)) condition |= GDK_INPUT_EXCEPTION; - + if (condition && input->function) (* input->function) (input->data, input->source, condition); } @@ -1746,7 +1746,7 @@ gdk_event_wait (void) } else return TRUE; - + return FALSE; } @@ -1758,20 +1758,20 @@ gdk_event_apply_filters (XEvent *xevent, GdkEventFilter *filter; GList *tmp_list; GdkFilterReturn result; - + tmp_list = filters; while (tmp_list) { filter = (GdkEventFilter *)tmp_list->data; - + result = (*filter->function)(xevent, event, filter->data); if (result != GDK_FILTER_CONTINUE) return result; - + tmp_list = tmp_list->next; } - + return GDK_FILTER_CONTINUE; } @@ -1779,7 +1779,7 @@ static gint gdk_event_translate (GdkEvent *event, XEvent *xevent) { - + GdkWindow *window; GdkWindowPrivate *window_private; static XComposeStatus compose; @@ -1792,13 +1792,13 @@ gdk_event_translate (GdkEvent *event, char buf[16]; #endif gint return_val; - + return_val = FALSE; - + /* We need to play catch-up with the dnd motion events */ if(gdk_dnd.drag_really && xevent->type == MotionNotify) - while (XCheckTypedEvent(xevent->xany.display,MotionNotify,xevent)); - + while (XCheckTypedEvent(xevent->xany.display,MotionNotify,xevent)); + /* Find the GdkWindow that this event occurred in. * All events occur in some GdkWindow (otherwise, why * would we be receiving them). It really is an error @@ -1807,30 +1807,30 @@ gdk_event_translate (GdkEvent *event, * specially - they are generated by XFree86's XInput under * some circumstances. */ - + if ((xevent->xany.window == None) && gdk_input_vtable.window_none_event) { return_val = gdk_input_vtable.window_none_event (event,xevent); - + if (return_val >= 0) /* was handled */ return return_val; else return_val = FALSE; } - + window = gdk_window_lookup (xevent->xany.window); window_private = (GdkWindowPrivate *) window; - + if (window != NULL) gdk_window_ref (window); else if(gdk_null_window_warnings) /* Special purpose programs that get events for other windows may want to disable this */ g_warning ("%#lx -> NULL\n", xevent->xany.window); - + /* Check for filters for this window */ - + { GdkFilterReturn result; result = gdk_event_apply_filters (xevent, event, @@ -1843,7 +1843,7 @@ gdk_event_translate (GdkEvent *event, return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE; } } - + /* We do a "manual" conversion of the XEvent to a * GdkEvent. The structures are mostly the same so * the conversion is fairly straightforward. We also @@ -1861,12 +1861,12 @@ gdk_event_translate (GdkEvent *event, */ #ifdef USE_XIM if (buf_len == 0) - { + { buf_len = 128; buf = g_new (gchar, buf_len); } keysym = GDK_VoidSymbol; - + if (xim_using == TRUE && xim_ic) { Status status; @@ -1876,15 +1876,15 @@ gdk_event_translate (GdkEvent *event, &xevent->xkey, buf, buf_len-1, &keysym, &status); if (status == XBufferOverflow) - { /* retry */ + { /* retry */ /* alloc adequate size of buffer */ GDK_NOTE (XIM, - g_print("XIM: overflow (required %i)\n", charcount)); - + g_message("XIM: overflow (required %i)", charcount)); + while (buf_len <= charcount) buf_len *= 2; buf = (gchar *) g_realloc (buf, buf_len); - + charcount = XmbLookupString (xim_ic->xic, &xevent->xkey, buf, buf_len-1, &keysym, &status); @@ -1903,41 +1903,41 @@ gdk_event_translate (GdkEvent *event, &keysym, &compose); #endif event->key.keyval = keysym; - + if (charcount > 0 && buf[charcount-1] == '\0') charcount --; else buf[charcount] = '\0'; - + /* Print debugging info. */ #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & GDK_DEBUG_EVENTS) { - g_print ("key press:\twindow: %ld key: %12s %d\n", - xevent->xkey.window - base_id, - event->key.keyval ? XKeysymToString (event->key.keyval) : "(none)", - event->key.keyval); + g_message ("key press:\twindow: %ld key: %12s %d", + xevent->xkey.window - base_id, + event->key.keyval ? XKeysymToString (event->key.keyval) : "(none)", + event->key.keyval); if (charcount > 0) - g_print ("\t\tlength: %4d string: \"%s\"\n", - charcount, buf); + g_message ("\t\tlength: %4d string: \"%s\"", + charcount, buf); } #endif /* G_ENABLE_DEBUG */ - + event->key.type = GDK_KEY_PRESS; event->key.window = window; event->key.time = xevent->xkey.time; event->key.state = (GdkModifierType) xevent->xkey.state; event->key.string = g_strdup (buf); event->key.length = charcount; - + return_val = window_private && !window_private->destroyed; if (!return_val) g_free (event->key.string); break; - + case KeyRelease: /* Lookup the string corresponding to the given keysym. */ @@ -1945,40 +1945,40 @@ gdk_event_translate (GdkEvent *event, charcount = XLookupString (&xevent->xkey, buf, 16, &keysym, &compose); event->key.keyval = keysym; - + /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("key release:\t\twindow: %ld key: %12s %d\n", - xevent->xkey.window - base_id, - XKeysymToString (event->key.keyval), - event->key.keyval)); - + g_message ("key release:\t\twindow: %ld key: %12s %d", + xevent->xkey.window - base_id, + XKeysymToString (event->key.keyval), + event->key.keyval)); + event->key.type = GDK_KEY_RELEASE; event->key.window = window; event->key.time = xevent->xkey.time; event->key.state = (GdkModifierType) xevent->xkey.state; event->key.length = 0; event->key.string = NULL; - + return_val = window_private && !window_private->destroyed; break; - + case ButtonPress: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d\n", - window_private?window_private->dnd_drag_enabled:0, - xevent->xbutton.window - base_id, - xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button)); - + g_message ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d", + window_private?window_private->dnd_drag_enabled:0, + xevent->xbutton.window - base_id, + xevent->xbutton.x, xevent->xbutton.y, + xevent->xbutton.button)); + if (window_private && (window_private->extension_events != 0) && gdk_input_ignore_core) break; - + event->button.type = GDK_BUTTON_PRESS; event->button.window = window; event->button.time = xevent->xbutton.time; @@ -1993,13 +1993,13 @@ gdk_event_translate (GdkEvent *event, event->button.button = xevent->xbutton.button; event->button.source = GDK_SOURCE_MOUSE; event->button.deviceid = GDK_CORE_POINTER; - + if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) && (event->button.window == button_window[1]) && (event->button.button == button_number[1])) { gdk_synthesize_click (event, 3); - + button_click_time[1] = 0; button_click_time[0] = 0; button_window[1] = NULL; @@ -2012,7 +2012,7 @@ gdk_event_translate (GdkEvent *event, (event->button.button == button_number[0])) { gdk_synthesize_click (event, 2); - + button_click_time[1] = button_click_time[0]; button_click_time[0] = event->button.time; button_window[1] = button_window[0]; @@ -2047,13 +2047,13 @@ gdk_event_translate (GdkEvent *event, } gdk_dnd.drag_numwindows = gdk_dnd.drag_really = 0; gdk_dnd.dnd_grabbed = FALSE; - + { /* Set motion mask for first DnD'd window, since it will be the one that is actually dragged */ XWindowAttributes dnd_winattr; XSetWindowAttributes dnd_setwinattr; - + /* We need to get motion events while the button is down, so we can know whether to really start dragging or not... */ XGetWindowAttributes(gdk_display, (Window)window_private->xwindow, @@ -2062,29 +2062,29 @@ gdk_event_translate (GdkEvent *event, window_private->dnd_drag_savedeventmask = dnd_winattr.your_event_mask; dnd_setwinattr.event_mask = window_private->dnd_drag_eventmask = ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | - EnterWindowMask | LeaveWindowMask | ExposureMask; + EnterWindowMask | LeaveWindowMask | ExposureMask; XChangeWindowAttributes(gdk_display, window_private->xwindow, CWEventMask, &dnd_setwinattr); + } } - } return_val = window_private && !window_private->destroyed; break; - + case ButtonRelease: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("button release[%d]:\twindow: %ld x,y: %d %d button: %d\n", - window_private?window_private->dnd_drag_enabled:0, - xevent->xbutton.window - base_id, - xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button)); - + g_message ("button release[%d]:\twindow: %ld x,y: %d %d button: %d", + window_private?window_private->dnd_drag_enabled:0, + xevent->xbutton.window - base_id, + xevent->xbutton.x, xevent->xbutton.y, + xevent->xbutton.button)); + if (window_private && (window_private->extension_events != 0) && gdk_input_ignore_core) break; - + event->button.type = GDK_BUTTON_RELEASE; event->button.window = window; event->button.time = xevent->xbutton.time; @@ -2099,7 +2099,7 @@ gdk_event_translate (GdkEvent *event, event->button.button = xevent->xbutton.button; event->button.source = GDK_SOURCE_MOUSE; event->button.deviceid = GDK_CORE_POINTER; - + gdk_dnd.last_drop_time = xevent->xbutton.time; if(gdk_dnd.drag_perhaps) { @@ -2109,7 +2109,7 @@ gdk_event_translate (GdkEvent *event, doesn't change during drag */ attrs.event_mask = gdk_dnd.real_sw->dnd_drag_savedeventmask; XChangeWindowAttributes(gdk_display, gdk_dnd.real_sw->xwindow, - CWEventMask, &attrs); + CWEventMask, &attrs); } if (gdk_dnd.dnd_grabbed) @@ -2121,51 +2121,51 @@ gdk_event_translate (GdkEvent *event, gdk_dnd.dnd_grabbed = FALSE; } - if(gdk_dnd.drag_really) - { - GdkPoint foo; - foo.x = xevent->xbutton.x_root; - foo.y = xevent->xbutton.y_root; - - if(gdk_dnd.dnd_drag_target != None) - gdk_dnd_drag_end(gdk_dnd.dnd_drag_target, foo); - gdk_dnd.drag_really = 0; - - gdk_dnd.drag_numwindows = 0; - if(gdk_dnd.drag_startwindows) + if(gdk_dnd.drag_really) { - g_free(gdk_dnd.drag_startwindows); - gdk_dnd.drag_startwindows = NULL; + GdkPoint foo; + foo.x = xevent->xbutton.x_root; + foo.y = xevent->xbutton.y_root; + + if(gdk_dnd.dnd_drag_target != None) + gdk_dnd_drag_end(gdk_dnd.dnd_drag_target, foo); + gdk_dnd.drag_really = 0; + + gdk_dnd.drag_numwindows = 0; + if(gdk_dnd.drag_startwindows) + { + g_free(gdk_dnd.drag_startwindows); + gdk_dnd.drag_startwindows = NULL; + } + + gdk_dnd.real_sw = NULL; } - - gdk_dnd.real_sw = NULL; - } - - gdk_dnd.drag_perhaps = 0; - gdk_dnd.dnd_drag_start.x = gdk_dnd.dnd_drag_start.y = 0; - gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0; - gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0; - gdk_dnd.dnd_drag_curwin = None; - return_val = window_private?TRUE:FALSE; - } else - return_val = window_private && !window_private->destroyed; + + gdk_dnd.drag_perhaps = 0; + gdk_dnd.dnd_drag_start.x = gdk_dnd.dnd_drag_start.y = 0; + gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0; + gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0; + gdk_dnd.dnd_drag_curwin = None; + return_val = window_private?TRUE:FALSE; + } else + return_val = window_private && !window_private->destroyed; break; - + case MotionNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s d:%d r%d\n", - xevent->xmotion.window - base_id, - xevent->xmotion.x, xevent->xmotion.y, - (xevent->xmotion.is_hint) ? "true" : "false", - gdk_dnd.drag_perhaps, gdk_dnd.drag_really)); - + g_message ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s d:%d r%d", + xevent->xmotion.window - base_id, + xevent->xmotion.x, xevent->xmotion.y, + (xevent->xmotion.is_hint) ? "true" : "false", + gdk_dnd.drag_perhaps, gdk_dnd.drag_really)); + if (window_private && (window_private->extension_events != 0) && gdk_input_ignore_core) break; - + event->motion.type = GDK_MOTION_NOTIFY; event->motion.window = window; event->motion.time = xevent->xmotion.time; @@ -2180,12 +2180,12 @@ gdk_event_translate (GdkEvent *event, event->motion.is_hint = xevent->xmotion.is_hint; event->motion.source = GDK_SOURCE_MOUSE; event->motion.deviceid = GDK_CORE_POINTER; - + #define IS_IN_ZONE(cx, cy) (cx >= gdk_dnd.dnd_drag_dropzone.x \ && cy >= gdk_dnd.dnd_drag_dropzone.y \ && cx < (gdk_dnd.dnd_drag_dropzone.x + gdk_dnd.dnd_drag_dropzone.width) \ && cy < (gdk_dnd.dnd_drag_dropzone.y + gdk_dnd.dnd_drag_dropzone.height)) - + if(gdk_dnd.drag_perhaps && gdk_dnd.drag_really /* && event->motion.is_hint */ /* HINTME */) { @@ -2199,13 +2199,13 @@ gdk_event_translate (GdkEvent *event, #endif Window childwin = gdk_root_window; int x, y, ox, oy; - + /* Interlude - display cursor for the drag ASAP */ gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, xevent->xmotion.y_root, gdk_dnd.dnd_drag_target?TRUE:FALSE, FALSE); - + lastwin = curwin; curwin = gdk_root_window; ox = x = xevent->xmotion.x_root; @@ -2231,23 +2231,23 @@ gdk_event_translate (GdkEvent *event, } #endif GDK_NOTE (DND, - g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n", - curwin, lastwin, gdk_dnd.dnd_drag_curwin)); + g_message("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx", + curwin, lastwin, gdk_dnd.dnd_drag_curwin)); if(curwin != gdk_dnd.dnd_drag_curwin && curwin != lastwin) { /* We have left one window and entered another (do leave & enter bits) */ if(gdk_dnd.dnd_drag_curwin != None) - gdk_dnd_drag_leave(gdk_dnd.dnd_drag_curwin); + gdk_dnd_drag_leave(gdk_dnd.dnd_drag_curwin); gdk_dnd.dnd_drag_curwin = curwin; gdk_dnd_drag_enter(gdk_dnd.dnd_drag_curwin); gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0; gdk_dnd.dnd_drag_target = None; GDK_NOTE (DND, - g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n", - curwin, lastwin, gdk_dnd.dnd_drag_curwin)); - + g_message("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx", + curwin, lastwin, gdk_dnd.dnd_drag_curwin)); + gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, xevent->xmotion.y_root, FALSE, TRUE); @@ -2263,7 +2263,7 @@ gdk_event_translate (GdkEvent *event, xevent->xmotion.y_root); gboolean old_in_zone = IS_IN_ZONE(gdk_dnd.dnd_drag_oldpos.x, gdk_dnd.dnd_drag_oldpos.y); - + if (!in_zone && old_in_zone) { /* We were in the drop zone and moved out */ @@ -2284,31 +2284,31 @@ gdk_event_translate (GdkEvent *event, } } } /* else - dnd_drag_curwin = None; */ + dnd_drag_curwin = None; */ return_val = FALSE; } else return_val = window_private && !window_private->destroyed; break; - + case EnterNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("enter notify:\t\twindow: %ld detail: %d subwin: %ld\n", - xevent->xcrossing.window - base_id, - xevent->xcrossing.detail, - xevent->xcrossing.subwindow - base_id)); - + g_message ("enter notify:\t\twindow: %ld detail: %d subwin: %ld", + xevent->xcrossing.window - base_id, + xevent->xcrossing.detail, + xevent->xcrossing.subwindow - base_id)); + /* Tell XInput stuff about it if appropriate */ if (window_private && (window_private->extension_events != 0) && gdk_input_vtable.enter_event) gdk_input_vtable.enter_event (&xevent->xcrossing, window); - + event->crossing.type = GDK_ENTER_NOTIFY; event->crossing.window = window; - + /* If the subwindow field of the XEvent is non-NULL, then * lookup the corresponding GdkWindow. */ @@ -2316,13 +2316,13 @@ gdk_event_translate (GdkEvent *event, event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow); else event->crossing.subwindow = NULL; - + event->crossing.time = xevent->xcrossing.time; event->crossing.x = xevent->xcrossing.x; event->crossing.y = xevent->xcrossing.y; event->crossing.x_root = xevent->xcrossing.x_root; event->crossing.y_root = xevent->xcrossing.y_root; - + /* Translate the crossing mode into Gdk terms. */ switch (xevent->xcrossing.mode) @@ -2337,7 +2337,7 @@ gdk_event_translate (GdkEvent *event, event->crossing.mode = GDK_CROSSING_UNGRAB; break; }; - + /* Translate the crossing detail into Gdk terms. */ switch (xevent->xcrossing.detail) @@ -2361,52 +2361,52 @@ gdk_event_translate (GdkEvent *event, event->crossing.detail = GDK_NOTIFY_UNKNOWN; break; } - + event->crossing.focus = xevent->xcrossing.focus; event->crossing.state = xevent->xcrossing.state; - + #ifdef G_ENABLE_DEBUG - if ((gdk_debug_flags & GDK_DEBUG_DND) & gdk_dnd.drag_perhaps) - { - g_print("We may[%d] have a drag into %#lx = %#lx\n", + if ((gdk_debug_flags & GDK_DEBUG_DND) & gdk_dnd.drag_perhaps) + { + g_message("We may[%d] have a drag into %#lx = %#lx", gdk_dnd.drag_really, xevent->xcrossing.window, gdk_dnd.real_sw->xwindow); - } + } #endif /* G_ENABLE_DEBUG */ - - if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really && - (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow)) - { + + if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really && + (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow)) + { #if 0 - gdk_dnd.drag_really = 0; - - GDK_NOTE (DND, g_print("Ungrabbed\n")); - - gdk_dnd.drag_numwindows = 0; - g_free(gdk_dnd.drag_startwindows); - gdk_dnd.drag_startwindows = NULL; - /* We don't want to ungrab the pointer here, or we'll - * start getting spurious enter/leave events */ + gdk_dnd.drag_really = 0; + + GDK_NOTE (DND, g_message("Ungrabbed")); + + gdk_dnd.drag_numwindows = 0; + g_free(gdk_dnd.drag_startwindows); + gdk_dnd.drag_startwindows = NULL; + /* We don't want to ungrab the pointer here, or we'll + * start getting spurious enter/leave events */ #endif #if 0 - XChangeActivePointerGrab (gdk_display, 0, None, CurrentTime); + XChangeActivePointerGrab (gdk_display, 0, None, CurrentTime); #endif - } - - return_val = window_private && !window_private->destroyed; - break; - + } + + return_val = window_private && !window_private->destroyed; + break; + case LeaveNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("leave notify:\t\twindow: %ld detail: %d subwin: %ld\n", - xevent->xcrossing.window - base_id, - xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id)); - + g_message ("leave notify:\t\twindow: %ld detail: %d subwin: %ld", + xevent->xcrossing.window - base_id, + xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id)); + event->crossing.type = GDK_LEAVE_NOTIFY; event->crossing.window = window; - + /* If the subwindow field of the XEvent is non-NULL, then * lookup the corresponding GdkWindow. */ @@ -2414,13 +2414,13 @@ gdk_event_translate (GdkEvent *event, event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow); else event->crossing.subwindow = NULL; - + event->crossing.time = xevent->xcrossing.time; event->crossing.x = xevent->xcrossing.x; event->crossing.y = xevent->xcrossing.y; event->crossing.x_root = xevent->xcrossing.x_root; event->crossing.y_root = xevent->xcrossing.y_root; - + /* Translate the crossing mode into Gdk terms. */ switch (xevent->xcrossing.mode) @@ -2435,7 +2435,7 @@ gdk_event_translate (GdkEvent *event, event->crossing.mode = GDK_CROSSING_UNGRAB; break; }; - + /* Translate the crossing detail into Gdk terms. */ switch (xevent->xcrossing.detail) @@ -2459,16 +2459,16 @@ gdk_event_translate (GdkEvent *event, event->crossing.detail = GDK_NOTIFY_UNKNOWN; break; } - + event->crossing.focus = xevent->xcrossing.focus; event->crossing.state = xevent->xcrossing.state; - + #ifdef G_ENABLE_DEBUG if ((gdk_debug_flags & GDK_DEBUG_DND) & gdk_dnd.drag_perhaps) { - g_print("We may[%d] have a drag out of %#lx = %#lx\n", - gdk_dnd.drag_really, - xevent->xcrossing.window, gdk_dnd.real_sw->xwindow); + g_message("We may[%d] have a drag out of %#lx = %#lx", + gdk_dnd.drag_really, + xevent->xcrossing.window, gdk_dnd.real_sw->xwindow); } #endif /* G_ENABLE_DEBUG */ if (gdk_dnd.drag_perhaps && !gdk_dnd.drag_really && @@ -2478,14 +2478,14 @@ gdk_event_translate (GdkEvent *event, gdk_dnd_drag_addwindow((GdkWindow *) gdk_dnd.real_sw); gdk_dnd_drag_begin((GdkWindow *) gdk_dnd.real_sw); xgpret = - XGrabPointer(gdk_display, gdk_dnd.real_sw->xwindow, False, - ButtonMotionMask | PointerMotionMask | - /* PointerMotionHintMask | */ /* HINTME */ - ButtonPressMask | ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, None, - None, CurrentTime); + XGrabPointer(gdk_display, gdk_dnd.real_sw->xwindow, False, + ButtonMotionMask | PointerMotionMask | + /* PointerMotionHintMask | */ /* HINTME */ + ButtonPressMask | ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, + None, CurrentTime); #ifdef G_ENABLE_DEBUG - GDK_NOTE(DND, g_print("xgpret = %d\n", xgpret)); + GDK_NOTE(DND, g_message("xgpret = %d", xgpret)); #endif gdk_dnd.dnd_grabbed = TRUE; gdk_dnd.drag_really = 1; @@ -2493,10 +2493,10 @@ gdk_event_translate (GdkEvent *event, xevent->xmotion.y_root, FALSE, TRUE); } - + return_val = window_private && !window_private->destroyed; break; - + case FocusIn: case FocusOut: /* We only care about focus events that indicate that _this_ @@ -2510,9 +2510,9 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("focus %s:\t\twindow: %ld\n", - (xevent->xany.type == FocusIn) ? "in" : "out", - xevent->xfocus.window - base_id)); + g_message ("focus %s:\t\twindow: %ld", + (xevent->xany.type == FocusIn) ? "in" : "out", + xevent->xfocus.window - base_id)); event->focus_change.type = GDK_FOCUS_CHANGE; event->focus_change.window = window; @@ -2521,28 +2521,28 @@ gdk_event_translate (GdkEvent *event, return_val = window_private && !window_private->destroyed; break; default: - ; + ; } break; - + case KeymapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("keymap notify\n")); - + g_message ("keymap notify")); + /* Not currently handled */ break; - + case Expose: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d\n", - xevent->xexpose.window - base_id, xevent->xexpose.count, - xevent->xexpose.x, xevent->xexpose.y, - xevent->xexpose.width, xevent->xexpose.height)); - + g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d", + xevent->xexpose.window - base_id, xevent->xexpose.count, + xevent->xexpose.x, xevent->xexpose.y, + xevent->xexpose.width, xevent->xexpose.height)); + event->expose.type = GDK_EXPOSE; event->expose.window = window; event->expose.area.x = xevent->xexpose.x; @@ -2550,17 +2550,17 @@ gdk_event_translate (GdkEvent *event, event->expose.area.width = xevent->xexpose.width; event->expose.area.height = xevent->xexpose.height; event->expose.count = xevent->xexpose.count; - + return_val = window_private && !window_private->destroyed; break; - + case GraphicsExpose: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("graphics expose:\tdrawable: %ld\n", - xevent->xgraphicsexpose.drawable - base_id)); - + g_message ("graphics expose:\tdrawable: %ld", + xevent->xgraphicsexpose.drawable - base_id)); + event->expose.type = GDK_EXPOSE; event->expose.window = window; event->expose.area.x = xevent->xgraphicsexpose.x; @@ -2568,23 +2568,23 @@ gdk_event_translate (GdkEvent *event, event->expose.area.width = xevent->xgraphicsexpose.width; event->expose.area.height = xevent->xgraphicsexpose.height; event->expose.count = xevent->xexpose.count; - + return_val = window_private && !window_private->destroyed; break; - + case NoExpose: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("no expose:\t\tdrawable: %ld\n", - xevent->xnoexpose.drawable - base_id)); - + g_message ("no expose:\t\tdrawable: %ld", + xevent->xnoexpose.drawable - base_id)); + event->no_expose.type = GDK_NO_EXPOSE; event->no_expose.window = window; - + return_val = window_private && !window_private->destroyed; break; - + case VisibilityNotify: /* Print debugging info. */ @@ -2593,33 +2593,33 @@ gdk_event_translate (GdkEvent *event, switch (xevent->xvisibility.state) { case VisibilityFullyObscured: - g_print ("visibility notify:\twindow: %ld none\n", - xevent->xvisibility.window - base_id); + g_message ("visibility notify:\twindow: %ld none", + xevent->xvisibility.window - base_id); break; case VisibilityPartiallyObscured: - g_print ("visibility notify:\twindow: %ld partial\n", - xevent->xvisibility.window - base_id); + g_message ("visibility notify:\twindow: %ld partial", + xevent->xvisibility.window - base_id); break; case VisibilityUnobscured: - g_print ("visibility notify:\twindow: %ld full\n", - xevent->xvisibility.window - base_id); + g_message ("visibility notify:\twindow: %ld full", + xevent->xvisibility.window - base_id); break; } #endif /* G_ENABLE_DEBUG */ - + event->visibility.type = GDK_VISIBILITY_NOTIFY; event->visibility.window = window; - + switch (xevent->xvisibility.state) { case VisibilityFullyObscured: event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED; break; - + case VisibilityPartiallyObscured: event->visibility.state = GDK_VISIBILITY_PARTIAL; break; - + case VisibilityUnobscured: event->visibility.state = GDK_VISIBILITY_UNOBSCURED; break; @@ -2627,84 +2627,84 @@ gdk_event_translate (GdkEvent *event, return_val = window_private && !window_private->destroyed; break; - + case CreateNotify: /* Not currently handled */ break; - + case DestroyNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("destroy notify:\twindow: %ld\n", - xevent->xdestroywindow.window - base_id)); - + g_message ("destroy notify:\twindow: %ld", + xevent->xdestroywindow.window - base_id)); + event->any.type = GDK_DESTROY; event->any.window = window; - + return_val = window_private && !window_private->destroyed; - + if(window && window_private->xwindow != GDK_ROOT_WINDOW()) - gdk_window_destroy_notify (window); + gdk_window_destroy_notify (window); break; - + case UnmapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("unmap notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id)); - + g_message ("unmap notify:\t\twindow: %ld", + xevent->xmap.window - base_id)); + event->any.type = GDK_UNMAP; event->any.window = window; - + if (xgrab_window == window_private) xgrab_window = NULL; - + return_val = window_private && !window_private->destroyed; break; - + case MapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("map notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id)); - + g_message ("map notify:\t\twindow: %ld", + xevent->xmap.window - base_id)); + event->any.type = GDK_MAP; event->any.window = window; - + return_val = window_private && !window_private->destroyed; break; - + case ReparentNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("reparent notify:\twindow: %ld\n", - xevent->xreparent.window - base_id)); - + g_message ("reparent notify:\twindow: %ld", + xevent->xreparent.window - base_id)); + /* Not currently handled */ break; - + case ConfigureNotify: /* Print debugging info. */ while ((XPending (gdk_display) > 0) && XCheckTypedWindowEvent(gdk_display, xevent->xany.window, ConfigureNotify, xevent)) - { + { GdkFilterReturn result; - + GDK_NOTE (EVENTS, - g_print ("configure notify discarded:\twindow: %ld\n", - xevent->xconfigure.window - base_id)); - + g_message ("configure notify discarded:\twindow: %ld", + xevent->xconfigure.window - base_id)); + result = gdk_event_apply_filters (xevent, event, window_private ?window_private->filters :gdk_default_filters); - + /* If the result is GDK_FILTER_REMOVE, there will be * trouble, but anybody who filtering the Configure events * better know what they are doing @@ -2713,21 +2713,21 @@ gdk_event_translate (GdkEvent *event, { return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE; } - - /*XSync (gdk_display, 0);*/ + + /*XSync (gdk_display, 0);*/ } - + GDK_NOTE (EVENTS, - g_print ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d\n", - xevent->xconfigure.window - base_id, - xevent->xconfigure.x, - xevent->xconfigure.y, - xevent->xconfigure.width, - xevent->xconfigure.height, - xevent->xconfigure.border_width, - xevent->xconfigure.above - base_id, - xevent->xconfigure.override_redirect)); + g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d", + xevent->xconfigure.window - base_id, + xevent->xconfigure.x, + xevent->xconfigure.y, + xevent->xconfigure.width, + xevent->xconfigure.height, + xevent->xconfigure.border_width, + xevent->xconfigure.above - base_id, + xevent->xconfigure.override_redirect)); if (window_private) { @@ -2749,7 +2749,7 @@ gdk_event_translate (GdkEvent *event, gint tx = 0; gint ty = 0; Window child_window = 0; - + if (!XTranslateCoordinates (window_private->xdisplay, window_private->xwindow, gdk_root_window, @@ -2782,36 +2782,36 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("property notify:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - + g_message ("property notify:\twindow: %ld", + xevent->xproperty.window - base_id)); + event->property.type = GDK_PROPERTY_NOTIFY; event->property.window = window; event->property.atom = xevent->xproperty.atom; event->property.time = xevent->xproperty.time; event->property.state = xevent->xproperty.state; - + return_val = window_private && !window_private->destroyed; break; - + case SelectionClear: GDK_NOTE (EVENTS, - g_print ("selection clear:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - + g_message ("selection clear:\twindow: %ld", + xevent->xproperty.window - base_id)); + event->selection.type = GDK_SELECTION_CLEAR; event->selection.window = window; event->selection.selection = xevent->xselectionclear.selection; event->selection.time = xevent->xselectionclear.time; - + return_val = window_private && !window_private->destroyed; break; - + case SelectionRequest: GDK_NOTE (EVENTS, - g_print ("selection request:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - + g_message ("selection request:\twindow: %ld", + xevent->xproperty.window - base_id)); + event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; event->selection.selection = xevent->xselectionrequest.selection; @@ -2819,43 +2819,43 @@ gdk_event_translate (GdkEvent *event, event->selection.property = xevent->xselectionrequest.property; event->selection.requestor = xevent->xselectionrequest.requestor; event->selection.time = xevent->xselectionrequest.time; - + return_val = window_private && !window_private->destroyed; break; - + case SelectionNotify: GDK_NOTE (EVENTS, - g_print ("selection notify:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - - + g_message ("selection notify:\twindow: %ld", + xevent->xproperty.window - base_id)); + + event->selection.type = GDK_SELECTION_NOTIFY; event->selection.window = window; event->selection.selection = xevent->xselection.selection; event->selection.target = xevent->xselection.target; event->selection.property = xevent->xselection.property; event->selection.time = xevent->xselection.time; - + return_val = window_private && !window_private->destroyed; break; - + case ColormapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("colormap notify:\twindow: %ld\n", - xevent->xcolormap.window - base_id)); - + g_message ("colormap notify:\twindow: %ld", + xevent->xcolormap.window - base_id)); + /* Not currently handled */ break; - + case ClientMessage: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("client message:\twindow: %ld\n", - xevent->xclient.window - base_id)); - + g_message ("client message:\twindow: %ld", + xevent->xclient.window - base_id)); + /* Client messages are the means of the window manager * communicating with a program. We'll first check to * see if this is really the window manager talking @@ -2873,16 +2873,16 @@ gdk_event_translate (GdkEvent *event, * the event is passed along to the program, * which should then destroy the window. */ - + /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("delete window:\t\twindow: %ld\n", - xevent->xclient.window - base_id)); - + g_message ("delete window:\t\twindow: %ld", + xevent->xclient.window - base_id)); + event->any.type = GDK_DELETE; event->any.window = window; - + return_val = window_private && !window_private->destroyed; } else if ((Atom) xevent->xclient.data.l[0] == gdk_wm_take_focus) @@ -2892,13 +2892,13 @@ gdk_event_translate (GdkEvent *event, else if (xevent->xclient.message_type == gdk_dnd.gdk_XdeEnter) { Atom reptype = 0; - + event->dropenter.u.allflags = xevent->xclient.data.l[1]; - - GDK_NOTE (DND, g_print ("GDK_DROP_ENTER [%d][%d]\n", - window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply)); + + GDK_NOTE (DND, g_message ("GDK_DROP_ENTER [%d][%d]", + window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply)); return_val = FALSE; - + /* Now figure out if we really want this drop... * If someone is trying funky clipboard stuff, ignore */ @@ -2908,35 +2908,35 @@ gdk_event_translate (GdkEvent *event, && (reptype = gdk_dnd_check_types (window, xevent))) { XEvent replyev; - + replyev.xclient.type = ClientMessage; replyev.xclient.window = xevent->xclient.data.l[0]; replyev.xclient.format = 32; replyev.xclient.message_type = gdk_dnd.gdk_XdeRequest; replyev.xclient.data.l[0] = window_private->xwindow; - + event->dragrequest.u.allflags = 0; event->dragrequest.u.flags.protocol_version = DND_PROTOCOL_VERSION; event->dragrequest.u.flags.willaccept = 1; event->dragrequest.u.flags.delete_data = (window_private->dnd_drop_destructive_op) ? 1 : 0; - + replyev.xclient.data.l[1] = event->dragrequest.u.allflags; replyev.xclient.data.l[2] = replyev.xclient.data.l[3] = 0; replyev.xclient.data.l[4] = reptype; - + if (!gdk_send_xevent (replyev.xclient.window, False, NoEventMask, &replyev)) - GDK_NOTE (DND, g_print("Sending XdeRequest to %#lx failed\n", - replyev.xclient.window)); - + GDK_NOTE (DND, g_message("Sending XdeRequest to %#lx failed", + replyev.xclient.window)); + event->any.type = GDK_DROP_ENTER; event->any.window = window; event->dropenter.requestor = replyev.xclient.window; event->dropenter.u.allflags = xevent->xclient.data.l[1]; - - GDK_NOTE (DND, g_print("We sent a GDK_DROP_ENTER on to Gtk\n")); + + GDK_NOTE (DND, g_message("We sent a GDK_DROP_ENTER on to Gtk")); return_val = TRUE; } } @@ -2944,9 +2944,9 @@ gdk_event_translate (GdkEvent *event, { #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) - g_print ("GDK_DROP_LEAVE\n"); + g_message ("GDK_DROP_LEAVE"); #endif - + if (window_private && window_private->dnd_drop_enabled) { event->dropleave.type = GDK_DROP_LEAVE; @@ -2966,11 +2966,11 @@ gdk_event_translate (GdkEvent *event, */ #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) - g_print ("GDK_DRAG_REQUEST\n"); + g_message ("GDK_DRAG_REQUEST"); #endif event->dragrequest.u.allflags = xevent->xclient.data.l[1]; return_val = FALSE; - + if (window && gdk_dnd.drag_really && xevent->xclient.data.l[0] == gdk_dnd.dnd_drag_curwin && event->dragrequest.u.flags.sendreply == 0) @@ -2995,7 +2995,7 @@ gdk_event_translate (GdkEvent *event, window_private->dnd_drag_accepted = 1; window_private->dnd_drag_data_type = xevent->xclient.data.l[4]; - + gdk_dnd.dnd_drag_target = gdk_dnd.dnd_drag_curwin; gdk_dnd_display_drag_cursor(-1, -1, TRUE, TRUE); } @@ -3008,56 +3008,56 @@ gdk_event_translate (GdkEvent *event, } } else if(xevent->xclient.message_type == gdk_dnd.gdk_XdeDataAvailable) - { - gint tmp_int; Atom tmp_atom; - gulong tmp_long; - guchar *tmp_charptr; - + { + gint tmp_int; Atom tmp_atom; + gulong tmp_long; + guchar *tmp_charptr; + #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) - g_print("GDK_DROP_DATA_AVAIL\n"); + g_message("GDK_DROP_DATA_AVAIL"); #endif - event->dropdataavailable.u.allflags = xevent->xclient.data.l[1]; - event->dropdataavailable.timestamp = xevent->xclient.data.l[4]; - event->dropdataavailable.coords.x = - xevent->xclient.data.l[3] & 0xffff; - event->dropdataavailable.coords.y = - (xevent->xclient.data.l[3] >> 16) & 0xffff; - if(window - /* No preview of data ATM */ - && event->dropdataavailable.u.flags.isdrop) - { - event->dropdataavailable.type = GDK_DROP_DATA_AVAIL; - event->dropdataavailable.window = window; - event->dropdataavailable.requestor = xevent->xclient.data.l[0]; - event->dropdataavailable.data_type = - gdk_atom_name(xevent->xclient.data.l[2]); - if(XGetWindowProperty (gdk_display, - event->dropdataavailable.requestor, - xevent->xclient.data.l[2], - 0, LONG_MAX - 1, - False, XA_PRIMARY, &tmp_atom, - &tmp_int, - &event->dropdataavailable.data_numbytes, - &tmp_long, - &tmp_charptr) - != Success) - { - g_warning("XGetWindowProperty on %#x may have failed\n", + event->dropdataavailable.u.allflags = xevent->xclient.data.l[1]; + event->dropdataavailable.timestamp = xevent->xclient.data.l[4]; + event->dropdataavailable.coords.x = + xevent->xclient.data.l[3] & 0xffff; + event->dropdataavailable.coords.y = + (xevent->xclient.data.l[3] >> 16) & 0xffff; + if(window + /* No preview of data ATM */ + && event->dropdataavailable.u.flags.isdrop) + { + event->dropdataavailable.type = GDK_DROP_DATA_AVAIL; + event->dropdataavailable.window = window; + event->dropdataavailable.requestor = xevent->xclient.data.l[0]; + event->dropdataavailable.data_type = + gdk_atom_name(xevent->xclient.data.l[2]); + if(XGetWindowProperty (gdk_display, + event->dropdataavailable.requestor, + xevent->xclient.data.l[2], + 0, LONG_MAX - 1, + False, XA_PRIMARY, &tmp_atom, + &tmp_int, + &event->dropdataavailable.data_numbytes, + &tmp_long, + &tmp_charptr) + != Success) + { + g_warning("XGetWindowProperty on %#x may have failed\n", event->dropdataavailable.requestor); - event->dropdataavailable.data = NULL; - } - else - { - GDK_NOTE (DND, g_print("XGetWindowProperty got us %ld bytes\n", - event->dropdataavailable.data_numbytes)); - event->dropdataavailable.data = - g_malloc (event->dropdataavailable.data_numbytes); - memcpy (event->dropdataavailable.data, - tmp_charptr, event->dropdataavailable.data_numbytes); - XFree(tmp_charptr); - return_val = TRUE; - } + event->dropdataavailable.data = NULL; + } + else + { + GDK_NOTE (DND, g_message("XGetWindowProperty got us %ld bytes", + event->dropdataavailable.data_numbytes)); + event->dropdataavailable.data = + g_malloc (event->dropdataavailable.data_numbytes); + memcpy (event->dropdataavailable.data, + tmp_charptr, event->dropdataavailable.data_numbytes); + XFree(tmp_charptr); + return_val = TRUE; + } return_val = TRUE; } } @@ -3083,28 +3083,28 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("mapping notify\n")); - + g_message ("mapping notify")); + /* Let XLib know that there is a new keyboard mapping. */ XRefreshKeyboardMapping (&xevent->xmapping); break; - + default: /* something else - (e.g., a Xinput event) */ - + if (window_private && (window_private->extension_events != 0) && gdk_input_vtable.other_event) return_val = gdk_input_vtable.other_event(event, xevent, window); else return_val = FALSE; - + return_val = return_val && !window_private->destroyed; - + break; } - + if (return_val) { if (event->any.window) @@ -3120,10 +3120,10 @@ gdk_event_translate (GdkEvent *event, event->any.window = NULL; event->any.type = GDK_NOTHING; } - + if (window) gdk_window_unref (window); - + return return_val; } @@ -3135,28 +3135,28 @@ gdk_event_get_type (Display *display, { GdkEvent event; GdkPredicate *pred; - + if (gdk_event_translate (&event, xevent)) { pred = (GdkPredicate*) arg; return (* pred->func) (&event, pred->data); } - + return FALSE; } #endif static void gdk_synthesize_click (GdkEvent *event, - gint nclicks) + gint nclicks) { GdkEvent temp_event; - + g_return_if_fail (event != NULL); - + temp_event = *event; temp_event.type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS; - + gdk_event_put (&temp_event); } @@ -3181,14 +3181,14 @@ static void gdk_exit_func (void) { static gboolean in_gdk_exit_func = FALSE; - + /* This is to avoid an infinite loop if a program segfaults in an atexit() handler (and yes, it does happen, especially if a program - has trounced over memory too badly for even g_print to work) */ + has trounced over memory too badly for even g_message to work) */ if (in_gdk_exit_func == TRUE) return; in_gdk_exit_func = TRUE; - + if (gdk_initialized) { #ifdef USE_XIM @@ -3200,7 +3200,7 @@ gdk_exit_func (void) gdk_image_exit (); gdk_input_exit (); gdk_key_repeat_restore (); - + XCloseDisplay (gdk_display); gdk_initialized = 0; } @@ -3229,11 +3229,11 @@ gdk_exit_func (void) */ static int -gdk_x_error (Display *display, +gdk_x_error (Display *display, XErrorEvent *error) { char buf[64]; - + if (gdk_error_warnings) { XGetErrorText (display, error->error_code, buf, 63); @@ -3244,7 +3244,7 @@ gdk_x_error (Display *display, error->request_code, error->minor_code); } - + gdk_error_code = -1; return 0; } @@ -3301,11 +3301,11 @@ gdk_signal (int sig_num) { static int caught_fatal_sig = 0; char *sig; - + if (caught_fatal_sig) kill (getpid (), sig_num); caught_fatal_sig = 1; - + switch (sig_num) { case SIGHUP: @@ -3333,8 +3333,8 @@ gdk_signal (int sig_num) sig = "unknown signal"; break; } - - g_print ("\n** ERROR **: %s caught\n", sig); + + g_message ("\n** ERROR **: %s caught", sig); #ifdef G_ENABLE_DEBUG abort (); #else /* !G_ENABLE_DEBUG */ @@ -3346,14 +3346,14 @@ static void gdk_dnd_drag_begin (GdkWindow *initial_window) { GdkEvent tev; - - GDK_NOTE(DND, g_print("------- STARTING DRAG from %p\n", initial_window)); - + + GDK_NOTE(DND, g_message("------- STARTING DRAG from %p", initial_window)); + tev.type = GDK_DRAG_BEGIN; tev.dragbegin.window = initial_window; tev.dragbegin.u.allflags = 0; tev.dragbegin.u.flags.protocol_version = DND_PROTOCOL_VERSION; - + gdk_event_put (&tev); } @@ -3369,7 +3369,7 @@ gdk_dnd_drag_enter (Window dest) sev.xclient.format = 32; sev.xclient.message_type = gdk_dnd.gdk_XdeEnter; sev.xclient.window = dest; - + tev.u.allflags = 0; tev.u.flags.protocol_version = DND_PROTOCOL_VERSION; tev.u.flags.sendreply = 1; @@ -3395,10 +3395,10 @@ gdk_dnd_drag_enter (Window dest) else sev.xclient.data.l[3] = sev.xclient.data.l[4] = None; if (!gdk_send_xevent (dest, False, StructureNotifyMask, &sev)) - GDK_NOTE (DND, g_print("Sending XdeEnter to %#lx failed\n", - dest)); + GDK_NOTE (DND, g_message("Sending XdeEnter to %#lx failed", + dest)); } - + } } @@ -3413,9 +3413,9 @@ gdk_dnd_drag_enter (Window dest) */ /* This needs to match XIMArg as defined in Xlcint.h exactly */ - + typedef struct { - gchar *name; + gchar *name; gpointer value; } GdkImArg; @@ -3433,7 +3433,7 @@ gdk_im_va_count (va_list list) { gint count = 0; gchar *name; - + name = va_arg (list, gchar *); while (name) { @@ -3441,7 +3441,7 @@ gdk_im_va_count (va_list list) (void)va_arg (list, gpointer); name = va_arg (list, gchar *); } - + return count; } @@ -3460,15 +3460,15 @@ gdk_im_va_to_nested (va_list list, guint count) { GdkImArg *result; GdkImArg *arg; - + gchar *name; - + if (count == 0) return NULL; - + result = g_new (GdkImArg, count+1); arg = result; - + name = va_arg (list, gchar *); while (name) { @@ -3477,9 +3477,9 @@ gdk_im_va_to_nested (va_list list, guint count) arg++; name = va_arg (list, gchar *); } - + arg->name = NULL; - + return (XVaNestedList)result; } @@ -3508,12 +3508,12 @@ gdk_im_begin (GdkIC ic, GdkWindow* window) { GdkICPrivate *private; Window xwin; - + g_return_if_fail (ic != NULL); g_return_if_fail (window); - + private = (GdkICPrivate *) ic; - + xim_using = TRUE; xim_ic = private; xim_window = window; @@ -3521,7 +3521,7 @@ gdk_im_begin (GdkIC ic, GdkWindow* window) { XGetICValues (private->xic, XNFocusWindow, &xwin, NULL); if (xwin != GDK_WINDOW_XWINDOW(window)) - XSetICValues (private->xic, XNFocusWindow, + XSetICValues (private->xic, XNFocusWindow, GDK_WINDOW_XWINDOW(window), NULL); if (private != xim_ic) XSetICFocus (private->xic); @@ -3563,13 +3563,13 @@ static GdkIMStyle gdk_im_choose_better_style (GdkIMStyle style1, GdkIMStyle style2) { GdkIMStyle s1, s2, u; - + if (style1 == 0) return style2; if (style2 == 0) return style1; if ((style1 & (GdkIMPreeditMask | GdkIMStatusMask)) - == (style2 & (GdkIMPreeditMask | GdkIMStatusMask))) + == (style2 & (GdkIMPreeditMask | GdkIMStatusMask))) return style1; - + s1 = style1 & GdkIMPreeditMask; s2 = style2 & GdkIMPreeditMask; u = s1 | s2; @@ -3603,9 +3603,9 @@ gdk_im_decide_style (GdkIMStyle supported_style) { gint i; GdkIMStyle style, tmp; - + g_return_val_if_fail (xim_styles != NULL, 0); - + style = 0; for (i=0; i<xim_styles->count_styles; i++) { @@ -3622,7 +3622,7 @@ gdk_im_set_best_style (GdkIMStyle style) if (style & GdkIMPreeditMask) { xim_best_allowed_style &= ~GdkIMPreeditMask; - + xim_best_allowed_style |= GdkIMPreeditNone; if (!(style & GdkIMPreeditNone)) { @@ -3642,7 +3642,7 @@ gdk_im_set_best_style (GdkIMStyle style) if (style & GdkIMStatusMask) { xim_best_allowed_style &= ~GdkIMStatusMask; - + xim_best_allowed_style |= GdkIMStatusNone; if (!(style & GdkIMStatusNone)) { @@ -3669,7 +3669,7 @@ gdk_im_open (XrmDatabase db, gchar* res_name, gchar* res_class) return FALSE; } XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL); - + return TRUE; } @@ -3703,17 +3703,17 @@ gdk_ic_new (GdkWindow* client_window, GdkICPrivate *private; XVaNestedList preedit_attr = NULL; guint count; - + g_return_val_if_fail (client_window != NULL, NULL); g_return_val_if_fail (focus_window != NULL, NULL); g_return_val_if_fail (gdk_im_ready(), NULL); - + private = g_new (GdkICPrivate, 1); - + va_start (list, style); count = gdk_im_va_count (list); va_end (list); - + va_start (list, style); preedit_attr = gdk_im_va_to_nested (list, count); va_end (list); @@ -3725,14 +3725,14 @@ gdk_ic_new (GdkWindow* client_window, g_free (private); return NULL; } - + private->xic = XCreateIC(gdk_im_get (), - XNInputStyle, style, - XNClientWindow, GDK_WINDOW_XWINDOW (client_window), - XNFocusWindow, GDK_WINDOW_XWINDOW (focus_window), - preedit_attr? XNPreeditAttributes : NULL, preedit_attr, - NULL); - + XNInputStyle, style, + XNClientWindow, GDK_WINDOW_XWINDOW (client_window), + XNFocusWindow, GDK_WINDOW_XWINDOW (focus_window), + preedit_attr? XNPreeditAttributes : NULL, preedit_attr, + NULL); + g_free (preedit_attr); if (!private->xic) @@ -3740,7 +3740,7 @@ gdk_ic_new (GdkWindow* client_window, g_free (private); return NULL; } - + xim_ic_list = g_list_append (xim_ic_list, private); return private; } @@ -3749,14 +3749,14 @@ void gdk_ic_destroy (GdkIC ic) { GdkICPrivate *private; - + g_return_if_fail (ic != NULL); private = (GdkICPrivate *) ic; - + if (xim_ic == private) gdk_im_end (); - + XDestroyIC (private->xic); xim_ic_list = g_list_remove (xim_ic_list, private); g_free (private); @@ -3766,11 +3766,11 @@ GdkIMStyle gdk_ic_get_style (GdkIC ic) { GdkICPrivate *private; - + g_return_val_if_fail (ic != NULL, 0); - + private = (GdkICPrivate *) ic; - + return private->style; } @@ -3781,21 +3781,21 @@ gdk_ic_set_values (GdkIC ic, ...) XVaNestedList args; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, ic); count = gdk_im_va_count (list); va_end (list); - + va_start (list, ic); args = gdk_im_va_to_nested (list, count); va_end (list); - + XSetICValues (private->xic, XNVaNestedList, args, NULL); - + g_free (args); } @@ -3806,21 +3806,21 @@ gdk_ic_get_values (GdkIC ic, ...) XVaNestedList args; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, ic); count = gdk_im_va_count (list); va_end (list); - + va_start (list, ic); args = gdk_im_va_to_nested (list, count); va_end (list); - + XGetICValues (private->xic, XNVaNestedList, args, NULL); - + g_free (args); } @@ -3831,22 +3831,22 @@ gdk_ic_set_attr (GdkIC ic, const char *target, ...) XVaNestedList attr; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); g_return_if_fail (target != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, target); count = gdk_im_va_count (list); va_end (list); - + va_start (list, target); attr = gdk_im_va_to_nested (list, count); va_end (list); - + XSetICValues (private->xic, target, attr, NULL); - + g_free (attr); } @@ -3857,22 +3857,22 @@ gdk_ic_get_attr (GdkIC ic, const char *target, ...) XVaNestedList attr; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); g_return_if_fail (target != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, target); count = gdk_im_va_count (list); va_end (list); - + va_start (list, target); attr = gdk_im_va_to_nested (list, count); va_end (list); - + XGetICValues (private->xic, target, attr, NULL); - + g_free (attr); } @@ -3884,21 +3884,21 @@ gdk_ic_get_events (GdkIC ic) glong bit; GdkICPrivate *private; gint i; - - /* From gdkwindow.c */ + + /* From gdkwindow.c */ extern int nevent_masks; extern int event_mask_table[]; - + g_return_val_if_fail (ic != NULL, 0); - + private = (GdkICPrivate *) ic; - + if (XGetICValues (private->xic, XNFilterEvents, &xmask, NULL) != NULL) { GDK_NOTE (XIM, g_warning ("Call to XGetICValues: %s failed", XNFilterEvents)); return 0; } - + mask = 0; for (i=0, bit=2; i < nevent_masks; i++, bit <<= 1) if (xmask & event_mask_table [i]) @@ -3906,7 +3906,7 @@ gdk_ic_get_events (GdkIC ic) mask |= bit; xmask &= ~ event_mask_table [i]; } - + if (xmask) g_warning ("ic requires events not supported by the application (%#04lx)", xmask); @@ -3919,17 +3919,17 @@ gdk_ic_cleanup (void) GList* node; gint destroyed; GdkICPrivate *private; - + destroyed = 0; for (node = xim_ic_list; node != NULL; node = node->next) { if (node->data) - { - private = (GdkICPrivate *) (node->data); - XDestroyIC (private->xic); - g_free (private); - destroyed++; - } + { + private = (GdkICPrivate *) (node->data); + XDestroyIC (private->xic); + g_free (private); + destroyed++; + } } #ifdef G_ENABLE_DEBUG if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0) @@ -4025,10 +4025,10 @@ _g_mbtowc (wchar_t *wstr, const char *str, size_t len) { static wchar_t wcs[MB_CUR_MAX + 1]; static gchar mbs[MB_CUR_MAX + 1]; - + wcs[0] = (wchar_t) NULL; mbs[0] = '\0'; - + /* The last argument isn't a mistake. The X locale code trims * the input string to the length of the output string! */ @@ -4037,13 +4037,13 @@ _g_mbtowc (wchar_t *wstr, const char *str, size_t len) return len; else if (wcs[0] == (wchar_t) NULL) return -1; - + len = _Xwctomb (mbs, wcs[0]); if (mbs[0] == '\0') return -1; if (wstr) *wstr = wcs[0]; - + return len; } @@ -4056,9 +4056,9 @@ gdk_dnd_drag_leave (Window dest) GdkEventDropLeave tev; int i; GdkWindowPrivate *wp; - + tev.u.allflags = 0; - + tev.u.flags.protocol_version = DND_PROTOCOL_VERSION; sev.xclient.type = ClientMessage; sev.xclient.window = dest; @@ -4070,8 +4070,8 @@ gdk_dnd_drag_leave (Window dest) wp = (GdkWindowPrivate *) gdk_dnd.drag_startwindows[i]; sev.xclient.data.l[0] = wp->xwindow; if (!gdk_send_xevent (dest, False, StructureNotifyMask, &sev)) - GDK_NOTE (DND, g_print("Sending XdeLeave to %#lx failed\n", - dest)); + GDK_NOTE (DND, g_message("Sending XdeLeave to %#lx failed", + dest)); wp->dnd_drag_accepted = 0; } } @@ -4088,14 +4088,14 @@ gdk_dnd_drag_end (Window dest, GdkWindowPrivate *wp; GdkEvent tev; int i; - + tev.dragrequest.type = GDK_DRAG_REQUEST; tev.dragrequest.drop_coords = coords; tev.dragrequest.requestor = dest; tev.dragrequest.u.allflags = 0; tev.dragrequest.u.flags.protocol_version = DND_PROTOCOL_VERSION; tev.dragrequest.isdrop = 1; - + for (i = 0; i < gdk_dnd.drag_numwindows; i++) { wp = (GdkWindowPrivate *) gdk_dnd.drag_startwindows[i]; @@ -4103,32 +4103,32 @@ gdk_dnd_drag_end (Window dest, { tev.dragrequest.window = (GdkWindow *) wp; tev.dragrequest.u.flags.delete_data = wp->dnd_drag_destructive_op; - tev.dragrequest.timestamp = gdk_dnd.last_drop_time; + tev.dragrequest.timestamp = gdk_dnd.last_drop_time; tev.dragrequest.data_type = - gdk_atom_name(wp->dnd_drag_data_type); - + gdk_atom_name(wp->dnd_drag_data_type); + gdk_event_put(&tev); } } } static GdkAtom -gdk_dnd_check_types (GdkWindow *window, - XEvent *xevent) +gdk_dnd_check_types (GdkWindow *window, + XEvent *xevent) { GdkWindowPrivate *wp = (GdkWindowPrivate *) window; int i, j; GdkEventDropEnter event; - + g_return_val_if_fail(window != NULL, 0); g_return_val_if_fail(xevent != NULL, 0); g_return_val_if_fail(xevent->type == ClientMessage, 0); g_return_val_if_fail(xevent->xclient.message_type == gdk_dnd.gdk_XdeEnter, 0); - + if(wp->dnd_drop_data_numtypesavail <= 0 || !wp->dnd_drop_data_typesavail) return 0; - + for (i = 2; i <= 4; i++) { for (j = 0; j < wp->dnd_drop_data_numtypesavail; j++) @@ -4137,7 +4137,7 @@ gdk_dnd_check_types (GdkWindow *window, return xevent->xclient.data.l[i]; } } - + /* Now we get the extended type list if it's available */ event.u.allflags = xevent->xclient.data.l[1]; if (event.u.flags.extended_typelist) @@ -4145,21 +4145,21 @@ gdk_dnd_check_types (GdkWindow *window, Atom *exttypes, realtype; gulong nitems, nbar; gint realfmt; - + if (XGetWindowProperty(gdk_display, xevent->xclient.data.l[0], gdk_dnd.gdk_XdeTypelist, 0L, LONG_MAX - 1, False, AnyPropertyType, &realtype, &realfmt, &nitems, &nbar, (unsigned char **) &exttypes) - != Success) + != Success) return 0; - + if (realfmt != (sizeof(Atom) * 8)) { g_warning("XdeTypelist property had format of %d instead of the expected %ld, on window %#lx\n", realfmt, (glong)sizeof(Atom) * 8, xevent->xclient.data.l[0]); return 0; } - + for (i = 0; i <= nitems; i++) { for (j = 0; j < wp->dnd_drop_data_numtypesavail; j++) @@ -4185,7 +4185,7 @@ gdk_print_atom (GdkAtom anatom) { gchar *tmpstr = NULL; tmpstr = (anatom!=None)?gdk_atom_name(anatom):"(none)"; - g_print("Atom %lu has name %s\n", anatom, tmpstr); + g_message("Atom %lu has name %s", anatom, tmpstr); if(tmpstr) g_free(tmpstr); } @@ -4195,9 +4195,9 @@ gdk_print_atom (GdkAtom anatom) * used only by below routine and itself */ static Window -getchildren (Display *dpy, - Window win, - Atom WM_STATE) +getchildren (Display *dpy, + Window win, + Atom WM_STATE) { Window root, parent, *children, inf = 0; Atom type = None; @@ -4205,10 +4205,10 @@ getchildren (Display *dpy, int format; unsigned long nitems, after; unsigned char *data; - + if (XQueryTree(dpy, win, &root, &parent, &children, &nchildren) == 0) return 0; - + for (i = 0; !inf && (i < nchildren); i++) { XGetWindowProperty (dpy, children[i], WM_STATE, 0, 0, False, @@ -4218,13 +4218,13 @@ getchildren (Display *dpy, inf = children[i]; XFree(data); } - + for (i = 0; !inf && (i < nchildren); i++) inf = getchildren (dpy, children[i], WM_STATE); - + if (children != None) XFree ((char *) children); - + return inf; } @@ -4234,8 +4234,8 @@ getchildren (Display *dpy, * modification of the XmuClientWindow() routine from X11R6.3 */ Window -gdk_get_client_window (Display *dpy, - Window win) +gdk_get_client_window (Display *dpy, + Window win) { Atom WM_STATE; Atom type = None; @@ -4243,20 +4243,20 @@ gdk_get_client_window (Display *dpy, unsigned long nitems, after; unsigned char *data; Window inf; - + if (win == 0) return DefaultRootWindow(dpy); - + if ((WM_STATE = XInternAtom (dpy, "WM_STATE", True)) == 0) return win; - + XGetWindowProperty (dpy, win, WM_STATE, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &data); if (type) return win; - + inf = getchildren (dpy, win, WM_STATE); - + if (inf == 0) return win; else @@ -4273,13 +4273,13 @@ gdk_drop_get_real_window (GdkWindow *w, GdkWindowPrivate *awin; GList *children; gint16 myx = *x, myy = *y; - + g_return_val_if_fail (w != NULL && x != NULL && y != NULL, NULL); - + myx = *x; myy = *y; - -descend: + + descend: for (children = gdk_window_get_children(retval); children && children->next; children = children->next) @@ -4295,10 +4295,10 @@ descend: goto descend; } } - + *x = myx; *y = myy; - + return retval; } #endif @@ -4311,9 +4311,9 @@ gdk_event_send_clientmessage_toall (GdkEvent *event) Window *ret_children, ret_root, ret_parent, curwin; unsigned int ret_nchildren; int i; - + g_return_if_fail(event != NULL); - + /* Set up our event to send, with the exception of its target window */ sev.xclient.type = ClientMessage; sev.xclient.display = gdk_display; @@ -4321,21 +4321,21 @@ gdk_event_send_clientmessage_toall (GdkEvent *event) sev.xclient.serial = CurrentTime; memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data)); sev.xclient.message_type = event->client.message_type; - + /* OK, we're all set, now let's find some windows to send this to */ if(XQueryTree(gdk_display, gdk_root_window, &ret_root, &ret_parent, &ret_children, &ret_nchildren) != True) return; - + /* foreach true child window of the root window, send an event to it */ for(i = 0; i < ret_nchildren; i++) { curwin = gdk_get_client_window(gdk_display, ret_children[i]); sev.xclient.window = curwin; if (!gdk_send_xevent (curwin, False, NoEventMask, &sev)) - GDK_NOTE (MISC, g_print("Gdk: Sending client message %ld to %#lx failed\n", - event->client.message_type, curwin)); + GDK_NOTE (MISC, g_message ("Sending client message %ld to %#lx failed", + event->client.message_type, curwin)); } - + XFree(ret_children); } @@ -4357,7 +4357,7 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask, result = XSendEvent (gdk_display, window, propagate, event_mask, event_send); XSync (gdk_display, False); gdk_error_warnings = 1; - + return result && (gdk_error_code != -1); } @@ -4371,13 +4371,13 @@ gdkx_XConvertCase (KeySym symbol, KeySym *upper) { register KeySym sym = symbol; - + g_return_if_fail (lower != NULL); g_return_if_fail (upper != NULL); - + *lower = sym; *upper = sym; - + switch (sym >> 8) { #if defined (GDK_A) && defined (GDK_Ooblique) @@ -4472,7 +4472,7 @@ gdkx_XConvertCase (KeySym symbol, *upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu); break; #endif /* CYRILLIC */ - + #if defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma) case 7: /* Greek */ /* Assume the KeySym is a legal value (ignore discontinuities) */ @@ -4494,7 +4494,7 @@ gdkx_XConvertCase (KeySym symbol, #endif gchar* -gdk_keyval_name (guint keyval) +gdk_keyval_name (guint keyval) { return XKeysymToString (keyval); } @@ -4503,18 +4503,18 @@ guint gdk_keyval_from_name (const gchar *keyval_name) { g_return_val_if_fail (keyval_name != NULL, 0); - + return XStringToKeysym (keyval_name); } guint -gdk_keyval_to_upper (guint keyval) +gdk_keyval_to_upper (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return upper_val; } @@ -4522,13 +4522,13 @@ gdk_keyval_to_upper (guint keyval) } guint -gdk_keyval_to_lower (guint keyval) +gdk_keyval_to_lower (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return lower_val; } @@ -4536,13 +4536,13 @@ gdk_keyval_to_lower (guint keyval) } gboolean -gdk_keyval_is_upper (guint keyval) +gdk_keyval_is_upper (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return upper_val == keyval; } @@ -4550,13 +4550,13 @@ gdk_keyval_is_upper (guint keyval) } gboolean -gdk_keyval_is_lower (guint keyval) +gdk_keyval_is_lower (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return lower_val == keyval; } diff --git a/gdk/gdkcc.c b/gdk/gdkcc.c index 12631a0772..df7c0a7833 100644 --- a/gdk/gdkcc.c +++ b/gdk/gdkcc.c @@ -69,7 +69,7 @@ static guint hash_color (gconstpointer key) { const GdkColor *color = key; - + return (color->red * 33023 + color->green * 30013 + color->blue * 27011); } @@ -79,7 +79,7 @@ compare_colors (gconstpointer a, { const GdkColor *aa = a; const GdkColor *bb = b; - + return ((aa->red == bb->red) && (aa->green == bb->green) && (aa->blue == bb->blue)); } @@ -108,20 +108,20 @@ my_x_query_colors (GdkColormap *colormap, { XColor *xcolors; gint i; - + xcolors = g_new (XColor, ncolors); for (i = 0; i < ncolors; i++) xcolors[i].pixel = colors[i].pixel; - + XQueryColors (gdk_display, GDK_COLORMAP_XCOLORMAP (colormap), xcolors, ncolors); - + for (i = 0; i < ncolors; i++) { colors[i].red = xcolors[i].red; colors[i].green = xcolors[i].green; colors[i].blue = xcolors[i].blue; } - + g_free (xcolors); } @@ -131,12 +131,12 @@ query_colors (GdkColorContext *cc) gint i; GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; cc->cmap = g_new (GdkColor, cc->num_colors); - + for (i = 0; i < cc->num_colors; i++) cc->cmap[i].pixel = cc->clut ? cc->clut[i] : ccp->std_cmap.base_pixel + i; - + my_x_query_colors (cc->colormap, cc->cmap, cc->num_colors); - + qsort (cc->cmap, cc->num_colors, sizeof (GdkColor), pixel_sort); } @@ -144,25 +144,25 @@ static void init_bw (GdkColorContext *cc) { GdkColor color; - + g_warning ("init_bw: failed to allocate colors, falling back to black and white"); - + cc->mode = GDK_CC_MODE_BW; - + color.red = color.green = color.blue = 0; if (!gdk_color_alloc (cc->colormap, &color)) cc->black_pixel = 0; else cc->black_pixel = color.pixel; - + color.red = color.green = color.blue = 0xffff; if (!gdk_color_alloc (cc->colormap, &color)) cc->white_pixel = cc->black_pixel ? 0 : 1; else cc->white_pixel = color.pixel; - + cc->num_colors = 2; } @@ -173,28 +173,28 @@ init_gray (GdkColorContext *cc) GdkColor *clrs, *cstart; gint i; gdouble dinc; - + cc->num_colors = GDK_VISUAL_XVISUAL (cc->visual)->map_entries; - + cc->clut = g_new (gulong, cc->num_colors); cstart = g_new (GdkColor, cc->num_colors); - -retrygray: - + + retrygray: + dinc = 65535.0 / (cc->num_colors - 1); - + clrs = cstart; - + for (i = 0; i < cc->num_colors; i++) { clrs->red = clrs->green = clrs->blue = dinc * i; - + if (!gdk_color_alloc (cc->colormap, clrs)) { gdk_colors_free (cc->colormap, cc->clut, i, 0); - + cc->num_colors /= 2; - + if (cc->num_colors > 1) goto retrygray; else @@ -206,12 +206,12 @@ retrygray: return; } } - + cc->clut[i] = clrs++->pixel; } - + g_free (cstart); - + /* XXX: is this the right thing to do? */ ccp->std_cmap.colormap = GDK_COLORMAP_XCOLORMAP (cc->colormap); ccp->std_cmap.base_pixel = 0; @@ -221,12 +221,12 @@ retrygray: ccp->std_cmap.red_mult = 1; ccp->std_cmap.green_mult = 0; ccp->std_cmap.blue_mult = 0; - + cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen); cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen); - + query_colors (cc); - + cc->mode = GDK_CC_MODE_MY_GRAY; } @@ -235,14 +235,14 @@ init_color (GdkColorContext *cc) { GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; gint cubeval; - + cubeval = 1; while ((cubeval * cubeval * cubeval) < GDK_VISUAL_XVISUAL (cc->visual)->map_entries) cubeval++; cubeval--; - + cc->num_colors = cubeval * cubeval * cubeval; - + ccp->std_cmap.red_max = cubeval - 1; ccp->std_cmap.green_max = cubeval - 1; ccp->std_cmap.blue_max = cubeval - 1; @@ -250,21 +250,21 @@ init_color (GdkColorContext *cc) ccp->std_cmap.green_mult = cubeval; ccp->std_cmap.blue_mult = 1; ccp->std_cmap.base_pixel = 0; - + cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen); cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen); cc->num_colors = DisplayCells (ccp->xdisplay, gdk_screen); - + /* a CLUT for storing allocated pixel indices */ - + cc->max_colors = cc->num_colors; cc->clut = g_new (gulong, cc->max_colors); - + for (cubeval = 0; cubeval < cc->max_colors; cubeval++) cc->clut[cubeval] = cubeval; - + query_colors (cc); - + cc->mode = GDK_CC_MODE_STD_CMAP; } @@ -274,66 +274,66 @@ init_true_color (GdkColorContext *cc) { GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; gulong rmask, gmask, bmask; - + cc->mode = GDK_CC_MODE_TRUE; - + /* Red */ - + rmask = cc->masks.red = cc->visual->red_mask; - + cc->shifts.red = 0; cc->bits.red = 0; - + while (!(rmask & 1)) { rmask >>= 1; cc->shifts.red++; } - + while (rmask & 1) { rmask >>= 1; cc->bits.red++; } - + /* Green */ - + gmask = cc->masks.green = cc->visual->green_mask; - + cc->shifts.green = 0; cc->bits.green = 0; - + while (!(gmask & 1)) { gmask >>= 1; cc->shifts.green++; } - + while (gmask & 1) { gmask >>= 1; cc->bits.green++; } - + /* Blue */ - + bmask = cc->masks.blue = cc->visual->blue_mask; - + cc->shifts.blue = 0; cc->bits.blue = 0; - + while (!(bmask & 1)) { bmask >>= 1; cc->shifts.blue++; } - + while (bmask & 1) { bmask >>= 1; cc->bits.blue++; } - + cc->num_colors = (cc->visual->red_mask | cc->visual->green_mask | cc->visual->blue_mask) + 1; cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen); cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen); @@ -349,49 +349,49 @@ init_direct_color (GdkColorContext *cc) gulong *gtable; gulong *btable; gdouble dinc; - + init_true_color (cc); /* for shift stuff */ - + rval = cc->visual->red_mask >> cc->shifts.red; gval = cc->visual->green_mask >> cc->shifts.green; bval = cc->visual->blue_mask >> cc->shifts.blue; - + rtable = g_new (gulong, rval + 1); gtable = g_new (gulong, gval + 1); btable = g_new (gulong, bval + 1); - + cc->max_entry = MAX (rval, gval); cc->max_entry = MAX (cc->max_entry, bval); - + cstart = g_new (GdkColor, cc->max_entry + 1); cc->clut = g_new (gulong, cc->max_entry + 1); - -retrydirect: - + + retrydirect: + for (n = 0; n < rval; n++) rtable[n] = rval ? (65535.0 / rval * n) : 0; - + for (n = 0; n < gval; n++) gtable[n] = gval ? (65535.0 / gval * n) : 0; - + for (n = 0; n < bval; n++) btable[n] = bval ? (65535.0 / bval * n) : 0; - + cc->max_entry = MAX (rval, gval); cc->max_entry = MAX (cc->max_entry, bval); - + count = 0; clrs = cstart; cc->num_colors = (rval + 1) * (gval + 1) * (bval + 1); - + for (n = 0; n < cc->max_entry; n++) { dinc = (double) n / cc->max_entry; - + clrs->red = rtable[(int) (dinc * rval)]; clrs->green = gtable[(int) (dinc * gval)]; clrs->blue = btable[(int) (dinc * bval)]; - + if (gdk_color_alloc (cc->colormap, clrs)) { cc->clut[count++] = clrs->pixel; @@ -400,25 +400,25 @@ retrydirect: else { gdk_colors_free (cc->colormap, cc->clut, count, 0); - + rval >>= 1; gval >>= 1; bval >>= 1; - + cc->masks.red = (cc->masks.red >> 1) & cc->visual->red_mask; cc->masks.green = (cc->masks.green >> 1) & cc->visual->green_mask; cc->masks.blue = (cc->masks.blue >> 1) & cc->visual->blue_mask; - + cc->shifts.red++; cc->shifts.green++; cc->shifts.blue++; - + cc->bits.red--; cc->bits.green--; cc->bits.blue--; - + cc->num_colors = (rval + 1) * (gval + 1) * (bval + 1); - + if (cc->num_colors >1) goto retrydirect; else @@ -430,13 +430,13 @@ retrydirect: } } } - + /* Update allocated color count; original num_colors is max_entry, which * is not necessarily the same as the really allocated number of colors. */ - + cc->num_colors = count; - + g_free (rtable); g_free (gtable); g_free (btable); @@ -447,7 +447,7 @@ static void init_palette (GdkColorContext *cc) { /* restore correct mode for this cc */ - + switch (cc->visual->type) { case GDK_VISUAL_STATIC_GRAY: @@ -457,40 +457,40 @@ init_palette (GdkColorContext *cc) else cc->mode = GDK_CC_MODE_MY_GRAY; break; - + case GDK_VISUAL_TRUE_COLOR: case GDK_VISUAL_DIRECT_COLOR: cc->mode = GDK_CC_MODE_TRUE; break; - + case GDK_VISUAL_STATIC_COLOR: case GDK_VISUAL_PSEUDO_COLOR: cc->mode = GDK_CC_MODE_STD_CMAP; break; - + default: cc->mode = GDK_CC_MODE_UNDEFINED; break; } - + /* previous palette */ - + if (cc->num_palette) g_free (cc->palette); - + if (cc->fast_dither) g_free (cc->fast_dither); - + /* clear hash table if present */ - + if (cc->color_hash) { /* XXX: quick-and-dirty way to remove everything */ - + g_hash_table_destroy (cc->color_hash); cc->color_hash = g_hash_table_new (hash_color, compare_colors); } - + cc->palette = NULL; cc->num_palette = 0; cc->fast_dither = NULL; @@ -505,10 +505,10 @@ gdk_color_context_new (GdkVisual *visual, GdkColorContext *cc; gint retry_count; GdkColormap *default_colormap; - + g_assert (visual != NULL); g_assert (colormap != NULL); - + ccp = g_new (GdkColorContextPrivate, 1); cc = (GdkColorContext *) ccp; ccp->xdisplay = gdk_display; @@ -518,16 +518,16 @@ gdk_color_context_new (GdkVisual *visual, cc->cmap = NULL; cc->mode = GDK_CC_MODE_UNDEFINED; cc->need_to_free_colormap = FALSE; - + cc->color_hash = NULL; cc->palette = NULL; cc->num_palette = 0; cc->fast_dither = NULL; - + default_colormap = gdk_colormap_get_system (); - + retry_count = 0; - + while (retry_count < 2) { /* Only create a private colormap if the visual found isn't equal @@ -535,66 +535,66 @@ gdk_color_context_new (GdkVisual *visual, * -or- if we are instructed to create a private colormap (which * never is the case for XmHTML). */ - + if (use_private_colormap || ((cc->visual != gdk_visual_get_system ()) /* default visual? */ && (GDK_COLORMAP_XCOLORMAP (colormap) == GDK_COLORMAP_XCOLORMAP (default_colormap)))) { g_warning ("gdk_color_context_new: non-default visual detected, " "using private colormap"); - + cc->colormap = gdk_colormap_new (cc->visual, FALSE); - + cc->need_to_free_colormap = (GDK_COLORMAP_XCOLORMAP (colormap) != GDK_COLORMAP_XCOLORMAP (default_colormap)); } - + switch (visual->type) { case GDK_VISUAL_STATIC_GRAY: case GDK_VISUAL_GRAYSCALE: GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is %s\n", - (visual->type == GDK_VISUAL_STATIC_GRAY) ? - "GDK_VISUAL_STATIC_GRAY" : - "GDK_VISUAL_GRAYSCALE")); - + g_message ("gdk_color_context_new: visual class is %s\n", + (visual->type == GDK_VISUAL_STATIC_GRAY) ? + "GDK_VISUAL_STATIC_GRAY" : + "GDK_VISUAL_GRAYSCALE")); + if (GDK_VISUAL_XVISUAL (cc->visual)->map_entries == 2) init_bw (cc); else init_gray (cc); - + break; - + case GDK_VISUAL_TRUE_COLOR: /* shifts */ GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n")); - + g_message ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n")); + init_true_color (cc); break; - + case GDK_VISUAL_DIRECT_COLOR: /* shifts and fake CLUT */ GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n")); - + g_message ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n")); + init_direct_color (cc); break; - + case GDK_VISUAL_STATIC_COLOR: case GDK_VISUAL_PSEUDO_COLOR: GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is %s\n", - (visual->type == GDK_VISUAL_STATIC_COLOR) ? - "GDK_VISUAL_STATIC_COLOR" : - "GDK_VISUAL_PSEUDO_COLOR")); - + g_message ("gdk_color_context_new: visual class is %s\n", + (visual->type == GDK_VISUAL_STATIC_COLOR) ? + "GDK_VISUAL_STATIC_COLOR" : + "GDK_VISUAL_PSEUDO_COLOR")); + init_color (cc); break; - + default: g_assert_not_reached (); } - + if ((cc->mode == GDK_CC_MODE_BW) && (cc->visual->depth > 1)) { use_private_colormap = TRUE; @@ -603,20 +603,20 @@ gdk_color_context_new (GdkVisual *visual, else break; } - + /* no. of colors allocated yet */ - + cc->num_allocated = 0; - + GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n", - cc->visual->depth, cc->num_colors)); - + g_message ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n", + cc->visual->depth, cc->num_colors)); + /* check if we need to initialize a hash table */ - + if ((cc->mode == GDK_CC_MODE_STD_CMAP) || (cc->mode == GDK_CC_MODE_UNDEFINED)) cc->color_hash = g_hash_table_new (hash_color, compare_colors); - + return (GdkColorContext *) cc; } @@ -626,10 +626,10 @@ gdk_color_context_new_mono (GdkVisual *visual, { GdkColorContextPrivate *ccp; GdkColorContext *cc; - + g_assert (visual != NULL); g_assert (colormap != NULL); - + cc = g_new (GdkColorContext, 1); ccp = (GdkColorContextPrivate *) cc; ccp->xdisplay = gdk_display; @@ -639,9 +639,9 @@ gdk_color_context_new_mono (GdkVisual *visual, cc->cmap = NULL; cc->mode = GDK_CC_MODE_UNDEFINED; cc->need_to_free_colormap = FALSE; - + init_bw (cc); - + return (GdkColorContext *) cc; } @@ -651,7 +651,7 @@ void gdk_color_context_free (GdkColorContext *cc) { g_assert (cc != NULL); - + if ((cc->visual->type == GDK_VISUAL_STATIC_COLOR) || (cc->visual->type == GDK_VISUAL_PSEUDO_COLOR)) { @@ -663,17 +663,17 @@ gdk_color_context_free (GdkColorContext *cc) gdk_colors_free (cc->colormap, cc->clut, cc->num_colors, 0); g_free (cc->clut); } - + if (cc->cmap != NULL) g_free (cc->cmap); - + if (cc->need_to_free_colormap) gdk_colormap_unref (cc->colormap); - + /* free any palette that has been associated with this GdkColorContext */ - + init_palette (cc); - + if (cc->color_hash) { g_hash_table_foreach (cc->color_hash, @@ -681,7 +681,7 @@ gdk_color_context_free (GdkColorContext *cc) NULL); g_hash_table_destroy (cc->color_hash); } - + g_free (cc); } @@ -695,146 +695,146 @@ gdk_color_context_get_pixel (GdkColorContext *cc, GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; g_assert (cc != NULL); g_assert (failed != NULL); - + *failed = FALSE; - + switch (cc->mode) { case GDK_CC_MODE_BW: - { - gdouble value; - - value = (red / 65535.0 * 0.30 - + green / 65535.0 * 0.59 - + blue / 65535.0 * 0.11); - - if (value > 0.5) - return cc->white_pixel; - - return cc->black_pixel; - } - + { + gdouble value; + + value = (red / 65535.0 * 0.30 + + green / 65535.0 * 0.59 + + blue / 65535.0 * 0.11); + + if (value > 0.5) + return cc->white_pixel; + + return cc->black_pixel; + } + case GDK_CC_MODE_MY_GRAY: - { - gulong ired, igreen, iblue; - - red = red * 0.30 + green * 0.59 + blue * 0.11; - green = 0; - blue = 0; - - if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max) - ired = ccp->std_cmap.red_max; - - ired *= ccp->std_cmap.red_mult; - - if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max) - igreen = ccp->std_cmap.green_max; - - igreen *= ccp->std_cmap.green_mult; - - if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max) - iblue = ccp->std_cmap.blue_max; - - iblue *= ccp->std_cmap.blue_mult; - - if (cc->clut != NULL) - return cc->clut[ccp->std_cmap.base_pixel + ired + igreen + iblue]; - - return ccp->std_cmap.base_pixel + ired + igreen + iblue; - } - + { + gulong ired, igreen, iblue; + + red = red * 0.30 + green * 0.59 + blue * 0.11; + green = 0; + blue = 0; + + if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max) + ired = ccp->std_cmap.red_max; + + ired *= ccp->std_cmap.red_mult; + + if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max) + igreen = ccp->std_cmap.green_max; + + igreen *= ccp->std_cmap.green_mult; + + if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max) + iblue = ccp->std_cmap.blue_max; + + iblue *= ccp->std_cmap.blue_mult; + + if (cc->clut != NULL) + return cc->clut[ccp->std_cmap.base_pixel + ired + igreen + iblue]; + + return ccp->std_cmap.base_pixel + ired + igreen + iblue; + } + case GDK_CC_MODE_TRUE: - { - gulong ired, igreen, iblue; - - if (cc->clut == NULL) - { - red >>= 16 - cc->bits.red; - green >>= 16 - cc->bits.green; - blue >>= 16 - cc->bits.blue; - - ired = (red << cc->shifts.red) & cc->masks.red; - igreen = (green << cc->shifts.green) & cc->masks.green; - iblue = (blue << cc->shifts.blue) & cc->masks.blue; - - return ired | igreen | iblue; - } - - ired = cc->clut[red * cc->max_entry / 65535] & cc->masks.red; - igreen = cc->clut[green * cc->max_entry / 65535] & cc->masks.green; - iblue = cc->clut[blue * cc->max_entry / 65535] & cc->masks.blue; - - return ired | igreen | iblue; - } - + { + gulong ired, igreen, iblue; + + if (cc->clut == NULL) + { + red >>= 16 - cc->bits.red; + green >>= 16 - cc->bits.green; + blue >>= 16 - cc->bits.blue; + + ired = (red << cc->shifts.red) & cc->masks.red; + igreen = (green << cc->shifts.green) & cc->masks.green; + iblue = (blue << cc->shifts.blue) & cc->masks.blue; + + return ired | igreen | iblue; + } + + ired = cc->clut[red * cc->max_entry / 65535] & cc->masks.red; + igreen = cc->clut[green * cc->max_entry / 65535] & cc->masks.green; + iblue = cc->clut[blue * cc->max_entry / 65535] & cc->masks.blue; + + return ired | igreen | iblue; + } + case GDK_CC_MODE_PALETTE: return gdk_color_context_get_pixel_from_palette (cc, &red, &green, &blue, failed); - + case GDK_CC_MODE_STD_CMAP: default: - { - GdkColor color; - GdkColor *result; - - color.red = red; - color.green = green; - color.blue = blue; - - result = g_hash_table_lookup (cc->color_hash, &color); - - if (!result) - { - color.red = red; - color.green = green; - color.blue = blue; - color.pixel = 0; - - if (!gdk_color_alloc (cc->colormap, &color)) - *failed = TRUE; - else - { - GdkColor *cnew; - - /* XXX: the following comment comes directly from - * XCC.c. I don't know if it is relevant for - * gdk_color_alloc() as it is for XAllocColor() - * - Federico - */ - /* - * I can't figure this out entirely, but it *is* possible - * that XAllocColor succeeds, even if the number of - * allocations we've made exceeds the number of available - * colors in the current colormap. And therefore it - * might be necessary for us to resize the CLUT. - */ - - if (cc->num_allocated == cc->max_colors) - { - cc->max_colors *= 2; - - GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixel: " - "resizing CLUT to %i entries\n", - cc->max_colors)); - - cc->clut = g_realloc (cc->clut, - cc->max_colors * sizeof (gulong)); - } - - /* Key and value are the same color structure */ - - cnew = g_new (GdkColor, 1); - *cnew = color; - g_hash_table_insert (cc->color_hash, cnew, cnew); - - cc->clut[cc->num_allocated] = color.pixel; - cc->num_allocated++; - return color.pixel; - } - } - - return result->pixel; - } + { + GdkColor color; + GdkColor *result; + + color.red = red; + color.green = green; + color.blue = blue; + + result = g_hash_table_lookup (cc->color_hash, &color); + + if (!result) + { + color.red = red; + color.green = green; + color.blue = blue; + color.pixel = 0; + + if (!gdk_color_alloc (cc->colormap, &color)) + *failed = TRUE; + else + { + GdkColor *cnew; + + /* XXX: the following comment comes directly from + * XCC.c. I don't know if it is relevant for + * gdk_color_alloc() as it is for XAllocColor() + * - Federico + */ + /* + * I can't figure this out entirely, but it *is* possible + * that XAllocColor succeeds, even if the number of + * allocations we've made exceeds the number of available + * colors in the current colormap. And therefore it + * might be necessary for us to resize the CLUT. + */ + + if (cc->num_allocated == cc->max_colors) + { + cc->max_colors *= 2; + + GDK_NOTE (COLOR_CONTEXT, + g_message ("gdk_color_context_get_pixel: " + "resizing CLUT to %i entries\n", + cc->max_colors)); + + cc->clut = g_realloc (cc->clut, + cc->max_colors * sizeof (gulong)); + } + + /* Key and value are the same color structure */ + + cnew = g_new (GdkColor, 1); + *cnew = color; + g_hash_table_insert (cc->color_hash, cnew, cnew); + + cc->clut[cc->num_allocated] = color.pixel; + cc->num_allocated++; + return color.pixel; + } + } + + return result->pixel; + } } } @@ -861,37 +861,37 @@ gdk_color_context_get_pixels (GdkColorContext *cc, g_assert (blues != NULL); g_assert (colors != NULL); g_assert (nallocated != NULL); - + memset (defs, 0, MAX_IMAGE_COLORS * sizeof (GdkColor)); memset (failed, 0, MAX_IMAGE_COLORS * sizeof (gint)); memset (allocated, 0, MAX_IMAGE_COLORS * sizeof (gint)); - + /* Will only have a value if used by the progressive image loader */ - + ncols = *nallocated; - + *nallocated = 0; - + /* First allocate all pixels */ - + for (i = 0; i < ncolors; i++) { /* colors[i] is only zero if the pixel at that location hasn't * been allocated yet. This is a sanity check required for proper * color allocation by the progressive image loader */ - + if (colors[i] == 0) { defs[i].red = reds[i]; defs[i].green = greens[i]; defs[i].blue = blues[i]; - + colors[i] = gdk_color_context_get_pixel (cc, reds[i], greens[i], blues[i], &bad_alloc); - + /* successfully allocated, store it */ - + if (!bad_alloc) { defs[i].pixel = colors[i]; @@ -901,114 +901,114 @@ gdk_color_context_get_pixels (GdkColorContext *cc, failed[nopen++] = i; } } - + *nallocated = ncols; - + /* all colors available, all done */ - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels: got all %i colors; " - "(%i colors allocated so far)\n", ncolors, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels: got all %i colors; " + "(%i colors allocated so far)\n", ncolors, cc->num_allocated)); + return; } - + /* The fun part. We now try to allocate the colors we couldn't allocate * directly. The first step will map a color onto its nearest color * that has been allocated (either by us or someone else). If any colors * remain unallocated, we map these onto the colors that we have allocated * ourselves. */ - + /* read up to MAX_IMAGE_COLORS colors of the current colormap */ - + cmapsize = MIN (cc->num_colors, MAX_IMAGE_COLORS); - + /* see if the colormap has any colors to read */ - + if (cmapsize < 0) { g_warning ("gdk_color_context_get_pixels: oops! no colors available, " "your images will look *really* ugly."); - + return; } - + #ifdef G_ENABLE_DEBUG exact_col = ncols; #endif - + /* initialize pixels */ - + for (i = 0; i < cmapsize; i++) { cmap[i].pixel = i; cmap[i].red = cmap[i].green = cmap[i].blue = 0; } - + /* read the colormap */ - + my_x_query_colors (cc->colormap, cmap, cmapsize); - + /* get a close match for any unallocated colors */ - + counter = nopen; nopen = 0; idx = 0; - + do { gint d, j, mdist, close, ri, gi, bi; gint rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + /* Store these vals. Small performance increase as this skips three * indexing operations in the loop code. */ - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + /* Walk all colors in the colormap and see which one is the * closest. Uses plain least squares. */ - + for (j = 0; (j < cmapsize) && (mdist != 0); j++) { /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - cmap[j].red) / 256; gd = (gi - cmap[j].green) / 256; bd = (bi - cmap[j].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = j; mdist = d; } } - + if (close != -1) { rd = cmap[close].red; gd = cmap[close].green; bd = cmap[close].blue; - + /* allocate */ - + colors[i] = gdk_color_context_get_pixel (cc, rd, gd, bd, &bad_alloc); - + /* store */ - + if (!bad_alloc) { defs[i] = cmap[close]; @@ -1024,68 +1024,68 @@ gdk_color_context_get_pixels (GdkColorContext *cc, /* deal with in next stage if allocation failed */ } while (++idx < counter); - + *nallocated = ncols; - + /* This is the maximum no. of allocated colors. See also the nopen == 0 * note above. */ - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels: got %i colors, %i exact and " - "%i close (%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels: got %i colors, %i exact and " + "%i close (%i colors allocated so far)\n", + ncolors, exact_col, close_col, cc->num_allocated)); + return; } - + /* Now map any remaining unallocated pixels into the colors we did get */ - + idx = 0; - + do { gint d, mdist, close, ri, gi, bi; gint j, rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + /* store */ - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + /* search allocated colors */ - + for (j = 0; (j < ncols) && (mdist != 0); j++) { k = allocated[j]; - + /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - defs[k].red) / 256; gd = (gi - defs[k].green) / 256; bd = (bi - defs[k].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = k; mdist = d; } } - + if (close < 0) { /* too bad, map to black */ - + defs[i].pixel = cc->black_pixel; defs[i].red = defs[i].green = defs[i].blue = 0; #ifdef G_ENABLE_DEBUG @@ -1099,15 +1099,15 @@ gdk_color_context_get_pixels (GdkColorContext *cc, subst_col++; #endif } - + colors[i] = defs[i].pixel; } while (++idx < nopen); - + GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels: got %i colors, %i exact, %i close, " - "%i substituted, %i to black (%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); + g_message ("gdk_color_context_get_pixels: got %i colors, %i exact, %i close, " + "%i substituted, %i to black (%i colors allocated so far)\n", + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } void @@ -1128,7 +1128,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, #ifdef G_ENABLE_DEBUG gint exact_col = 0, subst_col = 0, close_col = 0, black_col = 0; #endif - + g_assert (cc != NULL); g_assert (reds != NULL); g_assert (greens != NULL); @@ -1136,19 +1136,19 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, g_assert (used != NULL); g_assert (colors != NULL); g_assert (nallocated != NULL); - + memset (defs, 0, MAX_IMAGE_COLORS * sizeof (GdkColor)); memset (failed, 0, MAX_IMAGE_COLORS * sizeof (gint)); memset (allocated, 0, MAX_IMAGE_COLORS * sizeof (gint)); - + /* Will only have a value if used by the progressive image loader */ - + ncols = *nallocated; - + *nallocated = 0; - + /* First allocate all pixels */ - + for (i = 0; i < ncolors; i++) { /* used[i] is only -1 if the pixel at that location hasn't @@ -1157,7 +1157,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, * When colors[i] == 0 it indicates the slot is available for * allocation. */ - + if (used[i] != FALSE) { if (colors[i] == 0) @@ -1165,11 +1165,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, defs[i].red = reds[i]; defs[i].green = greens[i]; defs[i].blue = blues[i]; - + colors[i] = gdk_color_context_get_pixel (cc, reds[i], greens[i], blues[i], &bad_alloc); - + /* successfully allocated, store it */ - + if (!bad_alloc) { defs[i].pixel = colors[i]; @@ -1181,100 +1181,100 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, #ifdef DEBUG else GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: " - "pixel at slot %i already allocated, skipping\n", i)); + g_message ("gdk_color_context_get_pixels_incremental: " + "pixel at slot %i already allocated, skipping\n", i)); #endif } } - + *nallocated = ncols; - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: got all %i colors " - "(%i colors allocated so far)\n", - ncolors, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels_incremental: got all %i colors " + "(%i colors allocated so far)\n", + ncolors, cc->num_allocated)); + return; } - + cmapsize = MIN (cc->num_colors, MAX_IMAGE_COLORS); - + if (cmapsize < 0) { g_warning ("gdk_color_context_get_pixels_incremental: oops! " "No colors available images will look *really* ugly."); return; } - + #ifdef G_ENABLE_DEBUG exact_col = ncols; #endif - + /* initialize pixels */ - + for (i = 0; i < cmapsize; i++) { cmap[i].pixel = i; cmap[i].red = cmap[i].green = cmap[i].blue = 0; } - + /* read */ - + my_x_query_colors (cc->colormap, cmap, cmapsize); - + /* now match any unallocated colors */ - + counter = nopen; nopen = 0; idx = 0; - + do { gint d, j, mdist, close, ri, gi, bi; gint rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + /* store */ - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + for (j = 0; (j < cmapsize) && (mdist != 0); j++) { /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - cmap[j].red) / 256; gd = (gi - cmap[j].green) / 256; bd = (bi - cmap[j].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = j; mdist = d; } } - + if (close != -1) { rd = cmap[close].red; gd = cmap[close].green; bd = cmap[close].blue; - + /* allocate */ - + colors[i] = gdk_color_context_get_pixel (cc, rd, gd, bd, &bad_alloc); - + /* store */ - + if (!bad_alloc) { defs[i] = cmap[close]; @@ -1292,64 +1292,64 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, /* deal with in next stage if allocation failed */ } while (++idx < counter); - + *nallocated = ncols; - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: " - "got %i colors, %i exact and %i close " - "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels_incremental: " + "got %i colors, %i exact and %i close " + "(%i colors allocated so far)\n", + ncolors, exact_col, close_col, cc->num_allocated)); + return; } - + /* map remaining unallocated pixels into colors we did get */ - + idx = 0; - + do { gint d, mdist, close, ri, gi, bi; gint j, rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + /* search allocated colors */ - + for (j = 0; (j < ncols) && (mdist != 0); j++) { k = allocated[j]; - + /* downscale */ /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - defs[k].red) / 256; gd = (gi - defs[k].green) / 256; bd = (bi - defs[k].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = k; mdist = d; } } - + if (close < 0) { /* too bad, map to black */ - + defs[i].pixel = cc->black_pixel; defs[i].red = defs[i].green = defs[i].blue = 0; #ifdef G_ENABLE_DEBUG @@ -1363,16 +1363,16 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, subst_col++; #endif } - + colors[i] = defs[i].pixel; } while (++idx < nopen); - + GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: " - "got %i colors, %i exact, %i close, %i substituted, %i to black " - "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); + g_message ("gdk_color_context_get_pixels_incremental: " + "got %i colors, %i exact, %i close, %i substituted, %i to black " + "(%i colors allocated so far)\n", + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } gint @@ -1389,10 +1389,10 @@ gdk_color_context_query_colors (GdkColorContext *cc, { gint i; GdkColor *tc; - + g_assert (cc != NULL); g_assert (colors != NULL); - + switch (cc->mode) { case GDK_CC_MODE_BW: @@ -1404,7 +1404,7 @@ gdk_color_context_query_colors (GdkColorContext *cc, tc->red = tc->green = tc->blue = 0; } break; - + case GDK_CC_MODE_TRUE: if (cc->clut == NULL) for (i = 0, tc = colors; i < num_colors; i++, tc++) @@ -1419,7 +1419,7 @@ gdk_color_context_query_colors (GdkColorContext *cc, return 1; } break; - + case GDK_CC_MODE_STD_CMAP: default: if (cc->cmap == NULL) @@ -1431,17 +1431,17 @@ gdk_color_context_query_colors (GdkColorContext *cc, { gint first, last, half; gulong half_pixel; - + for (i = 0, tc = colors; i < num_colors; i++) { first = 0; last = cc->num_colors - 1; - + while (first <= last) { half = (first + last) / 2; half_pixel = cc->cmap[half].pixel; - + if (tc->pixel == half_pixel) { tc->red = cc->cmap[half].red; @@ -1473,94 +1473,94 @@ gdk_color_context_add_palette (GdkColorContext *cc, gint i, j, erg; gushort r, g, b; gulong pixel[1]; - + g_assert (cc != NULL); - + /* initialize this palette (will also erase previous palette as well) */ - + init_palette (cc); - + /* restore previous mode if we aren't adding a new palette */ - + if (num_palette == 0) { /* GDK_CC_MODE_STD_CMAP uses a hash table, so we'd better initialize one */ - + /* XXX: here, the hash table is already initialized */ - + return 0; } - + /* Initialize a hash table for this palette (we need one for allocating * the pixels in the palette using the current settings) */ - + if (cc->color_hash == NULL) cc->color_hash = g_hash_table_new (hash_color, compare_colors); - + /* copy incoming palette */ - + cc->palette = g_new0(GdkColor, num_palette); - + j = 0; - + for (i = 0; i < num_palette; i++) { erg = 0; pixel[0] = 0; - + /* try to allocate this color */ - + r = palette[i].red; g = palette[i].green; b = palette[i].blue; - + gdk_color_context_get_pixels (cc, &r, &g, &b, 1, pixel, &erg); - + /* only store if we succeed */ - + if (erg) { /* store in palette */ - + cc->palette[j].red = r; cc->palette[j].green = g; cc->palette[j].blue = b; cc->palette[j].pixel = pixel[0]; - + /* move to next slot */ - + j++; } } - + /* resize to fit */ - + if (j != num_palette) cc->palette = g_realloc (cc->palette, j * sizeof (GdkColor)); - + /* clear the hash table, we don't use it when dithering */ - + if (cc->color_hash) { g_hash_table_destroy (cc->color_hash); cc->color_hash = NULL; } - + /* store real palette size */ - + cc->num_palette = j; - + /* switch to palette mode */ - + cc->mode = GDK_CC_MODE_PALETTE; - + /* sort palette */ - + qsort (cc->palette, cc->num_palette, sizeof (GdkColor), pixel_sort); - + cc->fast_dither = NULL; - + return j; } @@ -1569,17 +1569,17 @@ gdk_color_context_init_dither (GdkColorContext *cc) { gint rr, gg, bb, err, erg, erb; gint success = FALSE; - + g_assert (cc != NULL); - + /* now we can initialize the fast dither matrix */ - + if (cc->fast_dither == NULL) cc->fast_dither = g_new (GdkColorContextDither, 1); - + /* Fill it. We ignore unsuccessful allocations, they are just mapped * to black instead */ - + for (rr = 0; rr < 32; rr++) for (gg = 0; gg < 32; gg++) for (bb = 0; bb < 32; bb++) @@ -1587,7 +1587,7 @@ gdk_color_context_init_dither (GdkColorContext *cc) err = (rr << 3) | (rr >> 2); erg = (gg << 3) | (gg >> 2); erb = (bb << 3) | (bb >> 2); - + cc->fast_dither->fast_rgb[rr][gg][bb] = gdk_color_context_get_index_from_palette (cc, &err, &erg, &erb, &success); cc->fast_dither->fast_err[rr][gg][bb] = err; @@ -1600,10 +1600,10 @@ void gdk_color_context_free_dither (GdkColorContext *cc) { g_assert (cc != NULL); - + if (cc->fast_dither) g_free (cc->fast_dither); - + cc->fast_dither = NULL; } @@ -1619,23 +1619,23 @@ gdk_color_context_get_pixel_from_palette (GdkColorContext *cc, gint mindif = 0x7fffffff; gint err = 0, erg = 0, erb = 0; gint i; - + g_assert (cc != NULL); g_assert (red != NULL); g_assert (green != NULL); g_assert (blue != NULL); g_assert (failed != NULL); - + *failed = FALSE; - + for (i = 0; i < cc->num_palette; i++) { dr = *red - cc->palette[i].red; dg = *green - cc->palette[i].green; db = *blue - cc->palette[i].blue; - + dif = dr * dr + dg * dg + db * db; - + if (dif < mindif) { mindif = dif; @@ -1644,14 +1644,14 @@ gdk_color_context_get_pixel_from_palette (GdkColorContext *cc, err = dr; erg = dg; erb = db; - + if (mindif == 0) break; } } - + /* we failed to map onto a color */ - + if (j == -1) *failed = TRUE; else @@ -1660,7 +1660,7 @@ gdk_color_context_get_pixel_from_palette (GdkColorContext *cc, *green = ABS (erg); *blue = ABS (erb); } - + return pixel; } @@ -1675,23 +1675,23 @@ gdk_color_context_get_index_from_palette (GdkColorContext *cc, gint mindif = 0x7fffffff; gint err = 0, erg = 0, erb = 0; gint i; - + g_assert (cc != NULL); g_assert (red != NULL); g_assert (green != NULL); g_assert (blue != NULL); g_assert (failed != NULL); - + *failed = FALSE; - + for (i = 0; i < cc->num_palette; i++) { dr = *red - cc->palette[i].red; dg = *green - cc->palette[i].green; db = *blue - cc->palette[i].blue; - + dif = dr * dr + dg * dg + db * db; - + if (dif < mindif) { mindif = dif; @@ -1699,14 +1699,14 @@ gdk_color_context_get_index_from_palette (GdkColorContext *cc, err = dr; erg = dg; erb = db; - + if (mindif == 0) break; } } - + /* we failed to map onto a color */ - + if (j == -1) { *failed = TRUE; @@ -1715,11 +1715,11 @@ gdk_color_context_get_index_from_palette (GdkColorContext *cc, else { /* return error fractions */ - + *red = err; *green = erg; *blue = erb; } - + return j; } diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index 6a74022c55..331aad7ef7 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -1,3 +1,21 @@ +/* GDK - The GIMP Drawing Kit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ #include <X11/Xlib.h> #include <X11/Xatom.h> #include <string.h> @@ -12,7 +30,7 @@ gdk_dnd_set_drag_cursors(GdkCursor *default_cursor, GdkCursor *goahead_cursor) gdk_dnd.c->gdk_cursor_dragdefault = ((GdkCursorPrivate *)default_cursor)->xcursor; gdk_dnd.c->gdk_cursor_dragok = ((GdkCursorPrivate *)goahead_cursor)->xcursor; - + if(gdk_dnd.dnd_grabbed) { if(gdk_dnd.c->drag_pm_default) @@ -42,7 +60,7 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin, GdkPoint *goahead_hotspot) { g_return_if_fail(default_pixmapwin != NULL); - + g_list_free(gdk_dnd.c->xids); gdk_dnd.c->xids = NULL; if(gdk_dnd.c->drag_pm_default) { @@ -54,9 +72,9 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin, gdk_window_hide(gdk_dnd.c->drag_pm_ok); gdk_window_unref(gdk_dnd.c->drag_pm_ok); } - + gdk_dnd.c->drag_pm_ok = NULL; - + gdk_window_ref(default_pixmapwin); gdk_dnd.c->drag_pm_default = default_pixmapwin; gdk_dnd.c->default_hotspot = *default_hotspot; @@ -68,7 +86,7 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin, gdk_dnd.c->drag_pm_ok = goahead_pixmapwin; gdk_dnd.c->ok_hotspot = *goahead_hotspot; } - + if(gdk_dnd.dnd_grabbed) { gdk_dnd_display_drag_cursor(-1, -1, @@ -90,7 +108,7 @@ gdk_dnd_display_drag_cursor(gint x, gint y, gboolean drag_ok, { if(!gdk_dnd.dnd_grabbed) return; - + if(gdk_dnd.c->drag_pm_default) { /* We're doing pixmaps here... */ @@ -99,29 +117,29 @@ gdk_dnd_display_drag_cursor(gint x, gint y, gboolean drag_ok, gint itmp; guint masktmp; Window wtmp; - + if(x == -2 && y == -2) /* Hide the cursors */ { gdk_window_hide(gdk_dnd.c->drag_pm_ok); gdk_window_hide(gdk_dnd.c->drag_pm_default); - GDK_NOTE(DND, g_print("Hiding both drag cursors\n")); + GDK_NOTE(DND, g_message("Hiding both drag cursors\n")); return; } - + if(x == -1 && y == -1) /* We're supposed to find it out for ourselves */ XQueryPointer(gdk_display, gdk_root_window, &wtmp, &wtmp, &x, &y, &itmp, &itmp, &masktmp); - + if(drag_ok) { - GDK_NOTE(DND, g_print("Switching to drag_ok cursor\n")); + GDK_NOTE(DND, g_message("Switching to drag_ok cursor\n")); mypix = gdk_dnd.c->drag_pm_ok; opix = gdk_dnd.c->drag_pm_default; myhotspot = &gdk_dnd.c->ok_hotspot; } else { - GDK_NOTE(DND, g_print("Switching to drag_default cursor\n")); + GDK_NOTE(DND, g_message("Switching to drag_default cursor\n")); mypix = gdk_dnd.c->drag_pm_default; opix = gdk_dnd.c->drag_pm_ok; myhotspot = &gdk_dnd.c->default_hotspot; @@ -129,7 +147,7 @@ gdk_dnd_display_drag_cursor(gint x, gint y, gboolean drag_ok, gdk_window_move(mypix, x - myhotspot->x, y - myhotspot->y); if(change_made) { - GDK_NOTE(DND, g_print("Cursors switched, hide & show\n")); + GDK_NOTE(DND, g_message("Cursors switched, hide & show\n")); gdk_window_hide(opix); } gdk_window_move(mypix, x - myhotspot->x, y - myhotspot->y); diff --git a/gdk/gdkfont.c b/gdk/gdkfont.c index 1b37930a73..cc1274a0d6 100644 --- a/gdk/gdkfont.c +++ b/gdk/gdkfont.c @@ -72,9 +72,9 @@ gdk_fontset_load (gchar *fontset_name) if (missing_charset_count) { gint i; - g_print ("Missing charsets in FontSet creation\n"); + g_message ("Missing charsets in FontSet creation\n"); for (i=0;i<missing_charset_count;i++) - g_print (" %s\n", missing_charset_list[i]); + g_message (" %s\n", missing_charset_list[i]); XFreeStringList (missing_charset_list); } diff --git a/gdk/gdkvisual.c b/gdk/gdkvisual.c index e7bf1648cc..693020ef61 100644 --- a/gdk/gdkvisual.c +++ b/gdk/gdkvisual.c @@ -211,9 +211,9 @@ gdk_visual_init (void) #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & GDK_DEBUG_MISC) for (i = 0; i < nvisuals; i++) - g_print ("Gdk: visual: %s: %d\n", - visual_names[visuals[i].visual.type], - visuals[i].visual.depth); + g_message ("visual: %s: %d", + visual_names[visuals[i].visual.type], + visuals[i].visual.depth); #endif /* G_ENABLE_DEBUG */ navailable_depths = 0; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 5c1feb2e3a..8c8623d4b0 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -407,7 +407,7 @@ gdk_window_new (GdkWindow *parent, (private->colormap != gdk_colormap_get_system ()) && (private->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window)))) { - GDK_NOTE (MISC, g_print ("adding colormap window\n")); + GDK_NOTE (MISC, g_message ("adding colormap window\n")); gdk_window_add_colormap_windows (window); } @@ -1771,7 +1771,7 @@ gdk_window_dnd_data_set (GdkWindow *window, data_numbytes); tmp = gdk_atom_name(window_private->dnd_drag_data_type); #ifdef DEBUG_DND - g_print("DnD type %s on window %ld\n", tmp, window_private->xwindow); + g_message("DnD type %s on window %ld\n", tmp, window_private->xwindow); #endif g_free(tmp); @@ -1801,9 +1801,8 @@ gdk_window_dnd_data_set (GdkWindow *window, if (!gdk_send_xevent (event->dragrequest.requestor, False, StructureNotifyMask, &sev)) - GDK_NOTE (DND, g_print("Sending XdeDataAvailable to %#x failed\n", - event->dragrequest.requestor)); - + GDK_NOTE (DND, g_message("Sending XdeDataAvailable to %#x failed\n", + event->dragrequest.requestor)); } void diff --git a/gdk/x11/gdkcc-x11.c b/gdk/x11/gdkcc-x11.c index 12631a0772..df7c0a7833 100644 --- a/gdk/x11/gdkcc-x11.c +++ b/gdk/x11/gdkcc-x11.c @@ -69,7 +69,7 @@ static guint hash_color (gconstpointer key) { const GdkColor *color = key; - + return (color->red * 33023 + color->green * 30013 + color->blue * 27011); } @@ -79,7 +79,7 @@ compare_colors (gconstpointer a, { const GdkColor *aa = a; const GdkColor *bb = b; - + return ((aa->red == bb->red) && (aa->green == bb->green) && (aa->blue == bb->blue)); } @@ -108,20 +108,20 @@ my_x_query_colors (GdkColormap *colormap, { XColor *xcolors; gint i; - + xcolors = g_new (XColor, ncolors); for (i = 0; i < ncolors; i++) xcolors[i].pixel = colors[i].pixel; - + XQueryColors (gdk_display, GDK_COLORMAP_XCOLORMAP (colormap), xcolors, ncolors); - + for (i = 0; i < ncolors; i++) { colors[i].red = xcolors[i].red; colors[i].green = xcolors[i].green; colors[i].blue = xcolors[i].blue; } - + g_free (xcolors); } @@ -131,12 +131,12 @@ query_colors (GdkColorContext *cc) gint i; GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; cc->cmap = g_new (GdkColor, cc->num_colors); - + for (i = 0; i < cc->num_colors; i++) cc->cmap[i].pixel = cc->clut ? cc->clut[i] : ccp->std_cmap.base_pixel + i; - + my_x_query_colors (cc->colormap, cc->cmap, cc->num_colors); - + qsort (cc->cmap, cc->num_colors, sizeof (GdkColor), pixel_sort); } @@ -144,25 +144,25 @@ static void init_bw (GdkColorContext *cc) { GdkColor color; - + g_warning ("init_bw: failed to allocate colors, falling back to black and white"); - + cc->mode = GDK_CC_MODE_BW; - + color.red = color.green = color.blue = 0; if (!gdk_color_alloc (cc->colormap, &color)) cc->black_pixel = 0; else cc->black_pixel = color.pixel; - + color.red = color.green = color.blue = 0xffff; if (!gdk_color_alloc (cc->colormap, &color)) cc->white_pixel = cc->black_pixel ? 0 : 1; else cc->white_pixel = color.pixel; - + cc->num_colors = 2; } @@ -173,28 +173,28 @@ init_gray (GdkColorContext *cc) GdkColor *clrs, *cstart; gint i; gdouble dinc; - + cc->num_colors = GDK_VISUAL_XVISUAL (cc->visual)->map_entries; - + cc->clut = g_new (gulong, cc->num_colors); cstart = g_new (GdkColor, cc->num_colors); - -retrygray: - + + retrygray: + dinc = 65535.0 / (cc->num_colors - 1); - + clrs = cstart; - + for (i = 0; i < cc->num_colors; i++) { clrs->red = clrs->green = clrs->blue = dinc * i; - + if (!gdk_color_alloc (cc->colormap, clrs)) { gdk_colors_free (cc->colormap, cc->clut, i, 0); - + cc->num_colors /= 2; - + if (cc->num_colors > 1) goto retrygray; else @@ -206,12 +206,12 @@ retrygray: return; } } - + cc->clut[i] = clrs++->pixel; } - + g_free (cstart); - + /* XXX: is this the right thing to do? */ ccp->std_cmap.colormap = GDK_COLORMAP_XCOLORMAP (cc->colormap); ccp->std_cmap.base_pixel = 0; @@ -221,12 +221,12 @@ retrygray: ccp->std_cmap.red_mult = 1; ccp->std_cmap.green_mult = 0; ccp->std_cmap.blue_mult = 0; - + cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen); cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen); - + query_colors (cc); - + cc->mode = GDK_CC_MODE_MY_GRAY; } @@ -235,14 +235,14 @@ init_color (GdkColorContext *cc) { GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; gint cubeval; - + cubeval = 1; while ((cubeval * cubeval * cubeval) < GDK_VISUAL_XVISUAL (cc->visual)->map_entries) cubeval++; cubeval--; - + cc->num_colors = cubeval * cubeval * cubeval; - + ccp->std_cmap.red_max = cubeval - 1; ccp->std_cmap.green_max = cubeval - 1; ccp->std_cmap.blue_max = cubeval - 1; @@ -250,21 +250,21 @@ init_color (GdkColorContext *cc) ccp->std_cmap.green_mult = cubeval; ccp->std_cmap.blue_mult = 1; ccp->std_cmap.base_pixel = 0; - + cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen); cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen); cc->num_colors = DisplayCells (ccp->xdisplay, gdk_screen); - + /* a CLUT for storing allocated pixel indices */ - + cc->max_colors = cc->num_colors; cc->clut = g_new (gulong, cc->max_colors); - + for (cubeval = 0; cubeval < cc->max_colors; cubeval++) cc->clut[cubeval] = cubeval; - + query_colors (cc); - + cc->mode = GDK_CC_MODE_STD_CMAP; } @@ -274,66 +274,66 @@ init_true_color (GdkColorContext *cc) { GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; gulong rmask, gmask, bmask; - + cc->mode = GDK_CC_MODE_TRUE; - + /* Red */ - + rmask = cc->masks.red = cc->visual->red_mask; - + cc->shifts.red = 0; cc->bits.red = 0; - + while (!(rmask & 1)) { rmask >>= 1; cc->shifts.red++; } - + while (rmask & 1) { rmask >>= 1; cc->bits.red++; } - + /* Green */ - + gmask = cc->masks.green = cc->visual->green_mask; - + cc->shifts.green = 0; cc->bits.green = 0; - + while (!(gmask & 1)) { gmask >>= 1; cc->shifts.green++; } - + while (gmask & 1) { gmask >>= 1; cc->bits.green++; } - + /* Blue */ - + bmask = cc->masks.blue = cc->visual->blue_mask; - + cc->shifts.blue = 0; cc->bits.blue = 0; - + while (!(bmask & 1)) { bmask >>= 1; cc->shifts.blue++; } - + while (bmask & 1) { bmask >>= 1; cc->bits.blue++; } - + cc->num_colors = (cc->visual->red_mask | cc->visual->green_mask | cc->visual->blue_mask) + 1; cc->white_pixel = WhitePixel (ccp->xdisplay, gdk_screen); cc->black_pixel = BlackPixel (ccp->xdisplay, gdk_screen); @@ -349,49 +349,49 @@ init_direct_color (GdkColorContext *cc) gulong *gtable; gulong *btable; gdouble dinc; - + init_true_color (cc); /* for shift stuff */ - + rval = cc->visual->red_mask >> cc->shifts.red; gval = cc->visual->green_mask >> cc->shifts.green; bval = cc->visual->blue_mask >> cc->shifts.blue; - + rtable = g_new (gulong, rval + 1); gtable = g_new (gulong, gval + 1); btable = g_new (gulong, bval + 1); - + cc->max_entry = MAX (rval, gval); cc->max_entry = MAX (cc->max_entry, bval); - + cstart = g_new (GdkColor, cc->max_entry + 1); cc->clut = g_new (gulong, cc->max_entry + 1); - -retrydirect: - + + retrydirect: + for (n = 0; n < rval; n++) rtable[n] = rval ? (65535.0 / rval * n) : 0; - + for (n = 0; n < gval; n++) gtable[n] = gval ? (65535.0 / gval * n) : 0; - + for (n = 0; n < bval; n++) btable[n] = bval ? (65535.0 / bval * n) : 0; - + cc->max_entry = MAX (rval, gval); cc->max_entry = MAX (cc->max_entry, bval); - + count = 0; clrs = cstart; cc->num_colors = (rval + 1) * (gval + 1) * (bval + 1); - + for (n = 0; n < cc->max_entry; n++) { dinc = (double) n / cc->max_entry; - + clrs->red = rtable[(int) (dinc * rval)]; clrs->green = gtable[(int) (dinc * gval)]; clrs->blue = btable[(int) (dinc * bval)]; - + if (gdk_color_alloc (cc->colormap, clrs)) { cc->clut[count++] = clrs->pixel; @@ -400,25 +400,25 @@ retrydirect: else { gdk_colors_free (cc->colormap, cc->clut, count, 0); - + rval >>= 1; gval >>= 1; bval >>= 1; - + cc->masks.red = (cc->masks.red >> 1) & cc->visual->red_mask; cc->masks.green = (cc->masks.green >> 1) & cc->visual->green_mask; cc->masks.blue = (cc->masks.blue >> 1) & cc->visual->blue_mask; - + cc->shifts.red++; cc->shifts.green++; cc->shifts.blue++; - + cc->bits.red--; cc->bits.green--; cc->bits.blue--; - + cc->num_colors = (rval + 1) * (gval + 1) * (bval + 1); - + if (cc->num_colors >1) goto retrydirect; else @@ -430,13 +430,13 @@ retrydirect: } } } - + /* Update allocated color count; original num_colors is max_entry, which * is not necessarily the same as the really allocated number of colors. */ - + cc->num_colors = count; - + g_free (rtable); g_free (gtable); g_free (btable); @@ -447,7 +447,7 @@ static void init_palette (GdkColorContext *cc) { /* restore correct mode for this cc */ - + switch (cc->visual->type) { case GDK_VISUAL_STATIC_GRAY: @@ -457,40 +457,40 @@ init_palette (GdkColorContext *cc) else cc->mode = GDK_CC_MODE_MY_GRAY; break; - + case GDK_VISUAL_TRUE_COLOR: case GDK_VISUAL_DIRECT_COLOR: cc->mode = GDK_CC_MODE_TRUE; break; - + case GDK_VISUAL_STATIC_COLOR: case GDK_VISUAL_PSEUDO_COLOR: cc->mode = GDK_CC_MODE_STD_CMAP; break; - + default: cc->mode = GDK_CC_MODE_UNDEFINED; break; } - + /* previous palette */ - + if (cc->num_palette) g_free (cc->palette); - + if (cc->fast_dither) g_free (cc->fast_dither); - + /* clear hash table if present */ - + if (cc->color_hash) { /* XXX: quick-and-dirty way to remove everything */ - + g_hash_table_destroy (cc->color_hash); cc->color_hash = g_hash_table_new (hash_color, compare_colors); } - + cc->palette = NULL; cc->num_palette = 0; cc->fast_dither = NULL; @@ -505,10 +505,10 @@ gdk_color_context_new (GdkVisual *visual, GdkColorContext *cc; gint retry_count; GdkColormap *default_colormap; - + g_assert (visual != NULL); g_assert (colormap != NULL); - + ccp = g_new (GdkColorContextPrivate, 1); cc = (GdkColorContext *) ccp; ccp->xdisplay = gdk_display; @@ -518,16 +518,16 @@ gdk_color_context_new (GdkVisual *visual, cc->cmap = NULL; cc->mode = GDK_CC_MODE_UNDEFINED; cc->need_to_free_colormap = FALSE; - + cc->color_hash = NULL; cc->palette = NULL; cc->num_palette = 0; cc->fast_dither = NULL; - + default_colormap = gdk_colormap_get_system (); - + retry_count = 0; - + while (retry_count < 2) { /* Only create a private colormap if the visual found isn't equal @@ -535,66 +535,66 @@ gdk_color_context_new (GdkVisual *visual, * -or- if we are instructed to create a private colormap (which * never is the case for XmHTML). */ - + if (use_private_colormap || ((cc->visual != gdk_visual_get_system ()) /* default visual? */ && (GDK_COLORMAP_XCOLORMAP (colormap) == GDK_COLORMAP_XCOLORMAP (default_colormap)))) { g_warning ("gdk_color_context_new: non-default visual detected, " "using private colormap"); - + cc->colormap = gdk_colormap_new (cc->visual, FALSE); - + cc->need_to_free_colormap = (GDK_COLORMAP_XCOLORMAP (colormap) != GDK_COLORMAP_XCOLORMAP (default_colormap)); } - + switch (visual->type) { case GDK_VISUAL_STATIC_GRAY: case GDK_VISUAL_GRAYSCALE: GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is %s\n", - (visual->type == GDK_VISUAL_STATIC_GRAY) ? - "GDK_VISUAL_STATIC_GRAY" : - "GDK_VISUAL_GRAYSCALE")); - + g_message ("gdk_color_context_new: visual class is %s\n", + (visual->type == GDK_VISUAL_STATIC_GRAY) ? + "GDK_VISUAL_STATIC_GRAY" : + "GDK_VISUAL_GRAYSCALE")); + if (GDK_VISUAL_XVISUAL (cc->visual)->map_entries == 2) init_bw (cc); else init_gray (cc); - + break; - + case GDK_VISUAL_TRUE_COLOR: /* shifts */ GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n")); - + g_message ("gdk_color_context_new: visual class is GDK_VISUAL_TRUE_COLOR\n")); + init_true_color (cc); break; - + case GDK_VISUAL_DIRECT_COLOR: /* shifts and fake CLUT */ GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n")); - + g_message ("gdk_color_context_new: visual class is GDK_VISUAL_DIRECT_COLOR\n")); + init_direct_color (cc); break; - + case GDK_VISUAL_STATIC_COLOR: case GDK_VISUAL_PSEUDO_COLOR: GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: visual class is %s\n", - (visual->type == GDK_VISUAL_STATIC_COLOR) ? - "GDK_VISUAL_STATIC_COLOR" : - "GDK_VISUAL_PSEUDO_COLOR")); - + g_message ("gdk_color_context_new: visual class is %s\n", + (visual->type == GDK_VISUAL_STATIC_COLOR) ? + "GDK_VISUAL_STATIC_COLOR" : + "GDK_VISUAL_PSEUDO_COLOR")); + init_color (cc); break; - + default: g_assert_not_reached (); } - + if ((cc->mode == GDK_CC_MODE_BW) && (cc->visual->depth > 1)) { use_private_colormap = TRUE; @@ -603,20 +603,20 @@ gdk_color_context_new (GdkVisual *visual, else break; } - + /* no. of colors allocated yet */ - + cc->num_allocated = 0; - + GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n", - cc->visual->depth, cc->num_colors)); - + g_message ("gdk_color_context_new: screen depth is %i, no. of colors is %i\n", + cc->visual->depth, cc->num_colors)); + /* check if we need to initialize a hash table */ - + if ((cc->mode == GDK_CC_MODE_STD_CMAP) || (cc->mode == GDK_CC_MODE_UNDEFINED)) cc->color_hash = g_hash_table_new (hash_color, compare_colors); - + return (GdkColorContext *) cc; } @@ -626,10 +626,10 @@ gdk_color_context_new_mono (GdkVisual *visual, { GdkColorContextPrivate *ccp; GdkColorContext *cc; - + g_assert (visual != NULL); g_assert (colormap != NULL); - + cc = g_new (GdkColorContext, 1); ccp = (GdkColorContextPrivate *) cc; ccp->xdisplay = gdk_display; @@ -639,9 +639,9 @@ gdk_color_context_new_mono (GdkVisual *visual, cc->cmap = NULL; cc->mode = GDK_CC_MODE_UNDEFINED; cc->need_to_free_colormap = FALSE; - + init_bw (cc); - + return (GdkColorContext *) cc; } @@ -651,7 +651,7 @@ void gdk_color_context_free (GdkColorContext *cc) { g_assert (cc != NULL); - + if ((cc->visual->type == GDK_VISUAL_STATIC_COLOR) || (cc->visual->type == GDK_VISUAL_PSEUDO_COLOR)) { @@ -663,17 +663,17 @@ gdk_color_context_free (GdkColorContext *cc) gdk_colors_free (cc->colormap, cc->clut, cc->num_colors, 0); g_free (cc->clut); } - + if (cc->cmap != NULL) g_free (cc->cmap); - + if (cc->need_to_free_colormap) gdk_colormap_unref (cc->colormap); - + /* free any palette that has been associated with this GdkColorContext */ - + init_palette (cc); - + if (cc->color_hash) { g_hash_table_foreach (cc->color_hash, @@ -681,7 +681,7 @@ gdk_color_context_free (GdkColorContext *cc) NULL); g_hash_table_destroy (cc->color_hash); } - + g_free (cc); } @@ -695,146 +695,146 @@ gdk_color_context_get_pixel (GdkColorContext *cc, GdkColorContextPrivate *ccp = (GdkColorContextPrivate *) cc; g_assert (cc != NULL); g_assert (failed != NULL); - + *failed = FALSE; - + switch (cc->mode) { case GDK_CC_MODE_BW: - { - gdouble value; - - value = (red / 65535.0 * 0.30 - + green / 65535.0 * 0.59 - + blue / 65535.0 * 0.11); - - if (value > 0.5) - return cc->white_pixel; - - return cc->black_pixel; - } - + { + gdouble value; + + value = (red / 65535.0 * 0.30 + + green / 65535.0 * 0.59 + + blue / 65535.0 * 0.11); + + if (value > 0.5) + return cc->white_pixel; + + return cc->black_pixel; + } + case GDK_CC_MODE_MY_GRAY: - { - gulong ired, igreen, iblue; - - red = red * 0.30 + green * 0.59 + blue * 0.11; - green = 0; - blue = 0; - - if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max) - ired = ccp->std_cmap.red_max; - - ired *= ccp->std_cmap.red_mult; - - if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max) - igreen = ccp->std_cmap.green_max; - - igreen *= ccp->std_cmap.green_mult; - - if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max) - iblue = ccp->std_cmap.blue_max; - - iblue *= ccp->std_cmap.blue_mult; - - if (cc->clut != NULL) - return cc->clut[ccp->std_cmap.base_pixel + ired + igreen + iblue]; - - return ccp->std_cmap.base_pixel + ired + igreen + iblue; - } - + { + gulong ired, igreen, iblue; + + red = red * 0.30 + green * 0.59 + blue * 0.11; + green = 0; + blue = 0; + + if ((ired = red * (ccp->std_cmap.red_max + 1) / 0xffff) > ccp->std_cmap.red_max) + ired = ccp->std_cmap.red_max; + + ired *= ccp->std_cmap.red_mult; + + if ((igreen = green * (ccp->std_cmap.green_max + 1) / 0xffff) > ccp->std_cmap.green_max) + igreen = ccp->std_cmap.green_max; + + igreen *= ccp->std_cmap.green_mult; + + if ((iblue = blue * (ccp->std_cmap.blue_max + 1) / 0xffff) > ccp->std_cmap.blue_max) + iblue = ccp->std_cmap.blue_max; + + iblue *= ccp->std_cmap.blue_mult; + + if (cc->clut != NULL) + return cc->clut[ccp->std_cmap.base_pixel + ired + igreen + iblue]; + + return ccp->std_cmap.base_pixel + ired + igreen + iblue; + } + case GDK_CC_MODE_TRUE: - { - gulong ired, igreen, iblue; - - if (cc->clut == NULL) - { - red >>= 16 - cc->bits.red; - green >>= 16 - cc->bits.green; - blue >>= 16 - cc->bits.blue; - - ired = (red << cc->shifts.red) & cc->masks.red; - igreen = (green << cc->shifts.green) & cc->masks.green; - iblue = (blue << cc->shifts.blue) & cc->masks.blue; - - return ired | igreen | iblue; - } - - ired = cc->clut[red * cc->max_entry / 65535] & cc->masks.red; - igreen = cc->clut[green * cc->max_entry / 65535] & cc->masks.green; - iblue = cc->clut[blue * cc->max_entry / 65535] & cc->masks.blue; - - return ired | igreen | iblue; - } - + { + gulong ired, igreen, iblue; + + if (cc->clut == NULL) + { + red >>= 16 - cc->bits.red; + green >>= 16 - cc->bits.green; + blue >>= 16 - cc->bits.blue; + + ired = (red << cc->shifts.red) & cc->masks.red; + igreen = (green << cc->shifts.green) & cc->masks.green; + iblue = (blue << cc->shifts.blue) & cc->masks.blue; + + return ired | igreen | iblue; + } + + ired = cc->clut[red * cc->max_entry / 65535] & cc->masks.red; + igreen = cc->clut[green * cc->max_entry / 65535] & cc->masks.green; + iblue = cc->clut[blue * cc->max_entry / 65535] & cc->masks.blue; + + return ired | igreen | iblue; + } + case GDK_CC_MODE_PALETTE: return gdk_color_context_get_pixel_from_palette (cc, &red, &green, &blue, failed); - + case GDK_CC_MODE_STD_CMAP: default: - { - GdkColor color; - GdkColor *result; - - color.red = red; - color.green = green; - color.blue = blue; - - result = g_hash_table_lookup (cc->color_hash, &color); - - if (!result) - { - color.red = red; - color.green = green; - color.blue = blue; - color.pixel = 0; - - if (!gdk_color_alloc (cc->colormap, &color)) - *failed = TRUE; - else - { - GdkColor *cnew; - - /* XXX: the following comment comes directly from - * XCC.c. I don't know if it is relevant for - * gdk_color_alloc() as it is for XAllocColor() - * - Federico - */ - /* - * I can't figure this out entirely, but it *is* possible - * that XAllocColor succeeds, even if the number of - * allocations we've made exceeds the number of available - * colors in the current colormap. And therefore it - * might be necessary for us to resize the CLUT. - */ - - if (cc->num_allocated == cc->max_colors) - { - cc->max_colors *= 2; - - GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixel: " - "resizing CLUT to %i entries\n", - cc->max_colors)); - - cc->clut = g_realloc (cc->clut, - cc->max_colors * sizeof (gulong)); - } - - /* Key and value are the same color structure */ - - cnew = g_new (GdkColor, 1); - *cnew = color; - g_hash_table_insert (cc->color_hash, cnew, cnew); - - cc->clut[cc->num_allocated] = color.pixel; - cc->num_allocated++; - return color.pixel; - } - } - - return result->pixel; - } + { + GdkColor color; + GdkColor *result; + + color.red = red; + color.green = green; + color.blue = blue; + + result = g_hash_table_lookup (cc->color_hash, &color); + + if (!result) + { + color.red = red; + color.green = green; + color.blue = blue; + color.pixel = 0; + + if (!gdk_color_alloc (cc->colormap, &color)) + *failed = TRUE; + else + { + GdkColor *cnew; + + /* XXX: the following comment comes directly from + * XCC.c. I don't know if it is relevant for + * gdk_color_alloc() as it is for XAllocColor() + * - Federico + */ + /* + * I can't figure this out entirely, but it *is* possible + * that XAllocColor succeeds, even if the number of + * allocations we've made exceeds the number of available + * colors in the current colormap. And therefore it + * might be necessary for us to resize the CLUT. + */ + + if (cc->num_allocated == cc->max_colors) + { + cc->max_colors *= 2; + + GDK_NOTE (COLOR_CONTEXT, + g_message ("gdk_color_context_get_pixel: " + "resizing CLUT to %i entries\n", + cc->max_colors)); + + cc->clut = g_realloc (cc->clut, + cc->max_colors * sizeof (gulong)); + } + + /* Key and value are the same color structure */ + + cnew = g_new (GdkColor, 1); + *cnew = color; + g_hash_table_insert (cc->color_hash, cnew, cnew); + + cc->clut[cc->num_allocated] = color.pixel; + cc->num_allocated++; + return color.pixel; + } + } + + return result->pixel; + } } } @@ -861,37 +861,37 @@ gdk_color_context_get_pixels (GdkColorContext *cc, g_assert (blues != NULL); g_assert (colors != NULL); g_assert (nallocated != NULL); - + memset (defs, 0, MAX_IMAGE_COLORS * sizeof (GdkColor)); memset (failed, 0, MAX_IMAGE_COLORS * sizeof (gint)); memset (allocated, 0, MAX_IMAGE_COLORS * sizeof (gint)); - + /* Will only have a value if used by the progressive image loader */ - + ncols = *nallocated; - + *nallocated = 0; - + /* First allocate all pixels */ - + for (i = 0; i < ncolors; i++) { /* colors[i] is only zero if the pixel at that location hasn't * been allocated yet. This is a sanity check required for proper * color allocation by the progressive image loader */ - + if (colors[i] == 0) { defs[i].red = reds[i]; defs[i].green = greens[i]; defs[i].blue = blues[i]; - + colors[i] = gdk_color_context_get_pixel (cc, reds[i], greens[i], blues[i], &bad_alloc); - + /* successfully allocated, store it */ - + if (!bad_alloc) { defs[i].pixel = colors[i]; @@ -901,114 +901,114 @@ gdk_color_context_get_pixels (GdkColorContext *cc, failed[nopen++] = i; } } - + *nallocated = ncols; - + /* all colors available, all done */ - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels: got all %i colors; " - "(%i colors allocated so far)\n", ncolors, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels: got all %i colors; " + "(%i colors allocated so far)\n", ncolors, cc->num_allocated)); + return; } - + /* The fun part. We now try to allocate the colors we couldn't allocate * directly. The first step will map a color onto its nearest color * that has been allocated (either by us or someone else). If any colors * remain unallocated, we map these onto the colors that we have allocated * ourselves. */ - + /* read up to MAX_IMAGE_COLORS colors of the current colormap */ - + cmapsize = MIN (cc->num_colors, MAX_IMAGE_COLORS); - + /* see if the colormap has any colors to read */ - + if (cmapsize < 0) { g_warning ("gdk_color_context_get_pixels: oops! no colors available, " "your images will look *really* ugly."); - + return; } - + #ifdef G_ENABLE_DEBUG exact_col = ncols; #endif - + /* initialize pixels */ - + for (i = 0; i < cmapsize; i++) { cmap[i].pixel = i; cmap[i].red = cmap[i].green = cmap[i].blue = 0; } - + /* read the colormap */ - + my_x_query_colors (cc->colormap, cmap, cmapsize); - + /* get a close match for any unallocated colors */ - + counter = nopen; nopen = 0; idx = 0; - + do { gint d, j, mdist, close, ri, gi, bi; gint rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + /* Store these vals. Small performance increase as this skips three * indexing operations in the loop code. */ - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + /* Walk all colors in the colormap and see which one is the * closest. Uses plain least squares. */ - + for (j = 0; (j < cmapsize) && (mdist != 0); j++) { /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - cmap[j].red) / 256; gd = (gi - cmap[j].green) / 256; bd = (bi - cmap[j].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = j; mdist = d; } } - + if (close != -1) { rd = cmap[close].red; gd = cmap[close].green; bd = cmap[close].blue; - + /* allocate */ - + colors[i] = gdk_color_context_get_pixel (cc, rd, gd, bd, &bad_alloc); - + /* store */ - + if (!bad_alloc) { defs[i] = cmap[close]; @@ -1024,68 +1024,68 @@ gdk_color_context_get_pixels (GdkColorContext *cc, /* deal with in next stage if allocation failed */ } while (++idx < counter); - + *nallocated = ncols; - + /* This is the maximum no. of allocated colors. See also the nopen == 0 * note above. */ - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels: got %i colors, %i exact and " - "%i close (%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels: got %i colors, %i exact and " + "%i close (%i colors allocated so far)\n", + ncolors, exact_col, close_col, cc->num_allocated)); + return; } - + /* Now map any remaining unallocated pixels into the colors we did get */ - + idx = 0; - + do { gint d, mdist, close, ri, gi, bi; gint j, rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + /* store */ - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + /* search allocated colors */ - + for (j = 0; (j < ncols) && (mdist != 0); j++) { k = allocated[j]; - + /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - defs[k].red) / 256; gd = (gi - defs[k].green) / 256; bd = (bi - defs[k].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = k; mdist = d; } } - + if (close < 0) { /* too bad, map to black */ - + defs[i].pixel = cc->black_pixel; defs[i].red = defs[i].green = defs[i].blue = 0; #ifdef G_ENABLE_DEBUG @@ -1099,15 +1099,15 @@ gdk_color_context_get_pixels (GdkColorContext *cc, subst_col++; #endif } - + colors[i] = defs[i].pixel; } while (++idx < nopen); - + GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels: got %i colors, %i exact, %i close, " - "%i substituted, %i to black (%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); + g_message ("gdk_color_context_get_pixels: got %i colors, %i exact, %i close, " + "%i substituted, %i to black (%i colors allocated so far)\n", + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } void @@ -1128,7 +1128,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, #ifdef G_ENABLE_DEBUG gint exact_col = 0, subst_col = 0, close_col = 0, black_col = 0; #endif - + g_assert (cc != NULL); g_assert (reds != NULL); g_assert (greens != NULL); @@ -1136,19 +1136,19 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, g_assert (used != NULL); g_assert (colors != NULL); g_assert (nallocated != NULL); - + memset (defs, 0, MAX_IMAGE_COLORS * sizeof (GdkColor)); memset (failed, 0, MAX_IMAGE_COLORS * sizeof (gint)); memset (allocated, 0, MAX_IMAGE_COLORS * sizeof (gint)); - + /* Will only have a value if used by the progressive image loader */ - + ncols = *nallocated; - + *nallocated = 0; - + /* First allocate all pixels */ - + for (i = 0; i < ncolors; i++) { /* used[i] is only -1 if the pixel at that location hasn't @@ -1157,7 +1157,7 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, * When colors[i] == 0 it indicates the slot is available for * allocation. */ - + if (used[i] != FALSE) { if (colors[i] == 0) @@ -1165,11 +1165,11 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, defs[i].red = reds[i]; defs[i].green = greens[i]; defs[i].blue = blues[i]; - + colors[i] = gdk_color_context_get_pixel (cc, reds[i], greens[i], blues[i], &bad_alloc); - + /* successfully allocated, store it */ - + if (!bad_alloc) { defs[i].pixel = colors[i]; @@ -1181,100 +1181,100 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, #ifdef DEBUG else GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: " - "pixel at slot %i already allocated, skipping\n", i)); + g_message ("gdk_color_context_get_pixels_incremental: " + "pixel at slot %i already allocated, skipping\n", i)); #endif } } - + *nallocated = ncols; - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: got all %i colors " - "(%i colors allocated so far)\n", - ncolors, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels_incremental: got all %i colors " + "(%i colors allocated so far)\n", + ncolors, cc->num_allocated)); + return; } - + cmapsize = MIN (cc->num_colors, MAX_IMAGE_COLORS); - + if (cmapsize < 0) { g_warning ("gdk_color_context_get_pixels_incremental: oops! " "No colors available images will look *really* ugly."); return; } - + #ifdef G_ENABLE_DEBUG exact_col = ncols; #endif - + /* initialize pixels */ - + for (i = 0; i < cmapsize; i++) { cmap[i].pixel = i; cmap[i].red = cmap[i].green = cmap[i].blue = 0; } - + /* read */ - + my_x_query_colors (cc->colormap, cmap, cmapsize); - + /* now match any unallocated colors */ - + counter = nopen; nopen = 0; idx = 0; - + do { gint d, j, mdist, close, ri, gi, bi; gint rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + /* store */ - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + for (j = 0; (j < cmapsize) && (mdist != 0); j++) { /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - cmap[j].red) / 256; gd = (gi - cmap[j].green) / 256; bd = (bi - cmap[j].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = j; mdist = d; } } - + if (close != -1) { rd = cmap[close].red; gd = cmap[close].green; bd = cmap[close].blue; - + /* allocate */ - + colors[i] = gdk_color_context_get_pixel (cc, rd, gd, bd, &bad_alloc); - + /* store */ - + if (!bad_alloc) { defs[i] = cmap[close]; @@ -1292,64 +1292,64 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, /* deal with in next stage if allocation failed */ } while (++idx < counter); - + *nallocated = ncols; - + if ((ncols == ncolors) || (nopen == 0)) { GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: " - "got %i colors, %i exact and %i close " - "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, cc->num_allocated)); - + g_message ("gdk_color_context_get_pixels_incremental: " + "got %i colors, %i exact and %i close " + "(%i colors allocated so far)\n", + ncolors, exact_col, close_col, cc->num_allocated)); + return; } - + /* map remaining unallocated pixels into colors we did get */ - + idx = 0; - + do { gint d, mdist, close, ri, gi, bi; gint j, rd, gd, bd; - + i = failed[idx]; - + mdist = 0x1000000; close = -1; - + ri = reds[i]; gi = greens[i]; bi = blues[i]; - + /* search allocated colors */ - + for (j = 0; (j < ncols) && (mdist != 0); j++) { k = allocated[j]; - + /* downscale */ /* Don't replace these by shifts; the sign may get clobbered */ - + rd = (ri - defs[k].red) / 256; gd = (gi - defs[k].green) / 256; bd = (bi - defs[k].blue) / 256; - + d = rd * rd + gd * gd + bd * bd; - + if (d < mdist) { close = k; mdist = d; } } - + if (close < 0) { /* too bad, map to black */ - + defs[i].pixel = cc->black_pixel; defs[i].red = defs[i].green = defs[i].blue = 0; #ifdef G_ENABLE_DEBUG @@ -1363,16 +1363,16 @@ gdk_color_context_get_pixels_incremental (GdkColorContext *cc, subst_col++; #endif } - + colors[i] = defs[i].pixel; } while (++idx < nopen); - + GDK_NOTE (COLOR_CONTEXT, - g_print ("gdk_color_context_get_pixels_incremental: " - "got %i colors, %i exact, %i close, %i substituted, %i to black " - "(%i colors allocated so far)\n", - ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); + g_message ("gdk_color_context_get_pixels_incremental: " + "got %i colors, %i exact, %i close, %i substituted, %i to black " + "(%i colors allocated so far)\n", + ncolors, exact_col, close_col, subst_col, black_col, cc->num_allocated)); } gint @@ -1389,10 +1389,10 @@ gdk_color_context_query_colors (GdkColorContext *cc, { gint i; GdkColor *tc; - + g_assert (cc != NULL); g_assert (colors != NULL); - + switch (cc->mode) { case GDK_CC_MODE_BW: @@ -1404,7 +1404,7 @@ gdk_color_context_query_colors (GdkColorContext *cc, tc->red = tc->green = tc->blue = 0; } break; - + case GDK_CC_MODE_TRUE: if (cc->clut == NULL) for (i = 0, tc = colors; i < num_colors; i++, tc++) @@ -1419,7 +1419,7 @@ gdk_color_context_query_colors (GdkColorContext *cc, return 1; } break; - + case GDK_CC_MODE_STD_CMAP: default: if (cc->cmap == NULL) @@ -1431,17 +1431,17 @@ gdk_color_context_query_colors (GdkColorContext *cc, { gint first, last, half; gulong half_pixel; - + for (i = 0, tc = colors; i < num_colors; i++) { first = 0; last = cc->num_colors - 1; - + while (first <= last) { half = (first + last) / 2; half_pixel = cc->cmap[half].pixel; - + if (tc->pixel == half_pixel) { tc->red = cc->cmap[half].red; @@ -1473,94 +1473,94 @@ gdk_color_context_add_palette (GdkColorContext *cc, gint i, j, erg; gushort r, g, b; gulong pixel[1]; - + g_assert (cc != NULL); - + /* initialize this palette (will also erase previous palette as well) */ - + init_palette (cc); - + /* restore previous mode if we aren't adding a new palette */ - + if (num_palette == 0) { /* GDK_CC_MODE_STD_CMAP uses a hash table, so we'd better initialize one */ - + /* XXX: here, the hash table is already initialized */ - + return 0; } - + /* Initialize a hash table for this palette (we need one for allocating * the pixels in the palette using the current settings) */ - + if (cc->color_hash == NULL) cc->color_hash = g_hash_table_new (hash_color, compare_colors); - + /* copy incoming palette */ - + cc->palette = g_new0(GdkColor, num_palette); - + j = 0; - + for (i = 0; i < num_palette; i++) { erg = 0; pixel[0] = 0; - + /* try to allocate this color */ - + r = palette[i].red; g = palette[i].green; b = palette[i].blue; - + gdk_color_context_get_pixels (cc, &r, &g, &b, 1, pixel, &erg); - + /* only store if we succeed */ - + if (erg) { /* store in palette */ - + cc->palette[j].red = r; cc->palette[j].green = g; cc->palette[j].blue = b; cc->palette[j].pixel = pixel[0]; - + /* move to next slot */ - + j++; } } - + /* resize to fit */ - + if (j != num_palette) cc->palette = g_realloc (cc->palette, j * sizeof (GdkColor)); - + /* clear the hash table, we don't use it when dithering */ - + if (cc->color_hash) { g_hash_table_destroy (cc->color_hash); cc->color_hash = NULL; } - + /* store real palette size */ - + cc->num_palette = j; - + /* switch to palette mode */ - + cc->mode = GDK_CC_MODE_PALETTE; - + /* sort palette */ - + qsort (cc->palette, cc->num_palette, sizeof (GdkColor), pixel_sort); - + cc->fast_dither = NULL; - + return j; } @@ -1569,17 +1569,17 @@ gdk_color_context_init_dither (GdkColorContext *cc) { gint rr, gg, bb, err, erg, erb; gint success = FALSE; - + g_assert (cc != NULL); - + /* now we can initialize the fast dither matrix */ - + if (cc->fast_dither == NULL) cc->fast_dither = g_new (GdkColorContextDither, 1); - + /* Fill it. We ignore unsuccessful allocations, they are just mapped * to black instead */ - + for (rr = 0; rr < 32; rr++) for (gg = 0; gg < 32; gg++) for (bb = 0; bb < 32; bb++) @@ -1587,7 +1587,7 @@ gdk_color_context_init_dither (GdkColorContext *cc) err = (rr << 3) | (rr >> 2); erg = (gg << 3) | (gg >> 2); erb = (bb << 3) | (bb >> 2); - + cc->fast_dither->fast_rgb[rr][gg][bb] = gdk_color_context_get_index_from_palette (cc, &err, &erg, &erb, &success); cc->fast_dither->fast_err[rr][gg][bb] = err; @@ -1600,10 +1600,10 @@ void gdk_color_context_free_dither (GdkColorContext *cc) { g_assert (cc != NULL); - + if (cc->fast_dither) g_free (cc->fast_dither); - + cc->fast_dither = NULL; } @@ -1619,23 +1619,23 @@ gdk_color_context_get_pixel_from_palette (GdkColorContext *cc, gint mindif = 0x7fffffff; gint err = 0, erg = 0, erb = 0; gint i; - + g_assert (cc != NULL); g_assert (red != NULL); g_assert (green != NULL); g_assert (blue != NULL); g_assert (failed != NULL); - + *failed = FALSE; - + for (i = 0; i < cc->num_palette; i++) { dr = *red - cc->palette[i].red; dg = *green - cc->palette[i].green; db = *blue - cc->palette[i].blue; - + dif = dr * dr + dg * dg + db * db; - + if (dif < mindif) { mindif = dif; @@ -1644,14 +1644,14 @@ gdk_color_context_get_pixel_from_palette (GdkColorContext *cc, err = dr; erg = dg; erb = db; - + if (mindif == 0) break; } } - + /* we failed to map onto a color */ - + if (j == -1) *failed = TRUE; else @@ -1660,7 +1660,7 @@ gdk_color_context_get_pixel_from_palette (GdkColorContext *cc, *green = ABS (erg); *blue = ABS (erb); } - + return pixel; } @@ -1675,23 +1675,23 @@ gdk_color_context_get_index_from_palette (GdkColorContext *cc, gint mindif = 0x7fffffff; gint err = 0, erg = 0, erb = 0; gint i; - + g_assert (cc != NULL); g_assert (red != NULL); g_assert (green != NULL); g_assert (blue != NULL); g_assert (failed != NULL); - + *failed = FALSE; - + for (i = 0; i < cc->num_palette; i++) { dr = *red - cc->palette[i].red; dg = *green - cc->palette[i].green; db = *blue - cc->palette[i].blue; - + dif = dr * dr + dg * dg + db * db; - + if (dif < mindif) { mindif = dif; @@ -1699,14 +1699,14 @@ gdk_color_context_get_index_from_palette (GdkColorContext *cc, err = dr; erg = dg; erb = db; - + if (mindif == 0) break; } } - + /* we failed to map onto a color */ - + if (j == -1) { *failed = TRUE; @@ -1715,11 +1715,11 @@ gdk_color_context_get_index_from_palette (GdkColorContext *cc, else { /* return error fractions */ - + *red = err; *green = erg; *blue = erb; } - + return j; } diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index 6a74022c55..331aad7ef7 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -1,3 +1,21 @@ +/* GDK - The GIMP Drawing Kit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ #include <X11/Xlib.h> #include <X11/Xatom.h> #include <string.h> @@ -12,7 +30,7 @@ gdk_dnd_set_drag_cursors(GdkCursor *default_cursor, GdkCursor *goahead_cursor) gdk_dnd.c->gdk_cursor_dragdefault = ((GdkCursorPrivate *)default_cursor)->xcursor; gdk_dnd.c->gdk_cursor_dragok = ((GdkCursorPrivate *)goahead_cursor)->xcursor; - + if(gdk_dnd.dnd_grabbed) { if(gdk_dnd.c->drag_pm_default) @@ -42,7 +60,7 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin, GdkPoint *goahead_hotspot) { g_return_if_fail(default_pixmapwin != NULL); - + g_list_free(gdk_dnd.c->xids); gdk_dnd.c->xids = NULL; if(gdk_dnd.c->drag_pm_default) { @@ -54,9 +72,9 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin, gdk_window_hide(gdk_dnd.c->drag_pm_ok); gdk_window_unref(gdk_dnd.c->drag_pm_ok); } - + gdk_dnd.c->drag_pm_ok = NULL; - + gdk_window_ref(default_pixmapwin); gdk_dnd.c->drag_pm_default = default_pixmapwin; gdk_dnd.c->default_hotspot = *default_hotspot; @@ -68,7 +86,7 @@ gdk_dnd_set_drag_shape(GdkWindow *default_pixmapwin, gdk_dnd.c->drag_pm_ok = goahead_pixmapwin; gdk_dnd.c->ok_hotspot = *goahead_hotspot; } - + if(gdk_dnd.dnd_grabbed) { gdk_dnd_display_drag_cursor(-1, -1, @@ -90,7 +108,7 @@ gdk_dnd_display_drag_cursor(gint x, gint y, gboolean drag_ok, { if(!gdk_dnd.dnd_grabbed) return; - + if(gdk_dnd.c->drag_pm_default) { /* We're doing pixmaps here... */ @@ -99,29 +117,29 @@ gdk_dnd_display_drag_cursor(gint x, gint y, gboolean drag_ok, gint itmp; guint masktmp; Window wtmp; - + if(x == -2 && y == -2) /* Hide the cursors */ { gdk_window_hide(gdk_dnd.c->drag_pm_ok); gdk_window_hide(gdk_dnd.c->drag_pm_default); - GDK_NOTE(DND, g_print("Hiding both drag cursors\n")); + GDK_NOTE(DND, g_message("Hiding both drag cursors\n")); return; } - + if(x == -1 && y == -1) /* We're supposed to find it out for ourselves */ XQueryPointer(gdk_display, gdk_root_window, &wtmp, &wtmp, &x, &y, &itmp, &itmp, &masktmp); - + if(drag_ok) { - GDK_NOTE(DND, g_print("Switching to drag_ok cursor\n")); + GDK_NOTE(DND, g_message("Switching to drag_ok cursor\n")); mypix = gdk_dnd.c->drag_pm_ok; opix = gdk_dnd.c->drag_pm_default; myhotspot = &gdk_dnd.c->ok_hotspot; } else { - GDK_NOTE(DND, g_print("Switching to drag_default cursor\n")); + GDK_NOTE(DND, g_message("Switching to drag_default cursor\n")); mypix = gdk_dnd.c->drag_pm_default; opix = gdk_dnd.c->drag_pm_ok; myhotspot = &gdk_dnd.c->default_hotspot; @@ -129,7 +147,7 @@ gdk_dnd_display_drag_cursor(gint x, gint y, gboolean drag_ok, gdk_window_move(mypix, x - myhotspot->x, y - myhotspot->y); if(change_made) { - GDK_NOTE(DND, g_print("Cursors switched, hide & show\n")); + GDK_NOTE(DND, g_message("Cursors switched, hide & show\n")); gdk_window_hide(opix); } gdk_window_move(mypix, x - myhotspot->x, y - myhotspot->y); diff --git a/gdk/x11/gdkfont-x11.c b/gdk/x11/gdkfont-x11.c index 1b37930a73..cc1274a0d6 100644 --- a/gdk/x11/gdkfont-x11.c +++ b/gdk/x11/gdkfont-x11.c @@ -72,9 +72,9 @@ gdk_fontset_load (gchar *fontset_name) if (missing_charset_count) { gint i; - g_print ("Missing charsets in FontSet creation\n"); + g_message ("Missing charsets in FontSet creation\n"); for (i=0;i<missing_charset_count;i++) - g_print (" %s\n", missing_charset_list[i]); + g_message (" %s\n", missing_charset_list[i]); XFreeStringList (missing_charset_list); } diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 9dd96da943..a4438cb6d2 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -8,7 +8,7 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public @@ -68,7 +68,7 @@ # define SELECT_MASK fd_set #else # ifndef _AIX - typedef long fd_mask; +typedef long fd_mask; # endif # if defined(_IBMR2) # define SELECT_MASK void @@ -101,120 +101,120 @@ struct _GdkPredicate * Private function declarations */ -static GdkEvent *gdk_event_new (void); -static gint gdk_event_wait (void); -static gint gdk_event_apply_filters (XEvent *xevent, +static GdkEvent *gdk_event_new (void); +static gint gdk_event_wait (void); +static gint gdk_event_apply_filters (XEvent *xevent, GdkEvent *event, GList *filters); -static gint gdk_event_translate (GdkEvent *event, - XEvent *xevent); +static gint gdk_event_translate (GdkEvent *event, + XEvent *xevent); #if 0 -static Bool gdk_event_get_type (Display *display, - XEvent *xevent, +static Bool gdk_event_get_type (Display *display, + XEvent *xevent, XPointer arg); #endif -static void gdk_synthesize_click (GdkEvent *event, - gint nclicks); +static void gdk_synthesize_click (GdkEvent *event, + gint nclicks); -static void gdk_dnd_drag_begin (GdkWindow *initial_window); -static void gdk_dnd_drag_enter (Window dest); -static void gdk_dnd_drag_leave (Window dest); -static void gdk_dnd_drag_end (Window dest, +static void gdk_dnd_drag_begin (GdkWindow *initial_window); +static void gdk_dnd_drag_enter (Window dest); +static void gdk_dnd_drag_leave (Window dest); +static void gdk_dnd_drag_end (Window dest, GdkPoint coords); -static GdkAtom gdk_dnd_check_types (GdkWindow *window, - XEvent *xevent); +static GdkAtom gdk_dnd_check_types (GdkWindow *window, + XEvent *xevent); #ifdef DEBUG_DND -static void gdk_print_atom (GdkAtom anatom); +static void gdk_print_atom (GdkAtom anatom); #endif #ifndef HAVE_XCONVERTCASE -static void gdkx_XConvertCase (KeySym symbol, - KeySym *lower, - KeySym *upper); +static void gdkx_XConvertCase (KeySym symbol, + KeySym *lower, + KeySym *upper); #define XConvertCase gdkx_XConvertCase #endif /* * old junk from offix, we might use it though so leave it */ -Window gdk_get_client_window (Display *dpy, - Window win); +Window gdk_get_client_window (Display *dpy, + Window win); #ifdef WE_HAVE_MOTIF_DROPS_DONE -static GdkWindow * gdk_drop_get_real_window (GdkWindow *w, +static GdkWindow * gdk_drop_get_real_window (GdkWindow *w, guint16 *x, guint16 *y); #endif -static void gdk_exit_func (void); -static int gdk_x_error (Display *display, +static void gdk_exit_func (void); +static int gdk_x_error (Display *display, XErrorEvent *error); -static int gdk_x_io_error (Display *display); -static RETSIGTYPE gdk_signal (int signum); +static int gdk_x_io_error (Display *display); +static RETSIGTYPE gdk_signal (int signum); #ifdef USE_XIM -static guint gdk_im_va_count (va_list list); +static guint gdk_im_va_count (va_list list); static XVaNestedList gdk_im_va_to_nested (va_list list, - guint count); + guint count); static GdkIM gdk_im_get (void); static gint gdk_im_open (XrmDatabase db, gchar* res_name, gchar* rec_class); static void gdk_im_close (void); -static void gdk_ic_cleanup (void); +static void gdk_ic_cleanup (void); #endif /* USE_XIM */ /* Private variable declarations */ -static int gdk_initialized = 0; /* 1 if the library is initialized, +static int gdk_initialized = 0; /* 1 if the library is initialized, * 0 otherwise. */ -static int connection_number = 0; /* The file descriptor number of our - * connection to the X server. This - * is used so that we may determine - * when events are pending by using - * the "select" system call. +static int connection_number = 0; /* The file descriptor number of our + * connection to the X server. This + * is used so that we may determine + * when events are pending by using + * the "select" system call. */ -static struct timeval start; /* The time at which the library was - * last initialized. +static struct timeval start; /* The time at which the library was + * last initialized. */ -static struct timeval timer; /* Timeout interval to use in the call - * to "select". This is used in - * conjunction with "timerp" to create - * a maximum time to wait for an event - * to arrive. +static struct timeval timer; /* Timeout interval to use in the call + * to "select". This is used in + * conjunction with "timerp" to create + * a maximum time to wait for an event + * to arrive. */ -static struct timeval *timerp; /* The actual timer passed to "select" - * This may be NULL, in which case - * "select" will block until an event - * arrives. +static struct timeval *timerp; /* The actual timer passed to "select" + * This may be NULL, in which case + * "select" will block until an event + * arrives. */ -static guint32 timer_val; /* The timeout length as specified by - * the user in milliseconds. +static guint32 timer_val; /* The timeout length as specified by + * the user in milliseconds. */ -static GList *inputs; /* A list of the input file descriptors - * that we care about. Each list node - * contains a GdkInput struct that describes - * when we are interested in the specified - * file descriptor. That is, when it is - * available for read, write or has an - * exception pending. +static GList *inputs; /* A list of the input file descriptors + * that we care about. Each list node + * contains a GdkInput struct that describes + * when we are interested in the specified + * file descriptor. That is, when it is + * available for read, write or has an + * exception pending. */ -static guint32 button_click_time[2]; /* The last 2 button click times. Used - * to determine if the latest button click - * is part of a double or triple click. +static guint32 button_click_time[2]; /* The last 2 button click times. Used + * to determine if the latest button click + * is part of a double or triple click. */ -static GdkWindow *button_window[2]; /* The last 2 windows to receive button presses. - * Also used to determine if the latest button - * click is part of a double or triple click. +static GdkWindow *button_window[2]; /* The last 2 windows to receive button presses. + * Also used to determine if the latest button + * click is part of a double or triple click. */ -static guint button_number[2]; /* The last 2 buttons to be pressed. +static guint button_number[2]; /* The last 2 buttons to be pressed. */ static GdkWindowPrivate *xgrab_window = NULL; /* Window that currently holds the - * x pointer grab + * x pointer grab */ #ifdef USE_XIM @@ -235,11 +235,11 @@ static gint autorepeat; #ifdef G_ENABLE_DEBUG static GDebugKey gdk_debug_keys[] = { - {"events", GDK_DEBUG_EVENTS}, - {"misc", GDK_DEBUG_MISC}, - {"dnd", GDK_DEBUG_DND}, + {"events", GDK_DEBUG_EVENTS}, + {"misc", GDK_DEBUG_MISC}, + {"dnd", GDK_DEBUG_DND}, {"color-context", GDK_DEBUG_COLOR_CONTEXT}, - {"xim", GDK_DEBUG_XIM} + {"xim", GDK_DEBUG_XIM} }; static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey); @@ -268,7 +268,7 @@ static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey); */ void -gdk_init (int *argc, +gdk_init (int *argc, char ***argv) { XKeyboardState keyboard_state; @@ -277,10 +277,10 @@ gdk_init (int *argc, XClassHint *class_hint; gchar **argv_orig = NULL; gint argc_orig = 0; - + if (gdk_initialized) return; - + if (argc && argv) { argc_orig = *argc; @@ -290,9 +290,9 @@ gdk_init (int *argc, argv_orig[i] = g_strdup ((*argv)[i]); argv_orig[argc_orig] = NULL; } - + X_GETTIMEOFDAY (&start); - + #ifndef I_NEED_TO_ACTUALLY_DEBUG_MY_PROGRAMS signal (SIGHUP, gdk_signal); signal (SIGINT, gdk_signal); @@ -302,14 +302,14 @@ gdk_init (int *argc, signal (SIGPIPE, gdk_signal); signal (SIGTERM, gdk_signal); #endif - + gdk_display_name = NULL; - + XSetErrorHandler (gdk_x_error); XSetIOErrorHandler (gdk_x_io_error); - + synchronize = FALSE; - + #ifdef G_ENABLE_DEBUG { gchar *debug_string = getenv("GDK_DEBUG"); @@ -319,20 +319,20 @@ gdk_init (int *argc, gdk_ndebug_keys); } #endif /* G_ENABLE_DEBUG */ - + if (argc && argv) { if (*argc > 0) { gchar *d; - + d = strrchr((*argv)[0],'/'); if (d != NULL) gdk_progname = g_strdup (d + 1); else gdk_progname = g_strdup ((*argv)[0]); } - + for (i = 1; i < *argc;) { #ifdef G_ENABLE_DEBUG @@ -361,7 +361,7 @@ gdk_init (int *argc, (strncmp ("--gdk-no-debug=", (*argv)[i], 15) == 0)) { gchar *equal_pos = strchr ((*argv)[i], '='); - + if (equal_pos != NULL) { gdk_debug_flags &= ~g_parse_debug_string (equal_pos+1, @@ -381,108 +381,108 @@ gdk_init (int *argc, else #endif /* G_ENABLE_DEBUG */ if (strcmp ("--display", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - - if ((i + 1) < *argc && (*argv)[i + 1]) - { - gdk_display_name = g_strdup ((*argv)[i + 1]); - (*argv)[i + 1] = NULL; - i += 1; - } - } - else if (strcmp ("--sync", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - synchronize = TRUE; - } - else if (strcmp ("--no-xshm", (*argv)[i]) == 0) - { - (*argv)[i] = NULL; - gdk_use_xshm = FALSE; - } - else if (strcmp ("--name", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_progname = (*argv)[i]; - (*argv)[i] = NULL; - } - } - else if (strcmp ("--class", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_progclass = (*argv)[i]; - (*argv)[i] = NULL; - } - } + { + (*argv)[i] = NULL; + + if ((i + 1) < *argc && (*argv)[i + 1]) + { + gdk_display_name = g_strdup ((*argv)[i + 1]); + (*argv)[i + 1] = NULL; + i += 1; + } + } + else if (strcmp ("--sync", (*argv)[i]) == 0) + { + (*argv)[i] = NULL; + synchronize = TRUE; + } + else if (strcmp ("--no-xshm", (*argv)[i]) == 0) + { + (*argv)[i] = NULL; + gdk_use_xshm = FALSE; + } + else if (strcmp ("--name", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_progname = (*argv)[i]; + (*argv)[i] = NULL; + } + } + else if (strcmp ("--class", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_progclass = (*argv)[i]; + (*argv)[i] = NULL; + } + } #ifdef XINPUT_GXI - else if (strcmp ("--gxid_host", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_input_gxid_host = ((*argv)[i]); - (*argv)[i] = NULL; - } - } - else if (strcmp ("--gxid_port", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - gdk_input_gxid_port = atoi ((*argv)[i]); - (*argv)[i] = NULL; - } - } + else if (strcmp ("--gxid_host", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_input_gxid_host = ((*argv)[i]); + (*argv)[i] = NULL; + } + } + else if (strcmp ("--gxid_port", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + gdk_input_gxid_port = atoi ((*argv)[i]); + (*argv)[i] = NULL; + } + } #endif #ifdef USE_XIM - else if (strcmp ("--xim-preedit", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - if (strcmp ("none", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditNone); - else if (strcmp ("nothing", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditNothing); - else if (strcmp ("area", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditArea); - else if (strcmp ("position", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditPosition); - else if (strcmp ("callbacks", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMPreeditCallbacks); - } - } - else if (strcmp ("--xim-status", (*argv)[i]) == 0) - { - if ((i + 1) < *argc && (*argv)[i + 1]) - { - (*argv)[i++] = NULL; - if (strcmp ("none", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusNone); - else if (strcmp ("nothing", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusNothing); - else if (strcmp ("area", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusArea); - else if (strcmp ("callbacks", (*argv)[i]) == 0) - gdk_im_set_best_style (GdkIMStatusCallbacks); - } - } + else if (strcmp ("--xim-preedit", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + if (strcmp ("none", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditNone); + else if (strcmp ("nothing", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditNothing); + else if (strcmp ("area", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditArea); + else if (strcmp ("position", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditPosition); + else if (strcmp ("callbacks", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMPreeditCallbacks); + } + } + else if (strcmp ("--xim-status", (*argv)[i]) == 0) + { + if ((i + 1) < *argc && (*argv)[i + 1]) + { + (*argv)[i++] = NULL; + if (strcmp ("none", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusNone); + else if (strcmp ("nothing", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusNothing); + else if (strcmp ("area", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusArea); + else if (strcmp ("callbacks", (*argv)[i]) == 0) + gdk_im_set_best_style (GdkIMStatusCallbacks); + } + } #endif - + i += 1; } - + for (i = 1; i < *argc; i++) { for (k = i; k < *argc; k++) if ((*argv)[k] != NULL) break; - + if (k > i) { k -= i; @@ -496,34 +496,34 @@ gdk_init (int *argc, { gdk_progname = "<unknown>"; } - - GDK_NOTE (MISC, g_print ("Gdk: progname: \"%s\"\n", gdk_progname)); - + + GDK_NOTE (MISC, g_message ("progname: \"%s\"", gdk_progname)); + gdk_display = XOpenDisplay (gdk_display_name); if (!gdk_display) { g_warning ("cannot open display: %s", XDisplayName (gdk_display_name)); exit(1); } - + /* This is really crappy. We have to look into the display structure * to find the base resource id. This is only needed for recording * and playback of events. */ /* base_id = RESOURCE_BASE; */ base_id = 0; - GDK_NOTE (EVENTS, g_print ("base id: %lu\n", base_id)); - + GDK_NOTE (EVENTS, g_message ("base id: %lu", base_id)); + connection_number = ConnectionNumber (gdk_display); GDK_NOTE (MISC, - g_print ("Gdk: connection number: %d\n", connection_number)); - + g_message ("connection number: %d", connection_number)); + if (synchronize) XSynchronize (gdk_display, True); - + gdk_screen = DefaultScreen (gdk_display); gdk_root_window = RootWindow (gdk_display, gdk_screen); - + gdk_leader_window = XCreateSimpleWindow(gdk_display, gdk_root_window, 10, 10, 10, 10, 0, 0 , 0); class_hint = XAllocClassHint(); @@ -548,7 +548,7 @@ gdk_init (int *argc, gdk_wm_window_protocols[0] = gdk_wm_delete_window; gdk_wm_window_protocols[1] = gdk_wm_take_focus; gdk_selection_property = XInternAtom (gdk_display, "GDK_SELECTION", False); - + gdk_dnd.gdk_XdeEnter = gdk_atom_intern("_XDE_ENTER", FALSE); gdk_dnd.gdk_XdeLeave = gdk_atom_intern("_XDE_LEAVE", FALSE); gdk_dnd.gdk_XdeRequest = gdk_atom_intern("_XDE_REQUEST", FALSE); @@ -556,29 +556,29 @@ gdk_init (int *argc, gdk_dnd.gdk_XdeTypelist = gdk_atom_intern("_XDE_TYPELIST", FALSE); gdk_dnd.c->gdk_cursor_dragdefault = XCreateFontCursor(gdk_display, XC_bogosity); gdk_dnd.c->gdk_cursor_dragok = XCreateFontCursor(gdk_display, XC_heart); - + XGetKeyboardControl (gdk_display, &keyboard_state); autorepeat = keyboard_state.global_auto_repeat; - + timer.tv_sec = 0; timer.tv_usec = 0; timerp = NULL; - + button_click_time[0] = 0; button_click_time[1] = 0; button_window[0] = NULL; button_window[1] = NULL; button_number[0] = -1; button_number[1] = -1; - + if (ATEXIT (gdk_exit_func)) g_warning ("unable to register exit function"); - + gdk_visual_init (); gdk_window_init (); gdk_image_init (); gdk_input_init (); - + #ifdef USE_XIM /* initialize XIM Protocol variables */ xim_using = FALSE; @@ -590,10 +590,10 @@ gdk_init (int *argc, gdk_im_set_best_style (GdkIMStatusCallbacks); xim_ic = NULL; xim_window = (GdkWindow*)NULL; - + gdk_im_open (NULL, NULL, NULL); #endif - + gdk_initialized = 1; } @@ -619,9 +619,9 @@ gdk_init (int *argc, void gdk_exit (int errorcode) { - /* de-initialisation is done by the gdk_exit_funct(), - no need to do this here (Alex J.) */ - exit (errorcode); + /* de-initialisation is done by the gdk_exit_funct(), + no need to do this here (Alex J.) */ + exit (errorcode); } /* @@ -641,19 +641,19 @@ gchar* gdk_set_locale (void) { if (!setlocale (LC_ALL,"")) - g_print ("locale not supported by C library\n"); - + g_message ("locale not supported by C library"); + if (!XSupportsLocale ()) { - g_print ("locale not supported by Xlib, locale set to C\n"); + g_message ("locale not supported by Xlib, locale set to C"); setlocale (LC_ALL, "C"); } - + if (!XSetLocaleModifiers ("")) { - g_print ("can not set locale modifiers\n"); + g_message ("can not set locale modifiers"); } - + return setlocale (LC_ALL,NULL); } @@ -680,9 +680,9 @@ gdk_events_pending (void) { gint result; GList *tmp_list; - + result = XPending (gdk_display); - + tmp_list = putback_events; while (tmp_list) { @@ -717,7 +717,7 @@ graphics_expose_predicate (Display *display, GdkWindowPrivate *private = (GdkWindowPrivate *)arg; g_return_val_if_fail (private != NULL, False); - + if ((xevent->xany.window == private->xwindow) && ((xevent->xany.type == GraphicsExpose) || (xevent->xany.type == NoExpose))) @@ -733,20 +733,20 @@ gdk_event_get_graphics_expose (GdkWindow *window) GdkEvent *event; g_return_val_if_fail (window != NULL, NULL); - + XIfEvent (gdk_display, &xevent, graphics_expose_predicate, (XPointer)window); - + if (xevent.xany.type == GraphicsExpose) { event = gdk_event_new (); - + if (gdk_event_translate (event, &xevent)) return event; else gdk_event_free (event); } - return NULL; + return NULL; } /* @@ -775,7 +775,7 @@ gdk_event_get (void) GdkEvent *event; GList *temp_list; XEvent xevent; - + #if 0 if (pred) { @@ -783,7 +783,7 @@ gdk_event_get (void) while (temp_list) { temp_event = temp_list->data; - + if ((* pred) (temp_event, data)) { if (event) @@ -792,29 +792,29 @@ gdk_event_get (void) g_list_free (temp_list); return TRUE; } - + temp_list = temp_list->next; } - + event_pred.func = pred; event_pred.data = data; - + if (XCheckIfEvent (gdk_display, &xevent, gdk_event_get_type, (XPointer) & event_pred)) if (event) return gdk_event_translate (event, &xevent); } else #endif - if (putback_events) - { - event = putback_events->data; - - temp_list = putback_events; - putback_events = g_list_remove_link (putback_events, temp_list); - g_list_free_1 (temp_list); - - return event; - } + if (putback_events) + { + event = putback_events->data; + + temp_list = putback_events; + putback_events = g_list_remove_link (putback_events, temp_list); + g_list_free_1 (temp_list); + + return event; + } /* Wait for an event to occur or the timeout to elapse. * If an event occurs "gdk_event_wait" will return TRUE. @@ -841,7 +841,7 @@ gdk_event_get (void) XNextEvent (gdk_display, &xevent); #endif event = gdk_event_new (); - + event->any.type = GDK_NOTHING; event->any.window = NULL; event->any.send_event = FALSE; @@ -852,7 +852,7 @@ gdk_event_get (void) else gdk_event_free (event); } - + return NULL; } @@ -860,11 +860,11 @@ void gdk_event_put (GdkEvent *event) { GdkEvent *new_event; - + g_return_if_fail (event != NULL); - + new_event = gdk_event_copy (event); - + putback_events = g_list_prepend (putback_events, new_event); } @@ -898,9 +898,9 @@ gdk_event_new (void) sizeof (GdkEvent), 4096, G_ALLOC_AND_FREE); - + new_event = g_chunk_new (GdkEvent, event_chunk); - + return new_event; } @@ -910,25 +910,25 @@ gdk_event_copy (GdkEvent *event) GdkEvent *new_event; g_return_val_if_fail (event != NULL, NULL); - + new_event = gdk_event_new (); - + *new_event = *event; gdk_window_ref (new_event->any.window); - + switch (event->any.type) { case GDK_KEY_PRESS: case GDK_KEY_RELEASE: new_event->key.string = g_strdup (event->key.string); break; - + case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: if (event->crossing.subwindow != NULL) gdk_window_ref (event->crossing.subwindow); break; - + case GDK_DROP_DATA_AVAIL: new_event->dropdataavailable.data_type = g_strdup (event->dropdataavailable.data_type); new_event->dropdataavailable.data = g_malloc (event->dropdataavailable.data_numbytes); @@ -936,11 +936,11 @@ gdk_event_copy (GdkEvent *event) event->dropdataavailable.data, event->dropdataavailable.data_numbytes); break; - + default: break; } - + return new_event; } @@ -967,36 +967,36 @@ gdk_event_free (GdkEvent *event) { g_assert (event_chunk != NULL); g_return_if_fail (event != NULL); - + if (event->any.window) gdk_window_unref (event->any.window); - + switch (event->any.type) { case GDK_KEY_PRESS: case GDK_KEY_RELEASE: g_free (event->key.string); break; - + case GDK_ENTER_NOTIFY: case GDK_LEAVE_NOTIFY: if (event->crossing.subwindow != NULL) gdk_window_unref (event->crossing.subwindow); break; - + case GDK_DROP_DATA_AVAIL: g_free (event->dropdataavailable.data_type); g_free (event->dropdataavailable.data); break; - + case GDK_DRAG_REQUEST: g_free (event->dragrequest.data_type); break; - + default: break; } - + g_mem_chunk_free (event_chunk, event); } @@ -1073,9 +1073,9 @@ gdk_time_get (void) struct timeval end; struct timeval elapsed; guint32 milliseconds; - + X_GETTIMEOFDAY (&end); - + if (start.tv_usec > end.tv_usec) { end.tv_usec += 1000000; @@ -1083,9 +1083,9 @@ gdk_time_get (void) } elapsed.tv_sec = end.tv_sec - start.tv_sec; elapsed.tv_usec = end.tv_usec - start.tv_usec; - + milliseconds = (elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000); - + return milliseconds; } @@ -1138,7 +1138,7 @@ gdk_timer_set (guint32 milliseconds) timer_val = milliseconds; timer.tv_sec = milliseconds / 1000; timer.tv_usec = (milliseconds % 1000) * 1000; - + } void @@ -1154,25 +1154,25 @@ gdk_timer_disable (void) } gint -gdk_input_add_full (gint source, +gdk_input_add_full (gint source, GdkInputCondition condition, GdkInputFunction function, - gpointer data, + gpointer data, GdkDestroyNotify destroy) { static gint next_tag = 1; GList *list; GdkInput *input; gint tag; - + tag = 0; list = inputs; - + while (list) { input = list->data; list = list->next; - + if ((input->source == source) && (input->condition == condition)) { if (input->destroy) @@ -1183,7 +1183,7 @@ gdk_input_add_full (gint source, tag = input->tag; } } - + if (!tag) { input = g_new (GdkInput, 1); @@ -1194,18 +1194,18 @@ gdk_input_add_full (gint source, input->data = data; input->destroy = destroy; tag = input->tag; - + inputs = g_list_prepend (inputs, input); } - + return tag; } gint -gdk_input_add (gint source, +gdk_input_add (gint source, GdkInputCondition condition, - GdkInputFunction function, - gpointer data) + GdkInputFunction function, + gpointer data) { return gdk_input_add_interp (source, condition, function, data, NULL); } @@ -1215,23 +1215,23 @@ gdk_input_remove (gint tag) { GList *list; GdkInput *input; - + list = inputs; while (list) { input = list->data; - + if (input->tag == tag) { if (input->destroy) (input->destroy) (input->data); - - input->tag = 0; /* do not free it here */ - input->condition = 0; /* it's done in gdk_event_wait */ - + + input->tag = 0; /* do not free it here */ + input->condition = 0; /* it's done in gdk_event_wait */ + break; } - + list = list->next; } } @@ -1260,17 +1260,17 @@ gdk_input_remove (gint tag) */ gint -gdk_pointer_grab (GdkWindow * window, - gint owner_events, - GdkEventMask event_mask, - GdkWindow * confine_to, - GdkCursor * cursor, - guint32 time) +gdk_pointer_grab (GdkWindow * window, + gint owner_events, + GdkEventMask event_mask, + GdkWindow * confine_to, + GdkCursor * cursor, + guint32 time) { - /* From gdkwindow.c */ + /* From gdkwindow.c */ extern int nevent_masks; extern int event_mask_table[]; - + gint return_val; GdkWindowPrivate *window_private; GdkWindowPrivate *confine_to_private; @@ -1280,33 +1280,33 @@ gdk_pointer_grab (GdkWindow * window, Window xconfine_to; Cursor xcursor; int i; - + g_return_val_if_fail (window != NULL, 0); - + window_private = (GdkWindowPrivate*) window; confine_to_private = (GdkWindowPrivate*) confine_to; cursor_private = (GdkCursorPrivate*) cursor; - + xwindow = window_private->xwindow; - + if (!confine_to || confine_to_private->destroyed) xconfine_to = None; else xconfine_to = confine_to_private->xwindow; - + if (!cursor) xcursor = None; else xcursor = cursor_private->xcursor; - - + + xevent_mask = 0; for (i = 0; i < nevent_masks; i++) { if (event_mask & (1 << (i + 1))) xevent_mask |= event_mask_table[i]; } - + if (((GdkWindowPrivate *)window)->extension_events && gdk_input_vtable.grab_pointer) return_val = gdk_input_vtable.grab_pointer (window, @@ -1331,7 +1331,7 @@ gdk_pointer_grab (GdkWindow * window, else return_val = AlreadyGrabbed; } - + if (return_val == GrabSuccess) xgrab_window = window_private; @@ -1358,7 +1358,7 @@ gdk_pointer_ungrab (guint32 time) { if (gdk_input_vtable.ungrab_pointer) gdk_input_vtable.ungrab_pointer (time); - + XUngrabPointer (gdk_display, time); xgrab_window = NULL; } @@ -1405,18 +1405,18 @@ gdk_pointer_is_grabbed (void) */ gint -gdk_keyboard_grab (GdkWindow * window, - gint owner_events, - guint32 time) +gdk_keyboard_grab (GdkWindow * window, + gint owner_events, + guint32 time) { GdkWindowPrivate *window_private; Window xwindow; - + g_return_val_if_fail (window != NULL, 0); - + window_private = (GdkWindowPrivate*) window; xwindow = window_private->xwindow; - + if (!window_private->destroyed) return XGrabKeyboard (window_private->xdisplay, xwindow, @@ -1467,9 +1467,9 @@ gint gdk_screen_width (void) { gint return_val; - + return_val = DisplayWidth (gdk_display, gdk_screen); - + return return_val; } @@ -1492,9 +1492,9 @@ gint gdk_screen_height (void) { gint return_val; - + return_val = DisplayHeight (gdk_display, gdk_screen); - + return return_val; } @@ -1517,9 +1517,9 @@ gint gdk_screen_width_mm (void) { gint return_val; - + return_val = DisplayWidthMM (gdk_display, gdk_screen); - + return return_val; } @@ -1542,9 +1542,9 @@ gint gdk_screen_height_mm (void) { gint return_val; - + return_val = DisplayHeightMM (gdk_display, gdk_screen); - + return return_val; } @@ -1624,7 +1624,7 @@ gdk_event_wait (void) SELECT_MASK exceptfds; int max_input; int nfd; - + /* If there are no events pending we will wait for an event. * The time we wait is dependant on the "timer". If no timer * has been specified then we'll block until an event arrives. @@ -1632,21 +1632,21 @@ gdk_event_wait (void) * arrives or the timer expires. (This is all done using the * "select" system call). */ - + if (XPending (gdk_display) == 0) { FD_ZERO (&readfds); FD_ZERO (&writefds); FD_ZERO (&exceptfds); - + FD_SET (connection_number, &readfds); max_input = connection_number; - + list = inputs; while (list) { input = list->data; - + if (input->tag) { if (input->condition & GDK_INPUT_READ) @@ -1655,14 +1655,14 @@ gdk_event_wait (void) FD_SET (input->source, &writefds); if (input->condition & GDK_INPUT_EXCEPTION) FD_SET (input->source, &exceptfds); - + max_input = MAX (max_input, input->source); list = list->next; } - else /* free removed inputs */ + else /* free removed inputs */ { temp_list = list; - + if (list->next) list->next->prev = list->prev; if (list->prev) @@ -1671,28 +1671,28 @@ gdk_event_wait (void) inputs = list->next; list = list->next; - + temp_list->next = NULL; temp_list->prev = NULL; - + g_free (temp_list->data); g_list_free (temp_list); } } - + #ifdef USE_PTHREADS if (gdk_using_threads) { gdk_select_waiting = TRUE; - + FD_SET (gdk_threads_pipe[0], &readfds); max_input = MAX (max_input, gdk_threads_pipe[0]); gdk_threads_leave (); } #endif - + nfd = select (max_input+1, &readfds, &writefds, &exceptfds, timerp); - + #ifdef USE_PTHREADS if (gdk_using_threads) { @@ -1704,10 +1704,10 @@ gdk_event_wait (void) read (gdk_threads_pipe[0], &c, 1); } #endif - + timerp = NULL; timer_val = 0; - + if (nfd > 0) { if (FD_ISSET (connection_number, &readfds)) @@ -1724,13 +1724,13 @@ gdk_event_wait (void) else return TRUE; } - + list = inputs; while (list) { input = list->data; list = list->next; - + condition = 0; if (FD_ISSET (input->source, &readfds)) condition |= GDK_INPUT_READ; @@ -1738,7 +1738,7 @@ gdk_event_wait (void) condition |= GDK_INPUT_WRITE; if (FD_ISSET (input->source, &exceptfds)) condition |= GDK_INPUT_EXCEPTION; - + if (condition && input->function) (* input->function) (input->data, input->source, condition); } @@ -1746,7 +1746,7 @@ gdk_event_wait (void) } else return TRUE; - + return FALSE; } @@ -1758,20 +1758,20 @@ gdk_event_apply_filters (XEvent *xevent, GdkEventFilter *filter; GList *tmp_list; GdkFilterReturn result; - + tmp_list = filters; while (tmp_list) { filter = (GdkEventFilter *)tmp_list->data; - + result = (*filter->function)(xevent, event, filter->data); if (result != GDK_FILTER_CONTINUE) return result; - + tmp_list = tmp_list->next; } - + return GDK_FILTER_CONTINUE; } @@ -1779,7 +1779,7 @@ static gint gdk_event_translate (GdkEvent *event, XEvent *xevent) { - + GdkWindow *window; GdkWindowPrivate *window_private; static XComposeStatus compose; @@ -1792,13 +1792,13 @@ gdk_event_translate (GdkEvent *event, char buf[16]; #endif gint return_val; - + return_val = FALSE; - + /* We need to play catch-up with the dnd motion events */ if(gdk_dnd.drag_really && xevent->type == MotionNotify) - while (XCheckTypedEvent(xevent->xany.display,MotionNotify,xevent)); - + while (XCheckTypedEvent(xevent->xany.display,MotionNotify,xevent)); + /* Find the GdkWindow that this event occurred in. * All events occur in some GdkWindow (otherwise, why * would we be receiving them). It really is an error @@ -1807,30 +1807,30 @@ gdk_event_translate (GdkEvent *event, * specially - they are generated by XFree86's XInput under * some circumstances. */ - + if ((xevent->xany.window == None) && gdk_input_vtable.window_none_event) { return_val = gdk_input_vtable.window_none_event (event,xevent); - + if (return_val >= 0) /* was handled */ return return_val; else return_val = FALSE; } - + window = gdk_window_lookup (xevent->xany.window); window_private = (GdkWindowPrivate *) window; - + if (window != NULL) gdk_window_ref (window); else if(gdk_null_window_warnings) /* Special purpose programs that get events for other windows may want to disable this */ g_warning ("%#lx -> NULL\n", xevent->xany.window); - + /* Check for filters for this window */ - + { GdkFilterReturn result; result = gdk_event_apply_filters (xevent, event, @@ -1843,7 +1843,7 @@ gdk_event_translate (GdkEvent *event, return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE; } } - + /* We do a "manual" conversion of the XEvent to a * GdkEvent. The structures are mostly the same so * the conversion is fairly straightforward. We also @@ -1861,12 +1861,12 @@ gdk_event_translate (GdkEvent *event, */ #ifdef USE_XIM if (buf_len == 0) - { + { buf_len = 128; buf = g_new (gchar, buf_len); } keysym = GDK_VoidSymbol; - + if (xim_using == TRUE && xim_ic) { Status status; @@ -1876,15 +1876,15 @@ gdk_event_translate (GdkEvent *event, &xevent->xkey, buf, buf_len-1, &keysym, &status); if (status == XBufferOverflow) - { /* retry */ + { /* retry */ /* alloc adequate size of buffer */ GDK_NOTE (XIM, - g_print("XIM: overflow (required %i)\n", charcount)); - + g_message("XIM: overflow (required %i)", charcount)); + while (buf_len <= charcount) buf_len *= 2; buf = (gchar *) g_realloc (buf, buf_len); - + charcount = XmbLookupString (xim_ic->xic, &xevent->xkey, buf, buf_len-1, &keysym, &status); @@ -1903,41 +1903,41 @@ gdk_event_translate (GdkEvent *event, &keysym, &compose); #endif event->key.keyval = keysym; - + if (charcount > 0 && buf[charcount-1] == '\0') charcount --; else buf[charcount] = '\0'; - + /* Print debugging info. */ #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & GDK_DEBUG_EVENTS) { - g_print ("key press:\twindow: %ld key: %12s %d\n", - xevent->xkey.window - base_id, - event->key.keyval ? XKeysymToString (event->key.keyval) : "(none)", - event->key.keyval); + g_message ("key press:\twindow: %ld key: %12s %d", + xevent->xkey.window - base_id, + event->key.keyval ? XKeysymToString (event->key.keyval) : "(none)", + event->key.keyval); if (charcount > 0) - g_print ("\t\tlength: %4d string: \"%s\"\n", - charcount, buf); + g_message ("\t\tlength: %4d string: \"%s\"", + charcount, buf); } #endif /* G_ENABLE_DEBUG */ - + event->key.type = GDK_KEY_PRESS; event->key.window = window; event->key.time = xevent->xkey.time; event->key.state = (GdkModifierType) xevent->xkey.state; event->key.string = g_strdup (buf); event->key.length = charcount; - + return_val = window_private && !window_private->destroyed; if (!return_val) g_free (event->key.string); break; - + case KeyRelease: /* Lookup the string corresponding to the given keysym. */ @@ -1945,40 +1945,40 @@ gdk_event_translate (GdkEvent *event, charcount = XLookupString (&xevent->xkey, buf, 16, &keysym, &compose); event->key.keyval = keysym; - + /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("key release:\t\twindow: %ld key: %12s %d\n", - xevent->xkey.window - base_id, - XKeysymToString (event->key.keyval), - event->key.keyval)); - + g_message ("key release:\t\twindow: %ld key: %12s %d", + xevent->xkey.window - base_id, + XKeysymToString (event->key.keyval), + event->key.keyval)); + event->key.type = GDK_KEY_RELEASE; event->key.window = window; event->key.time = xevent->xkey.time; event->key.state = (GdkModifierType) xevent->xkey.state; event->key.length = 0; event->key.string = NULL; - + return_val = window_private && !window_private->destroyed; break; - + case ButtonPress: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d\n", - window_private?window_private->dnd_drag_enabled:0, - xevent->xbutton.window - base_id, - xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button)); - + g_message ("button press[%d]:\t\twindow: %ld x,y: %d %d button: %d", + window_private?window_private->dnd_drag_enabled:0, + xevent->xbutton.window - base_id, + xevent->xbutton.x, xevent->xbutton.y, + xevent->xbutton.button)); + if (window_private && (window_private->extension_events != 0) && gdk_input_ignore_core) break; - + event->button.type = GDK_BUTTON_PRESS; event->button.window = window; event->button.time = xevent->xbutton.time; @@ -1993,13 +1993,13 @@ gdk_event_translate (GdkEvent *event, event->button.button = xevent->xbutton.button; event->button.source = GDK_SOURCE_MOUSE; event->button.deviceid = GDK_CORE_POINTER; - + if ((event->button.time < (button_click_time[1] + TRIPLE_CLICK_TIME)) && (event->button.window == button_window[1]) && (event->button.button == button_number[1])) { gdk_synthesize_click (event, 3); - + button_click_time[1] = 0; button_click_time[0] = 0; button_window[1] = NULL; @@ -2012,7 +2012,7 @@ gdk_event_translate (GdkEvent *event, (event->button.button == button_number[0])) { gdk_synthesize_click (event, 2); - + button_click_time[1] = button_click_time[0]; button_click_time[0] = event->button.time; button_window[1] = button_window[0]; @@ -2047,13 +2047,13 @@ gdk_event_translate (GdkEvent *event, } gdk_dnd.drag_numwindows = gdk_dnd.drag_really = 0; gdk_dnd.dnd_grabbed = FALSE; - + { /* Set motion mask for first DnD'd window, since it will be the one that is actually dragged */ XWindowAttributes dnd_winattr; XSetWindowAttributes dnd_setwinattr; - + /* We need to get motion events while the button is down, so we can know whether to really start dragging or not... */ XGetWindowAttributes(gdk_display, (Window)window_private->xwindow, @@ -2062,29 +2062,29 @@ gdk_event_translate (GdkEvent *event, window_private->dnd_drag_savedeventmask = dnd_winattr.your_event_mask; dnd_setwinattr.event_mask = window_private->dnd_drag_eventmask = ButtonMotionMask | ButtonPressMask | ButtonReleaseMask | - EnterWindowMask | LeaveWindowMask | ExposureMask; + EnterWindowMask | LeaveWindowMask | ExposureMask; XChangeWindowAttributes(gdk_display, window_private->xwindow, CWEventMask, &dnd_setwinattr); + } } - } return_val = window_private && !window_private->destroyed; break; - + case ButtonRelease: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("button release[%d]:\twindow: %ld x,y: %d %d button: %d\n", - window_private?window_private->dnd_drag_enabled:0, - xevent->xbutton.window - base_id, - xevent->xbutton.x, xevent->xbutton.y, - xevent->xbutton.button)); - + g_message ("button release[%d]:\twindow: %ld x,y: %d %d button: %d", + window_private?window_private->dnd_drag_enabled:0, + xevent->xbutton.window - base_id, + xevent->xbutton.x, xevent->xbutton.y, + xevent->xbutton.button)); + if (window_private && (window_private->extension_events != 0) && gdk_input_ignore_core) break; - + event->button.type = GDK_BUTTON_RELEASE; event->button.window = window; event->button.time = xevent->xbutton.time; @@ -2099,7 +2099,7 @@ gdk_event_translate (GdkEvent *event, event->button.button = xevent->xbutton.button; event->button.source = GDK_SOURCE_MOUSE; event->button.deviceid = GDK_CORE_POINTER; - + gdk_dnd.last_drop_time = xevent->xbutton.time; if(gdk_dnd.drag_perhaps) { @@ -2109,7 +2109,7 @@ gdk_event_translate (GdkEvent *event, doesn't change during drag */ attrs.event_mask = gdk_dnd.real_sw->dnd_drag_savedeventmask; XChangeWindowAttributes(gdk_display, gdk_dnd.real_sw->xwindow, - CWEventMask, &attrs); + CWEventMask, &attrs); } if (gdk_dnd.dnd_grabbed) @@ -2121,51 +2121,51 @@ gdk_event_translate (GdkEvent *event, gdk_dnd.dnd_grabbed = FALSE; } - if(gdk_dnd.drag_really) - { - GdkPoint foo; - foo.x = xevent->xbutton.x_root; - foo.y = xevent->xbutton.y_root; - - if(gdk_dnd.dnd_drag_target != None) - gdk_dnd_drag_end(gdk_dnd.dnd_drag_target, foo); - gdk_dnd.drag_really = 0; - - gdk_dnd.drag_numwindows = 0; - if(gdk_dnd.drag_startwindows) + if(gdk_dnd.drag_really) { - g_free(gdk_dnd.drag_startwindows); - gdk_dnd.drag_startwindows = NULL; + GdkPoint foo; + foo.x = xevent->xbutton.x_root; + foo.y = xevent->xbutton.y_root; + + if(gdk_dnd.dnd_drag_target != None) + gdk_dnd_drag_end(gdk_dnd.dnd_drag_target, foo); + gdk_dnd.drag_really = 0; + + gdk_dnd.drag_numwindows = 0; + if(gdk_dnd.drag_startwindows) + { + g_free(gdk_dnd.drag_startwindows); + gdk_dnd.drag_startwindows = NULL; + } + + gdk_dnd.real_sw = NULL; } - - gdk_dnd.real_sw = NULL; - } - - gdk_dnd.drag_perhaps = 0; - gdk_dnd.dnd_drag_start.x = gdk_dnd.dnd_drag_start.y = 0; - gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0; - gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0; - gdk_dnd.dnd_drag_curwin = None; - return_val = window_private?TRUE:FALSE; - } else - return_val = window_private && !window_private->destroyed; + + gdk_dnd.drag_perhaps = 0; + gdk_dnd.dnd_drag_start.x = gdk_dnd.dnd_drag_start.y = 0; + gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0; + gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0; + gdk_dnd.dnd_drag_curwin = None; + return_val = window_private?TRUE:FALSE; + } else + return_val = window_private && !window_private->destroyed; break; - + case MotionNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s d:%d r%d\n", - xevent->xmotion.window - base_id, - xevent->xmotion.x, xevent->xmotion.y, - (xevent->xmotion.is_hint) ? "true" : "false", - gdk_dnd.drag_perhaps, gdk_dnd.drag_really)); - + g_message ("motion notify:\t\twindow: %ld x,y: %d %d hint: %s d:%d r%d", + xevent->xmotion.window - base_id, + xevent->xmotion.x, xevent->xmotion.y, + (xevent->xmotion.is_hint) ? "true" : "false", + gdk_dnd.drag_perhaps, gdk_dnd.drag_really)); + if (window_private && (window_private->extension_events != 0) && gdk_input_ignore_core) break; - + event->motion.type = GDK_MOTION_NOTIFY; event->motion.window = window; event->motion.time = xevent->xmotion.time; @@ -2180,12 +2180,12 @@ gdk_event_translate (GdkEvent *event, event->motion.is_hint = xevent->xmotion.is_hint; event->motion.source = GDK_SOURCE_MOUSE; event->motion.deviceid = GDK_CORE_POINTER; - + #define IS_IN_ZONE(cx, cy) (cx >= gdk_dnd.dnd_drag_dropzone.x \ && cy >= gdk_dnd.dnd_drag_dropzone.y \ && cx < (gdk_dnd.dnd_drag_dropzone.x + gdk_dnd.dnd_drag_dropzone.width) \ && cy < (gdk_dnd.dnd_drag_dropzone.y + gdk_dnd.dnd_drag_dropzone.height)) - + if(gdk_dnd.drag_perhaps && gdk_dnd.drag_really /* && event->motion.is_hint */ /* HINTME */) { @@ -2199,13 +2199,13 @@ gdk_event_translate (GdkEvent *event, #endif Window childwin = gdk_root_window; int x, y, ox, oy; - + /* Interlude - display cursor for the drag ASAP */ gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, xevent->xmotion.y_root, gdk_dnd.dnd_drag_target?TRUE:FALSE, FALSE); - + lastwin = curwin; curwin = gdk_root_window; ox = x = xevent->xmotion.x_root; @@ -2231,23 +2231,23 @@ gdk_event_translate (GdkEvent *event, } #endif GDK_NOTE (DND, - g_print("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx\n", - curwin, lastwin, gdk_dnd.dnd_drag_curwin)); + g_message("Drag is now in window %#lx, lastwin was %#lx, ddc = %#lx", + curwin, lastwin, gdk_dnd.dnd_drag_curwin)); if(curwin != gdk_dnd.dnd_drag_curwin && curwin != lastwin) { /* We have left one window and entered another (do leave & enter bits) */ if(gdk_dnd.dnd_drag_curwin != None) - gdk_dnd_drag_leave(gdk_dnd.dnd_drag_curwin); + gdk_dnd_drag_leave(gdk_dnd.dnd_drag_curwin); gdk_dnd.dnd_drag_curwin = curwin; gdk_dnd_drag_enter(gdk_dnd.dnd_drag_curwin); gdk_dnd.dnd_drag_dropzone.x = gdk_dnd.dnd_drag_dropzone.y = 0; gdk_dnd.dnd_drag_dropzone.width = gdk_dnd.dnd_drag_dropzone.height = 0; gdk_dnd.dnd_drag_target = None; GDK_NOTE (DND, - g_print("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx\n", - curwin, lastwin, gdk_dnd.dnd_drag_curwin)); - + g_message("curwin = %#lx, lastwin = %#lx, dnd_drag_curwin = %#lx", + curwin, lastwin, gdk_dnd.dnd_drag_curwin)); + gdk_dnd_display_drag_cursor(xevent->xmotion.x_root, xevent->xmotion.y_root, FALSE, TRUE); @@ -2263,7 +2263,7 @@ gdk_event_translate (GdkEvent *event, xevent->xmotion.y_root); gboolean old_in_zone = IS_IN_ZONE(gdk_dnd.dnd_drag_oldpos.x, gdk_dnd.dnd_drag_oldpos.y); - + if (!in_zone && old_in_zone) { /* We were in the drop zone and moved out */ @@ -2284,31 +2284,31 @@ gdk_event_translate (GdkEvent *event, } } } /* else - dnd_drag_curwin = None; */ + dnd_drag_curwin = None; */ return_val = FALSE; } else return_val = window_private && !window_private->destroyed; break; - + case EnterNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("enter notify:\t\twindow: %ld detail: %d subwin: %ld\n", - xevent->xcrossing.window - base_id, - xevent->xcrossing.detail, - xevent->xcrossing.subwindow - base_id)); - + g_message ("enter notify:\t\twindow: %ld detail: %d subwin: %ld", + xevent->xcrossing.window - base_id, + xevent->xcrossing.detail, + xevent->xcrossing.subwindow - base_id)); + /* Tell XInput stuff about it if appropriate */ if (window_private && (window_private->extension_events != 0) && gdk_input_vtable.enter_event) gdk_input_vtable.enter_event (&xevent->xcrossing, window); - + event->crossing.type = GDK_ENTER_NOTIFY; event->crossing.window = window; - + /* If the subwindow field of the XEvent is non-NULL, then * lookup the corresponding GdkWindow. */ @@ -2316,13 +2316,13 @@ gdk_event_translate (GdkEvent *event, event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow); else event->crossing.subwindow = NULL; - + event->crossing.time = xevent->xcrossing.time; event->crossing.x = xevent->xcrossing.x; event->crossing.y = xevent->xcrossing.y; event->crossing.x_root = xevent->xcrossing.x_root; event->crossing.y_root = xevent->xcrossing.y_root; - + /* Translate the crossing mode into Gdk terms. */ switch (xevent->xcrossing.mode) @@ -2337,7 +2337,7 @@ gdk_event_translate (GdkEvent *event, event->crossing.mode = GDK_CROSSING_UNGRAB; break; }; - + /* Translate the crossing detail into Gdk terms. */ switch (xevent->xcrossing.detail) @@ -2361,52 +2361,52 @@ gdk_event_translate (GdkEvent *event, event->crossing.detail = GDK_NOTIFY_UNKNOWN; break; } - + event->crossing.focus = xevent->xcrossing.focus; event->crossing.state = xevent->xcrossing.state; - + #ifdef G_ENABLE_DEBUG - if ((gdk_debug_flags & GDK_DEBUG_DND) & gdk_dnd.drag_perhaps) - { - g_print("We may[%d] have a drag into %#lx = %#lx\n", + if ((gdk_debug_flags & GDK_DEBUG_DND) & gdk_dnd.drag_perhaps) + { + g_message("We may[%d] have a drag into %#lx = %#lx", gdk_dnd.drag_really, xevent->xcrossing.window, gdk_dnd.real_sw->xwindow); - } + } #endif /* G_ENABLE_DEBUG */ - - if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really && - (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow)) - { + + if (gdk_dnd.drag_perhaps && gdk_dnd.drag_really && + (xevent->xcrossing.window == gdk_dnd.real_sw->xwindow)) + { #if 0 - gdk_dnd.drag_really = 0; - - GDK_NOTE (DND, g_print("Ungrabbed\n")); - - gdk_dnd.drag_numwindows = 0; - g_free(gdk_dnd.drag_startwindows); - gdk_dnd.drag_startwindows = NULL; - /* We don't want to ungrab the pointer here, or we'll - * start getting spurious enter/leave events */ + gdk_dnd.drag_really = 0; + + GDK_NOTE (DND, g_message("Ungrabbed")); + + gdk_dnd.drag_numwindows = 0; + g_free(gdk_dnd.drag_startwindows); + gdk_dnd.drag_startwindows = NULL; + /* We don't want to ungrab the pointer here, or we'll + * start getting spurious enter/leave events */ #endif #if 0 - XChangeActivePointerGrab (gdk_display, 0, None, CurrentTime); + XChangeActivePointerGrab (gdk_display, 0, None, CurrentTime); #endif - } - - return_val = window_private && !window_private->destroyed; - break; - + } + + return_val = window_private && !window_private->destroyed; + break; + case LeaveNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("leave notify:\t\twindow: %ld detail: %d subwin: %ld\n", - xevent->xcrossing.window - base_id, - xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id)); - + g_message ("leave notify:\t\twindow: %ld detail: %d subwin: %ld", + xevent->xcrossing.window - base_id, + xevent->xcrossing.detail, xevent->xcrossing.subwindow - base_id)); + event->crossing.type = GDK_LEAVE_NOTIFY; event->crossing.window = window; - + /* If the subwindow field of the XEvent is non-NULL, then * lookup the corresponding GdkWindow. */ @@ -2414,13 +2414,13 @@ gdk_event_translate (GdkEvent *event, event->crossing.subwindow = gdk_window_lookup (xevent->xcrossing.subwindow); else event->crossing.subwindow = NULL; - + event->crossing.time = xevent->xcrossing.time; event->crossing.x = xevent->xcrossing.x; event->crossing.y = xevent->xcrossing.y; event->crossing.x_root = xevent->xcrossing.x_root; event->crossing.y_root = xevent->xcrossing.y_root; - + /* Translate the crossing mode into Gdk terms. */ switch (xevent->xcrossing.mode) @@ -2435,7 +2435,7 @@ gdk_event_translate (GdkEvent *event, event->crossing.mode = GDK_CROSSING_UNGRAB; break; }; - + /* Translate the crossing detail into Gdk terms. */ switch (xevent->xcrossing.detail) @@ -2459,16 +2459,16 @@ gdk_event_translate (GdkEvent *event, event->crossing.detail = GDK_NOTIFY_UNKNOWN; break; } - + event->crossing.focus = xevent->xcrossing.focus; event->crossing.state = xevent->xcrossing.state; - + #ifdef G_ENABLE_DEBUG if ((gdk_debug_flags & GDK_DEBUG_DND) & gdk_dnd.drag_perhaps) { - g_print("We may[%d] have a drag out of %#lx = %#lx\n", - gdk_dnd.drag_really, - xevent->xcrossing.window, gdk_dnd.real_sw->xwindow); + g_message("We may[%d] have a drag out of %#lx = %#lx", + gdk_dnd.drag_really, + xevent->xcrossing.window, gdk_dnd.real_sw->xwindow); } #endif /* G_ENABLE_DEBUG */ if (gdk_dnd.drag_perhaps && !gdk_dnd.drag_really && @@ -2478,14 +2478,14 @@ gdk_event_translate (GdkEvent *event, gdk_dnd_drag_addwindow((GdkWindow *) gdk_dnd.real_sw); gdk_dnd_drag_begin((GdkWindow *) gdk_dnd.real_sw); xgpret = - XGrabPointer(gdk_display, gdk_dnd.real_sw->xwindow, False, - ButtonMotionMask | PointerMotionMask | - /* PointerMotionHintMask | */ /* HINTME */ - ButtonPressMask | ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, None, - None, CurrentTime); + XGrabPointer(gdk_display, gdk_dnd.real_sw->xwindow, False, + ButtonMotionMask | PointerMotionMask | + /* PointerMotionHintMask | */ /* HINTME */ + ButtonPressMask | ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, + None, CurrentTime); #ifdef G_ENABLE_DEBUG - GDK_NOTE(DND, g_print("xgpret = %d\n", xgpret)); + GDK_NOTE(DND, g_message("xgpret = %d", xgpret)); #endif gdk_dnd.dnd_grabbed = TRUE; gdk_dnd.drag_really = 1; @@ -2493,10 +2493,10 @@ gdk_event_translate (GdkEvent *event, xevent->xmotion.y_root, FALSE, TRUE); } - + return_val = window_private && !window_private->destroyed; break; - + case FocusIn: case FocusOut: /* We only care about focus events that indicate that _this_ @@ -2510,9 +2510,9 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("focus %s:\t\twindow: %ld\n", - (xevent->xany.type == FocusIn) ? "in" : "out", - xevent->xfocus.window - base_id)); + g_message ("focus %s:\t\twindow: %ld", + (xevent->xany.type == FocusIn) ? "in" : "out", + xevent->xfocus.window - base_id)); event->focus_change.type = GDK_FOCUS_CHANGE; event->focus_change.window = window; @@ -2521,28 +2521,28 @@ gdk_event_translate (GdkEvent *event, return_val = window_private && !window_private->destroyed; break; default: - ; + ; } break; - + case KeymapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("keymap notify\n")); - + g_message ("keymap notify")); + /* Not currently handled */ break; - + case Expose: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d\n", - xevent->xexpose.window - base_id, xevent->xexpose.count, - xevent->xexpose.x, xevent->xexpose.y, - xevent->xexpose.width, xevent->xexpose.height)); - + g_message ("expose:\t\twindow: %ld %d x,y: %d %d w,h: %d %d", + xevent->xexpose.window - base_id, xevent->xexpose.count, + xevent->xexpose.x, xevent->xexpose.y, + xevent->xexpose.width, xevent->xexpose.height)); + event->expose.type = GDK_EXPOSE; event->expose.window = window; event->expose.area.x = xevent->xexpose.x; @@ -2550,17 +2550,17 @@ gdk_event_translate (GdkEvent *event, event->expose.area.width = xevent->xexpose.width; event->expose.area.height = xevent->xexpose.height; event->expose.count = xevent->xexpose.count; - + return_val = window_private && !window_private->destroyed; break; - + case GraphicsExpose: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("graphics expose:\tdrawable: %ld\n", - xevent->xgraphicsexpose.drawable - base_id)); - + g_message ("graphics expose:\tdrawable: %ld", + xevent->xgraphicsexpose.drawable - base_id)); + event->expose.type = GDK_EXPOSE; event->expose.window = window; event->expose.area.x = xevent->xgraphicsexpose.x; @@ -2568,23 +2568,23 @@ gdk_event_translate (GdkEvent *event, event->expose.area.width = xevent->xgraphicsexpose.width; event->expose.area.height = xevent->xgraphicsexpose.height; event->expose.count = xevent->xexpose.count; - + return_val = window_private && !window_private->destroyed; break; - + case NoExpose: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("no expose:\t\tdrawable: %ld\n", - xevent->xnoexpose.drawable - base_id)); - + g_message ("no expose:\t\tdrawable: %ld", + xevent->xnoexpose.drawable - base_id)); + event->no_expose.type = GDK_NO_EXPOSE; event->no_expose.window = window; - + return_val = window_private && !window_private->destroyed; break; - + case VisibilityNotify: /* Print debugging info. */ @@ -2593,33 +2593,33 @@ gdk_event_translate (GdkEvent *event, switch (xevent->xvisibility.state) { case VisibilityFullyObscured: - g_print ("visibility notify:\twindow: %ld none\n", - xevent->xvisibility.window - base_id); + g_message ("visibility notify:\twindow: %ld none", + xevent->xvisibility.window - base_id); break; case VisibilityPartiallyObscured: - g_print ("visibility notify:\twindow: %ld partial\n", - xevent->xvisibility.window - base_id); + g_message ("visibility notify:\twindow: %ld partial", + xevent->xvisibility.window - base_id); break; case VisibilityUnobscured: - g_print ("visibility notify:\twindow: %ld full\n", - xevent->xvisibility.window - base_id); + g_message ("visibility notify:\twindow: %ld full", + xevent->xvisibility.window - base_id); break; } #endif /* G_ENABLE_DEBUG */ - + event->visibility.type = GDK_VISIBILITY_NOTIFY; event->visibility.window = window; - + switch (xevent->xvisibility.state) { case VisibilityFullyObscured: event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED; break; - + case VisibilityPartiallyObscured: event->visibility.state = GDK_VISIBILITY_PARTIAL; break; - + case VisibilityUnobscured: event->visibility.state = GDK_VISIBILITY_UNOBSCURED; break; @@ -2627,84 +2627,84 @@ gdk_event_translate (GdkEvent *event, return_val = window_private && !window_private->destroyed; break; - + case CreateNotify: /* Not currently handled */ break; - + case DestroyNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("destroy notify:\twindow: %ld\n", - xevent->xdestroywindow.window - base_id)); - + g_message ("destroy notify:\twindow: %ld", + xevent->xdestroywindow.window - base_id)); + event->any.type = GDK_DESTROY; event->any.window = window; - + return_val = window_private && !window_private->destroyed; - + if(window && window_private->xwindow != GDK_ROOT_WINDOW()) - gdk_window_destroy_notify (window); + gdk_window_destroy_notify (window); break; - + case UnmapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("unmap notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id)); - + g_message ("unmap notify:\t\twindow: %ld", + xevent->xmap.window - base_id)); + event->any.type = GDK_UNMAP; event->any.window = window; - + if (xgrab_window == window_private) xgrab_window = NULL; - + return_val = window_private && !window_private->destroyed; break; - + case MapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("map notify:\t\twindow: %ld\n", - xevent->xmap.window - base_id)); - + g_message ("map notify:\t\twindow: %ld", + xevent->xmap.window - base_id)); + event->any.type = GDK_MAP; event->any.window = window; - + return_val = window_private && !window_private->destroyed; break; - + case ReparentNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("reparent notify:\twindow: %ld\n", - xevent->xreparent.window - base_id)); - + g_message ("reparent notify:\twindow: %ld", + xevent->xreparent.window - base_id)); + /* Not currently handled */ break; - + case ConfigureNotify: /* Print debugging info. */ while ((XPending (gdk_display) > 0) && XCheckTypedWindowEvent(gdk_display, xevent->xany.window, ConfigureNotify, xevent)) - { + { GdkFilterReturn result; - + GDK_NOTE (EVENTS, - g_print ("configure notify discarded:\twindow: %ld\n", - xevent->xconfigure.window - base_id)); - + g_message ("configure notify discarded:\twindow: %ld", + xevent->xconfigure.window - base_id)); + result = gdk_event_apply_filters (xevent, event, window_private ?window_private->filters :gdk_default_filters); - + /* If the result is GDK_FILTER_REMOVE, there will be * trouble, but anybody who filtering the Configure events * better know what they are doing @@ -2713,21 +2713,21 @@ gdk_event_translate (GdkEvent *event, { return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE; } - - /*XSync (gdk_display, 0);*/ + + /*XSync (gdk_display, 0);*/ } - + GDK_NOTE (EVENTS, - g_print ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d\n", - xevent->xconfigure.window - base_id, - xevent->xconfigure.x, - xevent->xconfigure.y, - xevent->xconfigure.width, - xevent->xconfigure.height, - xevent->xconfigure.border_width, - xevent->xconfigure.above - base_id, - xevent->xconfigure.override_redirect)); + g_message ("configure notify:\twindow: %ld x,y: %d %d w,h: %d %d b-w: %d above: %ld ovr: %d", + xevent->xconfigure.window - base_id, + xevent->xconfigure.x, + xevent->xconfigure.y, + xevent->xconfigure.width, + xevent->xconfigure.height, + xevent->xconfigure.border_width, + xevent->xconfigure.above - base_id, + xevent->xconfigure.override_redirect)); if (window_private) { @@ -2749,7 +2749,7 @@ gdk_event_translate (GdkEvent *event, gint tx = 0; gint ty = 0; Window child_window = 0; - + if (!XTranslateCoordinates (window_private->xdisplay, window_private->xwindow, gdk_root_window, @@ -2782,36 +2782,36 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("property notify:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - + g_message ("property notify:\twindow: %ld", + xevent->xproperty.window - base_id)); + event->property.type = GDK_PROPERTY_NOTIFY; event->property.window = window; event->property.atom = xevent->xproperty.atom; event->property.time = xevent->xproperty.time; event->property.state = xevent->xproperty.state; - + return_val = window_private && !window_private->destroyed; break; - + case SelectionClear: GDK_NOTE (EVENTS, - g_print ("selection clear:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - + g_message ("selection clear:\twindow: %ld", + xevent->xproperty.window - base_id)); + event->selection.type = GDK_SELECTION_CLEAR; event->selection.window = window; event->selection.selection = xevent->xselectionclear.selection; event->selection.time = xevent->xselectionclear.time; - + return_val = window_private && !window_private->destroyed; break; - + case SelectionRequest: GDK_NOTE (EVENTS, - g_print ("selection request:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - + g_message ("selection request:\twindow: %ld", + xevent->xproperty.window - base_id)); + event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; event->selection.selection = xevent->xselectionrequest.selection; @@ -2819,43 +2819,43 @@ gdk_event_translate (GdkEvent *event, event->selection.property = xevent->xselectionrequest.property; event->selection.requestor = xevent->xselectionrequest.requestor; event->selection.time = xevent->xselectionrequest.time; - + return_val = window_private && !window_private->destroyed; break; - + case SelectionNotify: GDK_NOTE (EVENTS, - g_print ("selection notify:\twindow: %ld\n", - xevent->xproperty.window - base_id)); - - + g_message ("selection notify:\twindow: %ld", + xevent->xproperty.window - base_id)); + + event->selection.type = GDK_SELECTION_NOTIFY; event->selection.window = window; event->selection.selection = xevent->xselection.selection; event->selection.target = xevent->xselection.target; event->selection.property = xevent->xselection.property; event->selection.time = xevent->xselection.time; - + return_val = window_private && !window_private->destroyed; break; - + case ColormapNotify: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("colormap notify:\twindow: %ld\n", - xevent->xcolormap.window - base_id)); - + g_message ("colormap notify:\twindow: %ld", + xevent->xcolormap.window - base_id)); + /* Not currently handled */ break; - + case ClientMessage: /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("client message:\twindow: %ld\n", - xevent->xclient.window - base_id)); - + g_message ("client message:\twindow: %ld", + xevent->xclient.window - base_id)); + /* Client messages are the means of the window manager * communicating with a program. We'll first check to * see if this is really the window manager talking @@ -2873,16 +2873,16 @@ gdk_event_translate (GdkEvent *event, * the event is passed along to the program, * which should then destroy the window. */ - + /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("delete window:\t\twindow: %ld\n", - xevent->xclient.window - base_id)); - + g_message ("delete window:\t\twindow: %ld", + xevent->xclient.window - base_id)); + event->any.type = GDK_DELETE; event->any.window = window; - + return_val = window_private && !window_private->destroyed; } else if ((Atom) xevent->xclient.data.l[0] == gdk_wm_take_focus) @@ -2892,13 +2892,13 @@ gdk_event_translate (GdkEvent *event, else if (xevent->xclient.message_type == gdk_dnd.gdk_XdeEnter) { Atom reptype = 0; - + event->dropenter.u.allflags = xevent->xclient.data.l[1]; - - GDK_NOTE (DND, g_print ("GDK_DROP_ENTER [%d][%d]\n", - window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply)); + + GDK_NOTE (DND, g_message ("GDK_DROP_ENTER [%d][%d]", + window_private->dnd_drop_enabled, event->dropenter.u.flags.sendreply)); return_val = FALSE; - + /* Now figure out if we really want this drop... * If someone is trying funky clipboard stuff, ignore */ @@ -2908,35 +2908,35 @@ gdk_event_translate (GdkEvent *event, && (reptype = gdk_dnd_check_types (window, xevent))) { XEvent replyev; - + replyev.xclient.type = ClientMessage; replyev.xclient.window = xevent->xclient.data.l[0]; replyev.xclient.format = 32; replyev.xclient.message_type = gdk_dnd.gdk_XdeRequest; replyev.xclient.data.l[0] = window_private->xwindow; - + event->dragrequest.u.allflags = 0; event->dragrequest.u.flags.protocol_version = DND_PROTOCOL_VERSION; event->dragrequest.u.flags.willaccept = 1; event->dragrequest.u.flags.delete_data = (window_private->dnd_drop_destructive_op) ? 1 : 0; - + replyev.xclient.data.l[1] = event->dragrequest.u.allflags; replyev.xclient.data.l[2] = replyev.xclient.data.l[3] = 0; replyev.xclient.data.l[4] = reptype; - + if (!gdk_send_xevent (replyev.xclient.window, False, NoEventMask, &replyev)) - GDK_NOTE (DND, g_print("Sending XdeRequest to %#lx failed\n", - replyev.xclient.window)); - + GDK_NOTE (DND, g_message("Sending XdeRequest to %#lx failed", + replyev.xclient.window)); + event->any.type = GDK_DROP_ENTER; event->any.window = window; event->dropenter.requestor = replyev.xclient.window; event->dropenter.u.allflags = xevent->xclient.data.l[1]; - - GDK_NOTE (DND, g_print("We sent a GDK_DROP_ENTER on to Gtk\n")); + + GDK_NOTE (DND, g_message("We sent a GDK_DROP_ENTER on to Gtk")); return_val = TRUE; } } @@ -2944,9 +2944,9 @@ gdk_event_translate (GdkEvent *event, { #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) - g_print ("GDK_DROP_LEAVE\n"); + g_message ("GDK_DROP_LEAVE"); #endif - + if (window_private && window_private->dnd_drop_enabled) { event->dropleave.type = GDK_DROP_LEAVE; @@ -2966,11 +2966,11 @@ gdk_event_translate (GdkEvent *event, */ #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) - g_print ("GDK_DRAG_REQUEST\n"); + g_message ("GDK_DRAG_REQUEST"); #endif event->dragrequest.u.allflags = xevent->xclient.data.l[1]; return_val = FALSE; - + if (window && gdk_dnd.drag_really && xevent->xclient.data.l[0] == gdk_dnd.dnd_drag_curwin && event->dragrequest.u.flags.sendreply == 0) @@ -2995,7 +2995,7 @@ gdk_event_translate (GdkEvent *event, window_private->dnd_drag_accepted = 1; window_private->dnd_drag_data_type = xevent->xclient.data.l[4]; - + gdk_dnd.dnd_drag_target = gdk_dnd.dnd_drag_curwin; gdk_dnd_display_drag_cursor(-1, -1, TRUE, TRUE); } @@ -3008,56 +3008,56 @@ gdk_event_translate (GdkEvent *event, } } else if(xevent->xclient.message_type == gdk_dnd.gdk_XdeDataAvailable) - { - gint tmp_int; Atom tmp_atom; - gulong tmp_long; - guchar *tmp_charptr; - + { + gint tmp_int; Atom tmp_atom; + gulong tmp_long; + guchar *tmp_charptr; + #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & (GDK_DEBUG_EVENTS | GDK_DEBUG_DND)) - g_print("GDK_DROP_DATA_AVAIL\n"); + g_message("GDK_DROP_DATA_AVAIL"); #endif - event->dropdataavailable.u.allflags = xevent->xclient.data.l[1]; - event->dropdataavailable.timestamp = xevent->xclient.data.l[4]; - event->dropdataavailable.coords.x = - xevent->xclient.data.l[3] & 0xffff; - event->dropdataavailable.coords.y = - (xevent->xclient.data.l[3] >> 16) & 0xffff; - if(window - /* No preview of data ATM */ - && event->dropdataavailable.u.flags.isdrop) - { - event->dropdataavailable.type = GDK_DROP_DATA_AVAIL; - event->dropdataavailable.window = window; - event->dropdataavailable.requestor = xevent->xclient.data.l[0]; - event->dropdataavailable.data_type = - gdk_atom_name(xevent->xclient.data.l[2]); - if(XGetWindowProperty (gdk_display, - event->dropdataavailable.requestor, - xevent->xclient.data.l[2], - 0, LONG_MAX - 1, - False, XA_PRIMARY, &tmp_atom, - &tmp_int, - &event->dropdataavailable.data_numbytes, - &tmp_long, - &tmp_charptr) - != Success) - { - g_warning("XGetWindowProperty on %#x may have failed\n", + event->dropdataavailable.u.allflags = xevent->xclient.data.l[1]; + event->dropdataavailable.timestamp = xevent->xclient.data.l[4]; + event->dropdataavailable.coords.x = + xevent->xclient.data.l[3] & 0xffff; + event->dropdataavailable.coords.y = + (xevent->xclient.data.l[3] >> 16) & 0xffff; + if(window + /* No preview of data ATM */ + && event->dropdataavailable.u.flags.isdrop) + { + event->dropdataavailable.type = GDK_DROP_DATA_AVAIL; + event->dropdataavailable.window = window; + event->dropdataavailable.requestor = xevent->xclient.data.l[0]; + event->dropdataavailable.data_type = + gdk_atom_name(xevent->xclient.data.l[2]); + if(XGetWindowProperty (gdk_display, + event->dropdataavailable.requestor, + xevent->xclient.data.l[2], + 0, LONG_MAX - 1, + False, XA_PRIMARY, &tmp_atom, + &tmp_int, + &event->dropdataavailable.data_numbytes, + &tmp_long, + &tmp_charptr) + != Success) + { + g_warning("XGetWindowProperty on %#x may have failed\n", event->dropdataavailable.requestor); - event->dropdataavailable.data = NULL; - } - else - { - GDK_NOTE (DND, g_print("XGetWindowProperty got us %ld bytes\n", - event->dropdataavailable.data_numbytes)); - event->dropdataavailable.data = - g_malloc (event->dropdataavailable.data_numbytes); - memcpy (event->dropdataavailable.data, - tmp_charptr, event->dropdataavailable.data_numbytes); - XFree(tmp_charptr); - return_val = TRUE; - } + event->dropdataavailable.data = NULL; + } + else + { + GDK_NOTE (DND, g_message("XGetWindowProperty got us %ld bytes", + event->dropdataavailable.data_numbytes)); + event->dropdataavailable.data = + g_malloc (event->dropdataavailable.data_numbytes); + memcpy (event->dropdataavailable.data, + tmp_charptr, event->dropdataavailable.data_numbytes); + XFree(tmp_charptr); + return_val = TRUE; + } return_val = TRUE; } } @@ -3083,28 +3083,28 @@ gdk_event_translate (GdkEvent *event, /* Print debugging info. */ GDK_NOTE (EVENTS, - g_print ("mapping notify\n")); - + g_message ("mapping notify")); + /* Let XLib know that there is a new keyboard mapping. */ XRefreshKeyboardMapping (&xevent->xmapping); break; - + default: /* something else - (e.g., a Xinput event) */ - + if (window_private && (window_private->extension_events != 0) && gdk_input_vtable.other_event) return_val = gdk_input_vtable.other_event(event, xevent, window); else return_val = FALSE; - + return_val = return_val && !window_private->destroyed; - + break; } - + if (return_val) { if (event->any.window) @@ -3120,10 +3120,10 @@ gdk_event_translate (GdkEvent *event, event->any.window = NULL; event->any.type = GDK_NOTHING; } - + if (window) gdk_window_unref (window); - + return return_val; } @@ -3135,28 +3135,28 @@ gdk_event_get_type (Display *display, { GdkEvent event; GdkPredicate *pred; - + if (gdk_event_translate (&event, xevent)) { pred = (GdkPredicate*) arg; return (* pred->func) (&event, pred->data); } - + return FALSE; } #endif static void gdk_synthesize_click (GdkEvent *event, - gint nclicks) + gint nclicks) { GdkEvent temp_event; - + g_return_if_fail (event != NULL); - + temp_event = *event; temp_event.type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS; - + gdk_event_put (&temp_event); } @@ -3181,14 +3181,14 @@ static void gdk_exit_func (void) { static gboolean in_gdk_exit_func = FALSE; - + /* This is to avoid an infinite loop if a program segfaults in an atexit() handler (and yes, it does happen, especially if a program - has trounced over memory too badly for even g_print to work) */ + has trounced over memory too badly for even g_message to work) */ if (in_gdk_exit_func == TRUE) return; in_gdk_exit_func = TRUE; - + if (gdk_initialized) { #ifdef USE_XIM @@ -3200,7 +3200,7 @@ gdk_exit_func (void) gdk_image_exit (); gdk_input_exit (); gdk_key_repeat_restore (); - + XCloseDisplay (gdk_display); gdk_initialized = 0; } @@ -3229,11 +3229,11 @@ gdk_exit_func (void) */ static int -gdk_x_error (Display *display, +gdk_x_error (Display *display, XErrorEvent *error) { char buf[64]; - + if (gdk_error_warnings) { XGetErrorText (display, error->error_code, buf, 63); @@ -3244,7 +3244,7 @@ gdk_x_error (Display *display, error->request_code, error->minor_code); } - + gdk_error_code = -1; return 0; } @@ -3301,11 +3301,11 @@ gdk_signal (int sig_num) { static int caught_fatal_sig = 0; char *sig; - + if (caught_fatal_sig) kill (getpid (), sig_num); caught_fatal_sig = 1; - + switch (sig_num) { case SIGHUP: @@ -3333,8 +3333,8 @@ gdk_signal (int sig_num) sig = "unknown signal"; break; } - - g_print ("\n** ERROR **: %s caught\n", sig); + + g_message ("\n** ERROR **: %s caught", sig); #ifdef G_ENABLE_DEBUG abort (); #else /* !G_ENABLE_DEBUG */ @@ -3346,14 +3346,14 @@ static void gdk_dnd_drag_begin (GdkWindow *initial_window) { GdkEvent tev; - - GDK_NOTE(DND, g_print("------- STARTING DRAG from %p\n", initial_window)); - + + GDK_NOTE(DND, g_message("------- STARTING DRAG from %p", initial_window)); + tev.type = GDK_DRAG_BEGIN; tev.dragbegin.window = initial_window; tev.dragbegin.u.allflags = 0; tev.dragbegin.u.flags.protocol_version = DND_PROTOCOL_VERSION; - + gdk_event_put (&tev); } @@ -3369,7 +3369,7 @@ gdk_dnd_drag_enter (Window dest) sev.xclient.format = 32; sev.xclient.message_type = gdk_dnd.gdk_XdeEnter; sev.xclient.window = dest; - + tev.u.allflags = 0; tev.u.flags.protocol_version = DND_PROTOCOL_VERSION; tev.u.flags.sendreply = 1; @@ -3395,10 +3395,10 @@ gdk_dnd_drag_enter (Window dest) else sev.xclient.data.l[3] = sev.xclient.data.l[4] = None; if (!gdk_send_xevent (dest, False, StructureNotifyMask, &sev)) - GDK_NOTE (DND, g_print("Sending XdeEnter to %#lx failed\n", - dest)); + GDK_NOTE (DND, g_message("Sending XdeEnter to %#lx failed", + dest)); } - + } } @@ -3413,9 +3413,9 @@ gdk_dnd_drag_enter (Window dest) */ /* This needs to match XIMArg as defined in Xlcint.h exactly */ - + typedef struct { - gchar *name; + gchar *name; gpointer value; } GdkImArg; @@ -3433,7 +3433,7 @@ gdk_im_va_count (va_list list) { gint count = 0; gchar *name; - + name = va_arg (list, gchar *); while (name) { @@ -3441,7 +3441,7 @@ gdk_im_va_count (va_list list) (void)va_arg (list, gpointer); name = va_arg (list, gchar *); } - + return count; } @@ -3460,15 +3460,15 @@ gdk_im_va_to_nested (va_list list, guint count) { GdkImArg *result; GdkImArg *arg; - + gchar *name; - + if (count == 0) return NULL; - + result = g_new (GdkImArg, count+1); arg = result; - + name = va_arg (list, gchar *); while (name) { @@ -3477,9 +3477,9 @@ gdk_im_va_to_nested (va_list list, guint count) arg++; name = va_arg (list, gchar *); } - + arg->name = NULL; - + return (XVaNestedList)result; } @@ -3508,12 +3508,12 @@ gdk_im_begin (GdkIC ic, GdkWindow* window) { GdkICPrivate *private; Window xwin; - + g_return_if_fail (ic != NULL); g_return_if_fail (window); - + private = (GdkICPrivate *) ic; - + xim_using = TRUE; xim_ic = private; xim_window = window; @@ -3521,7 +3521,7 @@ gdk_im_begin (GdkIC ic, GdkWindow* window) { XGetICValues (private->xic, XNFocusWindow, &xwin, NULL); if (xwin != GDK_WINDOW_XWINDOW(window)) - XSetICValues (private->xic, XNFocusWindow, + XSetICValues (private->xic, XNFocusWindow, GDK_WINDOW_XWINDOW(window), NULL); if (private != xim_ic) XSetICFocus (private->xic); @@ -3563,13 +3563,13 @@ static GdkIMStyle gdk_im_choose_better_style (GdkIMStyle style1, GdkIMStyle style2) { GdkIMStyle s1, s2, u; - + if (style1 == 0) return style2; if (style2 == 0) return style1; if ((style1 & (GdkIMPreeditMask | GdkIMStatusMask)) - == (style2 & (GdkIMPreeditMask | GdkIMStatusMask))) + == (style2 & (GdkIMPreeditMask | GdkIMStatusMask))) return style1; - + s1 = style1 & GdkIMPreeditMask; s2 = style2 & GdkIMPreeditMask; u = s1 | s2; @@ -3603,9 +3603,9 @@ gdk_im_decide_style (GdkIMStyle supported_style) { gint i; GdkIMStyle style, tmp; - + g_return_val_if_fail (xim_styles != NULL, 0); - + style = 0; for (i=0; i<xim_styles->count_styles; i++) { @@ -3622,7 +3622,7 @@ gdk_im_set_best_style (GdkIMStyle style) if (style & GdkIMPreeditMask) { xim_best_allowed_style &= ~GdkIMPreeditMask; - + xim_best_allowed_style |= GdkIMPreeditNone; if (!(style & GdkIMPreeditNone)) { @@ -3642,7 +3642,7 @@ gdk_im_set_best_style (GdkIMStyle style) if (style & GdkIMStatusMask) { xim_best_allowed_style &= ~GdkIMStatusMask; - + xim_best_allowed_style |= GdkIMStatusNone; if (!(style & GdkIMStatusNone)) { @@ -3669,7 +3669,7 @@ gdk_im_open (XrmDatabase db, gchar* res_name, gchar* res_class) return FALSE; } XGetIMValues (xim_im, XNQueryInputStyle, &xim_styles, NULL, NULL); - + return TRUE; } @@ -3703,17 +3703,17 @@ gdk_ic_new (GdkWindow* client_window, GdkICPrivate *private; XVaNestedList preedit_attr = NULL; guint count; - + g_return_val_if_fail (client_window != NULL, NULL); g_return_val_if_fail (focus_window != NULL, NULL); g_return_val_if_fail (gdk_im_ready(), NULL); - + private = g_new (GdkICPrivate, 1); - + va_start (list, style); count = gdk_im_va_count (list); va_end (list); - + va_start (list, style); preedit_attr = gdk_im_va_to_nested (list, count); va_end (list); @@ -3725,14 +3725,14 @@ gdk_ic_new (GdkWindow* client_window, g_free (private); return NULL; } - + private->xic = XCreateIC(gdk_im_get (), - XNInputStyle, style, - XNClientWindow, GDK_WINDOW_XWINDOW (client_window), - XNFocusWindow, GDK_WINDOW_XWINDOW (focus_window), - preedit_attr? XNPreeditAttributes : NULL, preedit_attr, - NULL); - + XNInputStyle, style, + XNClientWindow, GDK_WINDOW_XWINDOW (client_window), + XNFocusWindow, GDK_WINDOW_XWINDOW (focus_window), + preedit_attr? XNPreeditAttributes : NULL, preedit_attr, + NULL); + g_free (preedit_attr); if (!private->xic) @@ -3740,7 +3740,7 @@ gdk_ic_new (GdkWindow* client_window, g_free (private); return NULL; } - + xim_ic_list = g_list_append (xim_ic_list, private); return private; } @@ -3749,14 +3749,14 @@ void gdk_ic_destroy (GdkIC ic) { GdkICPrivate *private; - + g_return_if_fail (ic != NULL); private = (GdkICPrivate *) ic; - + if (xim_ic == private) gdk_im_end (); - + XDestroyIC (private->xic); xim_ic_list = g_list_remove (xim_ic_list, private); g_free (private); @@ -3766,11 +3766,11 @@ GdkIMStyle gdk_ic_get_style (GdkIC ic) { GdkICPrivate *private; - + g_return_val_if_fail (ic != NULL, 0); - + private = (GdkICPrivate *) ic; - + return private->style; } @@ -3781,21 +3781,21 @@ gdk_ic_set_values (GdkIC ic, ...) XVaNestedList args; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, ic); count = gdk_im_va_count (list); va_end (list); - + va_start (list, ic); args = gdk_im_va_to_nested (list, count); va_end (list); - + XSetICValues (private->xic, XNVaNestedList, args, NULL); - + g_free (args); } @@ -3806,21 +3806,21 @@ gdk_ic_get_values (GdkIC ic, ...) XVaNestedList args; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, ic); count = gdk_im_va_count (list); va_end (list); - + va_start (list, ic); args = gdk_im_va_to_nested (list, count); va_end (list); - + XGetICValues (private->xic, XNVaNestedList, args, NULL); - + g_free (args); } @@ -3831,22 +3831,22 @@ gdk_ic_set_attr (GdkIC ic, const char *target, ...) XVaNestedList attr; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); g_return_if_fail (target != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, target); count = gdk_im_va_count (list); va_end (list); - + va_start (list, target); attr = gdk_im_va_to_nested (list, count); va_end (list); - + XSetICValues (private->xic, target, attr, NULL); - + g_free (attr); } @@ -3857,22 +3857,22 @@ gdk_ic_get_attr (GdkIC ic, const char *target, ...) XVaNestedList attr; GdkICPrivate *private; guint count; - + g_return_if_fail (ic != NULL); g_return_if_fail (target != NULL); - + private = (GdkICPrivate *) ic; - + va_start (list, target); count = gdk_im_va_count (list); va_end (list); - + va_start (list, target); attr = gdk_im_va_to_nested (list, count); va_end (list); - + XGetICValues (private->xic, target, attr, NULL); - + g_free (attr); } @@ -3884,21 +3884,21 @@ gdk_ic_get_events (GdkIC ic) glong bit; GdkICPrivate *private; gint i; - - /* From gdkwindow.c */ + + /* From gdkwindow.c */ extern int nevent_masks; extern int event_mask_table[]; - + g_return_val_if_fail (ic != NULL, 0); - + private = (GdkICPrivate *) ic; - + if (XGetICValues (private->xic, XNFilterEvents, &xmask, NULL) != NULL) { GDK_NOTE (XIM, g_warning ("Call to XGetICValues: %s failed", XNFilterEvents)); return 0; } - + mask = 0; for (i=0, bit=2; i < nevent_masks; i++, bit <<= 1) if (xmask & event_mask_table [i]) @@ -3906,7 +3906,7 @@ gdk_ic_get_events (GdkIC ic) mask |= bit; xmask &= ~ event_mask_table [i]; } - + if (xmask) g_warning ("ic requires events not supported by the application (%#04lx)", xmask); @@ -3919,17 +3919,17 @@ gdk_ic_cleanup (void) GList* node; gint destroyed; GdkICPrivate *private; - + destroyed = 0; for (node = xim_ic_list; node != NULL; node = node->next) { if (node->data) - { - private = (GdkICPrivate *) (node->data); - XDestroyIC (private->xic); - g_free (private); - destroyed++; - } + { + private = (GdkICPrivate *) (node->data); + XDestroyIC (private->xic); + g_free (private); + destroyed++; + } } #ifdef G_ENABLE_DEBUG if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0) @@ -4025,10 +4025,10 @@ _g_mbtowc (wchar_t *wstr, const char *str, size_t len) { static wchar_t wcs[MB_CUR_MAX + 1]; static gchar mbs[MB_CUR_MAX + 1]; - + wcs[0] = (wchar_t) NULL; mbs[0] = '\0'; - + /* The last argument isn't a mistake. The X locale code trims * the input string to the length of the output string! */ @@ -4037,13 +4037,13 @@ _g_mbtowc (wchar_t *wstr, const char *str, size_t len) return len; else if (wcs[0] == (wchar_t) NULL) return -1; - + len = _Xwctomb (mbs, wcs[0]); if (mbs[0] == '\0') return -1; if (wstr) *wstr = wcs[0]; - + return len; } @@ -4056,9 +4056,9 @@ gdk_dnd_drag_leave (Window dest) GdkEventDropLeave tev; int i; GdkWindowPrivate *wp; - + tev.u.allflags = 0; - + tev.u.flags.protocol_version = DND_PROTOCOL_VERSION; sev.xclient.type = ClientMessage; sev.xclient.window = dest; @@ -4070,8 +4070,8 @@ gdk_dnd_drag_leave (Window dest) wp = (GdkWindowPrivate *) gdk_dnd.drag_startwindows[i]; sev.xclient.data.l[0] = wp->xwindow; if (!gdk_send_xevent (dest, False, StructureNotifyMask, &sev)) - GDK_NOTE (DND, g_print("Sending XdeLeave to %#lx failed\n", - dest)); + GDK_NOTE (DND, g_message("Sending XdeLeave to %#lx failed", + dest)); wp->dnd_drag_accepted = 0; } } @@ -4088,14 +4088,14 @@ gdk_dnd_drag_end (Window dest, GdkWindowPrivate *wp; GdkEvent tev; int i; - + tev.dragrequest.type = GDK_DRAG_REQUEST; tev.dragrequest.drop_coords = coords; tev.dragrequest.requestor = dest; tev.dragrequest.u.allflags = 0; tev.dragrequest.u.flags.protocol_version = DND_PROTOCOL_VERSION; tev.dragrequest.isdrop = 1; - + for (i = 0; i < gdk_dnd.drag_numwindows; i++) { wp = (GdkWindowPrivate *) gdk_dnd.drag_startwindows[i]; @@ -4103,32 +4103,32 @@ gdk_dnd_drag_end (Window dest, { tev.dragrequest.window = (GdkWindow *) wp; tev.dragrequest.u.flags.delete_data = wp->dnd_drag_destructive_op; - tev.dragrequest.timestamp = gdk_dnd.last_drop_time; + tev.dragrequest.timestamp = gdk_dnd.last_drop_time; tev.dragrequest.data_type = - gdk_atom_name(wp->dnd_drag_data_type); - + gdk_atom_name(wp->dnd_drag_data_type); + gdk_event_put(&tev); } } } static GdkAtom -gdk_dnd_check_types (GdkWindow *window, - XEvent *xevent) +gdk_dnd_check_types (GdkWindow *window, + XEvent *xevent) { GdkWindowPrivate *wp = (GdkWindowPrivate *) window; int i, j; GdkEventDropEnter event; - + g_return_val_if_fail(window != NULL, 0); g_return_val_if_fail(xevent != NULL, 0); g_return_val_if_fail(xevent->type == ClientMessage, 0); g_return_val_if_fail(xevent->xclient.message_type == gdk_dnd.gdk_XdeEnter, 0); - + if(wp->dnd_drop_data_numtypesavail <= 0 || !wp->dnd_drop_data_typesavail) return 0; - + for (i = 2; i <= 4; i++) { for (j = 0; j < wp->dnd_drop_data_numtypesavail; j++) @@ -4137,7 +4137,7 @@ gdk_dnd_check_types (GdkWindow *window, return xevent->xclient.data.l[i]; } } - + /* Now we get the extended type list if it's available */ event.u.allflags = xevent->xclient.data.l[1]; if (event.u.flags.extended_typelist) @@ -4145,21 +4145,21 @@ gdk_dnd_check_types (GdkWindow *window, Atom *exttypes, realtype; gulong nitems, nbar; gint realfmt; - + if (XGetWindowProperty(gdk_display, xevent->xclient.data.l[0], gdk_dnd.gdk_XdeTypelist, 0L, LONG_MAX - 1, False, AnyPropertyType, &realtype, &realfmt, &nitems, &nbar, (unsigned char **) &exttypes) - != Success) + != Success) return 0; - + if (realfmt != (sizeof(Atom) * 8)) { g_warning("XdeTypelist property had format of %d instead of the expected %ld, on window %#lx\n", realfmt, (glong)sizeof(Atom) * 8, xevent->xclient.data.l[0]); return 0; } - + for (i = 0; i <= nitems; i++) { for (j = 0; j < wp->dnd_drop_data_numtypesavail; j++) @@ -4185,7 +4185,7 @@ gdk_print_atom (GdkAtom anatom) { gchar *tmpstr = NULL; tmpstr = (anatom!=None)?gdk_atom_name(anatom):"(none)"; - g_print("Atom %lu has name %s\n", anatom, tmpstr); + g_message("Atom %lu has name %s", anatom, tmpstr); if(tmpstr) g_free(tmpstr); } @@ -4195,9 +4195,9 @@ gdk_print_atom (GdkAtom anatom) * used only by below routine and itself */ static Window -getchildren (Display *dpy, - Window win, - Atom WM_STATE) +getchildren (Display *dpy, + Window win, + Atom WM_STATE) { Window root, parent, *children, inf = 0; Atom type = None; @@ -4205,10 +4205,10 @@ getchildren (Display *dpy, int format; unsigned long nitems, after; unsigned char *data; - + if (XQueryTree(dpy, win, &root, &parent, &children, &nchildren) == 0) return 0; - + for (i = 0; !inf && (i < nchildren); i++) { XGetWindowProperty (dpy, children[i], WM_STATE, 0, 0, False, @@ -4218,13 +4218,13 @@ getchildren (Display *dpy, inf = children[i]; XFree(data); } - + for (i = 0; !inf && (i < nchildren); i++) inf = getchildren (dpy, children[i], WM_STATE); - + if (children != None) XFree ((char *) children); - + return inf; } @@ -4234,8 +4234,8 @@ getchildren (Display *dpy, * modification of the XmuClientWindow() routine from X11R6.3 */ Window -gdk_get_client_window (Display *dpy, - Window win) +gdk_get_client_window (Display *dpy, + Window win) { Atom WM_STATE; Atom type = None; @@ -4243,20 +4243,20 @@ gdk_get_client_window (Display *dpy, unsigned long nitems, after; unsigned char *data; Window inf; - + if (win == 0) return DefaultRootWindow(dpy); - + if ((WM_STATE = XInternAtom (dpy, "WM_STATE", True)) == 0) return win; - + XGetWindowProperty (dpy, win, WM_STATE, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &data); if (type) return win; - + inf = getchildren (dpy, win, WM_STATE); - + if (inf == 0) return win; else @@ -4273,13 +4273,13 @@ gdk_drop_get_real_window (GdkWindow *w, GdkWindowPrivate *awin; GList *children; gint16 myx = *x, myy = *y; - + g_return_val_if_fail (w != NULL && x != NULL && y != NULL, NULL); - + myx = *x; myy = *y; - -descend: + + descend: for (children = gdk_window_get_children(retval); children && children->next; children = children->next) @@ -4295,10 +4295,10 @@ descend: goto descend; } } - + *x = myx; *y = myy; - + return retval; } #endif @@ -4311,9 +4311,9 @@ gdk_event_send_clientmessage_toall (GdkEvent *event) Window *ret_children, ret_root, ret_parent, curwin; unsigned int ret_nchildren; int i; - + g_return_if_fail(event != NULL); - + /* Set up our event to send, with the exception of its target window */ sev.xclient.type = ClientMessage; sev.xclient.display = gdk_display; @@ -4321,21 +4321,21 @@ gdk_event_send_clientmessage_toall (GdkEvent *event) sev.xclient.serial = CurrentTime; memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data)); sev.xclient.message_type = event->client.message_type; - + /* OK, we're all set, now let's find some windows to send this to */ if(XQueryTree(gdk_display, gdk_root_window, &ret_root, &ret_parent, &ret_children, &ret_nchildren) != True) return; - + /* foreach true child window of the root window, send an event to it */ for(i = 0; i < ret_nchildren; i++) { curwin = gdk_get_client_window(gdk_display, ret_children[i]); sev.xclient.window = curwin; if (!gdk_send_xevent (curwin, False, NoEventMask, &sev)) - GDK_NOTE (MISC, g_print("Gdk: Sending client message %ld to %#lx failed\n", - event->client.message_type, curwin)); + GDK_NOTE (MISC, g_message ("Sending client message %ld to %#lx failed", + event->client.message_type, curwin)); } - + XFree(ret_children); } @@ -4357,7 +4357,7 @@ gdk_send_xevent (Window window, gboolean propagate, glong event_mask, result = XSendEvent (gdk_display, window, propagate, event_mask, event_send); XSync (gdk_display, False); gdk_error_warnings = 1; - + return result && (gdk_error_code != -1); } @@ -4371,13 +4371,13 @@ gdkx_XConvertCase (KeySym symbol, KeySym *upper) { register KeySym sym = symbol; - + g_return_if_fail (lower != NULL); g_return_if_fail (upper != NULL); - + *lower = sym; *upper = sym; - + switch (sym >> 8) { #if defined (GDK_A) && defined (GDK_Ooblique) @@ -4472,7 +4472,7 @@ gdkx_XConvertCase (KeySym symbol, *upper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu); break; #endif /* CYRILLIC */ - + #if defined (GDK_Greek_ALPHAaccent) && defined (GDK_Greek_finalsmallsigma) case 7: /* Greek */ /* Assume the KeySym is a legal value (ignore discontinuities) */ @@ -4494,7 +4494,7 @@ gdkx_XConvertCase (KeySym symbol, #endif gchar* -gdk_keyval_name (guint keyval) +gdk_keyval_name (guint keyval) { return XKeysymToString (keyval); } @@ -4503,18 +4503,18 @@ guint gdk_keyval_from_name (const gchar *keyval_name) { g_return_val_if_fail (keyval_name != NULL, 0); - + return XStringToKeysym (keyval_name); } guint -gdk_keyval_to_upper (guint keyval) +gdk_keyval_to_upper (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return upper_val; } @@ -4522,13 +4522,13 @@ gdk_keyval_to_upper (guint keyval) } guint -gdk_keyval_to_lower (guint keyval) +gdk_keyval_to_lower (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return lower_val; } @@ -4536,13 +4536,13 @@ gdk_keyval_to_lower (guint keyval) } gboolean -gdk_keyval_is_upper (guint keyval) +gdk_keyval_is_upper (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return upper_val == keyval; } @@ -4550,13 +4550,13 @@ gdk_keyval_is_upper (guint keyval) } gboolean -gdk_keyval_is_lower (guint keyval) +gdk_keyval_is_lower (guint keyval) { if (keyval) { KeySym lower_val = 0; KeySym upper_val = 0; - + XConvertCase (keyval, &lower_val, &upper_val); return lower_val == keyval; } diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c index e7bf1648cc..693020ef61 100644 --- a/gdk/x11/gdkvisual-x11.c +++ b/gdk/x11/gdkvisual-x11.c @@ -211,9 +211,9 @@ gdk_visual_init (void) #ifdef G_ENABLE_DEBUG if (gdk_debug_flags & GDK_DEBUG_MISC) for (i = 0; i < nvisuals; i++) - g_print ("Gdk: visual: %s: %d\n", - visual_names[visuals[i].visual.type], - visuals[i].visual.depth); + g_message ("visual: %s: %d", + visual_names[visuals[i].visual.type], + visuals[i].visual.depth); #endif /* G_ENABLE_DEBUG */ navailable_depths = 0; diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 5c1feb2e3a..8c8623d4b0 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -407,7 +407,7 @@ gdk_window_new (GdkWindow *parent, (private->colormap != gdk_colormap_get_system ()) && (private->colormap != gdk_window_get_colormap (gdk_window_get_toplevel (window)))) { - GDK_NOTE (MISC, g_print ("adding colormap window\n")); + GDK_NOTE (MISC, g_message ("adding colormap window\n")); gdk_window_add_colormap_windows (window); } @@ -1771,7 +1771,7 @@ gdk_window_dnd_data_set (GdkWindow *window, data_numbytes); tmp = gdk_atom_name(window_private->dnd_drag_data_type); #ifdef DEBUG_DND - g_print("DnD type %s on window %ld\n", tmp, window_private->xwindow); + g_message("DnD type %s on window %ld\n", tmp, window_private->xwindow); #endif g_free(tmp); @@ -1801,9 +1801,8 @@ gdk_window_dnd_data_set (GdkWindow *window, if (!gdk_send_xevent (event->dragrequest.requestor, False, StructureNotifyMask, &sev)) - GDK_NOTE (DND, g_print("Sending XdeDataAvailable to %#x failed\n", - event->dragrequest.requestor)); - + GDK_NOTE (DND, g_message("Sending XdeDataAvailable to %#x failed\n", + event->dragrequest.requestor)); } void diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c index f4a7254325..9241891376 100644 --- a/gtk/gtkfontsel.c +++ b/gtk/gtkfontsel.c @@ -161,28 +161,28 @@ struct _FontStyle }; struct _GtkFontSelInfo { - + /* This is a table with each FontInfo representing one font family+foundry */ FontInfo *font_info; gint nfonts; - + /* This stores all the valid combinations of properties for every family. Each FontInfo holds an index into its own space in this one big array. */ FontStyle *font_styles; gint nstyles; - + /* This stores all the font sizes available for every style. Each style holds an index into these arrays. */ guint16 *pixel_sizes; guint16 *point_sizes; - + /* These are the arrays of strings of all possible weights, slants, set widths, spacings, charsets & foundries, and the amount of space allocated for each array. */ gchar **properties[GTK_NUM_FONT_PROPERTIES]; guint16 nproperties[GTK_NUM_FONT_PROPERTIES]; guint16 space_allocated[GTK_NUM_FONT_PROPERTIES]; - + /* Whether any scalable bitmap fonts are available. If not, the 'Allow scaled bitmap fonts' toggle button is made insensitive. */ gboolean scaled_bitmaps_available; @@ -285,7 +285,7 @@ static gboolean gtk_font_selection_select_next (GtkFontSelection *fs, GtkWidget *clist, gint step); static void gtk_font_selection_show_available_styles - (GtkFontSelection *fs); +(GtkFontSelection *fs); static void gtk_font_selection_select_best_style (GtkFontSelection *fs, gboolean use_first); static gint gtk_font_selection_get_best_match (GtkFontSelection *fs); @@ -296,7 +296,7 @@ static void gtk_font_selection_select_style (GtkWidget *w, GdkEventButton *bevent, gpointer data); static void gtk_font_selection_show_available_sizes - (GtkFontSelection *fs); +(GtkFontSelection *fs); static gint gtk_font_selection_size_key_press (GtkWidget *w, GdkEventKey *event, gpointer data); @@ -340,8 +340,8 @@ static void gtk_font_selection_on_clear_filter (GtkWidget *w, static void gtk_font_selection_apply_filter (GtkFontSelection *fs); static void gtk_font_selection_clear_filter (GtkFontSelection *fs); static void gtk_font_selection_toggle_scaled_bitmaps - (GtkWidget *w, - gpointer data); +(GtkWidget *w, + gpointer data); /* Misc. utility functions. */ static void gtk_font_selection_insert_fonts (GtkFontSelection *fs); @@ -389,7 +389,7 @@ GtkType gtk_font_selection_get_type() { static GtkType font_selection_type = 0; - + if(!font_selection_type) { GtkTypeInfo fontsel_type_info = @@ -403,11 +403,11 @@ gtk_font_selection_get_type() /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; - + font_selection_type = gtk_type_unique (GTK_TYPE_NOTEBOOK, &fontsel_type_info); } - + return font_selection_type; } @@ -415,13 +415,13 @@ static void gtk_font_selection_class_init(GtkFontSelectionClass *klass) { GtkObjectClass *object_class; - + object_class = (GtkObjectClass *) klass; - + font_selection_parent_class = gtk_type_class (GTK_TYPE_NOTEBOOK); - + object_class->destroy = gtk_font_selection_destroy; - + gtk_font_selection_get_fonts (); } @@ -439,7 +439,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gchar *row_text[3]; gchar *property, *text; gboolean inserted; - + /* Initialize the GtkFontSelection struct. We do this here in case any callbacks are triggered while creating the interface. */ fontsel->font = NULL; @@ -449,18 +449,18 @@ gtk_font_selection_init(GtkFontSelection *fontsel) fontsel->size = INITIAL_FONT_SIZE; fontsel->selected_size = INITIAL_FONT_SIZE; fontsel->scale_bitmapped_fonts = FALSE; - + for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) { fontsel->property_filters[prop] = NULL; fontsel->property_nfilters[prop] = 0; } - + for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) - fontsel->property_values[prop] = 0; - + fontsel->property_values[prop] = 0; + fontsel->scroll_on_expose = TRUE; - + /* Create the main notebook page. */ fontsel->main_vbox = gtk_vbox_new (FALSE, 4); gtk_widget_show (fontsel->main_vbox); @@ -469,13 +469,13 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_set_usize (label, 120, -1); gtk_notebook_append_page (GTK_NOTEBOOK (fontsel), fontsel->main_vbox, label); - + /* Create the table of font, style & size. */ table = gtk_table_new (3, 3, FALSE); gtk_widget_show (table); gtk_table_set_col_spacings(GTK_TABLE(table), 8); gtk_box_pack_start (GTK_BOX (fontsel->main_vbox), table, TRUE, TRUE, 0); - + fontsel->font_label = gtk_label_new("Font:"); gtk_misc_set_alignment (GTK_MISC (fontsel->font_label), 0.0, 0.5); gtk_widget_show (fontsel->font_label); @@ -512,7 +512,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_signal_connect (GTK_OBJECT (fontsel->size_entry), "key_press_event", (GtkSignalFunc) gtk_font_selection_size_key_press, fontsel); - + /* Create the clists */ fontsel->font_clist = gtk_clist_new(1); gtk_clist_column_titles_hide (GTK_CLIST(fontsel->font_clist)); @@ -525,7 +525,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_table_attach (GTK_TABLE (table), fontsel->font_clist, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - + fontsel->font_style_clist = gtk_clist_new(1); gtk_clist_column_titles_hide (GTK_CLIST(fontsel->font_style_clist)); gtk_clist_set_column_width (GTK_CLIST(fontsel->font_style_clist), 0, 300); @@ -536,7 +536,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_table_attach (GTK_TABLE (table), fontsel->font_style_clist, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - + fontsel->size_clist = gtk_clist_new(1); gtk_clist_column_titles_hide (GTK_CLIST(fontsel->size_clist)); gtk_clist_set_policy(GTK_CLIST(fontsel->size_clist), GTK_POLICY_ALWAYS, @@ -545,12 +545,12 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_show(fontsel->size_clist); gtk_table_attach (GTK_TABLE (table), fontsel->size_clist, 2, 3, 2, 3, GTK_FILL, GTK_FILL, 0, 0); - - + + /* Insert the fonts. If there exist fonts with the same family but different foundries, then the foundry name is appended in brackets. */ gtk_font_selection_insert_fonts(fontsel); - + gtk_signal_connect (GTK_OBJECT (fontsel->font_clist), "select_row", GTK_SIGNAL_FUNC(gtk_font_selection_select_font), fontsel); @@ -561,7 +561,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_signal_connect_after (GTK_OBJECT (fontsel->font_clist), "expose_event", GTK_SIGNAL_FUNC(gtk_font_selection_expose_list), fontsel); - + gtk_signal_connect (GTK_OBJECT (fontsel->font_style_clist), "select_row", GTK_SIGNAL_FUNC(gtk_font_selection_select_style), fontsel); @@ -570,7 +570,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) "key_press_event", GTK_SIGNAL_FUNC(gtk_font_selection_on_clist_key_press), fontsel); - + /* Insert the standard font sizes */ gtk_clist_freeze (GTK_CLIST(fontsel->size_clist)); size_to_match = INITIAL_FONT_SIZE; @@ -588,7 +588,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) } } gtk_clist_thaw (GTK_CLIST(fontsel->size_clist)); - + gtk_signal_connect (GTK_OBJECT (fontsel->size_clist), "select_row", GTK_SIGNAL_FUNC(gtk_font_selection_select_size), fontsel); @@ -596,13 +596,13 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_signal_connect (GTK_OBJECT (fontsel->size_clist), "key_press_event", GTK_SIGNAL_FUNC(gtk_font_selection_on_clist_key_press), fontsel); - - + + /* create the Filter, Scale Bitmaps & Metric buttons */ hbox = gtk_hbox_new(FALSE, 8); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (fontsel->main_vbox), hbox, FALSE, TRUE, 0); - + fontsel->filter_button = gtk_button_new_with_label(" Clear Filter "); gtk_widget_show(fontsel->filter_button); gtk_box_pack_start (GTK_BOX (hbox), fontsel->filter_button, FALSE, FALSE, 0); @@ -610,7 +610,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_signal_connect (GTK_OBJECT (fontsel->filter_button), "clicked", GTK_SIGNAL_FUNC(gtk_font_selection_on_clear_filter), fontsel); - + fontsel->scaled_bitmaps_button = gtk_check_button_new_with_label("Allow scaled bitmap fonts"); gtk_widget_show(fontsel->scaled_bitmaps_button); @@ -621,8 +621,8 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_signal_connect (GTK_OBJECT (fontsel->scaled_bitmaps_button), "clicked", GTK_SIGNAL_FUNC(gtk_font_selection_toggle_scaled_bitmaps), fontsel); - - + + hbox2 = gtk_hbox_new(FALSE, 0); gtk_widget_show (hbox2); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); @@ -630,55 +630,55 @@ gtk_font_selection_init(GtkFontSelection *fontsel) label = gtk_label_new("Metric:"); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 8); - + fontsel->points_button = gtk_radio_button_new_with_label(NULL, "Points"); gtk_widget_show (fontsel->points_button); gtk_box_pack_start (GTK_BOX (hbox2), fontsel->points_button, FALSE, TRUE, 0); if (INITIAL_METRIC == POINTS_METRIC) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(fontsel->points_button), TRUE); - + fontsel->pixels_button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(fontsel->points_button), "Pixels"); gtk_widget_show (fontsel->pixels_button); gtk_box_pack_start (GTK_BOX (hbox2), fontsel->pixels_button, FALSE, TRUE, 0); if (INITIAL_METRIC == PIXELS_METRIC) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(fontsel->pixels_button), TRUE); - + gtk_signal_connect(GTK_OBJECT(fontsel->points_button), "toggled", (GtkSignalFunc) gtk_font_selection_metric_callback, fontsel); gtk_signal_connect(GTK_OBJECT(fontsel->pixels_button), "toggled", (GtkSignalFunc) gtk_font_selection_metric_callback, fontsel); - - + + /* create the text entry widget */ text_frame = gtk_frame_new ("Preview:"); gtk_widget_show (text_frame); gtk_frame_set_shadow_type(GTK_FRAME(text_frame), GTK_SHADOW_ETCHED_IN); gtk_box_pack_start (GTK_BOX (fontsel->main_vbox), text_frame, FALSE, TRUE, 0); - + /* This is just used to get a 4-pixel space around the preview entry. */ text_box = gtk_hbox_new (FALSE, 0); gtk_widget_show (text_box); gtk_container_add (GTK_CONTAINER (text_frame), text_box); gtk_container_border_width (GTK_CONTAINER (text_box), 4); - + fontsel->preview_entry = gtk_entry_new (); gtk_widget_show (fontsel->preview_entry); gtk_widget_set_usize (fontsel->preview_entry, -1, INITIAL_PREVIEW_HEIGHT); gtk_box_pack_start (GTK_BOX (text_box), fontsel->preview_entry, TRUE, TRUE, 0); - + /* Create the message area */ fontsel->message_label = gtk_label_new(""); gtk_widget_show (fontsel->message_label); gtk_box_pack_start (GTK_BOX (fontsel->main_vbox), fontsel->message_label, FALSE, FALSE, 0); - - + + /* Create the font info page */ fontsel->info_vbox = gtk_vbox_new (FALSE, 4); gtk_widget_show (fontsel->info_vbox); @@ -687,7 +687,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_set_usize (label, 120, -1); gtk_notebook_append_page (GTK_NOTEBOOK (fontsel), fontsel->info_vbox, label); - + fontsel->info_clist = gtk_clist_new_with_titles(3, titles); gtk_widget_set_usize (fontsel->info_clist, 390, 150); gtk_clist_set_column_width(GTK_CLIST(fontsel->info_clist), 0, 130); @@ -699,7 +699,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_show(fontsel->info_clist); gtk_box_pack_start (GTK_BOX (fontsel->info_vbox), fontsel->info_clist, TRUE, TRUE, 0); - + /* Insert the property names */ gtk_clist_freeze (GTK_CLIST(fontsel->info_clist)); row_text[1] = ""; @@ -713,18 +713,18 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_clist_set_shift(GTK_CLIST(fontsel->info_clist), i, 2, 0, 4); } gtk_clist_thaw (GTK_CLIST(fontsel->info_clist)); - + label = gtk_label_new("Requested Font Name:"); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (fontsel->info_vbox), label, FALSE, TRUE, 0); - + fontsel->requested_font_name = gtk_entry_new(); gtk_entry_set_editable(GTK_ENTRY(fontsel->requested_font_name), FALSE); gtk_widget_show (fontsel->requested_font_name); gtk_box_pack_start (GTK_BOX (fontsel->info_vbox), fontsel->requested_font_name, FALSE, TRUE, 0); - + label = gtk_label_new("Actual Font Name:"); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); @@ -735,18 +735,18 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_show (fontsel->actual_font_name); gtk_box_pack_start (GTK_BOX (fontsel->info_vbox), fontsel->actual_font_name, FALSE, TRUE, 0); - + sprintf(buffer, "%i fonts available with a total of %i styles.", fontsel_info->nfonts, fontsel_info->nstyles); label = gtk_label_new(buffer); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (fontsel->info_vbox), label, FALSE, FALSE, 0); - + gtk_signal_connect (GTK_OBJECT (fontsel), "switch_page", GTK_SIGNAL_FUNC(gtk_font_selection_switch_page), fontsel); - - + + /* Create the Filter page. */ fontsel->filter_vbox = gtk_vbox_new (FALSE, 4); gtk_widget_show (fontsel->filter_vbox); @@ -755,24 +755,24 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_set_usize (label, 120, -1); gtk_notebook_append_page (GTK_NOTEBOOK (fontsel), fontsel->filter_vbox, label); - + table = gtk_table_new (4, 3, FALSE); gtk_table_set_col_spacings(GTK_TABLE(table), 2); gtk_widget_show (table); gtk_box_pack_start (GTK_BOX (fontsel->filter_vbox), table, TRUE, TRUE, 0); - + for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) { gint left = filter_positions[prop][0]; gint top = filter_positions[prop][1]; - + label = gtk_label_new(xlfd_field_names[xlfd_index[prop]]); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0); gtk_misc_set_padding (GTK_MISC (label), 0, 2); gtk_widget_show(label); gtk_table_attach (GTK_TABLE (table), label, left, left + 1, top, top + 1, GTK_FILL, GTK_FILL, 0, 0); - + clist = gtk_clist_new(1); gtk_widget_set_usize (clist, 100, filter_heights[prop]); gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_MULTIPLE); @@ -780,7 +780,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_clist_set_policy(GTK_CLIST(clist), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_show(clist); - + /* For the bottom-right cell we add the 'Clear Filter' button. */ if (top == 2 && left == 2) { @@ -788,13 +788,13 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_show(vbox); gtk_table_attach (GTK_TABLE (table), vbox, left, left + 1, top + 1, top + 2, GTK_FILL, GTK_FILL, 0, 0); - + gtk_box_pack_start (GTK_BOX (vbox), clist, TRUE, TRUE, 0); - + alignment = gtk_alignment_new(0.5, 0.0, 0.8, 0.0); gtk_widget_show(alignment); gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, TRUE, 4); - + button = gtk_button_new_with_label("Clear Filter"); gtk_widget_show(button); gtk_container_add(GTK_CONTAINER(alignment), button); @@ -806,27 +806,27 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_table_attach (GTK_TABLE (table), clist, left, left + 1, top + 1, top + 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - + gtk_signal_connect (GTK_OBJECT (clist), "select_row", GTK_SIGNAL_FUNC(gtk_font_selection_select_filter), fontsel); gtk_signal_connect (GTK_OBJECT (clist), "unselect_row", GTK_SIGNAL_FUNC(gtk_font_selection_unselect_filter), fontsel); - + /* Insert the property names, expanded, and in sorted order. But we make sure that the wildcard '*' is first. */ gtk_clist_freeze (GTK_CLIST(clist)); property = "*"; gtk_clist_append(GTK_CLIST(clist), &property); - + for (i = 1; i < fontsel_info->nproperties[prop]; i++) { property = fontsel_info->properties[prop][i]; if (prop == SLANT) property = gtk_font_selection_expand_slant_code(property); else if (prop == SPACING) property = gtk_font_selection_expand_spacing_code(property); - + inserted = FALSE; for (row = 1; row < GTK_CLIST(clist)->rows; row++) { @@ -852,9 +852,9 @@ GtkWidget * gtk_font_selection_new() { GtkFontSelection *fontsel; - + fontsel = gtk_type_new (GTK_TYPE_FONT_SELECTION); - + return GTK_WIDGET (fontsel); } @@ -862,16 +862,16 @@ static void gtk_font_selection_destroy (GtkObject *object) { GtkFontSelection *fontsel; - + g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_FONT_SELECTION (object)); - + fontsel = GTK_FONT_SELECTION (object); - + /* All we have to do is unref the font, if we have one. */ if (fontsel->font) gdk_font_unref (fontsel->font); - + if (GTK_OBJECT_CLASS (font_selection_parent_class)->destroy) (* GTK_OBJECT_CLASS (font_selection_parent_class)->destroy) (object); } @@ -885,10 +885,10 @@ gtk_font_selection_insert_fonts (GtkFontSelection *fontsel) gchar font_buffer[XLFD_MAX_FIELD_LEN * 2 + 4]; gchar *font_item; gint nfonts, i, row; - + font_info = fontsel_info->font_info; nfonts = fontsel_info->nfonts; - + gtk_clist_freeze (GTK_CLIST(fontsel->font_clist)); gtk_clist_clear (GTK_CLIST(fontsel->font_clist)); for (i = 0; i < nfonts; i++) @@ -921,18 +921,18 @@ gtk_font_selection_expose_list (GtkWidget *widget, FontInfo *font_info; GList *selection; gint index; - + #ifdef FONTSEL_DEBUG - g_print("In expose_list\n"); + g_message("In expose_list\n"); #endif fontsel = GTK_FONT_SELECTION(data); - + if (fontsel->scroll_on_expose) { fontsel->scroll_on_expose = FALSE; - + font_info = fontsel_info->font_info; - + /* Try to scroll the font family clist to the selected item */ selection = GTK_CLIST(fontsel->font_clist)->selection; if (selection) @@ -940,7 +940,7 @@ gtk_font_selection_expose_list (GtkWidget *widget, index = GPOINTER_TO_INT (selection->data); gtk_clist_moveto(GTK_CLIST(fontsel->font_clist), index, -1, 0.5, 0); } - + /* Try to scroll the font style clist to the selected item */ selection = GTK_CLIST(fontsel->font_style_clist)->selection; if (selection) @@ -949,7 +949,7 @@ gtk_font_selection_expose_list (GtkWidget *widget, gtk_clist_moveto(GTK_CLIST(fontsel->font_style_clist), index, -1, 0.5, 0); } - + /* Try to scroll the font size clist to the selected item */ selection = GTK_CLIST(fontsel->size_clist)->selection; if (selection) @@ -972,24 +972,24 @@ gtk_font_selection_select_font (GtkWidget *w, GtkFontSelection *fontsel; FontInfo *font_info; FontInfo *font; - + #ifdef FONTSEL_DEBUG - g_print("In select_font\n"); + g_message("In select_font\n"); #endif fontsel = GTK_FONT_SELECTION(data); font_info = fontsel_info->font_info; - + if (bevent && !GTK_WIDGET_HAS_FOCUS (w)) gtk_widget_grab_focus (w); - + row = GPOINTER_TO_INT (gtk_clist_get_row_data (GTK_CLIST (fontsel->font_clist), row)); font = &font_info[row]; gtk_entry_set_text(GTK_ENTRY(fontsel->font_entry), font->family); - + /* If it is already the current font, just return. */ if (fontsel->font_index == row) return; - + fontsel->font_index = row; gtk_font_selection_show_available_styles (fontsel); gtk_font_selection_select_best_style (fontsel, TRUE); @@ -1002,7 +1002,7 @@ gtk_font_selection_on_clist_key_press (GtkWidget *clist, GtkFontSelection *fontsel) { #ifdef FONTSEL_DEBUG - g_print("In on_clist_key_press\n"); + g_message("In on_clist_key_press\n"); #endif if (event->keyval == GDK_Up) return gtk_font_selection_select_next (fontsel, clist, -1); @@ -1020,12 +1020,12 @@ gtk_font_selection_select_next (GtkFontSelection *fontsel, { GList *selection; gint current_row, row; - + selection = GTK_CLIST(clist)->selection; if (!selection) return FALSE; current_row = GPOINTER_TO_INT (selection->data); - + for (row = current_row + step; row >= 0 && row < GTK_CLIST(clist)->rows; row += step) @@ -1035,7 +1035,7 @@ gtk_font_selection_select_next (GtkFontSelection *fontsel, if (clist == fontsel->font_style_clist) if (GPOINTER_TO_INT (gtk_clist_get_row_data(GTK_CLIST(clist), row)) == -1) continue; - + /* Now we've found the row to select. */ if (gtk_clist_row_is_visible(GTK_CLIST(clist), row) != GTK_VISIBILITY_FULL) @@ -1063,16 +1063,16 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) gchar buffer[XLFD_MAX_FIELD_LEN * 6 + 2]; GdkColor *inactive_fg, *inactive_bg; gboolean show_charset; - + #ifdef FONTSEL_DEBUG - g_print("In show_available_styles\n"); + g_message("In show_available_styles\n"); #endif font = &fontsel_info->font_info[fontsel->font_index]; styles = &fontsel_info->font_styles[font->style_index]; - + gtk_clist_freeze (GTK_CLIST(fontsel->font_style_clist)); gtk_clist_clear (GTK_CLIST(fontsel->font_style_clist)); - + /* First we mark all visible styles as not having been displayed yet, and check if every style has the same charset. If not then we will display the charset in the list before the styles. */ @@ -1083,7 +1083,7 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) if (gtk_font_selection_style_visible(fontsel, font, style)) { styles[style].flags &= ~DISPLAYED; - + if (charset_index == -1) charset_index = styles[style].properties[CHARSET]; else if (charset_index != styles[style].properties[CHARSET]) @@ -1092,17 +1092,17 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) else styles[style].flags |= DISPLAYED; } - + /* Step through the undisplayed styles, finding the next charset which hasn't been displayed yet. Then display the charset on one line, if necessary, and the visible styles indented beneath it. */ inactive_fg = &fontsel->font_style_clist->style->fg[GTK_STATE_INSENSITIVE]; inactive_bg = &fontsel->font_style_clist->style->bg[GTK_STATE_INSENSITIVE]; - + for (style = 0; style < font->nstyles; style++) { if (styles[style].flags & DISPLAYED) continue; - + if (show_charset) { charset_index = styles[style].properties[CHARSET]; @@ -1116,15 +1116,15 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) gtk_clist_set_background(GTK_CLIST(fontsel->font_style_clist), row, inactive_bg); } - + for (tmpstyle = style; tmpstyle < font->nstyles; tmpstyle++) { if (styles[tmpstyle].flags & DISPLAYED || charset_index != styles[tmpstyle].properties[CHARSET]) continue; - + styles[tmpstyle].flags |= DISPLAYED; - + weight_index = styles[tmpstyle].properties[WEIGHT]; slant_index = styles[tmpstyle].properties[SLANT]; set_width_index = styles[tmpstyle].properties[SET_WIDTH]; @@ -1133,10 +1133,10 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) slant = fontsel_info->properties[SLANT] [slant_index]; set_width = fontsel_info->properties[SET_WIDTH][set_width_index]; spacing = fontsel_info->properties[SPACING] [spacing_index]; - + /* Convert '(nil)' weights to 'regular', since it looks nicer. */ if (!g_strcasecmp(weight, "(nil)")) weight = "regular"; - + /* We don't show default values or (nil) in the other properties. */ if (!g_strcasecmp(slant, "r")) slant = NULL; else if (!g_strcasecmp(slant, "(nil)")) slant = NULL; @@ -1145,15 +1145,15 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) else if (!g_strcasecmp(slant, "ri")) slant = "reverse italic"; else if (!g_strcasecmp(slant, "ro")) slant = "reverse oblique"; else if (!g_strcasecmp(slant, "ot")) slant = "other"; - + if (!g_strcasecmp(set_width, "normal")) set_width = NULL; else if (!g_strcasecmp(set_width, "(nil)")) set_width = NULL; - + if (!g_strcasecmp(spacing, "p")) spacing = NULL; else if (!g_strcasecmp(spacing, "(nil)")) spacing = NULL; else if (!g_strcasecmp(spacing, "m")) spacing = "[M]"; else if (!g_strcasecmp(spacing, "c")) spacing = "[C]"; - + /* Add the strings together, making sure there is 1 space between them */ strcpy(buffer, weight); @@ -1172,7 +1172,7 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) strcat(buffer, " "); strcat(buffer, spacing); } - + new_item = buffer; row = gtk_clist_append(GTK_CLIST(fontsel->font_style_clist), &new_item); @@ -1183,7 +1183,7 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel) GINT_TO_POINTER (tmpstyle)); } } - + gtk_clist_thaw (GTK_CLIST(fontsel->font_style_clist)); } @@ -1201,17 +1201,17 @@ gtk_font_selection_select_best_style(GtkFontSelection *fontsel, FontStyle *styles; gint row, prop, style = -1, style_to_find; gboolean found = FALSE; - + #ifdef FONTSEL_DEBUG - g_print("In select_best_style\n"); + g_message("In select_best_style\n"); #endif font = &fontsel_info->font_info[fontsel->font_index]; styles = &fontsel_info->font_styles[font->style_index]; - + /* If use_first is set, we just find the first style in the list, not including charset items. */ style_to_find = use_first ? -1 : gtk_font_selection_get_best_match (fontsel); - + for (row = 0; row < GTK_CLIST(fontsel->font_style_clist)->rows; row++) { style = GPOINTER_TO_INT (gtk_clist_get_row_data (GTK_CLIST (fontsel->font_style_clist), row)); @@ -1222,12 +1222,12 @@ gtk_font_selection_select_best_style(GtkFontSelection *fontsel, } } g_return_if_fail (found); - + fontsel->style = style; - + for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) fontsel->property_values[prop] = styles[fontsel->style].properties[prop]; - + gtk_clist_select_row(GTK_CLIST(fontsel->font_style_clist), row, 0); if (gtk_clist_row_is_visible(GTK_CLIST(fontsel->font_style_clist), row) != GTK_VISIBILITY_FULL) @@ -1251,38 +1251,38 @@ gtk_font_selection_select_style (GtkWidget *w, FontStyle *styles; gint style, prop; gchar *text; - + #ifdef FONTSEL_DEBUG - g_print("In select_style\n"); + g_message("In select_style\n"); #endif fontsel = GTK_FONT_SELECTION(data); font_info = fontsel_info->font_info; font = &font_info[fontsel->font_index]; styles = &fontsel_info->font_styles[font->style_index]; - + if (bevent && !GTK_WIDGET_HAS_FOCUS (w)) gtk_widget_grab_focus (w); - + /* The style index is stored in the row data, so we just need to copy the style values into the fontsel and reload the font. */ style = GPOINTER_TO_INT (gtk_clist_get_row_data(GTK_CLIST(fontsel->font_style_clist), row)); - + /* Don't allow selection of charset rows. */ if (style == -1) { gtk_clist_unselect_row(GTK_CLIST(fontsel->font_style_clist), row, 0); return; } - + gtk_clist_get_text(GTK_CLIST(fontsel->font_style_clist), row, 0, &text); gtk_entry_set_text(GTK_ENTRY(fontsel->font_style_entry), text); - + for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) fontsel->property_values[prop] = styles[style].properties[prop]; - + if (fontsel->style == style) return; - + fontsel->style = style; gtk_font_selection_show_available_sizes (fontsel); gtk_font_selection_select_best_size (fontsel); @@ -1294,9 +1294,9 @@ gtk_font_selection_toggle_scaled_bitmaps (GtkWidget *w, gpointer data) { GtkFontSelection *fontsel; - + fontsel = GTK_FONT_SELECTION(data); - + fontsel->scale_bitmapped_fonts = GTK_TOGGLE_BUTTON(w)->active ? TRUE : FALSE; if (fontsel->font_index != -1) @@ -1319,14 +1319,14 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel) gchar buffer[16], *size; gfloat bitmap_size_float; gboolean can_match; - + #ifdef FONTSEL_DEBUG - g_print("In show_available_sizes\n"); + g_message("In show_available_sizes\n"); #endif font = &fontsel_info->font_info[fontsel->font_index]; styles = &fontsel_info->font_styles[font->style_index]; style = &styles[fontsel->style]; - + standard_sizes = font_sizes; nstandard_sizes = sizeof(font_sizes) / sizeof(font_sizes[0]); if (fontsel->metric == POINTS_METRIC) @@ -1339,14 +1339,14 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel) bitmapped_sizes = &fontsel_info->pixel_sizes[style->pixel_sizes_index]; nbitmapped_sizes = style->npixel_sizes; } - + if (!(fontsel->scale_bitmapped_fonts && style->flags & SCALABLE_BITMAP_FONT) && !(style->flags & SCALABLE_FONT)) nstandard_sizes = 0; - + gtk_clist_freeze (GTK_CLIST(fontsel->size_clist)); gtk_clist_clear (GTK_CLIST(fontsel->size_clist)); - + /* Interleave the standard sizes with the bitmapped sizes so we get a list of ascending sizes. If the metric is points, we have to convert the decipoints to points. */ @@ -1365,7 +1365,7 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel) bitmap_size = *bitmapped_sizes; bitmap_size_float = *bitmapped_sizes; } - + if (can_match && nstandard_sizes && nbitmapped_sizes && *standard_sizes == bitmap_size) { @@ -1418,12 +1418,12 @@ gtk_font_selection_size_key_press (GtkWidget *w, gint new_size; gfloat new_size_float; gchar *text; - + #ifdef FONTSEL_DEBUG - g_print("In size_key_press\n"); + g_message("In size_key_press\n"); #endif fontsel = GTK_FONT_SELECTION(data); - + if (event->keyval == GDK_Return) { text = gtk_entry_get_text (GTK_ENTRY (fontsel->size_entry)); @@ -1440,19 +1440,19 @@ gtk_font_selection_size_key_press (GtkWidget *w, if (new_size < 20) new_size = 20; } - + /* Remember that this size was set explicitly. */ fontsel->selected_size = new_size; - + /* Check if the font size has changed, and return if it hasn't. */ if (fontsel->size == new_size) return TRUE; - + fontsel->size = new_size; gtk_font_selection_select_best_size (fontsel); return TRUE; } - + return FALSE; } @@ -1470,14 +1470,14 @@ gtk_font_selection_select_best_size(GtkFontSelection *fontsel) gboolean found = FALSE; gchar buffer[32]; GList *selection; - + #ifdef FONTSEL_DEBUG - g_print("In select_best_size\n"); + g_message("In select_best_size\n"); #endif font = &fontsel_info->font_info[fontsel->font_index]; styles = &fontsel_info->font_styles[font->style_index]; style = &styles[fontsel->style]; - + /* Find the closest size available in the size clist. If the exact size is in the list set found to TRUE. */ for (row = 0; row < GTK_CLIST(fontsel->size_clist)->rows; row++) @@ -1490,7 +1490,7 @@ gtk_font_selection_select_best_size(GtkFontSelection *fontsel) if (nmatched == 2) size += size_fraction; } - + if (size == fontsel->selected_size) { found = TRUE; @@ -1506,13 +1506,13 @@ gtk_font_selection_select_best_size(GtkFontSelection *fontsel) best_row = row; } } - + /* If we aren't scaling bitmapped fonts and this is a bitmapped font, we need to use the closest size found. */ if (!(fontsel->scale_bitmapped_fonts && style->flags & SCALABLE_BITMAP_FONT) && !(style->flags & SCALABLE_FONT)) found = TRUE; - + if (found) { fontsel->size = best_size; @@ -1527,7 +1527,7 @@ gtk_font_selection_select_best_size(GtkFontSelection *fontsel) gtk_clist_unselect_row(GTK_CLIST(fontsel->size_clist), GPOINTER_TO_INT (selection->data), 0); gtk_clist_moveto(GTK_CLIST(fontsel->size_clist), best_row, -1, 0.5, 0); - + /* Show the size in the size entry. */ if (fontsel->metric == PIXELS_METRIC) sprintf(buffer, "%i", fontsel->size); @@ -1557,15 +1557,15 @@ gtk_font_selection_select_size (GtkWidget *w, gchar *text; gchar buffer[16]; gint i; - + #ifdef FONTSEL_DEBUG - g_print("In select_size\n"); + g_message("In select_size\n"); #endif fontsel = GTK_FONT_SELECTION(data); - + if (bevent && !GTK_WIDGET_HAS_FOCUS (w)) gtk_widget_grab_focus (w); - + /* Copy the size from the clist to the size entry, but without the bitmapped marker ('*'). */ gtk_clist_get_text(GTK_CLIST(fontsel->size_clist), row, 0, &text); @@ -1577,18 +1577,18 @@ gtk_font_selection_select_size (GtkWidget *w, } buffer[i] = '\0'; gtk_entry_set_text(GTK_ENTRY(fontsel->size_entry), buffer); - + /* Check if the font size has changed, and return if it hasn't. */ new_size = atoi(text); if (fontsel->metric == POINTS_METRIC) new_size *= 10; - + if (fontsel->size == new_size) return; - + /* If the size was selected by the user we set the selected_size. */ fontsel->selected_size = new_size; - + fontsel->size = new_size; gtk_font_selection_load_font (fontsel); } @@ -1600,9 +1600,9 @@ gtk_font_selection_metric_callback (GtkWidget *w, gpointer data) { GtkFontSelection *fontsel = GTK_FONT_SELECTION(data); - + #ifdef FONTSEL_DEBUG - g_print("In metric_callback\n"); + g_message("In metric_callback\n"); #endif if (GTK_TOGGLE_BUTTON(fontsel->pixels_button)->active) { @@ -1636,11 +1636,11 @@ gtk_font_selection_field_to_index (gchar **table, gchar *field) { gint i; - + for (i = 0; i < ntable; i++) if (strcmp (field, table[i]) == 0) return i; - + return 0; } @@ -1652,24 +1652,24 @@ gtk_font_selection_load_font (GtkFontSelection *fontsel) { GdkFont *font; gchar *fontname, *label_text; - + if (fontsel->font) gdk_font_unref (fontsel->font); fontsel->font = NULL; - + /* If no family has been selected yet, just return FALSE. */ if (fontsel->font_index == -1) return FALSE; - + fontname = gtk_font_selection_get_font_name (fontsel); if (fontname) { #ifdef FONTSEL_DEBUG - g_print("Loading: %s\n", fontname); + g_message("Loading: %s\n", fontname); #endif font = gdk_font_load (fontname); g_free(fontname); - + if (font) { fontsel->font = font; @@ -1692,7 +1692,7 @@ gtk_font_selection_load_font (GtkFontSelection *fontsel) gtk_label_set(GTK_LABEL(fontsel->message_label), "The selected font is not a valid font."); } - + return FALSE; } @@ -1711,19 +1711,19 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel) gint text_height, new_height; gchar *text; XFontStruct *xfs; - + #ifdef FONTSEL_DEBUG - g_print("In update_preview\n"); + g_message("In update_preview\n"); #endif style = gtk_style_new (); gdk_font_unref (style->font); style->font = fontsel->font; gdk_font_ref (style->font); - + preview_entry = fontsel->preview_entry; gtk_widget_set_style (preview_entry, style); gtk_style_unref(style); - + text_height = preview_entry->style->font->ascent + preview_entry->style->font->descent; /* We don't ever want to be over MAX_PREVIEW_HEIGHT pixels high. */ @@ -1732,17 +1732,17 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel) new_height = INITIAL_PREVIEW_HEIGHT; if (new_height > MAX_PREVIEW_HEIGHT) new_height = MAX_PREVIEW_HEIGHT; - + if ((preview_entry->requisition.height < text_height + 10) || (preview_entry->requisition.height > text_height + 40)) gtk_widget_set_usize(preview_entry, -1, new_height); - + /* This sets the preview text, if it hasn't been set already. */ text = gtk_entry_get_text(GTK_ENTRY(fontsel->preview_entry)); if (strlen(text) == 0) gtk_entry_set_text(GTK_ENTRY(fontsel->preview_entry), PREVIEW_TEXT); gtk_entry_set_position(GTK_ENTRY(fontsel->preview_entry), 0); - + /* If this is a 2-byte font display a message to say it may not be displayed properly. */ xfs = GDK_FONT_XFONT(fontsel->font); @@ -1759,18 +1759,18 @@ gtk_font_selection_switch_page (GtkWidget *w, gpointer data) { GtkFontSelection *fontsel = GTK_FONT_SELECTION(data); - + /* This function strangely gets called when the window is destroyed, so we check here to see if the notebook is visible. */ if (!GTK_WIDGET_VISIBLE(w)) return; - + if (page_num == 0) gtk_font_selection_filter_fonts(fontsel); else if (page_num == 1) gtk_font_selection_show_font_info(fontsel); } - + static void gtk_font_selection_show_font_info (GtkFontSelection *fontsel) @@ -1783,11 +1783,11 @@ gtk_font_selection_show_font_info (GtkFontSelection *fontsel) gchar *field; gint i; gboolean shown_actual_fields = FALSE; - + fontname = gtk_font_selection_get_font_name(fontsel); gtk_entry_set_text(GTK_ENTRY(fontsel->requested_font_name), fontname ? fontname : ""); - + gtk_clist_freeze (GTK_CLIST(fontsel->info_clist)); for (i = 0; i < GTK_XLFD_NUM_FIELDS; i++) { @@ -1805,7 +1805,7 @@ gtk_font_selection_show_font_info (GtkFontSelection *fontsel) gtk_clist_set_text(GTK_CLIST(fontsel->info_clist), i, 1, field ? field : ""); } - + if (fontsel->font) { font_atom = XInternAtom(GDK_DISPLAY(), "FONT", True); @@ -1817,7 +1817,7 @@ gtk_font_selection_show_font_info (GtkFontSelection *fontsel) { name = XGetAtomName(GDK_DISPLAY(), atom); gtk_entry_set_text(GTK_ENTRY(fontsel->actual_font_name), name); - + for (i = 0; i < GTK_XLFD_NUM_FIELDS; i++) { field = gtk_font_selection_get_xlfd_field (name, i, @@ -1929,11 +1929,11 @@ gtk_font_selection_filter_fonts (GtkFontSelection *fontsel) GList *selection; gboolean empty_filter = TRUE, filter_changed = FALSE; gint prop, nselected, i, row, index; - + #ifdef FONTSEL_DEBUG - g_print("In filter_fonts\n"); + g_message("In filter_fonts\n"); #endif - + /* Check if the filter has changed, and also if it is an empty filter, i.e. all '*'s are selected. */ for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) @@ -1944,7 +1944,7 @@ gtk_font_selection_filter_fonts (GtkFontSelection *fontsel) if (nselected != 1 || GPOINTER_TO_INT (selection->data) != 0) { empty_filter = FALSE; - + if (fontsel->property_nfilters[prop] != nselected) filter_changed = TRUE; else @@ -1965,15 +1965,15 @@ gtk_font_selection_filter_fonts (GtkFontSelection *fontsel) filter_changed = TRUE; } } - + /* If the filter hasn't changed we just return. */ if (!filter_changed) return; - + #ifdef FONTSEL_DEBUG - g_print(" filter_fonts: filter has changed\n"); + g_message(" filter_fonts: filter has changed\n"); #endif - + /* Setting the toggle buttons state will trigger the callbacks to clear or apply the filter, unless the font list is already filtered, in which case we have to call apply_filter here. */ @@ -2003,18 +2003,18 @@ gtk_font_selection_apply_filter (GtkFontSelection *fontsel) gchar font_buffer[XLFD_MAX_FIELD_LEN * 2 + 4]; gchar *font_item; gboolean matched, matched_style; - + #ifdef FONTSEL_DEBUG - g_print("In apply_filter\n"); + g_message("In apply_filter\n"); #endif font_info = fontsel_info->font_info; nfonts = fontsel_info->nfonts; - + /* Free the old filter data and create the new arrays. */ for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) { g_free(fontsel->property_filters[prop]); - + clist = fontsel->filter_clists[prop]; selection = GTK_CLIST(clist)->selection; nselected = g_list_length(selection); @@ -2036,14 +2036,14 @@ gtk_font_selection_apply_filter (GtkFontSelection *fontsel) } } } - + /* Filter the list of fonts. */ gtk_clist_freeze (GTK_CLIST(fontsel->font_clist)); gtk_clist_clear (GTK_CLIST(fontsel->font_clist)); for (i = 0; i < nfonts; i++) { font = &font_info[i]; - + /* Check if the foundry matches. */ if (fontsel->property_nfilters[FOUNDRY] != 0) { @@ -2059,7 +2059,7 @@ gtk_font_selection_apply_filter (GtkFontSelection *fontsel) if (!matched) continue; } - + /* Now check if the other properties are matched in at least one style.*/ matched_style = FALSE; for (style = 0; style < font->nstyles; style++) @@ -2072,7 +2072,7 @@ gtk_font_selection_apply_filter (GtkFontSelection *fontsel) } if (!matched_style) continue; - + /* Insert the font in the clist. */ if ((i > 0 && font->family == font_info[i-1].family) || (i < nfonts - 1 && font->family == font_info[i+1].family)) @@ -2091,7 +2091,7 @@ gtk_font_selection_apply_filter (GtkFontSelection *fontsel) GINT_TO_POINTER (i)); } gtk_clist_thaw (GTK_CLIST(fontsel->font_clist)); - + /* Clear the current font and the style clist. */ fontsel->font_index = -1; if (fontsel->font) @@ -2113,13 +2113,13 @@ gtk_font_selection_style_visible(GtkFontSelection *fontsel, guint16 value; gint prop, j; gboolean matched; - + styles = &fontsel_info->font_styles[font->style_index]; - + for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) { value = styles[style].properties[prop]; - + if (fontsel->property_nfilters[prop] != 0) { matched = FALSE; @@ -2146,9 +2146,9 @@ gtk_font_selection_reset_filter (GtkWidget *w, { GtkFontSelection *fontsel; gint prop; - + fontsel = GTK_FONT_SELECTION(data); - + for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) gtk_clist_select_row(GTK_CLIST(fontsel->filter_clists[prop]), 0, 0); } @@ -2160,7 +2160,7 @@ gtk_font_selection_on_clear_filter (GtkWidget *w, gpointer data) { GtkFontSelection *fontsel; - + fontsel = GTK_FONT_SELECTION(data); gtk_font_selection_clear_filter(fontsel); } @@ -2172,9 +2172,9 @@ gtk_font_selection_clear_filter (GtkFontSelection *fontsel) { gboolean filtered = FALSE, found_style = FALSE; gint prop, row, style; - + #ifdef FONTSEL_DEBUG - g_print("In clear_filter\n"); + g_message("In clear_filter\n"); #endif /* Clear the filter data. */ for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) @@ -2185,20 +2185,20 @@ gtk_font_selection_clear_filter (GtkFontSelection *fontsel) fontsel->property_filters[prop] = NULL; fontsel->property_nfilters[prop] = 0; } - + /* Select all the '*'s on the filter page. */ gtk_font_selection_reset_filter(NULL, fontsel); - + /* Update the main notebook page. */ gtk_widget_set_sensitive(fontsel->filter_button, FALSE); gtk_label_set(GTK_LABEL(fontsel->font_label), "Font:"); - + /* If there is no filter at present just return. */ if (!filtered) return; - + gtk_font_selection_insert_fonts(fontsel); - + /* Now find the current font & style and select them again. */ if (fontsel->font_index != -1) { @@ -2209,7 +2209,7 @@ gtk_font_selection_clear_filter (GtkFontSelection *fontsel) gtk_clist_moveto(GTK_CLIST(fontsel->font_clist), fontsel->font_index, -1, 0.5, 0); gtk_font_selection_show_available_styles (fontsel); - + for (row = 0; row < GTK_CLIST(fontsel->font_style_clist)->rows; row++) { style = GPOINTER_TO_INT (gtk_clist_get_row_data(GTK_CLIST(fontsel->font_style_clist), row)); @@ -2219,7 +2219,7 @@ gtk_font_selection_clear_filter (GtkFontSelection *fontsel) break; } } - + if (found_style) { gtk_clist_select_row(GTK_CLIST(fontsel->font_style_clist), @@ -2255,9 +2255,9 @@ gtk_font_selection_get_fonts (void) gchar *field; guint8 flags; guint16 *pixel_sizes, *point_sizes, *tmp_sizes; - + fontsel_info = g_new (GtkFontSelInfo, 1); - + /* Get a maximum of MAX_FONTS fontnames from the X server. Use "-*" as the pattern rather than "-*-*-*-*-*-*-*-*-*-*-*-*-*-*" since the latter may result in fonts being returned which don't actually exist. @@ -2266,7 +2266,7 @@ gtk_font_selection_get_fonts (void) /* Output a warning if we actually get MAX_FONTS fonts. */ if (num_fonts == MAX_FONTS) g_warning("MAX_FONTS exceeded. Some fonts may be missing."); - + /* The maximum size of all these tables is the number of font names returned. We realloc them later when we know exactly how many unique entries there are. */ @@ -2274,9 +2274,9 @@ gtk_font_selection_get_fonts (void) fontsel_info->font_styles = g_new (FontStyle, num_fonts); fontsel_info->pixel_sizes = g_new (guint16, num_fonts); fontsel_info->point_sizes = g_new (guint16, num_fonts); - + fontnames = g_new (GSList*, num_fonts); - + /* Create the initial arrays for the property value strings, though they may be realloc'ed later. Put the wildcard '*' in the first elements. */ for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) @@ -2286,8 +2286,8 @@ gtk_font_selection_get_fonts (void) fontsel_info->nproperties[prop] = 1; fontsel_info->properties[prop][0] = "*"; } - - + + /* Insert the font families into the main table, sorted by family and foundry (fonts with different foundries are placed in seaparate FontInfos. All fontnames in each family + foundry are placed into the fontnames @@ -2296,7 +2296,7 @@ gtk_font_selection_get_fonts (void) for (i = 0; i < num_fonts; i++) { #ifdef FONTSEL_DEBUG - g_print("%s\n", xfontnames[i]); + g_message("%s\n", xfontnames[i]); #endif if (gtk_font_selection_is_xlfd_font_name (xfontnames[i])) gtk_font_selection_insert_font (fontnames, &fontsel_info->nfonts, xfontnames[i]); @@ -2307,15 +2307,15 @@ gtk_font_selection_get_fonts (void) #endif } } - - + + /* Since many font names will be in the same FontInfo not all of the allocated FontInfo table will be used, so we will now reallocate it with the real size. */ fontsel_info->font_info = g_realloc(fontsel_info->font_info, - sizeof(FontInfo) * fontsel_info->nfonts); - - + sizeof(FontInfo) * fontsel_info->nfonts); + + /* Now we work out which choices of weight/slant etc. are valid for each font. */ fontsel_info->nstyles = 0; @@ -2323,10 +2323,10 @@ gtk_font_selection_get_fonts (void) for (i = 0; i < fontsel_info->nfonts; i++) { font = &fontsel_info->font_info[i]; - + /* Use the next free position in the styles array. */ font->style_index = fontsel_info->nstyles; - + /* Now step through each of the fontnames with this family, and create a style for each fontname. Each style contains the index into the weights/slants etc. arrays, and a number of pixel/point sizes. */ @@ -2336,7 +2336,7 @@ gtk_font_selection_get_fonts (void) { fontname = temp_list->data; temp_list = temp_list->next; - + for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) { current_style->properties[prop] @@ -2347,26 +2347,26 @@ gtk_font_selection_get_fonts (void) current_style->point_sizes_index = npoint_sizes; current_style->npoint_sizes = 0; current_style->flags = 0; - - + + field = gtk_font_selection_get_xlfd_field (fontname, XLFD_PIXELS, field_buffer); pixels = atoi(field); - + field = gtk_font_selection_get_xlfd_field (fontname, XLFD_POINTS, field_buffer); points = atoi(field); - + field = gtk_font_selection_get_xlfd_field (fontname, XLFD_RESOLUTION_X, field_buffer); res_x = atoi(field); - + field = gtk_font_selection_get_xlfd_field (fontname, XLFD_RESOLUTION_Y, field_buffer); res_y = atoi(field); - + if (pixels == 0 && points == 0) { if (res_x == 0 && res_y == 0) @@ -2379,7 +2379,7 @@ gtk_font_selection_get_fonts (void) } else flags = BITMAP_FONT; - + /* Now we check to make sure that the style is unique. If it isn't we forget it. */ prev_style = fontsel_info->font_styles + font->style_index; @@ -2400,7 +2400,7 @@ gtk_font_selection_get_fonts (void) break; prev_style++; } - + /* If we matched an existing style, we need to add the pixels & point sizes to the style. If not, we insert the pixel & point sizes into our new style. Note that we don't add sizes for @@ -2431,11 +2431,11 @@ gtk_font_selection_get_fonts (void) for (tmp_sizes = fontsel_info->pixel_sizes + npixel_sizes; tmp_sizes > pixel_sizes; tmp_sizes--) *tmp_sizes = *(tmp_sizes - 1); - + *pixel_sizes = pixels; npixel_sizes++; prev_style->npixel_sizes++; - + tmp_style = prev_style + 1; while (tmp_style < current_style) { @@ -2443,7 +2443,7 @@ gtk_font_selection_get_fonts (void) tmp_style++; } } - + point_sizes = fontsel_info->point_sizes + prev_style->point_sizes_index; found_size = FALSE; @@ -2465,11 +2465,11 @@ gtk_font_selection_get_fonts (void) for (tmp_sizes = fontsel_info->point_sizes + npoint_sizes; tmp_sizes > point_sizes; tmp_sizes--) *tmp_sizes = *(tmp_sizes - 1); - + *point_sizes = points; npoint_sizes++; prev_style->npoint_sizes++; - + tmp_style = prev_style + 1; while (tmp_style < current_style) { @@ -2495,77 +2495,77 @@ gtk_font_selection_get_fonts (void) } } g_slist_free(fontnames[i]); - + /* Set nstyles to the real value, minus duplicated fontnames. Note that we aren't using all the allocated memory if fontnames are duplicated. */ font->nstyles = style; } - + /* Since some repeated styles may be skipped we won't have used all the allocated space, so we will now reallocate it with the real size. */ fontsel_info->font_styles = g_realloc(fontsel_info->font_styles, - sizeof(FontStyle) * fontsel_info->nstyles); + sizeof(FontStyle) * fontsel_info->nstyles); fontsel_info->pixel_sizes = g_realloc(fontsel_info->pixel_sizes, - sizeof(guint16) * npixel_sizes); + sizeof(guint16) * npixel_sizes); fontsel_info->point_sizes = g_realloc(fontsel_info->point_sizes, - sizeof(guint16) * npoint_sizes); + sizeof(guint16) * npoint_sizes); g_free(fontnames); XFreeFontNames (xfontnames); - - + + /* Debugging Output */ /* This outputs all FontInfos. */ #ifdef FONTSEL_DEBUG - g_print("\n\n Font Family Weight Slant Set Width Spacing Charset\n\n"); + g_message("\n\n Font Family Weight Slant Set Width Spacing Charset\n\n"); for (i = 0; i < fontsel_info->nfonts; i++) { FontInfo *font = &fontsel_info->font_info[i]; FontStyle *styles = fontsel_info->font_styles + font->style_index; for (style = 0; style < font->nstyles; style++) { - g_print("%5i %-16.16s ", i, font->family); + g_message("%5i %-16.16s ", i, font->family); for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) - g_print("%-9.9s ", - fontsel_info->properties[prop][styles->properties[prop]]); - g_print("\n "); - + g_message("%-9.9s ", + fontsel_info->properties[prop][styles->properties[prop]]); + g_message("\n "); + if (styles->flags & BITMAP_FONT) - g_print("Bitmapped font "); + g_message("Bitmapped font "); if (styles->flags & SCALABLE_FONT) - g_print("Scalable font "); + g_message("Scalable font "); if (styles->flags & SCALABLE_BITMAP_FONT) - g_print("Scalable-Bitmapped font "); - g_print("\n"); - + g_message("Scalable-Bitmapped font "); + g_message("\n"); + if (styles->npixel_sizes) { - g_print(" Pixel sizes: "); + g_message(" Pixel sizes: "); tmp_sizes = fontsel_info->pixel_sizes + styles->pixel_sizes_index; for (size = 0; size < styles->npixel_sizes; size++) - g_print("%i ", *tmp_sizes++); - g_print("\n"); + g_message("%i ", *tmp_sizes++); + g_message("\n"); } - + if (styles->npoint_sizes) { - g_print(" Point sizes: "); + g_message(" Point sizes: "); tmp_sizes = fontsel_info->point_sizes + styles->point_sizes_index; for (size = 0; size < styles->npoint_sizes; size++) - g_print("%i ", *tmp_sizes++); - g_print("\n"); + g_message("%i ", *tmp_sizes++); + g_message("\n"); } - - g_print("\n"); + + g_message("\n"); styles++; } } /* This outputs all available properties. */ for (prop = 0; prop < GTK_NUM_FONT_PROPERTIES; prop++) { - g_print("Property: %s\n", xlfd_field_names[xlfd_index[prop]]); + g_message("Property: %s\n", xlfd_field_names[xlfd_index[prop]]); for (i = 0; i < fontsel_info->nproperties[prop]; i++) - g_print(" %s\n", fontsel_info->properties[prop][i]); + g_message(" %s\n", fontsel_info->properties[prop][i]); } #endif } @@ -2588,17 +2588,17 @@ gtk_font_selection_insert_font (GSList *fontnames[], gint lower, upper; gint middle, cmp; gchar family_buffer[XLFD_MAX_FIELD_LEN]; - + table = fontsel_info->font_info; - + /* insert a fontname into a table */ family = gtk_font_selection_get_xlfd_field (fontname, XLFD_FAMILY, family_buffer); if (!family) return; - + foundry = gtk_font_selection_insert_field (fontname, FOUNDRY); - + lower = 0; if (*ntable > 0) { @@ -2608,7 +2608,7 @@ gtk_font_selection_insert_font (GSList *fontnames[], while (lower < upper) { middle = (lower + upper) >> 1; - + cmp = strcmp (family, table[middle].family); /* If the family matches we sort by the foundry. */ if (cmp == 0) @@ -2618,7 +2618,7 @@ gtk_font_selection_insert_font (GSList *fontnames[], cmp = strcmp(fontsel_info->properties[FOUNDRY][foundry], fontsel_info->properties[FOUNDRY][table[middle].foundry]); } - + if (cmp == 0) { fontnames[middle] = g_slist_prepend (fontnames[middle], @@ -2631,14 +2631,14 @@ gtk_font_selection_insert_font (GSList *fontnames[], lower = middle+1; } } - + /* Add another entry to the table for this new font family */ temp_info.family = family_exists ? family : g_strdup(family); temp_info.foundry = foundry; temp_fontname = g_slist_prepend (NULL, fontname); - + (*ntable)++; - + /* Quickly insert the entry into the table in sorted order * using a modification of insertion sort and the knowledge * that the entries proper position in the table was determined @@ -2669,26 +2669,26 @@ gtk_font_selection_insert_field (gchar *fontname, gchar field_buffer[XLFD_MAX_FIELD_LEN]; gchar *field; guint16 index; - + field = gtk_font_selection_get_xlfd_field (fontname, xlfd_index[prop], field_buffer); if (!field) return 0; - + /* If the field is already in the array just return its index. */ for (index = 0; index < fontsel_info->nproperties[prop]; index++) if (!strcmp(field, fontsel_info->properties[prop][index])) return index; - + /* Make sure we have enough space to add the field. */ if (fontsel_info->nproperties[prop] == fontsel_info->space_allocated[prop]) { fontsel_info->space_allocated[prop] += PROPERTY_ARRAY_INCREMENT; fontsel_info->properties[prop] = g_realloc(fontsel_info->properties[prop], - sizeof(gchar*) - * fontsel_info->space_allocated[prop]); + sizeof(gchar*) + * fontsel_info->space_allocated[prop]); } - + /* Add the new field. */ index = fontsel_info->nproperties[prop]; fontsel_info->properties[prop][index] = g_strdup(field); @@ -2716,18 +2716,18 @@ gtk_font_selection_get_font_name (GtkFontSelection *fontsel) gchar *family_str, *foundry_str; gchar *property_str[GTK_NUM_STYLE_PROPERTIES]; gint prop; - + g_return_val_if_fail (fontsel != NULL, NULL); g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), NULL); - + /* If no family has been selected return NULL. */ if (fontsel->font_index == -1) return NULL; - + font = &fontsel_info->font_info[fontsel->font_index]; family_str = font->family; foundry_str = fontsel_info->properties[FOUNDRY][font->foundry]; - + for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) { property_str[prop] @@ -2735,7 +2735,7 @@ gtk_font_selection_get_font_name (GtkFontSelection *fontsel) if (strcmp (property_str[prop], "(nil)") == 0) property_str[prop] = ""; } - + return gtk_font_selection_create_xlfd (fontsel->size, fontsel->metric, foundry_str, @@ -2755,10 +2755,10 @@ gtk_font_selection_get_best_match(GtkFontSelection *fontsel) FontInfo *font; FontStyle *styles; gint prop, style, best_style = 0, matched, best_matched = 0; - + font = &fontsel_info->font_info[fontsel->font_index]; styles = &fontsel_info->font_styles[font->style_index]; - + /* Find the style with the most matches. */ for (style = 0; style < font->nstyles; style++) { @@ -2774,7 +2774,7 @@ gtk_font_selection_get_best_match(GtkFontSelection *fontsel) best_style = style; } } - + return best_style; } @@ -2794,30 +2794,30 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel, gchar family_buffer[XLFD_MAX_FIELD_LEN]; gchar field_buffer[XLFD_MAX_FIELD_LEN]; gchar buffer[16]; - + g_return_val_if_fail (fontsel != NULL, FALSE); g_return_val_if_fail (GTK_IS_FONT_SELECTION (fontsel), FALSE); g_return_val_if_fail (fontname != NULL, FALSE); - + /* Check it is a valid fontname. */ if (!gtk_font_selection_is_xlfd_font_name(fontname)) return FALSE; - + family = gtk_font_selection_get_xlfd_field (fontname, XLFD_FAMILY, family_buffer); if (!family) return FALSE; - + field = gtk_font_selection_get_xlfd_field (fontname, XLFD_FOUNDRY, - field_buffer); + field_buffer); foundry = gtk_font_selection_field_to_index (fontsel_info->properties[FOUNDRY], fontsel_info->nproperties[FOUNDRY], field); - + index = gtk_font_selection_find_font(fontsel, family, foundry); if (index == -1) return FALSE; - + /* Convert the property fields into indices and set them. */ for (prop = 0; prop < GTK_NUM_STYLE_PROPERTIES; prop++) { @@ -2828,7 +2828,7 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel, field); fontsel->property_values[prop] = value; } - + field = gtk_font_selection_get_xlfd_field (fontname, XLFD_POINTS, field_buffer); size = atoi(field); @@ -2859,10 +2859,10 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel, sprintf (buffer, "%i", size); } gtk_entry_set_text (GTK_ENTRY (fontsel->size_entry), buffer); - + /* Clear any current filter. */ gtk_font_selection_clear_filter(fontsel); - + /* Now find the best style match. */ fontsel->font_index = index; gtk_clist_select_row(GTK_CLIST(fontsel->font_clist), index, 0); @@ -2870,11 +2870,11 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel, gtk_clist_moveto(GTK_CLIST(fontsel->font_clist), index, -1, 0.5, 0); else fontsel->scroll_on_expose = TRUE; - + gtk_font_selection_show_available_styles (fontsel); /* This will load the font. */ gtk_font_selection_select_best_style (fontsel, FALSE); - + return TRUE; } @@ -2887,12 +2887,12 @@ gtk_font_selection_find_font (GtkFontSelection *fontsel, { FontInfo *font_info; gint lower, upper, middle = -1, cmp, nfonts; - + font_info = fontsel_info->font_info; nfonts = fontsel_info->nfonts; if (nfonts == 0) return -1; - + /* Do a binary search to find the font family. */ lower = 0; upper = nfonts; @@ -2904,7 +2904,7 @@ gtk_font_selection_find_font (GtkFontSelection *fontsel, if (cmp == 0) cmp = strcmp(fontsel_info->properties[FOUNDRY][foundry], fontsel_info->properties[FOUNDRY][font_info[middle].foundry]); - + if (cmp == 0) return middle; else if (cmp < 0) @@ -2912,11 +2912,11 @@ gtk_font_selection_find_font (GtkFontSelection *fontsel, else if (cmp > 0) lower = middle+1; } - + /* If we can't match family & foundry see if just the family matches */ if (!strcmp (family, font_info[middle].family)) return middle; - + return -1; } @@ -2955,7 +2955,7 @@ gtk_font_selection_is_xlfd_font_name (const gchar *fontname) { gint i = 0; gint field_len = 0; - + while (*fontname) { if (*fontname++ == '-') @@ -2967,7 +2967,7 @@ gtk_font_selection_is_xlfd_font_name (const gchar *fontname) else field_len++; } - + return (i == 14) ? TRUE : FALSE; } @@ -2984,25 +2984,25 @@ gtk_font_selection_get_xlfd_field (const gchar *fontname, { const gchar *t1, *t2; gint countdown, len, num_dashes; - + if (!fontname) return NULL; - + /* we assume this is a valid fontname...that is, it has 14 fields */ - + countdown = field_num; t1 = fontname; while (*t1 && (countdown >= 0)) if (*t1++ == '-') countdown--; - + num_dashes = (field_num == XLFD_CHARSET) ? 2 : 1; for (t2 = t1; *t2; t2++) { if (*t2 == '-' && --num_dashes == 0) break; } - + if (t1 != t2) { /* Check we don't overflow the buffer */ @@ -3014,7 +3014,7 @@ gtk_font_selection_get_xlfd_field (const gchar *fontname, } else strcpy(buffer, "(nil)"); - + return buffer; } @@ -3036,23 +3036,23 @@ gtk_font_selection_create_xlfd (gint size, gchar buffer[16]; gchar *pixel_size = "*", *point_size = "*", *fontname; gint length; - + if (size <= 0) return NULL; - + sprintf (buffer, "%d", (int) size); if (metric == PIXELS_METRIC) pixel_size = buffer; else point_size = buffer; - + /* Note: be careful here - don't overrun the allocated memory. */ length = strlen(foundry) + strlen(family) + strlen(weight) + strlen(slant) + strlen(set_width) + strlen(pixel_size) + strlen(point_size) + strlen(spacing) + strlen(charset) + 1 + 1 + 1 + 1 + 1 + 3 + 1 + 5 + 3 + 1 /* for the terminating '\0'. */; - + fontname = g_new(gchar, length); /* **NOTE**: If you change this string please change length above! */ sprintf(fontname, "-%s-%s-%s-%s-%s-*-%s-%s-*-*-%s-*-%s", @@ -3071,7 +3071,7 @@ guint gtk_font_selection_dialog_get_type (void) { static guint font_selection_dialog_type = 0; - + if (!font_selection_dialog_type) { GtkTypeInfo fontsel_diag_info = @@ -3085,10 +3085,10 @@ gtk_font_selection_dialog_get_type (void) /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; - + font_selection_dialog_type = gtk_type_unique (GTK_TYPE_WINDOW, &fontsel_diag_info); } - + return font_selection_dialog_type; } @@ -3096,9 +3096,9 @@ static void gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass) { GtkObjectClass *object_class; - + object_class = (GtkObjectClass*) klass; - + font_selection_dialog_parent_class = gtk_type_class (GTK_TYPE_WINDOW); } @@ -3107,24 +3107,24 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag) { fontseldiag->dialog_width = -1; fontseldiag->auto_resize = TRUE; - + gtk_widget_set_events(GTK_WIDGET(fontseldiag), GDK_STRUCTURE_MASK); gtk_signal_connect (GTK_OBJECT (fontseldiag), "configure_event", (GtkSignalFunc) gtk_font_selection_dialog_on_configure, fontseldiag); - + gtk_container_border_width (GTK_CONTAINER (fontseldiag), 4); gtk_window_set_policy(GTK_WINDOW(fontseldiag), FALSE, TRUE, TRUE); - + fontseldiag->main_vbox = gtk_vbox_new (FALSE, 4); gtk_widget_show (fontseldiag->main_vbox); gtk_container_add (GTK_CONTAINER (fontseldiag), fontseldiag->main_vbox); - + fontseldiag->fontsel = gtk_font_selection_new(); gtk_widget_show (fontseldiag->fontsel); gtk_box_pack_start (GTK_BOX (fontseldiag->main_vbox), fontseldiag->fontsel, TRUE, TRUE, 0); - + /* Create the action area */ fontseldiag->action_area = gtk_hbutton_box_new (); gtk_button_box_set_layout(GTK_BUTTON_BOX(fontseldiag->action_area), @@ -3133,38 +3133,38 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag) gtk_box_pack_start (GTK_BOX (fontseldiag->main_vbox), fontseldiag->action_area, FALSE, FALSE, 0); gtk_widget_show (fontseldiag->action_area); - + fontseldiag->ok_button = gtk_button_new_with_label("OK"); GTK_WIDGET_SET_FLAGS (fontseldiag->ok_button, GTK_CAN_DEFAULT); gtk_widget_show(fontseldiag->ok_button); gtk_box_pack_start (GTK_BOX (fontseldiag->action_area), fontseldiag->ok_button, TRUE, TRUE, 0); gtk_widget_grab_default (fontseldiag->ok_button); - + fontseldiag->apply_button = gtk_button_new_with_label("Apply"); GTK_WIDGET_SET_FLAGS (fontseldiag->apply_button, GTK_CAN_DEFAULT); /*gtk_widget_show(fontseldiag->apply_button);*/ gtk_box_pack_start (GTK_BOX(fontseldiag->action_area), fontseldiag->apply_button, TRUE, TRUE, 0); - + fontseldiag->cancel_button = gtk_button_new_with_label("Cancel"); GTK_WIDGET_SET_FLAGS (fontseldiag->cancel_button, GTK_CAN_DEFAULT); gtk_widget_show(fontseldiag->cancel_button); gtk_box_pack_start (GTK_BOX(fontseldiag->action_area), fontseldiag->cancel_button, TRUE, TRUE, 0); - - + + } GtkWidget* gtk_font_selection_dialog_new (const gchar *title) { GtkFontSelectionDialog *fontseldiag; - + fontseldiag = gtk_type_new (GTK_TYPE_FONT_SELECTION_DIALOG); gtk_window_set_title (GTK_WINDOW (fontseldiag), title ? title : "Font Selection"); - + return GTK_WIDGET (fontseldiag); } @@ -3186,7 +3186,7 @@ gtk_font_selection_dialog_set_font_name (GtkFontSelectionDialog *fsd, { return gtk_font_selection_set_font_name(GTK_FONT_SELECTION(fsd->fontsel), fontname); - + } gchar* @@ -3224,6 +3224,6 @@ gtk_font_selection_dialog_on_configure (GtkWidget *widget, fsd->auto_resize = TRUE; gtk_window_set_policy(GTK_WINDOW(fsd), FALSE, TRUE, TRUE); } - + return FALSE; } diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 2089d881df..5f7b354d74 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -361,56 +361,11 @@ gtk_init (int *argc, } else if (strcmp ("--g-fatal-warnings", (*argv)[i]) == 0) { - GLogLevelFlags fatal_levels; + GLogLevelFlags fatal_mask; - fatal_levels = g_log_set_fatal_mask (g_log_domain_glib, G_LOG_FATAL_MASK); - fatal_levels |= G_LOG_LEVEL_WARNING; - g_log_set_fatal_mask (g_log_domain_glib, fatal_levels); - (*argv)[i] = NULL; - } - else if (strcmp ("--gdk-fatal-warnings", (*argv)[i]) == 0) - { - GLogLevelFlags fatal_levels; - - fatal_levels = g_log_set_fatal_mask ("Gdk", G_LOG_FATAL_MASK); - fatal_levels |= G_LOG_LEVEL_WARNING; - g_log_set_fatal_mask ("Gdk", fatal_levels); - (*argv)[i] = NULL; - } - else if (strcmp ("--gtk-fatal-warnings", (*argv)[i]) == 0) - { - GLogLevelFlags fatal_levels; - - fatal_levels = g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_FATAL_MASK); - fatal_levels |= G_LOG_LEVEL_WARNING; - g_log_set_fatal_mask (G_LOG_DOMAIN, fatal_levels); - (*argv)[i] = NULL; - } - else if (strcmp ("--g-fatal-checks", (*argv)[i]) == 0) - { - GLogLevelFlags fatal_levels; - - fatal_levels = g_log_set_fatal_mask (g_log_domain_glib, G_LOG_FATAL_MASK); - fatal_levels |= G_LOG_LEVEL_CRITICAL; - g_log_set_fatal_mask (g_log_domain_glib, fatal_levels); - (*argv)[i] = NULL; - } - else if (strcmp ("--gdk-fatal-checks", (*argv)[i]) == 0) - { - GLogLevelFlags fatal_levels; - - fatal_levels = g_log_set_fatal_mask ("Gdk", G_LOG_FATAL_MASK); - fatal_levels |= G_LOG_LEVEL_CRITICAL; - g_log_set_fatal_mask ("Gdk", fatal_levels); - (*argv)[i] = NULL; - } - else if (strcmp ("--gtk-fatal-checks", (*argv)[i]) == 0) - { - GLogLevelFlags fatal_levels; - - fatal_levels = g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_FATAL_MASK); - fatal_levels |= G_LOG_LEVEL_CRITICAL; - g_log_set_fatal_mask (G_LOG_DOMAIN, fatal_levels); + fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); + fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; + g_log_set_always_fatal (fatal_mask); (*argv)[i] = NULL; } i += 1; @@ -454,9 +409,10 @@ gtk_init (int *argc, g_free (current_locale); - GTK_NOTE (MISC, g_print("%s multi-byte string functions.\n", - gtk_use_mb ? "Using" : "Not using")); - + GTK_NOTE (MISC, + g_message ("%s multi-byte string functions.\n", + gtk_use_mb ? "Using" : "Not using")); + /* Initialize the default visual and colormap to be * used in creating widgets. (We want to use the system * defaults so as to be nice to the colormap). diff --git a/gtk/gtkobject.c b/gtk/gtkobject.c index 4e9d6099c3..aaaec0da84 100644 --- a/gtk/gtkobject.c +++ b/gtk/gtkobject.c @@ -95,19 +95,19 @@ gtk_object_debug_foreach (gpointer key, gpointer value, gpointer user_data) GtkObject *object; object = (GtkObject*) value; - g_print ("GTK-DEBUG: %p: %s ref_count=%d%s%s\n", - object, - gtk_type_name (GTK_OBJECT_TYPE (object)), - object->ref_count, - GTK_OBJECT_FLOATING (object) ? " (floating)" : "", - GTK_OBJECT_DESTROYED (object) ? " (destroyed)" : ""); + g_message ("[%p] %s\tref_count=%d%s%s\n", + object, + gtk_type_name (GTK_OBJECT_TYPE (object)), + object->ref_count, + GTK_OBJECT_FLOATING (object) ? " (floating)" : "", + GTK_OBJECT_DESTROYED (object) ? " (destroyed)" : ""); } static void gtk_object_debug (void) { g_hash_table_foreach (living_objs_ht, gtk_object_debug_foreach, NULL); - - g_print ("GTK-DEBUG: living objects count = %d\n", obj_count); + + g_message ("living objects count = %d\n", obj_count); } #endif /* G_ENABLE_DEBUG */ diff --git a/gtk/gtkpreview.c b/gtk/gtkpreview.c index 713db2b570..9a323ff32f 100644 --- a/gtk/gtkpreview.c +++ b/gtk/gtkpreview.c @@ -1252,28 +1252,28 @@ gtk_trim_cmap (GtkPreviewClass *klass) } } } - + if ((nred < 2) || (ngreen < 2) || (nblue < 2) || (ngray < 2)) { - g_print ("Unable to allocate sufficient colormap entries.\n"); - g_print ("Try exiting other color intensive applications.\n"); + g_message ("Unable to allocate sufficient colormap entries.\n"); + g_message ("Try exiting other color intensive applications.\n"); return; } - + /* If any of the shade values has changed, issue a warning */ if ((nred != klass->info.nred_shades) || (ngreen != klass->info.ngreen_shades) || (nblue != klass->info.nblue_shades) || (ngray != klass->info.ngray_shades)) { - g_print ("Not enough colors to satisfy requested color cube.\n"); - g_print ("Reduced color cube shades from\n"); - g_print ("[%d of Red, %d of Green, %d of Blue, %d of Gray] ==> [%d of Red, %d of Green, %d of Blue, %d of Gray]\n", - klass->info.nred_shades, klass->info.ngreen_shades, - klass->info.nblue_shades, klass->info.ngray_shades, - nred, ngreen, nblue, ngray); + g_message ("Not enough colors to satisfy requested color cube.\n"); + g_message ("Reduced color cube shades from\n"); + g_message ("[%d of Red, %d of Green, %d of Blue, %d of Gray] ==> [%d of Red, %d of Green, %d of Blue, %d of Gray]\n", + klass->info.nred_shades, klass->info.ngreen_shades, + klass->info.nblue_shades, klass->info.ngray_shades, + nred, ngreen, nblue, ngray); } - + klass->info.nred_shades = nred; klass->info.ngreen_shades = ngreen; klass->info.nblue_shades = nblue; diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index c1ae9997b6..2e8211ce36 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -96,7 +96,7 @@ struct _GtkIncrInfo GdkWindow *requestor; /* Requestor window - we create a GdkWindow so we can receive events */ GdkAtom selection; /* Selection we're sending */ - + GtkIncrConversion *conversions; /* Information about requested conversions - * With MULTIPLE requests (benighted 1980's * hardware idea), there can be more than @@ -170,7 +170,7 @@ gtk_selection_owner_set (GtkWidget *widget, GtkWidget *old_owner; GtkSelectionInfo *selection_info; GdkWindow *window; - + if (widget == NULL) window = NULL; else @@ -180,7 +180,7 @@ gtk_selection_owner_set (GtkWidget *widget, window = widget->window; } - + tmp_list = current_selections; while (tmp_list) { @@ -191,13 +191,13 @@ gtk_selection_owner_set (GtkWidget *widget, tmp_list = tmp_list->next; } - + if (tmp_list == NULL) selection_info = NULL; else if (selection_info->widget == widget) return TRUE; - + if (gdk_selection_owner_set (window, selection, time, TRUE)) { old_owner = NULL; @@ -242,7 +242,7 @@ gtk_selection_owner_set (GtkWidget *widget, event.window = old_owner->window; event.selection = selection; event.time = time; - + gtk_widget_event (old_owner, (GdkEvent *) &event); } return TRUE; @@ -291,14 +291,14 @@ gtk_selection_add_handler_full (GtkWidget *widget, GList *selection_handlers; GList *tmp_list; GtkSelectionHandler *handler; - + g_return_if_fail (widget != NULL); if (initialize) gtk_selection_init (); selection_handlers = gtk_object_get_data (GTK_OBJECT (widget), gtk_selection_handler_key); - + /* Reuse old handler structure, if present */ tmp_list = selection_handlers; while (tmp_list) @@ -326,7 +326,7 @@ gtk_selection_add_handler_full (GtkWidget *widget, } tmp_list = tmp_list->next; } - + if (tmp_list == NULL && function) { handler = g_new (GtkSelectionHandler, 1); @@ -362,9 +362,9 @@ gtk_selection_remove_all (GtkWidget *widget) GtkSelectionInfo *selection_info; GList *selection_handlers; GtkSelectionHandler *handler; - + /* Remove pending requests/incrs for this widget */ - + tmp_list = current_incrs; while (tmp_list) { @@ -377,7 +377,7 @@ gtk_selection_remove_all (GtkWidget *widget) } tmp_list = next; } - + tmp_list = current_retrievals; while (tmp_list) { @@ -393,7 +393,7 @@ gtk_selection_remove_all (GtkWidget *widget) } /* Disclaim ownership of any selections */ - + tmp_list = current_selections; while (tmp_list) { @@ -413,27 +413,27 @@ gtk_selection_remove_all (GtkWidget *widget) tmp_list = next; } - + /* Now remove all handlers */ - + selection_handlers = gtk_object_get_data (GTK_OBJECT (widget), gtk_selection_handler_key); gtk_object_remove_data (GTK_OBJECT (widget), gtk_selection_handler_key); - + tmp_list = selection_handlers; while (tmp_list) { next = tmp_list->next; handler = (GtkSelectionHandler *)tmp_list->data; - + if (handler->destroy) (*handler->destroy)(handler->data); - + g_free (handler); - + tmp_list = next; } - + g_list_free (selection_handlers); } @@ -464,21 +464,21 @@ gtk_selection_convert (GtkWidget *widget, GtkRetrievalInfo *info; GList *tmp_list; GdkWindow *owner_window; - + g_return_val_if_fail (widget != NULL, FALSE); - + if (initialize) gtk_selection_init (); if (!GTK_WIDGET_REALIZED (widget)) gtk_widget_realize (widget); - + /* Check to see if there are already any retrievals in progress for this widget. If we changed GDK to use the selection for the window property in which to store the retrieved information, then we could support multiple retrievals for different selections. This might be useful for DND. */ - + tmp_list = current_retrievals; while (tmp_list) { @@ -487,43 +487,43 @@ gtk_selection_convert (GtkWidget *widget, return FALSE; tmp_list = tmp_list->next; } - + info = g_new (GtkRetrievalInfo, 1); - + info->widget = widget; info->selection = selection; info->target = target; info->buffer = NULL; info->offset = -1; - + /* Check if this process has current owner. If so, call handler procedure directly to avoid deadlocks with INCR. */ - + owner_window = gdk_selection_owner_get (selection); if (owner_window != NULL) { GtkWidget *owner_widget; GtkSelectionData selection_data; - + selection_data.selection = selection; selection_data.target = target; selection_data.data = NULL; selection_data.length = -1; - + gdk_window_get_user_data (owner_window, (gpointer *)&owner_widget); - + if (owner_widget != NULL) { gtk_selection_invoke_handler (owner_widget, &selection_data); - + gtk_selection_retrieval_report (info, selection_data.type, selection_data.format, selection_data.data, selection_data.length); - + g_free (selection_data.data); g_free (info); @@ -532,11 +532,11 @@ gtk_selection_convert (GtkWidget *widget, } /* Otherwise, we need to go through X */ - + current_retrievals = g_list_append (current_retrievals, info); gdk_selection_convert (widget->window, selection, target, time); gtk_timeout_add (1000, (GtkFunction) gtk_selection_retrieval_timeout, info); - + return TRUE; } @@ -562,10 +562,10 @@ gtk_selection_data_set (GtkSelectionData *selection_data, { if (selection_data->data) g_free (selection_data->data); - + selection_data->type = type; selection_data->format = format; - + if (data) { selection_data->data = g_new (guchar, length+1); @@ -574,7 +574,7 @@ gtk_selection_data_set (GtkSelectionData *selection_data, } else selection_data->data = NULL; - + selection_data->length = length; } @@ -614,10 +614,10 @@ gtk_selection_clear (GtkWidget *widget, Tk filters based on serial #'s, which aren't retained by GTK. Filtering based on time's will be inherently somewhat unreliable. */ - + GList *tmp_list; GtkSelectionInfo *selection_info; - + tmp_list = current_selections; while (tmp_list) { @@ -629,7 +629,7 @@ gtk_selection_clear (GtkWidget *widget, tmp_list = tmp_list->next; } - + if (tmp_list) { if (selection_info->time > event->time) @@ -665,44 +665,44 @@ gtk_selection_request (GtkWidget *widget, GList *tmp_list; guchar *mult_atoms; int i; - + /* Check if we own selection */ - + tmp_list = current_selections; while (tmp_list) { GtkSelectionInfo *selection_info = (GtkSelectionInfo *)tmp_list->data; - + if ((selection_info->selection == event->selection) && (selection_info->widget == widget)) break; - + tmp_list = tmp_list->next; } - + if (tmp_list == NULL) return FALSE; info = g_new(GtkIncrInfo, 1); - + info->widget = widget; info->selection = event->selection; info->num_incrs = 0; - + /* Create GdkWindow structure for the requestor */ - + info->requestor = gdk_window_lookup (event->requestor); if (!info->requestor) info->requestor = gdk_window_foreign_new (event->requestor); /* Determine conversions we need to perform */ - + if (event->target == gtk_selection_atoms[MULTIPLE]) { GdkAtom type; gint format; gint length; - + mult_atoms = NULL; if (!gdk_property_get (info->requestor, event->property, GDK_SELECTION_TYPE_ATOM, 0, GTK_SELECTION_MAX_SIZE, FALSE, @@ -715,10 +715,10 @@ gtk_selection_request (GtkWidget *widget, g_free (info); return TRUE; } - + info->num_conversions = length / (2*sizeof (GdkAtom)); info->conversions = g_new (GtkIncrConversion, info->num_conversions); - + for (i=0; i<info->num_conversions; i++) { info->conversions[i].target = ((GdkAtom *)mult_atoms)[2*i]; @@ -733,39 +733,39 @@ gtk_selection_request (GtkWidget *widget, info->conversions[0].property = event->property; mult_atoms = (guchar *)info->conversions; } - + /* Loop through conversions and determine which of these are big enough to require doing them via INCR */ for (i=0; i<info->num_conversions; i++) { GtkSelectionData data; gint items; - + data.selection = event->selection; data.target = info->conversions[i].target; data.data = NULL; data.length = -1; - + #ifdef DEBUG_SELECTION - g_print("Selection %ld, target %ld (%s) requested by 0x%x (property = %ld)\n", - event->selection, info->conversions[i].target, - gdk_atom_name(info->conversions[i].target), - event->requestor, event->property); + g_message("Selection %ld, target %ld (%s) requested by 0x%x (property = %ld)\n", + event->selection, info->conversions[i].target, + gdk_atom_name(info->conversions[i].target), + event->requestor, event->property); #endif - + gtk_selection_invoke_handler (widget, &data); - + if (data.length < 0) { ((GdkAtom *)mult_atoms)[2*i+1] = GDK_NONE; info->conversions[i].property = GDK_NONE; continue; } - + g_return_val_if_fail ((data.format >= 8) && (data.format % 8 == 0), FALSE); - + items = (data.length + data.format/8 - 1) / (data.format/8); - + if (data.length > GTK_SELECTION_MAX_SIZE) { /* Sending via INCR */ @@ -784,37 +784,37 @@ gtk_selection_request (GtkWidget *widget, else { info->conversions[i].offset = -1; - + gdk_property_change (info->requestor, info->conversions[i].property, data.type, data.format, GDK_PROP_MODE_REPLACE, data.data, items); - + g_free (data.data); } } - + /* If we have some INCR's, we need to send the rest of the data in a callback */ - + if (info->num_incrs > 0) { /* FIXME: this could be dangerous if window doesn't still exist */ - + #ifdef DEBUG_SELECTION - g_print("Starting INCR...\n"); + g_message("Starting INCR...\n"); #endif - + gdk_window_set_events (info->requestor, gdk_window_get_events (info->requestor) | GDK_PROPERTY_CHANGE_MASK); current_incrs = g_list_append (current_incrs, info); gtk_timeout_add (1000, (GtkFunction)gtk_selection_incr_timeout, info); } - + /* If it was a MULTIPLE request, set the property to indicate which conversions succeeded */ if (event->target == gtk_selection_atoms[MULTIPLE]) @@ -825,16 +825,16 @@ gtk_selection_request (GtkWidget *widget, mult_atoms, info->num_conversions); g_free (mult_atoms); } - + gdk_selection_send_notify (event->requestor, event->selection, event->target, event->property, event->time); - + if (info->num_incrs == 0) { g_free (info->conversions); g_free (info); } - + return TRUE; } @@ -861,16 +861,16 @@ gtk_selection_incr_event (GdkWindow *window, GtkIncrInfo *info; gint num_bytes; guchar *buffer; - + int i; if (event->state != GDK_PROPERTY_DELETE) return FALSE; - + #ifdef DEBUG_SELECTION - g_print("PropertyDelete, property %ld\n", event->atom); + g_message("PropertyDelete, property %ld\n", event->atom); #endif - + /* Now find the appropriate ongoing INCR */ tmp_list = current_incrs; while (tmp_list) @@ -881,10 +881,10 @@ gtk_selection_incr_event (GdkWindow *window, tmp_list = tmp_list->next; } - + if (tmp_list == NULL) return FALSE; - + /* Find out which target this is for */ for (i=0; i<info->num_conversions; i++) { @@ -905,7 +905,7 @@ gtk_selection_incr_event (GdkWindow *window, info->conversions[i].offset; buffer = info->conversions[i].data.data + info->conversions[i].offset; - + if (num_bytes > GTK_SELECTION_MAX_SIZE) { num_bytes = GTK_SELECTION_MAX_SIZE; @@ -915,9 +915,9 @@ gtk_selection_incr_event (GdkWindow *window, info->conversions[i].offset = -2; } #ifdef DEBUG_SELECTION - g_print("INCR: put %d bytes (offset = %d) into window 0x%lx , property %ld\n", - num_bytes, info->conversions[i].offset, - GDK_WINDOW_XWINDOW(info->requestor), event->atom); + g_message("INCR: put %d bytes (offset = %d) into window 0x%lx , property %ld\n", + num_bytes, info->conversions[i].offset, + GDK_WINDOW_XWINDOW(info->requestor), event->atom); #endif gdk_property_change (info->requestor, event->atom, info->conversions[i].data.type, @@ -926,7 +926,7 @@ gtk_selection_incr_event (GdkWindow *window, buffer, (num_bytes + info->conversions[i].data.format/8 - 1) / (info->conversions[i].data.format/8)); - + if (info->conversions[i].offset == -2) { g_free (info->conversions[i].data.data); @@ -941,9 +941,9 @@ gtk_selection_incr_event (GdkWindow *window, } break; } - + /* Check if we're finished with all the targets */ - + if (info->num_incrs == 0) { current_incrs = g_list_remove_link (current_incrs, tmp_list); @@ -970,7 +970,7 @@ gtk_selection_incr_timeout (GtkIncrInfo *info) /* Determine if retrieval has finished by checking if it still in list of pending retrievals */ - + tmp_list = current_incrs; while (tmp_list) { @@ -991,7 +991,7 @@ gtk_selection_incr_timeout (GtkIncrInfo *info) g_free (info->conversions); /* FIXME: we should check if requestor window is still in use, and if not, remove it? */ - + g_free (info); return FALSE; /* remove timeout */ @@ -1029,8 +1029,8 @@ gtk_selection_notify (GtkWidget *widget, gint format; #ifdef DEBUG_SELECTION - g_print("Initial receipt of selection %ld, target %ld (property = %ld)\n", - event->selection, event->target, event->property); + g_message("Initial receipt of selection %ld, target %ld (property = %ld)\n", + event->selection, event->target, event->property); #endif tmp_list = current_retrievals; @@ -1041,10 +1041,10 @@ gtk_selection_notify (GtkWidget *widget, break; tmp_list = tmp_list->next; } - + if (!tmp_list) /* no retrieval in progress */ return FALSE; - + if (event->property == GDK_NONE) { current_retrievals = g_list_remove_link (current_retrievals, tmp_list); @@ -1052,18 +1052,18 @@ gtk_selection_notify (GtkWidget *widget, /* structure will be freed in timeout */ gtk_selection_retrieval_report (info, GDK_NONE, 0, NULL, -1); - + return TRUE; } length = gdk_selection_property_get (widget->window, &buffer, &type, &format); - + if (type == gtk_selection_atoms[INCR]) { /* The remainder of the selection will come through PropertyNotify events */ - + info->idle_time = 0; info->offset = 0; /* Mark as OK to proceed */ gdk_window_set_events (widget->window, @@ -1075,17 +1075,17 @@ gtk_selection_notify (GtkWidget *widget, /* We don't delete the info structure - that will happen in timeout */ current_retrievals = g_list_remove_link (current_retrievals, tmp_list); g_list_free (tmp_list); - + info->offset = length; gtk_selection_retrieval_report (info, type, format, buffer, length); } - + gdk_property_delete (widget->window, event->property); - + g_free (buffer); - + return TRUE; } @@ -1112,14 +1112,14 @@ gtk_selection_property_notify (GtkWidget *widget, int length; GdkAtom type; gint format; - + if ((event->state != GDK_PROPERTY_NEW_VALUE) || /* property was deleted */ (event->atom != gdk_selection_property)) /* not the right property */ return FALSE; - + #ifdef DEBUG_SELECTION - g_print("PropertyNewValue, property %ld\n", - event->atom); + g_message("PropertyNewValue, property %ld\n", + event->atom); #endif tmp_list = current_retrievals; @@ -1130,25 +1130,25 @@ gtk_selection_property_notify (GtkWidget *widget, break; tmp_list = tmp_list->next; } - + if (!tmp_list) /* No retrieval in progress */ return FALSE; - + if (info->offset < 0) /* We haven't got the SelectionNotify for this retrieval yet */ return FALSE; - + info->idle_time = 0; length = gdk_selection_property_get (widget->window, &new_buffer, &type, &format); gdk_property_delete (widget->window, event->atom); - + /* We could do a lot better efficiency-wise by paying attention to what length was sent in the initial INCR transaction, instead of doing memory allocation at every step. But its only guaranteed to be a _lower bound_ (pretty useless!) */ - + if (length == 0 || type == GDK_NONE) /* final zero length portion */ { /* Info structure will be freed in timeout */ @@ -1164,18 +1164,18 @@ gtk_selection_property_notify (GtkWidget *widget, if (!info->buffer) { #ifdef DEBUG_SELECTION - g_print("Start - Adding %d bytes at offset 0\n", - length); + g_message("Start - Adding %d bytes at offset 0\n", + length); #endif info->buffer = new_buffer; info->offset = length; } else { - + #ifdef DEBUG_SELECTION - g_print("Appending %d bytes at offset %d\n", - length,info->offset); + g_message("Appending %d bytes at offset %d\n", + length,info->offset); #endif /* We copy length+1 bytes to preserve guaranteed null termination */ info->buffer = g_realloc (info->buffer, info->offset+length+1); @@ -1184,7 +1184,7 @@ gtk_selection_property_notify (GtkWidget *widget, g_free (new_buffer); } } - + return TRUE; } @@ -1203,7 +1203,7 @@ gtk_selection_retrieval_timeout (GtkRetrievalInfo *info) /* Determine if retrieval has finished by checking if it still in list of pending retrievals */ - + tmp_list = current_retrievals; while (tmp_list) { @@ -1233,7 +1233,7 @@ gtk_selection_retrieval_timeout (GtkRetrievalInfo *info) return TRUE; /* timeout will happen again */ } - + } /************************************************************* @@ -1251,15 +1251,15 @@ gtk_selection_retrieval_report (GtkRetrievalInfo *info, guchar *buffer, gint length) { GtkSelectionData data; - + data.selection = info->selection; data.target = info->target; data.type = type; data.format = format; - + data.length = length; data.data = buffer; - + gtk_signal_emit_by_name (GTK_OBJECT(info->widget), "selection_received", &data); } @@ -1284,12 +1284,12 @@ gtk_selection_invoke_handler (GtkWidget *widget, { GList *tmp_list; GtkSelectionHandler *handler; - + g_return_if_fail (widget != NULL); tmp_list = gtk_object_get_data (GTK_OBJECT (widget), gtk_selection_handler_key); - + while (tmp_list) { handler = (GtkSelectionHandler *)tmp_list->data; @@ -1298,7 +1298,7 @@ gtk_selection_invoke_handler (GtkWidget *widget, break; tmp_list = tmp_list->next; } - + if (tmp_list == NULL) gtk_selection_default_handler (widget, data); else @@ -1311,7 +1311,7 @@ gtk_selection_invoke_handler (GtkWidget *widget, GTK_VALUE_BOXED(args[0]) = data; args[1].type = GTK_TYPE_NONE; args[1].name = NULL; - + handler->marshal (GTK_OBJECT(widget), handler->data, 1, args); } else @@ -1357,10 +1357,10 @@ gtk_selection_default_handler (GtkWidget *widget, sizeof (guint32)); return; } - + tmp_list = tmp_list->next; } - + data->length = -1; } else if (data->target == gtk_selection_atoms[TARGETS]) @@ -1370,40 +1370,40 @@ gtk_selection_default_handler (GtkWidget *widget, gint count; GList *tmp_list; GtkSelectionHandler *handler; - + count = 3; tmp_list = gtk_object_get_data (GTK_OBJECT(widget), gtk_selection_handler_key); while (tmp_list) { handler = (GtkSelectionHandler *)tmp_list->data; - + if (handler->selection == data->selection) count++; tmp_list = tmp_list->next; } - + data->type = GDK_SELECTION_TYPE_ATOM; data->format = 8*sizeof (GdkAtom); data->length = count*sizeof (GdkAtom); - + p = g_new (GdkAtom, count); data->data = (guchar *)p; - + *p++ = gtk_selection_atoms[TIMESTAMP]; *p++ = gtk_selection_atoms[TARGETS]; *p++ = gtk_selection_atoms[MULTIPLE]; - + tmp_list = gtk_object_get_data (GTK_OBJECT(widget), gtk_selection_handler_key); while (tmp_list) { handler = (GtkSelectionHandler *)tmp_list->data; - + if (handler->selection == data->selection) *p++ = handler->target; - + tmp_list = tmp_list->next; } } @@ -1418,12 +1418,12 @@ GtkSelectioData* gtk_selection_data_copy (GtkSelectionData *data) { GtkSelectionData *new_data; - + g_return_val_if_fail (data != NULL, NULL); - + new_data = g_new (GtkSelectionData, 1); *new_data = *data; - + return new_data; } @@ -1431,6 +1431,6 @@ void gtk_selection_data_free (GtkSelectionData *data) { g_return_if_fail (data != NULL); - + g_free (data); } diff --git a/gtk/gtktext.c b/gtk/gtktext.c index e725513873..e963e203f2 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -100,7 +100,7 @@ struct _TextFont { /* The actual font. */ GdkFont *gdk_font; - + gint16 char_widths[256]; }; @@ -108,13 +108,13 @@ struct _TextProperty { /* Font. */ TextFont* font; - + /* Background Color. */ GdkColor back_color; - + /* Foreground Color. */ GdkColor fore_color; - + /* Length of this property. */ guint length; }; @@ -147,10 +147,10 @@ struct _LineParams guint pixel_width; guint displayable_chars; guint wraps : 1; - + PrevTabCont tab_cont; PrevTabCont tab_cont_next; - + GtkPropertyMark start; GtkPropertyMark end; }; @@ -192,7 +192,7 @@ static void gtk_text_set_selection (GtkEditable *editable, gint end); static void gtk_text_real_set_editable (GtkEditable *editable, gboolean is_editable); - + /* Event handlers */ static void gtk_text_draw (GtkWidget *widget, GdkRectangle *area); @@ -357,7 +357,7 @@ static void gtk_text_show_props (GtkText* test, const char* func, int line); -#define TDEBUG(args) g_print args +#define TDEBUG(args) g_message args #define TEXT_ASSERT(text) gtk_text_assert (text,__PRETTY_FUNCTION__,__LINE__) #define TEXT_ASSERT_MARK(text,mark,msg) gtk_text_assert_mark (text,mark, \ __PRETTY_FUNCTION__,msg,__LINE__) @@ -451,7 +451,7 @@ GtkType gtk_text_get_type (void) { static GtkType text_type = 0; - + if (!text_type) { GtkTypeInfo text_info = @@ -465,10 +465,10 @@ gtk_text_get_type (void) /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; - + text_type = gtk_type_unique (GTK_TYPE_EDITABLE, &text_info); } - + return text_type; } @@ -478,16 +478,16 @@ gtk_text_class_init (GtkTextClass *class) GtkObjectClass *object_class; GtkWidgetClass *widget_class; GtkEditableClass *editable_class; - + object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; editable_class = (GtkEditableClass*) class; - + parent_class = gtk_type_class (GTK_TYPE_EDITABLE); - + object_class->destroy = gtk_text_destroy; object_class->finalize = gtk_text_finalize; - + widget_class->realize = gtk_text_realize; widget_class->unrealize = gtk_text_unrealize; widget_class->style_set = gtk_text_style_set; @@ -502,21 +502,21 @@ gtk_text_class_init (GtkTextClass *class) widget_class->key_press_event = gtk_text_key_press; widget_class->focus_in_event = gtk_text_focus_in; widget_class->focus_out_event = gtk_text_focus_out; - + editable_class->set_editable = gtk_text_real_set_editable; editable_class->insert_text = gtk_text_insert_text; editable_class->delete_text = gtk_text_delete_text; - + editable_class->move_cursor = gtk_text_move_cursor; editable_class->move_word = gtk_text_move_word; editable_class->move_page = gtk_text_move_page; editable_class->move_to_row = gtk_text_move_to_row; editable_class->move_to_column = gtk_text_move_to_column; - + editable_class->kill_char = gtk_text_kill_char; editable_class->kill_word = gtk_text_kill_word; editable_class->kill_line = gtk_text_kill_line; - + editable_class->update_text = gtk_text_update_text; editable_class->get_chars = gtk_text_get_chars; editable_class->set_selection = gtk_text_set_selection; @@ -527,30 +527,30 @@ static void gtk_text_init (GtkText *text) { GTK_WIDGET_SET_FLAGS (text, GTK_CAN_FOCUS); - + text->text = g_new (guchar, INITIAL_BUFFER_SIZE); text->text_len = INITIAL_BUFFER_SIZE; - + if (!params_mem_chunk) params_mem_chunk = g_mem_chunk_new ("LineParams", sizeof (LineParams), 256 * sizeof (LineParams), G_ALLOC_AND_FREE); - + text->default_tab_width = 4; text->tab_stops = NULL; - + text->tab_stops = g_list_prepend (text->tab_stops, (void*)8); text->tab_stops = g_list_prepend (text->tab_stops, (void*)8); - + text->line_start_cache = NULL; - + text->line_wrap = TRUE; text->word_wrap = FALSE; text->timer = 0; text->button = 0; - + GTK_EDITABLE(text)->editable = FALSE; } @@ -559,12 +559,12 @@ gtk_text_new (GtkAdjustment *hadj, GtkAdjustment *vadj) { GtkText *text; - + text = gtk_type_new (GTK_TYPE_TEXT); - + gtk_text_set_adjustments (text, hadj, vadj); gtk_editable_set_position (GTK_EDITABLE (text), 0); - + return GTK_WIDGET (text); } @@ -574,7 +574,7 @@ gtk_text_set_word_wrap (GtkText *text, { g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + text->word_wrap = (word_wrap != FALSE); if (GTK_WIDGET_REALIZED (text)) @@ -590,7 +590,7 @@ gtk_text_set_editable (GtkText *text, { g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + gtk_editable_set_editable (GTK_EDITABLE (text), is_editable); } @@ -599,12 +599,12 @@ gtk_text_real_set_editable (GtkEditable *editable, gboolean is_editable) { GtkText *text; - + g_return_if_fail (editable != NULL); g_return_if_fail (GTK_IS_TEXT (editable)); - + text = GTK_TEXT (editable); - + editable->editable = (is_editable != FALSE); if (is_editable) @@ -620,25 +620,25 @@ gtk_text_set_adjustments (GtkText *text, { g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + if (text->hadj && (text->hadj != hadj)) { gtk_signal_disconnect_by_data (GTK_OBJECT (text->hadj), text); gtk_object_unref (GTK_OBJECT (text->hadj)); } - + if (text->vadj && (text->vadj != vadj)) { gtk_signal_disconnect_by_data (GTK_OBJECT (text->vadj), text); gtk_object_unref (GTK_OBJECT (text->vadj)); } - + if (!hadj) hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - + if (!vadj) vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - + if (text->hadj != hadj) { text->hadj = hadj; @@ -655,7 +655,7 @@ gtk_text_set_adjustments (GtkText *text, (GtkSignalFunc) gtk_text_disconnect, text); } - + if (text->vadj != vadj) { text->vadj = vadj; @@ -681,7 +681,7 @@ gtk_text_set_point (GtkText *text, g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); g_return_if_fail (index <= TEXT_LENGTH (text)); - + text->point = find_mark (text, index); } @@ -690,7 +690,7 @@ gtk_text_get_point (GtkText *text) { g_return_val_if_fail (text != NULL, 0); g_return_val_if_fail (GTK_IS_TEXT (text), 0); - + return text->point.index; } @@ -699,7 +699,7 @@ gtk_text_get_length (GtkText *text) { g_return_val_if_fail (text != NULL, 0); g_return_val_if_fail (GTK_IS_TEXT (text), 0); - + return TEXT_LENGTH (text); } @@ -708,7 +708,7 @@ gtk_text_freeze (GtkText *text) { g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + text->freeze = TRUE; } @@ -717,9 +717,9 @@ gtk_text_thaw (GtkText *text) { g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + text->freeze = FALSE; - + if (GTK_WIDGET_REALIZED (text)) { recompute_geometry (text); @@ -737,26 +737,26 @@ gtk_text_insert (GtkText *text, { GtkEditable *editable = GTK_EDITABLE (text); gboolean frozen = FALSE; - + gint new_line_count = 1; guint old_height = 0; guint length; guint i; - + g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + /* This must be because we need to have the style set up. */ g_assert (GTK_WIDGET_REALIZED(text)); - + if (nchars < 0) length = strlen (chars); else length = nchars; - + if (length == 0) return; - + if (!text->freeze && (length > FREEZE_LENGTH)) { gtk_text_freeze (text); @@ -776,10 +776,10 @@ gtk_text_insert (GtkText *text, if (chars[i] == '\n') new_line_count++; } - + if (text->point.index < text->first_line_start_index) text->first_line_start_index += length; - + if (text->point.index < editable->selection_start_pos) editable->selection_start_pos += length; if (text->point.index < editable->selection_end_pos) @@ -787,26 +787,26 @@ gtk_text_insert (GtkText *text, /* We'll reset the cursor later anyways if we aren't frozen */ if (text->point.index < text->cursor_mark.index) text->cursor_mark.index += length; - + move_gap_to_point (text); - + if (font == NULL) font = GTK_WIDGET (text)->style->font; - + make_forward_space (text, length); - + memcpy (text->text + text->gap_position, chars, length); - + insert_text_property (text, font, fore, back, length); - + text->gap_size -= length; text->gap_position += length; - + advance_mark_n (&text->point, length); - + if (!text->freeze && (text->line_start_cache != NULL)) insert_expose (text, old_height, length, new_line_count); - + if (frozen) gtk_text_thaw (text); } @@ -817,12 +817,12 @@ gtk_text_backward_delete (GtkText *text, { g_return_val_if_fail (text != NULL, 0); g_return_val_if_fail (GTK_IS_TEXT (text), 0); - + if (nchars > text->point.index || nchars <= 0) return FALSE; - + gtk_text_set_point (text, text->point.index - nchars); - + return gtk_text_forward_delete (text, nchars); } @@ -833,13 +833,13 @@ gtk_text_forward_delete (GtkText *text, guint old_lines, old_height; GtkEditable *editable = GTK_EDITABLE (text); gboolean frozen = FALSE; - + g_return_val_if_fail (text != NULL, 0); g_return_val_if_fail (GTK_IS_TEXT (text), 0); - + if (text->point.index + nchars > TEXT_LENGTH (text) || nchars <= 0) return FALSE; - + if (!text->freeze && (nchars > FREEZE_LENGTH)) { gtk_text_freeze (text); @@ -855,7 +855,7 @@ gtk_text_forward_delete (GtkText *text, find_line_containing_point (text, text->point.index, TRUE); compute_lines_pixels (text, nchars, &old_lines, &old_height); } - + if (text->point.index < text->first_line_start_index) { if (text->point.index + nchars >= text->first_line_start_index) @@ -869,7 +869,7 @@ gtk_text_forward_delete (GtkText *text, else text->first_line_start_index -= nchars; } - + if (text->point.index < editable->selection_start_pos) editable->selection_start_pos -= MIN(nchars, editable->selection_start_pos - text->point.index); @@ -880,31 +880,31 @@ gtk_text_forward_delete (GtkText *text, if (text->point.index < text->cursor_mark.index) move_mark_n (&text->cursor_mark, -MIN(nchars, text->cursor_mark.index - text->point.index)); - + move_gap_to_point (text); - + text->gap_size += nchars; - + delete_text_property (text, nchars); - + if (!text->freeze && (text->line_start_cache != NULL)) { delete_expose (text, nchars, old_lines, old_height); draw_cursor (text, FALSE); } - + if (frozen) gtk_text_thaw (text); - + return TRUE; } - + static void gtk_text_set_position (GtkEditable *editable, gint position) { GtkText *text = (GtkText *) editable; - + undraw_cursor (text, FALSE); text->cursor_mark = find_mark (text, position); find_cursor (text, TRUE); @@ -922,7 +922,7 @@ gtk_text_get_chars (GtkEditable *editable, gchar *retval; gchar *p; guint n, nchars; - + g_return_val_if_fail (editable != NULL, NULL); g_return_val_if_fail (GTK_IS_TEXT (editable), NULL); text = GTK_TEXT (editable); @@ -934,12 +934,12 @@ gtk_text_get_chars (GtkEditable *editable, (end_pos > TEXT_LENGTH (text)) || (end_pos < start_pos)) return NULL; - + nchars = end_pos - start_pos; retval = g_new (gchar, nchars+1); p = retval; - + if (start_pos < text->gap_position) { n = MIN (text->gap_position - start_pos, nchars); @@ -948,7 +948,7 @@ gtk_text_get_chars (GtkEditable *editable, start_pos += n; nchars -= n; } - + if (start_pos+nchars >= text->gap_position) { memcpy (p, @@ -959,7 +959,7 @@ gtk_text_get_chars (GtkEditable *editable, } *p = 0; - + return retval; } @@ -968,10 +968,10 @@ static void gtk_text_destroy (GtkObject *object) { GtkText *text; - + g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_TEXT (object)); - + text = (GtkText *)object; if (text->hadj) { @@ -988,7 +988,7 @@ gtk_text_destroy (GtkObject *object) gtk_timeout_remove (text->timer); text->timer = 0; } - + GTK_OBJECT_CLASS(parent_class)->destroy (object); } @@ -997,16 +997,16 @@ gtk_text_finalize (GtkObject *object) { GtkText *text; GList *tmp_list; - + g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_TEXT (object)); - + text = (GtkText *)object; - + /* Clean up the internal structures */ g_free (text->text); free_cache (text); - + tmp_list = text->text_properties; while (tmp_list) { @@ -1015,10 +1015,10 @@ gtk_text_finalize (GtkObject *object) } g_list_free (text->text_properties); - + if (text->scratch_buffer) g_free (text->scratch_buffer); - + g_list_free (text->tab_stops); GTK_OBJECT_CLASS(parent_class)->finalize (object); @@ -1031,14 +1031,14 @@ gtk_text_realize (GtkWidget *widget) GtkEditable *editable; GdkWindowAttr attributes; gint attributes_mask; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TEXT (widget)); - + text = GTK_TEXT (widget); editable = GTK_EDITABLE (widget); GTK_WIDGET_SET_FLAGS (text, GTK_REALIZED); - + attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; @@ -1056,38 +1056,38 @@ gtk_text_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK | GDK_KEY_PRESS_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, text); - + attributes.x = (widget->style->klass->xthickness + TEXT_BORDER_ROOM); attributes.y = (widget->style->klass->ythickness + TEXT_BORDER_ROOM); attributes.width = widget->allocation.width - attributes.x * 2; attributes.height = widget->allocation.height - attributes.y * 2; - + text->text_area = gdk_window_new (widget->window, &attributes, attributes_mask); gdk_window_set_user_data (text->text_area, text); - + widget->style = gtk_style_attach (widget->style, widget->window); - + /* Can't call gtk_style_set_background here because it's handled specially */ gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]); gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]); - + text->line_wrap_bitmap = gdk_bitmap_create_from_data (text->text_area, (gchar*) line_wrap_bits, line_wrap_width, line_wrap_height); - + text->line_arrow_bitmap = gdk_bitmap_create_from_data (text->text_area, (gchar*) line_arrow_bits, line_arrow_width, line_arrow_height); - + text->gc = gdk_gc_new (text->text_area); gdk_gc_set_exposures (text->gc, TRUE); gdk_gc_set_foreground (text->gc, &widget->style->text[GTK_STATE_NORMAL]); - + #ifdef USE_XIM if (gdk_im_ready ()) { @@ -1097,12 +1097,12 @@ gtk_text_realize (GtkWidget *widget) GdkEventMask mask; GdkIMStyle style; GdkIMStyle supported_style = GdkIMPreeditNone | GdkIMPreeditNothing | - GdkIMPreeditPosition | - GdkIMStatusNone | GdkIMStatusNothing; - + GdkIMPreeditPosition | + GdkIMStatusNone | GdkIMStatusNothing; + if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) supported_style &= ~GdkIMPreeditPosition; - + style = gdk_im_decide_style (supported_style); switch (style & GdkIMPreeditMask) { @@ -1121,29 +1121,29 @@ gtk_text_realize (GtkWidget *widget) spot.y = height; editable->ic = gdk_ic_new (text->text_area, text->text_area, - style, - "spotLocation", &spot, - "area", &rect, - "fontSet", GDK_FONT_XFONT (widget->style->font), - NULL); + style, + "spotLocation", &spot, + "area", &rect, + "fontSet", GDK_FONT_XFONT (widget->style->font), + NULL); break; default: editable->ic = gdk_ic_new (text->text_area, text->text_area, - style, NULL); + style, NULL); } - + if (editable->ic == NULL) g_warning ("Can't create input context."); else { GdkColormap *colormap; - + mask = gdk_window_get_events (text->text_area); mask |= gdk_ic_get_events (editable->ic); gdk_window_set_events (text->text_area, mask); - + if ((colormap = gtk_widget_get_colormap (widget)) != - gtk_widget_get_default_colormap ()) + gtk_widget_get_default_colormap ()) { gdk_ic_set_attr (editable->ic, "preeditAttributes", "colorMap", GDK_COLORMAP_XCOLORMAP (colormap), @@ -1152,14 +1152,14 @@ gtk_text_realize (GtkWidget *widget) } } #endif - + init_properties (text); - + gdk_window_show (text->text_area); - + if (editable->selection_start_pos != editable->selection_end_pos) gtk_editable_claim_selection (editable, TRUE, GDK_CURRENT_TIME); - + if ((widget->allocation.width > 1) || (widget->allocation.height > 1)) recompute_geometry (text); } @@ -1169,20 +1169,20 @@ gtk_text_style_set (GtkWidget *widget, GtkStyle *previous_style) { GtkText *text; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TEXT (widget)); - + text = GTK_TEXT (widget); if (GTK_WIDGET_REALIZED (widget)) { gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]); gdk_window_set_background (text->text_area, &widget->style->base[GTK_STATE_NORMAL]); - + if ((widget->allocation.width > 1) || (widget->allocation.height > 1)) recompute_geometry (text); } - + if (GTK_WIDGET_DRAWABLE (widget)) gdk_window_clear (widget->window); } @@ -1191,22 +1191,22 @@ static void gtk_text_unrealize (GtkWidget *widget) { GtkText *text; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TEXT (widget)); - + text = GTK_TEXT (widget); - + gdk_window_set_user_data (text->text_area, NULL); gdk_window_destroy (text->text_area); text->text_area = NULL; - + gdk_gc_destroy (text->gc); text->gc = NULL; - + gdk_pixmap_unref (text->line_wrap_bitmap); gdk_pixmap_unref (text->line_arrow_bitmap); - + if (GTK_WIDGET_CLASS (parent_class)->unrealize) (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); } @@ -1218,32 +1218,32 @@ clear_focus_area (GtkText *text, gint area_x, gint area_y, gint area_width, gint gint ythick = TEXT_BORDER_ROOM + widget->style->klass->ythickness; gint xthick = TEXT_BORDER_ROOM + widget->style->klass->xthickness; - + gint width, height; gint xorig, yorig; gint x, y; - + gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height); - + yorig = - text->first_onscreen_ver_pixel + ythick; xorig = - text->first_onscreen_hor_pixel + xthick; - + while (yorig > 0) yorig -= height; - + while (xorig > 0) xorig -= width; - + for (y = area_y; y < area_y + area_height; ) { gint yoff = (y - yorig) % height; gint yw = MIN(height - yoff, (area_y + area_height) - y); - + for (x = area_x; x < area_x + area_width; ) { gint xoff = (x - xorig) % width; gint xw = MIN(width - xoff, (area_x + area_width) - x); - + gdk_draw_pixmap (widget->window, text->gc, widget->style->bg_pixmap[GTK_STATE_NORMAL], @@ -1253,7 +1253,7 @@ clear_focus_area (GtkText *text, gint area_x, gint area_y, gint area_width, gint y, xw, yw); - + x += width - xoff; } y += height - yoff; @@ -1268,26 +1268,26 @@ gtk_text_draw_focus (GtkWidget *widget) GtkText *text; gint width, height; gint x, y; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TEXT (widget)); - + text = GTK_TEXT (widget); - + if (GTK_WIDGET_DRAWABLE (widget)) { gint ythick = widget->style->klass->ythickness; gint xthick = widget->style->klass->xthickness; gint xextra = TEXT_BORDER_ROOM; gint yextra = TEXT_BORDER_ROOM; - + TDEBUG (("in gtk_text_draw_focus\n")); - + x = 0; y = 0; width = widget->allocation.width; height = widget->allocation.height; - + if (GTK_WIDGET_HAS_FOCUS (widget)) { x += 1; @@ -1296,23 +1296,23 @@ gtk_text_draw_focus (GtkWidget *widget) height -= 2; xextra -= 1; yextra -= 1; - + gdk_draw_rectangle (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], FALSE, 0, 0, widget->allocation.width - 1, widget->allocation.height - 1); } - + gtk_draw_shadow (widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN, x, y, width, height); - + x += xthick; y += ythick; width -= 2 * xthick; height -= 2 * ythick; - + if (widget->style->bg_pixmap[GTK_STATE_NORMAL]) { /* top rect */ @@ -1349,22 +1349,22 @@ gtk_text_size_request (GtkWidget *widget, gint ythickness; gint char_height; gint char_width; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TEXT (widget)); g_return_if_fail (requisition != NULL); - + xthickness = widget->style->klass->xthickness + TEXT_BORDER_ROOM; ythickness = widget->style->klass->ythickness + TEXT_BORDER_ROOM; - + char_height = MIN_TEXT_HEIGHT_LINES * (widget->style->font->ascent + widget->style->font->descent); - + char_width = MIN_TEXT_WIDTH_LINES * (gdk_text_width (widget->style->font, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 26) / 26); - + requisition->width = char_width + xthickness * 2; requisition->height = char_height + ythickness * 2; } @@ -1375,21 +1375,21 @@ gtk_text_size_allocate (GtkWidget *widget, { GtkText *text; GtkEditable *editable; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TEXT (widget)); g_return_if_fail (allocation != NULL); - + text = GTK_TEXT (widget); editable = GTK_EDITABLE (widget); - + widget->allocation = *allocation; if (GTK_WIDGET_REALIZED (widget)) { gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height); - + gdk_window_move_resize (text->text_area, widget->style->klass->xthickness + TEXT_BORDER_ROOM, widget->style->klass->ythickness + TEXT_BORDER_ROOM, @@ -1397,13 +1397,13 @@ gtk_text_size_allocate (GtkWidget *widget, TEXT_BORDER_ROOM) * 2, widget->allocation.height - (widget->style->klass->ythickness + TEXT_BORDER_ROOM) * 2); - + #ifdef USE_XIM if (editable->ic && (gdk_ic_get_style (editable->ic) & GdkIMPreeditPosition)) { gint width, height; GdkRectangle rect; - + gdk_window_get_size (text->text_area, &width, &height); rect.x = 0; rect.y = 0; @@ -1412,7 +1412,7 @@ gtk_text_size_allocate (GtkWidget *widget, gdk_ic_set_attr (editable->ic, "preeditAttributes", "area", &rect, NULL); } #endif - + recompute_geometry (text); } } @@ -1424,7 +1424,7 @@ gtk_text_draw (GtkWidget *widget, g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TEXT (widget)); g_return_if_fail (area != NULL); - + if (GTK_WIDGET_DRAWABLE (widget)) { expose_text (GTK_TEXT (widget), area, TRUE); @@ -1439,7 +1439,7 @@ gtk_text_expose (GtkWidget *widget, g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + if (event->window == GTK_TEXT (widget)->text_area) { TDEBUG (("in gtk_text_expose (expose)\n")); @@ -1450,7 +1450,7 @@ gtk_text_expose (GtkWidget *widget, TDEBUG (("in gtk_text_expose (focus)\n")); gtk_widget_draw_focus (widget); } - + return FALSE; } @@ -1459,27 +1459,27 @@ gtk_text_scroll_timeout (gpointer data) { GtkText *text; GdkEventMotion event; - + gint x, y; GdkModifierType mask; - + g_return_val_if_fail (GTK_IS_TEXT (data), FALSE); - + text = GTK_TEXT (data); - + text->timer = 0; gdk_window_get_pointer (text->text_area, &x, &y, &mask); - + if (!(mask & (GDK_BUTTON1_MASK | GDK_BUTTON3_MASK))) return FALSE; - + event.is_hint = 0; event.x = x; event.y = y; event.state = mask; - + gtk_text_motion_notify (GTK_WIDGET (text), &event); - + return FALSE; } @@ -1490,36 +1490,36 @@ gtk_text_button_press (GtkWidget *widget, GtkText *text; GtkEditable *editable; static GdkAtom ctext_atom = GDK_NONE; - + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + if (ctext_atom == GDK_NONE) ctext_atom = gdk_atom_intern ("COMPOUND_TEXT", FALSE); - + text = GTK_TEXT (widget); editable = GTK_EDITABLE (widget); - + if (text->button && (event->button != text->button)) return FALSE; - + text->button = event->button; if (!GTK_WIDGET_HAS_FOCUS (widget)) gtk_widget_grab_focus (widget); - + if (event->button == 1) { switch (event->type) { case GDK_BUTTON_PRESS: gtk_grab_add (widget); - + undraw_cursor (text, FALSE); find_mouse_cursor (text, (gint)event->x, (gint)event->y); draw_cursor (text, FALSE); - + /* Set it now, so we display things right. We'll unset it * later if things don't work out */ editable->has_selection = TRUE; @@ -1528,15 +1528,15 @@ gtk_text_button_press (GtkWidget *widget, text->cursor_mark.index); break; - + case GDK_2BUTTON_PRESS: gtk_text_select_word (text, event->time); break; - + case GDK_3BUTTON_PRESS: gtk_text_select_line (text, event->time); break; - + default: break; } @@ -1551,7 +1551,7 @@ gtk_text_button_press (GtkWidget *widget, undraw_cursor (text, FALSE); find_mouse_cursor (text, (gint)event->x, (gint)event->y); draw_cursor (text, FALSE); - + } gtk_selection_convert (widget, GDK_SELECTION_PRIMARY, @@ -1560,21 +1560,21 @@ gtk_text_button_press (GtkWidget *widget, else { gtk_grab_add (widget); - + undraw_cursor (text, FALSE); find_mouse_cursor (text, event->x, event->y); draw_cursor (text, FALSE); - + gtk_text_set_selection (GTK_EDITABLE(text), text->cursor_mark.index, text->cursor_mark.index); - + editable->has_selection = FALSE; if (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) == widget->window) gtk_selection_owner_set (NULL, GDK_SELECTION_PRIMARY, event->time); } } - + return FALSE; } @@ -1587,29 +1587,29 @@ gtk_text_button_release (GtkWidget *widget, g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + text = GTK_TEXT (widget); - + gtk_grab_remove (widget); - + if (text->button != event->button) return FALSE; - + text->button = 0; - + if (text->timer) { gtk_timeout_remove (text->timer); text->timer = 0; } - + if (event->button == 1) { text = GTK_TEXT (widget); editable = GTK_EDITABLE (widget); - + gtk_grab_remove (widget); - + editable->has_selection = FALSE; if (editable->selection_start_pos != editable->selection_end_pos) { @@ -1631,11 +1631,11 @@ gtk_text_button_release (GtkWidget *widget, { gtk_grab_remove (widget); } - + undraw_cursor (text, FALSE); find_cursor (text, TRUE); draw_cursor (text, FALSE); - + return FALSE; } @@ -1647,13 +1647,13 @@ gtk_text_motion_notify (GtkWidget *widget, gint x, y; gint height; GdkModifierType mask; - + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + text = GTK_TEXT (widget); - + x = event->x; y = event->y; mask = event->state; @@ -1661,13 +1661,13 @@ gtk_text_motion_notify (GtkWidget *widget, { gdk_window_get_pointer (text->text_area, &x, &y, &mask); } - + if ((text->button == 0) || !(mask & (GDK_BUTTON1_MASK | GDK_BUTTON3_MASK))) return FALSE; - + gdk_window_get_size (text->text_area, NULL, &height); - + if ((y < 0) || (y > height)) { if (text->timer == 0) @@ -1675,7 +1675,7 @@ gtk_text_motion_notify (GtkWidget *widget, text->timer = gtk_timeout_add (SCROLL_TIME, gtk_text_scroll_timeout, text); - + if (y < 0) scroll_int (text, y/2); else @@ -1684,15 +1684,15 @@ gtk_text_motion_notify (GtkWidget *widget, else return FALSE; } - + undraw_cursor (GTK_TEXT (widget), FALSE); find_mouse_cursor (GTK_TEXT (widget), x, y); draw_cursor (GTK_TEXT (widget), FALSE); - + gtk_text_set_selection (GTK_EDITABLE(text), GTK_EDITABLE(text)->selection_start_pos, text->cursor_mark.index); - + return FALSE; } @@ -1722,7 +1722,7 @@ gtk_text_delete_text (GtkEditable *editable, GtkText *text; g_return_if_fail (start_pos >= 0); - + text = GTK_TEXT (editable); gtk_text_set_point (text, start_pos); @@ -1742,19 +1742,19 @@ gtk_text_key_press (GtkWidget *widget, gchar key; gint return_val; gint position; - + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + return_val = FALSE; - + text = GTK_TEXT (widget); editable = GTK_EDITABLE (widget); - + key = event->keyval; return_val = TRUE; - + if ((GTK_EDITABLE(text)->editable == FALSE)) { switch (event->keyval) @@ -1785,12 +1785,12 @@ gtk_text_key_press (GtkWidget *widget, gint extend_selection; gint extend_start; guint initial_pos = editable->current_pos; - + text->point = find_mark (text, text->cursor_mark.index); - + extend_selection = event->state & GDK_SHIFT_MASK; extend_start = FALSE; - + if (extend_selection) { editable->has_selection = TRUE; @@ -1835,7 +1835,7 @@ gtk_text_key_press (GtkWidget *widget, else move_cursor_hor (text, +1); break; - + case GDK_BackSpace: if (event->state & GDK_CONTROL_MASK) gtk_text_delete_backward_word (text); @@ -1888,10 +1888,10 @@ gtk_text_key_press (GtkWidget *widget, /* Don't insert literally */ return_val = FALSE; break; - + default: return_val = FALSE; - + if (event->state & GDK_CONTROL_MASK) { if ((key >= 'A') && (key <= 'Z')) @@ -1902,7 +1902,7 @@ gtk_text_key_press (GtkWidget *widget, (* control_keys[(int) (key - 'a')]) (editable, event->time); return_val = TRUE; } - + break; } else if (event->state & GDK_MOD1_MASK) @@ -1915,26 +1915,26 @@ gtk_text_key_press (GtkWidget *widget, (* alt_keys[(int) (key - 'a')]) (editable, event->time); return_val = TRUE; } - + break; } else if (event->length > 0) { extend_selection = FALSE; - + if (event->length == 1) { gtk_editable_delete_selection (editable); position = text->point.index; gtk_editable_insert_text (editable, &(event->string[0]), 1, &position); } - + return_val = TRUE; } else return_val = FALSE; } - + if (return_val && (editable->current_pos != initial_pos)) { if (extend_selection) @@ -1963,7 +1963,7 @@ gtk_text_key_press (GtkWidget *widget, event->time); } } - + return return_val; } @@ -1974,19 +1974,19 @@ gtk_text_focus_in (GtkWidget *widget, g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + TDEBUG (("in gtk_text_focus_in\n")); - + GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); gtk_widget_draw_focus (widget); - + #ifdef USE_XIM if (GTK_EDITABLE(widget)->ic) gdk_im_begin (GTK_EDITABLE(widget)->ic, GTK_TEXT(widget)->text_area); #endif - + draw_cursor (GTK_TEXT(widget), TRUE); - + return FALSE; } @@ -1997,18 +1997,18 @@ gtk_text_focus_out (GtkWidget *widget, g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + TDEBUG (("in gtk_text_focus_out\n")); - + GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); gtk_widget_draw_focus (widget); - + undraw_cursor (GTK_TEXT(widget), TRUE); - + #ifdef USE_XIM gdk_im_end (); #endif - + return FALSE; } @@ -2020,14 +2020,14 @@ gtk_text_adjustment (GtkAdjustment *adjustment, g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + /* Just ignore it if we haven't been size-allocated yet, or * if something weird has happened */ if ((text->line_start_cache == NULL) || (GTK_WIDGET (text)->allocation.height <= 1) || (GTK_WIDGET (text)->allocation.width <= 1)) return; - + if (adjustment == text->hadj) { g_warning ("horizontal scrolling not implemented"); @@ -2035,18 +2035,18 @@ gtk_text_adjustment (GtkAdjustment *adjustment, else { gint diff = ((gint)adjustment->value) - text->last_ver_value; - + if (diff != 0) { undraw_cursor (text, FALSE); - + if (diff > 0) scroll_down (text, diff); else /* if (diff < 0) */ scroll_up (text, diff); - + draw_cursor (text, FALSE); - + text->last_ver_value = adjustment->value; } } @@ -2060,7 +2060,7 @@ gtk_text_disconnect (GtkAdjustment *adjustment, g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); g_return_if_fail (text != NULL); g_return_if_fail (GTK_IS_TEXT (text)); - + if (adjustment == text->hadj) text->hadj = NULL; if (adjustment == text->vadj) @@ -2072,13 +2072,13 @@ static GtkPropertyMark find_this_line_start_mark (GtkText* text, guint point_position, const GtkPropertyMark* near) { GtkPropertyMark mark; - + mark = find_mark_near (text, point_position, near); - + while (mark.index > 0 && GTK_TEXT_INDEX (text, mark.index - 1) != LINE_DELIM) decrement_mark (&mark); - + return mark; } @@ -2088,7 +2088,7 @@ init_tab_cont (GtkText* text, PrevTabCont* tab_cont) tab_cont->pixel_offset = 0; tab_cont->tab_start.tab_stops = text->tab_stops; tab_cont->tab_start.to_next_tab = (gulong) text->tab_stops->data; - + if (!tab_cont->tab_start.to_next_tab) tab_cont->tab_start.to_next_tab = text->default_tab_width; } @@ -2100,37 +2100,37 @@ line_params_iterate (GtkText* text, gint8 alloc, void* data, LineIteratorFunction iter) - /* mark0 MUST be a real line start. if ALLOC, allocate line params - * from a mem chunk. DATA is passed to ITER_CALL, which is called - * for each line following MARK, iteration continues unless ITER_CALL - * returns TRUE. */ + /* mark0 MUST be a real line start. if ALLOC, allocate line params + * from a mem chunk. DATA is passed to ITER_CALL, which is called + * for each line following MARK, iteration continues unless ITER_CALL + * returns TRUE. */ { GtkPropertyMark mark = *mark0; PrevTabCont tab_conts[2]; LineParams *lp, lpbuf; gint tab_cont_index = 0; - + if (tab_mark0) tab_conts[0] = *tab_mark0; else init_tab_cont (text, tab_conts); - + for (;;) { if (alloc) lp = g_chunk_new (LineParams, params_mem_chunk); else lp = &lpbuf; - + *lp = find_line_params (text, &mark, tab_conts + tab_cont_index, tab_conts + (tab_cont_index + 1) % 2); - + if ((*iter) (text, lp, data)) return; - + if (LAST_INDEX (text, lp->end)) break; - + mark = lp->end; advance_mark (&mark); tab_cont_index = (tab_cont_index + 1) % 2; @@ -2141,29 +2141,29 @@ static gint fetch_lines_iterator (GtkText* text, LineParams* lp, void* data) { FetchLinesData *fldata = (FetchLinesData*) data; - + fldata->new_lines = g_list_prepend (fldata->new_lines, lp); - + switch (fldata->fl_type) { case FetchLinesCount: if (!text->line_wrap || !lp->wraps) fldata->data += 1; - + if (fldata->data >= fldata->data_max) return TRUE; - + break; case FetchLinesPixels: - + fldata->data += LINE_HEIGHT(*lp); - + if (fldata->data >= fldata->data_max) return TRUE; - + break; } - + return FALSE; } @@ -2175,14 +2175,14 @@ fetch_lines (GtkText* text, gint data) { FetchLinesData fl_data; - + fl_data.new_lines = NULL; fl_data.data = 0; fl_data.data_max = data; fl_data.fl_type = fl_type; - + line_params_iterate (text, mark0, tab_cont0, TRUE, &fl_data, fetch_lines_iterator); - + return g_list_reverse (fl_data.new_lines); } @@ -2191,19 +2191,19 @@ fetch_lines_backward (GtkText* text) { GList* new_lines = NULL, *new_line_start; GtkPropertyMark mark; - + if (CACHE_DATA(text->line_start_cache).start.index == 0) return; - + mark = find_this_line_start_mark (text, CACHE_DATA(text->line_start_cache).start.index - 1, &CACHE_DATA(text->line_start_cache).start); - + new_line_start = new_lines = fetch_lines (text, &mark, NULL, FetchLinesCount, 1); - + while (new_line_start->next) new_line_start = new_line_start->next; - + new_line_start->next = text->line_start_cache; text->line_start_cache->prev = new_line_start; } @@ -2213,19 +2213,19 @@ fetch_lines_forward (GtkText* text, gint line_count) { GtkPropertyMark mark; GList* line = text->line_start_cache; - + while(line->next) line = line->next; - + mark = CACHE_DATA(line).end; - + if (LAST_INDEX (text, mark)) return; - + advance_mark(&mark); - + line->next = fetch_lines (text, &mark, &CACHE_DATA(line).tab_cont_next, FetchLinesCount, line_count); - + if (line->next) line->next->prev = line; } @@ -2239,28 +2239,28 @@ compute_lines_pixels (GtkText* text, guint char_count, { GList *line = text->current_line; gint chars_left = char_count; - + *lines = 0; *pixels = 0; - + /* If chars_left == 0, that means we're joining two lines in a * deletion, so add in the values for the next line as well */ for (; line && chars_left >= 0; line = line->next) { *pixels += LINE_HEIGHT(CACHE_DATA(line)); - + if (line == text->current_line) chars_left -= CACHE_DATA(line).end.index - text->point.index + 1; else chars_left -= CACHE_DATA(line).end.index - CACHE_DATA(line).start.index + 1; - + if (!text->line_wrap || !CACHE_DATA(line).wraps) *lines += 1; else if (chars_left < 0) chars_left = 0; /* force another loop */ - + if (!line->next) fetch_lines_forward (text, 1); } @@ -2270,18 +2270,18 @@ static gint total_line_height (GtkText* text, GList* line, gint line_count) { gint height = 0; - + for (; line && line_count > 0; line = line->next) { height += LINE_HEIGHT(CACHE_DATA(line)); - + if (!text->line_wrap || !CACHE_DATA(line).wraps) line_count -= 1; - + if (!line->next) fetch_lines_forward (text, line_count); } - + return height; } @@ -2291,49 +2291,49 @@ swap_lines (GtkText* text, GList* old, GList* new, guint old_line_count) if (old == text->line_start_cache) { GList* last; - + for (; old_line_count > 0; old_line_count -= 1) { while (text->line_start_cache && text->line_wrap && CACHE_DATA(text->line_start_cache).wraps) remove_cache_line(text, text->line_start_cache); - + remove_cache_line(text, text->line_start_cache); } - + last = g_list_last (new); - + last->next = text->line_start_cache; - + if (text->line_start_cache) text->line_start_cache->prev = last; - + text->line_start_cache = new; } else { GList *last; - + g_assert (old->prev); - + last = old->prev; - + for (; old_line_count > 0; old_line_count -= 1) { while (old && text->line_wrap && CACHE_DATA(old).wraps) old = remove_cache_line (text, old); - + old = remove_cache_line (text, old); } - + last->next = new; new->prev = last; - + last = g_list_last (new); - + last->next = old; - + if (old) old->prev = last; } @@ -2344,30 +2344,30 @@ correct_cache_delete (GtkText* text, gint nchars, gint lines) { GList* cache = text->current_line; gint i; - + for (i = 0; cache && i < lines; i += 1, cache = cache->next) /* nothing */; - + for (; cache; cache = cache->next) { GtkPropertyMark *start = &CACHE_DATA(cache).start; GtkPropertyMark *end = &CACHE_DATA(cache).end; - + start->index -= nchars; end->index -= nchars; - + if (LAST_INDEX (text, text->point) && start->index == text->point.index) *start = text->point; else if (start->property == text->point.property) start->offset = start->index - (text->point.index - text->point.offset); - + if (LAST_INDEX (text, text->point) && end->index == text->point.index) *end = text->point; if (end->property == text->point.property) end->offset = end->index - (text->point.index - text->point.offset); - + /*TEXT_ASSERT_MARK(text, start, "start");*/ /*TEXT_ASSERT_MARK(text, end, "end");*/ } @@ -2377,37 +2377,37 @@ static void delete_expose (GtkText* text, guint nchars, guint old_lines, guint old_pixels) { GtkWidget *widget = GTK_WIDGET (text); - + gint pixel_height; guint new_pixels = 0; GdkRectangle rect; GList* new_line = NULL; gint width, height; - + text->cursor_virtual_x = 0; - + correct_cache_delete (text, nchars, old_lines); - + pixel_height = pixel_height_of(text, text->current_line) - - LINE_HEIGHT(CACHE_DATA(text->current_line)); - + LINE_HEIGHT(CACHE_DATA(text->current_line)); + if (CACHE_DATA(text->current_line).start.index == text->point.index) CACHE_DATA(text->current_line).start = text->point; - + new_line = fetch_lines (text, &CACHE_DATA(text->current_line).start, &CACHE_DATA(text->current_line).tab_cont, FetchLinesCount, 1); - + swap_lines (text, text->current_line, new_line, old_lines); - + text->current_line = new_line; - + new_pixels = total_line_height (text, new_line, 1); - + gdk_window_get_size (text->text_area, &width, &height); - + if (old_pixels != new_pixels) { if (!widget->style->bg_pixmap[GTK_STATE_NORMAL]) @@ -2426,19 +2426,19 @@ delete_expose (GtkText* text, guint nchars, guint old_lines, guint old_pixels) text->vadj->upper -= old_pixels; adjust_adj (text, text->vadj); } - + rect.x = 0; rect.y = pixel_height; rect.width = width; rect.height = new_pixels; - + expose_text (text, &rect, FALSE); gtk_text_draw_focus ( (GtkWidget *) text); - + text->cursor_mark = text->point; - + find_cursor (text, TRUE); - + if (old_pixels != new_pixels) { if (widget->style->bg_pixmap[GTK_STATE_NORMAL]) @@ -2466,7 +2466,7 @@ correct_cache_insert (GtkText* text, gint nchars) GtkPropertyMark *start; GtkPropertyMark *end; gboolean was_split = FALSE; - + /* We need to distinguish whether the property was split in the * insert or not, so we check if the point (which points after * the insertion here), points to the same character as the @@ -2476,7 +2476,7 @@ correct_cache_insert (GtkText* text, gint nchars) { GtkPropertyMark tmp_mark = text->point; move_mark_n (&tmp_mark, -1); - + if (tmp_mark.property != text->point.property) was_split = TRUE; } @@ -2488,7 +2488,7 @@ correct_cache_insert (GtkText* text, gint nchars) * This also handles the case when we split exactly * at the beginning and start->offset is now invalid */ - + start = &CACHE_DATA(text->current_line).start; if (was_split) { @@ -2500,7 +2500,7 @@ correct_cache_insert (GtkText* text, gint nchars) (start->index == text->point.index - nchars)) SET_PROPERTY_MARK (start, start->property->prev, 0); } - + /* Now correct the offsets, and check for start or end marks that * are after the point, yet point to a property before the point's * property. This indicates that they are meant to point to the @@ -2508,12 +2508,12 @@ correct_cache_insert (GtkText* text, gint nchars) * we fix them up that way. */ cache = text->current_line->next; - + for (; cache; cache = cache->next) { start = &CACHE_DATA(cache).start; end = &CACHE_DATA(cache).end; - + if (LAST_INDEX (text, text->point) && start->index == text->point.index) *start = text->point; @@ -2533,7 +2533,7 @@ correct_cache_insert (GtkText* text, gint nchars) start->index += nchars; } } - + if (LAST_INDEX (text, text->point) && end->index == text->point.index) *end = text->point; @@ -2553,7 +2553,7 @@ correct_cache_insert (GtkText* text, gint nchars) end->index += nchars; } } - + /*TEXT_ASSERT_MARK(text, start, "start");*/ /*TEXT_ASSERT_MARK(text, end, "end");*/ } @@ -2565,38 +2565,38 @@ insert_expose (GtkText* text, guint old_pixels, gint nchars, guint new_line_count) { GtkWidget *widget = GTK_WIDGET (text); - + gint pixel_height; guint new_pixels = 0; GdkRectangle rect; GList* new_lines = NULL; gint width, height; - + text->cursor_virtual_x = 0; - + undraw_cursor (text, FALSE); - + correct_cache_insert (text, nchars); - + TEXT_SHOW_ADJ (text, text->vadj, "vadj"); - + pixel_height = pixel_height_of(text, text->current_line) - - LINE_HEIGHT(CACHE_DATA(text->current_line)); - + LINE_HEIGHT(CACHE_DATA(text->current_line)); + new_lines = fetch_lines (text, &CACHE_DATA(text->current_line).start, &CACHE_DATA(text->current_line).tab_cont, FetchLinesCount, new_line_count); - + swap_lines (text, text->current_line, new_lines, 1); - + text->current_line = new_lines; - + new_pixels = total_line_height (text, new_lines, new_line_count); - + gdk_window_get_size (text->text_area, &width, &height); - + if (old_pixels != new_pixels) { if (!widget->style->bg_pixmap[GTK_STATE_NORMAL]) @@ -2610,13 +2610,13 @@ insert_expose (GtkText* text, guint old_pixels, gint nchars, pixel_height + new_pixels, width, height + (old_pixels - new_pixels) - pixel_height); - + } text->vadj->upper += new_pixels; text->vadj->upper -= old_pixels; adjust_adj (text, text->vadj); } - + rect.x = 0; rect.y = pixel_height; rect.width = width; @@ -2624,13 +2624,13 @@ insert_expose (GtkText* text, guint old_pixels, gint nchars, expose_text (text, &rect, FALSE); gtk_text_draw_focus ( (GtkWidget *) text); - + text->cursor_mark = text->point; - + find_cursor (text, TRUE); draw_cursor (text, FALSE); - + if (old_pixels != new_pixels) { if (widget->style->bg_pixmap[GTK_STATE_NORMAL]) @@ -2645,7 +2645,7 @@ insert_expose (GtkText* text, guint old_pixels, gint nchars, else process_exposes (text); } - + TEXT_SHOW_ADJ (text, text->vadj, "vadj"); TEXT_ASSERT (text); TEXT_SHOW(text); @@ -2664,24 +2664,24 @@ get_text_font (GdkFont* gfont) TextFont* tf; gpointer lu; gint i; - + if (!font_cache_table) font_cache_table = g_hash_table_new (font_hash, (GCompareFunc) gdk_font_equal); - + lu = g_hash_table_lookup (font_cache_table, gfont); - + if (lu) return (TextFont*)lu; - + tf = g_new (TextFont, 1); - + tf->gdk_font = gfont; - + for(i = 0; i < 256; i += 1) tf->char_widths[i] = gdk_char_width (gfont, (char)i); - + g_hash_table_insert (font_cache_table, gfont, tf); - + return tf; } @@ -2697,7 +2697,7 @@ static TextProperty* new_text_property (GdkFont* font, GdkColor* fore, GdkColor* back, guint length) { TextProperty *prop; - + if (text_property_chunk == NULL) { text_property_chunk = g_mem_chunk_new ("text property mem chunk", @@ -2705,15 +2705,15 @@ new_text_property (GdkFont* font, GdkColor* fore, GdkColor* back, guint length) 1024*sizeof(TextProperty), G_ALLOC_AND_FREE); } - + prop = g_chunk_new(TextProperty, text_property_chunk); - + prop->font = get_text_font (font); prop->fore_color = *fore; if (back) prop->back_color = *back; prop->length = length; - + return prop; } @@ -2725,21 +2725,21 @@ move_gap_to_point (GtkText* text) if (text->gap_position < text->point.index) { gint diff = text->point.index - text->gap_position; - + g_memmove (text->text + text->gap_position, text->text + text->gap_position + text->gap_size, diff); - + text->gap_position = text->point.index; } else if (text->gap_position > text->point.index) { gint diff = text->gap_position - text->point.index; - + g_memmove (text->text + text->point.index + text->gap_size, text->text + text->point.index, diff); - + text->gap_position = text->point.index; } } @@ -2751,20 +2751,20 @@ make_forward_space (GtkText* text, guint len) if (text->gap_size < len) { guint sum = MAX(2*len, MIN_GAP_SIZE) + text->text_end; - + if (sum >= text->text_len) { guint i = 1; - + while (i <= sum) i <<= 1; - + text->text = (guchar*)g_realloc(text->text, i); } - + g_memmove (text->text + text->gap_position + text->gap_size + 2*len, text->text + text->gap_position + text->gap_size, text->text_end - (text->gap_position + text->gap_size)); - + text->text_end += len*2; text->gap_size += len*2; } @@ -2782,17 +2782,17 @@ insert_text_property (GtkText* text, GdkFont* font, GtkPropertyMark *mark = &text->point; TextProperty* forward_prop = MARK_CURRENT_PROPERTY(mark); TextProperty* backward_prop = MARK_PREV_PROPERTY(mark); - + if (MARK_OFFSET(mark) == 0) { /* Point is on the boundary of two properties. * If it is the same as either, grow, else insert * a new one. */ - + if (text_properties_equal(forward_prop, font, fore, back)) { /* Grow the property in front of us. */ - + MARK_PROPERTY_LENGTH(mark) += len; } else if (backward_prop && @@ -2800,11 +2800,11 @@ insert_text_property (GtkText* text, GdkFont* font, { /* Grow property behind us, point property and offset * change. */ - + SET_PROPERTY_MARK (&text->point, MARK_PREV_LIST_PTR (mark), backward_prop->length); - + backward_prop->length += len; } else if ((MARK_NEXT_LIST_PTR(mark) == NULL) && @@ -2819,18 +2819,18 @@ insert_text_property (GtkText* text, GdkFont* font, else { /* Splice a new property into the list. */ - + GList* new_prop = g_list_alloc(); - + new_prop->next = MARK_LIST_PTR(mark); new_prop->prev = MARK_PREV_LIST_PTR(mark); new_prop->next->prev = new_prop; - + if (new_prop->prev) new_prop->prev->next = new_prop; - + new_prop->data = new_text_property (font, fore, back, len); - + SET_PROPERTY_MARK (mark, new_prop, 0); } } @@ -2860,7 +2860,7 @@ insert_text_property (GtkText* text, GdkFont* font, new_prop->prev = MARK_LIST_PTR(mark); new_prop->next = NULL; MARK_NEXT_LIST_PTR(mark) = new_prop; - + SET_PROPERTY_MARK (mark, new_prop, 0); } else @@ -2869,37 +2869,37 @@ insert_text_property (GtkText* text, GdkFont* font, GList* new_prop_forward = g_list_alloc(); gint old_length = forward_prop->length; GList* next = MARK_NEXT_LIST_PTR(mark); - + /* Set the new lengths according to where they are split. Construct * two new properties. */ forward_prop->length = MARK_OFFSET(mark); - + new_prop_forward->data = new_text_property(forward_prop->font->gdk_font, &forward_prop->fore_color, &forward_prop->back_color, old_length - forward_prop->length); - + new_prop->data = new_text_property(font, fore, back, len); - + /* Now splice things in. */ MARK_NEXT_LIST_PTR(mark) = new_prop; new_prop->prev = MARK_LIST_PTR(mark); - + new_prop->next = new_prop_forward; new_prop_forward->prev = new_prop; - + new_prop_forward->next = next; - + if (next) next->prev = new_prop_forward; - + SET_PROPERTY_MARK (mark, new_prop, 0); } } - + while (text->text_properties_end->next) text->text_properties_end = text->text_properties_end->next; - + while (text->text_properties->prev) text->text_properties = text->text_properties->prev; } @@ -2908,7 +2908,7 @@ static void delete_text_property (GtkText* text, guint nchars) { /* Delete nchars forward from point. */ - + /* Deleting text properties is problematical, because we * might be storing around marks pointing to a property. * @@ -2925,34 +2925,34 @@ delete_text_property (GtkText* text, guint nchars) * of a line) we fix it up by setting it equal to the * point. */ - + TextProperty *prop; GList *tmp; gint is_first; - + for(; nchars; nchars -= 1) { prop = MARK_CURRENT_PROPERTY(&text->point); - + prop->length -= 1; - + if (prop->length == 0) { tmp = MARK_LIST_PTR (&text->point); - + is_first = tmp == text->text_properties; - + MARK_LIST_PTR (&text->point) = g_list_remove_link (tmp, tmp); text->point.offset = 0; - + g_mem_chunk_free (text_property_chunk, prop); g_list_free_1 (tmp); - + prop = MARK_CURRENT_PROPERTY (&text->point); - + if (is_first) text->text_properties = MARK_LIST_PTR (&text->point); - + g_assert (prop->length != 0); } else if (prop->length == text->point.offset) @@ -2961,7 +2961,7 @@ delete_text_property (GtkText* text, guint nchars) text->point.offset = 0; } } - + /* Check to see if we have just the single final position remaining * along in a property; if so, combine it with the previous property */ @@ -2971,11 +2971,11 @@ delete_text_property (GtkText* text, guint nchars) { tmp = MARK_LIST_PTR (&text->point); prop = MARK_CURRENT_PROPERTY(&text->point); - + MARK_LIST_PTR (&text->point) = MARK_PREV_LIST_PTR (&text->point); MARK_CURRENT_PROPERTY(&text->point)->length += 1; MARK_NEXT_LIST_PTR(&text->point) = NULL; - + text->point.offset = MARK_CURRENT_PROPERTY(&text->point)->length - 1; g_mem_chunk_free (text_property_chunk, prop); @@ -2987,7 +2987,7 @@ static void init_properties (GtkText *text) { GtkWidget *widget = (GtkWidget *)text; - + if (!text->text_properties) { text->text_properties = g_list_alloc(); @@ -2998,9 +2998,9 @@ init_properties (GtkText *text) &widget->style->base[GTK_STATE_NORMAL], 1); text->text_properties_end = text->text_properties; - + SET_PROPERTY_MARK (&text->point, text->text_properties, 0); - + text->point.index = 0; } } @@ -3023,9 +3023,9 @@ static void advance_mark_n (GtkPropertyMark* mark, gint n) { gint i; - + g_assert (n > 0); - + for (i = 0; i < n; i += 1) advance_mark (mark); } @@ -3034,9 +3034,9 @@ static void advance_mark (GtkPropertyMark* mark) { TextProperty* prop = MARK_CURRENT_PROPERTY (mark); - + mark->index += 1; - + if (prop->length > mark->offset + 1) mark->offset += 1; else @@ -3050,7 +3050,7 @@ static void decrement_mark (GtkPropertyMark* mark) { mark->index -= 1; - + if (mark->offset > 0) mark->offset -= 1; else @@ -3064,9 +3064,9 @@ static void decrement_mark_n (GtkPropertyMark* mark, gint n) { gint i; - + g_assert (n > 0); - + for (i = 0; i < n; i += 1) decrement_mark (mark); } @@ -3089,19 +3089,19 @@ find_mark_near (GtkText* text, guint mark_position, const GtkPropertyMark* near) { gint diffa; gint diffb; - + GtkPropertyMark mark; - + if (!near) diffa = mark_position + 1; else diffa = mark_position - near->index; - + diffb = mark_position; - + if (diffa < 0) diffa = -diffa; - + if (diffa <= diffb) { mark = *near; @@ -3112,7 +3112,7 @@ find_mark_near (GtkText* text, guint mark_position, const GtkPropertyMark* near) mark.property = text->text_properties; mark.offset = 0; } - + if (mark.index > mark_position) { while (mark.index > mark_position) @@ -3123,7 +3123,7 @@ find_mark_near (GtkText* text, guint mark_position, const GtkPropertyMark* near) while (mark_position > mark.index) advance_mark (&mark); } - + return mark; } @@ -3137,16 +3137,16 @@ find_line_containing_point (GtkText* text, guint point, { GList* cache; gint height; - + text->current_line = NULL; - + if (!text->line_start_cache->next) { /* @@@ Its visible, right? */ text->current_line = text->line_start_cache; return; } - + while ( ( scroll && (text->first_cut_pixels != 0) && (CACHE_DATA(text->line_start_cache->next).start.index > point) ) || ( (text->first_cut_pixels == 0) && @@ -3155,14 +3155,14 @@ find_line_containing_point (GtkText* text, guint point, scroll_int (text, - SCROLL_PIXELS); g_assert (text->line_start_cache->next); } - + TEXT_SHOW (text); gdk_window_get_size (text->text_area, NULL, &height); - + for (cache = text->line_start_cache; cache; cache = cache->next) { guint lph; - + if (CACHE_DATA(cache).end.index >= point || LAST_INDEX(text, CACHE_DATA(cache).end)) { @@ -3170,16 +3170,16 @@ find_line_containing_point (GtkText* text, guint point, * important side effect. */ return; } - + TEXT_SHOW_LINE (text, cache, "cache"); - + if (cache->next == NULL) fetch_lines_forward (text, 1); - + if (scroll) { lph = pixel_height_of (text, cache->next); - + /* Scroll the bottom of the line is on screen, or until * the line is the first onscreen line. */ @@ -3192,7 +3192,7 @@ find_line_containing_point (GtkText* text, guint point, } } } - + g_assert_not_reached (); /* Must set text->current_line here */ } @@ -3201,16 +3201,16 @@ pixel_height_of (GtkText* text, GList* cache_line) { gint pixels = - text->first_cut_pixels; GList *cache = text->line_start_cache; - + while (TRUE) { pixels += LINE_HEIGHT (CACHE_DATA(cache)); - + if (cache->data == cache_line->data) break; - + cache = cache->next; } - + return pixels; } @@ -3223,13 +3223,13 @@ find_char_width (GtkText* text, const GtkPropertyMark *mark, const TabStopMark * { gchar ch; gint16* char_widths; - + if (LAST_INDEX (text, *mark)) return 0; ch = GTK_TEXT_INDEX (text, mark->index); char_widths = MARK_CURRENT_TEXT_FONT (mark)->char_widths; - + if (ch == '\t') { return tab_mark->to_next_tab * char_widths[' ']; @@ -3263,7 +3263,7 @@ advance_tab_mark (GtkText* text, TabStopMark* tab_mark, gchar ch) static void advance_tab_mark_n (GtkText* text, TabStopMark* tab_mark, gint n) - /* No tabs! */ + /* No tabs! */ { while (n--) advance_tab_mark (text, tab_mark, 0); @@ -3274,24 +3274,24 @@ find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_hei { gchar ch; GtkEditable *editable = (GtkEditable *)text; - + GtkPropertyMark mark = start_line->start; TabStopMark tab_mark = start_line->tab_cont.tab_start; gint pixel_width = LINE_START_PIXEL (*start_line); - + while (mark.index < text->cursor_mark.index) { pixel_width += find_char_width (text, &mark, &tab_mark); - + advance_tab_mark (text, &tab_mark, GTK_TEXT_INDEX(text, mark.index)); advance_mark (&mark); } - + text->cursor_pos_x = pixel_width; text->cursor_pos_y = pixel_height; text->cursor_char_offset = start_line->font_descent; text->cursor_mark = mark; - + ch = LAST_INDEX (text, mark) ? LINE_DELIM : GTK_TEXT_INDEX (text, mark.index); @@ -3299,7 +3299,7 @@ find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_hei text->cursor_char = ch; else text->cursor_char = 0; - + #ifdef USE_XIM if (gdk_im_ready() && editable->ic && gdk_ic_get_style (editable->ic) & GdkIMPreeditPosition) @@ -3312,7 +3312,7 @@ find_cursor_at_line (GtkText* text, const LineParams* start_line, gint pixel_hei gdk_ic_set_attr (editable->ic, "preeditAttributes", "fontSet", GDK_FONT_XFONT (MARK_CURRENT_FONT (&mark)), NULL); - + gdk_ic_set_attr (editable->ic, "preeditAttributes", "spotLocation", &spot, "lineSpace", LINE_HEIGHT (*start_line), @@ -3329,57 +3329,57 @@ find_cursor (GtkText* text, gboolean scroll) if (GTK_WIDGET_REALIZED (text)) { find_line_containing_point (text, text->cursor_mark.index, scroll); - + g_assert (text->cursor_mark.index >= text->first_line_start_index); - + if (text->current_line) find_cursor_at_line (text, &CACHE_DATA(text->current_line), pixel_height_of(text, text->current_line)); } - + GTK_EDITABLE (text)->current_pos = text->cursor_mark.index; } static void find_mouse_cursor_at_line (GtkText *text, const LineParams* lp, - guint line_pixel_height, - gint button_x) + guint line_pixel_height, + gint button_x) { GtkPropertyMark mark = lp->start; TabStopMark tab_mark = lp->tab_cont.tab_start; - + gint char_width = find_char_width(text, &mark, &tab_mark); gint pixel_width = LINE_START_PIXEL (*lp) + (char_width+1)/2; - + text->cursor_pos_y = line_pixel_height; - + for (;;) { - gchar ch = LAST_INDEX (text, mark) ? - LINE_DELIM : GTK_TEXT_INDEX (text, mark.index); - + gchar ch = LAST_INDEX (text, mark) ? + LINE_DELIM : GTK_TEXT_INDEX (text, mark.index); + if (button_x < pixel_width || mark.index == lp->end.index) { text->cursor_pos_x = pixel_width - (char_width+1)/2; text->cursor_mark = mark; text->cursor_char_offset = lp->font_descent; - + if (!isspace(ch)) text->cursor_char = ch; else text->cursor_char = 0; - + break; } - + advance_tab_mark (text, &tab_mark, ch); advance_mark (&mark); - + pixel_width += char_width/2; - + char_width = find_char_width (text, &mark, &tab_mark); - + pixel_width += (char_width+1)/2; } } @@ -3417,20 +3417,20 @@ static void free_cache (GtkText* text) { GList* cache = text->line_start_cache; - + if (cache) { while (cache->prev) cache = cache->prev; - + text->line_start_cache = cache; } - + for (; cache; cache = cache->next) g_mem_chunk_free (params_mem_chunk, cache->data); - + g_list_free (text->line_start_cache); - + text->line_start_cache = NULL; } @@ -3438,24 +3438,24 @@ static GList* remove_cache_line (GtkText* text, GList* member) { GList *list; - + if (member == NULL) return NULL; - + if (member == text->line_start_cache) text->line_start_cache = text->line_start_cache->next; - + if (member->prev) member->prev->next = member->next; - + if (member->next) member->next->prev = member->prev; - + list = member->next; g_mem_chunk_free (params_mem_chunk, member->data); g_list_free_1 (member); - + return list; } @@ -3467,7 +3467,7 @@ static void move_cursor_buffer_ver (GtkText *text, int dir) { undraw_cursor (text, FALSE); - + if (dir > 0) { scroll_int (text, text->vadj->upper); @@ -3482,7 +3482,7 @@ move_cursor_buffer_ver (GtkText *text, int dir) 0, &text->cursor_mark); } - + find_cursor (text, TRUE); draw_cursor (text, FALSE); } @@ -3499,44 +3499,44 @@ move_cursor_ver (GtkText *text, int count) gint i; GtkPropertyMark mark; gint offset; - + mark = find_this_line_start_mark (text, text->cursor_mark.index, &text->cursor_mark); offset = text->cursor_mark.index - mark.index; - + if (offset > text->cursor_virtual_x) text->cursor_virtual_x = offset; - + if (count < 0) { if (mark.index == 0) return; - + decrement_mark (&mark); mark = find_this_line_start_mark (text, mark.index, &mark); } else { mark = text->cursor_mark; - + while (!LAST_INDEX(text, mark) && GTK_TEXT_INDEX(text, mark.index) != LINE_DELIM) advance_mark (&mark); - + if (LAST_INDEX(text, mark)) - return; - + return; + advance_mark (&mark); } - + for (i=0; i < text->cursor_virtual_x; i += 1, advance_mark(&mark)) if (LAST_INDEX(text, mark) || GTK_TEXT_INDEX(text, mark.index) == LINE_DELIM) break; - + undraw_cursor (text, FALSE); - + text->cursor_mark = mark; - + find_cursor (text, TRUE); - + draw_cursor (text, FALSE); } @@ -3548,15 +3548,15 @@ move_cursor_hor (GtkText *text, int count) (count < 0 && text->cursor_mark.index < (- count)) || (count == 0) ) return; - + text->cursor_virtual_x = 0; - + undraw_cursor (text, FALSE); - + move_mark_n (&text->cursor_mark, count); - + find_cursor (text, TRUE); - + draw_cursor (text, FALSE); } @@ -3575,7 +3575,7 @@ gtk_text_move_cursor (GtkEditable *editable, while (x++ != 0) move_cursor_hor (GTK_TEXT (editable), -1); } - + if (y > 0) { while (y-- != 0) @@ -3632,17 +3632,17 @@ static void gtk_text_move_forward_word (GtkText *text) { text->cursor_virtual_x = 0; - + undraw_cursor (text, FALSE); while (!LAST_INDEX (text, text->cursor_mark) && !isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index))) advance_mark (&text->cursor_mark); - + while (!LAST_INDEX (text, text->cursor_mark) && isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index))) advance_mark (&text->cursor_mark); - + find_cursor (text, TRUE); draw_cursor (text, FALSE); } @@ -3651,17 +3651,17 @@ static void gtk_text_move_backward_word (GtkText *text) { text->cursor_virtual_x = 0; - + undraw_cursor (text, FALSE); while ((text->cursor_mark.index > 0) && !isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1))) decrement_mark (&text->cursor_mark); - + while ((text->cursor_mark.index > 0) && isalnum (GTK_TEXT_INDEX(text, text->cursor_mark.index-1))) decrement_mark (&text->cursor_mark); - + find_cursor (text, TRUE); draw_cursor (text, FALSE); } @@ -3687,18 +3687,18 @@ gtk_text_move_to_column (GtkEditable *editable, gint column) { GtkText *text; - + text = GTK_TEXT (editable); - + text->cursor_virtual_x = 0; /* FIXME */ - + undraw_cursor (text, FALSE); - + /* Move to the beginning of the line */ while ((text->cursor_mark.index > 0) && (GTK_TEXT_INDEX (text, text->cursor_mark.index - 1) != LINE_DELIM)) decrement_mark (&text->cursor_mark); - + while (!LAST_INDEX (text, text->cursor_mark) && (GTK_TEXT_INDEX (text, text->cursor_mark.index) != LINE_DELIM)) { @@ -3706,10 +3706,10 @@ gtk_text_move_to_column (GtkEditable *editable, column--; else if (column == 0) break; - + advance_mark (&text->cursor_mark); } - + find_cursor (text, TRUE); draw_cursor (text, FALSE); } @@ -3718,7 +3718,7 @@ static void gtk_text_move_beginning_of_line (GtkText *text) { gtk_text_move_to_column (GTK_EDITABLE (text), 0); - + } static void @@ -3732,7 +3732,7 @@ gtk_text_kill_char (GtkEditable *editable, gint direction) { GtkText *text; - + text = GTK_TEXT (editable); if (editable->selection_start_pos != editable->selection_end_pos) @@ -3833,16 +3833,16 @@ gtk_text_select_word (GtkText *text, guint32 time) { gint start_pos; gint end_pos; - + GtkEditable *editable; editable = GTK_EDITABLE (text); - + gtk_text_move_backward_word (text); start_pos = text->cursor_mark.index; - + gtk_text_move_forward_word (text); end_pos = text->cursor_mark.index; - + editable->has_selection = TRUE; gtk_text_set_selection (editable, start_pos, end_pos); gtk_editable_claim_selection (editable, start_pos != end_pos, time); @@ -3853,17 +3853,17 @@ gtk_text_select_line (GtkText *text, guint32 time) { gint start_pos; gint end_pos; - + GtkEditable *editable; editable = GTK_EDITABLE (text); - + gtk_text_move_beginning_of_line (text); start_pos = text->cursor_mark.index; - + gtk_text_move_end_of_line (text); gtk_text_move_forward_character (text); end_pos = text->cursor_mark.index; - + editable->has_selection = TRUE; gtk_text_set_selection (editable, start_pos, end_pos); gtk_editable_claim_selection (editable, start_pos != end_pos, time); @@ -3877,15 +3877,15 @@ static void adjust_adj (GtkText* text, GtkAdjustment* adj) { gint height; - + gdk_window_get_size (text->text_area, NULL, &height); - + adj->step_increment = MIN (adj->upper, (float) SCROLL_PIXELS); adj->page_increment = MIN (adj->upper, height - (float) KEY_SCROLL_PIXELS); adj->page_size = MIN (adj->upper, height); adj->value = MIN (adj->value, adj->upper - adj->page_size); adj->value = MAX (adj->value, 0.0); - + gtk_signal_emit_by_name (GTK_OBJECT (adj), "changed"); } @@ -3893,12 +3893,12 @@ static gint set_vertical_scroll_iterator (GtkText* text, LineParams* lp, void* data) { gint *pixel_count = (gint*) data; - + if (text->first_line_start_index == lp->start.index) text->vadj->value = (float) *pixel_count; - + *pixel_count += LINE_HEIGHT (*lp); - + return FALSE; } @@ -3907,33 +3907,33 @@ set_vertical_scroll_find_iterator (GtkText* text, LineParams* lp, void* data) { SetVerticalScrollData *svdata = (SetVerticalScrollData *) data; gint return_val; - + if (svdata->last_didnt_wrap) svdata->last_line_start = lp->start.index; - + if (svdata->pixel_height <= (gint) text->vadj->value && svdata->pixel_height + LINE_HEIGHT(*lp) > (gint) text->vadj->value) { svdata->mark = lp->start; - + text->first_cut_pixels = (gint)text->vadj->value - svdata->pixel_height; text->first_onscreen_ver_pixel = svdata->pixel_height; text->first_line_start_index = svdata->last_line_start; - + return_val = TRUE; } else { svdata->pixel_height += LINE_HEIGHT (*lp); - + return_val = FALSE; } - + if (!lp->wraps) svdata->last_didnt_wrap = TRUE; else svdata->last_didnt_wrap = FALSE; - + return return_val; } @@ -3945,35 +3945,35 @@ set_vertical_scroll (GtkText* text) gint height; gint pixel_count = 0; gint orig_value; - + line_params_iterate (text, &mark, NULL, FALSE, &pixel_count, set_vertical_scroll_iterator); - + text->vadj->upper = (float) pixel_count; orig_value = (gint) text->vadj->value; - + gdk_window_get_size (text->text_area, NULL, &height); - + text->vadj->step_increment = MIN (text->vadj->upper, (float) SCROLL_PIXELS); text->vadj->page_increment = MIN (text->vadj->upper, height - (float) KEY_SCROLL_PIXELS); text->vadj->page_size = MIN (text->vadj->upper, height); text->vadj->value = MIN (text->vadj->value, text->vadj->upper - text->vadj->page_size); text->vadj->value = MAX (text->vadj->value, 0.0); - + text->last_ver_value = (gint)text->vadj->value; text->first_cut_pixels = 0; - + gtk_signal_emit_by_name (GTK_OBJECT (text->vadj), "changed"); - + if (text->vadj->value != orig_value) { /* We got clipped, and don't really know which line to put first. */ data.pixel_height = 0; data.last_didnt_wrap = TRUE; - + line_params_iterate (text, &mark, NULL, FALSE, &data, set_vertical_scroll_find_iterator); - + return data.mark; } else @@ -3986,13 +3986,13 @@ static void scroll_int (GtkText* text, gint diff) { gfloat upper; - + text->vadj->value += diff; - + upper = text->vadj->upper - text->vadj->page_size; text->vadj->value = MIN (text->vadj->value, upper); text->vadj->value = MAX (text->vadj->value, 0.0); - + gtk_signal_emit_by_name (GTK_OBJECT (text->vadj), "value_changed"); } @@ -4000,10 +4000,10 @@ static void process_exposes (GtkText *text) { GdkEvent *event; - + /* Make sure graphics expose events are processed before scrolling * again */ - + while ((event = gdk_event_get_graphics_expose (text->text_area)) != NULL) { gtk_widget_event (GTK_WIDGET (text), event); @@ -4020,13 +4020,13 @@ static gint last_visible_line_height (GtkText* text) { GList *cache = text->line_start_cache; gint height; - + gdk_window_get_size (text->text_area, NULL, &height); - + for (; cache->next; cache = cache->next) if (pixel_height_of(text, cache->next) > height) break; - + if (cache) return pixel_height_of(text, cache) - 1; else @@ -4047,13 +4047,13 @@ scroll_down (GtkText* text, gint diff0) GdkRectangle rect; gint real_diff = 0; gint width, height; - + text->first_onscreen_ver_pixel += diff0; - + while (diff0-- > 0) { g_assert (text->line_start_cache); - + if (text->first_cut_pixels < LINE_HEIGHT(CACHE_DATA(text->line_start_cache)) - 1) { text->first_cut_pixels += 1; @@ -4061,19 +4061,19 @@ scroll_down (GtkText* text, gint diff0) else { text->first_cut_pixels = 0; - + text->line_start_cache = text->line_start_cache->next; - + text->first_line_start_index = CACHE_DATA(text->line_start_cache).start.index; - + if (!text->line_start_cache->next) fetch_lines_forward (text, 1); } - + real_diff += 1; } - + gdk_window_get_size (text->text_area, &width, &height); if (height > real_diff) gdk_draw_pixmap (text->text_area, @@ -4085,27 +4085,27 @@ scroll_down (GtkText* text, gint diff0) 0, width, height - real_diff); - + rect.x = 0; rect.y = MAX (0, height - real_diff); rect.width = width; rect.height = MIN (height, real_diff); - + expose_text (text, &rect, FALSE); gtk_text_draw_focus ( (GtkWidget *) text); - + if (text->current_line) { gint cursor_min; - + text->cursor_pos_y -= real_diff; cursor_min = drawn_cursor_min(text); - + if (cursor_min < 0) find_mouse_cursor (text, text->cursor_pos_x, first_visible_line_height (text)); } - + if (height > real_diff) process_exposes (text); } @@ -4116,13 +4116,13 @@ scroll_up (GtkText* text, gint diff0) gint real_diff = 0; GdkRectangle rect; gint width, height; - + text->first_onscreen_ver_pixel += diff0; - + while (diff0++ < 0) { g_assert (text->line_start_cache); - + if (text->first_cut_pixels > 0) { text->first_cut_pixels -= 1; @@ -4131,18 +4131,18 @@ scroll_up (GtkText* text, gint diff0) { if (!text->line_start_cache->prev) fetch_lines_backward (text); - + text->line_start_cache = text->line_start_cache->prev; - + text->first_line_start_index = CACHE_DATA(text->line_start_cache).start.index; - + text->first_cut_pixels = LINE_HEIGHT(CACHE_DATA(text->line_start_cache)) - 1; } - + real_diff += 1; } - + gdk_window_get_size (text->text_area, &width, &height); if (height > real_diff) gdk_draw_pixmap (text->text_area, @@ -4154,29 +4154,29 @@ scroll_up (GtkText* text, gint diff0) real_diff, width, height - real_diff); - + rect.x = 0; rect.y = 0; rect.width = width; rect.height = MIN (height, real_diff); - + expose_text (text, &rect, FALSE); gtk_text_draw_focus ( (GtkWidget *) text); - + if (text->current_line) { gint cursor_max; gint height; - + text->cursor_pos_y += real_diff; cursor_max = drawn_cursor_max(text); gdk_window_get_size (text->text_area, NULL, &height); - + if (cursor_max >= height) find_mouse_cursor (text, text->cursor_pos_x, last_visible_line_height (text)); } - + if (height > real_diff) process_exposes (text); } @@ -4201,10 +4201,10 @@ find_line_params (GtkText* text, gchar ch; gint ch_width; GdkFont *font; - + gdk_window_get_size (text->text_area, (gint*) &max_display_pixels, NULL); max_display_pixels -= LINE_WRAP_ROOM; - + lp.wraps = 0; lp.tab_cont = *tab_cont; lp.start = *mark; @@ -4213,51 +4213,51 @@ find_line_params (GtkText* text, lp.displayable_chars = 0; lp.font_ascent = 0; lp.font_descent = 0; - + init_tab_cont (text, next_cont); - + while (!LAST_INDEX(text, lp.end)) { g_assert (lp.end.property); - + ch = GTK_TEXT_INDEX (text, lp.end.index); font = MARK_CURRENT_FONT (&lp.end); - + if (ch == LINE_DELIM) { /* Newline doesn't count in computation of line height, even * if its in a bigger font than the rest of the line. Unless, * of course, there are no other characters. */ - + if (!lp.font_ascent && !lp.font_descent) { lp.font_ascent = font->ascent; lp.font_descent = font->descent; } - + lp.tab_cont_next = *next_cont; - + return lp; } - + ch_width = find_char_width (text, &lp.end, &tab_mark); - + if (ch_width + lp.pixel_width > max_display_pixels) { lp.wraps = 1; - + if (text->line_wrap) { next_cont->tab_start = tab_mark; next_cont->pixel_offset = 0; - + if (ch == '\t') { /* Here's the tough case, a tab is wrapping. */ gint pixels_avail = max_display_pixels - lp.pixel_width; gint space_width = MARK_CURRENT_TEXT_FONT(&lp.end)->char_widths[' ']; gint spaces_avail = pixels_avail / space_width; - + if (spaces_avail == 0) { decrement_mark (&lp.end); @@ -4276,7 +4276,7 @@ find_line_params (GtkText* text, { GtkPropertyMark saved_mark = lp.end; guint saved_characters = lp.displayable_chars; - + lp.displayable_chars += 1; while (!isspace (GTK_TEXT_INDEX (text, lp.end.index)) && @@ -4285,7 +4285,7 @@ find_line_params (GtkText* text, decrement_mark (&lp.end); lp.displayable_chars -= 1; } - + /* If whole line is one word, revert to char wrapping */ if (lp.end.index == lp.start.index) { @@ -4300,9 +4300,9 @@ find_line_params (GtkText* text, decrement_mark (&lp.end); } } - + lp.tab_cont_next = *next_cont; - + return lp; } } @@ -4310,26 +4310,26 @@ find_line_params (GtkText* text, { lp.displayable_chars += 1; } - + lp.font_ascent = MAX (font->ascent, lp.font_ascent); lp.font_descent = MAX (font->descent, lp.font_descent); lp.pixel_width += ch_width; - + advance_mark(&lp.end); advance_tab_mark (text, &tab_mark, ch); } - + if (LAST_INDEX(text, lp.start)) { /* Special case, empty last line. */ font = MARK_CURRENT_FONT (&lp.end); - + lp.font_ascent = font->ascent; lp.font_descent = font->descent; } - + lp.tab_cont_next = *next_cont; - + return lp; } @@ -4339,14 +4339,14 @@ expand_scratch_buffer (GtkText* text, guint len) if (len >= text->scratch_buffer_len) { guint i = 1; - + while (i <= len && i < MIN_GAP_SIZE) i <<= 1; - + if (text->scratch_buffer) text->scratch_buffer = g_new (guchar, i); else text->scratch_buffer = g_realloc (text->scratch_buffer, i); - + text->scratch_buffer_len = i; } } @@ -4371,7 +4371,7 @@ mark_bg_gc (GtkText* text, const GtkPropertyMark *mark) } else if (!gdk_color_equal(MARK_CURRENT_BACK (mark), >K_WIDGET(text)->style->base[GTK_STATE_NORMAL])) - + { gdk_gc_set_foreground (text->gc, MARK_CURRENT_BACK (mark)); return text->gc; @@ -4390,17 +4390,17 @@ draw_line (GtkText* text, guint running_offset = lp->tab_cont.pixel_offset; guchar* buffer; GdkGC *fg_gc, *bg_gc; - + GtkEditable *editable = GTK_EDITABLE(text); guint selection_start_pos = MIN (editable->selection_start_pos, editable->selection_end_pos); guint selection_end_pos = MAX (editable->selection_start_pos, editable->selection_end_pos); - + GtkPropertyMark mark = lp->start; TabStopMark tab_mark = lp->tab_cont.tab_start; gint pixel_height = pixel_start_height + lp->font_ascent; guint chars = lp->displayable_chars; - + /* First provide a contiguous segment of memory. This makes reading * the code below *much* easier, and only incurs the cost of copying * when the line being displayed spans the gap. */ @@ -4408,10 +4408,10 @@ draw_line (GtkText* text, mark.index + chars > text->gap_position) { expand_scratch_buffer (text, chars); - + for (i = 0; i < chars; i += 1) text->scratch_buffer[i] = GTK_TEXT_INDEX(text, mark.index + i); - + buffer = text->scratch_buffer; } else @@ -4421,7 +4421,7 @@ draw_line (GtkText* text, else buffer = text->text + mark.index; } - + if (running_offset > 0) { @@ -4438,16 +4438,16 @@ draw_line (GtkText* text, else if (GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL]) { GdkRectangle rect; - + rect.x = 0; rect.y = pixel_start_height; rect.width = running_offset; rect.height = LINE_HEIGHT (*lp); - + clear_area (text, &rect); } } - + for (; chars > 0; chars -= len, buffer += len, len = 0) { if (buffer[0] != '\t') @@ -4455,17 +4455,17 @@ draw_line (GtkText* text, guchar* next_tab = memchr (buffer, '\t', chars); gint pixel_width; GdkFont *font; - + len = MIN (MARK_CURRENT_PROPERTY (&mark)->length - mark.offset, chars); - + if (next_tab) len = MIN (len, next_tab - buffer); - + if (mark.index < selection_start_pos) len = MIN (len, selection_start_pos - mark.index); else if (mark.index < selection_end_pos) len = MIN (len, selection_end_pos - mark.index); - + font = MARK_CURRENT_PROPERTY (&mark)->font->gdk_font; if (font->type == GDK_FONT_FONT) { @@ -4497,7 +4497,7 @@ draw_line (GtkText* text, clear_area (text, &rect); } - + if ((mark.index >= selection_start_pos) && (mark.index < selection_end_pos)) { @@ -4511,37 +4511,37 @@ draw_line (GtkText* text, gdk_gc_set_foreground (text->gc, MARK_CURRENT_FORE (&mark)); fg_gc = text->gc; } - + gdk_draw_text (text->text_area, MARK_CURRENT_FONT (&mark), fg_gc, running_offset, pixel_height, (gchar*) buffer, len); - + running_offset += pixel_width; - + advance_tab_mark_n (text, &tab_mark, len); } else { len = 1; - + bg_gc = mark_bg_gc (text, &mark); if (bg_gc) { gint pixels_remaining; gint space_width; gint spaces_avail; - + gdk_window_get_size (text->text_area, &pixels_remaining, NULL); pixels_remaining -= (LINE_WRAP_ROOM + running_offset); - + space_width = MARK_CURRENT_TEXT_FONT(&mark)->char_widths[' ']; - + spaces_avail = pixels_remaining / space_width; spaces_avail = MIN (spaces_avail, tab_mark.to_next_tab); - + gdk_draw_rectangle (text->text_area, bg_gc, TRUE, @@ -4550,13 +4550,13 @@ draw_line (GtkText* text, spaces_avail * space_width, LINE_HEIGHT (*lp)); } - + running_offset += tab_mark.to_next_tab * MARK_CURRENT_TEXT_FONT(&mark)->char_widths[' ']; - + advance_tab_mark (text, &tab_mark, '\t'); } - + advance_mark_n (&mark, len); } } @@ -4568,7 +4568,7 @@ draw_line_wrap (GtkText* text, guint height /* baseline height */) GdkPixmap *bitmap; gint bitmap_width; gint bitmap_height; - + if (text->line_wrap) { bitmap = text->line_wrap_bitmap; @@ -4581,21 +4581,21 @@ draw_line_wrap (GtkText* text, guint height /* baseline height */) bitmap_width = line_arrow_width; bitmap_height = line_arrow_height; } - + gdk_window_get_size (text->text_area, &width, NULL); width -= LINE_WRAP_ROOM; - + gdk_gc_set_stipple (text->gc, bitmap); - + gdk_gc_set_fill (text->gc, GDK_STIPPLED); - + gdk_gc_set_foreground (text->gc, >K_WIDGET (text)->style->text[GTK_STATE_NORMAL]); - + gdk_gc_set_ts_origin (text->gc, width + 1, height - bitmap_height - 1); - + gdk_draw_rectangle (text->text_area, text->gc, TRUE, @@ -4603,9 +4603,9 @@ draw_line_wrap (GtkText* text, guint height /* baseline height */) height - bitmap_height - 1 /* one pixel above the baseline. */, bitmap_width, bitmap_height); - + gdk_gc_set_ts_origin (text->gc, 0, 0); - + gdk_gc_set_fill (text->gc, GDK_SOLID); } @@ -4613,31 +4613,31 @@ static void undraw_cursor (GtkText* text, gint absolute) { GtkEditable *editable = (GtkEditable *)text; - + TDEBUG (("in undraw_cursor\n")); - + if (absolute) text->cursor_drawn_level = 0; - + if ((text->cursor_drawn_level ++ == 0) && (editable->selection_start_pos == editable->selection_end_pos) && GTK_WIDGET_DRAWABLE (text)) { GdkFont* font; - + g_assert(text->cursor_mark.property); - + font = MARK_CURRENT_FONT(&text->cursor_mark); - + if (GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL]) { GdkRectangle rect; - + rect.x = text->cursor_pos_x; rect.y = text->cursor_pos_y - text->cursor_char_offset - font->ascent; rect.width = 1; rect.height = font->ascent + 1; /* @@@ I add one here because draw_line is inclusive, right? */ - + clear_area (text, &rect); } else @@ -4647,14 +4647,14 @@ undraw_cursor (GtkText* text, gint absolute) text->cursor_pos_y - text->cursor_char_offset, text->cursor_pos_x, text->cursor_pos_y - text->cursor_char_offset - font->ascent); } - + if (text->cursor_char) { if (font->type == GDK_FONT_FONT) gdk_gc_set_font (text->gc, font); - + gdk_gc_set_foreground (text->gc, MARK_CURRENT_FORE (&text->cursor_mark)); - + gdk_draw_text (text->text_area, font, text->gc, text->cursor_pos_x, @@ -4693,25 +4693,25 @@ static void draw_cursor (GtkText* text, gint absolute) { GtkEditable *editable = (GtkEditable *)text; - + TDEBUG (("in draw_cursor\n")); - + if (absolute) text->cursor_drawn_level = 1; - + if ((--text->cursor_drawn_level == 0) && editable->editable && (editable->selection_start_pos == editable->selection_end_pos) && GTK_WIDGET_DRAWABLE (text)) { GdkFont* font; - + g_assert (text->cursor_mark.property); - + font = MARK_CURRENT_FONT (&text->cursor_mark); - + gdk_gc_set_foreground (text->gc, >K_WIDGET (text)->style->text[GTK_STATE_NORMAL]); - + gdk_draw_line (text->text_area, text->gc, text->cursor_pos_x, text->cursor_pos_y - text->cursor_char_offset, text->cursor_pos_x, @@ -4729,22 +4729,22 @@ clear_area (GtkText *text, GdkRectangle *area) gint width, height; gint x = area->x, y = area->y; gint xorig, yorig; - + gdk_window_get_size (widget->style->bg_pixmap[GTK_STATE_NORMAL], &width, &height); - + yorig = - text->first_onscreen_ver_pixel; xorig = - text->first_onscreen_hor_pixel; - + for (y = area->y; y < area->y + area->height; ) { gint yoff = (y - yorig) % height; gint yw = MIN(height - yoff, (area->y + area->height) - y); - + for (x = area->x; x < area->x + area->width; ) { gint xoff = (x - xorig) % width; gint xw = MIN(width - xoff, (area->x + area->width) - x); - + gdk_draw_pixmap (text->text_area, text->gc, widget->style->bg_pixmap[GTK_STATE_NORMAL], @@ -4754,7 +4754,7 @@ clear_area (GtkText *text, GdkRectangle *area) y, xw, yw); - + x += width - xoff; } y += height - yoff; @@ -4772,24 +4772,24 @@ expose_text (GtkText* text, GdkRectangle *area, gboolean cursor) gint min_y = MAX (0, area->y); gint max_y = MAX (0, area->y + area->height); gint height; - + gdk_window_get_size (text->text_area, NULL, &height); max_y = MIN (max_y, height); - + TDEBUG (("in expose x=%d y=%d w=%d h=%d\n", area->x, area->y, area->width, area->height)); - + clear_area (text, area); - + for (; pixels < height; cache = cache->next) { if (pixels < max_y && (pixels + (gint)LINE_HEIGHT(CACHE_DATA(cache))) >= min_y) { draw_line (text, pixels, &CACHE_DATA(cache)); - + if (CACHE_DATA(cache).wraps) draw_line_wrap (text, pixels + CACHE_DATA(cache).font_ascent); } - + if (cursor && GTK_WIDGET_HAS_FOCUS (text)) { if (CACHE_DATA(cache).start.index <= text->cursor_mark.index && @@ -4803,13 +4803,13 @@ expose_text (GtkText* text, GdkRectangle *area, gboolean cursor) draw_cursor (text, FALSE); } } - + pixels += LINE_HEIGHT(CACHE_DATA(cache)); - + if (!cache->next) { fetch_lines_forward (text, 1); - + if (!cache->next) break; } @@ -4822,16 +4822,16 @@ gtk_text_update_text (GtkEditable *editable, gint end_pos) { GtkText *text = GTK_TEXT (editable); - + GList *cache = text->line_start_cache; gint pixels = - text->first_cut_pixels; GdkRectangle area; gint width; gint height; - + if (end_pos < 0) end_pos = TEXT_LENGTH (text); - + if (end_pos < start_pos) return; @@ -4840,9 +4840,9 @@ gtk_text_update_text (GtkEditable *editable, area.y = -1; area.width = width; area.height = 0; - + TDEBUG (("in expose span start=%d stop=%d\n", start_pos, end_pos)); - + for (; pixels < height; cache = cache->next) { if (CACHE_DATA(cache).start.index < end_pos) @@ -4856,18 +4856,18 @@ gtk_text_update_text (GtkEditable *editable, } else break; - + pixels += LINE_HEIGHT(CACHE_DATA(cache)); - + if (!cache->next) { fetch_lines_forward (text, 1); - + if (!cache->next) break; } } - + if (area.y >= 0) expose_text (text, &area, TRUE); } @@ -4878,19 +4878,19 @@ recompute_geometry (GtkText* text) GtkPropertyMark start_mark; gint height; gint width; - + free_cache (text); - + start_mark = set_vertical_scroll (text); - + gdk_window_get_size (text->text_area, &width, &height); - + text->line_start_cache = fetch_lines (text, &start_mark, NULL, FetchLinesPixels, height + text->first_cut_pixels); - + find_cursor (text, TRUE); } @@ -4904,9 +4904,9 @@ gtk_text_set_selection (GtkEditable *editable, gint end) { GtkText *text = GTK_TEXT (editable); - + guint start1, end1, start2, end2; - + if (end < 0) end = TEXT_LENGTH (text); @@ -4914,25 +4914,25 @@ gtk_text_set_selection (GtkEditable *editable, end1 = MAX(start,end); start2 = MIN(editable->selection_start_pos, editable->selection_end_pos); end2 = MAX(editable->selection_start_pos, editable->selection_end_pos); - + if (start2 < start1) { guint tmp; - + tmp = start1; start1 = start2; start2 = tmp; tmp = end1; end1 = end2; end2 = tmp; } - + undraw_cursor (text, FALSE); editable->selection_start_pos = start; editable->selection_end_pos = end; draw_cursor (text, FALSE); - + /* Expose only what changed */ - + if (start1 < start2) gtk_text_update_text (editable, start1, MIN(end1, start2)); - + if (end2 > end1) gtk_text_update_text (editable, MAX(end1, start2), end2); else if (end2 < end1) @@ -4951,41 +4951,41 @@ gtk_text_show_cache_line (GtkText *text, GList *cache, { LineParams *lp = &CACHE_DATA(cache); gint i; - + if (cache == text->line_start_cache) - g_print ("Line Start Cache: "); - + g_message ("Line Start Cache: "); + if (cache == text->current_line) - g_print("Current Line: "); - - g_print ("%s:%d: cache line %s s=%d,e=%d,lh=%d (", - func, - line, - what, - lp->start.index, - lp->end.index, - LINE_HEIGHT(*lp)); - + g_message("Current Line: "); + + g_message ("%s:%d: cache line %s s=%d,e=%d,lh=%d (", + func, + line, + what, + lp->start.index, + lp->end.index, + LINE_HEIGHT(*lp)); + for (i = lp->start.index; i < (lp->end.index + lp->wraps); i += 1) - g_print ("%c", GTK_TEXT_INDEX (text, i)); - - g_print (")\n"); + g_message ("%c", GTK_TEXT_INDEX (text, i)); + + g_message (")\n"); } static void gtk_text_show_cache (GtkText *text, const char* func, gint line) { GList *l = text->line_start_cache; - + if (!l) { return; } - + /* back up to the absolute beginning of the line cache */ while (l->prev) l = l->prev; - - g_print ("*** line cache ***\n"); + + g_message ("*** line cache ***\n"); for (; l; l = l->next) gtk_text_show_cache_line (text, l, "all", func, line); } @@ -5000,7 +5000,7 @@ gtk_text_assert_mark (GtkText *text, gint line) { GtkPropertyMark correct_mark = find_mark (text, mark->index); - + if (mark->offset != correct_mark.offset || mark->property != correct_mark.property) g_warning ("incorrect %s text property marker in %s:%d, index %d -- bad!", where, msg, line, mark->index); @@ -5014,25 +5014,25 @@ gtk_text_assert (GtkText *text, GList* cache = text->line_start_cache; GtkPropertyMark* before_mark = NULL; GtkPropertyMark* after_mark = NULL; - + gtk_text_show_props (text, msg, line); - + for (; cache->prev; cache = cache->prev) /* nothing */; - - g_print ("*** line markers ***\n"); - + + g_message ("*** line markers ***\n"); + for (; cache; cache = cache->next) { after_mark = &CACHE_DATA(cache).end; gtk_text_assert_mark (text, &CACHE_DATA(cache).start, before_mark, after_mark, msg, "start", line); before_mark = &CACHE_DATA(cache).start; - + if (cache->next) after_mark = &CACHE_DATA(cache->next).start; else after_mark = NULL; - + gtk_text_assert_mark (text, &CACHE_DATA(cache).end, before_mark, after_mark, msg, "end", line); before_mark = &CACHE_DATA(cache).end; } @@ -5045,18 +5045,18 @@ gtk_text_show_adj (GtkText *text, const char* func, gint line) { - g_print ("*** adjustment ***\n"); - - g_print ("%s:%d: %s adjustment l=%.1f u=%.1f v=%.1f si=%.1f pi=%.1f ps=%.1f\n", - func, - line, - what, - adj->lower, - adj->upper, - adj->value, - adj->step_increment, - adj->page_increment, - adj->page_size); + g_message ("*** adjustment ***\n"); + + g_message ("%s:%d: %s adjustment l=%.1f u=%.1f v=%.1f si=%.1f pi=%.1f ps=%.1f\n", + func, + line, + what, + adj->lower, + adj->upper, + adj->value, + adj->step_increment, + adj->page_increment, + adj->page_size); } static void @@ -5066,20 +5066,20 @@ gtk_text_show_props (GtkText *text, { GList* props = text->text_properties; int proplen = 0; - - g_print ("%s:%d: ", msg, line); - + + g_message ("%s:%d: ", msg, line); + for (; props; props = props->next) { TextProperty *p = (TextProperty*)props->data; - + proplen += p->length; - - g_print ("[%d,%p,%p,%ld,%ld] ", p->length, p, p->font, p->fore_color.pixel, p->back_color.pixel); + + g_message ("[%d,%p,%p,%ld,%ld] ", p->length, p, p->font, p->fore_color.pixel, p->back_color.pixel); } - - g_print ("\n"); - + + g_message ("\n"); + if (proplen - 1 != TEXT_LENGTH(text)) g_warning ("incorrect property list length in %s:%d -- bad!", msg, line); } diff --git a/gtk/gtktree.c b/gtk/gtktree.c index ecaf7f2d35..6b7ad8a238 100644 --- a/gtk/gtktree.c +++ b/gtk/gtktree.c @@ -69,7 +69,7 @@ GtkType gtk_tree_get_type (void) { static GtkType tree_type = 0; - + if (!tree_type) { GtkTypeInfo tree_info = @@ -83,10 +83,10 @@ gtk_tree_get_type (void) /* reserved_2 */ NULL, (GtkClassInitFunc) NULL, }; - + tree_type = gtk_type_unique (gtk_container_get_type (), &tree_info); } - + return tree_type; } @@ -96,13 +96,13 @@ gtk_tree_class_init (GtkTreeClass *class) GtkObjectClass *object_class; GtkWidgetClass *widget_class; GtkContainerClass *container_class; - + object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - + parent_class = gtk_type_class (gtk_container_get_type ()); - + tree_signals[SELECTION_CHANGED] = gtk_signal_new ("selection_changed", GTK_RUN_FIRST, @@ -126,11 +126,11 @@ gtk_tree_class_init (GtkTreeClass *class) gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1, GTK_TYPE_WIDGET); - + gtk_object_class_add_signals (object_class, tree_signals, LAST_SIGNAL); - + object_class->destroy = gtk_tree_destroy; - + widget_class->map = gtk_tree_map; widget_class->unmap = gtk_tree_unmap; widget_class->realize = gtk_tree_realize; @@ -141,13 +141,13 @@ gtk_tree_class_init (GtkTreeClass *class) widget_class->button_release_event = gtk_tree_button_release; widget_class->size_request = gtk_tree_size_request; widget_class->size_allocate = gtk_tree_size_allocate; - + container_class->add = gtk_tree_add; container_class->remove = - (void (*)(GtkContainer *, GtkWidget *)) gtk_tree_remove_item; + (void (*)(GtkContainer *, GtkWidget *)) gtk_tree_remove_item; container_class->foreach = gtk_tree_foreach; container_class->child_type = gtk_tree_child_type; - + class->selection_changed = NULL; class->select_child = gtk_real_tree_select_child; class->unselect_child = gtk_real_tree_unselect_child; @@ -188,7 +188,7 @@ gtk_tree_append (GtkTree *tree, g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (tree_item != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item)); - + gtk_tree_insert(tree, tree_item, -1); } @@ -200,7 +200,7 @@ gtk_tree_prepend (GtkTree *tree, g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (tree_item != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item)); - + gtk_tree_insert(tree, tree_item, 0); } @@ -210,31 +210,31 @@ gtk_tree_insert (GtkTree *tree, gint position) { gint nchildren; - + g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (tree_item != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item)); - + /* set parent widget to item */ gtk_widget_set_parent (tree_item, GTK_WIDGET (tree)); - + if (GTK_WIDGET_VISIBLE (tree_item->parent)) { if (GTK_WIDGET_REALIZED (tree_item->parent) && !GTK_WIDGET_REALIZED (tree_item)) gtk_widget_realize (tree_item); - + if (GTK_WIDGET_MAPPED (tree_item->parent) && !GTK_WIDGET_MAPPED (tree_item)) gtk_widget_map (tree_item); } - + nchildren = g_list_length (tree->children); - + if ((position < 0) || (position > nchildren)) position = nchildren; - + if (position == nchildren) { tree->children = g_list_append(tree->children, tree_item); @@ -243,10 +243,10 @@ gtk_tree_insert (GtkTree *tree, { tree->children = g_list_insert(tree->children, tree_item, position); } - + if (GTK_WIDGET_VISIBLE (tree)) gtk_widget_queue_resize (GTK_WIDGET (tree)); - + } static void @@ -254,36 +254,36 @@ gtk_tree_add (GtkContainer *container, GtkWidget *widget) { GtkTree *tree; - + g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_TREE (container)); g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (widget)); - + tree = GTK_TREE (container); - + gtk_widget_set_parent (widget, GTK_WIDGET (container)); if (GTK_WIDGET_VISIBLE (widget->parent)) { if (GTK_WIDGET_REALIZED (widget->parent) && !GTK_WIDGET_REALIZED (widget)) gtk_widget_realize (widget); - + if (GTK_WIDGET_MAPPED (widget->parent) && !GTK_WIDGET_MAPPED (widget)) gtk_widget_map (widget); } - + tree->children = g_list_append (tree->children, widget); - + if (!tree->selection && (tree->selection_mode == GTK_SELECTION_BROWSE)) { gtk_tree_select_child (tree, widget); } - + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container)) gtk_widget_queue_resize (widget); - + } static gint @@ -292,17 +292,17 @@ gtk_tree_button_press (GtkWidget *widget, { GtkTree *tree; GtkWidget *item; - + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TREE (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + tree = GTK_TREE (widget); item = gtk_get_event_widget ((GdkEvent*) event); - + while (item && !GTK_IS_TREE_ITEM (item)) item = item->parent; - + if (!item || (item->parent != widget)) return FALSE; @@ -318,7 +318,7 @@ gtk_tree_button_press (GtkWidget *widget, if(GTK_TREE_ITEM(item)->subtree) gtk_tree_item_collapse(GTK_TREE_ITEM(item)); break; } - + return TRUE; } @@ -328,14 +328,14 @@ gtk_tree_button_release (GtkWidget *widget, { GtkTree *tree; GtkWidget *item; - + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TREE (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + tree = GTK_TREE (widget); item = gtk_get_event_widget ((GdkEvent*) event); - + return TRUE; } @@ -345,25 +345,25 @@ gtk_tree_child_position (GtkTree *tree, { GList *children; gint pos; - - + + g_return_val_if_fail (tree != NULL, -1); g_return_val_if_fail (GTK_IS_TREE (tree), -1); g_return_val_if_fail (child != NULL, -1); - + pos = 0; children = tree->children; - + while (children) { if (child == GTK_WIDGET (children->data)) return pos; - + pos += 1; children = children->next; } - - + + return -1; } @@ -413,12 +413,12 @@ gtk_tree_destroy (GtkObject *object) GtkTree *tree; GtkWidget *child; GList *children; - + g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_TREE (object)); - + tree = GTK_TREE (object); - + children = tree->children; while (children) { @@ -430,10 +430,10 @@ gtk_tree_destroy (GtkObject *object) gtk_widget_destroy (child); gtk_widget_unref (child); } - + g_list_free (tree->children); tree->children = NULL; - + if (tree->root_tree == tree) { GList *node; @@ -442,7 +442,7 @@ gtk_tree_destroy (GtkObject *object) g_list_free (tree->selection); tree->selection = NULL; } - + if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -456,32 +456,32 @@ gtk_tree_draw (GtkWidget *widget, GtkWidget *child; GdkRectangle child_area; GList *children; - - + + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE (widget)); g_return_if_fail (area != NULL); - + if (GTK_WIDGET_DRAWABLE (widget)) { tree = GTK_TREE (widget); - + children = tree->children; while (children) { child = children->data; children = children->next; - + if (gtk_widget_intersect (child, area, &child_area)) gtk_widget_draw (child, &child_area); - + if((subtree = GTK_TREE_ITEM(child)->subtree) && GTK_WIDGET_VISIBLE(subtree) && gtk_widget_intersect (subtree, area, &child_area)) gtk_widget_draw (subtree, &child_area); } } - + } static gint @@ -492,31 +492,31 @@ gtk_tree_expose (GtkWidget *widget, GtkWidget *child; GdkEventExpose child_event; GList *children; - - + + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TREE (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + if (GTK_WIDGET_DRAWABLE (widget)) { tree = GTK_TREE (widget); - + child_event = *event; - + children = tree->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_NO_WINDOW (child) && gtk_widget_intersect (child, &event->area, &child_event.area)) gtk_widget_event (child, (GdkEvent*) &child_event); } } - - + + return FALSE; } @@ -528,22 +528,22 @@ gtk_tree_foreach (GtkContainer *container, GtkTree *tree; GtkWidget *child; GList *children; - - + + g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_TREE (container)); g_return_if_fail (callback != NULL); - + tree = GTK_TREE (container); children = tree->children; - + while (children) { child = children->data; children = children->next; - + (* callback) (child, callback_data); - + if(GTK_TREE_ITEM(child)->subtree) (* callback)(GTK_TREE_ITEM(child)->subtree, callback_data); } @@ -555,21 +555,21 @@ gtk_tree_map (GtkWidget *widget) GtkTree *tree; GtkWidget *child; GList *children; - - + + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE (widget)); - + GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); tree = GTK_TREE (widget); - + gdk_window_show (widget->window); - + if(GTK_IS_TREE(widget->parent)) { /* set root tree for this tree */ tree->root_tree = GTK_TREE(widget->parent)->root_tree; - + tree->level = GTK_TREE(GTK_WIDGET(tree)->parent)->level+1; tree->indent_value = GTK_TREE(GTK_WIDGET(tree)->parent)->indent_value; tree->current_indent = GTK_TREE(GTK_WIDGET(tree)->parent)->current_indent + @@ -579,21 +579,21 @@ gtk_tree_map (GtkWidget *widget) } else tree->root_tree = tree; - + children = tree->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child)) gtk_widget_map (child); - + if (GTK_TREE_ITEM (child)->subtree) { child = GTK_WIDGET (GTK_TREE_ITEM (child)->subtree); - + if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child)) gtk_widget_map (child); } @@ -607,11 +607,11 @@ gtk_tree_motion_notify (GtkWidget *widget, g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TREE (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + #ifdef TREE_DEBUG - g_print("gtk_tree_motion_notify\n"); + g_message("gtk_tree_motion_notify\n"); #endif /* TREE_DEBUG */ - + return FALSE; } @@ -620,13 +620,13 @@ gtk_tree_realize (GtkWidget *widget) { GdkWindowAttr attributes; gint attributes_mask; - - + + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE (widget)); - + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - + attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; @@ -636,12 +636,12 @@ gtk_tree_realize (GtkWidget *widget) attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; - + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); - + widget->style = gtk_style_attach (widget->style, widget->window); gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]); @@ -652,16 +652,16 @@ gtk_tree_remove_item (GtkTree *container, GtkWidget *widget) { GList *item_list; - + g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_TREE (container)); g_return_if_fail (widget != NULL); g_return_if_fail (container == GTK_TREE (widget->parent)); - + item_list = g_list_append (NULL, widget); gtk_tree_remove_items (GTK_TREE (container), item_list); - + g_list_free (item_list); } @@ -675,7 +675,7 @@ gtk_tree_sort_item_by_depth(GtkWidget* a, GtkWidget* b) return 1; if((GTK_TREE(a->parent)->level) > (GTK_TREE(b->parent)->level)) return -1; - + return 0; } @@ -689,14 +689,14 @@ gtk_tree_remove_items (GtkTree *tree, GList *sorted_list; GtkTree *real_tree; GtkTree *root_tree; - + g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); - + #ifdef TREE_DEBUG - g_print("+ gtk_tree_remove_items [ tree %#x items list %#x ]\n", (int)tree, (int)items); + g_message("+ gtk_tree_remove_items [ tree %#x items list %#x ]\n", (int)tree, (int)items); #endif /* TREE_DEBUG */ - + /* We may not yet be mapped, so we actively have to find our * root tree */ @@ -707,175 +707,175 @@ gtk_tree_remove_items (GtkTree *tree, GtkWidget *tmp = GTK_WIDGET (tree); while (tmp->parent && GTK_IS_TREE (tmp->parent)) tmp = tmp->parent; - + root_tree = GTK_TREE (tmp); } - + tmp_list = items; selected_widgets = NULL; sorted_list = NULL; widget = NULL; - + #ifdef TREE_DEBUG - g_print("* sort list by depth\n"); + g_message("* sort list by depth\n"); #endif /* TREE_DEBUG */ - + while (tmp_list) { - + #ifdef TREE_DEBUG - g_print("* item [%#x] depth [%d]\n", - (int)tmp_list->data, - (int)GTK_TREE(GTK_WIDGET(tmp_list->data)->parent)->level); + g_message ("* item [%#x] depth [%d]\n", + (int)tmp_list->data, + (int)GTK_TREE(GTK_WIDGET(tmp_list->data)->parent)->level); #endif /* TREE_DEBUG */ - + sorted_list = g_list_insert_sorted(sorted_list, tmp_list->data, (GCompareFunc)gtk_tree_sort_item_by_depth); tmp_list = g_list_next(tmp_list); } - + #ifdef TREE_DEBUG /* print sorted list */ - g_print("* sorted list result\n"); + g_message("* sorted list result\n"); tmp_list = sorted_list; while(tmp_list) { - g_print("* item [%#x] depth [%d]\n", - (int)tmp_list->data, - (int)GTK_TREE(GTK_WIDGET(tmp_list->data)->parent)->level); + g_message("* item [%#x] depth [%d]\n", + (int)tmp_list->data, + (int)GTK_TREE(GTK_WIDGET(tmp_list->data)->parent)->level); tmp_list = g_list_next(tmp_list); } #endif /* TREE_DEBUG */ - + #ifdef TREE_DEBUG - g_print("* scan sorted list\n"); + g_message("* scan sorted list\n"); #endif /* TREE_DEBUG */ - + tmp_list = sorted_list; while (tmp_list) { widget = tmp_list->data; tmp_list = tmp_list->next; - + #ifdef TREE_DEBUG - g_print("* item [%#x] subtree [%#x]\n", - (int)widget, (int)GTK_TREE_ITEM_SUBTREE(widget)); + g_message("* item [%#x] subtree [%#x]\n", + (int)widget, (int)GTK_TREE_ITEM_SUBTREE(widget)); #endif /* TREE_DEBUG */ - + /* get real owner of this widget */ real_tree = GTK_TREE(widget->parent); #ifdef TREE_DEBUG - g_print("* subtree having this widget [%#x]\n", (int)real_tree); + g_message("* subtree having this widget [%#x]\n", (int)real_tree); #endif /* TREE_DEBUG */ - + if (widget->state == GTK_STATE_SELECTED) { selected_widgets = g_list_prepend (selected_widgets, widget); #ifdef TREE_DEBUG - g_print("* selected widget - adding it in selected list [%#x]\n", - (int)selected_widgets); + g_message("* selected widget - adding it in selected list [%#x]\n", + (int)selected_widgets); #endif /* TREE_DEBUG */ } - + /* remove this item from its real parent */ #ifdef TREE_DEBUG - g_print("* remove widget from its owner tree\n"); + g_message("* remove widget from its owner tree\n"); #endif /* TREE_DEBUG */ real_tree->children = g_list_remove (real_tree->children, widget); - + /* remove subtree associate at this item if it exist */ if(GTK_TREE_ITEM(widget)->subtree) { #ifdef TREE_DEBUG - g_print("* remove subtree associate at this item [%#x]\n", - (int) GTK_TREE_ITEM(widget)->subtree); + g_message("* remove subtree associate at this item [%#x]\n", + (int) GTK_TREE_ITEM(widget)->subtree); #endif /* TREE_DEBUG */ if (GTK_WIDGET_MAPPED (GTK_TREE_ITEM(widget)->subtree)) gtk_widget_unmap (GTK_TREE_ITEM(widget)->subtree); - + gtk_widget_unparent (GTK_TREE_ITEM(widget)->subtree); GTK_TREE_ITEM(widget)->subtree = NULL; } - + /* really remove widget for this item */ #ifdef TREE_DEBUG - g_print("* unmap and unparent widget [%#x]\n", (int)widget); + g_message("* unmap and unparent widget [%#x]\n", (int)widget); #endif /* TREE_DEBUG */ if (GTK_WIDGET_MAPPED (widget)) gtk_widget_unmap (widget); - + gtk_widget_unparent (widget); - + /* delete subtree if there is no children in it */ if(real_tree->children == NULL && real_tree != root_tree) { #ifdef TREE_DEBUG - g_print("* owner tree don't have children ... destroy it\n"); + g_message("* owner tree don't have children ... destroy it\n"); #endif /* TREE_DEBUG */ gtk_tree_item_remove_subtree(GTK_TREE_ITEM(real_tree->tree_owner)); } - + #ifdef TREE_DEBUG - g_print("* next item in list\n"); + g_message("* next item in list\n"); #endif /* TREE_DEBUG */ } - + if (selected_widgets) { #ifdef TREE_DEBUG - g_print("* scan selected item list\n"); + g_message("* scan selected item list\n"); #endif /* TREE_DEBUG */ tmp_list = selected_widgets; while (tmp_list) { widget = tmp_list->data; tmp_list = tmp_list->next; - + #ifdef TREE_DEBUG - g_print("* widget [%#x] subtree [%#x]\n", - (int)widget, (int)GTK_TREE_ITEM_SUBTREE(widget)); + g_message("* widget [%#x] subtree [%#x]\n", + (int)widget, (int)GTK_TREE_ITEM_SUBTREE(widget)); #endif /* TREE_DEBUG */ /* remove widget of selection */ root_tree->selection = g_list_remove (root_tree->selection, widget); - + /* unref it to authorize is destruction */ gtk_widget_unref (widget); } - + /* emit only one selection_changed signal */ gtk_signal_emit (GTK_OBJECT (root_tree), tree_signals[SELECTION_CHANGED]); } - + #ifdef TREE_DEBUG - g_print("* free selected_widgets list\n"); + g_message("* free selected_widgets list\n"); #endif /* TREE_DEBUG */ g_list_free (selected_widgets); g_list_free (sorted_list); - + if (root_tree->children && !root_tree->selection && (root_tree->selection_mode == GTK_SELECTION_BROWSE)) { #ifdef TREE_DEBUG - g_print("* BROWSE mode, select another item\n"); + g_message("* BROWSE mode, select another item\n"); #endif /* TREE_DEBUG */ widget = root_tree->children->data; gtk_tree_select_child (root_tree, widget); } - + if (GTK_WIDGET_VISIBLE (root_tree)) { #ifdef TREE_DEBUG - g_print("* query queue resizing for root_tree\n"); + g_message("* query queue resizing for root_tree\n"); #endif /* TREE_DEBUG */ gtk_widget_queue_resize (GTK_WIDGET (root_tree)); } } - + void gtk_tree_select_child (GtkTree *tree, GtkWidget *tree_item) @@ -893,14 +893,14 @@ gtk_tree_select_item (GtkTree *tree, gint item) { GList *tmp_list; - + g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); - + tmp_list = g_list_nth (tree->children, item); if (tmp_list) gtk_tree_select_child (tree, GTK_WIDGET (tmp_list->data)); - + } static void @@ -911,14 +911,14 @@ gtk_tree_size_allocate (GtkWidget *widget, GtkWidget *child, *subtree; GtkAllocation child_allocation; GList *children; - - + + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE (widget)); g_return_if_fail (allocation != NULL); - + tree = GTK_TREE (widget); - + widget->allocation = *allocation; if (GTK_WIDGET_REALIZED (widget)) gdk_window_move_resize (widget->window, @@ -930,22 +930,22 @@ gtk_tree_size_allocate (GtkWidget *widget, child_allocation.x = GTK_CONTAINER (tree)->border_width; child_allocation.y = GTK_CONTAINER (tree)->border_width; child_allocation.width = MAX (1, allocation->width - child_allocation.x * 2); - + children = tree->children; - + while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child)) { child_allocation.height = child->requisition.height; - + gtk_widget_size_allocate (child, &child_allocation); - + child_allocation.y += child_allocation.height; - + if((subtree = GTK_TREE_ITEM(child)->subtree)) if(GTK_WIDGET_VISIBLE (subtree)) { @@ -956,7 +956,7 @@ gtk_tree_size_allocate (GtkWidget *widget, } } } - + } static void @@ -966,60 +966,60 @@ gtk_tree_size_request (GtkWidget *widget, GtkTree *tree; GtkWidget *child, *subtree; GList *children; - - + + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE (widget)); g_return_if_fail (requisition != NULL); - + tree = GTK_TREE (widget); requisition->width = 0; requisition->height = 0; - + children = tree->children; while (children) { child = children->data; children = children->next; - + if (GTK_WIDGET_VISIBLE (child)) { gtk_widget_size_request (child, &child->requisition); - + requisition->width = MAX (requisition->width, child->requisition.width); requisition->height += child->requisition.height; - + if((subtree = GTK_TREE_ITEM(child)->subtree) && GTK_WIDGET_VISIBLE (subtree)) { gtk_widget_size_request (subtree, &subtree->requisition); - + requisition->width = MAX (requisition->width, subtree->requisition.width); - + requisition->height += subtree->requisition.height; } } } - + requisition->width += GTK_CONTAINER (tree)->border_width * 2; requisition->height += GTK_CONTAINER (tree)->border_width * 2; - + requisition->width = MAX (requisition->width, 1); requisition->height = MAX (requisition->height, 1); - + } static void gtk_tree_unmap (GtkWidget *widget) { - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE (widget)); - + GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED); gdk_window_hide (widget->window); - + } void @@ -1030,7 +1030,7 @@ gtk_tree_unselect_child (GtkTree *tree, g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (tree_item != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (tree_item)); - + gtk_signal_emit (GTK_OBJECT (tree), tree_signals[UNSELECT_CHILD], tree_item); } @@ -1039,14 +1039,14 @@ gtk_tree_unselect_item (GtkTree *tree, gint item) { GList *tmp_list; - + g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); - + tmp_list = g_list_nth (tree->children, item); if (tmp_list) gtk_tree_unselect_child (tree, GTK_WIDGET (tmp_list->data)); - + } static void @@ -1056,32 +1056,32 @@ gtk_real_tree_select_child (GtkTree *tree, GList *selection, *root_selection; GList *tmp_list; GtkWidget *tmp_item; - + g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (child != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (child)); - + root_selection = tree->root_tree->selection; switch (tree->root_tree->selection_mode) { case GTK_SELECTION_SINGLE: - + selection = root_selection; - + /* remove old selection list */ while (selection) { tmp_item = selection->data; - + if (tmp_item != child) { gtk_tree_item_deselect (GTK_TREE_ITEM (tmp_item)); - + tmp_list = selection; selection = selection->next; - + root_selection = g_list_remove_link (root_selection, tmp_list); gtk_widget_unref (tmp_item); @@ -1090,7 +1090,7 @@ gtk_real_tree_select_child (GtkTree *tree, else selection = selection->next; } - + if (child->state == GTK_STATE_NORMAL) { gtk_tree_item_select (GTK_TREE_ITEM (child)); @@ -1103,39 +1103,39 @@ gtk_real_tree_select_child (GtkTree *tree, root_selection = g_list_remove (root_selection, child); gtk_widget_unref (child); } - + tree->root_tree->selection = root_selection; - + gtk_signal_emit (GTK_OBJECT (tree->root_tree), tree_signals[SELECTION_CHANGED]); break; - - + + case GTK_SELECTION_BROWSE: selection = root_selection; - + while (selection) { tmp_item = selection->data; - + if (tmp_item != child) { gtk_tree_item_deselect (GTK_TREE_ITEM (tmp_item)); - + tmp_list = selection; selection = selection->next; - + root_selection = g_list_remove_link (root_selection, tmp_list); gtk_widget_unref (tmp_item); - + g_list_free (tmp_list); } else selection = selection->next; } - + tree->root_tree->selection = root_selection; - + if (child->state == GTK_STATE_NORMAL) { gtk_tree_item_select (GTK_TREE_ITEM (child)); @@ -1146,7 +1146,7 @@ gtk_real_tree_select_child (GtkTree *tree, tree_signals[SELECTION_CHANGED]); } break; - + case GTK_SELECTION_MULTIPLE: if (child->state == GTK_STATE_NORMAL) { @@ -1167,7 +1167,7 @@ gtk_real_tree_select_child (GtkTree *tree, tree_signals[SELECTION_CHANGED]); } break; - + case GTK_SELECTION_EXTENDED: break; } @@ -1181,7 +1181,7 @@ gtk_real_tree_unselect_child (GtkTree *tree, g_return_if_fail (GTK_IS_TREE (tree)); g_return_if_fail (child != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (child)); - + switch (tree->selection_mode) { case GTK_SELECTION_SINGLE: @@ -1197,7 +1197,7 @@ gtk_real_tree_unselect_child (GtkTree *tree, tree_signals[SELECTION_CHANGED]); } break; - + case GTK_SELECTION_EXTENDED: break; } @@ -1209,7 +1209,7 @@ gtk_tree_set_selection_mode (GtkTree *tree, { g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); - + tree->selection_mode = mode; } @@ -1219,7 +1219,7 @@ gtk_tree_set_view_mode (GtkTree *tree, { g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); - + tree->view_mode = mode; } @@ -1229,6 +1229,6 @@ gtk_tree_set_view_lines (GtkTree *tree, { g_return_if_fail (tree != NULL); g_return_if_fail (GTK_IS_TREE (tree)); - + tree->view_line = flag; } diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c index 137ff4474b..1e05d71a6f 100644 --- a/gtk/gtktreeitem.c +++ b/gtk/gtktreeitem.c @@ -924,7 +924,7 @@ gtk_tree_item_destroy (GtkObject *object) g_return_if_fail (GTK_IS_TREE_ITEM (object)); #ifdef TREE_DEBUG - g_print("+ gtk_tree_item_destroy [object %#x]\n", (int)object); + g_message("+ gtk_tree_item_destroy [object %#x]\n", (int)object); #endif /* TREE_DEBUG */ item = GTK_TREE_ITEM(object); @@ -976,7 +976,7 @@ gtk_tree_item_destroy (GtkObject *object) GTK_OBJECT_CLASS (parent_class)->destroy (object); #ifdef TREE_DEBUG - g_print("- gtk_tree_item_destroy\n"); + g_message("- gtk_tree_item_destroy\n"); #endif /* TREE_DEBUG */ } diff --git a/gtk/gtktypeutils.c b/gtk/gtktypeutils.c index 0181d7dc60..23a694e94a 100644 --- a/gtk/gtktypeutils.c +++ b/gtk/gtktypeutils.c @@ -413,13 +413,13 @@ gtk_type_describe_heritage (GtkType type) if (first) { first = FALSE; - g_print ("is a "); + g_message ("is a "); } if (node->type_info.type_name) - g_print ("%s\n", node->type_info.type_name); + g_message ("%s\n", node->type_info.type_name); else - g_print ("<unnamed type>\n"); + g_message ("<unnamed type>\n"); LOOKUP_TYPE_NODE (node, node->parent_type); } @@ -441,17 +441,17 @@ gtk_type_describe_tree (GtkType type, guint i; for (i = 0; i < indent; i++) - g_print (" "); + g_message (" "); if (node->type_info.type_name) - g_print ("%s", node->type_info.type_name); + g_message ("%s", node->type_info.type_name); else - g_print ("(no-name)"); + g_message ("(no-name)"); if (show_size) - g_print (" ( %d bytes )\n", node->type_info.object_size); + g_message (" ( %d bytes )\n", node->type_info.object_size); else - g_print ("\n"); + g_message ("\n"); old_indent = indent; indent += 4; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 829e38e64b..c09337d60a 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -1510,7 +1510,7 @@ gtk_widget_realize (GtkWidget *widget) { /* if (GTK_IS_CONTAINER (widget) && !GTK_WIDGET_NO_WINDOW (widget)) - g_print ("%s\n", gtk_type_name (GTK_WIDGET_TYPE (widget))); + g_message ("%s\n", gtk_type_name (GTK_WIDGET_TYPE (widget))); */ if (widget->parent && !GTK_WIDGET_REALIZED (widget->parent)) |