callback.c
来自「ANFY特效」· C语言 代码 · 共 2,174 行 · 第 1/5 页
C
2,174 行
{ message_box(_("Error ! Problem when copying file in applet directory"), 0); g_free (filename); return; } gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "back_image")), file); } g_free (filename);}void on_image_browse (GtkWidget *widget, gpointer user_data){ char* filename, szImgFormat[10], buf[16], strWorkDir[1024]; unsigned int iWidth; unsigned int iHeight; file_browse ("Open", &filename); if (filename == NULL) return; GetAppletPath(current_applet, strWorkDir); if (GetFormatAndSize(filename, szImgFormat, &iWidth, &iHeight) == 1) { if( current_dialog == DLG_ROTATE || current_dialog == DLG_WARP ) { if( !IsTwoPower(iWidth) || !IsTwoPower(iHeight) ) { message_box(_("Error ! The image size must be powers of 2, es: 64*64,128*64,256*128,16*16..."), 0); g_free (filename); return; } } if( current_dialog == DLG_WOBBLER ) { if( !IsTwoPower(iWidth) || !IsTwoPower(iHeight) ) message_box(_("Warning: this applet runs faster using images of special sizes such as 32x32 or 256x256!"), 0); } if( current_dialog == DLG_TUNNEL ) { sprintf (buf, "%d", iHeight); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "image_height")), buf); sprintf (buf, "%d", iWidth); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "image_width")), buf); } else if (current_dialog != DLG_ROTATE && current_dialog != DLG_TUNNEL3D && current_dialog != DLG_WARP && current_dialog != DLG_WOBBLER) { sprintf (buf, "%d", iHeight); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "height")), buf); sprintf (buf, "%d", iWidth); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "width")), buf); dlg_oldres=1; /* OnSelchangeCboRes(); */ } if( current_dialog == DLG_VOXEL ) { if( iWidth != 256 || iHeight != 256) { message_box(_("Error ! The image size must be 256*256"), 0); g_free (filename); return; } } { char szSourcePath[1024], file[1024]; PathFromFile(filename, szSourcePath); FileFromPath(filename, file); if( !MyCopyFile(szSourcePath, strWorkDir, file)) { message_box(_("Error ! Problem when copying file in applet directory"), 0); g_free (filename); return; } gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "image")), file); } } g_free (filename);}void OnBrowseFileImg (GtkWidget *widget, gpointer user_data){ char* filename, szImgFormat[10], strWorkDir[1024], buf[16]; unsigned int iWidth, iWidthAlt; unsigned int iHeight, iHeightAlt; file_browse ("Open", &filename); if (filename == NULL) return; GetAppletPath(current_applet, strWorkDir); if (GetFormatAndSize(filename, szImgFormat, &iWidth, &iHeight) == 1) { if (current_dialog == DLG_ANFYBUMP) { char* strSecondImage; strSecondImage = gtk_entry_get_text (GTK_ENTRY (lookup_widget (main_dlg, "bump_image"))); if (strlen (strSecondImage) != 0) { char strTmp[1024]; GetAppletPath(current_applet, strTmp); strcat (strTmp, "/"); strcat (strTmp, strSecondImage); if (GetFormatAndSize (strTmp, szImgFormat, &iWidthAlt, &iHeightAlt) == TRUE) { if( iWidth != iWidthAlt || iHeight != iHeightAlt) { message_box (_("Error ! The bump image and altenative bump image must be of the same size"), 0); g_free (filename); return; } } else { g_free (filename); return; } } } sprintf (buf, "%d", iHeight); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "height")), buf); sprintf (buf, "%d", iWidth); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "width")), buf); dlg_oldres = 1; /* if (current_dialog != DLG_ANLENS) { OnSelchangeCboRes(); } */ { char szSourcePath[1024], file[1024]; PathFromFile(filename, szSourcePath); FileFromPath(filename, file); if( !MyCopyFile(szSourcePath, strWorkDir, file)) { message_box(_("Error ! Problem when copying file in applet directory"), 0); g_free (filename); return; } gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "image")), file); } /* if( m_uiID == IDD_ANLAKE ) { OnHalfreflect(); } */ } g_free (filename);}void on_progress (GtkWidget *widget, gpointer user_data){ GtkWidget *w; w = lookup_widget (main_dlg, "pen_progr"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) == TRUE) gtk_widget_set_sensitive (w, TRUE); else gtk_widget_set_sensitive (w, FALSE);}// =========================================================// STEP0 dialog callbacksvoid on_step0_preview_all (GtkWidget *widget, gpointer user_data){ char str[1024]; strcpy (str, g_strAppPath); strcat (str, "/"); strcat (str, g_strHelpDir); strcat (str, "/samples.html"); StartBrowser (str);}void on_step0_combo_applet_changed (GtkWidget *widget, gpointer user_data){ int i; GtkWidget* label; gchar *name, *desc = "", buf[50]; name = gtk_entry_get_text (GTK_ENTRY (widget)); label = lookup_widget (widget->parent, "description"); // Update the description for (i = 0; i < NUMAPPLETS; i++) if (strcmp (applet_info[i].name, name) == 0) { desc = applet_info[i].description; current_applet = i; break; } gtk_label_set_text (GTK_LABEL (label), desc); // Update the 'Help' menu sprintf (buf, _("Applet %s info"), name); label = lookup_widget (widget->parent, "applet_info"); gtk_label_set_text (GTK_LABEL(GTK_BIN(label)->child), buf);}void on_step0_category_changed (GtkWidget *widget, gpointer user_data){ GtkWidget *combo; GList *glist; combo = lookup_widget (widget->parent, "applet_combo"); glist = NULL; switch ((int)user_data) { // Banner / Slideshow case 1: { glist = g_list_append (glist, applet_info[APPLET_BOOKFLIP].name); glist = g_list_append (glist, applet_info[APPLET_ANFADE].name); glist = g_list_append (glist, applet_info[APPLET_MOSAIC].name); } break; // Fractals & ALife case 2: { glist = g_list_append (glist, applet_info[APPLET_FLOZOIDS].name); glist = g_list_append (glist, applet_info[APPLET_ANFRACT].name); glist = g_list_append (glist, applet_info[APPLET_LIFE2D].name); glist = g_list_append (glist, applet_info[APPLET_MANDEL].name); } break; // Image effects case 3: { glist = g_list_append (glist, applet_info[APPLET_ANFYBUMP].name); glist = g_list_append (glist, applet_info[APPLET_DEFORM].name); glist = g_list_append (glist, applet_info[APPLET_FIREWORKS].name); glist = g_list_append (glist, applet_info[APPLET_HUEROT].name); glist = g_list_append (glist, applet_info[APPLET_ANLAKE].name); glist = g_list_append (glist, applet_info[APPLET_ANLENS].name); glist = g_list_append (glist, applet_info[APPLET_ROTATE].name); glist = g_list_append (glist, applet_info[APPLET_ANFYSNOW].name); glist = g_list_append (glist, applet_info[APPLET_WARP].name); glist = g_list_append (glist, applet_info[APPLET_ANWATER].name); glist = g_list_append (glist, applet_info[APPLET_WOBBLER].name); } break; // 3D Applets case 4: { glist = g_list_append (glist, applet_info[APPLET_ANFY3D].name); glist = g_list_append (glist, applet_info[APPLET_FLUID].name); glist = g_list_append (glist, applet_info[APPLET_GALAXY].name); glist = g_list_append (glist, applet_info[APPLET_TMAPCUBE].name); glist = g_list_append (glist, applet_info[APPLET_ANTUNNEL].name); glist = g_list_append (glist, applet_info[APPLET_TUNNEL3D].name); glist = g_list_append (glist, applet_info[APPLET_ANVOXEL].name); glist = g_list_append (glist, applet_info[APPLET_WORMHOLE].name); } break; // Navigation menu case 5: { glist = g_list_append (glist, applet_info[APPLET_CUBEMENU].name); glist = g_list_append (glist, applet_info[APPLET_MORPHMENU].name); glist = g_list_append (glist, applet_info[APPLET_TREEMENU].name); glist = g_list_append (glist, applet_info[APPLET_WHEEL].name); } break; // Other case 6: { glist = g_list_append (glist, applet_info[APPLET_ANFYCAM].name); glist = g_list_append (glist, applet_info[APPLET_ANFYPAINT].name); glist = g_list_append (glist, applet_info[APPLET_BLOBS].name); glist = g_list_append (glist, applet_info[APPLET_ANBLUR].name); glist = g_list_append (glist, applet_info[APPLET_FIRE].name); glist = g_list_append (glist, applet_info[APPLET_ANFLAG].name); glist = g_list_append (glist, applet_info[APPLET_FLAGLOAD].name); glist = g_list_append (glist, applet_info[APPLET_PLASMA].name); glist = g_list_append (glist, applet_info[APPLET_SOLIDSCROLLER].name); glist = g_list_append (glist, applet_info[APPLET_TSCROLLER].name); } break; } gtk_combo_set_popdown_strings (GTK_COMBO (combo), glist); g_list_free (glist);}// =========================================================// EXPERT dialog callbacksvoid on_expert_standard (GtkWidget *widget, gpointer user_data){ gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "memory")), "1000"); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "task")), "3"); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "minsync")), "10"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (main_dlg, "netscape")), FALSE);}void on_expert_compatibility (GtkWidget *widget, gpointer user_data){ gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "memory")), "15"); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "task")), "1"); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "minsync")), "30"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (main_dlg, "netscape")), TRUE);}void on_expert_speed (GtkWidget *widget, gpointer user_data){ gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "memory")), "1000"); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "task")), "6"); gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "minsync")), "2"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (main_dlg, "netscape")), FALSE);}void on_expert_enable_over (GtkWidget *widget, gpointer user_data){ gboolean enable; enable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (lookup_widget (main_dlg, "enable_image"))); gtk_widget_set_sensitive (lookup_widget (main_dlg, "browse"), enable); gtk_widget_set_sensitive (lookup_widget (main_dlg, "xoffset"), enable); gtk_widget_set_sensitive (lookup_widget (main_dlg, "yoffset"), enable); gtk_widget_set_sensitive (lookup_widget (main_dlg, "image"), enable); if (!enable) gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "image")), "");}void on_expert_browse (GtkWidget *widget, gpointer user_data){ char* filename, strAppletDir[1024]; file_browse ("Open", &filename); if (filename == NULL) return; GetAppletPath(current_applet, strAppletDir); { char szSourcePath[1024], file[1024]; PathFromFile(filename, szSourcePath); FileFromPath(filename, file); if (!MyCopyFile(szSourcePath, strAppletDir, file)) { message_box(_("Error ! Problem when copying file in applet directory"), 0); g_free (filename); return; } gtk_entry_set_text (GTK_ENTRY (lookup_widget (main_dlg, "image")), file); } g_free (filename);}void on_step1_clipboard (GtkWidget *widget, gpointer this_text){ gtk_editable_select_region (GTK_EDITABLE (this_text), 0, gtk_text_get_length (GTK_TEXT (this_text))); gtk_editable_copy_clipboard (GTK_EDITABLE (this_text));}// =========================================================// REGISTRATION dialog callbacksvoid GetListRegCode(char* strRegCode, GtkWidget* dlg){ GtkCList *cl; char* ptr; int i; strcpy (strRegCode, ""); cl = GTK_CLIST (lookup_widget (dlg, "regcode_list")); for (i = 0; i < cl->rows; i++) { gtk_clist_get_text (cl, i, 0, &ptr); strcat (strRegCode, ptr); if (i+1 < cl->rows) strcat (strRegCode, "+"); }}void on_add_code (GtkWidget *widget, gpointer user_data){ GtkWidget *entry; char* row[2]; entry = lookup_widget (widget->parent, "regcode_entry"); row[0] = gtk_entry_get_text (GTK_ENTRY (entry)); if (strlen (row[0]) == 0) return; row[1] = NULL; gtk_clist_append (GTK_CLIST (lookup_widget (widget->parent, "regcode_list")), row); gtk_entry_set_text (GTK_ENTRY (entry), ""); gtk_widget_set_sensitive (lookup_widget (widget->parent, "regcode_remove"), TRUE); { char* strDomain, strItem[256]; // strDomain = gtk_entry_get_text (GTK_ENTRY (lookup_widget (widget->parent, "domain_entry"))); gtk_label_get (GTK_LABEL (GTK_BIN (lookup_widget (widget->parent, "domains"))->child), &strDomain); GetListRegCode(strItem, widget->parent); printf ("aa-%s-%s\n", strDomain,strItem); SaveVar(INI_APP_SECTION, strDomain, strItem); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?