#include "config.h"
+#include "gtkmain.h"
+
#include <glib.h>
-#include "gdkconfig.h"
+#include "gdk/gdk.h"
#include <locale.h>
#include "gtkclipboard.h"
#include "gtkdnd.h"
#include "gtkversion.h"
-#include "gtkmain.h"
#include "gtkmodules.h"
#include "gtkrc.h"
#include "gtkrecentmanager.h"
#include "gtkselection.h"
#include "gtksettings.h"
-#include "gtkwidget.h"
-#include "gtkwindow.h"
+#include "gtkwidgetprivate.h"
+#include "gtkwindowprivate.h"
#include "gtktooltip.h"
#include "gtkdebug.h"
-#include "gtkalias.h"
#include "gtkmenu.h"
-#include "gdk/gdkkeysyms.h"
-
-#include "gdk/gdkprivate.h" /* for GDK_WINDOW_DESTROYED */
#ifdef G_OS_WIN32
/* Private type definitions
*/
-typedef struct _GtkInitFunction GtkInitFunction;
typedef struct _GtkQuitFunction GtkQuitFunction;
typedef struct _GtkKeySnooperData GtkKeySnooperData;
-struct _GtkInitFunction
-{
- GtkFunction function;
- gpointer data;
-};
-
struct _GtkQuitFunction
{
guint id;
static GtkWindowGroup *gtk_main_get_window_group (GtkWidget *widget);
-const guint gtk_major_version = GTK_MAJOR_VERSION;
-const guint gtk_minor_version = GTK_MINOR_VERSION;
-const guint gtk_micro_version = GTK_MICRO_VERSION;
-const guint gtk_binary_age = GTK_BINARY_AGE;
-const guint gtk_interface_age = GTK_INTERFACE_AGE;
-
static guint gtk_main_loop_level = 0;
static gint pre_initialized = FALSE;
static gint gtk_initialized = FALSE;
static GSList *main_loops = NULL; /* stack of currently executing main loops */
-static GList *init_functions = NULL; /* A list of init functions.
- */
static GList *quit_functions = NULL; /* A list of quit functions.
*/
static GSList *key_snoopers = NULL;
-guint gtk_debug_flags = 0; /* Global GTK debug flag */
+static guint debug_flags = 0; /* Global GTK debug flag */
#ifdef G_ENABLE_DEBUG
static const GDebugKey gtk_debug_keys[] = {
};
#endif /* G_ENABLE_DEBUG */
+/**
+ * gtk_get_major_version:
+ *
+ * Returns the major version number of the GTK+ library. (e.g. in GTK+ version
+ * 3.1.5 this is 3.)
+ *
+ * This function is in the library, so it represents the GTK+ library
+ * your code is running against. Contrast with the #GTK_MAJOR_VERSION
+ * macro, which represents the major version of the GTK+ headers you
+ * have included when compiling your code.
+ *
+ * Returns: the major version number of the GTK+ library.
+ *
+ * Since: 3.0
+ */
+guint
+gtk_get_major_version (void)
+{
+ return GTK_MAJOR_VERSION;
+}
+
+/**
+ * gtk_get_minor_version:
+ *
+ * Returns the minor version number of the GTK+ library. (e.g. in GTK+ version
+ * 3.1.5 this is 1.)
+ *
+ * This function is in the library, so it represents the GTK+ library
+ * your code is are running against. Contrast with the
+ * #GTK_MINOR_VERSION macro, which represents the minor version of the
+ * GTK+ headers you have included when compiling your code.
+ *
+ * Returns: the minor version number of the GTK+ library.
+ *
+ * Since: 3.0
+ */
+guint
+gtk_get_minor_version (void)
+{
+ return GTK_MINOR_VERSION;
+}
+
+/**
+ * gtk_get_micro_version:
+ *
+ * Returns the micro version number of the GTK+ library. (e.g. in GTK+ version
+ * 3.1.5 this is 5.)
+ *
+ * This function is in the library, so it represents the GTK+ library
+ * your code is are running against. Contrast with the
+ * #GTK_MICRO_VERSION macro, which represents the micro version of the
+ * GTK+ headers you have included when compiling your code.
+ *
+ * Returns: the micro version number of the GTK+ library.
+ *
+ * Since: 3.0
+ */
+guint
+gtk_get_micro_version (void)
+{
+ return GTK_MICRO_VERSION;
+}
+
+/**
+ * gtk_get_binary_age:
+ *
+ * Returns the binary age as passed to
+ * <application>libtool</application> when building the GTK+ library
+ * the process is running against. If
+ * <application>libtool</application> means nothing to you, don't
+ * worry about it.
+ *
+ * Returns: the binary age of the GTK+ library.
+ *
+ * Since: 3.0
+ */
+guint
+gtk_get_binary_age (void)
+{
+ return GTK_BINARY_AGE;
+}
+
+/**
+ * gtk_get_interface_age:
+ *
+ * Returns the interface age as passed to
+ * <application>libtool</application> when building the GTK+ library
+ * the process is running against. If
+ * <application>libtool</application> means nothing to you, don't
+ * worry about it.
+ *
+ * Returns: the interface age of the GTK+ library.
+ *
+ * Since: 3.0
+ */
+guint
+gtk_get_interface_age (void)
+{
+ return GTK_INTERFACE_AGE;
+}
+
/**
* gtk_check_version:
* @required_major: the required major version.
* This function is primarily for GTK+ modules; the module
* can call this function to check that it wasn't loaded
* into an incompatible version of GTK+. However, such a
- * a check isn't completely reliable, since the module may be
+ * check isn't completely reliable, since the module may be
* linked against an old version of GTK+ and calling the
* old version of gtk_check_version(), but still get loaded
* into an application using a newer version of GTK+.
static gboolean
gtk_arg_debug_cb (const char *key, const char *value, gpointer user_data)
{
- gtk_debug_flags |= g_parse_debug_string (value,
- gtk_debug_keys,
- G_N_ELEMENTS (gtk_debug_keys));
+ debug_flags |= g_parse_debug_string (value,
+ gtk_debug_keys,
+ G_N_ELEMENTS (gtk_debug_keys));
return TRUE;
}
static gboolean
gtk_arg_no_debug_cb (const char *key, const char *value, gpointer user_data)
{
- gtk_debug_flags &= ~g_parse_debug_string (value,
- gtk_debug_keys,
- G_N_ELEMENTS (gtk_debug_keys));
+ debug_flags &= ~g_parse_debug_string (value,
+ gtk_debug_keys,
+ G_N_ELEMENTS (gtk_debug_keys));
return TRUE;
}
env_string = g_getenv ("GTK_DEBUG");
if (env_string != NULL)
{
- gtk_debug_flags = g_parse_debug_string (env_string,
- gtk_debug_keys,
- G_N_ELEMENTS (gtk_debug_keys));
+ debug_flags = g_parse_debug_string (env_string,
+ gtk_debug_keys,
+ G_N_ELEMENTS (gtk_debug_keys));
env_string = NULL;
}
#endif /* G_ENABLE_DEBUG */
g_log_set_always_fatal (fatal_mask);
}
- if (gtk_debug_flags & GTK_DEBUG_UPDATES)
+ if (debug_flags & GTK_DEBUG_UPDATES)
gdk_window_set_debug_updates (TRUE);
{
g_type_init ();
_gtk_accel_map_init ();
- _gtk_rc_init ();
/* Set the 'initialized' flag.
*/
}
+/**
+ * gtk_get_debug_flags:
+ *
+ * Returns the GTK+ debug flags.
+ *
+ * This function is intended for GTK+ modules that want
+ * to adjust their debug output based on GTK+ debug flags.
+ *
+ * Returns: the GTK+ debug flags.
+ */
+guint
+gtk_get_debug_flags (void)
+{
+ return debug_flags;
+}
+
+/**
+ * gtk_set_debug_flags:
+ *
+ * Sets the GTK+ debug flags.
+ */
+void
+gtk_set_debug_flags (guint flags)
+{
+ debug_flags = flags;
+}
+
/**
* gtk_get_option_group:
* @open_default_display: whether to open the default display
* @argc: a pointer to the number of command line arguments.
* @argv: a pointer to the array of command line arguments.
* @parameter_string: a string which is displayed in
- * the first line of <option>--help</option> output, after
+ * the first line of <option>--help</option> output, after
* <literal><replaceable>programname</replaceable> [OPTION...]</literal>
* @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
* describing the options of your program
* @translation_domain: a translation domain to use for translating
* the <option>--help</option> output for the options in @entries
- * with gettext(), or %NULL
- * @error: a return location for errors
+ * and the @parameter_string with gettext(), or %NULL
+ * @error: a return location for errors
*
- * This function does the same work as gtk_init_check().
- * Additionally, it allows you to add your own commandline options,
- * and it automatically generates nicely formatted
+ * This function does the same work as gtk_init_check().
+ * Additionally, it allows you to add your own commandline options,
+ * and it automatically generates nicely formatted
* <option>--help</option> output. Note that your program will
* be terminated after writing out the help output.
*
- * Returns: %TRUE if the GUI has been successfully initialized,
+ * Returns: %TRUE if the GUI has been successfully initialized,
* %FALSE otherwise.
- *
+ *
* Since: 2.6
*/
gboolean
return FALSE;
gtk_group = gtk_get_option_group (TRUE);
-
+
context = g_option_context_new (parameter_string);
g_option_context_add_group (context, gtk_group);
-
+ g_option_context_set_translation_domain (context, translation_domain);
+
if (entries)
g_option_context_add_main_entries (context, entries, translation_domain);
retval = g_option_context_parse (context, argc, argv, error);
-
+
g_option_context_free (context);
return retval;
gtk_main (void)
{
GList *tmp_list;
- GList *functions;
- GtkInitFunction *init;
GMainLoop *loop;
gtk_main_loop_level++;
loop = g_main_loop_new (NULL, TRUE);
main_loops = g_slist_prepend (main_loops, loop);
- tmp_list = functions = init_functions;
- init_functions = NULL;
-
- while (tmp_list)
- {
- init = tmp_list->data;
- tmp_list = tmp_list->next;
-
- (* init->function) (init->data);
- g_free (init);
- }
- g_list_free (functions);
-
if (g_main_loop_is_running (main_loops->data))
{
GDK_THREADS_LEAVE ();
case GDK_PROXIMITY_OUT:
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
- display = gdk_drawable_get_display (event->any.window);
+ display = gdk_window_get_display (event->any.window);
device = gdk_event_get_device (event);
if (!gdk_device_grab_info_libgtk_only (display, device, &grab_window, &owner_events) ||
if (device)
grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
- if (!grab_widget && window_group->grabs)
- grab_widget = window_group->grabs->data;
+ if (!grab_widget)
+ grab_widget = gtk_window_group_get_current_grab (window_group);
/* If the grab widget is an ancestor of the event widget
* then we send the event to the original event widget.
case GDK_DELETE:
g_object_ref (event_widget);
- if ((!window_group->grabs || gtk_widget_get_toplevel (window_group->grabs->data) == event_widget) &&
+ if ((!gtk_window_group_get_current_grab (window_group) || gtk_widget_get_toplevel (gtk_window_group_get_current_grab (window_group)) == event_widget) &&
!gtk_widget_event (event_widget, event))
gtk_widget_destroy (event_widget);
g_object_unref (event_widget);
/* Unexpected GDK_DESTROY from the outside, ignore for
* child windows, handle like a GDK_DELETE for toplevels
*/
- if (!event_widget->parent)
+ if (!gtk_widget_get_parent (event_widget))
{
g_object_ref (event_widget);
if (!gtk_widget_event (event_widget, event) &&
{
/* The app may paint with a previously allocated cairo_t,
which will draw directly to the window. We can't catch cairo
- drap operatoins to automatically flush the window, thus we
+ draw operations to automatically flush the window, thus we
need to explicitly flush any outstanding moves or double
buffering */
gdk_window_flush (event->any.window);
break;
case GDK_PROPERTY_NOTIFY:
- case GDK_NO_EXPOSE:
case GDK_FOCUS_CHANGE:
case GDK_CONFIGURE:
case GDK_MAP:
/* Catch alt press to enable auto-mnemonics;
* menus are handled elsewhere
*/
- if ((event->key.keyval == GDK_Alt_L || event->key.keyval == GDK_Alt_R) &&
+ if ((event->key.keyval == GDK_KEY_Alt_L || event->key.keyval == GDK_KEY_Alt_R) &&
!GTK_IS_MENU_SHELL (grab_widget))
{
gboolean auto_mnemonics;
if (is_shadowed)
{
- GTK_PRIVATE_SET_FLAG (child, GTK_SHADOWED);
+ _gtk_widget_set_shadowed (child, TRUE);
if (!was_shadowed && devices &&
gtk_widget_is_sensitive (child))
synth_crossing_for_grab_notify (child, info->new_grab_widget,
}
else
{
- GTK_PRIVATE_UNSET_FLAG (child, GTK_SHADOWED);
+ _gtk_widget_set_shadowed (child, FALSE);
if (was_shadowed && devices &&
gtk_widget_is_sensitive (child))
synth_crossing_for_grab_notify (info->old_grab_widget, child,
if (!gtk_widget_has_grab (widget) && gtk_widget_is_sensitive (widget))
{
_gtk_widget_set_has_grab (widget, TRUE);
-
+
group = gtk_main_get_window_group (widget);
- if (group->grabs)
- old_grab_widget = (GtkWidget *)group->grabs->data;
- else
- old_grab_widget = NULL;
+ old_grab_widget = gtk_window_group_get_current_grab (group);
g_object_ref (widget);
- group->grabs = g_slist_prepend (group->grabs, widget);
+ _gtk_window_group_add_grab (group, widget);
gtk_grab_notify (group, NULL, old_grab_widget, widget, TRUE);
}
}
+/**
+ * gtk_grab_get_current:
+ *
+ * Queries the current grab of the default window group.
+ *
+ * Return value: (transfer none): The widget which currently
+ * has the grab or %NULL if no grab is active
+ */
GtkWidget*
gtk_grab_get_current (void)
{
group = gtk_main_get_window_group (NULL);
- if (group->grabs)
- return GTK_WIDGET (group->grabs->data);
- return NULL;
+ return gtk_window_group_get_current_grab (group);
}
void
_gtk_widget_set_has_grab (widget, FALSE);
group = gtk_main_get_window_group (widget);
- group->grabs = g_slist_remove (group->grabs, widget);
-
- if (group->grabs)
- new_grab_widget = (GtkWidget *)group->grabs->data;
- else
- new_grab_widget = NULL;
+ _gtk_window_group_remove_grab (group, widget);
+ new_grab_widget = gtk_window_group_get_current_grab (group);
gtk_grab_notify (group, NULL, widget, new_grab_widget, FALSE);
-
+
g_object_unref (widget);
}
}
gtk_grab_notify (group, device, widget, new_grab_widget, FALSE);
}
-void
-gtk_init_add (GtkFunction function,
- gpointer data)
-{
- GtkInitFunction *init;
-
- init = g_new (GtkInitFunction, 1);
- init->function = function;
- init->data = data;
-
- init_functions = g_list_prepend (init_functions, init);
-}
-
guint
gtk_key_snooper_install (GtkKeySnoopFunc snooper,
gpointer func_data)
}
static gint
-gtk_quit_destructor (GtkObject **object_p)
+gtk_quit_destructor (GtkWidget **object_p)
{
if (*object_p)
- gtk_object_destroy (*object_p);
+ gtk_widget_destroy (*object_p);
g_free (object_p);
return FALSE;
}
void
-gtk_quit_add_destroy (guint main_level,
- GtkObject *object)
+gtk_quit_add_destroy (guint main_level,
+ GtkWidget *object)
{
- GtkObject **object_p;
+ GtkWidget **object_p;
g_return_if_fail (main_level > 0);
- g_return_if_fail (GTK_IS_OBJECT (object));
+ g_return_if_fail (GTK_IS_WIDGET (object));
- object_p = g_new (GtkObject*, 1);
+ object_p = g_new (GtkWidget*, 1);
*object_p = object;
g_signal_connect (object,
"destroy",
* If there is a current event and it has a device, return that
* device, otherwise return %NULL.
*
- * Returns: a #GdkDevice, or %NULL
+ * Returns: (transfer none): a #GdkDevice, or %NULL
**/
GdkDevice *
gtk_get_current_event_device (void)
* returns %NULL, otherwise returns the widget that received the event
* originally.
*
- * Return value: the widget that originally received @event, or %NULL
+ * Return value: (transfer none): the widget that originally
+ * received @event, or %NULL
**/
GtkWidget*
gtk_get_event_widget (GdkEvent *event)
widget = NULL;
if (event && event->any.window &&
- (event->type == GDK_DESTROY || !GDK_WINDOW_DESTROYED (event->any.window)))
+ (event->type == GDK_DESTROY || !gdk_window_is_destroyed (event->any.window)))
{
gdk_window_get_user_data (event->any.window, &widget_ptr);
widget = widget_ptr;
handled_event = event->type != GDK_SCROLL;
else
handled_event = gtk_widget_event (widget, event);
-
- tmp = widget->parent;
+
+ tmp = gtk_widget_get_parent (widget);
g_object_unref (widget);
widget = tmp;
return continue_emission;
}
-
-#define __GTK_MAIN_C__
-#include "gtkaliasdef.c"