Ejemplo n.º 1
0
void snooper_install(Tbfwin *bfwin) {
	bfwin->snooper = g_new0(Tsnooper,1);
	gtk_key_snooper_install( (GtkKeySnoopFunc) main_snooper, bfwin);
	SNOOPER(bfwin->snooper)->last_seq = gdk_event_new(GDK_KEY_PRESS);
	SNOOPER(bfwin->snooper)->last_event = gdk_event_new(GDK_KEY_PRESS);
	/* SNOOPER(bfwin->snooper)->stat = SNOOPER_ACTIVE; */
}
Ejemplo n.º 2
0
static VALUE
rg_s_key_snooper_install(VALUE self)
{
    VALUE func = rb_block_proc();
    VALUE id = INT2FIX(gtk_key_snooper_install(
                           (GtkKeySnoopFunc)gtk_m_key_snoop_func,
                           (gpointer)func));
    G_RELATIVE2(self, func, id__snooper_callbacks__, id);
    return id;
}
static guint
mai_util_add_key_event_listener (AtkKeySnoopFunc listener,
                                 gpointer data)
{
    NS_ENSURE_TRUE(listener, 0);

    static guint key=0;

    if (!key_listener_list) {
        key_listener_list = g_hash_table_new(NULL, NULL);
        key_snooper_id = gtk_key_snooper_install(mai_key_snooper, data);
    }
    AtkKeySnoopFuncPointer atkKeySnoop;
    atkKeySnoop.func_ptr = listener;
    g_hash_table_insert(key_listener_list, GUINT_TO_POINTER (key++),
                        atkKeySnoop.data);
    return key;
}
Ejemplo n.º 4
0
/**
 * input_sdl_init(): Initialize the SDL input subsystem.
 * @return 0 on success; non-zero on error.
 */
int input_sdl_init(void)
{
	// Initialize the keys and joystick state arrays.
	memset(input_sdl_keys, 0x00, sizeof(input_sdl_keys));
	memset(input_sdl_joystate, 0x00, sizeof(input_sdl_joystate));
	
	// Install the GTK+ key snooper.
	gtk_key_snooper_install(input_sdl_gdk_keysnoop, NULL);
	
	// Initialize joysticks.
	input_sdl_num_joysticks = 0;
	if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
	{
		// Error initializing the SDL joystick handler.
		// Disable joysticks.
		LOG_MSG(input, LOG_MSG_LEVEL_CRITICAL,
			"SDL joystick initialization failed: %s. Joysticks will be unavailable.",
			SDL_GetError());
		return 0;
	}
	
	// If any joysticks are connected, set them up.
	// TODO: Increase number of joysticks from 6?
	if (SDL_NumJoysticks() > 0)
	{
		SDL_JoystickEventState(SDL_ENABLE);
		
		for (int i = 0; i < INPUT_SDL_MAX_JOYSTICKS; i++)
		{
			input_sdl_joys[i] = SDL_JoystickOpen(i);
			if (input_sdl_joys[i])
				input_sdl_num_joysticks++;
		}
	}
	
	// Joysticks initialized.
	return 0;
}
}


void scim_bridge_client_imcontext_focus_in (GtkIMContext *context)
{
    scim_bridge_pdebugln (8, "scim_bridge_client_imcontext_focus_in ()");

    ScimBridgeClientIMContext *imcontext = SCIM_BRIDGE_CLIENT_IMCONTEXT (context);
    
    if (focused_imcontext != NULL && focused_imcontext != imcontext) scim_bridge_client_imcontext_focus_out (GTK_IM_CONTEXT (focused_imcontext));
    focused_imcontext = imcontext;

    if (!scim_bridge_client_is_messenger_opened () && scim_bridge_client_is_reconnection_enabled ()) {
        scim_bridge_pdebugln (7, "Trying to open the connection again...");
        scim_bridge_client_open_messenger ();
    }

    if (!key_snooper_used && is_key_snooper_enabled ()) {
        key_snooper_id = gtk_key_snooper_install ((GtkKeySnoopFunc) &key_snooper, NULL);
        key_snooper_used = TRUE;
    }
    if (scim_bridge_client_is_messenger_opened () && imcontext != NULL) {
        if (scim_bridge_client_change_focus (imcontext, TRUE)) {
            scim_bridge_perrorln ("An IOException occurred at scim_bridge_client_imcontext_focus_in ()");
Ejemplo n.º 6
0
G_MODULE_EXPORT void
gtk_module_init (gint * argc, gchar *** argv)
{
	gtk_key_snooper_install(snooper, NULL);
}
Ejemplo n.º 7
0
int main (int argc, char *argv[])
{
	GtkWidget	*main_window;
	GOptionContext	*context;
	GError		*option_error;
	gchar		*config_file_name, *dir;
	gboolean	show_version = FALSE;

	GOptionEntry options[] =
	{
		{
			"version",
			'v',
			0,
			G_OPTION_ARG_NONE,
			&show_version,
			_("Show version information"),
			NULL
		},
		{NULL}
	};

#ifdef WITH_HILDON
	HildonProgram   *hildon_program;
#endif

#ifdef ENABLE_NLS
	bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (PACKAGE, "UTF-8");
	textdomain (PACKAGE);
  
	gtk_set_locale();
#endif

	/* Parse command line options */
	context = g_option_context_new (NULL);
	g_option_context_set_summary(context,
			_("Carry out simple and scientific calculations"));
#ifdef ENABLE_NLS
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
#else
	g_option_context_add_main_entries (context, options, NULL);
#endif
	g_option_context_add_group (context, gtk_get_option_group (TRUE));

	if (!g_option_context_parse (context, &argc, &argv, &option_error))
	{
		if (option_error)
			g_print ("%s\n", option_error->message);

		return EXIT_FAILURE;
	}

	g_option_context_free (context);

	if(show_version == TRUE)
	{
		g_print(_("%s v%s, (c) 2002-2010 Simon Floery\n"),
			PACKAGE, VERSION);
		return EXIT_SUCCESS;
	}


	gtk_init (&argc, &argv);

	/* at first, get config file */
	dir = g_build_filename (g_get_user_config_dir (), PACKAGE, NULL);
	g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
	config_file_name = g_build_filename (dir, CONFIG_FILE_NAME, NULL);
	g_free(dir);

	prefs = config_file_read (config_file_name);
	
	constant = config_file_get_constants();
	user_function = config_file_get_user_functions();
	g_free (config_file_name);

	current_status.notation = prefs.def_notation;

#ifdef WITH_HILDON
	gtkbuilder_register_widget (HILDON_TYPE_WINDOW, gtkbuilder_hildon_window_new, gtkbuilder_standard_build_children, NULL);
	hildon_program = HILDON_PROGRAM(hildon_program_get_instance());
#endif

	/* at first get the main frame */
	
	/* sth like ui_launch_up_ui for splitting into first time wizard? */
	main_window = ui_main_window_create();
#ifdef WITH_HILDON
	hildon_program_add_window(hildon_program, HILDON_WINDOW(main_window));
	g_set_application_name(PACKAGE_NAME);
	create_hildon_menu(HILDON_WINDOW(main_window));
#endif	

	/* set the window title */
#ifndef WITH_DEFCALC
	gtk_window_set_title ((GtkWindow *)main_window, PACKAGE_NAME);
#else
	gtk_window_set_title ((GtkWindow *)main_window, "Calculator");
#endif

	/* set the window's icon */
#ifndef WITH_DEFCALC
	gtk_window_set_default_icon_name (PACKAGE);
#else
	gtk_window_set_default_icon_name ("utilities-calculator");
#endif

	/* usually, only Shift, CTRL and ALT modifiers are paid attention to by 
	 * accelerator code. add MOD2 (NUMLOCK allover the world?) to the list. 
	 * We have to do this for a working keypad.
	 */

	gtk_accelerator_set_default_mod_mask (gtk_accelerator_get_default_mod_mask () | GDK_MOD2_MASK); 
				  
	/* prepare calc_basic */

	main_alg = alg_init (0);
	rpn_init (prefs.stack_size, 0);
		
	/* apply changes */
	apply_preferences (prefs);

	memory.data = NULL;
	memory.len = 0;

	/* see function key_snooper for details */
	gtk_key_snooper_install (key_snooper, NULL);

	gtk_window_resize ((GtkWindow *)main_window, 1, 1);
	
	/* gtk_widget_show main window as late as possible */
	gtk_widget_show (main_window);

	gtk_main ();

	/* save changes to file */
	dir = g_build_filename (g_get_user_config_dir (), PACKAGE, NULL);
	g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
	config_file_name = g_build_filename (dir, CONFIG_FILE_NAME, NULL);
	g_free(dir);

	config_file_write (config_file_name, prefs, constant, user_function);
	g_free (config_file_name);

	return EXIT_SUCCESS;
}
Ejemplo n.º 8
0
void snooper_install() {
	/* install a snooper for doc->view */
	main_v->snooper = gtk_key_snooper_install( (GtkKeySnoopFunc) completion_snooper, NULL);
	main_v->last_kevent = gdk_event_new(GDK_KEY_PRESS);/* requires GLIB 2.2*/
}
Ejemplo n.º 9
0
static void
fcitx_im_context_class_init(FcitxIMContextClass *klass)
{
    GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS(klass);
    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);

    parent_class = (GtkIMContextClass *) g_type_class_peek_parent (klass);

    im_context_class->set_client_window = fcitx_im_context_set_client_window;
    im_context_class->filter_keypress = fcitx_im_context_filter_keypress;
    im_context_class->reset = fcitx_im_context_reset;
    im_context_class->get_preedit_string = fcitx_im_context_get_preedit_string;
    im_context_class->focus_in = fcitx_im_context_focus_in;
    im_context_class->focus_out = fcitx_im_context_focus_out;
    im_context_class->set_cursor_location = fcitx_im_context_set_cursor_location;
    im_context_class->set_use_preedit = fcitx_im_context_set_use_preedit;
    im_context_class->set_surrounding = fcitx_im_context_set_surrounding;
    gobject_class->finalize = fcitx_im_context_finalize;

    _signal_commit_id =
        g_signal_lookup("commit", G_TYPE_FROM_CLASS(klass));
    g_assert(_signal_commit_id != 0);

    _signal_preedit_changed_id =
        g_signal_lookup("preedit-changed", G_TYPE_FROM_CLASS(klass));
    g_assert(_signal_preedit_changed_id != 0);

    _signal_preedit_start_id =
        g_signal_lookup("preedit-start", G_TYPE_FROM_CLASS(klass));
    g_assert(_signal_preedit_start_id != 0);

    _signal_preedit_end_id =
        g_signal_lookup("preedit-end", G_TYPE_FROM_CLASS(klass));
    g_assert(_signal_preedit_end_id != 0);

    _signal_delete_surrounding_id =
        g_signal_lookup("delete-surrounding", G_TYPE_FROM_CLASS(klass));
    g_assert(_signal_delete_surrounding_id != 0);

    _signal_retrieve_surrounding_id =
        g_signal_lookup("retrieve-surrounding", G_TYPE_FROM_CLASS(klass));
    g_assert(_signal_retrieve_surrounding_id != 0);

    _use_key_snooper = !_get_boolean_env ("IBUS_DISABLE_SNOOPER", !(_ENABLE_SNOOPER))
                       && !_get_boolean_env("FCITX_DISABLE_SNOOPER", !(_ENABLE_SNOOPER));
    /* env IBUS_DISABLE_SNOOPER does not exist */
    if (_use_key_snooper) {
        /* disable snooper if app is in _no_snooper_apps */
        const gchar * prgname = g_get_prgname ();
        if (g_getenv ("IBUS_NO_SNOOPER_APPS")) {
            _no_snooper_apps = g_getenv ("IBUS_NO_SNOOPER_APPS");
        }
        if (g_getenv ("FCITX_NO_SNOOPER_APPS")) {
            _no_snooper_apps = g_getenv ("FCITX_NO_SNOOPER_APPS");
        }
        gchar **p;
        gchar ** apps = g_strsplit (_no_snooper_apps, ",", 0);
        for (p = apps; *p != NULL; p++) {
            if (g_regex_match_simple (*p, prgname, 0, 0)) {
                _use_key_snooper = FALSE;
                break;
            }
        }
        g_strfreev (apps);
    }

    /* make ibus fix benefits us */
    _use_sync_mode = _get_boolean_env("IBUS_ENABLE_SYNC_MODE", FALSE)
                     || _get_boolean_env("FCITX_ENABLE_SYNC_MODE", FALSE);
    /* always install snooper */
    if (_key_snooper_id == 0)
        _key_snooper_id = gtk_key_snooper_install (_key_snooper_cb, NULL);
}