📄 dialog-prefs.c
字号:
GTK_SIGNAL_FUNC (prefs_changed), NULL);#endif gtk_signal_connect (GTK_OBJECT (autoindent), "toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT(toolbar_radio_button_1), "toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT(toolbar_radio_button_2), "toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT(toolbar_radio_button_3), "toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (tabsize)->adjustment), "value_changed", GTK_SIGNAL_FUNC (prefs_changed), NULL); }static voidundo_levels_toggled (GtkWidget *widget, gpointer data){ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (undo_levels))) { gtk_toggle_button_update_label_sensitivity (undo_levels, TRUE); gtk_widget_set_sensitive (GTK_WIDGET (undo_levels_spin_button), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (undo_levels_label), TRUE); } else { gtk_toggle_button_update_label_sensitivity (undo_levels, FALSE); gtk_widget_set_sensitive (GTK_WIDGET (undo_levels_spin_button), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (undo_levels_label), FALSE); } gnome_property_box_changed (GNOME_PROPERTY_BOX (propertybox));}static voidprepare_documents_page (GladeXML *gui){ gedit_debug (DEBUG_PREFS, ""); mdimode = glade_xml_get_widget (gui, "mdimode"); tabpos = glade_xml_get_widget (gui, "tabpos"); undo_levels = glade_xml_get_widget (gui, "undo_levels"); undo_levels_label = glade_xml_get_widget (gui, "undo_levels_label"); undo_levels_spin_button = glade_xml_get_widget (gui, "undo_levels_spin_button"); if ( !mdimode || !tabpos || !undo_levels || !undo_levels_label || !undo_levels_spin_button) { g_warning ("Could not load widgets from prefs.glade correctly\n"); return; } /* set initial button states */ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (undo_levels), settings->undo_levels>0); if (settings->undo_levels < 1) { gtk_toggle_button_update_label_sensitivity (undo_levels, FALSE); gtk_widget_set_sensitive (GTK_WIDGET (undo_levels_spin_button), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (undo_levels_label), FALSE); } else gtk_spin_button_set_value (GTK_SPIN_BUTTON (undo_levels_spin_button), (guint) settings->undo_levels); /* set initial states */ gtk_option_menu_set_history (GTK_OPTION_MENU (mdimode), settings->mdi_mode); gtk_option_menu_set_history (GTK_OPTION_MENU (tabpos), settings->tab_pos); /* connect signals */ gtk_signal_connect (GTK_OBJECT (GTK_MENU_SHELL (gtk_option_menu_get_menu(GTK_OPTION_MENU (mdimode)))), "selection-done", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (GTK_MENU_SHELL (gtk_option_menu_get_menu(GTK_OPTION_MENU (tabpos)))), "selection-done", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (undo_levels), "toggled", GTK_SIGNAL_FUNC (undo_levels_toggled), NULL); gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (undo_levels_spin_button)->adjustment), "value_changed", GTK_SIGNAL_FUNC (prefs_changed), NULL);}static voidprepare_fontscolors_page (GladeXML *gui){ GtkStyle *style; GdkColor *c; gedit_debug (DEBUG_PREFS, ""); foreground = glade_xml_get_widget (gui, "foreground"); background = glade_xml_get_widget (gui, "background"); defaultfont = glade_xml_get_widget (gui, "defaultfont"); /* setup the initial states */ if (mdi->active_view) style = gtk_style_copy (gtk_widget_get_style ( GTK_WIDGET (GEDIT_VIEW (mdi->active_view)->text))); else style = gtk_style_new (); c = &style->base[0]; gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (background), c->red, c->green, c->blue, 0); c = &style->text[0]; gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (foreground), c->red, c->green, c->blue, 0); gtk_style_unref (style); if (settings->font) gnome_font_picker_set_font_name (GNOME_FONT_PICKER (defaultfont), settings->font); /* connect signals */ gtk_signal_connect (GTK_OBJECT (foreground), "color_set", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (background), "color_set", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (defaultfont), "font_set", GTK_SIGNAL_FUNC (prefs_changed), NULL);}static voidprint_lines_toggled (GtkWidget *widget, gpointer data){ gedit_debug (DEBUG_PREFS, ""); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (print_lines))) { gtk_widget_set_sensitive (GTK_WIDGET (print_lines_spin_button), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (lines_label), TRUE); } else { gtk_widget_set_sensitive (GTK_WIDGET (print_lines_spin_button), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (lines_label), FALSE); } gnome_property_box_changed (GNOME_PROPERTY_BOX (propertybox));}static voidprepare_printing_page (GladeXML *gui){ gedit_debug (DEBUG_PREFS, ""); print_header = glade_xml_get_widget (gui, "printheader"); print_lines = glade_xml_get_widget (gui, "printlines"); print_lines_spin_button = glade_xml_get_widget (gui, "printlinesspin"); lines_label = glade_xml_get_widget (gui, "lineslabel"); print_wrap = glade_xml_get_widget (gui, "printwrap"); print_orientation_portrait_radio_button = glade_xml_get_widget (gui, "print_orientation_portrait_radio_button"); if ( !print_header || !print_lines || !print_lines_spin_button || !lines_label || !print_wrap || !print_orientation_portrait_radio_button) { g_warning ("Could not load the widgets for the print page."); return; } /* set initial button states */ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (print_header), settings->print_header); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (print_lines), settings->print_lines); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (print_wrap), settings->print_wrap_lines); if (settings->print_orientation == PRINT_ORIENT_PORTRAIT) gtk_radio_button_select (GTK_RADIO_BUTTON(print_orientation_portrait_radio_button)->group,0); else gtk_radio_button_select (GTK_RADIO_BUTTON(print_orientation_portrait_radio_button)->group,1); if (!settings->print_lines) { gtk_widget_set_sensitive (GTK_WIDGET (print_lines_spin_button), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (lines_label), FALSE); } else gtk_spin_button_set_value(GTK_SPIN_BUTTON( print_lines_spin_button), (gint)settings->print_lines); /* connect signals */ gtk_signal_connect (GTK_OBJECT (print_header), "toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (print_wrap), "toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (print_lines), "toggled", GTK_SIGNAL_FUNC (print_lines_toggled), NULL); gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (print_lines_spin_button)->adjustment), "value_changed", GTK_SIGNAL_FUNC (prefs_changed), NULL); gtk_signal_connect (GTK_OBJECT (print_orientation_portrait_radio_button), "toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL);}static voidprepare_pagesize_page (GladeXML *gui){ gedit_debug (DEBUG_PREFS, ""); paperselector = glade_xml_get_widget (gui, "paperselector"); gnome_paper_selector_set_name( GNOME_PAPER_SELECTOR (paperselector), settings->papersize); /* connect signals */ gtk_signal_connect(GTK_OBJECT( GTK_COMBO( GNOME_PAPER_SELECTOR(paperselector)->paper)->entry), "changed", GTK_SIGNAL_FUNC (prefs_changed), NULL); }#if 0static voidgedit_prefs_notebook_switch_page (GtkWidget *widget, gpointer data){ g_print ("Page switched\n");}#endifstatic voiddialog_prefs_impl (GladeXML *gui){ static GnomeHelpMenuEntry help_entry = { NULL, "prefs" }; gedit_debug (DEBUG_PREFS, ""); propertybox = glade_xml_get_widget (gui, "propertybox");#ifdef USE_NOTEBOOK notebook = glade_xml_get_widget (gui, "notebook");#endif g_return_if_fail (propertybox != NULL);#ifdef USE_NOTBEOOK g_return_if_fail (notebook != NULL);#endif /* glade won't let me set the title of the propertybox */ gtk_window_set_title (GTK_WINDOW (propertybox), _("gedit: Preferences")); prepare_general_page (gui); prepare_documents_page (gui); prepare_fontscolors_page (gui); prepare_printing_page (gui); prepare_pagesize_page (gui); /* connect signals */ gtk_signal_connect (GTK_OBJECT (propertybox),"apply", GTK_SIGNAL_FUNC (apply_cb), NULL); gtk_signal_connect (GTK_OBJECT (propertybox),"destroy", GTK_SIGNAL_FUNC (destroy_cb), NULL); gtk_signal_connect (GTK_OBJECT (propertybox),"delete_event", GTK_SIGNAL_FUNC (gtk_false), NULL); help_entry.name = gnome_app_id; gtk_signal_connect (GTK_OBJECT (propertybox),"help", GTK_SIGNAL_FUNC (gnome_help_pbox_display), &help_entry);#ifdef USE_NOTEBBOK gtk_signal_connect (GTK_OBJECT (notebook),"switch_page", GTK_SIGNAL_FUNC (gedit_prefs_notebook_switch_page), NULL);#endif gnome_dialog_set_parent (GNOME_DIALOG (propertybox), gedit_window_active()); /* show everything */ gtk_widget_show_all (propertybox);}voidgedit_dialog_prefs (void){ static GladeXML *gui = NULL; gedit_debug (DEBUG_PREFS, ""); if (!propertybox) { gui = glade_xml_new (GEDIT_GLADEDIR "prefs.glade", NULL); if (!gui) { g_warning ("Could not find prefs.glade\n"); return; } dialog_prefs_impl (gui); gtk_object_unref (GTK_OBJECT (gui)); } else { gdk_window_show (propertybox->window); gdk_window_raise (propertybox->window); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -