/** * keybinder_bind: (skip) * @keystring: an accelerator description (gtk_accelerator_parse() format) * @handler: callback function * @user_data: data to pass to @handler * * Grab a key combination globally and register a callback to be called each * time the key combination is pressed. * * This function is excluded from introspected bindings and is replaced by * keybinder_bind_full. * * Returns: %TRUE if the accelerator could be grabbed */ gboolean keybinder_bind (const char *keystring, KeybinderHandler handler, void *user_data) { return keybinder_bind_full(keystring, handler, user_data, NULL); }
void keybinds_conf_load (void) { FILE *fpConfig; char ConfFilePath [512]; char Getline[512]; char Mod[2]; char *pBuff = NULL; #ifdef __linux__ sprintf(ConfFilePath ,"%s/keybinds.ini" ,DirConf); #elif __WIN32 sprintf(ConfFilePath ,"%s\\keybinds.ini" ,DirConf); #endif fpConfig = fopen(ConfFilePath , "r"); if (fpConfig == NULL) { log_error(true,"**Warning: Couldn't load config file 'keybinds.ini' - Using defaults."); keybinds_conf_create (); return; } #ifdef __linux__ keybinder_unbind_all(Hotkey_FUP); keybinder_unbind_all(Hotkey_SS_A_UP); keybinder_unbind_all(Hotkey_SS_W_UP); keybinder_unbind_all(Hotkey_SS_F_UP); keybinder_unbind_all(Hotkey_SS_A_CAP); keybinder_unbind_all(Hotkey_SS_W_CAP); keybinder_unbind_all(Hotkey_SS_F_CAP); keybinder_unbind_all(Hotkey_OPEN); #elif _WIN32 int i; for ( i = 0 ; i < HOTKEY_COUNT ; ++i) UnregisterHotKey(hWndGTK, 200+i); #endif while(fgets (Getline , 512 , fpConfig) != NULL) { if(strncmp(Getline, "Hotkey_FUP" , strlen("Hotkey_FUP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_FUP, strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_A_UP" , strlen("Hotkey_SS_A_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_A_UP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_W_UP" , strlen("Hotkey_SS_W_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_W_UP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_F_UP" , strlen("Hotkey_SS_F_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_F_UP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_A_CAP" , strlen("Hotkey_SS_A_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_A_CAP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_W_CAP" , strlen("Hotkey_SS_W_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_W_CAP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_SS_F_CAP" , strlen("Hotkey_SS_F_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_SS_F_CAP,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Hotkey_OPEN" , strlen("Hotkey_OPEN")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; snprintf(Hotkey_OPEN,strlen(pBuff),"%s",pBuff); } else if(strncmp(Getline, "Enable_HK_FUP" , strlen("Enable_HK_FUP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_FUP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_A_UP" , strlen("Enable_HK_SS_A_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_A_UP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_W_UP" , strlen("Enable_HK_SS_W_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_W_UP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_F_UP" , strlen("Enable_HK_SS_F_UP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_F_UP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_A_CAP" , strlen("Enable_HK_SS_A_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_A_CAP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_W_CAP" , strlen("Enable_HK_SS_W_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_W_CAP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_SS_F_CAP" , strlen("Enable_HK_SS_F_CAP")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_SS_F_CAP = atoi(Mod); } else if(strncmp(Getline, "Enable_HK_OPEN" , strlen("Enable_HK_OPEN")) == 0) { pBuff = strstr(Getline , "="); pBuff += 2; strncpy(Mod,pBuff,1); bHotkey_OPEN = atoi(Mod); } } pBuff = NULL; fclose(fpConfig); #ifdef __linux__ char MenuLabel[128]; if(bHotkey_FUP) { keybinder_bind_full(Hotkey_FUP, file_chooser_start, NULL, NULL); sprintf(MenuLabel,"Upload File(s)\t\t%s",Hotkey_FUP ); gtk_menu_item_set_label ( GTK_MENU_ITEM(menuFileUp), MenuLabel); } else gtk_menu_item_set_label ( GTK_MENU_ITEM(menuFileUp), "Upload File"); if (bHotkey_SS_A_UP) { keybinder_bind_full(Hotkey_SS_A_UP, take_screenshot, (void*)1, NULL); sprintf(MenuLabel,"Capture Area & UP\t%s", Hotkey_SS_A_UP); gtk_menu_item_set_label (GTK_MENU_ITEM(menuCapUp), MenuLabel); } else gtk_menu_item_set_label (GTK_MENU_ITEM(menuCapUp), "Capture Area & UP"); if (bHotkey_SS_W_UP) keybinder_bind_full(Hotkey_SS_W_UP, take_screenshot, (void*)2, NULL); if (bHotkey_SS_F_UP) keybinder_bind_full(Hotkey_SS_F_UP, take_screenshot, (void*)3, NULL); if (bHotkey_SS_A_CAP) { keybinder_bind_full(Hotkey_SS_A_CAP, take_screenshot, (void*)4, NULL); sprintf(MenuLabel,"Capture Area\t\t%s", Hotkey_SS_A_CAP); gtk_menu_item_set_label (GTK_MENU_ITEM(menuCap) , MenuLabel); } else gtk_menu_item_set_label (GTK_MENU_ITEM(menuCap) , "Capture Area"); if (bHotkey_SS_W_CAP) keybinder_bind_full(Hotkey_SS_W_CAP, take_screenshot, (void*)5, NULL); if (bHotkey_SS_F_CAP) keybinder_bind_full(Hotkey_SS_F_CAP, take_screenshot, (void*)6, NULL); if (bHotkey_OPEN) { keybinder_bind_full(Hotkey_OPEN, pomfit_open_links, NULL, NULL); sprintf(MenuLabel,"Open URL(s)\t\t%s", Hotkey_OPEN); gtk_menu_item_set_label (GTK_MENU_ITEM(menuOpen) , MenuLabel); } else gtk_menu_item_set_label (GTK_MENU_ITEM(menuOpen) , "Open URL(s)"); #elif _WIN32 /* Win Key Code { 0, 2, 1, 4, 8} NULL , ALT , CTRL , SHIFT , WIN */ int len; int Key[HOTKEY_COUNT] ; int Modes[HOTKEY_COUNT][2]; char Bind[HOTKEY_COUNT][64]; strcpy(Bind[0],Hotkey_FUP); strcpy(Bind[1],Hotkey_SS_A_UP); strcpy(Bind[2],Hotkey_SS_W_UP); strcpy(Bind[3],Hotkey_SS_F_UP); strcpy(Bind[4],Hotkey_SS_A_CAP); strcpy(Bind[5],Hotkey_SS_W_CAP); strcpy(Bind[6],Hotkey_SS_F_CAP); strcpy(Bind[7],Hotkey_OPEN); for (i = 0 ; i < HOTKEY_COUNT ; ++i) { len = strlen(Bind[i]); Key[i] = Bind[i][len-1]; pBuff = strtok(Bind[i], ">"); if(pBuff != NULL) { if(pBuff[1] == 'C') Modes[i][0] = 2; else if (pBuff[1] == 'S') Modes[i][0] = 4; else if (pBuff[1] == 'A') Modes[i][0] = 1; else if (pBuff[1] == 'W') Modes[i][0] = 8; else Modes[i][0] = 0; } else continue; pBuff = strtok(NULL, ">"); if(pBuff != NULL) { if(pBuff[1] == 'C') Modes[i][1] = 2; else if (pBuff[1] == 'S') Modes[i][1] = 4; else if (pBuff[1] == 'A') Modes[i][1] = 1; else if (pBuff[1] == 'W') Modes[i][1] = 8; else Modes[i][1] = 0; } } pBuff = NULL; if(bHotkey_FUP) RegisterHotKey(hWndGTK, HOTKEY_FILEUP, Modes[0][1] | Modes[0][0], Key[0]); if (bHotkey_SS_A_UP) RegisterHotKey(hWndGTK, HOTKEY_AREA_SS_UP, Modes[1][1] | Modes[1][0], Key[1]); if (bHotkey_SS_W_UP) RegisterHotKey(hWndGTK, HOTKEY_WIN_SS_UP, Modes[2][1] | Modes[2][0], Key[2]); if (bHotkey_SS_F_UP) RegisterHotKey(hWndGTK, HOTKEY_FULL_SS_UP, Modes[3][1] | Modes[3][0], Key[3]); if (bHotkey_SS_A_CAP) RegisterHotKey(hWndGTK, HOTKEY_AREA_SS_CAP, Modes[4][1] | Modes[4][0], Key[4]); if (bHotkey_SS_W_CAP) RegisterHotKey(hWndGTK, HOTKEY_WIN_SS_CAP, Modes[5][1] | Modes[5][0], Key[5]); if (bHotkey_SS_F_CAP) RegisterHotKey(hWndGTK, HOTKEY_FULL_SS_CAP, Modes[6][1] | Modes[6][0], Key[6]); if (bHotkey_OPEN) RegisterHotKey(hWndGTK, HOTKEY_OPEN, Modes[7][1] | Modes[7][0], Key[7]); #endif }