?? save.c
字號:
#include <gtk/gtk.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include "main.h"#include "custom.h"#include "support.h"#include "misc.h"// =========================================================char* GetScrollTextFile (int applet);void GetListRegCode(char* strRegCode, GtkWidget* dlg);#define IS_CHECKED(w) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lookup_widget (main_dlg, w)))#define GET_TEXT(w) gtk_entry_get_text (GTK_ENTRY (lookup_widget (main_dlg, w)))#define SAVE_INT(v,i) { \ char tmp[8]; \ sprintf (tmp, "%d", i); \ SaveVar(ini_section, v, tmp); }#define SAVE_UL(v,i) { \ char tmp[8]; \ sprintf (tmp, "%lx", (long unsigned int)i); \ SaveVar(ini_section, v, tmp); }#define SAVE_ENTRY(v,w) \ SaveVar(ini_section, v, gtk_entry_get_text (GTK_ENTRY (lookup_widget (main_dlg, w))))#define SAVE_CHECK(v,w) { \ widget = lookup_widget (main_dlg, w); \ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE) \ SaveVar(ini_section, v, INI_YES); \ else \ SaveVar(ini_section, v, INI_NO); }#define SAVE_CHECK_ENTRY(s,c,e) { \ widget = lookup_widget (main_dlg, c); \ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE) \ SaveVar(ini_section, s, gtk_entry_get_text (GTK_ENTRY (lookup_widget (main_dlg, e)))); \ else \ SaveVar(ini_section, s, INI_NO); }// =========================================================guint8* m_aiIconFlag;void SaveTreeMenu(GtkCTree* ptc, GtkCTreeNode* item, guint32* pidMenu, guint32 idLevel){ GtkCTreeNode* child = NULL; char strItem[256], *strText, strCaption[256]; ITEM_DATA* pItemData; if (item == NULL || ptc == NULL) { --(*pidMenu); return; } sprintf (strCaption, "%s%d", INI_MENU_TEXT_, *pidMenu); gtk_ctree_get_node_info (ptc, item, &strText, NULL, NULL, NULL, NULL, NULL, NULL, NULL); SaveVar (applet_info[current_applet].name, strCaption, strText); sprintf (strCaption, "%s%d",INI_MENU_LEVEL_, *pidMenu); sprintf (strItem, "%d", idLevel); SaveVar(applet_info[current_applet].name, strCaption, strItem); pItemData=(ITEM_DATA*)gtk_ctree_node_get_row_data (ptc, item); if (pItemData != NULL) { sprintf (strCaption, "%s%d",INI_MENU_URL_, *pidMenu); SaveVar(applet_info[current_applet].name, strCaption, pItemData->strURL); if (pItemData->iIconIndex >=0) { /* m_aiIconFlag.SetAtGrow(m_astrIconList.GetSize(),0); if( m_aiIconFlag[pItemData->iIconIndex] != 1 ) { sprintf (strCaption, "%s%d",INI_ICON_, m_iIndex); SaveVar( applet_info[current_applet].name, strCaption, m_astrIconList[pItemData->iIconIndex] ); m_aiIconFlag.SetAt(pItemData->iIconIndex,1); //salvo in questo vettore la posizione in cui o mem. l'icona //nelle impostazioni //m_uiIconPos[pItemData->iIconIndex]=m_iIndex; m_aiIconPos.SetAtGrow(pItemData->iIconIndex,m_iIndex); //salvo una stringa nulla nella posizione successiva //per impdeire fusioni con le impostazioni precedenti sprintf (strCaption, "%s%d",INI_ICON_, m_iIndex+1); SaveVar( applet_info[current_applet].name, strCaption, _T("") ); m_iIndex++; } sprintf (strCaption, "%s%d",INI_MENU_ICON_, *pidMenu); CString strPos; strPos.Format(_T("%d"), m_aiIconPos[pItemData->iIconIndex] ); SaveVar(applet_info[current_applet].name, strCaption, strPos ); */ } } if ((child = GTK_CTREE_ROW (item)->children) != NULL) { //se e' un nodo salvo anche se e' espanso o no sprintf (strCaption, "%s%d",INI_MENU_STATE, *pidMenu); if (GTK_CTREE_ROW (item)->expanded) SaveVar(applet_info[current_applet].name, strCaption, "1"); else SaveVar(applet_info[current_applet].name, strCaption, "0"); sprintf (strCaption, "%s%d",INI_MENU_LINK_, *pidMenu); sprintf (strItem, "%d", *pidMenu+1); SaveVar(applet_info[current_applet].name, strCaption, strItem); ++(*pidMenu); SaveTreeMenu( ptc, child , pidMenu, idLevel+1); } else { sprintf (strCaption, "%s%d",INI_MENU_LINK_, *pidMenu); SaveVar(applet_info[current_applet].name, strCaption, ""); } if ((child = GTK_CTREE_ROW (item)->sibling) != NULL) { ++(*pidMenu); SaveTreeMenu( ptc, child, pidMenu, idLevel ); } else { sprintf (strCaption, "%s%d",INI_MENU_TEXT_, (*pidMenu)+1); SaveVar(applet_info[current_applet].name, strCaption, ""); }}void SaveTreeCtrl(GtkCTree* ptc, GtkCTreeNode* item, char x, char y, char* pcLink, char cParent){ char strCaption[256]; GtkCTreeNode* child = NULL; ITEM_DATA* pItemData; if (item == NULL || ptc == NULL) return; sprintf (strCaption, "%s%c%c", INI_MENU_TEXT_, x, y); { gchar* strText; gtk_ctree_get_node_info (ptc, item, &strText, NULL, NULL, NULL, NULL, NULL, NULL, NULL); SaveVar (applet_info[current_applet].name, strCaption, strText); } pItemData=(ITEM_DATA*)gtk_ctree_node_get_row_data (ptc, item); if( pItemData != NULL ) { sprintf (strCaption, "%s%c%c",INI_MENU_URL_, x, y); SaveVar(applet_info[current_applet].name, strCaption, pItemData->strURL ); sprintf (strCaption, "%s%c%c",INI_MENU_TARGET_, x, y); SaveVar(applet_info[current_applet].name, strCaption, pItemData->strNewFrameName ); } if ((child = GTK_CTREE_ROW (item)->children) != NULL) { //se e' un nodo salvo anche se e' espanso o no sprintf (strCaption, "%s%c%c", INI_MENU_STATE, x, y); if (GTK_CTREE_ROW (item)->expanded) SaveVar(applet_info[current_applet].name, strCaption, "1"); else SaveVar(applet_info[current_applet].name, strCaption, "0"); (*pcLink)=GetMenuLinkNext(applet_info[current_applet].name, (*pcLink)); sprintf (strCaption, "%s%c%c", INI_MENU_LINK_, x, y); SaveVar(applet_info[current_applet].name, strCaption, pcLink); SaveTreeCtrl(ptc, child , *pcLink, '0', pcLink, x); } else if (pItemData != NULL) { if (pItemData->bBack) { char tmp[2] = { cParent, 0 }; sprintf (strCaption, "%s%c%c", INI_MENU_LINK_, x, y); SaveVar(applet_info[current_applet].name, strCaption, tmp); } else { sprintf (strCaption, "%s%c%c", INI_MENU_LINK_, x, y); SaveVar(applet_info[current_applet].name, strCaption, ""); } } if ((child = GTK_CTREE_ROW (item)->sibling) != NULL) { SaveTreeCtrl(ptc, child, x, GetMenuLinkNext(applet_info[current_applet].name, y), pcLink, cParent); } else { //salvo anche una voce successiva vuota per evitare "fusioni" con le //impostazioni precedenti sprintf (strCaption, "%s%c%c", INI_MENU_TEXT_, x, GetMenuLinkNext(applet_info[current_applet].name, y)); SaveVar(applet_info[current_applet].name, strCaption, ""); }}// =========================================================void save_dialog_data ( /* char* lpcstrPathFileName*/ ){ char strtmp[256], ini_section[64], section[64]; int items, index; GtkWidget* widget = NULL; IMAGE_INFO *info; if (current_applet != -1) strcpy (ini_section, applet_info[current_applet].name); switch (current_dialog) { case DLG_STEP0: SaveVar(INI_APP_SECTION, INI_LAST_APPLET_CONFIGURED, GET_TEXT("applet_entry")); /* ((CAppletWzdDlg*)m_pParentWnd)->m_strCurrentApplet=strTmp; */ if (IS_CHECKED("cat_banner")) strcpy (strtmp, "1"); else if (IS_CHECKED("cat_fractals")) strcpy (strtmp, "2"); else if (IS_CHECKED("cat_image")) strcpy (strtmp, "3"); else if (IS_CHECKED("cat_3d")) strcpy (strtmp, "4"); else if (IS_CHECKED("cat_navigation")) strcpy (strtmp, "5"); else // if (IS_CHECKED("cat_other")) strcpy (strtmp, "6"); SaveVar(INI_APP_SECTION, INI_LAST_APPLET_CATEGORY, strtmp); break; case DLG_TEXTSTYLE: SAVE_ENTRY (INI_TEXTMODE, "text_type_entry"); { char* txt; txt = gtk_editable_get_chars (GTK_EDITABLE (lookup_widget (main_dlg, "text")), 0, -1); if (strchr (txt, '\n') == NULL) strcat(txt, "\r\n"); ReadWriteFileScrollText(current_applet, txt, 1); //write } SAVE_ENTRY (INI_TEXTVSPACE, "v_spac"); SAVE_ENTRY (INI_TEXTSPEED, "speed"); SAVE_ENTRY (INI_TEXTOFFSET, "y_offset"); SAVE_ENTRY (INI_TEXTSINANGLE, "sine_angle"); SAVE_ENTRY (INI_TEXTSINEAMPL, "sine_amplitude"); SAVE_ENTRY (INI_TEXTSINSPEED, "sine_speed"); SAVE_ENTRY (INI_TEXTJUMPAMP, "jump_amplitude"); SAVE_ENTRY (INI_TEXTJUMPSPEED, "jump_speed"); SAVE_CHECK (INI_TEXTSHADOW, "shadow"); SAVE_INT (INI_TEXT_COLORRED, dlg_textcolor_red); SAVE_INT (INI_TEXT_COLORGREEN, dlg_textcolor_green); SAVE_INT (INI_TEXT_COLORBLU, dlg_textcolor_blue); // SAVE_CHECK (INI_STANDARD_FONT, "standard"); SAVE_ENTRY (INI_TEXT_FONT, "font_entry"); SAVE_ENTRY (INI_TEXT_SIZE, "size_entry"); SAVE_ENTRY (INI_TEXT_SIZE_MIN, "min_entry"); SAVE_ENTRY (INI_TEXT_SIZE_MAX, "max_entry"); SAVE_CHECK (INI_TEXT_ITALIC, "italic"); SAVE_CHECK (INI_TEXT_BOLD, "bold"); SAVE_INT (INI_TEXTS_COLORRED, dlg_textscolor_red); SAVE_INT (INI_TEXTS_COLORGREEN, dlg_textscolor_green); SAVE_INT (INI_TEXTS_COLORBLU, dlg_textscolor_blue); break; case DLG_EXPERTMODE: SAVE_ENTRY (INI_EX_MEMDELAY, "memory"); SAVE_ENTRY (INI_EX_TASK_PRIORITY, "task"); SAVE_ENTRY (INI_EX_MINSYNC, "minsync"); SAVE_CHECK (INI_FIXNETSCAPE, "netscape"); SAVE_ENTRY (INI_STATUSMSG, "statusbar"); SAVE_ENTRY (INI_NOJAVAMSG, "nojava"); widget = lookup_widget (main_dlg, "enable_image"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE) SAVE_ENTRY (INI_OVERIMG, "image"); else SaveVar(ini_section, INI_OVERIMG, INI_NO); SAVE_ENTRY (INI_OVERIMGX, "xoffset"); SAVE_ENTRY (INI_OVERIMGY, "yoffset"); break; /* case DLG_REGCODE: */ case DLG_REGISTRATION: { char strRegCode[256], *strTmp; GtkWidget* label = GTK_BIN (lookup_widget (main_dlg, "domains"))->child; if (label != NULL) { gtk_label_get (GTK_LABEL (label), &strTmp); SaveVar(INI_APP_SECTION, INI_DOMAIN, strTmp); } GetListRegCode(strRegCode, main_dlg); SaveVar(INI_APP_SECTION, INI_REGCODE, strRegCode); if (current_dialog == DLG_REGISTRATION) { if (IS_CHECKED ("enable_link")) SaveVar (ini_section, INI_REGLINK, INI_NO); else SAVE_ENTRY (INI_REGLINK, "link_entry"); if (!(IS_CHECKED ("enable_target"))) { SaveVar(ini_section, INI_REGNEWFRAME, INI_NO); SaveVar(ini_section, INI_REGFRAMENAME, "_blank"); } else { SaveVar(ini_section, INI_REGNEWFRAME, INI_YES); strTmp = GET_TEXT ("mode_entry"); if (strcmp (strTmp, _("other target...")) == 0) SAVE_ENTRY (INI_REGFRAMENAME, "target_entry"); else SaveVar(ini_section, INI_REGFRAMENAME, strTmp); } } } break; case DLG_BLOBS: SAVE_ENTRY (INI_WIDTH, "width"); SAVE_ENTRY (INI_HEIGHT, "height"); SAVE_ENTRY (INI_NBLOBS, "number_entry"); SAVE_ENTRY (INI_BVAL1, "i"); SAVE_ENTRY (INI_BVAL2, "j"); SAVE_ENTRY (INI_BVAL3, "k"); SAVE_ENTRY (INI_RES, "resolution_entry"); SAVE_ENTRY (INI_MINSPEED, "min_entry"); SAVE_ENTRY (INI_COLORPAL, "color_entry"); SAVE_CHECK (INI_SINEMODE, "sine"); SAVE_CHECK (INI_STARSHAPE, "star"); SAVE_CHECK (INI_NEGCOLOR, "negative"); break; case DLG_ANBLUR: SAVE_ENTRY (INI_WIDTH, "width"); SAVE_ENTRY (INI_HEIGHT, "height"); SAVE_ENTRY (INI_FORMAT_VALUE, "image_type"); SAVE_ENTRY (INI_IMGS_VALUE, "frames"); SAVE_ENTRY (INI_NIMGS, "num"); SAVE_CHECK (INI_PINGPONG, "ping_pong"); SAVE_CHECK (INI_DOUBLESIZE, "double_size"); SAVE_ENTRY (INI_SPEED, "play"); SAVE_ENTRY (INI_PINGPAUSE, "ping_pause"); SAVE_ENTRY (INI_PONGPAUSE, "pong_pause"); SAVE_ENTRY (INI_AUDIOPING, "ping_audio"); SAVE_ENTRY (INI_AUDIOPONG, "pong_audio"); break; case DLG_ANFYBUMP: SAVE_ENTRY (INI_IMAGE_FILE, "image"); SAVE_ENTRY (INI_WIDTH, "width"); SAVE_ENTRY (INI_HEIGHT, "height"); SAVE_ENTRY (INI_RES, "resolution_entry"); SAVE_CHECK_ENTRY (INI_ALT_IMAGE_FILE, "alt_image", "bump_image"); SAVE_ENTRY (INI_BUMP_HEIGHT, "bump_entry"); SAVE_ENTRY (INI_LIGHTSIZE, "light_entry"); SAVE_CHECK (INI_INTERACTIVE_MODE, "interactive"); SAVE_ENTRY (INI_ANGLE_X, "anglex"); SAVE_ENTRY (INI_ANGLE_Y, "angley"); SAVE_ENTRY (INI_LMIN, "min"); SAVE_ENTRY (INI_LMAX, "max"); SAVE_ENTRY (INI_LPOW, "power"); break; case DLG_ANFADE: SAVE_ENTRY (INI_WIDTH, "width"); SAVE_ENTRY (INI_HEIGHT, "height"); SAVE_ENTRY (INI_RES, "resolution_entry"); widget = lookup_widget (main_dlg, "image_list"); items = GTK_CLIST (widget)->rows; for(index = 0; index < items; index++) { info = gtk_clist_get_row_data (GTK_CLIST (widget), index); sprintf (section, "%s%d", INI_IMAGE_, index+1); SaveVar(ini_section, section, info->image); sprintf (section, "%s%d", INI_LINK_, index+1); SaveVar(ini_section, section, info->link); sprintf (section, "%s%d", INI_STATUS_MSG_, index+1); SaveVar(ini_section, section, info->status); } sprintf (section, "%s%d", INI_IMAGE_, index+1); SaveVar(ini_section, section, ""); SAVE_CHECK (INI_PROGFADE, "progressive"); SAVE_ENTRY (INI_FRAME_SPEED, "frame_speed"); SAVE_ENTRY (INI_PAUSE, "pause"); break; case DLG_ANFLAG: SAVE_ENTRY (INI_WIDTH, "width"); SAVE_ENTRY (INI_HEIGHT, "height"); SAVE_ENTRY (INI_FLAG_RES, "resolution_entry"); SAVE_ENTRY (INI_FLAG_PATTERN, "pattern_entry"); SAVE_ENTRY (INI_WIND_SPEED, "speed"); SAVE_ENTRY (INI_WIND, "wind_entry"); SAVE_ENTRY (INI_FLAG_NATION, "nation_entry"); SAVE_ENTRY (INI_CURVE, "curve_entry"); SAVE_INT (INI_BACK_COLOR_R, dlg_backcolor_red); SAVE_INT (INI_BACK_COLOR_G, dlg_backcolor_green); SAVE_INT (INI_BACK_COLOR_B, dlg_backcolor_blue); SAVE_ENTRY (INI_PIXDENSITY, "pix_entry"); break; case DLG_CUBEMENU: SAVE_ENTRY (INI_WIDTH, "width"); SAVE_ENTRY (INI_HEIGHT, "height"); SAVE_ENTRY (INI_RES, "resolution_entry"); widget = lookup_widget (main_dlg, "image_list"); items = GTK_CLIST (widget)->rows;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -