void keybinder_free() { keybinder_unbind("XF86AudioPlay", (KeybinderHandler) keybind_play_handler); keybinder_unbind("XF86AudioStop", (KeybinderHandler) keybind_stop_handler); keybinder_unbind("XF86AudioPrev", (KeybinderHandler) keybind_prev_handler); keybinder_unbind("XF86AudioNext", (KeybinderHandler) keybind_next_handler); keybinder_unbind("XF86AudioMedia", (KeybinderHandler) keybind_media_handler); }
/* Apply the new preferences */ static void apply_preferences() { /* Unbind the keys before binding new ones */ keybinder_unbind(prefs.history_key, history_hotkey); g_free(prefs.history_key); prefs.history_key = NULL; keybinder_unbind(prefs.actions_key, actions_hotkey); g_free(prefs.actions_key); prefs.actions_key = NULL; keybinder_unbind(prefs.menu_key, menu_hotkey); g_free(prefs.menu_key); prefs.menu_key = NULL; keybinder_unbind(prefs.search_key, search_hotkey); g_free(prefs.search_key); prefs.search_key = NULL; keybinder_unbind(prefs.offline_key, offline_hotkey); g_free(prefs.offline_key); prefs.offline_key = NULL; /* Get the new preferences */ prefs.use_copy = gtk_toggle_button_get_active((GtkToggleButton*)copy_check); prefs.use_primary = gtk_toggle_button_get_active((GtkToggleButton*)primary_check); prefs.synchronize = gtk_toggle_button_get_active((GtkToggleButton*)synchronize_check); prefs.automatic_paste = gtk_toggle_button_get_active((GtkToggleButton*)paste_check); prefs.show_indexes = gtk_toggle_button_get_active((GtkToggleButton*)show_indexes_check); prefs.save_uris = gtk_toggle_button_get_active((GtkToggleButton*)save_uris_check); prefs.use_rmb_menu = gtk_toggle_button_get_active((GtkToggleButton*)use_rmb_menu_check); prefs.save_history = gtk_toggle_button_get_active((GtkToggleButton*)save_check); prefs.history_limit = gtk_spin_button_get_value_as_int((GtkSpinButton*)history_spin); prefs.items_menu = gtk_spin_button_get_value_as_int((GtkSpinButton*)items_menu); prefs.statics_show = gtk_toggle_button_get_active((GtkToggleButton*)statics_show_check); prefs.statics_items = gtk_spin_button_get_value_as_int((GtkSpinButton*)statics_items_spin); prefs.hyperlinks_only = gtk_toggle_button_get_active((GtkToggleButton*)hyperlinks_check); prefs.confirm_clear = gtk_toggle_button_get_active((GtkToggleButton*)confirm_check); prefs.single_line = gtk_toggle_button_get_active((GtkToggleButton*)linemode_check); prefs.reverse_history = gtk_toggle_button_get_active((GtkToggleButton*)reverse_check); prefs.item_length = gtk_spin_button_get_value_as_int((GtkSpinButton*)charlength_spin); prefs.ellipsize = gtk_combo_box_get_active((GtkComboBox*)ellipsize_combo) + 1; prefs.history_key = g_strdup(gtk_entry_get_text((GtkEntry*)history_key_entry)); prefs.actions_key = g_strdup(gtk_entry_get_text((GtkEntry*)actions_key_entry)); prefs.menu_key = g_strdup(gtk_entry_get_text((GtkEntry*)menu_key_entry)); prefs.search_key = g_strdup(gtk_entry_get_text((GtkEntry*)search_key_entry)); prefs.offline_key = g_strdup(gtk_entry_get_text((GtkEntry*)offline_key_entry)); /* Bind keys and apply the new history limit */ keybinder_bind(prefs.history_key, history_hotkey, NULL); keybinder_bind(prefs.actions_key, actions_hotkey, NULL); keybinder_bind(prefs.menu_key, menu_hotkey, NULL); keybinder_bind(prefs.search_key, search_hotkey, NULL); keybinder_bind(prefs.offline_key, offline_hotkey, NULL); truncate_history(); }
static PyObject * GlobalHotkey_bind (GlobalHotkey *self, PyObject *args) { const char *key; PyObject *extra; PyObject *tmp; CallableObject *co; extra = NULL; tmp = NULL; co = malloc (sizeof (CallableObject)); co->callback = NULL; co->params = PyTuple_New (extra ? 2 : 1); if (!PyArg_ParseTuple (args, "sO|O", &key, &tmp, &extra)) return NULL; Py_INCREF (tmp); co->callback = tmp; /* Already binded keys should be unbinded before binding again */ if (PyDict_GetItemString (self->binded, key) != NULL) PyErr_Format (PyExc_Exception, "Key %s already binded", key); PyTuple_SetItem (co->params, 0, PyString_FromString (key)); if (extra) PyTuple_SetItem (co->params, 1, extra); /* Is it a valid python callback? */ if (PyCallable_Check (co->callback)) { /* Let's try to bind the key, if it is not possible, a False python value is returned. */ if (keybinder_bind (key, caller, co)) { /* If it is not possible to add the entry to the binded dict, we should not bind the key */ if (PyDict_SetItemString (self->binded, key, co->callback) != 0) { keybinder_unbind (key, caller); return Py_BuildValue ("i", 0); } else return Py_BuildValue ("i", 1); } else return Py_BuildValue ("i", 0); } PyErr_SetString (PyExc_TypeError, "First param must be callable."); Py_DECREF (extra); return NULL; }
/* lkeybinder library function 'unbind' */ static int lkeybinder_unbind (lua_State *L) { const char *keystr = luaL_checkstring(L, 1); keybinder_unbind(keystr, lkeybinder_handler); /* get table */ lua_rawgeti(L, LUA_REGISTRYINDEX, lkeybinder_reg_key); lua_pushstring(L, keystr); lua_pushnil(L); lua_rawset(L, -3); return 0; }
static PyObject * GlobalHotkey_unbind (GlobalHotkey *self, PyObject *args) { char *key; if (!PyArg_ParseTuple (args, "s", &key)) return NULL; keybinder_unbind (key, caller); PyDict_DelItemString (self->binded, key); return Py_BuildValue (""); }
static void key_combination_key_changed_callback(GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) { hasChanged = 1; keybinder_unbind(popupKey, keyhandler); GConfValue *value = gconf_entry_get_value(entry); popupKey = g_strdup(gconf_value_get_string(value)); keybinder_bind(popupKey, keyhandler, NULL); gtk_tooltips_set_tip(toolTip, GTK_WIDGET(user_data), g_strdup_printf(_("Glipper (%s)\nClipboardmanager"), popupKey), "Glipper"); gtk_entry_set_text((GtkEntry*)keyCombEntry, popupKey); }
static PyObject * GlobalHotkey_unbind_all (GlobalHotkey *self) { PyObject *key, *value; Py_ssize_t pos = 0; char *str_key; while (PyDict_Next (self->binded, &pos, &key, &value)) { str_key = PyString_AsString (key); keybinder_unbind (str_key, caller); } PyDict_Clear (self->binded); return Py_BuildValue ("i", 1); }
void gsd_kb_util_value_free_func (gpointer data) { KeysAndCmd *_kandc_ptr = (KeysAndCmd*) (data); char* _keystring = _kandc_ptr->keystring; char* _cmdstring = _kandc_ptr->cmdstring; //Currently we only support one handler. KeybinderHandler _handler = gsd_kb_handler_default; g_debug ("unbind %s -----> %s", _keystring, _cmdstring); keybinder_unbind (_keystring, _handler); g_free (_keystring); g_free (_cmdstring); g_free (_kandc_ptr); }
/* This is Sparta! */ int main(int argc, char **argv) { bindtextdomain(GETTEXT_PACKAGE, CLIPITLOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); /* Initiate GTK+ */ gtk_init(&argc, &argv); /* Parse options and exit if returns TRUE */ if (argc > 1) { if (parse_options(argc, argv)) return 0; } /* Read input from stdin (if any) */ else { /* Check if stdin is piped */ if (!isatty(fileno(stdin))) { GString* piped_string = g_string_new(NULL); /* Append stdin to string */ while (1) { gchar* buffer = (gchar*)g_malloc(256); if (fgets(buffer, 256, stdin) == NULL) { g_free(buffer); break; } g_string_append(piped_string, buffer); g_free(buffer); } /* Check if anything was piped in */ if (piped_string->len > 0) { /* Truncate new line character */ /* g_string_truncate(piped_string, (piped_string->len - 1)); */ /* Copy to clipboard */ GtkClipboard* clip = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text(clip, piped_string->str, -1); gtk_clipboard_store(clip); /* Exit */ return 0; } g_string_free(piped_string, TRUE); } } /* Init ClipIt */ clipit_init(); /* Run GTK+ loop */ gtk_main(); /* Unbind keys */ keybinder_unbind(prefs.history_key, history_hotkey); keybinder_unbind(prefs.actions_key, actions_hotkey); keybinder_unbind(prefs.menu_key, menu_hotkey); keybinder_unbind(prefs.search_key, search_hotkey); keybinder_unbind(prefs.offline_key, offline_hotkey); /* Cleanup */ g_free(prefs.history_key); g_free(prefs.actions_key); g_free(prefs.menu_key); g_free(prefs.search_key); g_free(prefs.offline_key); g_list_foreach(history, (GFunc)g_free, NULL); g_list_free(history); g_free(primary_text); g_free(clipboard_text); g_free(synchronized_text); /* Exit */ return 0; }
void xvd_keys_release (XvdInstance *Inst) { keybinder_unbind ("XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Alt>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Shift>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl><Shift>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl><Alt>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl><Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Alt><Shift>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Shift><Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl><Shift><Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl><Shift><Alt>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Shift><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("<Ctrl><Shift><Alt><Super>XF86AudioRaiseVolume", xvd_raise_handler); keybinder_unbind ("XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Alt>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Shift>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl><Shift>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl><Alt>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl><Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Alt><Shift>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Alt><Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Shift><Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl><Shift><Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl><Shift><Alt>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Shift><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("<Ctrl><Shift><Alt><Super>XF86AudioLowerVolume", xvd_lower_handler); keybinder_unbind ("XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Alt>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Super>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Shift>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl><Shift>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl><Alt>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl><Super>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Alt><Shift>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Alt><Super>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Shift><Super>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl><Shift><Super>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl><Shift><Alt>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl><Alt><Super>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Shift><Alt><Super>XF86AudioMute", xvd_mute_handler); keybinder_unbind ("<Ctrl><Shift><Alt><Super>XF86AudioMute", xvd_mute_handler); }
void handler (const char *keystring, void *user_data) { printf("Handle %s (%p)!\n", keystring, user_data); keybinder_unbind(keystring, handler); gtk_main_quit(); }
/* FIXME: Cleanup track refs */ void common_cleanup(struct con_win *cwin) { CDEBUG(DBG_INFO, "Cleaning up"); if ((cwin->cstate->state == ST_STOPPED) && (cwin->cstate->curr_mobj_clear)) delete_musicobject(cwin->cstate->curr_mobj); if ((cwin->cstate->state == ST_PLAYING) || (cwin->cstate->state == ST_PAUSED)) stop_playback(cwin); save_preferences(cwin); g_object_unref(cwin->library_store); g_object_unref(cwin->pixbuf->image_play); g_object_unref(cwin->pixbuf->image_pause); if (cwin->pixbuf->pixbuf_app) g_object_unref(cwin->pixbuf->pixbuf_app); if (cwin->pixbuf->pixbuf_dir) g_object_unref(cwin->pixbuf->pixbuf_dir); if (cwin->pixbuf->pixbuf_artist) g_object_unref(cwin->pixbuf->pixbuf_artist); if (cwin->pixbuf->pixbuf_album) g_object_unref(cwin->pixbuf->pixbuf_album); if (cwin->pixbuf->pixbuf_track) g_object_unref(cwin->pixbuf->pixbuf_track); if (cwin->pixbuf->pixbuf_genre) g_object_unref(cwin->pixbuf->pixbuf_genre); g_slice_free(struct pixbuf, cwin->pixbuf); if (cwin->album_art) gtk_widget_destroy(cwin->album_art); if (cwin->cstate->cdda_drive) cdio_cddap_close(cwin->cstate->cdda_drive); if (cwin->cstate->cddb_disc) cddb_disc_destroy(cwin->cstate->cddb_disc); if (cwin->cstate->cddb_conn) { cddb_destroy(cwin->cstate->cddb_conn); libcddb_shutdown(); } g_free(cwin->cpref->lw.lastfm_user); g_free(cwin->cpref->lw.lastfm_pass); #ifdef HAVE_LIBGLYR g_free(cwin->cpref->cache_folder); #endif g_free(cwin->cpref->configrc_file); g_free(cwin->cpref->installed_version); g_free(cwin->cpref->audio_sink); g_free(cwin->cpref->audio_alsa_device); g_free(cwin->cpref->audio_oss_device); g_free(cwin->cpref->album_art_pattern); g_free(cwin->cpref->audio_cd_device); g_free(cwin->cpref->start_mode); g_free(cwin->cpref->sidebar_pane); g_key_file_free(cwin->cpref->configrc_keyfile); free_str_list(cwin->cpref->library_dir); free_str_list(cwin->cpref->lib_add); free_str_list(cwin->cpref->lib_delete); free_str_list(cwin->cpref->library_tree_nodes); free_str_list(cwin->cpref->playlist_columns); g_slist_free(cwin->cpref->playlist_column_widths); g_slice_free(struct con_pref, cwin->cpref); g_rand_free(cwin->cstate->rand); g_free(cwin->cstate->last_folder); g_mutex_free(cwin->cstate->c_mutex); /* Hack, hack */ if (g_mutex_trylock(cwin->cstate->l_mutex) == TRUE) { g_mutex_unlock(cwin->cstate->l_mutex); g_mutex_free(cwin->cstate->l_mutex); } g_cond_free(cwin->cstate->c_cond); g_slice_free(struct con_state, cwin->cstate); #ifdef HAVE_LIBGLYR uninit_glyr_related (cwin); #endif g_free(cwin->cdbase->db_file); sqlite3_close(cwin->cdbase->db); g_slice_free(struct con_dbase, cwin->cdbase); if (cwin->cstate->audio_init && cwin->cmixer) cwin->cmixer->deinit_mixer(cwin); if (cwin->clibao->ao_dev) { CDEBUG(DBG_INFO, "Freeing ao dev"); ao_close(cwin->clibao->ao_dev); } ao_shutdown(); g_slice_free(struct con_mixer, cwin->cmixer); g_slice_free(struct con_libao, cwin->clibao); g_free(cwin->clastfm->session_id); g_free(cwin->clastfm->submission_url); if (cwin->clastfm->curl_handle) curl_easy_cleanup(cwin->clastfm->curl_handle); curl_global_cleanup(); g_slice_free(struct con_lastfm, cwin->clastfm); dbus_connection_remove_filter(cwin->con_dbus, dbus_filter_handler, cwin); dbus_bus_remove_match(cwin->con_dbus, "type='signal',path='/org/pragha/DBus'", NULL); dbus_connection_unref(cwin->con_dbus); #if HAVE_GLIB_2_26 mpris_cleanup(cwin); #endif if (notify_is_initted()) notify_uninit(); #ifdef HAVE_LIBKEYBINDER keybinder_unbind("XF86AudioPlay", (KeybinderHandler) keybind_play_handler); keybinder_unbind("XF86AudioStop", (KeybinderHandler) keybind_stop_handler); keybinder_unbind("XF86AudioPrev", (KeybinderHandler) keybind_prev_handler); keybinder_unbind("XF86AudioNext", (KeybinderHandler) keybind_next_handler); keybinder_unbind("XF86AudioMedia", (KeybinderHandler) keybind_media_handler); #endif g_option_context_free(cwin->cmd_context); g_slice_free(struct con_win, cwin); }