⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 options.c

📁 添加系统调用。。。在LINUX下添加一个新的系统调用。在文件中添加自己的系统调用的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*cellwriter -- a character recognition input methodCopyright (C) 2007 Michael Levin <risujin@risujin.org>This program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.*/#include "config.h"#include "common.h"#include "recognize.h"#include <stdlib.h>#include <string.h>#ifdef HAVE_GNOME#include <libgnome/libgnome.h>#endif/* preprocess.c */int ignore_stroke_dir, ignore_stroke_num;/* cellwidget.c */extern int cell_width, cell_height, cell_cols_pref, cell_rows_pref,           train_on_input, right_to_left, keyboard_enabled, xinput_enabled;extern GdkColor custom_active_color, custom_inactive_color,                custom_ink_color, custom_select_color;void cell_widget_render(void);void cell_widget_set_cursor(int recreate);void cell_widget_enable_xinput(int on);/* keywidget.c */extern GdkColor custom_key_color;extern int keyboard_size;void key_widget_update_colors(void);/* statusicon.c */extern int status_menu_left_click;/*        Profile options*/static void color_sync(GdkColor *color){        profile_sync_short((short*)&color->red);        profile_sync_short((short*)&color->green);        profile_sync_short((short*)&color->blue);}void options_sync(void)/* Read or write options. Order here is important for compatibility. */{        profile_write("options");        profile_sync_int(&cell_width);        profile_sync_int(&cell_height);        profile_sync_int(&cell_cols_pref);        profile_sync_int(&cell_rows_pref);        color_sync(&custom_active_color);        color_sync(&custom_inactive_color);        color_sync(&custom_select_color);        color_sync(&custom_ink_color);        profile_sync_int(&train_on_input);        profile_sync_int(&ignore_stroke_dir);        profile_sync_int(&ignore_stroke_num);        profile_sync_int(&wordfreq_enable);        profile_sync_int(&right_to_left);        color_sync(&custom_key_color);        profile_sync_int(&keyboard_enabled);        profile_sync_int(&xinput_enabled);        profile_sync_int(&style_colors);        profile_sync_int(&status_menu_left_click);        profile_write("\n");}/*        Unicode blocks list*/static void unicode_block_toggled(GtkCellRendererToggle *renderer, gchar *path,                                  GtkListStore *blocks_store){        UnicodeBlock *block;        GtkTreePath *tree_path;        GtkTreeIter iter;        GValue value;        gboolean enabled;        int index;        /* Get the block this checkbox references */        tree_path = gtk_tree_path_new_from_string(path);        gtk_tree_model_get_iter(GTK_TREE_MODEL(blocks_store), &iter, tree_path);        index = gtk_tree_path_get_indices(tree_path)[0];        gtk_tree_path_free(tree_path);        block = unicode_blocks + index;        /* Toggle its value */        memset(&value, 0, sizeof (value));        gtk_tree_model_get_value(GTK_TREE_MODEL(blocks_store), &iter, 0,                                 &value);        enabled = !g_value_get_boolean(&value);        gtk_list_store_set(blocks_store, &iter, 0, enabled, -1);        unicode_block_toggle(index, enabled);}static GtkWidget *create_blocks_list(void){        GtkWidget *view, *scrolled;        GtkTreeIter iter;        GtkTreeViewColumn *column;        GtkListStore *blocks_store;        GtkCellRenderer *renderer;        UnicodeBlock *block;        /* Tree view */        blocks_store = gtk_list_store_new(2, G_TYPE_BOOLEAN, G_TYPE_STRING);        view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(blocks_store));        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);        gtk_tooltips_set_tip(tooltips, view,                             "Controls which blocks are enabled for "                             "recognition and appear in the training mode "                             "combo box.", NULL);        /* Column */        column = gtk_tree_view_column_new();        gtk_tree_view_insert_column(GTK_TREE_VIEW(view), column, 0);        renderer = gtk_cell_renderer_toggle_new();        g_signal_connect(G_OBJECT(renderer), "toggled",                         G_CALLBACK(unicode_block_toggled), blocks_store);        gtk_tree_view_column_pack_start(column, renderer, FALSE);        gtk_tree_view_column_add_attribute(column, renderer, "active", 0);        renderer = gtk_cell_renderer_text_new();        gtk_tree_view_column_pack_start(column, renderer, TRUE);        gtk_tree_view_column_add_attribute(column, renderer, "text", 1);        /* Fill blocks list */        block = unicode_blocks;        while (block->name) {                gtk_list_store_append(blocks_store, &iter);                gtk_list_store_set(blocks_store, &iter, 0, block->enabled,                                   1, block->name, -1);                block++;        }        /* Scrolled window */        scrolled = gtk_scrolled_window_new(NULL, NULL);        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),                                            GTK_SHADOW_ETCHED_IN);        gtk_container_add(GTK_CONTAINER(scrolled), view);        return scrolled;}/*        Options dialog*/#define CELL_WIDTH_MIN  24#define CELL_HEIGHT_MIN 48#define CELL_HEIGHT_MAX 96static GtkWidget *options_dialog = NULL, *cell_width_spin, *cell_height_spin,                 *color_table;static void close_dialog(void){        gtk_widget_hide(options_dialog);}static void color_set(GtkColorButton *button, GdkColor *color){        gtk_color_button_get_color(button, color);        window_update_colors();}static void ink_color_set(void){        cell_widget_set_cursor(TRUE);}static void xinput_enabled_toggled(void){        cell_widget_enable_xinput(xinput_enabled);}static void spin_value_changed_int(GtkSpinButton *button, int *value){        *value = (int)gtk_spin_button_get_value(button);}static void spin_value_changed_int_repack(GtkSpinButton *button, int *value){        spin_value_changed_int(button, value);        window_pack();}static void check_button_toggled(GtkToggleButton *button, int *value){        *value = gtk_toggle_button_get_active(button);}static void check_button_toggled_repack(GtkToggleButton *button, int *value){        check_button_toggled(button, value);        window_pack();}static GtkWidget *label_new_markup(const char *s){        GtkWidget *w;        w = gtk_label_new(NULL);        gtk_label_set_markup(GTK_LABEL(w), s);        gtk_misc_set_alignment(GTK_MISC(w), 0, 0.5);        return w;}static GtkWidget *spacer_new(int width, int height){        GtkWidget *w;        w = gtk_hbox_new(FALSE, 0);        gtk_widget_set_size_request(w, width, height);        return w;}static GtkWidget *spin_button_new_int(int min, int max, int *variable,                                      int repack){        GtkWidget *w;        w = gtk_spin_button_new_with_range(min, max, 1.);        gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), *variable);        g_signal_connect(G_OBJECT(w), "value-changed",                         repack ? G_CALLBACK(spin_value_changed_int_repack) :                                  G_CALLBACK(spin_value_changed_int), variable);        return w;}static GtkWidget *check_button_new(const char *label, int *variable, int repack){        GtkWidget *w;        w = gtk_check_button_new_with_label(label);        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), *variable);        g_signal_connect(G_OBJECT(w), "toggled",                         repack ? G_CALLBACK(check_button_toggled_repack) :                                  G_CALLBACK(check_button_toggled), variable);        return w;}static void cell_height_value_changed(void){        gtk_spin_button_set_range(GTK_SPIN_BUTTON(cell_width_spin),                                  CELL_WIDTH_MIN, cell_height);}static void cell_width_value_changed(void){        int min;        min = CELL_HEIGHT_MIN > cell_width ? CELL_HEIGHT_MIN : cell_width;        gtk_spin_button_set_range(GTK_SPIN_BUTTON(cell_height_spin),                                  min, CELL_HEIGHT_MAX);}static void style_colors_changed(void){#if GTK_CHECK_VERSION(2, 10, 0)        gtk_widget_set_sensitive(color_table, !style_colors);        window_update_colors();#endif}#ifdef HAVE_GNOMEstatic void help_clicked(void){        GError *error = NULL;        gnome_url_show(CELLWRITER_URL, &error);        if (error)                g_warning("Failed to launch help: %s", error->message);}#endifstatic GtkWidget *create_color_table(void){        GtkWidget *table;        int i, entries;        struct {                const char *string;                GdkColor *color;                int reset_cursor;        } colors[] = {                { "<b>Custom colors:</b>", NULL, FALSE },                { "Used cell:", &custom_active_color, FALSE },                { "Blank cell:", &custom_inactive_color, FALSE },                { "Highlight:", &custom_select_color, FALSE },                { "Text and ink:", &custom_ink_color, TRUE  },                { "Key face:", &custom_key_color, FALSE },        };        entries = (int)(sizeof (colors) / sizeof (*colors));        table = gtk_table_new(entries, 2, TRUE);        for (i = 0; i < entries; i++) {                GtkWidget *w, *hbox;                /* Headers */                if (!colors[i].color)                        w = label_new_markup(colors[i].string);                /* Color label */                else {                        hbox = gtk_hbox_new(FALSE, 0);                        gtk_box_pack_start(GTK_BOX(hbox), spacer_new(16, -1),                                           FALSE, FALSE, 0);                        w = label_new_markup(colors[i].string);                        gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);                        gtk_misc_set_alignment(GTK_MISC(w), 0, 0.5);                        w = hbox;                }                gtk_table_attach(GTK_TABLE(table), w, 0, 1, i, i + 1,                                 GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);                if (!colors[i].color)                        continue;                /* Attach color selection button */                w = gtk_color_button_new_with_color(colors[i].color);                g_signal_connect(G_OBJECT(w), "color-set",                                 G_CALLBACK(color_set), colors[i].color);                gtk_table_attach(GTK_TABLE(table), w, 1, 2, i, i + 1,                                 GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);                /* Some colors reset the cursor */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -