diff options
author | James Willcox <jwillcox@src.gnome.org> | 2003-02-21 23:36:34 +0000 |
---|---|---|
committer | James Willcox <jwillcox@src.gnome.org> | 2003-02-21 23:36:34 +0000 |
commit | 90df530b16689e4cc691547215a8172d8e358a45 (patch) | |
tree | 88506e9430832a8c39b7053db2009b582d73b907 | |
parent | 31953bb465a311ffbec807f84a5e0f96e16f6309 (diff) | |
download | gedit-gnome-2-0.tar.gz |
Remove the gedit directory which was accidentally addedgnome-2-0
Remove the gedit directory which was accidentally added
85 files changed, 0 insertions, 33621 deletions
diff --git a/gedit/.cvsignore b/gedit/.cvsignore deleted file mode 100644 index 9f067009f..000000000 --- a/gedit/.cvsignore +++ /dev/null @@ -1,13 +0,0 @@ -.deps -gedit -gedit-marshal.c -gedit-marshal.h -gnome-recent-marshal.c -gnome-recent-marshal.h -Makefile -Makefile.in -GNOME_Gedit-common.c -GNOME_Gedit-skels.c -GNOME_Gedit-stubs.c -GNOME_Gedit.h -.libs diff --git a/gedit/ChangeLog b/gedit/ChangeLog deleted file mode 100644 index eb712088c..000000000 --- a/gedit/ChangeLog +++ /dev/null @@ -1,1802 +0,0 @@ -2002-11-15 Paolo Maggi <maggi@athena.polito.it> - - * gedit-plugins-engine.c (gedit_plugins_engine_load_dir): - use G_MODULE_SUFFIX, instead of the hardcoded string ".so" - (fix bug #93765, thanks to Benjamin Thery) - backported from HEAD - -2002-11-15 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi.c: fixed Documents menu - backported from HEAD - -2002-11-15 Paolo Maggi <maggi@athena.polito.it> - - Fix bug #91791 - backported from HEAD. - - * gedit-undo-manager.c (GeditUndoActionType): removed a comma at the - end of the enums - - * gnome-recent-model.c: removed a comma after PROP_LIMIT - -2002-11-15 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c (gedit_document_save_as_real): add \n to end - of file if needed (fix bug #95676) - backported from HEAD - -2002-11-15 James Willcox <jwillcox@gnome.org> - - * gedit-document.c: (gedit_document_save_as_real): - - Use umask(2) to calculate permissions for new files. - Fixes #93303, backported from HEAD. Original patch by Matt Brubeck. - -2002-11-15 James Willcox <jwillcox@gnome.org> - - * bonobo-mdi.c: (toplevel_focus), (app_close_book): - - Fixes #92376, backported from HEAD. Original patch by Paolo. - -2002-09-19 Federico Mena Quintero <federico@ximian.com> - - * gedit-document.c (gedit_document_save_as_real): Oops, use errno - if we tried to rename the file. - -2002-09-03 Federico Mena Quintero <federico@ximian.com> - - * gedit-document.c: Preserve the group of the parent directory if - the S_ISGID flag is set. Fixes #88699. - - -2002-08-16 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c (gedit_file_save_as): fixed bug #90879 (thanks to - Owen Taylor for the patch) - -2002-08-16 Federico Mena Quintero <federico@ximian.com> - - Fixes part of #90133. - - * gedit-mdi.c (gedit_mdi_app_created_handler): Only restore the - state/size of windows if the session is not being restored. - - * bonobo-mdi-session.c (bonobo_mdi_restore_state): Turn the - restoring state of the MDI on/off as appropriate. - - * bonobo-mdi.c (bonobo_mdi_set_restoring_state): New function. - (bonobo_mdi_get_restoring_state): New function. - (app_clone): Only set the default size of the window if the - session is not being restored. - (app_create): Likewise. - -2002-08-16 Federico Mena Quintero <federico@ximian.com> - - * gedit-file.c (gedit_file_save): Also call gtk_window_present() here. - (gedit_file_save_all): Likewise. - (gedit_file_open_uri_list): Likewise. - - * gedit-mdi.c (gedit_mdi_remove_child_handler): Likewise. - -2002-08-15 Federico Mena Quintero <federico@ximian.com> - - * dialogs/gedit-preferences.glade2: Changed the ATK descriptions - for the widgets that have duplicated labels, to make them more - clear. Fixes part of #90279. - -2002-08-15 Federico Mena Quintero <federico@ximian.com> - - Fixes part of #90133. - - * bonobo-mdi.c (bonobo_mdi_set_active_view): Do not call - gtk_window_present(); it is better to do this case-by-case like - when setting the active view from a menu. Calling present() on - every window will screw up session management as we don't want to - change the stacking order or virtual desktop that the window - manager will give us. - (child_list_activated_cb): Do call gtk_window_present() here. - -2002-08-14 Federico Mena Quintero <federico@ximian.com> - - * dialogs/gedit-plugin-manager.c (plugin_manager_construct_tree): - Install a custom search equal function for our non-string column. - Fixes the treeview part of #90280. - -2002-08-13 Federico Mena Quintero <federico@ximian.com> - - Fixes #90231. - - * gedit-file-selector-util.c (ok_clicked_cb): Test whether the - file is read-only and present a confirmation dialog in that case. - (replace_read_only_file): New function. - (replace_existing_file): Use the replace_dialog() core. - (replace_dialog): Moved the replace_existing_file() code to here - and made it more generic. - - * gedit-document.c (gedit_document_save_as): Tell - gedit_document_save_as_real() to create a backup file. - - * gedit-file.c (gedit_file_open_uri_list): - gtk_message_dialog_new() takes a printf() format, so don't compose - the string first - it may contain percent signs which will screw - us here. - - * gedit-print.c (gedit_print_error_dialog): Likewise. - -2002-07-25 Paolo Maggi <maggi@athena.polito.it> - - * gnome-recent-model.c (gnome_recent_model_add): free canonical_uri - - * gnome-recent-view-bonobo.c (gnome_recent_view_bonobo_set_list): - fix appname - -2002-07-23 Paolo Maggi <maggi@athena.polito.it> - - Now gedit should work well with broken utf8 filenames. - - Modified files: - * gedit-file.c - * gnome-recent-model.c - * gnome-recent-view-bonobo.c - * gedit-document.c - * gedit-utils.c - * bonobo-mdi.c - * gedit-file-selector-util.c - -2002-07-23 James Willcox <jwillcox@cs.indiana.edu> - - * gnome-recent-model.c: Convert URIs to utf8 on the way in, - convert back to the C library representation on the way out. - - * gnome-recent-view-bonobo.c (gnome_recent_view_bonobo_set_list): - Escape relevant parts of the XML. (#88362) - -2002-07-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c (gedit_file_open_uri_list): fix typo - -2002-07-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.c (gedit_utils_convert_search_text): fixed to work - with utf8 chars in the proper way (fixed bug #88660 and #88661) - -2002-07-18 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs-manager.c: use gnome-config instead of gconf to manage - window size and state - -2002-07-16 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c (gedit_file_open_uri_list): if a file does not exists - and create == TRUE, create it (fixed bug #77557) - - * gedit-utils.[ch] (gedit_utils_error_reporting_creating_file): new - function - -2002-07-16 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.[ch] (gedit_utils_create_empty_file): new function - - * gedit-file.c (gedit_file_open_uri_list): return FALSE if no file - is loaded - - * gedit2.c (gedit_load_file_list): read stdin even if data == NULL - (bug #88213 partially fixed) - - * gedit-document.c (gedit_document_load_from_stdin): convert input - from locale encoding to utf8 if needed - - * gedit-commands.c (gedit_cmd_help_about): fix bug #88269 - -2002-07-15 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-utils.[ch] (gedit_utils_convert_search_text): Converts - things like "\n" into special characters. Also, corrected - g_uft8_caselessnmatch() to g_utf8_caselessnmatch() and fixed - all references to the misspelled version. - - * gedit-document.[ch]: search using the converted string - - * dialogs/gedit-dialog-replace.c - (replace_dlg_replace_button_pressed): Compare to the converted - string to the selected text, instead of the user-specified string. - -2002-07-15 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-preferences-dialog.c: fixed bug #88019 - - * dialogs/gedit-preferences.glade2: s/S_elected text color/ - Selecte_d text color (fixed bug #88018) - - *dialogs/plugin-manager.glade2: s/D_etails/De_tails (fixed bug #88018) - -2002-07-10 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.[ch] (gedit_utils_uri_exists): new functions - - * gedit-mdi.c (gedit_mdi_remove_child_handler): Check to see if - the file has been deleted from the filesystem before closing - (fixed bug #75861). - - * gedit-file.c (gedit_file_save): Save the file if it has - been deleted from the filesystem ((fixed bug #75861). - -2002-07-10 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs-manager.[ch]: - s/GEDIT_SAVE_CURRENT_LOCALE_WHEN_POSSIBLE/GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE, - added GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL description - - * dialogs/gedit-preferences-dialog.c: added a "When creating a new file..." - frame in the Save page - - * dialogs/gedit-preferences.glade2: ditto - - * gedit-document.c (gedit_save_as_real): when requested save the - file using the original encoding - -2002-07-09 Paolo Maggi <maggi@athena.polito.it> - - The "Plugin Manager" is now a page in the "Preferences" dialog - - * dialogs/gedit-plugin-manager.h: new file - * dialogs/gedit-dialog-plugin-manager.c -> gedit-plugin-manager.c - - * dialogs/Makefile.am (libdialogs_a_SOURCES): added - gedit-plugin-manager.[ch], removed gedit-dialog-plugin-manager.c - - * gedit-commands.[ch] (gedit_cmd_tools_plugin_manager): deleted - - * gedit-menus.c (gedit_verbs): removed the PluginsManager entry - - * gedit-ui.xml: removed the "Plugin Manager" menu item - - * dialogs/gedit-dialogs.h (gedit_dialog_plugin_manager): removed - - * dialogs/gedit-preferences-dialog.c: removed unused code, added the - "Plugin Manager" page - - * dialogs/gedit-preferences.glade2: cleaned up - - * dialogs/plugin-manager.glade2: cleaned up - -2002-07-08 Paolo Maggi <maggi@athena.polito.it> - - * .cvsignore: Updated - -2002-07-08 Paolo Maggi <maggi@athena.polito.it> - - * Makefile.am: create a gnome-text-editor symbolic link - to gedit - - * gedit2.c (main): set the GNOME_PARAM_HUMAN_READABLE_NAME - paramater to "Text Editor" - -2002-07-05 Paolo Maggi <maggi@athena.polito.it> - - Fixed bug #76001 - - * bonobo-mdi.[ch]: added a "top_window_destroy" - signal - (bonobo_mdi_new)(bonobo_mdi_construct): take the default - size of the toplevel windows as parameter - (app_clone): clone the window size and state - - * gedit-mdi.c (gedit_mdi_app_destroy_handler): new function for - saving the size and state if the destroyed window - (gedit_mdi_app_created_handler): set window size and state - - * gedit-prefs-manager.[ch]: added functions to set and get - the window size and state - -2002-07-04 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-document.c (gedit_document_load): - Set the GError back to NULL after freeing it. - -2002-07-04 James Willcox <jwillcox@cs.indiana.edu> - - * gnome-recent-view-bonobo.c (gnome_recent_view_bonobo_finalize): - free some stuff when we get finalized. - - * gedit-mdi.c (gedit_mdi_app_created_handler): - add a GDestroyNotify which unrefs the GnomeRecentView when the - window is destroyed. - -2002-07-04 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-dialog-replace.c: fixed bug #86333 - -2002-07-04 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c: save used encoding while loading a file, - try to use "ISO-8859-15" as last resource while loading a file. - - * gedit-file.c (gedit_file_save_as): fix bug #87276 - - * gedit-prefs-manager.c (GPM_DEFAULT_BACKUP_COPY_EXTENSION): Changed - the default to ~. This is also reflected in the new GConf - schema file. - -2002-07-03 Federico Mena Quintero <federico@ximian.com> - - * gedit-prefs-manager.c (GPM_DEFAULT_CREATE_BACKUP_COPY): Changed - the default to true. This is also reflected in the new GConf - schema file. - -2002-07-03 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi.[ch] (bonobo_mdi_get_window_info) - new method - (app_clone): set the size of the new window to the - one of the cloned one - -2002-07-03 Paolo Maggi <maggi@athena.polito.it> - - * gnome-vfs-helpers.[ch]: removed - - * *.c: s/gnome_vfs_x/eel - -2002-06-28 James Willcox <jwillcox@cs.indiana.edu> - - * dialogs/gedit-dialog-goto-line.c: Only allow digits in the entry - -2002-06-17 Federico Mena Quintero <federico@ximian.com> - - Fixes #84986. - - * bonobo-mdi.c (gen_role): Moved over from gedit-mdi.c. - (app_create): Added a "window_role" argument so that we can set up - the window's role here. - (app_clone): Likewise. - (bonobo_mdi_open_toplevel): Likewise. - (bonobo_mdi_add_toplevel_view): Likewise. - - * bonobo-mdi-session.c (restore_window_child): Pass the role - argument to bonobo_mdi_add_toplevel_view(). - (restore_window): Pass the role argument to - bonobo_mdi_open_toplevel(). - - * gedit2.c (main): Likewise. - - * gedit-mdi.c (gedit_mdi_app_created_handler): Do not set the role - here. - -2002-06-14 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs-manager.[ch]: new files - - * Makefile.am: - * gedit-commands.c: - * gedit-document.c: - * gedit-file.c: - * gedit-mdi.[ch]: - * gedit-print.c: - * gedit-recent.c: - * gedit-session.c: - * gedit-undo-manager.c: - * gedit-view.c: - * gedit2.c: - * dialogs/gedit-preferences-dialog.[ch]: - * dialogs/gedit-preferences.glade2: use gedit-prefs-manager API - -2002-06-14 Paolo Maggi <maggi@athena.polito.it> - - * src/gedit-preferences.glade2: fixed a typo - -2002-06-11 Federico Mena Quintero <federico@ximian.com> - - * gedit-mdi.c (gedit_mdi_remove_child_handler): - gtk_window_present() the confirmation dialog so that the user sees - it even when shutting down the session. Fixes #84677. - -2002-06-05 Jagadeesh B.G <jagadeesh.banavara@wipro.com> - - * src/dialogs/gedit-preferences.glade2: Fix some ATK relations. - Fixes bug #84108. - -2002-05-31 Federico Mena Quintero <federico@ximian.com> - - * Makefile.am (INCLUDES): Patch by Hidetoshi Tajima - (hidetoshi.tajima@sun.com) to fix the localedir on Solaris. Fixes - #83614. - -2002-05-30 James Willcox <jwillcox@cs.indiana.edu> - - * bonobo-mdi.c (child_list_menu_add_item): - Assign keyboard accelerators to items in the "Documents" menu. - -2002-05-29 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi-session.c: save and restore window role - - * bonobo-mdi.c (book_button_release): use - gtk_window_set_default_size instead of gtk_widget_set_size_request - - * gedit-document.c (gedit_document_replace_selected_text): - let replace be long zero chars - - *gedit-mdi.c (gen_role): new function - (gedit_mdi_app_created_handler): set unique window role using gen_role - - * dialogs/gedit-dialog-replace.c: fix bug #83401 - -2002-05-28 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-application-server.[ch], gedit-document-server.[ch], - gedit-window-server.[ch]: new files, provides an implementation for a - CORBA interface to gedit. - - * gedit2.c: added command line arguments for using the new CORBA - interface. Lets you open files, create new windows, etc. - -2002-05-27 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c (gedit_file_open): display formatted uris - in the status bar - -2002-05-27 Paolo Maggi <maggi@athena.polito.it> - - * gedit-mdi.c (gedit_mdi_set_app_toolbar_style): fixed bug #82877 - -2002-05-27 James Willcox <jwillcox@cs.indiana.edu> - - * gnome-recent-model.c (gnome_recent_model_delete_from_list): - Fixed memory leak (Thanks to Gustavo Giráldez for the patch) - -2002-05-23 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file-selector-util.c (run_file_selector): check if data != NULL - -2002-05-23 Paolo Maggi <maggi@athena.polito.it> - - * gedit-view.c: added Undo and Redo to the popup menu - (gedit_view_init): connected the populate-popup signal and removed - old commented code - (gedit_view_undo_activate_callback)(gedit_view_redo_activate_callback) - (gedit_view_populate_popup): new static functions - - Note that since I'm using stock menu items, I'm not breaking the - string freeze - -2002-05-22 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi.c (app_close_book)(book_motion)(book_button_press) - (book_button_release): return gboolean instead of gint - (toplevel_focus): always returns FALSE (this fixes bug #77735) - - * gedit-view.c (gedit_view_grab_focus): removed the ack to fix - bug #77735 - - Thanks to Yogeesh MB, Federico Mena Quintero and Owen Taylor for - their help in fixing this bug - -2002-05-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.c (remove_timeout_cb): set current_mi to NULL to - fix a crash - -2002-05-21 Paolo Maggi <maggi@athena.polito.it> - - Fixed bug #79205 removing the "Show Tooltips" menu item - - Modified files: gedit-ui.xml, gedit-mdi.c and gedit-prefs.[ch] - -2002-05-21 Yogeesh MB <yogeeshappa.mathighatta@wipro.com> - - * gedit-view.c (gedit_view_grab_focus): Fixed bug #77735 - both on Solaris and Linux - -2002-05-21 Federico Mena Quintero <federico@ximian.com> - - * gedit-view.c (gedit_view_init): Do not set a focus chain. I - don't see how this could affect things for this bug, but it is - intended to fix #77735 anyways. - -2002-05-21 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c (gedit_file_save): convert filename to - utf8 before inserting it in the list of recent files - -2002-05-20 Paolo Maggi <maggi@athena.polito.it> - - Fixed bug #81878 - - gedit-file-selector-util.c (run_file_selector): set - using_bonobo_filesel to TRUE only if dialog != NULL - - gedit-file.c: added the gedit_default_path variable - (gedit_file_open): use and update gedit_default_path - (gedit_file_save_as): ditto - - gnome-vfs-helpers.[ch] (gnome_vfs_x_uri_get_dirname): - new function - -2002-05-20 Paolo Maggi <maggi@athena.polito.it> - - gedit-ui.xml: s/About.../About - -2002-05-15 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c (gedit_file_save): insert a canonical uri - in the recent list (this should fix bug #76641) - -2002-05-14 Paolo Maggi <maggi@athena.polito.it> - - Added basic session management (thanks to Federico Mena Quintero - for his initial patch and his help) - - * gedit-session.[ch], bonobo-mdi-session.[ch]: new files - - * Makefile.am: added the new files to gedit_SOURCES - - * gedit-debug.[ch]: added support for debugging session - management related stuffs - - * gedit-document.[ch] (gedit_document_get_raw_uri): new function - - * gedit-mdi-child.c (gedit_mdi_child_get_config_string): new function - (implementation of the virtual function get_config_string) - - * gedit2.c (main): almost rewritten to add SM support - -2002-05-14 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: added accellerator to help menu items - (thanks to Glynn Foster) - -2002-05-14 Paolo Maggi <maggi@athena.polito.it> - - gedit-file.c: Fixed bug #77834 - - gedit-document.c (gedit_document_get_uri) - (gedit_document_get_short_name): always return valid - UTF-8 text - -2002-05-10 Paolo Maggi <maggi@athena.polito.it> - - * gedit-print.c: fixed bug #79733, now the default - is to print to a printer - -2002-05-09 Paolo Maggi <maggi@athena.polito.it> - - * gedit-print.c: changed the print dialog title - to "Print" - -2002-05-07 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file-selector-util.c: use a quark to - store retval (user_data_id) - -2002-05-06 Paolo Maggi <maggi@athena.polito.it> - - * gedit-mdi.c: set main window role - -2002-05-06 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c: fixed bug #80841 - (Thanks to Mats-Ola Persson) - -2002-05-03 Federico Mena Quintero <federico@ximian.com> - - * gedit-document.c (gedit_document_save_as_real): Do saving in - the following way: - - 1. Get the real filename by following all the symlinks of - the original filename. This is the icky function - follow_symlinks(). - - 2. Write a temporary filename with the buffer contents. - - 3. If create_backup_copy, rename the real_filename to - real_filename.bak. - - 4. Rename the temporary filename to the real_filename. - - 5. Restore file permissions and ownership. - - It is sad that yes, the Unix API is complete and lets us do - this, but we must still write a bunch of code to *save a stupid - file*. - -2002-04-30 jacob berkman <jacob@ximian.com> - - * Makefile.am (EXTRA_DIST): add gnome-recent-marshal.list - -2002-04-30 Federico Mena Quintero <federico@ximian.com> - - * dialogs/gedit-dialog-replace.c - (replace_dlg_replace_button_pressed): Do not pass null arguments - for printf() formats to gedit_debug(); this will crash on - non-glibc systems. Should fix #78011. - -2002-04-30 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: added an icon to Help->Contents - -2002-04-29 Miles Lane <miles@megapathdsl.net> - - * Add "#include <string.h>" to gnome-recent-util.c in order - to fix the build. Instructed to do so by Chema. :) - -2002-04-29 James Willcox <jwillcox@cs.indiana.edu> - - * Makefile.am: Added a bunch of new stuff for gnome-recent (recent - files code) - * gnome-recent-model.[ch], gnome-recent-view.[ch], - gnome-recent-view-bonobo.[ch], gnome-recent-util.[ch], - gnome-recent-marshal.list: - All new files, replaces the old recent files system with a new - model-view system. - * gedit-file.c (gedit_file_open_recent): Small changes to cope with - gnome-recent stuff - * gedit-mdi.c: ditto - * gedit-recent.[ch]: Essentially, these are new, even though they - existed before. This is just an accessor for the gnome-recent - model now. - - All of this stuff should fix bug #76641 (problems when FAM isn't - available). - -2002-04-23 Federico Mena Quintero <federico@ximian.com> - - * gedit-document.c (gedit_document_save_as_real): Properly handle - file permissions. Fixes bug #76196 (patch approved by Chema - Celorio). - -2002-04-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-view.[ch] (gedit_view_set_font)(gedit_view_set_colors): - added the def parameter - - * gedit-mdi.c (gedit_mdi_update_ui_according_to_preferences): - removed unused code and fixed bug #76407 - -2002-04-20 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-preferences-dialog.c: fixed bug #79277 - -2002-04-20 Abel Cheung <maddog@linux.org.hk> - - * gedit-commands.c: Added translator_credits. - -2002-04-18 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-ui.xml: Change the shortcut for the plugin manager to be "M" - instead of "P" (which conflicted with the shortcut for "Paste") - -2002-04-17 Paolo Maggi <maggi@athena.polito.it> - - * gedit-menus.[ch] (gedit_menus_add_menu_item_toggle): new function - (gedit_menus_add_menu_item_toggle_all): ditto - -2002-04-17 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-preferences-dialog.c: fixed bug #78856 (I hope!) - -2002-04-16 Hema Seetharamaiah <hema.seetharamaiah@wipro.com> - - * Accessibility Changes. Mainly setting up of relations, Accessible name/descriptions. - Files affected : - - gedit-utils.c - - gedit-utils.h - - dialogs/gedit-preferences-dialog.c - - dialogs/gedit-preferences.glade2 - - dialogs/plugin-manager.glade2 - - dialogs/replace.glade2 - - dialogs/goto-line.glade2 - - dialogs/program-location-dialog.glade2 - - dialogs/uri.glade2 - -2002-04-15 Kjartan Maraas <kmaraas@gnome.org> - - * dialogs/gedit-dialog-plugin-manager.c: #include <config.h> - * dialogs/gedit-dialog-replace.c: Same. - * dialogs/gedit-dialog-uri.c: Same and mark a string for translation. - The preferences dialog still isn't working with localization though :( - -2002-04-03 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: Fixed bug #77404 - - * dialogs/gedit-preferences.glade2: Fixed bugs #77403 - and #77401 - -2002-04-02 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: Fixed bug #76763 - - * dialogs/gedit-preferences-dialog.c: Fixed point 5 - of bug #76500 - -2002-03-28 Abel Cheung <maddog@linux.org.hk> - - * gedit-ui.xml: Fix typo. - -2002-03-27 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/*.glade2: fixed bug #76341 - -2002-03-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.h: added g_uft8_caselessnmatch function - - * gedit-document.c: - * gedit-utils.c: - * dialogs/gedit-dialog-replace.c: fixed bug #75869 - - * dialogs/gnome-print-font-dialog.c (gfsd_modify_preview_phrase): - prototype changed to return void. - -2002-03-19 James Willcox <jwillcox@cs.indiana.edu> - - * dialogs/gnome-print-font-dialog.c (gfsd_modify_preview_phrase): - return NULL, otherwise build fails. - -2002-03-18 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: fix bug #75085 - - * gedit-view.c (gedit_view_grab_focus): fix - bug #75112 - -2002-03-18 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi-child.c: cleaned - * bonobo-mdi.c: cleaned - * bonobo-mdi.h: cleaned - * gedit-mdi-child.c: cleaned - * gedit-mdi.c: cleaned - * gedit-view.c: cleaned - * gedit-file.c: cleaned - - * dialogs/Makefile.am: added gnome-print-font-picker.c, - gnome-print-font-picker.h, gnome-print-font-dialog.c, - gnome-print-font-dialog.h - - * dialogs/gnome-print-font-picker.c: new file - * dialogs/gnome-print-font-picker.h: new file - * dialogs/gnome-print-font-dialog.c: new file - * dialogs/gnome-print-font-dialog.h: new file - - * dialogs/gedit-preferences-dialog.c: added - the Print/Fonts page (needed to fix bug #71364) - * dialogs/gedit-preferences.glade2: ditto - -2002-03-15 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-preferences-dialog.c: - * dialogs/gedit-preferences.glade2: added a print font page - -2002-03-12 Kjartan Maraas <kmaraas@gnome.org> - - * gedit-utils.c: Fix some strings to be consistent wrt «.» and throw - in some spaces where needed. - -2002-03-07 Paolo Maggi <maggi@athena.polito.it> - - * gedit-plugin.c: new file - - * gedit-plugin.h: declare gedit_plugin_locate_program - - * Makefile.am (gedit_SOURCES): add gedit-plugin.c - - * gedit-commands.c: fix bug #71841 - - * dialogs/gedit-dialog-plugin-manager.c: ditto - - * dialogs/gedit-dialog-uri.c: ditto - - * dialogs/gedit-plugin-program-location-dialog.c: ditto - -2002-03-06 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs.[ch]: added new max_recents pref - - * gedit-mdi.c (gedit_mdi_app_created_handler): - use gedit_setting->max_recent - - *gedit-recent.c: - #define GEDIT_RECENT_BASE_KEY "/apps/gedit-2/recent-files" - -2002-03-05 Paolo Maggi <maggi@athena.polito.it> - - * Makefile.am: #defined DATADIR - - * gedit2.c (main): set GNOME_PARAM_APP_DATADIR in gnome_program_init - -2002-03-04 Kjartan Maraas <kmaraas@gnome.org> - - * gedit-utils (gedit_utils_error_reporting_loading_file): Fix a typo. - -2002-03-04 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-recent.c (gedit_recent_update_menus): more mem leak cleanup - -2002-03-04 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-recent.c - (gedit_recent_g_slist_deep_free): Remove warning spew. - Changed the base gconf key to be in a more correct place. - -2002-03-04 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-recent.c - (gedit_recent_monitor_uri): Fixed mem leak. - (gedit_recent_add): Ditto. - -2002-03-04 Paolo Maggi <maggi@athena.polito.it> - - * gedit-mdi.c (gedit_mdi_set_app_statusbar_style): - now the resize_grip really works - - * gedit-ui.xml: fixed for resize_grip - - * gedit-file.c (gedit_file_open_single_uri): open - the new document in the active_child if this one - is untouched - (gedit_file_open_recent): don't try to grab focus - if no active view exists - -2002-02-28 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-recent.c (gedit_recent_menu_cb): Don't free the menu data - (this fixes a crash). Other misc. cleanup. - -2002-02-28 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/replace.glade2: removed requires lib="gnome" - - * gedit-utils.c: fixed bug #72953 - - * gedit-undo-manager.c: mem leak fixed - -2002-02-27 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-recent.c (gedit_recent_menu_cb): Don't add the URI to the - list. Also added debugging messages. - -2002-02-27 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-recent.c (gedit_recent_notify_cb): Check whether there is - a BonoboUIComponent - * gedit-mdi.c (gedit_mdi_get_recent_from_window): Do better error - checking. - -2002-02-27 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c (gedit_document_save_as_real): - fixed bug #67037 - -2002-02-26 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-recent.[ch]: Completely replaced by new code. This will - make its way into a library somewhere soon. - * gedit-mdi.[ch]: Made to use the new gedit-recent. - * gedit-file.c: Ditto - -2002-02-25 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-preferences-dialog.c - (gedit_preferences_dialog_auto_save_checkbutton_toggled): - new function - (gedit_preferences_dialog_setup_save_page): connect "toggled" - signal of the auto save checkbutton - -2002-02-25 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.[ch] (gedit_cmd_help_contents): new - function - - * gedit-menus.[c]: added HelpContents to gedit_verbs - -2002-02-23 Kjartan Maraas <kmaraas@gnome.org> - - * gedit2.c: Remove unsupported #ifdef ENABLE_NLS stuff. - -2002-02-23 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.c (gedit_utils_error_reporting_reverting_file): - report more helpful error messages - -2002-02-23 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.[ch](gedit_utils_error_reporting_loading_file) - (gedit_utils_error_reporting_saving_file) - (gedit_utils_error_reporting_reverting_file): new functions - - * gedit-file.c: use the new functions to report errors - - * gedit-document.c (gedit_document_save_as_real): better - error reporting - -2002-02-22 Federico Mena Quintero <federico@ximian.com> - - * bonobo-mdi.c: Replace gtk_object_* with the new - GObject calls. - * gedit-mdi.c: Likewise. - -2002-02-22 Paolo Maggi <maggi@athena.polito.it> - - gedit-ui.xml: In menus, all the words (except 'and') should start - with a capital letter (That's just the convention for menus) - -2002-02-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-mdi.[ch](gedit_mdi_clear_active_window_statusbar): - new function - - * gedit-file.c (gedit_file_close): call - gedit_mdi_clear_active_window_statusbar - (gedit_file_close_all): ditto - - * gedit-document.c (gedit_document_get_untitled_number) - (gedit_document_release_untitled_number): new function - Now the untitled numbers are assigned in a smarter way - -2002-02-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c (gedit_file_new): active view grabs focus - (gedit_file_open_recent): ditto - - * gedit-view.c (gedit_view_finalize): removed really broken - code I really don't know why I wrote - - * dialogs/plugin-manager.glade2: added support for long text - in the notebook pages - -2002-02-21 Paolo Maggi <maggi@athena.polito.it> - - Name changed: gedit2->gedit - - * gedit-ui.xml: removed Tools menu - -2002-02-21 Paolo Maggi <maggi@athena.polito.it> - - * gedit-mdi.c: continuing fix bug #71940 - * gedit-ui.xml: ditto - * dialogs/gedit-preferences-dialog.c: get rid of user interface - related pages (Toolbar and Status bar) - -2002-02-20 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file.c: fix bug #71940 - * gedit-mdi.c: ditto - -2002-02-20 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-preferences-dialog.c: fix bug #71940 - -2002-02-18 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: rewritten to be HIG compliance (bug #71850) - I asked the release team's permission before committing and breaking - the UI freeze ;) - View menu still does not work. - -2002-02-18 Paolo Maggi <maggi@athena.polito.it> - - * gedit-undo-manager.c (gedit_undo_manager_merge_action): fixed - bug #71830 - -2002-02-14 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-dialog-plugin-manager.c - (dialog_plugin_manager_get_selected_plugin): rewritten - -2002-02-13 Kjartan Maraas <kmaraas@gnome.org> - - * bonobo-mdi.c: #include <config.h> for proper i18n. - * gedit-document.c: Same here. - * gedit-file.c: Same. - * gedit-file-selector-util.c: Same. - * gedit-plugins-engine.c: Same - * gedit-print.c: Same. - * gedit-view.c: Same - -2002-02-13 Paolo Maggi <maggi@athena.polito.it> - - * gedit-undo-manager.c: now it should work well also with - non-ASCII chars - -2002-02-12 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: added EditOps_5 placeholder - - * dialogs/gedit-dialog-plugin-manager.c - (dialog_plugin_manager_construct_tree): unref model - - * dialogs/gedit-preferences-dialog.c (finalize): unref tree model - - * dialogs/plugin-manager.glade2: fixed scrolling bug - -2002-02-08 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.[ch] (gedit_document_save_a_copy_as): - new function - - * gedit2.[ch] (gedit_get_open_documents): new function - - * dialogs/Makefile.am: added gedit-plugin-program-location-dialog.c - - * gedit-plugin-program-location-dialog.c: new file - - * dialogs/gedit-dialogs.h (gedit_plugin_program_location_dialog): - new function - - * dialogs/program-location-dialog.glade2: new file - -2002-02-07 Federico Mena Quintero <federico@ximian.com> - - * gedit2.c (main): Do not call setlocale(). We should not be - forcing the locale on anyone. - -2002-02-07 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.[ch] (gedit_document_get_cursor) - (gedit_document_set_cursor): new functions - -2002-02-06 Paolo Maggi <maggi@athena.polito.it> - - * gedit_mdi.c (gedit_mdi_update_ui_according_to_preferences): - fix mem leak - - * gedit-plugins-engine.c (gedit_plugins_engine_save_settings): - ditto - - * dialogs/gedit-dialog-plugin-manager.c - (dialog_plugin_manager_get_selected_plugin):ditto - - * dialogs/gedit-preferences-dialog.c: warning cleans. - -2002-02-06 Paolo Maggi <maggi@athena.polito.it> - - * gedit-view.c (gedit_view_set_tab_size): - now it works - (gedit_view_calculate_real_tab_width): new static - function - (gedit_view_new): set tab size - - * gedit_mdi.c (gedit_mdi_update_ui_according_to_preferences): - set tab size for each view - - * dialogs/gedit-preferences-dialog: show the tab page - (gedit_preferences_dialog_update_settings): get tab size from - the tab page - -2002-02-06 Paolo Maggi <maggi@athena.polito.it> - - * Makefile.am: define G*_DEPRECATED - in INCLUDES - - * *.c: fix to compile with G*_DEPRECATED - -2002-02-05 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/Makefile.am: define G*_DEPRECATED - in INCLUDES - - * dialogs/gedit-dialog-goto-line.c: - * dialogs/gedit-dialog-plugin-manager.c: - * dialogs/gedit-dialog-replace.c: - * dialogs/gedit-preferences-dialog.c: fix to compile - with G*_DEPRECATED - -2002-02-05 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file-selector-util.c: removed unused code - - * gedit-debug.c: - * gedit-debug.h: - * gedit-document.c: - * gedit-document.h: - * gedit-file.c: - * gedit-plugins-engine.c: - * gedit-plugins-engine.h: - * gedit-prefs.c: - * gedit-prefs.h: - * gedit-print.c: - * gedit-recent.c: - * gedit-undo-manager.c: - * gedit-utils.c: - * gedit2.c: - * gedit2.h: - * dialogs/gedit-preferences-dialog.c: warning cleans. - -2002-01-29 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.c (remove_message_timeout): re-write not - using bonobo_ui_engine - (bonobo_window_flash): ditto - -2002-01-29 Michael Meeks <michael@ximian.com> - - * gedit-mdi.c: re-write not using bonobo_ui_engine - this was wrong. - - * *.[ch]: warning cleans. - -2002-01-26 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-menus.[ch]: - (gedit_menus_[add/remove]_menu_item, - gedit_menus_[add/remove]_menu_item_all): - new functions, make it easier for plugins to add menus to - toplevel windows. - -2002-01-24 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.[ch] (gedit_document_get_selected_text): now - take two new paramters: start and end - (gedit_document_get_line_at_offset): new function - - * gedit-print.c (gedit_print_document): print the right start - line number when printing selections - - * dialogs/plugin-manager.glade2: cosmetic changes - -2002-01-23 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (gedit_commands_about_cmd): fixed the - about box - - * gedit-document.c (gedit_document_set_readonly): - removed unused code - - * gedit-file.c (gedit_file_exit): save plugins settings - before exiting - - * gedit-plugins-engine.c: now it saves the plugins settings - -2002-01-23 James Willcox <jwillcox@cs.indiana.edu> - - * dialogs/plugin-manager.glade2: Added GtkLabels in the "Details" - notebook page for plugin name and copyright. - - * dialogs/gedit-dialog-plugin-manager.c - (dialog_plugin_manager_update_info): Update the plugin name and - copyright information, along with some other small tweaks. - (row_activated): Changed the behavior to toggle the "active" state - of the plugin, instead of configuring it. - - -2002-01-22 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-file.c: Fixed a bug where after opening one of the recent - documents, garbage would appear on the status bar. This was caused - by gedit_recent_add() freeing the uri before we were done with it. - - * gedit-mdi.c: Fixed calls to bonobo_ui_engine_xml_set_prop (it - previously would not compile). - * gedit-menus.c: ditto - -2002-01-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-view.c (gedit_view_doc_readonly_changed_handler): - new static function - (gedit_view_new): connect to the readonly_changed signal - from doc - - * gedit-document.c (gedit_document_set_readonly): - commented code to set not_editable tag. It is no more - needed - -2002-01-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-plugins-engine.[ch] (gedit_plugins_engine_configure_plugin): - new function - - * dialogs/gedit-dialog-plugin-manager.c: now use - gedit_plugins_engine_configure_plugin - -2002-01-22 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (gedit_cmd_help_about): added James to - authors - -2002-01-21 James Willcox <jwillcox@cs.indiana.edu> - - * dialogs/gedit-dialog-plugin-manager.c: Implemented the plugin - manager. - - * dialogs/plugin-manager.glade2: UI for the plugin manager. - - -2002-01-21 Marcel K. de Carli Silva <magaljedi@bol.com.br> - - * gedit2.c (main): check if args != NULL only one time - (options): use POPT_ARG_NONE to indicate no argument - - * gedit-prefs.c (gedit_prefs_save_color): new functio - (gedit_prefs_load_color): ditto - (gedit_prefs_save_settings): use gedit_prefs_save_color - (gedit_prefs_load_settings): use gedit_prefs_load_color - -2002-01-20 Paolo Maggi <maggi@athena.polito.it> - - * gedit-plugins-engine.c (gedit_plugins_engine_load): - load "configure", "save_settings", "update_ui" and "destroy" - symbols - -2002-01-18 Paolo Maggi <maggi@athena.polito.it> - - * gedit-mdi.c: update plugins UI when needed - - * gedit-plugin.h: cleaned a bit - - * gedit-plugins-engine.[ch]: implemented the plugin engine - - * gedit2.c (main): initialize the plugin engine - -2002-01-18 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c: Fixed some little problems - with auto-save - - * gedit2.c: removed plugin initialization - -2002-01-17 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-document.c: Added support for auto-save. - (gedit_document_auto_save_timeout): New function - (gedit_document_auto_save): ditto - (gedit_document_save): reset auto save timer (if needed) - (gedit_document_load): start auto save timer (if needed) - (gedit_document_finalize): remove auto save timer - - * dialogs/gedit-preferences.glade2: made the auto save widgets - sensitive. - -2002-01-17 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.[ch] (gedit_document_insert_text_at_cursor): - new function - - * gedit2.[ch] (gedit_get_top_windows): new function - (gedit_get_ui_component_from_window): ditto - - * gedit-ui.xml: added a lot of new placeholders - -2002-01-16 Paolo Maggi <maggi@athena.polito.it> - - * Makefile.am: defined GEDIT_LOCALEDIR - - [Added a +<lnum> option (like vi)] Thanks to James Willcox - for his work on it - - [Started implemetation of plugin support] - - * gedit-plugin.h: new file - - * gedit-plugins-engine.[ch]: ditto - - [Fixed some bug with notebook labels in bonobo-mdi] - -2002-01-15 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.h (gedit_text_iter_forward_search): new prototype - - * gedit-utils.c (gedit_text_iter_forward_search): new experimental - function to perform case insensitive search (beside normal case - sensitive search) - (g_utf8_strcasestr): new private function - (g_uft8_caselessnmatch): ditto - (forward_chars_with_skipping): ditto - (lines_match): ditto - (strbreakup): ditto - - * gedit-document.c (gedit_document_find): enabled support for - case insensitive search. Use the new gedit_text_iter_forward_search - - * dialogs/gedit-dialog-replace.c: enabled support for case insensitive - search - -2002-01-14 James Willcox <jwillcox@cs.indiana.edu> - - * dialogs/gedit-dialog-replace.c: Made one small change - in the wording of the search error message. (The consensus is - that the word "string" shouldn't appear in an error message). - - * dialogs/gedit-preferences.glade2: More string fixes. - -2002-01-14 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c (gedit_document_load): add some debug - message - - * gnome-vfs-helpers.c (gnome_vfs_x_read_entire_file): hack to - fix a bug when loading ftp files - - * gedit-ui.xml: hide debug menu - -2002-01-13 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs.c: save and load window size - (gedit_prefs_configure_event_handler): new function - - * gedit-pref.h (gedit_prefs_configure_event_handler): - new prototype - - * gedit-mdi.c (gedit_mdi_app_created_handler): connect the - "configure_event" signal of the created window to - gedit_prefs_configure_event_handler to track window size - -2002-01-12 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs.[ch]: - * gedit-mdi.c: - * gedit-view.[ch]: - * dialogs/gedit-preferences-dialog.c: - * dialogs/gedit-preferences-dialog.glade: - - [Add current cursor position and overwrite - mode on statusbar. Enjoy it - It is too late - and I'm too lame to write a more detailed - Change Log entry] - -2002-01-11 Paolo Maggi <maggi@athena.polito.it> - - * gedit-view.c: now it can display line numbers - (gedit_view_show_line_numbers): new function - (gedit_view_get_lines): ditto - (gedit_view_line_numbers_expose): ditto - - * gedit-view.h (gedit_view_show_line_numbers): new prototype - - * gedit-mdi.c (gedit_mdi_update_ui_according_to_preferences): call - gedit_view_show_line_numbers - - * gedit-prefs.[ch]: added the show_line_numbers setting - - * dialogs/gedit-preferences-dialog.c : added a line numbers page - - * dialogs/gedit-preferences-dialog.glade2: ditto - - * dialogs/gedit-dialog-goto-line.c (goto_button_pressed): go to the - right line number - -2002-01-11 Paolo Maggi <maggi@athena.polito.it> - - * gedit2.[ch]: added flags gedit_close_x_button_pressed and - gedit_exit_button_pressed - - * gedit-commands.c (gedit_cmd_file_close): update - gedit_close_x_button_pressed - (gedit_cmd_file_close_all): ditto - (gedit_cmd_file_exit): update gedit_exit_button_pressed - - * gedit-utils.[ch] (gedit_dialog_add_button): new function - - * gedit-file-selector-util.c (replace_existing_file): use new - gedit_dialog_add_button function - - * gedit-prefs.h: cleaned - - * gedit-recent.c: renamed some functions (now all the function - as the gedit prefix) - - * gedit-file.c: finished porting to the new gedit-file-selector API - (gedit_file_save_as_real): new function - (gedit_file_save_as_ok_button_clicked_handler): call - gedit_file_save_as_real - -2002-01-10 Jason Leach <jasonleach@usa.net> - - [Use gconf to store recent documents opened] - - * gedit-recent.c (gedit_recent_history_save): Renamed from - gedit_recent_history_write_config. - - * gedit-recent.c (recent_history_get_list): Use gconf in place of - gnome_config. - (recent_history_update_list): Ditto. - -2002-01-10 Paolo Maggi <maggi@athena.polito.it> - - * gedit-ui.xml: Exit button removed from toolbar - - * gedit-mdi.c (gedit_mdi_set_app_toolbar_style): really check - system settings - - * gedit-commands.c (gedit_cmd_help_about): cosmetic changes - -2002-01-09 Paolo Maggi <maggi@athena.polito.it> - - * gedit-utils.[ch] (gedit_button_new_with_stock_image): new function - - * dialogs/gedit-dialog-goto-line.c: now the goto line dialog is modal - - * dialogs/gedit-dialog-replace.c (dialog_replace_get_dialog): use the - new gedit_button_new_with_stock_image function to set an image for - the replace button - -2002-01-08 Paolo Maggi <maggi@athena.polito.it> - - * gedit-file-selector-util.[ch]: new files - - * gedit-file.c (gedit_file_open): use gedit_file_selector_open - - * gedit-undo-manager.c: fixed some UTF-8 related problem - - * gedit-document.c (gedit_document_save_as_real): save using locale - encoding if requested - -2002-01-07 Paolo Maggi <maggi@athena.polito.it> - - * gedit-print.c (gedit_print_create_new_page): new static function - (gedit_print_end_page): ditto - (gedit_print_paragraph): use gedit_print_create_new_page and - gedit_print_end_page to create new pages - (gedit_print_document): ditto - -2002-01-07 Paolo Maggi <maggi@athena.polito.it> - - * gedit-print.c: now, it is possible to print line numbers - (there are still some little issues to solve) - (gedit_print_line): new static function - -2002-01-05 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.h (gedit_document_has_selected_text): return FALSE - if doc is not a GeditDocument - - * gedit-file.c (gedit_file_open_uri_list): fixed a compiler warning - - * gedit-prefs.c: load and save preferences for printing support - (now they have new names) - - * gedit-print.c: use new preferences names - - * dialogs/gedit-preferences-dialog.c: the Print/Page page now - operates on the preferences - -2002-01-04 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (gedit_cmd_file_print_preview): uncommented - - * gedit-prefs.[ch]: added some preferences for printing support - - * gedit-print.c: refinements here and there - - * dialogs/gedit-preferences-dialog.c: added a Print/Page page - - * dialogs/gedit-preferences.glade2: ditto - - -2002-01-04 Paolo Maggi <maggi@athena.polito.it> - - * gedit-print.c (gedit_print_get_next_line_to_print_delimiter): - little improvement in precision. It is still not so precise as I would - like - -2002-01-03 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c (gedit_document_save_as_real): create - a backup copy of the file before saving - (gedit_document_has_selected_text): new function - - * gedit-document.h (gedit_document_has_selected_text): new - prototype - - * gedit-prefs.[ch]: preferences for printing support added - - * gedit-print.c: rewritten, now gedit2 has a basic printing - support - - * dialog/gedit-preferences-dialog.c: added a Save page - - * dialogs/gedit-preferences.glade2: ditto - -2001-12-29 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs.[ch]: rewritten - - * gedit-mdi.c: use new preference names - - * gedit-undo-manager.c: ditto - - * gedit-view.c: ditto - - * dialogs/gedit-preferences-dialog.c: ditto - -2001-12-19 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi.c (bonobo_mdi_init_instance): force tab position to be top - - * gedit-mdi.c (gedit_mdi_init): ditto - - * gedit-document.c: fixed some bugs when dealing with readonly docs - -2001-12-17 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (gedit_cmd_search_replace): call gedit_dialog_replace () - - * gedit-document.c: added last_replace_text and last_search_was_case_sensitive - fields to GeditDocumentPrivate - (gedit_document_finalize): free last_replace_text - (gedit_document_get_short_name): return the right value when doc->priv->uri != NULL - (gedit_document_begin_user_action): new public function - (gedit_document_end_user_action): ditto - (gedit_document_get_last_searched_text): call gedit_debug - (gedit_document_get_last_replace_text): new public function - (gedit_document_find): cleaned - (gedit_document_get_selected_text): new public function - (gedit_document_replace_selected_text): ditto - (gedit_document_replace_all): ditto - - * gedit-document.h: added prototypes for new public functions (see gedit-document.c log) - - * dialogs/gedit-dialog-replace.c: added support for replace; find and replace dialog are no more - modal - - Thanks to snorp (James Willcox <jwillcox@cs.indiana.edu>) for his - help in implementing find and replace. - -2001-12-14 Gediminas Paulauskas <menesis@delfi.lt> - - * gedit-marshal.list: added this file with one marshaller, which - previously was in libgnome. - - * Makefile.am: generate, use, and dist gedit-marshal.* - - * bonobo-mdi.c: replace gnome_marshal with gedit_marshal - -2001-12-12 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (TO_BE_IMPLEMENTED: set OK button as default - (gedit_cmd_search_find_again): set OK button as default in the GtkMessageDialog - (gedit_cmd_settings_preferences): added alert dialog - - * gedit-file.c: set OK button as default in all the alert dialogs - (gedit_file_close_all): update UI items sensitivity - - * gedit-mdi.c (gedit_mdi_set_active_window_verbs_sensitivity): behave - gently when active_window == NULL - - * gedit-prefs.c: write and read GEDIT_BASE_KEY GEDIT_PREF_WRAP_MODE and - GEDIT_BASE_KEY GEDIT_PREF_TOOLBAR_LABELS as int - - * dialogs/gedit-preferences-dialog.c (gedit_preferences_dialog_update_settings): - update font and colors settings even if the default ones are selected - -2001-12-11 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (gedit_cmd_help_about): fixed - - * dialogs/gedit-preferences-dialog.c : Save page added (it still - does nothing) - -2001-12-11 Paolo Maggi <maggi@athena.polito.it> - - * gedit-prefs.c (gedit_prefs_save_settings): check if gconf_client != NULL - (gedit_prefs_load_settings): ditto - (gedit_prefs_init): ditto - - * bonobo-mdi.c: calls to g_print removed - -2001-12-10 James Willcox <jwillcox@cs.indiana.edu> - - * gedit-prefs.c: Converted to use gconf. - -2001-12-10 Paolo Maggi <maggi@athena.polito.it> - - * gedit-mdi.c (gedit_mdi_set_app_toolbar_style): icons->icon - -2001-12-09 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi.child.c (bonobo_mdi_child_instance_init): ref and sink mdi_child - - * bonobo-mdi.c (bonobo_mdi_instance_init): ref and sink mdi - (book_motion)(book_button_press)(book_button_release): fix a bug related to - GtkNotebook being NO_WINDOW - (set_active_view): call gtk_widget_grab_focus on the view - (bonobo_mdi_set_active_view): removed a call to gtk_widget_grab_focus - - * gedit-document.c (gedit_document_load): try to convert file contents to UTF8 - from current locale if the file contains invalid UTF8 data - - * gedit-file.c (gedit_file_exit): save prefs before unreffing gedit_mdi - (gedit_file_open_uri_list): passes the active child to gedit_file_open_real - - * gedit-mdi-child.c (gedit_mdi_child_create_view): removed unused old code - - * gedit-mdi.c (gedit_mdi_update_ui_according_to_preferences): set selected - text colors - (gedit_mdi_init): fix a leak - - * gedit-prefs.[ch]: added prefs for selected text colors - - * gedit-view.c (gedit_view_grab_focus): yeah, now we have a red blinking cursor - (gedit_view_init)(gedit_view_set_colors): set selected text colors - - * dialogs/gedit-dialog-uri.c: ativate Open button when ENTER is pressed - - * dialogs/gedit-preferences-dialog.c: added support for selected text colors - -2001-12-08 Abel Cheung <maddog@linux.org.hk> - - * gedit-file.c: Fixed misspellings. - -2001-12-03 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (TO_BE_IMPLEMENTED): new macro - (gedit_cmd_file_print): marked as TO_BE_IMPLEMENTED - (gedit_cmd_file_print_preview): marked as TO_BE_IMPLEMENTED - (gedit_cmd_help_about): added a caveat - (gedit_cmd_search_find_again): new function - (gedit_cmd_search_replace): marked as TO_BE_IMPLEMENTED - - * gedit-commands.h (gedit_cmd_search_find_again): new prototype - - * gedit-document.c (gedit_document_get_last_searched_text): new function - (gedit_document_find_again): new function - - * gedit-document.h (gedit_document_get_last_searched_text): new prototype - (gedit_document_find_again): ditto - - * gedit-menus.c: added SearchFindAgain to gedit_verbs [] - - * gedit-prefs.c: added #include "gedit2.h". - (gedit_prefs_save_settings): save the active top level window size - - * dialogs/gedit-dialog-replace.c (gedit_dialog_find): remember the last - searched text per document - -2001-12-03 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c (gedit_document_find): when some text is selected and you - want to search beginning from the cursor position, start searching - from the end of the selection - - * dialogs/gedit-dialog-replace.c: added beginning and cursor to _GeditDialogFind - and _GeditDialogReplace - (find_dlg_find_button_pressed): set active "search from cursor" radiobutton - when needed - -2001-12-02 Paolo Maggi <maggi@athena.polito.it> - - * gedit-document.c: added last_searched_text to GeditDocumentPrivate - (gedit_document_finalize): free last_searched_text - (gedit_document_find): new function - - * gedit-document.h (gedit_document_find): new prototype - - * gedit-mdi.c (gedit_mdi_update_ui_according_to_preferences): set wrap mode too - - * gedit-prefs.h : word_wrap -> wrap_mode - - * gedit-prefs.c : #define DEFAULT_FONTSET removed. - Definition of DEFAULT_FONT changed, now the default font is Sans 12 - (gedit_prefs_save_settings): save wrap_mode - (gedit_prefs_load_settings): use g_new0 to allocate settings. Load wrap_mode. - Fix a memory leak with font. - - * gedit-print.c : some experiment with libgnomeprintui-2.0. It is really broken :-( - - * gedit-ui.xml : hide Plugins and Debug menus - - * gedit-view.c (gedit_view_init): use the preferrend wrap_mode when a GeditView is - created. Fixed a bug with colors and font preferences. - (gedit_view_set_colors): rewritten to use gtk_widget_modify_base and - gtk_widget_modify_text - (gedit_view_set_font): rewritten to use gtk_widget_modify_font - (gedit_view_set_wrap_mode): new function - (gedit_view_set_tab_size): new function. ATTN: it is broken - - * gedit-view.h: (gedit_view_set_wrap_mode): new prototype - (gedit_view_set_tab_size): new prototype - - * dialogs/gedit-dialog-replace.c : gedit-mdi-child.h and gedit-debug.h #included - (find_dlg_find_button_pressed): implemented - (gedit_dialog_find): close correcly the find dlg - - * dialogs/gedit-preferences-dialog.c : wrap mode page added. - Save and Tabs pages hidden. Paper and Page empty pages added. - (gedit_preferences_dialog_setup_logo_page): new function - (gedit_preferences_dialog_setup_wrap_mode_page): ditto - (gedit_preferences_dialog_update_settings): read data from wrap mode page too. - - * gedit-preferences.glade2 : wrap mode page added. - -2001-11-28 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.c (gedit_cmd_settings_preferences): now it really update gedit settings - (gedit_cmd_help_about): cleaned a bit - - * gedit-mdi.c (gedit_mdi_set_app_status_bar): removed - (gedit_mdi_set_app_statusbar_style): new functio - (gedit_mdi_set_app_toolbar_style): almost rewritten - (gedit_mdi_update_ui_according_to_preferences): new function - - * gedit-mdi.h (gedit_mdi_update_ui_according_to_preferences): new prototype - - * gedit-prefs.[ch]: removed some unused prefs - - * gedit-view.c (gedit_view_init): use the preferred colors and font when - a GeditView is created - (gedit_view_set_colors): new function - (gedit_view_set_font): ditto - - * gedit-view.h (gedit_view_set_colors): new prototype - (gedit_view_set_font): ditto - - * dialogs/gedit-preferences-dialog.c: cleaned - (gedit_preferences_dialog_update_settings): new function - -2001-11-27 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gedit-preferences-dialog.c: added Undo and Tabs pages, removed Save page. - - * dialogs/gedit-preferences.glade2: finished... I hope - -2001-11-26 Paolo Maggi <maggi@athena.polito.it> - - * Makefile.am: -DGEDIT_UI_DIR and -DGEDIT_GLADE_DIR added to INCLUDES, - ui_DATA defined, added gedit-print.c and gedit-print.h to gedit2_SOURCES - - * bonobo-mdi.c (app_create): removed old commented code - - * gedit-commands.[ch] (gedit_cmd_file_print): new function - (gedit_cmd_file_print_preview): ditto - (gedit_cmd_settings_preferences): ditto - - * gedit-file.c (gedit_file_save_as_ok_button_clicked_handler): typo - - * gedit-mdi.c (gedit_mdi_init): removed old commented code, search - gedit-ui.xml in the rigth location - - * gedit-menus.c: added FilePrint, FilePrintPreview and SettingsPreferences to - gedit_verbs [] - - * gedit-prefs.[ch]: added two new preferences, i.e. use_default_font and use_default_colors - - * dialogs/Makefile.am: -DGEDIT_UI_DIR and -DGEDIT_GLADE_DIR added to INCLUDES, - added gedit-preferences-dialog.[ch] to libdialogs_a_SOURCES - - * dialogs/gedit-dialog-goto-line.c (dialog_goto_line_get_dialog): search glade file in the rigth location - - * dialogs/gedit-dialog-uri.c (dialog_open_uri_get_dialog): ditto - - * dialogs/gedit-dialog-replace.c (dialog_replace_get_dialog): ditto - (gedit_dialog_replace): close window only when "replace all" or "close" button is pressed - - * gedit-print.[ch] - * dialogs/gedit-preferences.glade2 - * dialogs/gedit-preferences-dialog.[ch]: new files - - -2001-11-23 Paolo Maggi <maggi@athena.polito.it> - - * gedit-commands.[ch] (gedit_cmd_search_replace): new function - - * gedit-menus.c: added SearchReplace to gedit_verbs [] - - * dialogs/gedit-dialog-replace.c: almost rewritten - - * dialogs/gedit-dialogs.h (gedit_dialog_replace): new prototype - -2001-11-19 Paolo Maggi <maggi@athena.polito.it> - - * bonobo-mdi.c: (bonobo_mdi_destroy) doesn't use GTK_OBJECT_DESTROYED anymore - - * gedit-document.[ch] (gedit_document_load_from_stdin): new function - (gedit_document_begin_not_undoable_action): ditto - (gedit_document_end_not_undoable_action): ditto - - * gedit-file.[ch] (gedit_file_open_from_stdin): new function - - * gedit-recent.c (gedit_recent_cb): check if active_child != NULL before - casting to GEDIT_MDI_CHILD - - * gedit2.c (gedit_load_file_list): now calls gedit_file_open_from_stdin (NULL) - -2001-11-16 Carlos Perelló MarÃn <carlos@gnome-db.org> - - * gedit2.c: Added support to AM_GLIB_GNU_GETTEXT - * gedit-recent.c, gedit-utils.c, gedit-document.c, gedit-file.c: - Fixed the gnome-vfs-helpers.h include. - -2001-11-16 Paolo Maggi <maggi@athena.polito.it> - - * Started the port to GNOME 2.0 - -2001-11-16 Carlos Perelló MarÃn <carlos@gnome-db.org> - - * ChangeLog: rolled over to ChangeLog-20011116. diff --git a/gedit/ChangeLog-20011116 b/gedit/ChangeLog-20011116 deleted file mode 100644 index b134db2cc..000000000 --- a/gedit/ChangeLog-20011116 +++ /dev/null @@ -1,2238 +0,0 @@ -2001-10-10 Jason Leach <jasonleach@usa.net> - - [Fix #61989, Text selection color unthemed] - - * view.c (gedit_view_init): Get a copy of a mapped widget, the - GnomeApp in this case, then modify that copy's foreground and - background colors to the ones from settings, then apply this to - the text widget style, ensuring everything except foreground and - background colors come from the user's theme. - - [Fix #60223, Use 'want' instead of 'wish' in dialogs] - - * document.c (remove_child_cb): s/wish/want/ - - * file.c (file_revert_cb): Ditto. - -2001-09-11 Chema Celorio <chema@celorio.com> - - * view.c (gedit_switch_view): wrap arround. And the keys where inverted - -2001-09-10 Chema Celorio <chema@celorio.com> - - * prefs.c (gedit_prefs_load_settings): gettextize the default font. - -2001-09-08 Chema Celorio <chema@celorio.com> - - * view.c (gedit_switch_view): fix 60209. When in notebook mode you can - switch documents with Ctrl+Page_UP & Ctrl+Page_Down - - * recent.c : Fix 59114. Recent file menu entries that contain underscores - are displayed properly. This resulted in a ugly hack because this is a limitation - in libgnomeui so i had to borrow a lot of code. - -2001-06-04 Vlad Harchev <hvv@hippo.ru> - - * print-util.[ch] (gedit_print_show): Added gedit_print_show - printing - routine that is fully i18n-wise correct (taken from gnumeric-0.64). - (gedit_print_show_iso8859_1): compile it only if i18n-wise incorrect - printing is requested by undefining _PROPER_I18N - - * print-doc.c (print_ps_line)(print_header): Use just added - gedit_print_show instead of gedit_print_show_iso8859_1 - -2001-06-04 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_open): if the file is not an URI, ask the user if he - wants to create it. - -2001-05-27 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_convert_to_full_pathname): handle uris. Make static, - fix a bug. - (gedit_file_determine_read_only): split from file_open - - * document.c (gedit_document_load): fix. Remove the file opening code from - here. move to file.c - * other files : cosmetic improvements - -2001-05-15 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gtkchecklist.c (gtk_check_list_finalize): memleak - (gtk_check_list_clear): memleak - -2001-05-15 Paolo Maggi <maggi@athena.polito.it> - - * document.c (gedit_document_get_buffer): clean the code and - update documentation - -2001-05-15 Paolo Maggi <maggi@athena.polito.it> - - * print.c: #included "print-util.h" to silent a warning - -2001-05-10 Paolo Maggi <maggi@athena.polito.it> - - * document.c (remove_child_cb): msgbox parented - - * plugin.c (gedit_plugins_menu_add): hint for "Manager..." menu entry - set to "Manage available plugin modules" (like in Gnumeric) - - * prefs.[ch]: Preferences::use_fontset removed - - * view.c (gedit_view_set_font): now gedit can use fontsets - - * dialogs/plugin-manager.glade: cosmetic changes - -2001-04-23 Jason Leach <jasonleach@usa.net> - - * debug.[ch]: New files, split off the debugging stuff from - utils.[ch] and put them here. - -2001-04-02 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/dialo-plugins.c: fix typo in - GEDIT_PLUGIN_MANAGER_GLADE_FILE - -2001-04-02 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/uri.glade: changed the title of the dialog to - "Open from URI..." - - * dialogs/dialog-about.c (dialog_about): set a parent for the about - dialog - - * dialogs/about.glade: set visible to FALSE - -2001-03-28 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/gtkchecklist.h: new file - - * dialogs/gtkchecklist.c: new file - - * dialogs/Makefile.am (libdialogs_a_SOURCES): added gtkchecklist.h - and gtkchecklist.c - - * dialogs/dialog-plugins.c: - * dialogs/plugin-manager.glade: - * dialogs/plugin-manager.glade.h: rewritten for the new plugin manager - -2001-03-28 Jason Leach <jasonleach@usa.net> - - * view.h (struct _GeditToolbar): chaned the @undo and @redo to - 1-bit gboolean instead of gint types. - - * search.c: S/DEBUG_RECENT/DEBUG_SEARCH/ everywhere in here. - -2001-03-24 Chema Celorio <chema@celorio.com> - - * view.c (gedit_event_key_press): fix a long time know - nasty code - -2001-03-19 Paolo Maggi <maggi@athena.polito.it> - - * document.c (gedit_document_load): new check on URI - - * menus.c: comment the File Info menu item. Now we have the - Document Info plugin - - * search.c (file_info)(gedit_file_info_cb): commented with #if0 - (should I remove them?) - - * search.h (gedit_file_info_cb): commented - - * window.c (gedit_window_set_widgets_sensitivity): don't change - sensitivity of the the File Info menu item. - -2001-03-18 Chema Celorio <chema@celorio.com> - - * release 0.9.6 - -2001-03-10 Chema Celorio <chema@celorio.com> - - * gedit.c (options): debug-window should set debug_window. - Thanks Gary Benson <garyb@ee.bath.ac.uk> for pointing this out - -2001-03-18 Chema Celorio <chema@celorio.com> - - * menus.c (toolbar_data): uncomment the Exit menu ;-) - -2001-03-09 Paolo Maggi <maggi@athena.polito.it> - - * file.c (gedit_file_open): bug fix - -2001-03-07 Paolo Maggi <maggi@athena.polito.it> - - * menus.c: litte menus and toolbar reorganization - - * dialogs/dialog-replace.c (search_not_found_notify): - "Text not found" string replaced with "Search string not found" - - * dialogs/prefs.glade: added accelletators - -2001-03-03 Jason Leach <jasonleach@usa.net> - - * file.c (gedit_file_open): Update for gnome-vfs-0.6.2 by changing - gnome_vfs_file_info_init() to gnome_vfs_file_info_new() and - adjusting a few other small things. - -2001-02-28 Chema Celorio <chema@celorio.com> - - * print.c (gedit_print): handle canceled and hittin print - on the print preview window ok. - - * print-doc.c (gedit_print_document_determine_lines): remove - debugin output - -2001-02-25 Chema Celorio <chema@celorio.com> - - * print-doc.c (gedit_print_document): clean the code a bit. - But it really need a rewrite - - * print-util.c (gedit_print_progress_clicked): implement. - Printing can now be canceled - - * print.c (gedit_print): run verify fonts - (gedit_print): actually print - -2001-02-25 Chema Celorio <chema@celorio.com> - - * print.h: add progress_bar * progress_dialog - - * print-util.c (gedit_print_progress_start): implement. - (gedit_print_progress_tick): implement - (gedit_print_progress_end): implement - - -2001-02-24 Chema Celorio <chema@celorio.com> - - * print-doc.c: move all the actual printing code here. print.c - is the glue between gedit & gnome-print. This code is butt ugly. - It has my name, but I didn't write it ;-)! - - * print-util.c: new file - * print-doc.h: ditto - * print-util.h: ditto - - * print.c: full rewrite. - I need no longer to hide the fact that i wrote this code. - - * Makefile.am: add print-doc.[ch] & print-util.[ch] - - * menus.c (popup_menu): the priting functions where renamed. update. - * window.c (gedit_window_set_widgets_sensitivity): ditto - - * document.h (GEDIT_IS_DOCUMENT): the macro should be GEDIT_IS_DOCUMENT - - * view.c (gedit_view_get_document): Implement - - * document.c (gedit_document_set_undo): use new macro GEDIT_IS_DOCUMENT - -2001-02-20 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/dialogs.h: modified gedit_plugin_program_location_dialog - prototype - - * dialogs/dialog-plugins.c (gedit_plugin_program_location_dialog): - added two parameters - - * dialogs/dialog-plugins.c: - * dialogs/program.glade: - * plugin-manager.glade: embellishment of the dialogs - - * plugin.c (gedit_plugin_program_location_get): use the modified - gedit_plugin_program_location_dialog - -2001-02-19 Paolo Maggi <maggi@athena.polito.it> - - * document.c (gedit_document_set_readonly): now uses g_return_if_fail - instead of g_assert - (gedit_document_get_tab_name): now uses g_return_val_if_fail - instead of g_assert - - * recent.c (gedit_recent_update_all_windows): now uses g_return_if_fail - instead of g_assert - - * window.c (gedit_window_set_widgets_sensitivity_ro): g_asserts removed - - * dialogs/dialog-replace.c (dialog_display_messages): fix typo - -2001-02-15 Paolo Maggi <maggi@athena.polito.it> - - * file.c (gedit_file_open): flash a message on the status bar - reporting the name of the file is going to be loaded - - * gedit.c (main): now gedit_document_load is called after - the gtk main loop is started - - * window.h: added new macro MSGBAR_LOADING_FILE - -2001-02-13 Paolo Maggi <maggi@athena.polito.it> - - * document.c (gedit_document_load): stupid bug fixed - when loading files with escaped name. - -2001-02-13 Paolo Maggi <maggi@athena.polito.it> - - * document.c (gedit_document_get_tab_name)(gedit_document_load) - (gedit_document_set_title): - * file.c (gedit_file_open)(gedit_file_save_as)(gedit_file_save) - (gedit_file_save_as_ok_sel) - * print.c (print_set_pji): - * recent.c (gedit_recent_add_menu_item) : added support for - escaped file names and URIs - -2001-02-13 Paolo Maggi <maggi@athena.polito.it> - - * file.c (gedit_file_open): now uses g_return_val_if_fail - instead of g_assert - (gedit_file_open_ok_sel): now uses g_return_if_fail - instead of g_assert - - * document.c (gedit_document_load): now uses - g_return_val_if_fail instead of g_assert - -2001-02-12 Paolo Maggi <maggi@athena.polito.it> - - * file.c (gedit_file_save_as_ok_sel): remove g_assert - that crashed gedit when exiting and saving a file. - (file_save_document): before saving a document raise - one of its views. - - * document.c (remove_child_cb): before removing a mdi child - raise a view if the document is changed. - - -2001-02-11 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_save_as_ok_sel): remove g_asserts - that where crashing then exiting gedit and saving a file. - - * view.c (gedit_view_set_tab_size): implement - (gedit_view_init): call _set_tab_size after creating the gtk_text - widget. - - * window.c (gedit_window_refresh_all): call set_tab_size - - * prefs.c (gedit_prefs_load_settings): tab size. Save load and - add to struct. - - * dialogs/dialog-prefs.c (apply_cb): support for tab size - - * window.c (gedit_window_refresh_all): add a tab size changed parameter - - * file.c: remove message to translators - -2001-02-07 Paolo Maggi <maggi@athena.polito.it> - - * dialogs/dialog-uri.c (open_button_pressed): - hide dlg before trying to load file from URI - -2001-02-07 Paolo Maggi <maggi@athena.polito.it> - - * view.c (gedit_view_init): the same popup menu is attached - to all the wiews - - * window.c (gedit_window_set_widgets_sensitivity_ro): fix - - * dialogs/dialog-uri.c (dialog_open_uri_get_dialog)(open_button_pressed): - now uri history is not saved - -2001-02-05 Paolo Maggi <maggi@athena.polito.it> - - * file.c: new variable save_all_flag, new enum GeditSaveAllFlagStates - (save_all_continue): new function - (gedit_file_save_as): now it saves the right file and the save as dialog is modal - (gedit_file_save): active a document's view before saving the document - (file_save_all): now it really saves all the modified files - (file_open_cb): now the open dialog is modal - (gedit_file_save_as_ok_sel): call file_save_all when needed - - * dialogs/dialog-uri.c (dialog_open_uri_get_dialog): the open from uri - dialog is modal - -2001-02-02 Paolo Maggi <maggi@athena.polito.it> - - * file.c (file_save_all_cb): only call file_save_all - (file_save_all): new function - (gedit_file_save_as): show file name in the save as dialog - - * file.h: added definition of file_save_all - - * window.c (gedit_window_set_widgets_sensitivity_ro): now it - does not set "Save All" menu item sensitivity - - * document.c (gedit_document_set_readonly): set doc->changed to FALSE - (gedit_document_get_tab_name): add the 'star' parameter - (remove_child_cb): little code reorganization - (gedit_document_set_title): now the title contains also the path of the file - - * document.h: added the 'star' parameter to gedit_document_get_tab_name - - * print.c(print_set_pji): new title for the preview window - - * search.c (gedit_file_info_cb): now it uses the new gedit_document_get_tab_name - - * view.c (gedit_view_set_readonly): now it uses the new - gedit_document_get_tab_name - (gedit_view_text_changed_cb): now it changes the tab name when a document is - modified - - * dialogs/dialog-uri.c (open_button_pressed): set ro sensitivity when needed - -2001-01-30 Paolo Maggi <maggi@athena.polito.it> - - * document.c: #included <libgnomevfs/gnome-vfs.h> - (gedit_document_load): re-written to use gnome-vfs - - * file.c: #include <libgnomevfs/gnome-vfs.h> and "dialogs/dialogs.h" - #defined PREALLOCATED_BUF_LEN - (gedit_file_open): re-written to use gnome-vfs - (uri_open_cb): new function - (gedit_file_open_ok_sel): check if gedit_document_current() != NULL - before setting readonly flag - - * file.h: added definition of uri_open_cb - - * gedit.c: #included <libgnomevfs/gnome-vfs.h> - (main): initialize gnome-vfs - - * menus.c: added item "Open from _URI..." in File menu - - * dialogs/uri.glade: new file - - * dialogs/uri.glade.h: new file - - * dialogs/dialog-uri.c: new file - - * dialogs/Makefile.am: new files added - - * dialogs/dialogs.h: added definition of gedit_dialog_open_uri - -2001-01-26 Paolo Maggi <maggi@athena.polito.it> - - * menus.c: added a separator in the toolbar - -2001-01-26 Paolo Maggi <maggi@athena.polito.it> - - * plugin.h: new field modify_an_existing_doc - - * plugin.c (gedit_plugin_load) : default setting for - modify_an_existing_doc is FALSE - - * window.h: - * window.c: new function gedit_window_set_widgets_sensitivity_ro - - * file.c (gedit_file_save_as_ok_sel)(gedit_file_open_ok_sel) - * document.c (gedit_document_load ) - * recent.c (recent_cb) - * view.c (gedit_view_changed_cb)(gedit_view_add_cb)(gedit_view_remove): - correctly set menu and toolbar item sensitivity when a read only file - is opened (or saved) - -2000-12-14 Alex Roberts <bse@bakterium.com> - - * prefs.c (gedit_prefs_save_settings): only save the run flag - if it's FALSE. we really dont need to save it each time we save. - - * file.c: added missing semicolon to the message. now it - actually compile ;) - -2000-11-28 Chema Celorio <chema@celorio.com> - - * file.c: add message for Translators - -2000-11-20 Chema Celorio <chema@celorio.com> - - * new branch: HEAD is going to get ported to the - new text widget and gnome-vfs. - This is the unstable branch of gedit. - -2000-11-22 Paolo Maggi <maggi@athena.polito.it> - - * menus.c: litte menus and toolbar reorganization - - * plugin.c (gedit_plugins_menu_add): add an icon to the - "Manager..." menu entry - - * dialogs/replace.glade: cosmetic layout changes - -2000-11-20 Chema Celorio <chema@celorio.com> - - * dialogs/about.glade: Added paolo and roberto to the about - box. - - * prefs.c (gedit_prefs_load_settings): fix a crash. - -2000-11-20 Paolo Maggi <maggi@athena.polito.it> - - * recent.c (recent_cb): when needed update the recent file - menu in all open windows - -2000-11-18 Paolo Maggi <maggi@athena.polito.it> - - * plugin.c: #defined DATA_PLUGINS_TO_REMOVE - (gedit_plugins_menu_add): fix problems when used - with more than one toplevel windows; remove old broken - code - - * plugin.h: menu_item attribute commented because it is not - needed - - * window.c (gedit_window_set_widgets_sensitivity): fix - problems withplugins sensitivity; remove old broken code - (gedit_window_set_plugins_menu_sensitivity): new method - - * window.h: new method gedit_window_set_plugins_menu_sensitivity - - * dialogs/dialog-plugins.c: #included <string.h> to fix warnings - (gedit_plugin_manager_clicked): set plugins menu sensitivity - - * undo.c: #included <string.h> to fix warnings - - * dialogs/dialog-replace.c: #included <string.h> to fix warnings - (dialog_display_messages): fix warning - - * dialogs/dialog-prefs.c: #included <string.h> to fix warnings - -2000-11-17 Paolo Maggi <maggi@athena.polito.it> - - * recent.c: #defined DATA_ITEMS_TO_REMOVE - (gedit_recent_update_menus): fix recent items - bugs. Now the right number of items are removed from menu - (gedit_recent_update_all_windows): new method - (gedit_recent_update): documentation modified - - * recent.h: new method gedit_recent_update_all_windows - - * file.c (gedit_file_open): now it uses - gedit_recent_update_all_windows in place of gedit_recent_update - (gedit_file_save_as_ok_sel): now it uses - gedit_recent_update_all_windows in place of gedit_recent_update - -2000-10-30 Chema Celorio <chema@celorio.com> - - * recent.c (gedit_recent_update_menus): add a comment for - tranlators - -2000-10-28 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_view_menu_sensitivity): add some - g_return_ and GTK_IS_WIDGET to avoid a crash. - (gedit_window_set_widgets_sensitivity): ditto - -2000-10-28 Chema Celorio <chema@celorio.com> - - * print.c (g_unichar_to_utf8): new function temp. - (print_show_iso8859_1): new function so that we can print - with the new gnome-print. Remove when we use unicode internally - (print_ps_line): use new function for show - -2000-10-21 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_set_font): memleak - (gedit_view_destroy): new method - (gedit_view_finalize): remove - - * document.c (gedit_document_destroy): memleak - - * recent.c (gedit_recent_add_menu_item): memleak - -2000-10-20 Chema Celorio <chema@celorio.com> - - * search.c (gedit_search_pos_to_line): rename from pos_to_line - (gedit_replace_all_execute): add a parameter to cursor position - - * dialogs/dialog-replace.c (action_replace_all): set the window - and cursor position after replace all. - -2000-10-20 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c (action_replace_all): use g_doc_replace_text - v.s. using g_doc_delte + g_doc_insert so that undo is a 1 step process - -2000-10-20 Chema Celorio <chema@celorio.com> - - * search.c (gedit_replace_all_execute): I need to write 100 pages - of "I shall not use unsigned numbers ..." - -2000-10-20 Chema Celorio <chema@celorio.com> - - * search.c (gedit_search_execute): kill a warning - (gedit_replace_all_execute): fix a stupid crash - - * dialogs/dialog-replace.c (action_replace_all): fix #29036 - (action_find): kill a warning - -2000-10-17 Chema Celorio <chema@celorio.com> - - * prefs.c (gedit_prefs_save_settings): quick fix to not crash - when gedit is beeing closed thru the window manager. - /me opens the brown paper bag drawer - -2000-10-16 Chema Celorio <chema@celorio.com> - - * search.c (gedit_replace_all_execute): fix a crash when replacing - all. (gmorten found it). - - * recent.c (gedit_recent_update_menus): rewrite, fix recent items - bugs. - (gedit_recent_add_menu_item): implement - (gedit_recent_remove): clean - - * prefs.h (struct _Preferences): remove settings->num_recent, we have - recent file list, and we know the size of the list. - - * recent.c (gedit_recent_update_menus): don't return if list == NULL. - This was causing a crash. - - * menus.c: clean the file, remove unused stuff - add ifndef's for stuff that is disabled - * menus.h: ditto - -2000-10-15 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-prefs.c (apply_cb): fix a crash when starting with - a clean ~/.gnome/gedit. You Shall strdup a string you plan to free. - -2000-10-15 Chema Celorio <chema@celorio.com> - - * menus.c: renamed some public functions prepending gedit_ - to their names - - * search.h: clean and leave only the functions that are called. - - * search.c: make this struct private, move from .h to .c - start cleaning this file too. - - * document.h (struct _GeditDocument): ditto. Rename from Document - to GeditDocument - - * view.h (struct _GeditView): start to clean this mess. This struct - is much smaller now. Rename from View to GeditView - - * view.c (gedit_view_get_type): start cleaning this file. Adding function - descriptions and removing the nonsense code. - - * file.c (file_revert_cb): kill a memleak when reverting documents. - (gedit_file_open): do not allow doc->filename & fname to point at the - same location. We might free doc->filename inside. - -2000-10-15 Chema Celorio <chema@celorio.com> - - * undo.c (gedit_undo_add): allow adding 0 size undo elements. The user - might replace "foo" with "". - - * prefs.c (gedit_prefs_save_settings): only save the window size when - the window is not maximized. - - * dialogs/dialogs.h: prepend gedit_ to all the functions. Rename - the references to this function names. - - * dialogs/dialog-replace.c (gedit_find_again): implement find again - - * undo.c (gedit_undo_check_size): when removing undo objects from the stack - verify that we remove pairs of replaces together. We where leaving half of - an undo state in the stack - - * search.c (gedit_search_replace_all_execute): limit the size that the buffer - can grow to. Gedit pukes on large g_reallocs. - -2000-10-14 Chema Celorio <chema@celorio.com> - - * search.c (gedit_search_replace_all_execute): grow the buffer using levien's - method (<<=1). This helps gedit to not crash when allocating for large buffers. - - * view.c (gedit_view_init): remove the panned window again - -2000-10-14 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c: rewrite, use coolio gnome-dialog functions. - This code looks so much cleaner. - - * view.c (gedit_view_delete): fix a problem that was causing replace - all to really suck. - - * search.c (gedit_search_replace_all_execute): constify & - fix a small bug that was causing a warning to be emited - - * view.c (gedit_view_set_window_position_from_lines): fine tune - - * search.c (search_text_execute): constify - * undo.c (gedit_undo_add): constify - (gedit_undo_merge): constify - (struct _GeditUndoInfo): make this struct private to undo.c - : remove <gnome.h> - - * document.c (gedit_document_replace_text): constify - - * dialogs/dialog-prefs.c: remove g_print - * print.c: ditto - -2000-10-13 Yuri Syrota <rasta@renome.rovno.ua> - - * file.c: replace "0pplication" with "application" - (syntax error in message) - -2000-10-10 Chema Celorio <chema@celorio.com> - - * prefs.h (struct _Preferences): print_lines was marked as ": 1" and - the print lines function did not worked. Fix. - - * file.c (gedit_file_open_ok_sel): if there aren't any selected files. - Open the file specified in the entry - - * plugin.c (gedit_plugin_guess_program_location): kill 3 leaks - gnoem_config_get_string returns g_malloc'ed strings - (gedit_plugin_program_location_change): mem leak - (gedit_plugin_program_location_get): another one - - * file.c (gedit_file_selector_key_event): if the user hits ESC in the - open or save dialog, destroy the dialog - - * search.c (file_info_cb): kill another memleak - - * commands.c (tab_right_cb): use left,bottom & right. Not lft,btm &rgt - - * dialogs/dialog-goto-line.c: rewrite. Actually understand gnome_dialog - and use it. - -2000-10-10 Kjartan Maraas <kmaraas@gnome.org> - - * dialogs/dialog-prefs.c: Changed to really work with - gnome_help_pbox_display(). - -2000-10-09 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-goto-line.c: the goto line dialog is no longer public - kill memleaks and clean the file a bit - - * plugin.c (gedit_plugins_menu_add): kill 2 strings that we - where leaking - - * recent.c (gedit_recent_update_menus): kill a mem-leak - - * view.c (gedit_view_class_init): After months of not beeing - able to sleep well over this bug. Killed this mother fucker ! - I wached this bug ask for forgiveness before squashing it to the - floor. - - Close : - #14756, #5260, #12325, #13576, #14104, #14204, - #15528, #15669, #15746, #16197, #20325; - - * file.c (gedit_file_open): allow the opening of 0 bytes files, - users have requested this feature. - (gedit_file_save): allow the user to save 0 bytes files - - make open_file_selector private and static - - (file_open_cb): Implement multiple file opening - (gedit_file_selector_get_filenames): - (gedit_file_open_ok_sel): - - -2000-10-08 Chema Celorio <chema@celorio.com> - - * print.c: clean - -2000-10-07 Kjartan Maraas <kmaraas@gnome.org> - - * dialogs/dialog-prefs.c: (dialog_prefs_impl): Use - gnome_help_pbox_display() instead of gnome_help_pbox_goto() - to make sure the help comes up in the gnome-help-browser. - -2000-09-08 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_refresh_line_hack): finally fixed the problem when - deleting a complete line of text. close bug #19862 - -2000-08-31 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_save): add more checks to improve robustness - - * window.c (gedit_window_new): no need to load the icon here. - - * gedit.c (main): use new icon - - * view.c (gedit_views_insert): if text length <1, return - -2000-08-30 Chema Celorio <chema@celorio.com> - - Fixed small bugs/issues here & there - - * file.c (gedit_view_insert_if_mapped): after more than 10 hrs. finaly - fixed the crash reported in - #19044: program crashed - #20097: gedit DnD crash - #20743: crashes when opening DOS file - #22287: (crash during mime) loaded a temp file from gftp. bryce weiner <cogburn@fuse.net>. - It is based on a semi-hacky soltuion, but users want a stable editor. - -2000-07-09 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_save): fix 16143 - -2000-07-07 Chema Celorio <chema@celorio.com> - - * plugin.c (gedit_plugin_load): do not "_(" mark warning messages for - translation - -2000-07-06 Chema Celorio <chema@celorio.com> - - * view.c (doc_insert_text_real_cb): new function to fix #16374. We cant assume that - a parameter that is not passed to a funciton will be TRUE. - - * document.c (gedit_document_insert_text): call doc_insert_text_real_cb - - same for the _delete_ function - -2000-07-05 Chema Celorio <chema@celorio.com> - - * search.c (file_info_cb): added total size to the dialog - -2000-07-05 Chema Celorio <chema@celorio.com> - - * search.c (file_info_cb): kill compile warning - - * view.c (gedit_view_init): fix the code a bit - -2000-07-05 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_init): try to fix the speed problems with sucky - themes. I think they are gone, but we need to verify it. - -2000-07-02 <phoenix@nova.es> - - * search.c (count_lines_cb): This function is reform . add file_info () - * search.c (file_info): Add new function . Return -> total chars , total - words , total lines , total paragraphs .... - -2000-07-01 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_view_menu_sensitivity): set the sensitivity - of the revert menu item - - * view.c (gedit_view_changed_cb): set sentivity of the add/remove view - menu - - * dialogs/dialog-prefs.c (apply_cb): we where not setting tab_pos. - set tab pos after apply. - -2000-06-30 <chema@celorio.com> - - * plugin.h (struct _PluginData): add long_desc - - * dialogs/dialog-plugins.c: - (gedit_plugin_manager_item_clicked): use pd->long_desc v.s. pd->desc - -2000-06-30 <chema@celorio.com> - - * dialogs/dialog-plugins.c: find a work arround for the crash. - -2000-06-29 Chema Celorio <chema@celorio.com> - - * document.c (gedit_document_set_title): fix leak. - -2000-06-29 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-plugins.c: remove g_print's - - * document.c: Do not free docname. back Charles commit. - -2000-06-29 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_add_cb): call set_view_menu_sensitivity after adding a view - (gedit_view_remove): call set_view_menu_sensitivity after removing a view - - * plugin.c (gedit_plugin_load): add installed_by_default code. - * plugin.h (struct _PluginData): ditto - -2000-06-29 Charles Kerr <charles@skywalker.ou.edu> - - * document.c (gedit_document_set_title): small memory leak fixed: - g_free docname before exiting the function - -2000-06-28 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-plugins.c (gedit_plugin_manager_item_clicked): add the plugin description - in the plugin manager when the plugin name is clicked. - -2000-06-27 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_load_widgets): fix a ugly piece of code. - - * window.c (gedit_window_set_view_menu_sensitivity): new function. - -2000-06-26 Chema Celorio <chema@celorio.com> - - * plugin.c (gedit_plugin_save_settings): save the plugins that are installed - - * prefs.c (gedit_prefs_save_settings): call gedit_plugin_save_settings - -2000-06-26 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-plugins.c (gedit_plugin_manager_create): new function - (gedit_plugin_manager_clicked): new func - (gedit_plugin_manager_destroy): new func - (gedit_plugin_manager_item_remove_all): new func - (gedit_plugin_manager_item_add_all): - (gedit_plugin_manager_item_remove): - (gedit_plugin_manager_item_add): - (gedit_plugin_manager_item_load): - (gedit_plugin_clist_compare_function): - (gedit_plugin_lists_freeze): - (gedit_plugin_lists_thaw): - - * plugin.c (gedit_plugins_menu_add): plugin manager stuff - * plugin.h: ditto - -2000-06-25 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_widgets_sensitivity): set sensitity of - the plugins menu items. - - * plugin.h (struct _PluginData): add menu_item and - needs_a_document. - -2000-06-25 Chema Celorio <chema@celorio.com> - - * utils.c (gedit_utils_error_dialog): new function - (gedit_utils_delete_temp): new function [unfinished] - (gedit_utils_create_temp_from_doc): new function - -2000-06-22 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_get_position): fix a bug in which the text - position will not get updated in the text widget when the position - is changed with the mouse. - -2000-06-22 Chema Celorio <chema@celorio.com> - - * plugin.c (gedit_plugin_program_location_get): clean g_prints - * dialogs/dialog-plugins.c: ditto - -2000-06-21 Chema Celorio <chema@celorio.com> - - * utils.h: remove the defines used for accesing the toolbar/menus. - - * view.c (gedit_view_load_widgets): call gnome_mdi_get[menubar/toolbar] - to get the menu/tooblar UI_INFO - * window.c (gedit_window_set_widgets_sensitivity): ditto - -2000-06-21 Chema Celorio <chema@celorio.com> - - * search.c (gedit_search_replace_all_execute): add sanity check - - * window.c (gedit_window_set_widgets_sensitivity): fix a bug - -2000-06-20 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c (replace_text_clicked_cb): fix a bug - adjust start_position after a replace - - * plugin.c (gedit_plugin_program_location_get): fix - (gedit_plugin_program_location_clear): new - -2000-06-20 Chema Celorio <chema@celorio.com> - - * plugin.h: add prototype - - * plugin.c (gedit_plugin_program_location_get): new func. - (gedit_plugin_guess_program_location): new, func. - - * dialogs/dialog-plugins.c (gedit_plugin_program_location_dialog): new file - new function. Move the code from the email plugin to here so that it can - be reused. - - * window.c (gedit_window_set_widgets_sensitivity): fix a bug that made the - new documents unshade the undo && redo items. - - * dialogs/dialog-prefs.c (apply_cb): raise the props box - - * window.c (gedit_window_refresh_all): fix small bug - -2000-06-20 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_widgets_sensitivity): new function that turns - on and off the sensitivty of the menus & toolbar items. - - * file.c (file_close_cb): turn off sensitivty of toolbar and menu - items ( that need a document to work) - (file_close_all_cb): ditto - - * document.c (gedit_document_new_with_file): turn toolbar and - menu items sensitivity on - (gedit_document_new_with_title): ditto - (gedit_document_new): ditto - - * window.c (gedit_window_refresh_all): fix a crash that happened - when apply was clicked in the prefs box and there where no documents - open. - -2000-06-19 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_refresh_all): queue_resize the toolbar when setting - to system settings and system setings = ICONS_ONLY - -2000-06-19 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_refresh_all): fix the bug in which the toolbars will - no get loaded when the mdi_mode is changed. - -2000-06-18 Chema Celorio <chema@celorio.com> - - * undo.c (gedit_undo_check_size): fix the bug that messed the undo stack when reducing - the number of undo levels in the prefs. We need to remove elements from the bottom - up, since the list length is changed every time we removed an element from the top. - - * document.c (gedit_document_swap_hc_cb): kill bug - - * view.c (gedit_view_load_toolbar_widgets): unshade/shade the undo&redo menu items - too - (gedit_view_set_undo): ditto - -2000-06-18 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_toolbar_labels): fix the problem in which the - toolbar will not resize if the prefs are changed from text to icons. - - * document.c (gedit_document_set_title): set title to $docname $(readonly) - for doc->readonly == TRUE. - - (doc_delete_text_cb): if start_pos == end_pos, return. This caused - a warning to appear when the user typed CTL+K and the line length - was null. Should we enable this kind of shortcuts ? I don't think - so. - -2000-06-18 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_init): dont create vpane, since the split screen - is disabled now. - - * window.c (gedit_window_set_toolbar_labels): finish preference toolbar - labels set to system-wide setting. - - * view.c (gedit_view_changed_cb): install menu hints for the Document - menus - -2000-06-18 Chema Celorio <chema@celorio.com> - - * view.c: the toolbar is a view element not a window one - because if mdi_mode = TOPLEVEL, each view has it's own toolbar - * window.c: ditto - * document.c: ditto - -2000-06-17 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-prefs.c: add toobar_labels group - - * prefs.c (gedit_prefs_save_settings): toolbar_labels, change to int - (gedit_prefs_determine_use_fontset): ditto - - * window.c (gedit_window_new): fix the problems with mdi_mode = TOPLEVEL - - * gedit.c (main): reorder the *_init_functions - - * print.c (file_print_cb): #ifdef PRINT_SELECTION so that we can - compile against gnome-print-0.20 - -2000-06-16 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_status_bar): fix - ( still has problems with Mdi_mode=TOP_level) - - * gedit.c (main): change the order of initialization - - * view.c (gedit_view_get_position): add sanity check - - * file.c (gedit_file_open_ok_sel): fix a crash - -2000-06-15 Chema Celorio <chema@celorio.com> - - * prefs.c (gedit_prefs_save_settings): fix a g_warning if the windows is closed - by clickin on the [X] - - * window.c (gedit_window_destroy): remove - -2000-06-15 Chema Celorio <chema@celorio.com> - - * print.c (file_print_cb): finish print_range = selection - you will need to update gnome_print. - - * view.c (gedit_view_get_selection): if star_pos = end_pos - selection is not active. - -2000-06-15 Chema Celorio <chema@celorio.com> - - * document.c (gedit_document_get_tab_name): mark strings for tranlation - in a different way. They are not beeing tranlated. - (gedit_document_set_title): mark string - - * dialogs/dialog-prefs.c (prepare_printing_page): dont' set print_lines sensitivity - (print_lines_toggled): ditto - -2000-06-15 Valek Filippov <frob@df.ru> - - * search.c: microchange for i18n. - -2000-06-15 Chema Celorio <chema@celorio.com> - - * plugin.c (gedit_plugins_window_add): add hints to the plugin menu - use plugin_data->description; - - * window.c (gedit_window_set_status_bar): fix the statusbar. - - * dialogs/dialog-replace.c (replace_text_clicked_cb): memleak fix - -2000-06-14 Chema Celorio <chema@celorio.com> - - * window.h (struct _GeditToolbar): new - - * undo.c (gedit_undo_redo): add the stuff needed to set the - undo and redo buttons sensitivity - (gedit_undo_undo): ditto - - * document.c (gedit_mdi_init): move mdi_open_toplevel here - - * dialogs/dialog-prefs.c (gedit_window_refresh): set toolbar_labels on/off - * gedit.c (main): ditto - * prefs.c (gedit_save_settings): - (gedit_load_settings): ditto - * prefs.h (struct _Preferences): ditto - - * document.c (gedit_mdi_init): rename the "Files" menu to - "Documents" - - * window.c : remove swap hc and move to document.c - - * document.c (gedit_document_swap_hc_cb): moved here & rename - - * window.h: comment out a structure and some variables - that are not beeing used. - -2000-06-14 Chema Celorio <chema@celorio.com> - - * print.c (gedit_print_verify_fonts): new function. It verifies - that the user has the fonts required. - (print_set_pji): fix a stupid bug, close 13922. - - * window.c (doc_swaphc_cb): add error dialogs. - if the file is allready open, don't open it again - set it's view active. - - * search.c (dump_search_state): remove unused enums - SEARCH_IN_PROGRESS_COUNT_LINES & _REPLACE - -2000-06-13 Chema Celorio <chema@celorio.com> - - * utils.h (gedit_debug): add debug_window macro - - * gedit.c: add "gint debug_window" - - * document.c (gedit_document_load): convert the file_list->data - to a full_pathname. - - * file.c (gedit_file_convert_to_full_pathname): new function to convert - the file_name passed as argument to a full path name. - * file.h: add prototype - - * recent.c: rename functions for consistency with the rest - of the code. - - * prefs.c (gedit_load_settings): compose mdi string from - enum and not use a number. - - * file.c (file_close_cb): after closing a doc, set the - title. - - * document.c (gedit_mdi_init): don't display "gedit "VERSION - in the title window, since gedit_document_set_title is not. - If you want to add the version number to the title window - pleas also add it to the function gedit_docuemnt_set_title. - - * view.c (gedit_view_remove_cb): after removing a view, set - the title again. - -2000-06-13 Chema Celorio <chema@celorio.com> - - * file.c: finish fixing the BUG in which gedit will not - exit after a quit request is made from the user or a close - all encounters an Untitled document. This had to be done with - a hack to fix the problem that gnome_mdi_remove_all can't wait - for a save_as dialog encountered when saving Untitled documents. - (gedit_close_all_flag_status): new function - (gedit_close_all_flag_clear): new function - (gedit_close_all_flag_verify): new function - -2000-06-12 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_open): connect the text_changed signal after opening a file. - - * document.c (gedit_document_new_with_file): return TRUE/FALSE upon succes/error - modified all the functions that called this one. - - * view.c (gedit_view_update_line_indicator): new name for line_pos_cb. - - * document.c (gedit_mdi_init): dont' connect to "child_changed" - connect to view_changed so that we set the title of the window - when switching to/from diferent views and not only diferent docs. - - * file.c (file_quit_cb): disconect the "destroy" signal before - calling gedit_object_destroy. Because it was conected to this - function and it was beeing called twice. - - * document.h: added a variable to hold the signal "destroy" - for mdi - - * dialogs/dialog-prefs.c: don't make the dialog modal, if - it Settings->Preferences is called again show and raise - the - - * file.c (gedit_dump_close_all_flag_status): new function - usefull for debuging, remove later. - - * utils.h: add gedit_close_all_flag enums' - -2000-06-11 Chema Celorio <chema@celorio.com> - - * file.c (file_save_document): new function - - * dialogs/dialog-prefs.c (dialog_prefs_impl): make the window modal - -2000-06-11 Chema Celorio <chema@celorio.com> - - * undo.c (gedit_undo_undo): renamed, Implement GEDIT_UNDO_REPLACE - * undo.c (gedit_undo_redo): Implement GEDIT_UNDO_REPLACE - - * menus.c (toolbar_data): replace undo_do with undo_undo - - * file.c (gedit_file_open): after opening a doc - set the position to 0 - - * undo.h (struct _GeditUndoInfo): add GEDIT_UNDO_REPLACE - - * document.c (gedit_document_replace_text): new function - -2000-06-11 Chema Celorio <chema@celorio.com> - - * utils.c: remove gedit_set_title from here - - * document.h: add new prototype - - * document.c (gedit_document_set_title): move here, adn rename - - * file.c (gedit_file_open): call insert_text first and then set - the readonly flag. - - * document.c (gedit_document_delete_text): if doc->readonly return - (gedit_document_insert_text): ditto - - * file.c (gedit_file_save): call save as if doc->filename = NULL - (gedit_file_save_as): new function - (file_save_as_cb): call gedit_file_save_as - - * dialogs/dialog-replace.c (dialog_replace): set the find & replace - dialog title accordingly - -2000-06-11 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_remove_cb): don't remove views if views # < 2 - ( this fixes a crash too ) - - * commands.c (edit_cut_cb): use gedit_editable_current() and - not GTK_TEXT(mdi->whatever.... - - * utils.h (gedit_editable_current): macro for gedit_editable_current() - - * document.c (child_changed_cb): dont use mdi->active view - use gedit_view_current() - -2000-06-10 Chema Celorio <chema@celorio.com> - - * search.c (count_lines_cb): don't display filename (NULL) - use "Untitled #" - -2000-06-09 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_create_popup): dont str_dup the filename - gedit_docuement_new_with_title will. - - * dialogs/dialog-replace.c (dialog_replace): call the correct callback - for "activate" in replace_entry and search_entry they where switched - (replace_entry_activate_cb): act as if the replace button has been clicked - (replace_text_clicked_cb): use gedit_search_info.replace_start & replace_end - when replacing, not the active selection. - (replace_text_clicked_cb): save search_start & end values for replace - when find next gets clicked - - * search.h: add replace_start & replace_end to gedit_search_info - - * search.c (gedit_search_start): clear .replace_start and .replace_end - - * file.c (gedit_file_stdin): fix - -2000-06-09 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_status_bar): fix status bar bug - - * utils.h (options): add DEBUG_WINDOW - - * window.c: add calls to gedit_debug - - * undo.c (gedit_undo_check_size): add call to gedit_debug - - * dialogs/dialog-prefs.c (gtk_option_menu_get_active_index): remove - the \n in gedit_debug(.... - -2000-06-08 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_stdin): use new function to set - the position in the view. - - * view.c (views_delete): make static. - (views_insert): make static - Use new functions to insert into the documents - - * plugin.h: add prototype to kill warning - - * dialogs/prefs.glade: typo - -2000-06-08 Chema Celorio <chema@celorio.com> - - * search.c (gedit_search_replace_all_execute): fix an ugly - crash. - -2000-06-06 Roberto Majadas <phoenix@nova.es> - - * file.c (gedit_file_stdin): fix the pipe constant problem - -2000-06-06 Chema Celorio <chema@celorio.com> - - * search.h: add last_text_searched to the structure and start_pos parameter - to find again. - - * dialogs/dialog-replace.c (replace_text_clicked_cb): save the last text - searched for find again. - - * menus.c (gedit_edit_menu): add FIND_AGAIN menu entry - - * file.c (gedit_shutdown): move this function here. - - * gedit.h (gedit_shutdown): delete and remove from repository - -2000-06-05 Chema Celorio <chema@celorio.com> - - * gedit.h (gedit_shutdown): remove structure from here. - - * search.h: added new prototype - * search.c (search_text_not_found_notify): move here - (find_again_execute): implement - -2000-06-05 Chema Celorio <chema@celorio.com> - - * search.c (gedit_search_replace_all_execute): done. - - * dialogs/dialog-replace.c (replace_text_clicked_cb): call replace all. - and display dialog. - -2000-06-05 Chema Celorio <chema@celorio.com> - - * document.c (gedit_document_get_tab_name): added comments - -2000-06-05 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c (replace_text_clicked_cb): start - replace all stuff - - * search.c (gedit_search_replace_all_execute): start implementing - - * prefs.c: new pref print_orientation - * dialogs/dialog-prefs.c: ditto - - * print.c : implement orientation. - - * view.h (struct _View): clean the struct and optimize it. - - * menus.c (view_menu): call the new functions - -2000-06-05 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_create_popup): rename - - * document.c (gedit_get_document_tab_name): rewrite. - -2000-06-04 Chema Celorio <chema@celorio.com> - - * document.h (struct _Document): clean the structure. - -2000-06-04 Chema Celorio <chema@celorio.com> - - * file.c (file_revert_cb): before reverting a file delete it's text. - - * search.c: remove all direct access to the text - and mdi. Use the new functions to make the code textwidget and mdi - independendant. - - * view.c (gedit_view_get_window_position): new function - (gedit_view_set_window_position): new function - (gedit_view_get_selection): new function - (gedit_view_set_selection): enable it. - * view.c (gedit_view_set_window_position_from_lines): new function - - * window.c (gedit_window_active): new function - - * dialogs/dialog-replace.c: remove all direct access to the text - and mdi. Use the new functions to make the code textwidget and mdi - independendant. - - * undo.c (gedit_undo_do): use the new function to set the scrollbar - position - (gedit_undo_redo): ditto - * undo.h: remove the "extern" directive before each function name - * prefs.h: ditto - * utils.h: ditto - - * view.c (gedit_view_toggle_line_wrap_cb): delete, it was not beeing - used - -2000-06-04 Chema Celorio <chema@celorio.com> - - * document.c (gedit_document_delete_text): new function. - - * undo.c (gedit_undo_do): use gedit_document_delete_text and - gedit_document_insert_text. - (gedit_undo_redo): ditto - - * file.c (gedit_file_open_ok_sel): don't create the - view here. gedit_document_new_with_file will. - - * view.c (views_delete): use gedit_view_delete - (gedit_view_delete): new function. - * view.c (doc_delete_text_cb): rewrite - -2000-06-04 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_insert): don't freeze and thaw the view. - (views_delete): ditto. - - * file.c (gedit_file_stdin): insert to view with the new method. - (gedit_file_save): ditto - (gedit_file_open): if doc = null create one. - - * document.h: add new functions - - * view.c (gedit_add_view): fix . use gedit_document_get_buffer - (gedit_view_buffer_sync): delete - (gedit_view_refresh): delete - - * document.c (gedit_document_new_with_title): set doc->filename - (gedit_document_load): implement. - - * gedit.c (main): call gedit_document_load. - - * view.c (gedit_view_buffer_sync): dont need it anymore - (gedit_view_refresh): don't need it anymore - (gedit_view_insert): new function - (views_insert): call gedit_view_insert - - * document.c (gedit_document_destroy): we don't keep an - internal buffer of the file. So remove all references to it. - (gedit_document_new): ditto - (gedit_document_new_with_title): ditto - - * file.c: renamed the functios to gedit_file_[function] - -2000-06-03 Chema Celorio <chema@celorio.com> - - * view.c (gedit_event_key_press): undo/redo was beeing - called twice when pressing the shortcut key. - - * view.c: remove \n from gedit_debug - * document.c: ditto - * print.c: ditto - * file.c: ditto - * recent.c: ditto - * search.c : ditto - -2000-06-02 Chema Celorio <chema@celorio.com> - - * undo.c (gedit_undo_merge): consider deleting - text with the backspace and the delete key. - -2000-06-04 Roberto Majadas <phoenix@nova.es> - - * gedit.c (main): added a call to gedit_file_stdin - * file.c (gedit_file_stdin): new function. Reads file from - stdin. - * document.c (gedit_document_stdin): new function - -2000-06-02 Chema Celorio <chema@celorio.com> - - * undo.c (gedit_undo_check_size): implement. - checks the undo list size and deletes the objects - with levels < settings->undo_levels - - * dialogs/dialog-prefs.c (apply_cb): added undo_levels_stuff - (undo_levels_toggled): new function - (prepare_documents_page): add undo levels stuff - - * prefs.c: add undo levels. - * prefs.h (struct _Preferences): ditto. - - * undo.c (gedit_undo_merge): check if the position - of the undo text is the same as the last_undo - (gedit_undo_merge): merge GEDIT_UNDO_DELETE too. - -2000-06-02 Chema Celorio <chema@celorio.com> - - * undo.c (gedit_undo_merge): New function. Merges - a previous undo item with the new data. We now undo - words and not chars. This also saves memory because - of less gedit_undo struct's used. - (gedit_undo_free_list): new function. Plugs a memleak - (gedit_undo_add): verify if the data can be merged - and call gedit_free_list - - * utils.h (gedit_debug): add newline to the undo macros, - we have to delete the newline from all the other files. - - * undo.h (GEDIT_UNDO_DELETE): use unique enum's - and not DELETE & INSERT - -2000-06-01 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_current): new function we should use - this function now to add an abstraction layer for future - changes. - - * undo.c (gedit_undo_add): plug a HUGe leak - (gedit_undo_do): plug another leak. - (gedit_undo_redo): adjust the current view, not undo->view - (gedit_undo_do): ditto - - * undo.h (struct _gedit_undo): remove *view from _gedit_undo - structure, we don't need it anymore and saves memory. - - -2000-06-01 Jason Leach <leach@wam.umd.edu> - - * dialogs/Makefile.am (glade_msgs): removed find-line.glade.h so - make distcheck could pass - -2000-06-01 Chema Celorio <chema@celorio.com> - - * document.h (struct _Document): rename buff to buffer - to find all the places where it is beeing used. - - * file.c: use buffer now v.s. buff - - * document.c (gedit_document_get_buffer): new function, - this provides an abstraction layey on the method to get - the text buffer. - - * undo.c (gedit_undo_do): don't update the internal - buffer, this was causing a crash. - * undo.c (gedit_undo_redo): ditto - - * view.c (insert_into_buffer): remove - - * dialogs/dialog-replace.c (dialog_replace): kill - warning - - -2000-05-31 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c: use the new function - - * undo.c (gedit_undo_do): use new function - (gedit_undo_redo): ditto - - * view.c: added views_insert and view_delete - (gedit_view_list_insert): deleted - (views_delete): moved here - (views_insert): moved here - (doc_insert_text_cb): rewrote and. Now uses the new - view function - - Starting to clean this ugly file. - - * undo.c: move the views_insert and view_delete to view - - * dialogs/dialog-replace.c (dialog_replace): fix the problem when - the dialog pops up in 2 diferent locations. - - moved the views_insert code to view.c - -2000-05-30 Chema Celorio <chema@celorio.com> - - * undo.c (gedit_undo_do): before undoing/redoing - adjust the window so that we dont have to see - the document scroll in a very anoying fashion - (gedit_undo_redo): ditto. - - * document.h (struct _Document): added untitled_number - entry. - - * view.c : #ifdef out split screen code - * undo.c : #ifdef out split screen code - * document.c : #ifdef out split screen code - It seems that the speed problems have been solved ! - We need to confirm this whit the users that reported - them. - (gedit_get_document_tab_name): fix, added new parameter. - - * dialogs/dialog-prefs.c (gedit_window_refresh): set split screen in - all docs and all views. - -2000-05-29 Chema Celorio <chema@celorio.com> - - * print.c (print_determine_lines): fix - (print_line): fix - - * pixmaps/gedit-icon.xpm : fix - - -2000-05-25 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c (replace_text_clicked_cb): first - implementation of replace all. - - * view.c: use new debug function ( macro ) - -2000-05-24 Chema Celorio <chema@celorio.com> - - * undo.c (views_insert): before undoing check whether there - is a piece of text selected.If there is, unselect it. - (views_delete): same - - * view.c (doc_insert_text_cb): go back to the original - parameters, we were overloading a mdi_view function so we - can't change those. - -2000-05-24 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c (replace_text_clicked_cb): replace now - works, it still needs some love. - - * undo.c (views_insert): disable split screen, it - was making gedit slow - (views_delete): ditto - - * view.c (doc_insert_text_cb): changed parameters for - function. - * view.h: reflect new parameters - - * dialogs/dialog-replace.c (views_delete): added this function - to delete text before replacing. **-- Found more about what - the speed problems with gedit are --**. - - * file.c (file_revert_cb): do not revert a (NULL) file, - since we don't have a filename to rever it to. - - * undo.c (gedit_undo_redo): clean the code a bit - - * dialogs/dialog-replace.c: merge dialog-search and - dialog-replace, they now share the code and the glade - file. We just hide the "replace" stuff in the dialog - when called from search. - - * dialogs/dialog-search.c : deleted - * dialogs/search.glade : deleted - * dialogs/search.glade.h : deleted - -2000-05-24 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-replace.c: start the replace stuff. - - * dialogs/dialog-search.c (search_text_clicked_cb): Improve fix - behaivor - (search_text_clicked_cb): let the user know that the search was - not successfull. I am still don't like the way we are doing so - but is better than nothing. - -2000-05-23 Chema Celorio <chema@celorio.com> - - * view.c (view_changed_cb): don't call set readonly - this was causing a mess with the "Untitled #" name for each view. - - * file.c (gedit_file_save): after saving as, turn the - readonly flag off in all views. - - * document.c: change gedit_debug to the new form - (gedit_get_document_tab_name): fixed a small bug - - * dialogs/dialog-goto-line.c (dialog_goto_line): set dialog's parent - * dialogs/dialog-search.c (dialog_find): ditto - -2000-05-23 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-search.c (dialog_find): make window - modal and do more checks. - - * dialogs/dialog-goto-line.c (goto_line_activate_cb): - rename find_line -> goto_line - (dialog_goto_line): make window modal to avoid weird - situations - - * dialogs/dialogs.h: ditto - * search.c (goto_line_cb): ditto - -2000-05-22 Chema Celorio <chema@celorio.com> - - * window.c (gedit_window_set_icon): use the correct - name for the new transparent icon. - - * search.c (search_text_execute): use a mask for case - sensitive. It's better than duplicating code. - -2000-05-22 Chema Celorio <chema@celorio.com> - - * search.c: improve search robustnes a bit, - there is still more work to do. - -2000-05-21 Chema Celorio <chema@celorio.com> - - * search.c: Rewrote - -2000-05-13 Chema Celorio <chema@celorio.com> - - * utils.h (gedit_debug): add debug recent - - * gedit.c (options): add debug recent - - * utils.c: deleted debug function, we are now - using a macro Jason wrote. - - -2000-05-17 Jason Leach <leach@wam.umd.edu> - - * view.c: cleaning up some of the debug messages. - * prefs.c: ditto. - -2000-05-12 Jason Leach <leach@wam.umd.edu> - - * view.c (gedit_event_key_press): removed unused variable 'gint - mask' - -2000-05-05 Jason Leach <leach@wam.umd.edu> - - * window.c: changed references to gE_icon to point to the new - gedit-icon - -2000-05-01 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-prefs.c (prepare_fontscolors_page): leak. - (apply_cb): leak. - - * view.c (doc_delete_text_cb): leak - -2000-05-01 Chema Celorio <chema@celorio.com> - - * print.c (print_header): leak x 3 - (print_ps_line): leak. - -2000-05-01 Jason Leach <leach@wam.umd.edu> - - * undo.c (gedit_undo_do): plugged a leak that happened everytime - you did undo then redo. - - * recent.c (recent_update_menus): fixed a 35-45 byte leak that - happened every time you opened a file or this was called (visit a - file already in your recent list, etc). - - * view.c (gedit_event_button_press): fixed a silly 20-byte leak - that happened on every button press event in a document. - - * view.c (gedit_view_init): fixed a 624-byte leak that happened - with every document you opened. - -2000-05-01 Chema Celorio <chema@celorio.com> - - * document.c (gedit_document_new): leak - -2000-05-01 Jason Leach <leach@wam.umd.edu> - - * view.c (doc_insert_text_cb): added a call to insert_into_buffer, - this is important because otherwise doc->buf->str otherwise won't - contain the contents of your document until you save or something, - so like the e-mail plugin sends no body on Untitled documents. - -2000-05-01 Chema Celorio <chema@celorio.com> - - * plugin.c (gedit_plugins_window_add): memleaks -= 1; - - * recent.c (recent_update_menus): memleaks -= 1; - -2000-05-01 Chema Celorio <chema@celorio.com> - - * recent.c (recent_update_menus): memleaks -= 4; - - * plugin.c (gedit_plugins_window_add): memleaks -= 6; - - * prefs.c (prefs_determine_use_fontset): memleaks -= 1; - -2000-04-29 Jason Leach <leach@wam.umd.edu> - - * gedit.c (options): new command-line options --debug-print and - --debug-file, to show only sections of debugging messages. - - * utils.h (gedit_debug): added sectioning of DEBUG_PRINT and - DEBUG_FILE - - * all files: renamed gedit_debug_mess -> gedit_debug - - * gedit.c (options): new command-line option --debug to turn on - debug messages in gedit, default to disable. - - * utils.h (gedit_debug): new debug stdout thingy. - - * utils.c (gedit_debug_mess): #if'd out this, it's getting - replaced with a #define'd gedit_debug in utils.h - -2000-04-29 Chema Celorio <chema@celorio.com> - - * print.c: typo. - - * plugin.c (gedit_plugins_window_add): Memory leak fix, - free path. - -2000-04-28 Chema Celorio <chema@celorio.com> - - * print.c (file_print_cb): Finished the word wrapping - stuff - - * recent.c (recent_update_menus): Fix a bug that will make - the print item in the File menu disapear when the recent - file list was < 4. - - -2000-04-27 Chema Celorio <chema@celorio.com> - - * print.c (print_line): Started doing the word wrapping - versus word clipping so that we can use the printing - code in pan. - - * menus.c (gedit_file_menu): Fixed a small bug where the - print menu item will appear in the wrong place if gedit - is launched with a file as an argument. - -2000-04-25 Jason Leach <leach@wam.umd.edu> - - * recent.c: Replaced the use of gnome-history with custom routines - to store history in ~/.gnome/gedit, much better. - -2000-04-21 Alex Roberts <bse@error.fsnet.co.uk> - - * file.c: Fixed various spelling mistakes. - (file_revert_do): added translation tags - -2000-04-20 Chema Celorio <chema@celorio.com> - - * print.c (print_document): Added gnome_print_beginpage - we can now navigate postscript output with gv - -2000-04-20 Alex Roberts <bse@error.fsnet.co.uk> - - * dialogs/about.glade: Added my email address. - -2000-04-18 Chema Celorio <chema@celorio.com> - - * print.c: added a print range to the print - dialog and moved the initialization for - printing. - -2000-04-15 Chema Celorio <chema@celorio.com> - - * dialogs/dialog-prefs.c (prepare_pagesize_page): new function - (prepare_printing_page): load spin button with value - - * prefs.c (gedit_load_settings): Added paper stuff - (gedit_save_settings): ditto - - * dialogs/dialog-prefs.c (apply_cb): ditto - -2000-04-14 Chema Celorio <chema@celorio.com> - - * gedit.c (main): if the file is empty, dont - crash - -2000-04-14 Jason Leach <leach@wam.umd.edu> - - * window.c (gedit_window_set_status_bar): fixed a bug with status - bar getting toggled in prefs, even when the user hasn't asked for - it to toggle. - -2000-04-14 Chema Celorio <chema@celorio.com> - - * file.c: if the file is opened by another - app, let the user know. - -2000-04-14 Jason Leach <leach@wam.umd.edu> - - * view.c (gedit_event_button_press): made private - (gedit_event_key_press): ditto - (view_list_erase): ditto - (gedit_event_key_press): fix ALT-F menu accessing again... - -2000-04-13 Chema Celorio <chema@celorio.com> - - * print.c (print_setfont): new function - finish the printing prefs stuff - -2000-04-13 Chema Celorio <chema@celorio.com> - - * utils.c (gtk_radio_button_select): created, copied - from gnumeric - (gtk_radio_group_get_selected): ditto - - * dialogs/dialog-prefs.c : add printing stuff, - still need to do the print.c part tho - - * dialogs/dialog-search.c (search_dialog_button_cb): if - not doc is open, return. - (search_cb): ditto - - * commands.[ch] (about_cb): moved here find_line, replace - and about callbacks - - * menus.c: moved some callbacks to commands.c - - * dialogs/dialog-prefs.c: included "commands.h" and "window.h" - to kill two compilation warnings. - (gedit_window_refresh): made non-static since prefs.c is - calling it. - - * utils.h and utils.c (gedit_debug_mess): added new debug - enum DEBUG_PREFS and DEBUG_PRINT - - * prefs.c: included #utils for debuging some bugs. - - * undo.c (gedit_undo_do): If no document is active - dont crash. - (gedit_undo_redo): ditto - * commands.c (edit_cut_cb): ditto - (edit_copy_cb): ditto - (edit_paste_cb): ditto - (edit_selall_cb): ditto - (options_toggle_split_screen_cb): ditto - (options_toggle_read_only_cb): ditto - (options_toggle_word_wrap_cb): ditto - (options_toggle_line_wrap_cb): ditto - (options_toggle_status_bar_cb): ditto - - * dialogs/dialog-prefs.c (gedit_window_refresh): ditto - - * file.c (file_revert_cb): ditto - * file.c (file_save_as_cb): ditto - - * print.c (file_print_cb): ditto - * print.c: added utils.h - - -2000-04-13 Jason Leach <leach@wam.umd.edu> - - * dialogs/dialog-prefs.c (apply_cb): fixed problems with changes - to the colors not getting applied and "show statusbar" not working - correctly. - -2000-04-10 Valek Filippov <frob@df.ru> - - * file.c: typo fix - -2000-04-09 Chema Celorio <chema@celorio.com> - - * document.c (gedit_document_real_changed): not used, delete it. - (gedit_document_marshal): not used, delete it. - (gedit_add_view): commented out a g_print function .. - - * dialogs/dialog-replace.c: Removed some compile - warnings. - - * menus.c (gedit_tab_menu): simpify the menus - set the tabs in the prefs box not on a menu entry. - (gedit_settings_menu): why would the user change - the RO setting ?. Removed from menu - (gedit_settings_menu): Removed the save settings - entry from the menu. Settings should be saved automaticlly - by the prefs box. - - * prefs.c: removed compile warnings - * recent.c: removed a compile warning - * dialogs/dialog-find-line.c: removed a compile - warning. - * dialogs/dialog-replace.c: removed a compile - warning. - - * search_backup.c: - * search_backup.h: - I have included this files in the CVS because I am - goint to delete some search functions that we might - want to implement as plugins in the future. We need - to simplify the find & search/replace functions. The - more complex stuff like find in all files ( or something - like grep ) will be better off, if implemented as a plugin - -2000-04-09 Chema Celorio <chema@celorio.com> - - * view.c (gedit_view_init): Do not connect key_press_event - with gtk_signal_connect_after. key_press_event has to be - the first function to handle this event. This fixes the Ctrl+W - bug. - - **We still need to add wrapping to the - prefs box.*** - * print.c (print_line): Implemented text - wrapping. - (print_ps_line): created - (set_pji): added wrapping stuff - (print_determine_lines): added wrapping stuff - - * document.c (gedit_document_create_view): call - "gedit_view_set_read_only" when creating a new view - to update the title and the RO status. - -2000-04-08 Chema Celorio <chema@celorio.com> - - * file.c (gedit_file_open): Close the Untiled - doc only if the open was succesfull. - - (popup_create_new_file): dont save the - file. Just set doc->filename. - -2000-04-08 Chema Celorio <chema@celorio.com> - - * file.c (file_saveas_ok_sel): ask user - before overwriting a file. - (popup_create_new_file): moved - from commands. and added a g_free call. - - * gedit.c (main): fixed when you call gedit myfile.txt - and myfile.txt does not exists. - - * commands.c (edit_cut_cb): removed the commented - functions that where moved to file.c - (popup_create_new_file): moved to file.c - - * recent.c (recent_update): cleaned a bit - (recent_cb): FIXME: we need to delete a file - from the recent menu if an error was encountered - while trying to open it. - - * commands.c: removed some prototpes that where not - longer used. - (popup_create_new_file): shut up a warning. - (gedit_shutdown): comment it out, looks like - it is not beeing used. - - * recent.c : Include file.h - (recent_cb): rewrote. - - * view.c (view_changed_cb): call - gedit_view_set_read_only. - - * file.c (gedit_file_open): Rewrote - (file_open_ok_sel): Don't report to the - user if there was an error, let file_open - do it. - - * document.h (struct _Document): Added a read - only entry in the Document structure - -2000-04-06 Jason Leach <leach@wam.umd.edu> - - * prefs.c (gedit_window_refresh): fixed a problem jpr just - mentioned about changes to the font not getting applied to the - documents already open. - -2000-04-05 Jason Leach <leach@wam.umd.edu> - - * prefs.c (get_prefs): fixed the crash with preferences when you - have no documents open. - -2000-04-04 Jason Leach <leach@wam.umd.edu> - - * gedit-window.c (doc_swaphc_cb): fix a crash that was just - earlier added to BUGS - - * gE_view.c (gedit_view_init): make the style actually follow your - GTK+ theme, so no more default blue selection. - (gedit_event_key_press): fixed the ALT-F bug - -2000-04-04 Chema Celorio <chema@celorio.com> - - * gedit-file-io.c (gedit_file_save): cleaned - the code and fixed bug #5929. - (file_save_all_cb): rewrote it. - (file_open_cb): fixed small bug - (file_saveas_destroy): no longer needed - use generic destroy_cb - (file_save_all_as_cb): deleted, no need - to have a save_all_as func. - (file_save_all_as_destroy): ditto - (file_save_all_as_ok_sel): ditto - (file_close_all_cb): rewrote - (file_close_cb): rewrote - (file_revert_do): no longer needed, removed - (file_save_as_cb): fixed a bug - -2000-04-04 Chema Celorio <chema@celorio.com> - - * commands.c: Removed all the file-io - functions from here and the prototypes - from commands.h - - * gE_view.c: removed popup_menu from - here.#included gedit-file-io.h because - sortcut key's uses some file functions. - - * gedit-menus.c (popup_menu): moved - popup_menu to here - * gedit-menus.h (gedit_menus_init): moved - popup_menu to here and share it with the - outside world. - - * gedit-file-io.c: Rewriten part of - the file-io functions, will continue ma~ana. - (delete_event_cb): added - (cancel_cb): added - (file_open_cb): rewriten - (file_open_ok_sel): rewriten, file opening - is not done here anymore, call gedit_doc_new_with_file - (file_cancel_sel): no longer needed replaced by a generic - cancel_cb - -2000-04-03 Chema Celorio <chema@celorio.com> - - * gedit-utils.c (gedit_debug_mess): Added - switch to display only some types of - messages. - - * gedit-file-io.c: Moved file related functions - from commands.c to here - - * commands.c: . - -2000-04-03 Jason Leach <leach@wam.umd.edu> - - * gedit-print.c: took out some unecessary #include's - -2000-04-03 Chema Celorio <chema@celorio.com> - - * gedit-undo.c: Cleaned the debug code - it now uses gedit_debug_mess. - - * gedit-utils.h: Added more debug types - - * gedit-menus.c (gedit_edit_menu): Moved all the - menus definition to gedit-menus from gE_mdi.c - (gedit_tab_menu): Disbled the windows menu. - - * gedit-utils.c (gedit_debug_mess): New function - not finished, we need to be able to turn some - message types on and off - * gE_view.c: Added debug calls - * other files: code cleanup - - -2000-04-03 Jason Leach <leach@wam.umd.edu> - - * gE_plugin.c (load_all_plugins): replaced a getenv() with a - g_get_home_dir() - - * gE_plugin.c: removed 4 unnecessary #include's - - * commands.c (file_open_ok_sel): replaced some stat() stuff with a - nice g_file_test() call - - * gedit-undo.c (gedit_undo_add): fix for the double CTRL-K crash - just added to BUGS - - * gedit.c (main): who added the && FALSE to the - if (g_list_length(mdi->children) == 0) ? Took that out. - - * gE_view.c (popup_menu): cleaned up this GnomeUIInfo - - * commands.c: removed 5 unnecessar #includes - (file_quit_cb): lets quit via gtk_main_quit() rather than a - gtk_exit(0); - (recent_update_menus): don't need to if() before g_free() - (recent_update): replace resource heavy g_list_length calls with - an integer counter. - -2000-04-03 Chema Celorio <chema@celorio.com> - - * gedit-menus.c (gedit_menu): When compiling - without plugin support, do not show plugin menu - entry - * BUGS : added a bug { CTRL+K } - -2000-04-03 Jason Leach <leach@wam.umd.edu> - - * gE_mdi.c (gedit_document_destroy): fixed a crash when gedit - tries to open a document without read permissions, and then when - you go to exit. - (gedit_document_new_with_file): bugfix with having the a busted up - gedit when you try and open files you don't have access to. - - * gE_window.c (gedit_window_set_status_bar): new function, it will - change your life (if your life is lacking dynamic control of - enabling/disabling the statusbar) - - * gE_prefs_box.c (gedit_apply): fixed a bug where everytime you - pressed OK in the preferences, it would run the apply callback - twice, that's like, way lame and stuff. - -2000-04-03 Chema Celorio <chema@celorio.com> - * gedit-undo.c (views_insert): fixed a cursor positioning problem - when undoing - (views_delete): ditto basiclly thaw gtk_text befor - inserting/deleting this keeps the cursor in the correct position - -2000-04-02 Jason Leach <leach@wam.umd.edu> - - * gE_mdi.c (get_untitled_as_string): made static - (gedit_document_new): woops, broke something here, its fixed. - - * *.[ch]: perl -p -i -e 's/gE_/gedit_/' changing all instances of - gE_ to gedit_, meaning our #include lines are busted right now, - will fix asap. - -2000-04-02 Chema Celorio <chema@celorio.com> - - * menus.c: Added print preview entry. - - * gE_print.c (file_print_preview_cb): Added print preview - capabilities - (print_document): ditto - (preview_destroy_cb): ditto - -2000-04-02 Jason Leach <leach@wam.umd.edu> - - * search.c (create_search_dialog): marked a string for i18n that - wasn't but should have been. - (destroy_clist_data): don't need to do if(b) before g_free(b) - - * search.c: removed 5 unnecessary #include's, killed all - warnings. - - * gE_print.c: killed 2 warnings. - - * gE_prefs_box.c: killed all warnings. - - * gE_files.c: removed 8 unnecessary #include's, killed all - warnings. - - * gE_undo.c: killed all warnings. - - * gE_mdi.c: removed 5 unnecessary #include's, killed all warnings. - -2000-04-01 Jason Leach <leach@wam.umd.edu> - - * gE_prefs_box.c (cancel_cb): destroy the font selector window - when we close the preferences, closes bug #4432. - (font_sel): open pop open one font selector at a time, preventing - any potential future bugs with this happening. - (properties_changed): fix indentation - - * gE_prefs_box.c: commented out 5 unnecessary #include's - diff --git a/gedit/GNOME_Gedit.idl b/gedit/GNOME_Gedit.idl deleted file mode 100644 index 15f352dc8..000000000 --- a/gedit/GNOME_Gedit.idl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Interface for gedit - */ - -#include <Bonobo.idl> - -module GNOME { - - module Gedit { - - /* URIs are just plain strings, but we use a typedef to make - * the interface definitions clearer. - */ - typedef string URI; - typedef sequence<URI> URIList; - - interface Document : Bonobo::Unknown { - oneway void setLinePosition (in long line); - }; - - interface Window : Bonobo::Unknown { - oneway void openURIList (in URIList locations); - oneway void grabFocus (); - Document newDocument (); - }; - - - interface Application : Bonobo::Unknown { - Window newWindow (); - - Document getActiveDocument (); - Window getActiveWindow (); - - oneway void quit (); - }; - - - }; -}; diff --git a/gedit/Makefile.am b/gedit/Makefile.am deleted file mode 100644 index 401644677..000000000 --- a/gedit/Makefile.am +++ /dev/null @@ -1,139 +0,0 @@ -## Process this file with automake to produce Makefile.in -SUBDIRS= dialogs - -bin_PROGRAMS = gedit - -uidir = $(datadir)/gedit-2/ui/ - - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/dialogs \ - $(GEDIT_CFLAGS) \ - -DDATADIR=\""$(datadir)"\" \ - -DGNOME_ICONDIR=\""$(datadir)/pixmaps"\" \ - -DGEDIT_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ - -DGEDIT_UI_DIR=\""$(datadir)/gedit-2/ui/"\" \ - -DGEDIT_PLUGINDIR=\""$(libdir)/gedit-2/plugins"\" \ - -DGEDIT_GLADEDIR=\""$(datadir)/gedit-2/glade/"\" \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGNOME_DISABLE_DEPRECATED - -gedit_LDFLAGS = -export-dynamic - -gedit_LDADD = \ - dialogs/libdialogs.a \ - $(GEDIT_LIBS) - -IDL_FILE = GNOME_Gedit.idl - -IDL_SOURCES = \ - GNOME_Gedit-stubs.c \ - GNOME_Gedit-common.c \ - GNOME_Gedit-skels.c \ - GNOME_Gedit.h - -BUILT_SOURCES = \ - gedit-marshal.c \ - gedit-marshal.h \ - gnome-recent-marshal.c \ - gnome-recent-marshal.h - -gedit_SOURCES = \ - $(IDL_SOURCES) \ - gedit2.c \ - gedit2.h \ - gedit-mdi.c \ - gedit-mdi.h \ - gedit-mdi-child.c \ - gedit-mdi-child.h \ - gedit-document.c \ - gedit-document.h \ - gedit-view.c \ - gedit-view.h \ - gedit-menus.h \ - gedit-menus.c \ - gedit-debug.c \ - gedit-debug.h \ - gedit-utils.c \ - gedit-utils.h \ - gedit-commands.h \ - gedit-commands.c \ - gedit-file.h \ - gedit-file.c \ - gedit-undo-manager.h \ - gedit-undo-manager.c \ - gedit-print.h \ - gedit-print.c \ - gedit-session.c \ - gedit-session.h \ - bonobo-mdi.c \ - bonobo-mdi.h \ - bonobo-mdi-child.c \ - bonobo-mdi-child.h \ - bonobo-mdi-session.c \ - bonobo-mdi-session.h \ - gedit-file-selector-util.h \ - gedit-file-selector-util.c \ - gedit-plugins-engine.h \ - gedit-plugins-engine.c \ - gedit-plugin.h \ - gedit-plugin.c \ - gedit-prefs-manager.c \ - gedit-prefs-manager.h \ - gnome-recent-model.c \ - gnome-recent-model.h \ - gnome-recent-view.c \ - gnome-recent-view.h \ - gnome-recent-view-bonobo.c \ - gnome-recent-view-bonobo.h \ - gnome-recent-util.c \ - gnome-recent-util.h \ - gedit-recent.c \ - gedit-recent.h \ - gedit-application-server.c \ - gedit-application-server.h \ - gedit-document-server.c \ - gedit-document-server.h \ - gedit-window-server.c \ - gedit-window-server.h \ - $(BUILT_SOURCES) - -gedit-marshal.h: gedit-marshal.list $(GLIB_GENMARSHAL) - $(GLIB_GENMARSHAL) $< --header --prefix=gedit_marshal > $@ - -gedit-marshal.c: gedit-marshal.list $(GLIB_GENMARSHAL) - echo "#include \"gedit-marshal.h\"" > $@ && \ - $(GLIB_GENMARSHAL) $< --body --prefix=gedit_marshal >> $@ - -gnome-recent-marshal.h: gnome-recent-marshal.list $(GLIB_GENMARSHAL) - $(GLIB_GENMARSHAL) $< --header --prefix=gnome_recent > $@ - -gnome-recent-marshal.c: gnome-recent-marshal.list $(GLIB_GENMARSHAL) - echo "#include \"gnome-recent-marshal.h\"" > $@ && \ - $(GLIB_GENMARSHAL) $< --body --prefix=gnome_recent >> $@ - -$(IDL_SOURCES): $(IDL_FILE) - $(ORBIT_IDL) -I $(LIBBONOBO_IDL) -I $(BONOBO_ACTIVATION_IDL) $(IDL_FILE) - -ui_DATA = gedit-ui.xml - -idl_DATA = $(IDL_FILE) -idldir = $(datadir)/idl - -EXTRA_DIST = \ - $(ui_DATA) \ - gedit-marshal.list \ - gnome-recent-marshal.list \ - $(IDL_FILE) - -CLEANFILES = $(BUILT_SOURCES) $(IDL_SOURCES) - -install-exec-local: - rm -f $(DESTDIR)$(bindir)/gnome-text-editor - ln -s gedit $(DESTDIR)$(bindir)/gnome-text-editor - diff --git a/gedit/bonobo-mdi-child.c b/gedit/bonobo-mdi-child.c deleted file mode 100644 index 09dd381dc..000000000 --- a/gedit/bonobo-mdi-child.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * bonobo-mdi-child.c - implementation of a BonoboMDI object - * - * Copyright (C) 2001-2002 Free Software Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Paolo Maggi - */ - -#include "bonobo-mdi-child.h" - -struct _BonoboMDIChildPrivate -{ - GObject *parent; - - gchar *name; - GList *views; -}; - -enum { - NAME_CHANGED, - LAST_SIGNAL -}; - -static void bonobo_mdi_child_class_init (BonoboMDIChildClass *klass); -static void bonobo_mdi_child_instance_init (BonoboMDIChild *); -static void bonobo_mdi_child_finalize (GObject *); - -static GtkWidget *bonobo_mdi_child_set_label (BonoboMDIChild *, GtkWidget *, gpointer); -static GtkWidget *bonobo_mdi_child_create_view (BonoboMDIChild *); - -static void bonobo_mdi_child_real_name_changed (BonoboMDIChild *child, gchar* old_name); - -static GObjectClass *parent_class = NULL; -static guint mdi_child_signals [LAST_SIGNAL] = { 0 }; - -GType -bonobo_mdi_child_get_type (void) -{ - static GType bonobo_mdi_child_type = 0; - - if (bonobo_mdi_child_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (BonoboMDIChildClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) bonobo_mdi_child_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (BonoboMDIChild), - 0, /* n_preallocs */ - (GInstanceInitFunc) bonobo_mdi_child_instance_init - }; - - bonobo_mdi_child_type = g_type_register_static (G_TYPE_OBJECT, - "BonoboMDIChild", - &our_info, - 0); - } - - return bonobo_mdi_child_type; -} - -static void -bonobo_mdi_child_class_init (BonoboMDIChildClass *klass) -{ - GObjectClass *gobject_class; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class = (GObjectClass*)klass; - - gobject_class->finalize = bonobo_mdi_child_finalize; - - klass->create_view = NULL; - klass->get_config_string = NULL; - klass->set_label = bonobo_mdi_child_set_label; - - klass->name_changed = bonobo_mdi_child_real_name_changed; - - mdi_child_signals[NAME_CHANGED] = - g_signal_new ("name_changed", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (BonoboMDIChildClass, name_changed), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, - 1, - G_TYPE_STRING); -} - -static void -bonobo_mdi_child_instance_init (BonoboMDIChild *mdi_child) -{ - g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child)); - - mdi_child->priv = g_new0 (BonoboMDIChildPrivate, 1); - - mdi_child->priv->name = NULL; - mdi_child->priv->parent = NULL; - mdi_child->priv->views = NULL; -} - - -/* the default set_label function: returns a GtkLabel with child->priv->name - * if you provide your own, it should return a new widget if its old_label - * parameter is NULL and modify and return the old widget otherwise. it - * should (obviously) NOT call the parent class handler! - */ -static GtkWidget * -bonobo_mdi_child_set_label (BonoboMDIChild *child, GtkWidget *old_label, gpointer data) -{ - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), NULL); - g_return_val_if_fail (child->priv != NULL, NULL); - - if (old_label != NULL) - { - gtk_label_set_text (GTK_LABEL (old_label), child->priv->name); - return old_label; - } - else - { - GtkWidget *label; - - label = gtk_label_new (child->priv->name); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - - return label; - } -} - -static void -bonobo_mdi_child_finalize (GObject *obj) -{ - BonoboMDIChild *mdi_child; - - g_return_if_fail (BONOBO_IS_MDI_CHILD (obj)); - - mdi_child = BONOBO_MDI_CHILD (obj); - g_return_if_fail (mdi_child->priv != NULL); - - while (mdi_child->priv->views) - bonobo_mdi_child_remove_view (mdi_child, - GTK_WIDGET (mdi_child->priv->views->data)); - - if (mdi_child->priv->name != NULL) - g_free (mdi_child->priv->name); - - if (mdi_child->priv != NULL) - g_free (mdi_child->priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize)(obj); -} - -/** - * bonobo_mdi_child_add_view: - * @mdi_child: A pointer to a BonoboMDIChild object. - * - * Description: - * Creates a new view of a child (a GtkWidget) adds it to the list - * of the views and returns a pointer to it. Virtual function - * that has to be specified for classes derived from BonoboMDIChild - * is used to create the new view. - * - * Return value: - * A pointer to the new view. - **/ -GtkWidget * -bonobo_mdi_child_add_view (BonoboMDIChild *mdi_child) -{ - GtkWidget *view = NULL; - - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL); - g_return_val_if_fail (mdi_child->priv != NULL, NULL); - - view = bonobo_mdi_child_create_view (mdi_child); - - if (view) { - mdi_child->priv->views = g_list_append (mdi_child->priv->views, view); - - g_object_set_data (G_OBJECT (view), "BonoboMDIChild", mdi_child); - } - - return view; -} - -/** - * bonobo_mdi_child_remove_view: - * @mdi_child: A pointer to a BonoboMDIChild object. - * @view: View to be removed. - * - * Description: - * Removes view @view from the list of @mdi_child's views and - * unrefs it. - **/ -void -bonobo_mdi_child_remove_view (BonoboMDIChild *mdi_child, GtkWidget *view) -{ - g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child)); - g_return_if_fail (mdi_child->priv != NULL); - g_return_if_fail (GTK_IS_WIDGET (view)); - - mdi_child->priv->views = g_list_remove (mdi_child->priv->views, view); - - g_object_unref (G_OBJECT (view)); -} - -/** - * bonobo_mdi_child_set_name: - * @mdi_child: A pointer to a BonoboMDIChild object. - * @name: String containing the new name for the child. - * - * Description: - * Changes name of @mdi_child to @name. @name is duplicated and stored - * in @mdi_child. If @mdi_child has already been added to BonoboMDI, - * it also takes care of updating it. - **/ -void -bonobo_mdi_child_set_name (BonoboMDIChild *mdi_child, const gchar *name) -{ - gchar *old_name; - - g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child)); - g_return_if_fail (mdi_child->priv != NULL); - - old_name = mdi_child->priv->name; - - if (old_name == name) - return; - - mdi_child->priv->name = (gchar *)g_strdup (name); - - g_signal_emit (G_OBJECT (mdi_child), - mdi_child_signals [NAME_CHANGED], 0, - old_name); - - if (old_name) - g_free (old_name); -} - -static GtkWidget * -bonobo_mdi_child_create_view (BonoboMDIChild *child) -{ - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), NULL); - - if (BONOBO_MDI_CHILD_GET_CLASS (child)->create_view) - return BONOBO_MDI_CHILD_GET_CLASS (child)->create_view (child, NULL); - - return NULL; -} - -static void -bonobo_mdi_child_real_name_changed (BonoboMDIChild *child, gchar* old_name) -{ - g_return_if_fail (BONOBO_IS_MDI_CHILD (child)); - - return; -} - -gchar * -bonobo_mdi_child_get_name (const BonoboMDIChild *mdi_child) -{ - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL); - g_return_val_if_fail (mdi_child->priv != NULL, NULL); - - if (mdi_child->priv->name) - return g_strdup (mdi_child->priv->name); - else - return NULL; -} - -GList * -bonobo_mdi_child_get_views (const BonoboMDIChild *mdi_child) -{ - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL); - g_return_val_if_fail (mdi_child->priv != NULL, NULL); - - return mdi_child->priv->views; -} - -GObject * -bonobo_mdi_child_get_parent (const BonoboMDIChild *mdi_child) -{ - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (mdi_child), NULL); - g_return_val_if_fail (mdi_child->priv != NULL, NULL); - - return G_OBJECT (mdi_child->priv->parent); - -} - -void -bonobo_mdi_child_set_parent (BonoboMDIChild *mdi_child, GObject *parent) -{ - g_return_if_fail (BONOBO_IS_MDI_CHILD (mdi_child)); - g_return_if_fail (mdi_child->priv != NULL); - - mdi_child->priv->parent = parent; -} diff --git a/gedit/bonobo-mdi-child.h b/gedit/bonobo-mdi-child.h deleted file mode 100644 index 49d9b66e4..000000000 --- a/gedit/bonobo-mdi-child.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * bonobo-mdi-child.h - definition of a BonoboMDI object - * - * Copyright (C) 2001-2002 Free Software Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Paolo Maggi - */ - -#ifndef _BONOBO_MDI_CHILD_H_ -#define _BONOBO_MDI_CHILD_H_ - -#include <gtk/gtk.h> -#include <bonobo/bonobo-window.h> - -#define BONOBO_TYPE_MDI_CHILD (bonobo_mdi_child_get_type ()) -#define BONOBO_MDI_CHILD(obj) (GTK_CHECK_CAST ((obj), BONOBO_TYPE_MDI_CHILD, BonoboMDIChild)) -#define BONOBO_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), BONOBO_TYPE_MDI_CHILD, BonoboMDIChildClass)) -#define BONOBO_IS_MDI_CHILD(obj) (GTK_CHECK_TYPE ((obj), BONOBO_TYPE_MDI_CHILD)) -#define BONOBO_IS_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BONOBO_TYPE_MDI_CHILD)) -#define BONOBO_MDI_CHILD_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BONOBO_TYPE_MDI_CHILD, BonoboMDIChildClass)) - -/* BonoboMDIChild - * is an abstract class. In order to use it, you have to either derive a - * new class from it and set the proper virtual functions in its parent - * BonoboMDIChildClass structure or use the BonoboMDIGenericChild class - * that allows to specify the relevant functions on a per-instance basis - * and can directly be used with BonoboMDI. - */ - -typedef struct _BonoboMDIChildPrivate BonoboMDIChildPrivate; - -typedef struct -{ - GObject object; - - BonoboMDIChildPrivate *priv; -} BonoboMDIChild; - - -typedef GtkWidget *(*BonoboMDIChildViewCreator) (BonoboMDIChild *, gpointer); -typedef GList *(*BonoboMDIChildMenuCreator) (BonoboMDIChild *, GtkWidget *, gpointer); -typedef gchar *(*BonoboMDIChildConfigFunc) (BonoboMDIChild *, gpointer); -typedef GtkWidget *(*BonoboMDIChildLabelFunc) (BonoboMDIChild *, GtkWidget *, gpointer); - -/* - * Note that if you override the set_label virtual function, it should return - * a new widget if its GtkWidget* parameter is NULL and modify and return the - * old widget otherwise. - * (see bonobo-mdi-child.c/bonobo_mdi_child_set_book_label() for an example). - */ - -typedef struct -{ - GObjectClass parent_class; - - /* Virtual functions */ - BonoboMDIChildViewCreator create_view; - BonoboMDIChildConfigFunc get_config_string; - BonoboMDIChildLabelFunc set_label; - - void (* name_changed) (BonoboMDIChild *mdi_child, gchar* old_name); - -} BonoboMDIChildClass; - -GType bonobo_mdi_child_get_type (void) G_GNUC_CONST; - -GtkWidget *bonobo_mdi_child_add_view (BonoboMDIChild *mdi_child); -void bonobo_mdi_child_remove_view (BonoboMDIChild *mdi_child, - GtkWidget *view); - -GList *bonobo_mdi_child_get_views (const BonoboMDIChild *mdi_child); - -void bonobo_mdi_child_set_name (BonoboMDIChild *mdi_child, - const gchar *name); -gchar *bonobo_mdi_child_get_name (const BonoboMDIChild *mdi_child); - -void bonobo_mdi_child_set_parent (BonoboMDIChild *mdi_child, - GObject *parent); -GObject *bonobo_mdi_child_get_parent (const BonoboMDIChild *mdi_child); - -G_END_DECLS - -#endif /* _BONOBO_MDI_CHILD_H_ */ - - - diff --git a/gedit/bonobo-mdi-session.c b/gedit/bonobo-mdi-session.c deleted file mode 100644 index 1f8c40f2b..000000000 --- a/gedit/bonobo-mdi-session.c +++ /dev/null @@ -1,531 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * bonobo-mdi-session.c - session managament functions - * - * Copyright (C) 2002 Free Software Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - -#include <config.h> - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -/*#include "gnome-i18nP.h"*/ - -#include "bonobo-mdi-session.h" -#include <libgnome/gnome-config.h> -#include <bonobo/bonobo-dock-layout.h> - -static GPtrArray * config_get_list (const gchar *); -static void config_set_list (const gchar *, GList *, - gpointer (*)(gpointer)); -static void restore_window_child (BonoboMDI *, GHashTable *, - GHashTable *, GHashTable *, - GHashTable *, GHashTable *, - glong, glong, gboolean *, - gchar *); -static void restore_window (BonoboMDI *, const gchar *, - GPtrArray *, GHashTable *, - GHashTable *, GHashTable *, - GHashTable *, GHashTable *, - glong); -static void set_active_window (BonoboMDI *, GHashTable *, glong); - - -static gpointer view_window_func (gpointer); - -static gchar * -bonobo_mdi_child_get_config_string (BonoboMDIChild *child) -{ - if(BONOBO_MDI_CHILD_GET_CLASS(child)->get_config_string) - return BONOBO_MDI_CHILD_GET_CLASS(child)->get_config_string(child, NULL); - - return NULL; -} - -static GPtrArray * -config_get_list (const gchar *key) -{ - GPtrArray *array; - gchar *string, *pos; - - string = gnome_config_get_string (key); - if (!string) return NULL; - - array = g_ptr_array_new (); - - pos = string; - while (*pos) { - glong value; - gchar *tmp; - - tmp = strchr (pos, ':'); - if (tmp) *tmp = '\0'; - - if (sscanf (pos, "%lx", &value) == 1) - g_ptr_array_add (array, (gpointer) value); - - if (tmp) - pos = tmp+1; - else - break; - } - - g_free (string); - return array; -} - -static void -config_set_list (const gchar *key, GList *list, gpointer (*func)(gpointer)) -{ - gchar value [BUFSIZ]; - - value [0] = '\0'; - while (list) { - char buffer [BUFSIZ]; - gpointer data; - - data = func ? func (list->data) : list->data; - g_snprintf (buffer, sizeof(buffer), "%lx", (glong) data); - if (*value) strcat (value, ":"); - strcat (value, buffer); - - list = g_list_next (list); - } - - gnome_config_set_string (key, value); -} - -static void -restore_window_child (BonoboMDI *mdi, GHashTable *child_hash, - GHashTable *child_windows, GHashTable *child_views, - GHashTable *view_hash, GHashTable *window_hash, - glong window, glong child, gboolean *init, - gchar *role) -{ - GPtrArray *windows, *views; - BonoboMDIChild *mdi_child; - guint k; - - windows = g_hash_table_lookup (child_windows, (gpointer) child); - if (!windows) return; - - views = g_hash_table_lookup (child_views, (gpointer) child); - if (!views) return; - - mdi_child = g_hash_table_lookup (child_hash, (gpointer) child); - if (!mdi_child) return; - - for (k = 0; k < windows->len; k++) { - if (windows->pdata [k] != (gpointer) window) - continue; - - if (*init) - bonobo_mdi_add_view (mdi, mdi_child); - else { - bonobo_mdi_add_toplevel_view (mdi, mdi_child, role); - - *init = TRUE; - - g_hash_table_insert (window_hash, - (gpointer) window, - bonobo_mdi_get_active_window (mdi)); - } - - g_hash_table_insert (view_hash, - views->pdata [k], - bonobo_mdi_get_active_view (mdi)); - } -} - -static void -restore_window (BonoboMDI *mdi, const gchar *section, GPtrArray *child_list, - GHashTable *child_hash, GHashTable *child_windows, - GHashTable *child_views, GHashTable *view_hash, - GHashTable *window_hash, glong window) -{ - gboolean init = FALSE; - gchar key [BUFSIZ], *role; - guint j; - - g_snprintf (key, sizeof(key), "%s/mdi_window_%lx", section, window); - role = gnome_config_get_string (key); - - if(child_list->len == 0) { - bonobo_mdi_open_toplevel (mdi, role); - - g_hash_table_insert (window_hash, (gpointer) window, - bonobo_mdi_get_active_window (mdi)); - } - else - for (j = 0; j < child_list->len; j++) - restore_window_child (mdi, child_hash, child_windows, - child_views, view_hash, - window_hash, window, - (glong) child_list->pdata [j], - &init, role); - -#if 0 - - g_snprintf (key, sizeof(key), "%s/mdi_window_layout_%lx", section, window); - string = gnome_config_get_string (key); - if (!string) return; - - { - BonoboWindow *app = bonobo_mdi_get_active_window (mdi); - BonoboDockLayout *layout; - - printf("app->layout == %08lx\n", app->layout); - - /* this should be a nasty hack before dock-layout gets a bit better - don't even know if it works, though ;) */ - layout = bonobo_dock_get_layout(BONOBO_DOCK(app->dock)); - bonobo_dock_layout_parse_string(bonobo_mdi_get_active_window (mdi)->layout, string); - gtk_container_forall(GTK_CONTAINER(app->dock), remove_items, app->dock); - bonobo_dock_add_from_layout(BONOBO_DOCK(app->dock), layout); - g_object_unref (G_OBJECT(layout)); - } -#endif - if (role != NULL) - g_free (role); -} - -static void -set_active_window (BonoboMDI *mdi, GHashTable *window_hash, glong active_window) -{ - BonoboWindow *app; - GtkWidget *view; - - app = g_hash_table_lookup (window_hash, (gpointer) active_window); - if (!app) return; - - view = bonobo_mdi_get_view_from_window (mdi, app); - if (!view) return; - - bonobo_mdi_set_active_view (mdi, view); -} - -/** - * bonobo_mdi_restore_state: - * @mdi: A pointer to a BonoboMDI object. - * @section: Name of the section to restore MDI state from. - * @create_child_func: A function that recreates a child from its config string. - * - * Description: - * Restores the MDI state. Children are recreated with @create_child_func that - * restores information about a child from a config string that was provided - * during saving state by the child. - * - * Return value: - * TRUE if state was successfully restored, FALSE otherwise. - **/ -gboolean -bonobo_mdi_restore_state (BonoboMDI *mdi, const gchar *section, - BonoboMDIChildCreator create_child_func) -{ - gboolean retval; - gchar key [BUFSIZ], *string; - GPtrArray *window_list, *child_list; - GHashTable *child_hash, *child_windows; - GHashTable *child_views, *view_hash, *window_hash; - glong active_view = 0, active_window = 0; - guint i; - gint mode; - - retval = FALSE; - - bonobo_mdi_set_restoring_state (mdi, TRUE); - - g_snprintf (key, sizeof(key), "%s/mdi_mode=-1", section); - mode = gnome_config_get_int (key); - if (gnome_config_get_int (key) == -1) - goto out; -#if 0 - bonobo_mdi_set_mode (mdi, mode); -#endif - child_hash = g_hash_table_new (NULL, NULL); - child_windows = g_hash_table_new (NULL, NULL); - child_views = g_hash_table_new (NULL, NULL); - view_hash = g_hash_table_new (NULL, NULL); - window_hash = g_hash_table_new (NULL, NULL); - - /* Walk the list of windows. */ - - g_snprintf (key, sizeof(key), "%s/mdi_windows", section); - window_list = config_get_list (key); - - /* Walk the list of children. */ - - g_snprintf (key, sizeof(key), "%s/mdi_children", section); - child_list = config_get_list (key); - - /* Get the active view. */ - - g_snprintf (key, sizeof(key), "%s/mdi_active_view", section); - string = gnome_config_get_string (key); - - if (string) { - sscanf (string, "%lx", &active_view); - g_free (string); - } - - /* Get the active window. */ - - g_snprintf (key, sizeof(key), "%s/mdi_active_window", section); - string = gnome_config_get_string (key); - - if (string) { - sscanf (string, "%lx", &active_window); - g_free (string); - } - - /* Read child descriptions. */ - - for (i = 0; i < child_list->len; i++) { - glong child = (glong) child_list->pdata [i]; - GPtrArray *windows, *views; - BonoboMDIChild *mdi_child; - - g_snprintf (key, sizeof(key), "%s/mdi_child_config_%lx", - section, child); - string = gnome_config_get_string (key); - /* - if (!string) continue; - */ - mdi_child = create_child_func (string); - - if (string != NULL) - g_free (string); - - bonobo_mdi_add_child (mdi, mdi_child); - - g_hash_table_insert (child_hash, (gpointer)child, mdi_child); - - g_snprintf (key, sizeof(key), "%s/mdi_child_windows_%lx", - section, child); - windows = config_get_list (key); - - g_hash_table_insert (child_windows, (gpointer) child, windows); - - g_snprintf (key, sizeof(key), "%s/mdi_child_views_%lx", - section, child); - views = config_get_list (key); - - g_hash_table_insert (child_views, (gpointer) child, views); - } - - /* Read window descriptions. */ - - for (i = 0; i < window_list->len; i++) - restore_window (mdi, section, child_list, - child_hash, child_windows, - child_views, view_hash, window_hash, - (glong) window_list->pdata [i]); - - /* For each window, set its active view. */ - - for (i = 0; i < window_list->len; i++) { - GtkWidget *real_view; - glong view; - gint ret; - - g_snprintf (key, sizeof(key), "%s/mdi_window_view_%lx", - section, (long) window_list->pdata [i]); - string = gnome_config_get_string (key); - if (!string) continue; - - ret = sscanf (string, "%lx", &view); - g_free (string); - if (ret != 1) continue; - - real_view = g_hash_table_lookup (view_hash, (gpointer) view); - if (!real_view) continue; - - bonobo_mdi_set_active_view (mdi, real_view); - } - - /* Finally, set the active window. */ - - set_active_window (mdi, window_hash, active_window); - - /* Free allocated memory. */ - - for (i = 0; i < child_list->len; i++) { - glong child = (glong) child_list->pdata [i]; - GPtrArray *windows, *views; - - windows = g_hash_table_lookup (child_windows, (gpointer) child); - if (windows) g_ptr_array_free (windows, FALSE); - - views = g_hash_table_lookup (child_views, (gpointer) child); - if (views) g_ptr_array_free (views, FALSE); - } - - g_hash_table_destroy (child_hash); - g_hash_table_destroy (child_windows); - g_hash_table_destroy (child_views); - g_hash_table_destroy (view_hash); - g_hash_table_destroy (window_hash); - - retval = TRUE; - - out: - bonobo_mdi_set_restoring_state (mdi, FALSE); - - return retval; -} - -static gpointer -view_window_func (gpointer data) -{ - if (GTK_WIDGET_REALIZED (GTK_WIDGET (data))) - return bonobo_mdi_get_window_from_view(GTK_WIDGET(data)); - else - return NULL; -} - -/** - * bonobo_mdi_save_state: - * @mdi: A pointer to a BonoboMDI object. - * @section: Name of the section that the MDI config should be saved to. - * - * Description: - * Saves MDI state to the application's config file in section @section. - **/ -void -bonobo_mdi_save_state (BonoboMDI *mdi, const gchar *section) -{ - gchar key [BUFSIZ], value [BUFSIZ]; - GList *child, *window; - - gnome_config_clean_section (section); - - /* save MDI mode */ - g_snprintf (key, sizeof(key), "%s/mdi_mode", section); -#if 0 - gnome_config_set_int (key, bonobo_mdi_get_mode (mdi)); -#endif - /* This *is* the value of BONOBO_MDI_DEFAULT_MODE from - * ghex/src/bonobo-mdi.h. Unbelievable, eh? - */ - gnome_config_set_int (key, 42); - - /* Write list of children. */ - - g_snprintf (key, sizeof(key), "%s/mdi_children", section); - config_set_list (key, bonobo_mdi_get_children (mdi), NULL); - - /* Write list of windows. */ - - g_snprintf (key, sizeof(key), "%s/mdi_windows", section); - config_set_list (key, bonobo_mdi_get_windows (mdi), NULL); - - /* Save active window. */ - - g_snprintf (key, sizeof(key), "%s/mdi_active_window", section); - g_snprintf (value, sizeof(value), "%lx", (glong) bonobo_mdi_get_active_window (mdi)); - gnome_config_set_string (key, value); - - /* Save active view. */ - - g_snprintf (key, sizeof(key), "%s/mdi_active_view", section); - g_snprintf (value, sizeof(value), "%lx", (glong) bonobo_mdi_get_active_view (mdi)); - gnome_config_set_string (key, value); - - /* Walk list of children. */ - - child = bonobo_mdi_get_children (mdi); - while (child) { - BonoboMDIChild *mdi_child; - gchar *string; - - mdi_child = BONOBO_MDI_CHILD (child->data); - - /* Save child configuration. */ - - string = bonobo_mdi_child_get_config_string(mdi_child); - - if (string) { - g_snprintf (key, sizeof(key), "%s/mdi_child_config_%lx", - section, (long) mdi_child); - gnome_config_set_string (key, string); - g_free (string); - } - - /* Save list of views this child has. */ - - g_snprintf (key, sizeof(key), "%s/mdi_child_windows_%lx", - section, (long) mdi_child); - config_set_list (key, bonobo_mdi_child_get_views (mdi_child), view_window_func); - - g_snprintf (key, sizeof(key), "%s/mdi_child_views_%lx", - section, (long) mdi_child); - config_set_list (key, bonobo_mdi_child_get_views (mdi_child), NULL); - - child = g_list_next (child); - } - - /* Save list of toplevel windows. */ - - window = bonobo_mdi_get_windows (mdi); - while (window) { - BonoboWindow *app; - GtkWidget *view; - const gchar *role; -#ifdef SNM - gchar *string; - BonoboDockLayout *layout; -#endif - - app = BONOBO_WINDOW (window->data); - - role = gtk_window_get_role (GTK_WINDOW (app)); - - if (role != NULL) - { - g_snprintf (key, sizeof(key), "%s/mdi_window_%lx", - section, (long) app); - gnome_config_set_string (key, role); - } - - view = bonobo_mdi_get_view_from_window (mdi, app); - - g_snprintf (key, sizeof(key), "%s/mdi_window_view_%lx", - section, (long) app); - g_snprintf (value, sizeof(value), "%lx", (long) view); - - gnome_config_set_string (key, value); - - g_snprintf(key, sizeof(key), "%s/mdi_window_layout_%lx", - section, (long) app); - -#ifdef SNM - layout = bonobo_dock_get_layout (BONOBO_DOCK (app->priv->dock)); - string = bonobo_dock_layout_create_string (layout); - g_object_unref (G_OBJECT (layout)); - gnome_config_set_string(key, string); - g_free(string); -#endif - - window = g_list_next (window); - } - - gnome_config_sync (); -} diff --git a/gedit/bonobo-mdi-session.h b/gedit/bonobo-mdi-session.h deleted file mode 100644 index 6fda1f6a0..000000000 --- a/gedit/bonobo-mdi-session.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * bonobo-mdi-session.h - session managament functions - * - * Copyright (C) 2002 Free Software Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - * - */ - -/* - * Originally written by Martin Baulig <martin@home-of-linux.org> - */ - -#ifndef __BONOBO_MDI_SESSION_H__ -#define __BONOBO_MDI_SESSION_H__ - -#include <string.h> - -#include "bonobo-mdi.h" - -/* This function should parse the config string and return a newly - * created BonoboMDIChild. */ -typedef BonoboMDIChild *(*BonoboMDIChildCreator) (const gchar *); - -/* bonobo_mdi_restore_state(): call this with the BonoboMDI object, the - * config section name and the function used to recreate the BonoboMDIChildren - * from their config strings. */ -gboolean bonobo_mdi_restore_state (BonoboMDI *mdi, const gchar *section, - BonoboMDIChildCreator child_create_func); - -/* bonobo_mdi_save_state (): call this with the BonoboMDI object as the - * first and the config section name as the second argument. */ -void bonobo_mdi_save_state (BonoboMDI *mdi, const gchar *section); - -#endif diff --git a/gedit/bonobo-mdi.c b/gedit/bonobo-mdi.c deleted file mode 100644 index 12819d692..000000000 --- a/gedit/bonobo-mdi.c +++ /dev/null @@ -1,2247 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * bonobo-mdi.c - implementation of a BonoboMDI object - * - * Copyright (C) 2001-2002 Free Software Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Paolo Maggi - */ - -/* - * Modified by the gedit Team, 2001-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "bonobo-mdi.h" - -#include <bonobo/bonobo-i18n.h> -#include <gedit-marshal.h> -#include <bonobo/bonobo-dock-layout.h> -#include <bonobo/bonobo-ui-util.h> - -#include "gedit-debug.h" - -#include <string.h> -#include <time.h> -#include <unistd.h> - -#define BONOBO_MDI_KEY "BonoboMDI" -#define BONOBO_MDI_CHILD_KEY "BonoboMDIChild" -#define UI_COMPONENT_KEY "UIComponent" -#define BOOK_KEY "Book" -#define WINDOW_INFO_KEY "BonoboMDIWindowInfo" - -static void bonobo_mdi_class_init (BonoboMDIClass *); -static void bonobo_mdi_instance_init (BonoboMDI *); -static void bonobo_mdi_finalize (GObject *); -static void child_list_menu_create (BonoboMDI *, BonoboWindow *); -static void child_list_menu_create_all (BonoboMDI *); -static void child_list_menu_remove (BonoboMDI *, BonoboWindow *); -static void child_list_menu_remove_all (BonoboMDI *); - - -static void child_list_activated_cb (BonoboUIComponent *uic, gpointer user_data, - const gchar* verbname); - -static void app_create (BonoboMDI *, gchar *, const char *); -static void app_clone (BonoboMDI *, BonoboWindow *, const char *); -static void app_destroy (BonoboWindow *, BonoboMDI *); -static void app_set_view (BonoboMDI *, BonoboWindow *, GtkWidget *); - -static gboolean app_close_book (BonoboWindow *, GdkEventAny *, BonoboMDI *); - -static GtkWidget *book_create (BonoboMDI *); -static void book_switch_page (GtkNotebook *, GtkNotebookPage *, - gint, BonoboMDI *); -static gboolean book_motion (GtkWidget *widget, GdkEventMotion *e, - gpointer data); -static gboolean book_button_press (GtkWidget *widget, GdkEventButton *e, - gpointer data); -static gboolean book_button_release (GtkWidget *widget, GdkEventButton *e, - gpointer data); -static void book_add_view (GtkNotebook *, GtkWidget *); -static void set_page_by_widget (GtkNotebook *, GtkWidget *); - -static gboolean toplevel_focus (BonoboWindow *, GdkEventFocus *, BonoboMDI *); - -static void set_active_view (BonoboMDI *, GtkWidget *); - -/* convenience functions that call child's "virtual" functions */ -static GtkWidget *child_set_label (BonoboMDIChild *, GtkWidget *); - -static void child_name_changed (BonoboMDIChild *mdi_child, - gchar* old_name, - BonoboMDI *mdi); -static void bonobo_mdi_update_child (BonoboMDI *mdi, BonoboMDIChild *child); - -static gchar* escape_underscores (const gchar* text); - -static GtkWidget* get_book_from_window (BonoboWindow *window); - -static GdkCursor *drag_cursor = NULL; - -enum { - ADD_CHILD, - REMOVE_CHILD, - ADD_VIEW, - REMOVE_VIEW, - CHILD_CHANGED, - VIEW_CHANGED, - TOP_WINDOW_CREATED, - TOP_WINDOW_DESTROY, - ALL_WINDOWS_DESTROYED, - LAST_SIGNAL -}; - - -struct _BonoboMDIPrivate -{ - GtkPositionType tab_pos; - - guint signal_id; - gint in_drag : 1; - - gchar *mdi_name; - gchar *title; - - gchar *ui_xml; - gchar *ui_file_name; - BonoboUIVerb *verbs; - - /* Probably only one of these would do, but... redundancy rules ;) */ - BonoboMDIChild *active_child; - GtkWidget *active_view; - BonoboWindow *active_window; - - GList *windows; /* toplevel windows - BonoboWindow widgets */ - GList *children; /* children - BonoboMDIChild objects*/ - - GSList *registered; /* see comment for bonobo_mdi_(un)register() functions - * below for an explanation. */ - - /* Paths for insertion of mdi-child list menu via */ - gchar *child_list_path; - - gint default_window_height; - gint default_window_width; - - /* Whether our state is being restored for session management */ - gboolean restoring_state; -}; - -typedef gboolean (*BonoboMDISignal1) (GObject *, gpointer, gpointer); -typedef void (*BonoboMDISignal2) (GObject *, gpointer, gpointer); - -static GObjectClass *parent_class = NULL; -static guint mdi_signals [LAST_SIGNAL] = { 0 }; - -GType -bonobo_mdi_get_type (void) -{ - static GType bonobo_mdi_type = 0; - - if (bonobo_mdi_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (BonoboMDIClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) bonobo_mdi_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (BonoboMDI), - 0, /* n_preallocs */ - (GInstanceInitFunc) bonobo_mdi_instance_init - }; - - bonobo_mdi_type = g_type_register_static (G_TYPE_OBJECT, - "BonoboMDI", - &our_info, - 0); - } - - return bonobo_mdi_type; -} - -static void -bonobo_mdi_class_init (BonoboMDIClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass*) class; - - object_class->finalize = bonobo_mdi_finalize; - - mdi_signals[ADD_CHILD] = - g_signal_new ("add_child", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, add_child), - NULL, NULL, - gedit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, - BONOBO_TYPE_MDI_CHILD); - - mdi_signals[REMOVE_CHILD] = - g_signal_new ("remove_child", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, remove_child), - NULL, NULL, - gedit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, - BONOBO_TYPE_MDI_CHILD); - - mdi_signals[ADD_VIEW] = - g_signal_new ("add_view", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, add_view), - NULL, NULL, - gedit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, - GTK_TYPE_WIDGET); - - mdi_signals[REMOVE_VIEW] = - g_signal_new ("remove_view", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, remove_view), - NULL, NULL, - gedit_marshal_BOOLEAN__OBJECT, - G_TYPE_BOOLEAN, - 1, - GTK_TYPE_WIDGET); - - mdi_signals[CHILD_CHANGED] = - g_signal_new ("child_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, child_changed), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - BONOBO_TYPE_MDI_CHILD); - - mdi_signals[VIEW_CHANGED] = - g_signal_new ("view_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(BonoboMDIClass, view_changed), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - GTK_TYPE_WIDGET); - - mdi_signals[TOP_WINDOW_CREATED] = - g_signal_new ("top_window_created", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, top_window_created), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - BONOBO_TYPE_WINDOW); - - mdi_signals[TOP_WINDOW_DESTROY] = - g_signal_new ("top_window_destroy", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, top_window_destroy), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - BONOBO_TYPE_WINDOW); - - mdi_signals[ALL_WINDOWS_DESTROYED] = - g_signal_new ("all_windows_destroyed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (BonoboMDIClass, all_windows_destroyed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - - class->add_child = NULL; - class->remove_child = NULL; - class->add_view = NULL; - class->remove_view = NULL; - class->child_changed = NULL; - class->view_changed = NULL; - class->top_window_created = NULL; - - parent_class = gtk_type_class (G_TYPE_OBJECT); -} - -static void -bonobo_mdi_finalize (GObject *object) -{ - BonoboMDI *mdi; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (BONOBO_IS_MDI (object)); - - mdi = BONOBO_MDI (object); - g_return_if_fail (mdi->priv != NULL); - - bonobo_mdi_remove_all (mdi, TRUE); - - if (mdi->priv->child_list_path != NULL) - g_free (mdi->priv->child_list_path); - - if (mdi->priv->mdi_name != NULL) - g_free (mdi->priv->mdi_name); - - if (mdi->priv->title != NULL) - g_free (mdi->priv->title); - - if (mdi->priv->ui_xml != NULL) - g_free (mdi->priv->ui_xml); - - if (mdi->priv->ui_file_name != NULL) - g_free (mdi->priv->ui_file_name); - - g_free (mdi->priv); - mdi->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize)(object); - - gedit_debug (DEBUG_MDI, "END"); -} - - -static void -bonobo_mdi_instance_init (BonoboMDI *mdi) -{ - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (BONOBO_IS_MDI (mdi)); - - mdi->priv = g_new0 (BonoboMDIPrivate, 1); - g_return_if_fail (mdi->priv != NULL); - - mdi->priv->tab_pos = GTK_POS_TOP; - - mdi->priv->signal_id = 0; - mdi->priv->in_drag = FALSE; - - mdi->priv->children = NULL; - mdi->priv->windows = NULL; - mdi->priv->registered = NULL; - - mdi->priv->active_child = NULL; - mdi->priv->active_window = NULL; - mdi->priv->active_view = NULL; - - mdi->priv->ui_xml = NULL; - mdi->priv->ui_file_name = NULL; - mdi->priv->verbs = NULL; - - mdi->priv->child_list_path = NULL; - - gedit_debug (DEBUG_MDI, "END"); -} - - -/** - * bonobo_mdi_new: - * @mdi_name: Application name as used in filenames and paths. - * @title: Title of the application windows. - * - * Description: - * Creates a new MDI object. @mdi_name and @title are used for - * MDI's calling bonobo_window_new (). - * - * Return value: - * A pointer to a new BonoboMDI object. - **/ -GObject* -bonobo_mdi_new (const gchar *mdi_name, const gchar *title, - gint default_window_width, gint default_window_height) -{ - BonoboMDI *mdi; - - gedit_debug (DEBUG_MDI, ""); - - mdi = g_object_new (BONOBO_TYPE_MDI, NULL); - - mdi->priv->mdi_name = g_strdup (mdi_name); - mdi->priv->title = g_strdup (title); - - mdi->priv->default_window_width = default_window_width; - mdi->priv->default_window_height = default_window_height; - - gedit_debug (DEBUG_MDI, "END"); - - return G_OBJECT (mdi); -} - -static GtkWidget * -child_set_label (BonoboMDIChild *child, GtkWidget *label) -{ - GtkWidget *w; - w = BONOBO_MDI_CHILD_GET_CLASS (child)->set_label (child, label, NULL); - - return w; -} - -static void -set_page_by_widget (GtkNotebook *book, GtkWidget *view) -{ - gint i; - - i = gtk_notebook_page_num (book, view); - - if (gtk_notebook_get_current_page (book) != i) - gtk_notebook_set_current_page (book, i); -} - -static void -child_list_activated_cb (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - BonoboMDI* mdi; - BonoboMDIChild *child = BONOBO_MDI_CHILD (user_data); - g_return_if_fail (child != NULL); - - gedit_debug (DEBUG_MDI, ""); - - mdi = BONOBO_MDI (g_object_get_data (G_OBJECT (child), BONOBO_MDI_KEY)); - g_return_if_fail (mdi != NULL); - - if (child && (child != mdi->priv->active_child)) - { - GList *views = bonobo_mdi_child_get_views (child); - - if (views) - { - GtkWindow *window; - - window = GTK_WINDOW (bonobo_mdi_get_window_from_view (views->data)); - gtk_window_present (window); - - bonobo_mdi_set_active_view (mdi, views->data); - } - else - bonobo_mdi_add_view (mdi, child); - } - - gedit_debug (DEBUG_MDI, "END"); -} - -static gchar* -escape_underscores (const gchar* text) -{ - GString *str; - gint length; - const gchar *p; - const gchar *end; - - g_return_val_if_fail (text != NULL, NULL); - - length = strlen (text); - - str = g_string_new (""); - - p = text; - end = text + length; - - while (p != end) - { - const gchar *next; - next = g_utf8_next_char (p); - - switch (*p) - { - case '_': - g_string_append (str, "__"); - break; - default: - g_string_append_len (str, p, next - p); - break; - } - - p = next; - } - - return g_string_free (str, FALSE); -} - -static void -child_list_menu_create (BonoboMDI *mdi, BonoboWindow *win) -{ - GList *child; - BonoboUIComponent *ui_component; - gint accell_num = 1; - - if (mdi->priv->child_list_path == NULL) - return; - - ui_component = BONOBO_UI_COMPONENT ( - g_object_get_data (G_OBJECT (win), UI_COMPONENT_KEY)); - - child = mdi->priv->children; - - bonobo_ui_component_freeze (ui_component, NULL); - - while (child) - { - gchar *xml = NULL; - gchar *cmd = NULL; - gchar *verb_name = NULL; - gchar *tip; - gchar *escaped_name; - gchar *safe_name; - gchar *child_name = bonobo_mdi_child_get_name (BONOBO_MDI_CHILD (child->data)); - - safe_name = g_markup_escape_text (child_name, strlen (child_name)); - g_return_if_fail (safe_name != NULL); - - escaped_name = escape_underscores (safe_name); - g_return_if_fail (escaped_name != NULL); - - tip = g_strdup_printf (_("Activate %s"), safe_name); - verb_name = g_strdup_printf ("Child_%p", child->data); - xml = g_strdup_printf ("<menuitem name=\"%s\" verb=\"%s\"" - " _label=\"%s\"/>", verb_name, verb_name, escaped_name); - - if (accell_num <= 9) - cmd = g_strdup_printf ("<cmd name = \"%s\" _label=\"%s\"" - " _tip=\"%s\" accel=\"*Alt*%d\"/>", - verb_name, escaped_name, tip, accell_num); - else - cmd = g_strdup_printf ("<cmd name = \"%s\" _label=\"%s\"" - " _tip=\"%s\"/>", verb_name, escaped_name, tip); - - ++ accell_num; - - g_free (tip); - g_free (child_name); - g_free (safe_name); - g_free (escaped_name); - - bonobo_ui_component_set_translate (ui_component, mdi->priv->child_list_path, xml, NULL); - bonobo_ui_component_set_translate (ui_component, "/commands/", cmd, NULL); - bonobo_ui_component_add_verb (ui_component, verb_name, child_list_activated_cb, child->data); - - g_free (xml); - g_free (cmd); - g_free (verb_name); - - child = g_list_next (child); - } - - bonobo_ui_component_thaw (ui_component, NULL); -} - -static void -child_list_menu_remove (BonoboMDI *mdi, BonoboWindow *win) -{ - GList *child; - BonoboUIComponent *ui_component; - - if (mdi->priv->child_list_path == NULL) - return; - - ui_component = BONOBO_UI_COMPONENT ( - g_object_get_data (G_OBJECT (win), UI_COMPONENT_KEY)); - - child = mdi->priv->children; - - bonobo_ui_component_freeze (ui_component, NULL); - - while (child) - { - gchar *verb_name = NULL; - gchar *path; - gchar *cmd; - - verb_name = g_strdup_printf ("Child_%p", child->data); - path = g_strdup_printf ("%s%s", mdi->priv->child_list_path, verb_name); - cmd = g_strdup_printf ("/commands/%s", verb_name); - - bonobo_ui_component_remove_verb (ui_component, verb_name); - bonobo_ui_component_rm (ui_component, path, NULL); - bonobo_ui_component_rm (ui_component, cmd, NULL); - - g_free (path); - g_free (cmd); - g_free (verb_name); - - child = g_list_next (child); - } - - bonobo_ui_component_thaw (ui_component, NULL); -} - -static void -child_list_menu_create_all (BonoboMDI *mdi) -{ - GList *win_node; - - if (mdi->priv->child_list_path == NULL) - return; - - win_node = mdi->priv->windows; - - while (win_node) - { - child_list_menu_create (mdi, BONOBO_WINDOW (win_node->data)); - - win_node = g_list_next (win_node); - } -} - -static void -child_list_menu_remove_all (BonoboMDI *mdi) -{ - GList *win_node; - - if (mdi->priv->child_list_path == NULL) - return; - - win_node = mdi->priv->windows; - - while (win_node) - { - child_list_menu_remove (mdi, BONOBO_WINDOW (win_node->data)); - - win_node = g_list_next (win_node); - } -} - - - -static gboolean -book_motion (GtkWidget *widget, GdkEventMotion *e, gpointer data) -{ - BonoboMDI *mdi; - - mdi = BONOBO_MDI (data); - - if (!drag_cursor) - drag_cursor = gdk_cursor_new (GDK_HAND2); - - if (e->window == GTK_NOTEBOOK (widget)->event_window) - { - mdi->priv->in_drag = TRUE; - gtk_grab_add (widget); - gdk_pointer_grab (widget->window, FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK, NULL, - drag_cursor, GDK_CURRENT_TIME); - if (mdi->priv->signal_id) - { - g_signal_handler_disconnect (G_OBJECT (widget), - mdi->priv->signal_id); - mdi->priv->signal_id = 0; - } - } - - return FALSE; -} - -static gboolean -book_button_press (GtkWidget *widget, GdkEventButton *e, gpointer data) -{ - BonoboMDI *mdi; - - mdi = BONOBO_MDI (data); - - if ((e->button == 1) && (e->window == GTK_NOTEBOOK (widget)->event_window)) - mdi->priv->signal_id = g_signal_connect ( - G_OBJECT (widget), - "motion_notify_event", - G_CALLBACK (book_motion), - mdi); - - return FALSE; -} - -static gboolean -book_button_release (GtkWidget *widget, GdkEventButton *e, gpointer data) -{ - gint x = e->x_root, y = e->y_root; - BonoboMDI *mdi; - - mdi = BONOBO_MDI(data); - - if (mdi->priv->signal_id) - { - g_signal_handler_disconnect (G_OBJECT (widget), mdi->priv->signal_id); - mdi->priv->signal_id = 0; - } - - if ((e->button == 1) && mdi->priv->in_drag) - { - GdkWindow *window; - GList *child; - BonoboWindow *win; - GtkWidget *view, *new_book; - GtkNotebook *old_book = GTK_NOTEBOOK (widget); - - mdi->priv->in_drag = FALSE; - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gtk_grab_remove (widget); - - window = gdk_window_at_pointer (&x, &y); - if (window) - window = gdk_window_get_toplevel (window); - - child = mdi->priv->windows; - - while (child) - { - if (window == GTK_WIDGET (child->data)->window) - { - int cur_page; - - /* page was dragged to another notebook */ - - old_book = GTK_NOTEBOOK(widget); - new_book = get_book_from_window (BONOBO_WINDOW (child->data)); - - if (old_book == (GtkNotebook *) new_book) - /* page has been dropped on the source notebook */ - return FALSE; - - cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (old_book)); - - if (cur_page >= 0) - { - view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (old_book), cur_page); - gtk_container_remove (GTK_CONTAINER(old_book), view); - - book_add_view (GTK_NOTEBOOK (new_book), view); - - win = bonobo_mdi_get_window_from_view (view); - gdk_window_raise (GTK_WIDGET(win)->window); - - mdi->priv->active_window = win; - - cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (old_book)); - - if (cur_page < 0) - { - mdi->priv->active_window = win; - win = BONOBO_WINDOW (gtk_widget_get_toplevel ( - GTK_WIDGET (old_book))); - mdi->priv->windows = g_list_remove(mdi->priv->windows, win); - gtk_widget_destroy (GTK_WIDGET (win)); - } - - g_signal_emit (G_OBJECT (mdi), - mdi_signals [CHILD_CHANGED], - 0, - NULL); - - g_signal_emit (G_OBJECT (mdi), - mdi_signals [VIEW_CHANGED], - 0, - view); - } - - return FALSE; - } - - child = child->next; - } - - if (g_list_length (old_book->children) == 1) - return FALSE; - - /* create a new toplevel */ - if (old_book->cur_page) - { - gint width, height; - int cur_page = gtk_notebook_get_current_page (old_book); - - view = gtk_notebook_get_nth_page (old_book, cur_page); - - win = bonobo_mdi_get_window_from_view (view); - - gtk_window_get_size (GTK_WINDOW (win), &width, &height); - - gtk_container_remove (GTK_CONTAINER (old_book), view); - - app_clone (mdi, win, NULL); - - new_book = book_create (mdi); - - book_add_view (GTK_NOTEBOOK (new_book), view); - - gtk_window_set_position (GTK_WINDOW (mdi->priv->active_window), GTK_WIN_POS_MOUSE); - - gtk_window_set_default_size (GTK_WINDOW (mdi->priv->active_window), width, height); - - if (!GTK_WIDGET_VISIBLE (mdi->priv->active_window)) - gtk_widget_show (GTK_WIDGET (mdi->priv->active_window)); - } - } - - return FALSE; -} - -static GtkWidget * -book_create (BonoboMDI *mdi) -{ - GtkWidget *us; - GtkWidget *vbox; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi->priv->active_window != NULL, NULL); - - vbox = gtk_vbox_new (FALSE, 0); - us = gtk_notebook_new (); - - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (us), mdi->priv->tab_pos); - - gtk_box_pack_start (GTK_BOX (vbox), us, TRUE, TRUE, 0); - - gtk_widget_show_all (vbox); - - bonobo_window_set_contents (mdi->priv->active_window, vbox); - g_object_set_data (G_OBJECT (mdi->priv->active_window), BOOK_KEY, us); - - gtk_widget_add_events (us, GDK_BUTTON1_MOTION_MASK); - - g_signal_connect (G_OBJECT (us), "switch_page", - G_CALLBACK (book_switch_page), mdi); - - g_signal_connect (G_OBJECT (us), "button_press_event", - G_CALLBACK (book_button_press), mdi); - g_signal_connect (G_OBJECT (us), "button_release_event", - G_CALLBACK (book_button_release), mdi); - - gtk_notebook_set_scrollable (GTK_NOTEBOOK (us), TRUE); - - gedit_debug (DEBUG_MDI, "END"); - - return us; -} - -static void -book_add_view (GtkNotebook *book, GtkWidget *view) -{ - BonoboMDIChild *child; - GtkWidget *title; - - gedit_debug (DEBUG_MDI, ""); - - child = bonobo_mdi_get_child_from_view (view); - - title = child_set_label (child, NULL); - - gtk_notebook_append_page (book, view, title); - - if (g_list_length (book->children) > 1) - set_page_by_widget (book, view); - - gedit_debug (DEBUG_MDI, "END"); -} - -static void -book_switch_page (GtkNotebook *book, GtkNotebookPage *pg, gint page_num, BonoboMDI *mdi) -{ - BonoboWindow *win; - GtkWidget *page; - - gedit_debug (DEBUG_MDI, ""); - - win = BONOBO_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (book))); - - page = gtk_notebook_get_nth_page (book, page_num); - - if (page != NULL) - { - if (page != mdi->priv->active_view) - app_set_view (mdi, win, page); - } - else - app_set_view (mdi, win, NULL); - - gedit_debug (DEBUG_MDI, "END"); - -} - -static GtkWidget* -get_book_from_window (BonoboWindow *window) -{ - gpointer *book; - - g_return_val_if_fail (window != NULL, NULL); - - book = g_object_get_data (G_OBJECT (window), BOOK_KEY); - - return (book != NULL) ? GTK_WIDGET (book) : NULL; -} - -static gboolean -toplevel_focus (BonoboWindow *win, GdkEventFocus *event, BonoboMDI *mdi) -{ - GtkWidget *contents; - - gedit_debug (DEBUG_MDI, ""); - - /* updates active_view and active_child when a new toplevel receives focus */ - g_return_val_if_fail (BONOBO_IS_WINDOW (win), FALSE); - - if (mdi->priv->active_window == win) - return FALSE; - - mdi->priv->active_window = win; - - contents = get_book_from_window (win); - - if (GTK_NOTEBOOK (contents)->cur_page) - { - int cur_page; - GtkWidget *child; - - cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (contents)); - child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (contents), cur_page); - set_active_view (mdi, child); - } - else - set_active_view (mdi, NULL); - - gedit_debug (DEBUG_MDI, "END"); - - return FALSE; -} - -static gboolean -app_configure_event_handler (GtkWidget *widget, GdkEventConfigure *event) -{ - BonoboMDIWindowInfo *window_info; - - g_return_val_if_fail (BONOBO_IS_WINDOW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - window_info = (BonoboMDIWindowInfo*) - g_object_get_data (G_OBJECT (widget), WINDOW_INFO_KEY); - g_return_val_if_fail (window_info != NULL, FALSE); - - window_info->width = event->width; - window_info->height = event->height; - - return FALSE; -} - -static gboolean -app_window_state_event_handler (GtkWidget *widget, GdkEventWindowState *event) -{ - BonoboMDIWindowInfo *window_info; - - g_return_val_if_fail (BONOBO_IS_WINDOW (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - window_info = (BonoboMDIWindowInfo*) - g_object_get_data (G_OBJECT (widget), WINDOW_INFO_KEY); - g_return_val_if_fail (window_info != NULL, FALSE); - - window_info->state = event->new_window_state; - - return FALSE; -} - - -static void -app_clone (BonoboMDI *mdi, BonoboWindow *win, const char *window_role) -{ - gedit_debug (DEBUG_MDI, ""); - - app_create (mdi, NULL, window_role); - - if (win != NULL && !bonobo_mdi_get_restoring_state (mdi)) - { - const BonoboMDIWindowInfo *window_info = bonobo_mdi_get_window_info (win); - g_return_if_fail (window_info != NULL); - - if ((window_info->state & GDK_WINDOW_STATE_MAXIMIZED) != 0) - gtk_window_maximize (GTK_WINDOW (mdi->priv->active_window)); - else - { - gtk_window_set_default_size (GTK_WINDOW (mdi->priv->active_window), - window_info->width, - window_info->height); - - gtk_window_unmaximize (GTK_WINDOW (mdi->priv->active_window)); - } - - if ((window_info->state & GDK_WINDOW_STATE_STICKY ) != 0) - gtk_window_stick (GTK_WINDOW (mdi->priv->active_window)); - else - gtk_window_unstick (GTK_WINDOW (mdi->priv->active_window)); - } - - gedit_debug (DEBUG_MDI, "END"); -} - - -static gboolean -app_close_book (BonoboWindow *win, GdkEventAny *event, BonoboMDI *mdi) -{ - BonoboMDIChild *child; - GtkWidget *view; - gint handler_ret = TRUE; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (win != NULL, FALSE); - g_return_val_if_fail (mdi != NULL, FALSE); - - toplevel_focus (win, NULL, mdi); - - if (g_list_length (mdi->priv->windows) == 1) - { - if (!bonobo_mdi_remove_all (mdi, FALSE)) - { - gedit_debug (DEBUG_MDI, "END1"); - - return TRUE; - } - - mdi->priv->windows = g_list_remove (mdi->priv->windows, win); - gtk_widget_destroy (GTK_WIDGET (win)); - - /* only emit al_windows_destroyed signal if there are no non-MDI windows registered - with it. */ - if (mdi->priv->registered == NULL) - g_signal_emit (G_OBJECT (mdi), mdi_signals [ALL_WINDOWS_DESTROYED], 0); - } - else - { - GList *children = gtk_container_get_children ( - GTK_CONTAINER (get_book_from_window (win))); - GList *li; - - if (children == NULL) - { - mdi->priv->windows = g_list_remove (mdi->priv->windows, win); - gtk_widget_destroy (GTK_WIDGET (win)); - - gedit_debug (DEBUG_MDI, "END2"); - - return FALSE; - } - - /* first check if all the children in this notebook can be removed */ - for (li = children; li != NULL; li = li->next) - { - GList *node; - view = li->data; - - child = bonobo_mdi_get_child_from_view (view); - - node = bonobo_mdi_child_get_views (child); - - while (node) - { - if (bonobo_mdi_get_window_from_view (node->data) != win) - break; - - node = node->next; - } - - if (node == NULL) - { - /* all the views reside in this BonoboWindow */ - g_signal_emit (G_OBJECT(mdi), - mdi_signals [REMOVE_CHILD], - 0, - child, - &handler_ret); - - if (handler_ret == FALSE) - { - g_list_free (children); - - gedit_debug (DEBUG_MDI, "END3"); - - return TRUE; - } - } - } - - /* now actually remove all children/views! */ - for (li = children; li != NULL; li = li->next) - { - view = li->data; - - child = bonobo_mdi_get_child_from_view (view); - - /* if this is the last view, remove the child */ - if (g_list_length (bonobo_mdi_child_get_views (child)) == 1) - bonobo_mdi_remove_child (mdi, child, TRUE); - else - bonobo_mdi_remove_view (mdi, view, TRUE); - } - - g_list_free (children); - } - - gedit_debug (DEBUG_MDI, "END"); - - return FALSE; -} - -static void -app_set_view (BonoboMDI *mdi, BonoboWindow *win, GtkWidget *view) -{ - gedit_debug (DEBUG_MDI, ""); - - gtk_window_set_title (GTK_WINDOW (win), mdi->priv->title); - - set_active_view (mdi, view); - - gedit_debug (DEBUG_MDI, "END"); -} - -static void -app_destroy (BonoboWindow *win, BonoboMDI *mdi) -{ - gedit_debug (DEBUG_MDI, ""); - - if (mdi->priv->active_window == win) - mdi->priv->active_window = - (mdi->priv->windows != NULL) ? BONOBO_WINDOW (mdi->priv->windows->data) : NULL; - - g_signal_emit (G_OBJECT (mdi), mdi_signals [TOP_WINDOW_DESTROY], 0, win); - - gedit_debug (DEBUG_MDI, "END"); -} - -/* Generates a unique string for a window role. - * - * Taken from EOG. - */ -static char * -gen_role (void) -{ - char *ret; - static char *hostname; - time_t t; - static int serial; - - t = time (NULL); - - if (!hostname) { - static char buffer [512]; - - if ((gethostname (buffer, sizeof (buffer) - 1) == 0) && - (buffer [0] != 0)) - hostname = buffer; - else - hostname = "localhost"; - } - - ret = g_strdup_printf ("bonobo-mdi-window-%d-%d-%d-%ld-%d@%s", - getpid (), - getgid (), - getppid (), - (long) t, - serial++, - hostname); - - return ret; -} - -static void -app_create (BonoboMDI *mdi, gchar *layout_string, const char *window_role) -{ - GtkWidget *window; - BonoboWindow *bw; - gchar* config_path; - BonoboUIContainer *ui_container = NULL; - BonoboUIComponent *ui_component = NULL; - BonoboMDIWindowInfo *window_info = NULL; - - gedit_debug (DEBUG_MDI, ""); - - window = bonobo_window_new (mdi->priv->mdi_name, mdi->priv->title); - g_return_if_fail (window != NULL); - - if (!bonobo_mdi_get_restoring_state (mdi)) - gtk_window_set_default_size (GTK_WINDOW (window), - mdi->priv->default_window_width, - mdi->priv->default_window_height); - - if (window_role) - gtk_window_set_role (GTK_WINDOW (window), window_role); - else { - char *role; - - role = gen_role (); - gtk_window_set_role (GTK_WINDOW (window), role); - g_free (role); - } - - bw = BONOBO_WINDOW (window); - - mdi->priv->windows = g_list_append (mdi->priv->windows, window); - - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (app_close_book), mdi); - g_signal_connect (G_OBJECT (window), "focus_in_event", - G_CALLBACK (toplevel_focus), mdi); - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (app_destroy), mdi); - g_signal_connect (G_OBJECT (window), "configure_event", - G_CALLBACK (app_configure_event_handler), NULL); - g_signal_connect (G_OBJECT (window), "window_state_event", - G_CALLBACK (app_window_state_event_handler), NULL); - - /* Create Container: */ - ui_container = bonobo_window_get_ui_container (bw); - - config_path = g_strdup_printf ("/%s/UIConfig/kvps", mdi->priv->mdi_name); - - bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (bw), - config_path); - g_free (config_path); - - /* Create a UI component with which to communicate with the window */ - ui_component = bonobo_ui_component_new_default (); - - /* Associate the BonoboUIComponent with the container */ - bonobo_ui_component_set_container ( - ui_component, BONOBO_OBJREF (ui_container), NULL); - - /* set up UI */ - if (mdi->priv->ui_xml != NULL) - { - bonobo_ui_component_set_translate (ui_component, - "/", mdi->priv->ui_xml, NULL); - } - else - if (mdi->priv->ui_file_name) - { - bonobo_ui_util_set_ui (ui_component, "", mdi->priv->ui_file_name, - mdi->priv->mdi_name, NULL); - } - - if (mdi->priv->verbs) - bonobo_ui_component_add_verb_list_with_data (ui_component, - mdi->priv->verbs, mdi); - - mdi->priv->active_window = bw; - mdi->priv->active_child = NULL; - mdi->priv->active_view = NULL; - - window_info = g_new0 (BonoboMDIWindowInfo, 1); - - g_object_set_data (G_OBJECT (bw), UI_COMPONENT_KEY, ui_component); - g_object_set_data_full (G_OBJECT (bw), WINDOW_INFO_KEY, window_info, g_free); - - g_signal_emit (G_OBJECT (mdi), mdi_signals [TOP_WINDOW_CREATED], 0, window); - - child_list_menu_create (mdi, bw); - - gedit_debug (DEBUG_MDI, "END"); -} - -static void -set_active_view (BonoboMDI *mdi, GtkWidget *view) -{ - BonoboMDIChild *old_child; - GtkWidget *old_view; - - gedit_debug (DEBUG_MDI, ""); - - old_child = mdi->priv->active_child; - old_view = mdi->priv->active_view; - - mdi->priv->active_view = view; - - if (!view) - mdi->priv->active_child = NULL; - else - { - - mdi->priv->active_child = bonobo_mdi_get_child_from_view (view); - mdi->priv->active_window = bonobo_mdi_get_window_from_view (view); - - gtk_widget_grab_focus (GTK_WIDGET (view)); - } - - if (view == old_view) - { - gedit_debug (DEBUG_MDI, "END1"); - - return; - } - - if (mdi->priv->active_child != old_child) - { - gedit_debug (DEBUG_MDI, "Emit child_changed"); - - g_signal_emit (G_OBJECT (mdi), mdi_signals [CHILD_CHANGED], 0, old_child); - } - - gedit_debug (DEBUG_MDI, "Emit view_changed"); - - g_signal_emit (G_OBJECT (mdi), mdi_signals [VIEW_CHANGED], 0, old_view); - - gedit_debug (DEBUG_MDI, "END2"); -} - -/** - * bonobo_mdi_set_active_view: - * @mdi: A pointer to an MDI object. - * @view: A pointer to the view that is to become the active one. - * - * Description: - * Sets the active view to @view. - **/ -void -bonobo_mdi_set_active_view (BonoboMDI *mdi, GtkWidget *view) -{ - GtkWindow *window; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (mdi != NULL); - g_return_if_fail (BONOBO_IS_MDI (mdi)); - g_return_if_fail (view != NULL); - g_return_if_fail (GTK_IS_WIDGET (view)); - - set_page_by_widget (GTK_NOTEBOOK (view->parent), view); - - window = GTK_WINDOW (bonobo_mdi_get_window_from_view (view)); - - set_active_view (mdi, view); - - gedit_debug (DEBUG_MDI, "END"); -} - -/** - * bonobo_mdi_add_view: - * @mdi: A pointer to a BonoboMDI object. - * @child: A pointer to a child. - * - * Description: - * Creates a new view of the child and adds it to the MDI. BonoboMDIChild - * @child has to be added to the MDI with a call to bonobo_mdi_add_child - * before its views are added to the MDI. - * An "add_view" signal is emitted to the MDI after the view has been - * created, but before it is shown and added to the MDI, with a pointer to - * the created view as its parameter. The view is added to the MDI only if - * the signal handler (if it exists) returns %TRUE. If the handler returns - * %FALSE, the created view is destroyed and not added to the MDI. - * - * Return value: - * %TRUE if adding the view succeeded and %FALSE otherwise. - **/ -gboolean -bonobo_mdi_add_view (BonoboMDI *mdi, BonoboMDIChild *child) -{ - GtkWidget *view; - GtkWidget *book; - gint ret = TRUE; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - g_return_val_if_fail (child != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE); - - view = bonobo_mdi_child_add_view (child); - - g_return_val_if_fail (view != NULL, FALSE); - - g_signal_emit (G_OBJECT (mdi), mdi_signals [ADD_VIEW], 0, view, &ret); - - if (!ret) - { - bonobo_mdi_child_remove_view (child, view); - - gedit_debug (DEBUG_MDI, "END1"); - - return FALSE; - } - - if (mdi->priv->active_window == NULL) - { - app_create (mdi, NULL, NULL); - gtk_widget_show (GTK_WIDGET (mdi->priv->active_window)); - } - - - if (!GTK_WIDGET_VISIBLE (view)) - gtk_widget_show (view); - - book = get_book_from_window (mdi->priv->active_window); - - if (book == NULL) - book = book_create (mdi); - - book_add_view (GTK_NOTEBOOK (book), view); - - /* this reference will compensate the view's unrefing - when removed from its parent later, as we want it to - stay valid until removed from the child with a call - to bonobo_mdi_child_remove_view() */ - g_object_ref (G_OBJECT (view)); - gtk_object_sink (GTK_OBJECT (view)); - - g_object_set_data (G_OBJECT (view), BONOBO_MDI_CHILD_KEY, child); - - gedit_debug (DEBUG_MDI, "END2"); - - return TRUE; -} - -/** - * bonobo_mdi_add_toplevel_view: - * @mdi: A pointer to a BonoboMDI object. - * @child: A pointer to a BonoboMDIChild object to be added to the MDI. - * @window_role: X window role to use for the window, for session-management - * purposes. If this is %NULL, a unique role string will be automatically - * generated. - * - * Description: - * Creates a new view of the child and adds it to the MDI; it behaves the - * same way as bonobo_mdi_add_view in %BONOBO_MDI_MODAL and %BONOBO_MDI_TOPLEVEL - * modes, but in %BONOBO_MDI_NOTEBOOK mode, the view is added in a new - * toplevel window unless the active one has no views in it. - * - * Return value: - * %TRUE if adding the view succeeded and %FALSE otherwise. - **/ -gboolean -bonobo_mdi_add_toplevel_view (BonoboMDI *mdi, BonoboMDIChild *child, const char *window_role) -{ - GtkWidget *view; - gint ret = TRUE; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - g_return_val_if_fail (child != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE); - - view = bonobo_mdi_child_add_view (child); - - g_return_val_if_fail (view != NULL, FALSE); - - g_signal_emit (G_OBJECT (mdi), mdi_signals [ADD_VIEW], 0, view, &ret); - - if (ret == FALSE) - { - bonobo_mdi_child_remove_view (child, view); - - gedit_debug (DEBUG_MDI, "END1"); - - return FALSE; - } - - bonobo_mdi_open_toplevel (mdi, window_role); - - if (!GTK_WIDGET_VISIBLE (view)) - gtk_widget_show (view); - - book_add_view (GTK_NOTEBOOK (get_book_from_window (mdi->priv->active_window)), view); - - /* this reference will compensate the view's unrefing - when removed from its parent later, as we want it to - stay valid until removed from the child with a call - to bonobo_mdi_child_remove_view() */ - g_object_ref (G_OBJECT (view)); - gtk_object_sink (GTK_OBJECT (view)); - - g_object_set_data (G_OBJECT (view), BONOBO_MDI_CHILD_KEY, child); - - gedit_debug (DEBUG_MDI, "END2"); - - return TRUE; -} - -/** - * bonobo_mdi_remove_view: - * @mdi: A pointer to a BonoboMDI object. - * @view: View to remove. - * @force: If TRUE, the "remove_view" signal is not emitted. - * - * Description: - * Removes a view from an MDI. - * A "remove_view" signal is emitted to the MDI before actually removing - * view. The view is removed only if the signal handler (if it exists and - * the @force is set to %FALSE) returns %TRUE. - * - * Return value: - * %TRUE if the view was removed and %FALSE otherwise. - **/ -gboolean -bonobo_mdi_remove_view (BonoboMDI *mdi, GtkWidget *view, gint force) -{ - GtkWidget *book; - BonoboWindow *window; - BonoboMDIChild *child; - gint ret = TRUE; - gint pn; - gboolean was_active_window = FALSE; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - g_return_val_if_fail (view != NULL, FALSE); - g_return_val_if_fail (GTK_IS_WIDGET (view), FALSE); - - if (!force) - g_signal_emit (G_OBJECT (mdi), mdi_signals [REMOVE_VIEW], 0, view, &ret); - - if (ret == FALSE) - { - gedit_debug (DEBUG_MDI, "END1"); - - return FALSE; - } - - was_active_window = (view == mdi->priv->active_view); - - child = bonobo_mdi_get_child_from_view (view); - window = bonobo_mdi_get_window_from_view (view); - - book = get_book_from_window (window); - g_return_val_if_fail (book != NULL, TRUE); - - if (g_list_length (GTK_NOTEBOOK (book)->children) == 1) - app_set_view (mdi, window, NULL); - - bonobo_mdi_child_remove_view (child, view); - - pn = gtk_notebook_page_num (GTK_NOTEBOOK (book), view); - gtk_notebook_remove_page (GTK_NOTEBOOK (book), pn); - - if (GTK_NOTEBOOK (book)->cur_page == NULL) - { - if ((g_list_length (mdi->priv->windows) > 1) || - (mdi->priv->registered != NULL)) - { - gedit_debug (DEBUG_VIEW, "Destroy window"); - - /* if this is NOT the last toplevel or a registered object - exists, destroy the toplevel */ - mdi->priv->windows = g_list_remove (mdi->priv->windows, window); - gtk_widget_destroy (GTK_WIDGET (window)); - - if (mdi->priv->active_window && was_active_window) - mdi->priv->active_view = bonobo_mdi_get_view_from_window ( - mdi, - mdi->priv->active_window); - } - } - else - { - pn = gtk_notebook_get_current_page (GTK_NOTEBOOK (book)); - app_set_view (mdi, window, gtk_notebook_get_nth_page (GTK_NOTEBOOK (book), pn)); - } - - - gedit_debug (DEBUG_MDI, "END2"); - - return TRUE; -} - -static void -child_name_changed (BonoboMDIChild *mdi_child, gchar* old_name, BonoboMDI *mdi) -{ - bonobo_mdi_update_child (mdi, mdi_child); -} - -/** - * bonobo_mdi_add_child: - * @mdi: A pointer to a BonoboMDI object. - * @child: A pointer to a BonoboMDIChild to add to the MDI. - * - * Description: - * Adds a new child to the MDI. No views are added: this has to be done with - * a call to bonobo_mdi_add_view. - * First an "add_child" signal is emitted to the MDI with a pointer to the - * child as its parameter. The child is added to the MDI only if the signal - * handler (if it exists) returns %TRUE. If the handler returns %FALSE, the - * child is not added to the MDI. - * - * Return value: - * %TRUE if the child was added successfully and %FALSE otherwise. - **/ -gint -bonobo_mdi_add_child (BonoboMDI *mdi, BonoboMDIChild *child) -{ - gint ret = TRUE; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - g_return_val_if_fail (child != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE); - - g_signal_emit (G_OBJECT (mdi), mdi_signals [ADD_CHILD], 0, child, &ret); - - if (ret == FALSE) - { - gedit_debug (DEBUG_MDI, "END1"); - - return FALSE; - } - - bonobo_mdi_child_set_parent (child, G_OBJECT (mdi)); - - child_list_menu_remove_all (mdi); - - mdi->priv->children = g_list_append (mdi->priv->children, child); - - g_signal_connect (G_OBJECT (child), "name_changed", - G_CALLBACK (child_name_changed), mdi); - - child_list_menu_create_all (mdi); - - g_object_set_data (G_OBJECT (child), BONOBO_MDI_KEY, mdi); - - gedit_debug (DEBUG_MDI, "END2"); - - return TRUE; -} - -/** - * bonobo_mdi_remove_child: - * @mdi: A pointer to a BonoboMDI object. - * @child: Child to remove. - * @force: If TRUE, the "remove_child" signal is not emitted - * - * Description: - * Removes a child and all of its views from the MDI. - * A "remove_child" signal is emitted to the MDI with @child as its parameter - * before actually removing the child. The child is removed only if the signal - * handler (if it exists and the @force is set to %FALSE) returns %TRUE. - * - * Return value: - * %TRUE if the removal was successful and %FALSE otherwise. - **/ -gint -bonobo_mdi_remove_child (BonoboMDI *mdi, BonoboMDIChild *child, gint force) -{ - gint ret = TRUE; - GList *view_node; - GtkWidget *view; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - g_return_val_if_fail (child != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI_CHILD (child), FALSE); - - /* if force is set to TRUE, don't call the remove_child handler (ie there is no way for the - user to stop removal of the child) */ - - if (!force) - g_signal_emit (G_OBJECT (mdi), mdi_signals [REMOVE_CHILD], 0, child, &ret); - - if (ret == FALSE) - { - gedit_debug (DEBUG_MDI, "END1"); - - return FALSE; - } - - view_node = bonobo_mdi_child_get_views (child); - - while (view_node) - { - view = GTK_WIDGET (view_node->data); - view_node = view_node->next; - bonobo_mdi_remove_view (mdi, GTK_WIDGET (view), TRUE); - } - - child_list_menu_remove_all (mdi); - - mdi->priv->children = g_list_remove (mdi->priv->children, child); - - child_list_menu_create_all (mdi); - - if (child == mdi->priv->active_child) - mdi->priv->active_child = NULL; - - bonobo_mdi_child_set_parent (child, NULL); - - g_signal_handlers_disconnect_by_func (G_OBJECT (child), G_CALLBACK (child_name_changed), mdi); - - g_object_unref (G_OBJECT (child)); - - gedit_debug (DEBUG_MDI, "END2"); - - return TRUE; -} - -/** - * bonobo_mdi_remove_all: - * @mdi: A pointer to a BonoboMDI object. - * @force: If TRUE, the "remove_child" signal is not emitted - * - * Description: - * Removes all children and all views from the MDI. - * A "remove_child" signal is emitted to the MDI for each child before - * actually trying to remove any. If signal handlers for all children (if - * they exist and the @force is set to %FALSE) return %TRUE, all children - * and their views are removed and none otherwise. - * - * Return value: - * %TRUE if the removal was successful and %FALSE otherwise. - **/ -gint -bonobo_mdi_remove_all (BonoboMDI *mdi, gint force) -{ - GList *child_node; - gint handler_ret = TRUE; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - - /* first check if removal of any child will be prevented by the - remove_child signal handler */ - if (!force) - { - child_node = mdi->priv->children; - while (child_node) - { - g_signal_emit (G_OBJECT (mdi), - mdi_signals [REMOVE_CHILD], - 0, - child_node->data, - &handler_ret); - - /* if any of the children may not be removed, none will be */ - if (handler_ret == FALSE) - { - gedit_debug (DEBUG_MDI, "END1"); - - return FALSE; - } - - child_node = child_node->next; - } - } - - /* remove all the children with force arg set to true so that remove_child - handlers are not called again */ - while (mdi->priv->children) - bonobo_mdi_remove_child (mdi, BONOBO_MDI_CHILD (mdi->priv->children->data), TRUE); - - gedit_debug (DEBUG_MDI, "END2"); - - return TRUE; -} - -/** - * bonobo_mdi_open_toplevel: - * @mdi: A pointer to a BonoboMDI object. - * @window_role: X window role to use for the window, for session-management - * purposes. If this is %NULL, a unique role string will be automatically - * generated. - * - * Description: - * Opens a new toplevel window. This is usually used only for opening - * the initial window on startup (just before calling gtkmain()) if no - * windows were open because a session was restored or children were added - * because of command line args). - **/ -void -bonobo_mdi_open_toplevel (BonoboMDI *mdi, const char *window_role) -{ - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (mdi != NULL); - g_return_if_fail (BONOBO_IS_MDI (mdi)); - - app_clone (mdi, mdi->priv->active_window, window_role); - - book_create (mdi); - - gtk_widget_show (GTK_WIDGET (mdi->priv->active_window)); - - gedit_debug (DEBUG_MDI, "END1"); -} - -/** - * bonobo_mdi_update_child: - * @mdi: A pointer to a BonoboMDI object. - * @child: Child to update. - * - * Description: - * Updates all notebook labels of @child's views and their window titles - * after its name changes. It is not required if bonobo_mdi_child_set_name() - * is used for setting the child's name. - **/ -static void -bonobo_mdi_update_child (BonoboMDI *mdi, BonoboMDIChild *child) -{ - GtkWidget *view, *title; - GList *view_node; - GList *win_node; - gchar* child_name, *path, *path_cmd, *tip, *escaped_name; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (mdi != NULL); - g_return_if_fail (BONOBO_IS_MDI (mdi)); - g_return_if_fail (child != NULL); - g_return_if_fail (BONOBO_IS_MDI_CHILD (child)); - - view_node = bonobo_mdi_child_get_views (child); - - while (view_node) - { - view = GTK_WIDGET (view_node->data); - - title = child_set_label (child, NULL); - - gtk_notebook_set_tab_label (GTK_NOTEBOOK (view->parent), view, title); - - view_node = g_list_next (view_node); - } - - /* Update child list menus */ - if(mdi->priv->child_list_path == NULL) - { - gedit_debug (DEBUG_MDI, "END1"); - - return; - } - - win_node = mdi->priv->windows; - - child_name = bonobo_mdi_child_get_name (child); - escaped_name = escape_underscores (child_name); - path = g_strdup_printf ("%sChild_%p", mdi->priv->child_list_path, child); - path_cmd = g_strdup_printf ("/commands/Child_%p", child); - tip = g_strdup_printf (_("Activate %s"), child_name); - - while (win_node) - { - BonoboUIComponent *ui_component; - - ui_component = BONOBO_UI_COMPONENT ( - g_object_get_data (G_OBJECT (win_node->data), UI_COMPONENT_KEY)); - - bonobo_ui_component_set_prop (ui_component, path, "label", escaped_name, NULL); - bonobo_ui_component_set_prop (ui_component, path, "tip", tip, NULL); - - win_node = g_list_next (win_node); - } - - g_free (escaped_name); - g_free (path); - g_free (path_cmd); - g_free (tip); - g_free (child_name); - - gedit_debug (DEBUG_MDI, "END2"); -} - -/** - * bonobo_mdi_find_child: - * @mdi: A pointer to a BonoboMDI object. - * @name: A string with a name of the child to find. - * - * Description: - * Finds a child named @name. - * - * Return value: - * A pointer to the BonoboMDIChild object if the child was found and NULL - * otherwise. - **/ -BonoboMDIChild * -bonobo_mdi_find_child (BonoboMDI *mdi, const gchar *name) -{ - GList *child_node; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, NULL); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL); - - child_node = mdi->priv->children; - while (child_node) - { - gchar* child_name = bonobo_mdi_child_get_name (BONOBO_MDI_CHILD (child_node->data)); - - if (strcmp (child_name, name) == 0) - { - g_free (child_name); - - gedit_debug (DEBUG_MDI, "END1"); - - return BONOBO_MDI_CHILD (child_node->data); - } - - g_free (child_name); - - child_node = g_list_next (child_node); - } - - gedit_debug (DEBUG_MDI, "END2"); - - return NULL; -} - -/** - * bonobo_mdi_get_active_child: - * @mdi: A pointer to a BonoboMDI object. - * - * Description: - * Returns a pointer to the active BonoboMDIChild object. - * - * Return value: - * A pointer to the active BonoboMDIChild object. %NULL, if there is none. - **/ -BonoboMDIChild * -bonobo_mdi_get_active_child (BonoboMDI *mdi) -{ - g_return_val_if_fail (mdi != NULL, NULL); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL); - - if (mdi->priv->active_view) - return (bonobo_mdi_get_child_from_view (mdi->priv->active_view)); - - return NULL; -} - -/** - * bonobo_mdi_get_active_view: - * @mdi: A pointer to a BonoboMDI object. - * - * Description: - * Returns a pointer to the active view (the one with the focus). - * - * Return value: - * A pointer to a GtkWidget *. - **/ -GtkWidget * -bonobo_mdi_get_active_view (BonoboMDI *mdi) -{ - g_return_val_if_fail (mdi != NULL, NULL); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL); - - return mdi->priv->active_view; -} - -/** - * bonobo_mdi_get_active_window: - * @mdi: A pointer to a BonoboMDI object. - * - * Description: - * Returns a pointer to the toplevel window containing the active view. - * - * Return value: - * A pointer to a BonoboWindow that has the focus. - **/ -BonoboWindow * -bonobo_mdi_get_active_window (BonoboMDI *mdi) -{ - g_return_val_if_fail (mdi != NULL, NULL); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL); - - return mdi->priv->active_window; -} - -void -bonobo_mdi_set_ui_template (BonoboMDI *mdi, const gchar *xml, BonoboUIVerb verbs[]) -{ - g_return_if_fail (mdi != NULL); - g_return_if_fail (BONOBO_IS_MDI (mdi)); - g_return_if_fail (xml != NULL); - - if (mdi->priv->ui_xml != NULL) - g_free (mdi->priv->ui_xml); - - mdi->priv->ui_xml = g_strdup (xml); - - /* FIXME */ - mdi->priv->verbs = verbs; -} - -void -bonobo_mdi_set_ui_template_file (BonoboMDI *mdi, const gchar *file_name, BonoboUIVerb verbs[]) -{ - g_return_if_fail (mdi != NULL); - g_return_if_fail (BONOBO_IS_MDI (mdi)); - g_return_if_fail (file_name != NULL); - - if (mdi->priv->ui_file_name != NULL) - g_free (mdi->priv->ui_file_name); - - mdi->priv->ui_file_name = g_strdup (file_name); - - /* FIXME */ - mdi->priv->verbs = verbs; -} - -/** - * bonobo_mdi_set_child_list_path: - * @mdi: A pointer to a BonoboMDI object. - * @path: A menu path where the child list menu should be inserted - * - * Description: - * Sets the position for insertion of menu items used to activate the MDI - * children that were added to the MDI. See gnome_app_find_menu_pos for - * details on menu paths. If the path is not set or set to %NULL, these menu - * items aren't going to be inserted in the MDI menu structure. Note that if - * you want all menu items to be inserted in their own submenu, you have to - * create that submenu (and leave it empty, of course). - **/ -void -bonobo_mdi_set_child_list_path (BonoboMDI *mdi, const gchar *path) -{ - g_return_if_fail (mdi != NULL); - g_return_if_fail (BONOBO_IS_MDI (mdi)); - - if (mdi->priv->child_list_path) - g_free (mdi->priv->child_list_path); - - mdi->priv->child_list_path = g_strdup (path); -} - -/** - * bonobo_mdi_register: - * @mdi: A pointer to a BonoboMDI object. - * @object: Object to register. - * - * Description: - * Registers GObject @object with MDI. - * This is mostly intended for applications that open other windows besides - * those opened by the MDI and want to continue to run even when no MDI - * windows exist (an example of this would be GIMP's window with tools, if - * the pictures were MDI children). As long as there is an object registered - * with the MDI, the MDI will not destroy itself when the last of its windows - * is closed. If no objects are registered, closing the last MDI window - * results in MDI being destroyed. - **/ -void -bonobo_mdi_register (BonoboMDI *mdi, GObject *object) -{ - if (!g_slist_find (mdi->priv->registered, object)) - mdi->priv->registered = g_slist_append (mdi->priv->registered, object); -} - -/** - * bonobo_mdi_unregister: - * @mdi: A pointer to a BonoboMDI object. - * @object: Object to unregister. - * - * Description: - * Removes GObject @object from the list of registered objects. - **/ -void -bonobo_mdi_unregister (BonoboMDI *mdi, GObject *object) -{ - mdi->priv->registered = g_slist_remove (mdi->priv->registered, object); -} - -/** - * bonobo_mdi_get_child_from_view: - * @view: A pointer to a GtkWidget. - * - * Description: - * Returns a child that @view is a view of. - * - * Return value: - * A pointer to the BonoboMDIChild the view belongs to. - **/ -BonoboMDIChild * -bonobo_mdi_get_child_from_view (GtkWidget *view) -{ - return BONOBO_MDI_CHILD (g_object_get_data (G_OBJECT(view), BONOBO_MDI_CHILD_KEY)); -} - -/** - * bonobo_mdi_get_window_from_view: - * @view: A pointer to a GtkWidget. - * - * Description: - * Returns the toplevel window for this view. - * - * Return value: - * A pointer to the BonoboWindow containg the specified view. - **/ -BonoboWindow * -bonobo_mdi_get_window_from_view (GtkWidget *view) -{ - return BONOBO_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))); -} - -/** - * bonobo_mdi_get_view_from_window: - * @mdi: A pointer to a BonoboMDI object. - * @win: A pointer to a BonoboWindow widget. - * - * Description: - * Returns the pointer to the view in the MDI toplevel window @win. - * If the mode is set to %GNOME_MDI_NOTEBOOK, the view in the current - * page is returned. - * - * Return value: - * A pointer to a view. - **/ -GtkWidget * -bonobo_mdi_get_view_from_window (BonoboMDI *mdi, BonoboWindow *win) -{ - GtkWidget *book; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (mdi != NULL, NULL); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), NULL); - g_return_val_if_fail (win != NULL, NULL); - g_return_val_if_fail (BONOBO_IS_WINDOW (win), NULL); - - book = get_book_from_window (win); - g_return_val_if_fail (book != NULL, NULL); - - if (GTK_NOTEBOOK (book)->cur_page) - { - int cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (book)); - - gedit_debug (DEBUG_MDI, "END1"); - - return gtk_notebook_get_nth_page (GTK_NOTEBOOK (book), cur_page); - } - else - { - gedit_debug (DEBUG_MDI, "END2"); - - return NULL; - } -} - -void -bonobo_mdi_construct (BonoboMDI *mdi, const gchar* name, const gchar* title, - gint default_window_width, gint default_window_height) -{ - g_return_if_fail (mdi->priv->mdi_name == NULL); - g_return_if_fail (mdi->priv->title == NULL); - - g_return_if_fail (name != NULL); - g_return_if_fail (title != NULL); - - mdi->priv->mdi_name = g_strdup (name); - mdi->priv->title = g_strdup (title); - - mdi->priv->default_window_width = default_window_width; - mdi->priv->default_window_height = default_window_height; - -} - -GList * -bonobo_mdi_get_children (BonoboMDI *mdi) -{ - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - - return mdi->priv->children; -} - -GList * -bonobo_mdi_get_windows (BonoboMDI *mdi) -{ - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - - return mdi->priv->windows; -} - - - -BonoboUIComponent* -bonobo_mdi_get_ui_component_from_window (BonoboWindow* win) -{ - return BONOBO_UI_COMPONENT ( - g_object_get_data (G_OBJECT (win), UI_COMPONENT_KEY)); -} - -const BonoboMDIWindowInfo * -bonobo_mdi_get_window_info (BonoboWindow *win) -{ - return (const BonoboMDIWindowInfo *) - g_object_get_data (G_OBJECT (win), WINDOW_INFO_KEY); -} - -/** - * bonobo_mdi_set_restoring_state: - * @mdi: A pointer to an MDI object. - * @restoring_state: Whether the state is being restored. - * - * Sets whether the MDI object is being restored to a known state. - **/ -void -bonobo_mdi_set_restoring_state (BonoboMDI *mdi, gboolean restoring_state) -{ - BonoboMDIPrivate *priv; - - g_return_if_fail (mdi != NULL); - g_return_if_fail (BONOBO_IS_MDI (mdi)); - - priv = mdi->priv; - - g_return_if_fail (priv->restoring_state && restoring_state); - g_return_if_fail (!priv->restoring_state && !restoring_state); - - priv->restoring_state = restoring_state ? TRUE : FALSE; -} - -/** - * bonobo_mdi_get_restoring_state: - * @mdi: A pointer to an MDI object. - * - * Queries whether an MDI object is having its state restored. - * - * Return value: TRUE if the MDI object is being restored, FALSE otherwise. - **/ -gboolean -bonobo_mdi_get_restoring_state (BonoboMDI *mdi) -{ - BonoboMDIPrivate *priv; - - g_return_val_if_fail (mdi != NULL, FALSE); - g_return_val_if_fail (BONOBO_IS_MDI (mdi), FALSE); - - priv = mdi->priv; - return priv->restoring_state; -} diff --git a/gedit/bonobo-mdi.h b/gedit/bonobo-mdi.h deleted file mode 100644 index 8e8d49905..000000000 --- a/gedit/bonobo-mdi.h +++ /dev/null @@ -1,208 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * bonobo-mdi.h - definition of a BonoboMDI object - * - * Copyright (C) 2001-2002 Free Software Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Paolo Maggi - */ - -/* - * Modified by the gedit Team, 2001-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef _BONOBO_MDI_H_ -#define _BONOBO_MDI_H_ - -#include <gtk/gtk.h> -#include <bonobo/bonobo-window.h> -#include <bonobo/bonobo-ui-component.h> - - -#include "bonobo-mdi-child.h" - -#define BONOBO_TYPE_MDI (bonobo_mdi_get_type ()) -#define BONOBO_MDI(obj) (GTK_CHECK_CAST ((obj), BONOBO_TYPE_MDI, BonoboMDI)) -#define BONOBO_MDI_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), BONOBO_TYPE_MDI, BonoboMDIClass)) -#define BONOBO_IS_MDI(obj) (GTK_CHECK_TYPE ((obj), BONOBO_TYPE_MDI)) -#define BONOBO_IS_MDI_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), BONOBO_TYPE_MDI)) -#define BONOBO_MDI_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), BONOBO_TYPE_MDI, BonoboMDIClass)) - -typedef struct _BonoboMDIPrivate BonoboMDIPrivate; - -typedef struct { - GObject object; - - BonoboMDIPrivate *priv; -} BonoboMDI; - -typedef struct { - GObjectClass parent_class; - - /* Signals */ - gboolean (*add_child) (BonoboMDI *mdi, BonoboMDIChild *child); - gboolean (*remove_child) (BonoboMDI *mdi, BonoboMDIChild *child); - gboolean (*add_view) (BonoboMDI *mdi, GtkWidget *view); - gboolean (*remove_view) (BonoboMDI *mdi, GtkWidget *view); - void (*child_changed) (BonoboMDI *mdi, BonoboMDIChild *child); - void (*view_changed) (BonoboMDI *mdi, GtkWidget *view); - void (*top_window_created) (BonoboMDI *mdi, BonoboWindow *window); - void (*top_window_destroy) (BonoboMDI *mdi, BonoboWindow *window); - void (*all_windows_destroyed)(BonoboMDI *mdi); -} BonoboMDIClass; - -typedef struct _BonoboMDIWindowInfo BonoboMDIWindowInfo; - -struct _BonoboMDIWindowInfo { - gint width; - gint height; - - GdkWindowState state; -}; - -/* - * description of BonoboMDI signals: - * - * gboolean add_child(BonoboMDI *, BonoboMDIChild *) - * gboolean add_view(BonoboMDI *, GtkWidget *) - * are called before actually adding a mdi_child or a view to the MDI. if the handler returns - * TRUE, the action proceeds otherwise the mdi_child or view are not added. - * - * gboolean remove_child(BonoboMDI *, BonoboMDIChild *) - * gboolean remove_view(BonoboMDI *, GtkWidget *) - * are called before removing mdi_child or view. the handler should return true if the object - * is to be removed from MDI - * - * void child_changed(BonoboMDI *, BonoboMDIChild *) - * gets called each time when active child is changed with the second argument - * pointing to the old child. mdi->active_view and mdi->active_child still already - * hold the new values - * - * void view_changed(BonoboMDI *, GtkWidget *) - * is emitted whenever a view is changed, regardless of it being the view of the same child as - * the old view or not. the second argument points to the old view, mdi->active_view and - * mdi->active_child hold the new values. if the child has also been changed, this signal is - * emitted after the child_changed signal. - * - * void top_window_created(BonoboMDI *, BonoboWindow *) - * is called with each newly created BonoboWindow to allow the MDI user to customize it (add a - * statusbar, toolbars or menubar if the method with ui templates is not sufficient, - * etc.). - * no contents may be set since BonoboMDI uses them for storing either a view of a child - * or a notebook - */ - -GType bonobo_mdi_get_type (void); - -GObject *bonobo_mdi_new (const gchar *mdi_name, - const gchar *title, - gint default_window_width, - gint default_window_height); - -void bonobo_mdi_construct (BonoboMDI *mdi, - const gchar *name, - const gchar *title, - gint default_window_width, - gint default_window_height); - -/* setting the ui template*/ -void bonobo_mdi_set_ui_template (BonoboMDI *mdi, - const gchar *xml, - BonoboUIVerb verbs[]); -void bonobo_mdi_set_ui_template_file (BonoboMDI *mdi, - const gchar *file_name, - BonoboUIVerb verbs[]); - -void bonobo_mdi_set_child_list_path (BonoboMDI *mdi, - const gchar *path); - -/* manipulating views */ -gboolean bonobo_mdi_add_view (BonoboMDI *mdi, - BonoboMDIChild *child); -gboolean bonobo_mdi_add_toplevel_view (BonoboMDI *mdi, - BonoboMDIChild *child, - const char *window_role); -gboolean bonobo_mdi_remove_view (BonoboMDI *mdi, - GtkWidget *view, - gboolean force); - -GtkWidget *bonobo_mdi_get_active_view (BonoboMDI *mdi); -void bonobo_mdi_set_active_view (BonoboMDI *mdi, - GtkWidget *view); - -/* manipulating children */ -gint bonobo_mdi_add_child (BonoboMDI *mdi, - BonoboMDIChild *child); -gint bonobo_mdi_remove_child (BonoboMDI *mdi, - BonoboMDIChild *child, - gboolean force); -gint bonobo_mdi_remove_all (BonoboMDI *mdi, - gboolean force); - -void bonobo_mdi_open_toplevel (BonoboMDI *mdi, - const char *window_role); - -BonoboMDIChild *bonobo_mdi_get_active_child (BonoboMDI *mdi); -BonoboMDIChild *bonobo_mdi_find_child (BonoboMDI *mdi, - const gchar *name); - -BonoboWindow *bonobo_mdi_get_active_window (BonoboMDI *mdi); - -void bonobo_mdi_set_restoring_state (BonoboMDI *mdi, - gboolean restoring_state); -gboolean bonobo_mdi_get_restoring_state (BonoboMDI *mdi); - -/* - * the following two functions are here to make life easier if an application - * creates objects (like opening a window) that should "keep the application - * alive" even if there are no MDI windows open. any such windows should be - * registered with the MDI: as long as there is a window registered, the MDI - * will not destroy itself (even if the last of its windows is closed). on the - * other hand, closing the last MDI window when no objects are registered - * with the MDI will result in MDI being gtk_object_destroy()ed. - */ -void bonobo_mdi_register (BonoboMDI *mdi, - GObject *object); -void bonobo_mdi_unregister (BonoboMDI *mdi, - GObject *object); - -/* - * convenience functions for retrieveing BonoboMDIChild and BonoboApp - * objects associated with a particular view and for retrieveing the - * visible view of a certain BonoboWindow. - */ -BonoboWindow *bonobo_mdi_get_window_from_view (GtkWidget *view); -BonoboMDIChild *bonobo_mdi_get_child_from_view (GtkWidget *view); -GtkWidget *bonobo_mdi_get_view_from_window (BonoboMDI *mdi, - BonoboWindow *window); - -GList *bonobo_mdi_get_children (BonoboMDI *mdi); -GList *bonobo_mdi_get_windows (BonoboMDI *mdi); - -BonoboUIComponent *bonobo_mdi_get_ui_component_from_window (BonoboWindow *win); - -/* Utility function to generate unique window roles */ -char *bonobo_mdi_generate_window_role (void); - -const BonoboMDIWindowInfo *bonobo_mdi_get_window_info (BonoboWindow *win); - -#endif /* _BONOBO_MDI_H_ */ - - diff --git a/gedit/dialogs/.cvsignore b/gedit/dialogs/.cvsignore deleted file mode 100644 index 2f5b33bde..000000000 --- a/gedit/dialogs/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile.in -Makefile -.deps
\ No newline at end of file diff --git a/gedit/dialogs/Makefile.am b/gedit/dialogs/Makefile.am deleted file mode 100644 index 6a259bef7..000000000 --- a/gedit/dialogs/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -gladedir = $(datadir)/gedit-2/glade/ - -INCLUDES = \ - -I$(top_srcdir)/src \ - $(GEDIT_CFLAGS) \ - -DGNOME_ICONDIR=\""$(datadir)/pixmaps"\" \ - -DGEDIT_GLADEDIR=\""$(datadir)/gedit-2/glade/"\" \ - -DG_DISABLE_DEPRECATED \ - -DGDK_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DGNOME_DISABLE_DEPRECATED - - -noinst_LIBRARIES = libdialogs.a - -libdialogs_a_SOURCES = \ - gedit-dialog-uri.c \ - gedit-dialog-goto-line.c \ - gedit-dialog-replace.c \ - gedit-preferences-dialog.h \ - gedit-preferences-dialog.c \ - gedit-plugin-manager.c \ - gedit-plugin-manager.h \ - gedit-plugin-program-location-dialog.c \ - gnome-print-font-picker.c \ - gnome-print-font-picker.h \ - gnome-print-font-dialog.c \ - gnome-print-font-dialog.h \ - gedit-dialogs.h - -glade_DATA = \ - uri.glade2 \ - goto-line.glade2 \ - replace.glade2 \ - plugin-manager.glade2 \ - gedit-preferences.glade2 \ - program-location-dialog.glade2 - -EXTRA_DIST = $(glade_DATA) - diff --git a/gedit/dialogs/gedit-dialog-goto-line.c b/gedit/dialogs/gedit-dialog-goto-line.c deleted file mode 100644 index bb7ebb6de..000000000 --- a/gedit/dialogs/gedit-dialog-goto-line.c +++ /dev/null @@ -1,242 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-dialog-goto-line.c - * This file is part of gedit - * - * Copyright (C) 2001-2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <glade/glade-xml.h> -#include <libgnome/libgnome.h> - -#include "gedit2.h" -#include "gedit-mdi.h" -#include "gedit-utils.h" -#include "gedit-dialogs.h" -#include "gedit-document.h" -#include "gedit-view.h" -#include "gedit-debug.h" - -typedef struct _GeditDialogGotoLine GeditDialogGotoLine; - -struct _GeditDialogGotoLine { - GtkWidget *dialog; - - GtkWidget *entry; -}; - -static void goto_button_pressed (GeditDialogGotoLine * dialog); -static GeditDialogGotoLine *dialog_goto_line_get_dialog (void); -static void dialog_destroyed (GtkObject *obj, void **dialog_pointer); - -static void -dialog_destroyed (GtkObject *obj, void **dialog_pointer) -{ - gedit_debug (DEBUG_SEARCH, ""); - - if (dialog_pointer != NULL) - { - g_free (*dialog_pointer); - *dialog_pointer = NULL; - } -} - -static void -dialog_response_handler (GtkDialog *dlg, gint res_id, GeditDialogGotoLine *dialog) -{ - gedit_debug (DEBUG_SEARCH, ""); - - switch (res_id) { - case GTK_RESPONSE_OK: - goto_button_pressed (dialog); - break; - - default: - gtk_widget_destroy (dialog->dialog); - } -} - -static void -entry_insert_text (GtkEditable *editable, const char *text, gint length, gint *position) -{ - gunichar c; - const gchar *p; - const gchar *end; - - p = text; - end = text + length; - - while (p != end) { - const gchar *next; - next = g_utf8_next_char (p); - - c = g_utf8_get_char (p); - - if (!g_unichar_isdigit (c)) { - g_signal_stop_emission_by_name (editable, "insert_text"); - break; - } - - p = next; - } -} - -static GeditDialogGotoLine * -dialog_goto_line_get_dialog (void) -{ - static GeditDialogGotoLine *dialog = NULL; - GladeXML *gui; - GtkWindow *window; - GtkWidget *content; - GtkWidget *button; - - gedit_debug (DEBUG_SEARCH, ""); - - if (dialog != NULL) - { - gdk_window_show (dialog->dialog->window); - gdk_window_raise (dialog->dialog->window); - gtk_widget_grab_focus (dialog->dialog); - - return dialog; - } - - gui = glade_xml_new (GEDIT_GLADEDIR "goto-line.glade2", - "goto_line_dialog_content", NULL); - - if (!gui) { - g_warning - ("Could not find goto-line.glade2, reinstall gedit.\n"); - return NULL; - } - - window = GTK_WINDOW (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi))); - - dialog = g_new0 (GeditDialogGotoLine, 1); - - dialog->dialog = gtk_dialog_new_with_buttons (_("Goto line..."), - window, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CANCEL, - NULL); - - g_return_val_if_fail (dialog->dialog != NULL, NULL); - - /* Add Goto Line button */ - button = gedit_button_new_with_stock_image (_("_Goto line"), GTK_STOCK_JUMP_TO); - g_return_val_if_fail (button != NULL, NULL); - - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - - gtk_widget_show (button); - - gtk_dialog_add_action_widget (GTK_DIALOG (dialog->dialog), - button, GTK_RESPONSE_OK); - - content = glade_xml_get_widget (gui, "goto_line_dialog_content"); - - dialog->entry = glade_xml_get_widget (gui, "entry"); - - if (!dialog->entry) { - g_warning ( - _("Could not find the required widgets inside goto-line.glade2.\n")); - g_object_unref (gui); - return NULL; - } - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->dialog)->vbox), - content, FALSE, FALSE, 0); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog), - GTK_RESPONSE_OK); - - g_signal_connect (G_OBJECT (dialog->entry), "insert_text", - G_CALLBACK (entry_insert_text), dialog); - - g_signal_connect(G_OBJECT (dialog->dialog), "destroy", - G_CALLBACK (dialog_destroyed), &dialog); - - g_signal_connect(G_OBJECT (dialog->dialog), "response", - G_CALLBACK (dialog_response_handler), dialog); - - g_object_unref (gui); - - gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE); - - return dialog; -} - - -void -gedit_dialog_goto_line (void) -{ - GeditDialogGotoLine *dialog; - - gedit_debug (DEBUG_SEARCH, ""); - - dialog = dialog_goto_line_get_dialog (); - if (dialog == NULL) { - g_warning ("Could not create the Goto Line dialog"); - return; - } - - gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), - GTK_WINDOW - (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi)))); - - gtk_widget_grab_focus (dialog->entry); - - if (!GTK_WIDGET_VISIBLE (dialog->dialog)) - gtk_widget_show (dialog->dialog); -} - -static void -goto_button_pressed (GeditDialogGotoLine *dialog) -{ - const gchar* text; - GeditView* active_view; - GeditDocument* active_document; - - gedit_debug (DEBUG_SEARCH, ""); - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - active_document = gedit_view_get_document (active_view); - g_return_if_fail (active_document); - - text = gtk_entry_get_text (GTK_ENTRY (dialog->entry)); - - if (text != NULL && text [0] != 0) - { - guint line = MAX (atoi (text)- 1, 0); - gedit_document_goto_line (active_document, line); - gedit_view_scroll_to_cursor (active_view); - gtk_widget_grab_focus (GTK_WIDGET (active_view)); - } -} - diff --git a/gedit/dialogs/gedit-dialog-replace.c b/gedit/dialogs/gedit-dialog-replace.c deleted file mode 100644 index bf4680d77..000000000 --- a/gedit/dialogs/gedit-dialog-replace.c +++ /dev/null @@ -1,741 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-dialog-replace.c - * This file is part of gedit - * - * Copyright (C) 2001 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <glade/glade-xml.h> -#include <libgnome/libgnome.h> - -#include "gedit2.h" -#include "gedit-mdi.h" -#include "gedit-utils.h" -#include "gedit-dialogs.h" -#include "gedit-document.h" -#include "gedit-mdi-child.h" -#include "gedit-view.h" -#include "gedit-debug.h" -#include "gedit-utils.h" - -#define GEDIT_RESPONSE_FIND 101 -#define GEDIT_RESPONSE_REPLACE 102 -#define GEDIT_RESPONSE_REPLACE_ALL 103 - -typedef struct _GeditDialogReplace GeditDialogReplace; -typedef struct _GeditDialogFind GeditDialogFind; - -struct _GeditDialogReplace { - GtkWidget *dialog; - - GtkWidget *search_entry; - GtkWidget *replace_entry; - GtkWidget *replace_hbox; - GtkWidget *case_sensitive; - GtkWidget *beginning; - GtkWidget *cursor; -}; - -struct _GeditDialogFind { - GtkWidget *dialog; - - GtkWidget *search_entry; - GtkWidget *case_sensitive; - GtkWidget *beginning; - GtkWidget *cursor; -}; - -static void dialog_destroyed (GtkObject *obj, void **dialog_pointer); - -static void dialog_find_response_handler (GtkDialog *dlg, gint res_id, GeditDialogFind *find_dialog); - -static void find_dlg_find_button_pressed (GeditDialogFind * dialog); - -static void replace_dlg_find_button_pressed (GeditDialogReplace * dialog); -static void replace_dlg_replace_button_pressed (GeditDialogReplace * dialog); -static void replace_dlg_replace_all_button_pressed (GeditDialogReplace * dialog); - -static GeditDialogReplace *dialog_replace_get_dialog (void); -static GeditDialogFind *dialog_find_get_dialog (void); - -static void -dialog_destroyed (GtkObject *obj, void **dialog_pointer) -{ - gedit_debug (DEBUG_SEARCH, ""); - - if (dialog_pointer != NULL) - { - g_free (*dialog_pointer); - *dialog_pointer = NULL; - } -} - -static void -dialog_replace_response_handler (GtkDialog *dlg, gint res_id, GeditDialogReplace *replace_dialog) -{ - gedit_debug (DEBUG_SEARCH, ""); - - switch (res_id) { - case GEDIT_RESPONSE_FIND: - replace_dlg_find_button_pressed (replace_dialog); - break; - - case GEDIT_RESPONSE_REPLACE: - replace_dlg_replace_button_pressed (replace_dialog); - break; - - case GEDIT_RESPONSE_REPLACE_ALL: - replace_dlg_replace_all_button_pressed (replace_dialog); - break; - default: - gtk_widget_destroy (replace_dialog->dialog); - } -} - -static void -dialog_find_response_handler (GtkDialog *dlg, gint res_id, GeditDialogFind *find_dialog) -{ - gedit_debug (DEBUG_SEARCH, ""); - - switch (res_id) { - case GEDIT_RESPONSE_FIND: - find_dlg_find_button_pressed (find_dialog); - break; - - default: - gtk_widget_destroy (find_dialog->dialog); - } -} - -static GeditDialogReplace * -dialog_replace_get_dialog (void) -{ - static GeditDialogReplace *dialog = NULL; - GladeXML *gui; - GtkWindow *window; - GtkWidget *content; - GtkWidget *button; - - gedit_debug (DEBUG_SEARCH, ""); - - if (dialog != NULL) - { - gdk_window_show (dialog->dialog->window); - gdk_window_raise (dialog->dialog->window); - gtk_widget_grab_focus (dialog->dialog); - - return dialog; - } - - gui = glade_xml_new ( GEDIT_GLADEDIR "replace.glade2", - "replace_dialog_content", NULL); - - if (!gui) { - g_warning - ("Could not find replace.glade2, reinstall gedit.\n"); - return NULL; - } - - window = GTK_WINDOW (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi))); - - dialog = g_new0 (GeditDialogReplace, 1); - - dialog->dialog = gtk_dialog_new_with_buttons (_("Replace"), - window, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL); - - g_return_val_if_fail (dialog->dialog != NULL, NULL); - - /* Add Replace All button */ - gtk_dialog_add_button (GTK_DIALOG (dialog->dialog), - _("Replace _All"), GEDIT_RESPONSE_REPLACE_ALL); - - /* Add Replace button */ - button = gedit_button_new_with_stock_image (_("_Replace"), GTK_STOCK_FIND_AND_REPLACE); - g_return_val_if_fail (button != NULL, NULL); - - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - - gtk_widget_show (button); - - gtk_dialog_add_action_widget (GTK_DIALOG (dialog->dialog), - button, GEDIT_RESPONSE_REPLACE); - - /* Add Find button */ - gtk_dialog_add_button (GTK_DIALOG (dialog->dialog), - GTK_STOCK_FIND, GEDIT_RESPONSE_FIND); - - content = glade_xml_get_widget (gui, "replace_dialog_content"); - dialog->search_entry = glade_xml_get_widget (gui, "search_for_text_entry"); - dialog->replace_entry = glade_xml_get_widget (gui, "replace_with_text_entry"); - dialog->replace_hbox = glade_xml_get_widget (gui, "hbox_replace_with"); - dialog->case_sensitive = glade_xml_get_widget (gui, "case_sensitive"); - dialog->beginning = glade_xml_get_widget (gui, "beginning_radio_button"); - dialog->cursor = glade_xml_get_widget (gui, "cursor_radio_button"); - - if (!content || - !dialog->search_entry || - !dialog->replace_entry || - !dialog->replace_hbox || - !dialog->case_sensitive || - !dialog->cursor || - !dialog->beginning ) - { - g_print - ("Could not find the required widgets inside replace.glade2.\n"); - return NULL; - } - - gtk_widget_show (dialog->replace_hbox); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->dialog)->vbox), - content, FALSE, FALSE, 0); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_FIND); - - g_signal_connect(G_OBJECT (dialog->dialog), "destroy", - G_CALLBACK (dialog_destroyed), &dialog); - - g_signal_connect(G_OBJECT (dialog->dialog), "response", - G_CALLBACK (dialog_replace_response_handler), dialog); - - g_object_unref (G_OBJECT (gui)); - - gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE); - - return dialog; -} - -static GeditDialogFind * -dialog_find_get_dialog (void) -{ - static GeditDialogFind *dialog = NULL; - GladeXML *gui; - GtkWindow *window; - GtkWidget *content; - GtkWidget *replace_hbox; - - gedit_debug (DEBUG_SEARCH, ""); - - if (dialog != NULL) - { - gdk_window_show (dialog->dialog->window); - gdk_window_raise (dialog->dialog->window); - gtk_widget_grab_focus (dialog->dialog); - return dialog; - } - - gui = glade_xml_new (GEDIT_GLADEDIR "replace.glade2", - "replace_dialog_content", NULL); - - if (!gui) { - g_warning - ("Could not find replace.glade2, reinstall gedit.\n"); - return NULL; - } - - window = GTK_WINDOW (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi))); - - dialog = g_new0 (GeditDialogFind, 1); - - dialog->dialog = gtk_dialog_new_with_buttons (_("Find"), - window, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - GTK_STOCK_FIND, - GEDIT_RESPONSE_FIND, - NULL); - - g_return_val_if_fail (dialog->dialog != NULL, NULL); - - content = glade_xml_get_widget (gui, "replace_dialog_content"); - - dialog->search_entry = glade_xml_get_widget (gui, "search_for_text_entry"); - - replace_hbox = glade_xml_get_widget (gui, "hbox_replace_with"); - - dialog->case_sensitive = glade_xml_get_widget (gui, "case_sensitive"); - dialog->beginning = glade_xml_get_widget (gui, "beginning_radio_button"); - dialog->cursor = glade_xml_get_widget (gui, "cursor_radio_button"); - - if (!content || - !dialog->search_entry || - !replace_hbox || - !dialog->case_sensitive || - !dialog->cursor || - !dialog->beginning ) - { - g_print - ("Could not find the required widgets inside replace.glade2.\n"); - return NULL; - } - - gtk_widget_hide (replace_hbox); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->dialog)->vbox), - content, FALSE, FALSE, 0); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_FIND); - - g_signal_connect(G_OBJECT (dialog->dialog), "destroy", - G_CALLBACK (dialog_destroyed), &dialog); - - g_signal_connect(G_OBJECT (dialog->dialog), "response", - G_CALLBACK (dialog_find_response_handler), dialog); - - g_object_unref (G_OBJECT (gui)); - - gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE); - - return dialog; -} - -void -gedit_dialog_find (void) -{ - GeditDialogFind *dialog; - GeditMDIChild *active_child; - GeditDocument *doc; - gchar* last_searched_text; - - gedit_debug (DEBUG_SEARCH, ""); - - dialog = dialog_find_get_dialog (); - if (dialog == NULL) { - g_warning ("Cannot create the Find dialog"); - return; - } - - gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), - GTK_WINDOW - (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi)))); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_child != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - last_searched_text = gedit_document_get_last_searched_text (doc); - if (last_searched_text != NULL) - { - gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), last_searched_text); - g_free (last_searched_text); - } - - gtk_widget_grab_focus (dialog->search_entry); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->beginning), TRUE); - - if (!GTK_WIDGET_VISIBLE (dialog->dialog)) - gtk_widget_show (dialog->dialog); -} - -void -gedit_dialog_replace (void) -{ - GeditDialogReplace *dialog; - GeditMDIChild *active_child; - GeditDocument *doc; - gchar* last_searched_text; - gchar* last_replace_text; - - gedit_debug (DEBUG_SEARCH, ""); - - dialog = dialog_replace_get_dialog (); - if (dialog == NULL) { - g_warning ("Cannot create the Replace dialog"); - return; - } - - gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), - GTK_WINDOW - (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi)))); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_child != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - last_searched_text = gedit_document_get_last_searched_text (doc); - if (last_searched_text != NULL) - { - gtk_entry_set_text (GTK_ENTRY (dialog->search_entry), last_searched_text); - g_free (last_searched_text); - } - - last_replace_text = gedit_document_get_last_replace_text (doc); - if (last_replace_text != NULL) - { - gtk_entry_set_text (GTK_ENTRY (dialog->replace_entry), last_replace_text); - g_free (last_replace_text); - } - - gtk_widget_grab_focus (dialog->search_entry); - - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_REPLACE, FALSE); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->beginning), TRUE); - - if (!GTK_WIDGET_VISIBLE (dialog->dialog)) - gtk_widget_show (dialog->dialog); -} - -static void -find_dlg_find_button_pressed (GeditDialogFind *dialog) -{ - GeditMDIChild *active_child; - GeditView* active_view; - GeditDocument *doc; - const gchar* search_string = NULL; - gboolean from_cursor; - gboolean case_sensitive; - - gedit_debug (DEBUG_SEARCH, ""); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) == NULL) - return; - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_child != NULL); - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - search_string = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry)); - g_return_if_fail (search_string != NULL); - - if (strlen (search_string) <= 0) - return; - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->beginning))) - from_cursor = FALSE; - else - from_cursor = TRUE; - - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->case_sensitive))) - case_sensitive = TRUE; - else - case_sensitive = FALSE; - - if (!gedit_document_find (doc, search_string, from_cursor, case_sensitive)) - { - GtkWidget *message_dlg; - - message_dlg = gtk_message_dialog_new ( - GTK_WINDOW (dialog->dialog), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("The text \"%s\" was not found."), search_string); - - gtk_dialog_set_default_response (GTK_DIALOG (message_dlg), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (message_dlg), FALSE); - - gtk_dialog_run (GTK_DIALOG (message_dlg)); - gtk_widget_destroy (message_dlg); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->beginning), TRUE); - } - else - { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->cursor), TRUE); - gedit_view_scroll_to_cursor (active_view); - } -} - - -static void -replace_dlg_find_button_pressed (GeditDialogReplace *dialog) -{ - /* This is basically the same as find_dlg_find_button_pressed */ - - GeditMDIChild *active_child; - GeditView* active_view; - GeditDocument *doc; - const gchar* search_string = NULL; - gboolean from_cursor; - gboolean case_sensitive; - - gedit_debug (DEBUG_SEARCH, ""); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) == NULL) - return; - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_child != NULL); - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - search_string = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry)); - g_return_if_fail (search_string != NULL); - - if (strlen (search_string) <= 0) - return; - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->beginning))) - from_cursor = FALSE; - else - from_cursor = TRUE; - - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->case_sensitive))) - case_sensitive = TRUE; - else - case_sensitive = FALSE; - - if (!gedit_document_find (doc, search_string, from_cursor, case_sensitive)) - { - GtkWidget *message_dlg; - - message_dlg = gtk_message_dialog_new ( - GTK_WINDOW (dialog->dialog), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("The text \"%s\" was not found."), search_string); - - gtk_dialog_set_default_response (GTK_DIALOG (message_dlg), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (message_dlg), FALSE); - - gtk_dialog_run (GTK_DIALOG (message_dlg)); - gtk_widget_destroy (message_dlg); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->beginning), TRUE); - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_REPLACE, FALSE); - - } - else - { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->cursor), TRUE); - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_REPLACE, TRUE); - - gedit_view_scroll_to_cursor (active_view); - } -} - -static void -replace_dlg_replace_button_pressed (GeditDialogReplace *dialog) -{ - GeditMDIChild *active_child; - GeditView* active_view; - GeditDocument *doc; - const gchar* search_string = NULL; - const gchar* replace_string = NULL; - gchar* selected_text = NULL; - gchar *converted_search_string = NULL; - gboolean case_sensitive; - - gedit_debug (DEBUG_SEARCH, ""); - - g_return_if_fail (dialog != NULL); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) == NULL) - { - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_REPLACE, FALSE); - return; - } - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_child != NULL); - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - search_string = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry)); - replace_string = gtk_entry_get_text (GTK_ENTRY (dialog->replace_entry)); - - g_return_if_fail (search_string); - g_return_if_fail (replace_string); - - if (strlen (search_string) <= 0) - return; - - selected_text = gedit_document_get_selected_text (doc, NULL, NULL); - - gedit_debug (DEBUG_SEARCH, "Sel text: %s", selected_text ? selected_text : "NULL"); - gedit_debug (DEBUG_SEARCH, "Search string: %s", search_string ? search_string : "NULL"); - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->case_sensitive))) - case_sensitive = TRUE; - else - case_sensitive = FALSE; - - converted_search_string = gedit_utils_convert_search_text (search_string); - - if ((selected_text == NULL) || - (case_sensitive && (strcmp (selected_text, converted_search_string) - !=0)) || (!case_sensitive && !g_utf8_caselessnmatch (selected_text, search_string, - strlen (selected_text), - strlen (search_string)) != 0)) - { - gedit_debug (DEBUG_SEARCH, "selected_text (%s) != search_string (%s)", - selected_text ? selected_text : "NULL", - search_string ? search_string : "NULL"); - - if (selected_text != NULL) - g_free (selected_text); - - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_REPLACE, FALSE); - - replace_dlg_find_button_pressed (dialog); - - return; - } - - g_free (selected_text); - g_free (converted_search_string); - - gedit_debug (DEBUG_SEARCH, "Replace string: %s", replace_string ? replace_string : "NULL"); - - gedit_document_replace_selected_text (doc, replace_string); - - gedit_debug (DEBUG_SEARCH, "Replaced"); - - /* go ahead and find the next one */ - if (!gedit_document_find (doc, search_string, TRUE, case_sensitive)) - { - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->beginning), TRUE); - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_REPLACE, FALSE); - } - else - { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->cursor), TRUE); - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog->dialog), - GEDIT_RESPONSE_REPLACE, TRUE); - - gedit_view_scroll_to_cursor (active_view); - } - - gedit_debug (DEBUG_SEARCH, "END"); -} - - -static void -replace_dlg_replace_all_button_pressed (GeditDialogReplace *dialog) -{ - GeditMDIChild *active_child; - GeditView* active_view; - GeditDocument *doc; - const gchar* search_string = NULL; - const gchar* replace_string = NULL; - gboolean case_sensitive; - gint replaced_items; - GtkWidget *message_dlg; - - gedit_debug (DEBUG_SEARCH, ""); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) == NULL) - return; - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_child != NULL); - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - search_string = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry)); - replace_string = gtk_entry_get_text (GTK_ENTRY (dialog->replace_entry)); - - g_return_if_fail (search_string); - g_return_if_fail (replace_string); - - if (strlen (search_string) <= 0) - return; - - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->case_sensitive))) - case_sensitive = TRUE; - else - case_sensitive = FALSE; - - replaced_items = gedit_document_replace_all (doc, search_string, replace_string, case_sensitive); - - if (replaced_items <= 0) - { - message_dlg = gtk_message_dialog_new ( - GTK_WINDOW (dialog->dialog), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("The text \"%s\" was not found."), search_string); - } - else - { - message_dlg = gtk_message_dialog_new ( - GTK_WINDOW (dialog->dialog), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Found and replaced %d occurences."), replaced_items); - } - - gtk_dialog_set_default_response (GTK_DIALOG (message_dlg), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (message_dlg), FALSE); - - gtk_dialog_run (GTK_DIALOG (message_dlg)); - gtk_widget_destroy (message_dlg); -} - diff --git a/gedit/dialogs/gedit-dialog-uri.c b/gedit/dialogs/gedit-dialog-uri.c deleted file mode 100644 index a10ba9a4c..000000000 --- a/gedit/dialogs/gedit-dialog-uri.c +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-dialog-uri.c - * This file is part of gedit - * - * Copyright (C) 2001 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glade/glade-xml.h> -#include <libgnome/gnome-help.h> - -#include "gedit2.h" -#include "gedit-mdi.h" -#include "gedit-utils.h" -#include "gedit-file.h" -#include "gedit-dialogs.h" - -typedef struct _GeditDialogOpenUri GeditDialogOpenUri; - -struct _GeditDialogOpenUri { - GtkWidget *dialog; - - GtkWidget *uri; - GtkWidget *uri_list; -}; - -static void open_button_pressed (GeditDialogOpenUri * dialog); -static void help_button_pressed (GeditDialogOpenUri * dialog); -static GeditDialogOpenUri *dialog_open_uri_get_dialog (void); -static void dialog_open_uri_list_activate (GtkWidget *uri_list, - GeditDialogOpenUri *dlg); - -static void -dialog_open_uri_list_activate (GtkWidget *uri_list, GeditDialogOpenUri *dlg) -{ - g_return_if_fail (dlg != NULL); - gtk_dialog_response (GTK_DIALOG (dlg->dialog), GTK_RESPONSE_OK); -} - -static GeditDialogOpenUri * -dialog_open_uri_get_dialog (void) -{ - static GeditDialogOpenUri *dialog = NULL; - GladeXML *gui; - GtkWindow *window; - GtkWidget *content; - - if (dialog != NULL) - return dialog; - - gui = glade_xml_new (GEDIT_GLADEDIR "uri.glade2", - "open_uri_dialog_content", NULL); - - if (!gui) { - g_warning - ("Could not find uri.glade2, reinstall gedit.\n"); - return NULL; - } - - window = GTK_WINDOW (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi))); - - dialog = g_new0 (GeditDialogOpenUri, 1); - - dialog->dialog = gtk_dialog_new_with_buttons (_("Open from URI"), - window, - GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, - GTK_RESPONSE_OK, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, - NULL); - - g_return_val_if_fail (dialog->dialog != NULL, NULL); - - content = glade_xml_get_widget (gui, "open_uri_dialog_content"); - - dialog->uri = glade_xml_get_widget (gui, "uri"); - dialog->uri_list = glade_xml_get_widget (gui, "uri_list"); - - if (!dialog->uri || !dialog->uri_list) { - g_print - ("Could not find the required widgets inside uri.glade.\n"); - return NULL; - } - - g_signal_connect (G_OBJECT (dialog->uri_list), "activate", - G_CALLBACK (dialog_open_uri_list_activate), dialog); - - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog->dialog)->vbox), - content, FALSE, FALSE, 0); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog->dialog), - GTK_RESPONSE_OK); - - g_object_unref (gui); - - gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE); - - return dialog; -} - - -void -gedit_dialog_open_uri (void) -{ - GeditDialogOpenUri *dialog; - gint response; - - dialog = dialog_open_uri_get_dialog (); - if (dialog == NULL) { - g_warning ("Could not create the Open URI dialog"); - return; - } - - gtk_widget_grab_focus (dialog->uri); - - gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), - GTK_WINDOW - (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi)))); - - gtk_entry_set_text (GTK_ENTRY (dialog->uri), ""); - - do { - response = gtk_dialog_run (GTK_DIALOG (dialog->dialog)); - - switch (response) { - case GTK_RESPONSE_OK: - open_button_pressed (dialog); - break; - - case GTK_RESPONSE_HELP: - help_button_pressed (dialog); - break; - - default: - gtk_widget_hide (dialog->dialog); - } - - } while (response == GTK_RESPONSE_HELP); -} - -static void -open_button_pressed (GeditDialogOpenUri * dialog) -{ - gchar *file_name = NULL; - - g_return_if_fail (dialog != NULL); - - file_name = - gtk_editable_get_chars (GTK_EDITABLE (dialog->uri), 0, -1); - - gtk_widget_hide (dialog->dialog); - - gedit_file_open_single_uri (file_name); - - g_free (file_name); -} - -static void -help_button_pressed (GeditDialogOpenUri * dialog) -{ - GError *error = NULL; - - gnome_help_display ("gedit.xml", "gedit-open-from-uri", &error); - - if (error != NULL) - { - g_warning (error->message); - - g_error_free (error); - } - -} diff --git a/gedit/dialogs/gedit-dialogs.h b/gedit/dialogs/gedit-dialogs.h deleted file mode 100644 index 96574de85..000000000 --- a/gedit/dialogs/gedit-dialogs.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-dialogs.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_DIALOGS_H__ -#define __GEDIT_DIALOGS_H__ - -#include <gtk/gtkwindow.h> - -void gedit_dialog_goto_line (void); -void gedit_dialog_find (void); -void gedit_dialog_replace (void); - -void gedit_dialog_open_uri (void); - -gchar *gedit_plugin_program_location_dialog (gchar *program_name, - gchar *plugin_name, - GtkWindow *parent); - -#endif /* __GEDIT_DIALOGS_H__ */ diff --git a/gedit/dialogs/gedit-plugin-manager.c b/gedit/dialogs/gedit-plugin-manager.c deleted file mode 100644 index 1a5c63c6d..000000000 --- a/gedit/dialogs/gedit-plugin-manager.c +++ /dev/null @@ -1,553 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-plugin-manager.c - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi and James Willcox - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/libgnome.h> -#include <libgnomeui/libgnomeui.h> -#include <glade/glade-xml.h> - -#include <string.h> - -#include "gedit-plugin-manager.h" - -#include "gedit2.h" -#include "gedit-mdi.h" -#include "gedit-utils.h" -#include "gedit-dialogs.h" -#include "gedit-plugins-engine.h" -#include "gedit-plugin.h" -#include "gedit-debug.h" - -#define PLUGIN_MANAGER_ACTIVE_COLUMN 0 -#define PLUGIN_MANAGER_NAME_COLUMN 1 - -#define PLUGIN_MANAGER_NAME_TITLE _("Plugin") -#define PLUGIN_MANAGER_ACTIVE_TITLE _("Load") - -#define PLUGIN_MANAGER_LOGO "/gedit-plugin-manager.png" - -typedef struct _GeditPluginManager GeditPluginManager; - -struct _GeditPluginManager { - GtkWidget *page; /* a GtkNotebook page */ - - GtkWidget *tree; /* a GtkTreeView, shows plugins */ - GtkWidget *notebook; /* a GtkNotebook, shows info about plugins */ - - GtkWidget *author; /* a GtkLabel, shows the author of the plugin */ - GtkWidget *filename; /* a GtkLabel, shows the filename of the plugin */ - GtkWidget *desc; /* a GtkLabel, shows the description of the plugin */ - GtkWidget *name; /* a GtkLabel, shows the name of the plugin */ - GtkWidget *copyright; /* a GtkLabel, shows the copyright info of the plugin */ - GtkWidget *configure_button; /* a GtkButton,configures a plugin when clicked */ - - const GList *plugins; /* a list of type GeditPlugin */ -}; - -static GeditPluginInfo *plugin_manager_get_selected_plugin (GeditPluginManager *dialog); -static void plugin_manager_toggle_active (GtkTreeIter *iter, GtkTreeModel *model); -static void plugin_manager_toggle_all (GeditPluginManager *dialog); -static void plugin_manager_update_info (GeditPluginManager *dialog, - GeditPluginInfo *info); - -static void plugin_manager_destroyed (GtkObject *obj, void *dialog_pointer); - - -static void -configure_button_cb (GtkWidget *button, gpointer data) -{ - GeditPluginManager *pm = data; - GeditPluginInfo *info; - - gedit_debug (DEBUG_PLUGINS, ""); - - info = plugin_manager_get_selected_plugin (pm); - - g_return_if_fail (info != NULL); - - gedit_debug (DEBUG_PLUGINS, "Configuring: %s\n", info->plugin->name); - - gedit_plugins_engine_configure_plugin (info->plugin, - gtk_widget_get_toplevel (pm->page)); - - gedit_debug (DEBUG_PLUGINS, "Done"); -} - -static void -plugin_manager_view_cell_cb (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) -{ - GeditPluginInfo *info; - const gchar *title; - - /* - gedit_debug (DEBUG_PLUGINS, ""); - */ - - g_return_if_fail (tree_model != NULL); - g_return_if_fail (tree_column != NULL); - - gtk_tree_model_get (tree_model, iter, PLUGIN_MANAGER_NAME_COLUMN, &info, -1); - - if (info == NULL) - return; - - title = gtk_tree_view_column_get_title (tree_column); - - /* FIXME: this string comparison stuff sucks. is there a better way? */ - if (!strcmp (title, PLUGIN_MANAGER_NAME_TITLE)) - g_object_set (G_OBJECT (cell), "text", info->plugin->name, NULL); -} - -static void -active_toggled_cb (GtkCellRendererToggle *cell, - gchar *path_str, - gpointer data) -{ - GeditPluginManager *dialog = (GeditPluginManager *)data; - GtkTreeIter iter; - GtkTreePath *path = gtk_tree_path_new_from_string (path_str); - GtkTreeModel *model; - - gedit_debug (DEBUG_PLUGINS, ""); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree)); - g_return_if_fail (model != NULL); - - /* get toggled iter */ - gtk_tree_model_get_iter (model, &iter, path); - - if (&iter != NULL) { - plugin_manager_toggle_active (&iter, model); - } - - /* clean up */ - gtk_tree_path_free (path); -} - -static void -cursor_changed_cb (GtkTreeView *view, gpointer data) -{ - GeditPluginManager *dialog = data; - GeditPluginInfo *info; - - gedit_debug (DEBUG_PLUGINS, ""); - - info = plugin_manager_get_selected_plugin (dialog); - g_return_if_fail (info != NULL); - - gtk_widget_set_sensitive (GTK_WIDGET (dialog->configure_button), - gedit_plugins_engine_is_a_configurable_plugin (info->plugin)); - - plugin_manager_update_info (dialog, info); -} - -static void -row_activated_cb (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer data) -{ - GeditPluginManager *dialog = data; - GtkTreeIter iter; - GtkTreeModel *model; - - gedit_debug (DEBUG_PLUGINS, ""); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree)); - - g_return_if_fail (model != NULL); - - gtk_tree_model_get_iter (model, &iter, path); - - g_return_if_fail (&iter != NULL); - - plugin_manager_toggle_active (&iter, model); -} - -static void -column_clicked_cb (GtkTreeViewColumn *tree_column, gpointer data) -{ - GeditPluginManager *dialog = data; - - gedit_debug (DEBUG_PLUGINS, ""); - - g_return_if_fail (dialog != NULL); - - plugin_manager_toggle_all (dialog); -} - - -static void -plugin_manager_populate_lists (GeditPluginManager *dialog) -{ - const GList *plugins; - GtkListStore *model; - GtkTreeIter iter; - - gedit_debug (DEBUG_PLUGINS, ""); - - plugins = dialog->plugins; - - model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree))); - - while (plugins) { - GeditPluginInfo *info; - info = (GeditPluginInfo *)plugins->data; - - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, PLUGIN_MANAGER_NAME_COLUMN, info, - PLUGIN_MANAGER_ACTIVE_COLUMN,(info->state == GEDIT_PLUGIN_ACTIVATED), - -1); - - plugins = plugins->next; - } - - if (gtk_tree_model_get_iter_root (GTK_TREE_MODEL (model), &iter)) - { - GtkTreeSelection *selection; - GeditPluginInfo* info; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree)); - g_return_if_fail (selection != NULL); - gtk_tree_selection_select_iter (selection, &iter); - - gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, - PLUGIN_MANAGER_NAME_COLUMN, &info, -1); - - gtk_widget_set_sensitive (GTK_WIDGET (dialog->configure_button), - gedit_plugins_engine_is_a_configurable_plugin (info->plugin)); - - plugin_manager_update_info (dialog, info); - } -} - -static void -plugin_manager_set_active (GtkTreeIter *iter, GtkTreeModel *model, gboolean active) -{ - GeditPluginInfo *info; - - gedit_debug (DEBUG_PLUGINS, ""); - - gtk_tree_model_get (model, iter, PLUGIN_MANAGER_NAME_COLUMN, &info, -1); - - g_return_if_fail (info != NULL); - - if (active) { - /* activate the plugin */ - if (!gedit_plugins_engine_activate_plugin (info->plugin)) { - gedit_debug (DEBUG_PLUGINS, "Could not activate %s.\n", info->plugin->name); - active ^= 1; - } - } - else { - /* deactivate the plugin */ - if (!gedit_plugins_engine_deactivate_plugin (info->plugin)) { - gedit_debug (DEBUG_PLUGINS, "Could not deactivate %s.\n", info->plugin->name); - active ^= 1; - } - } - - /* set new value */ - gtk_list_store_set (GTK_LIST_STORE (model), iter, - PLUGIN_MANAGER_ACTIVE_COLUMN, - (info->state == GEDIT_PLUGIN_ACTIVATED), -1); - -} - -static void -plugin_manager_toggle_active (GtkTreeIter *iter, GtkTreeModel *model) -{ - gboolean active; - - gedit_debug (DEBUG_PLUGINS, ""); - - gtk_tree_model_get (model, iter, PLUGIN_MANAGER_ACTIVE_COLUMN, &active, -1); - - active ^= 1; - - plugin_manager_set_active (iter, model, active); -} - - - -static void -plugin_manager_update_info (GeditPluginManager *dialog, GeditPluginInfo *info) -{ - gchar *t; - gchar *filename; - gchar *author; - gchar *name; - - gedit_debug (DEBUG_PLUGINS, ""); - - /* maybe we should put the full path? It's pretty long.... */ - t = g_path_get_basename (info->plugin->file); - g_return_if_fail (t != NULL); - - filename = g_strdup_printf ("%s: %s", _("Module file name"), t); - author = g_strdup_printf ("%s: %s", _("Author(s)"), info->plugin->author); - name = g_strdup_printf ("%s plugin", info->plugin->name); - - gtk_label_set_text (GTK_LABEL (dialog->desc), info->plugin->desc); - gtk_label_set_text (GTK_LABEL (dialog->author), author); - gtk_label_set_text (GTK_LABEL (dialog->filename), filename); - gtk_label_set_text (GTK_LABEL (dialog->copyright), info->plugin->copyright); - gtk_label_set_text (GTK_LABEL (dialog->name), name); - - g_free (t); - g_free (author); - g_free (filename); - g_free (name); -} - -static GeditPluginInfo * -plugin_manager_get_selected_plugin (GeditPluginManager *dialog) -{ - GeditPluginInfo *info = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreeSelection *selection; - - gedit_debug (DEBUG_PLUGINS, ""); - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree)); - g_return_val_if_fail (model != NULL, NULL); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree)); - g_return_val_if_fail (selection != NULL, NULL); - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - gtk_tree_model_get (model, &iter, PLUGIN_MANAGER_NAME_COLUMN, &info, -1); - } - - return info; -} - - -static void -plugin_manager_toggle_all (GeditPluginManager *dialog) -{ - GtkTreeModel *model; - GtkTreeIter iter; - static gboolean active; - - gedit_debug (DEBUG_PLUGINS, ""); - - active ^= 1; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tree)); - - g_return_if_fail (model != NULL); - - gtk_tree_model_get_iter_root (model, &iter); - - do { - plugin_manager_set_active (&iter, model, active); - } - while (gtk_tree_model_iter_next (model, &iter)); -} - -/* Callback used as the interactive search comparison function */ -static gboolean -name_search_cb (GtkTreeModel *model, - gint column, - const gchar *key, - GtkTreeIter *iter, - gpointer data) -{ - GeditPluginInfo *info; - gchar *normalized_string; - gchar *normalized_key; - gchar *case_normalized_string; - gchar *case_normalized_key; - gint key_len; - gboolean retval; - - gtk_tree_model_get (model, iter, PLUGIN_MANAGER_NAME_COLUMN, &info, -1); - if (!info) - return FALSE; - - normalized_string = g_utf8_normalize (info->plugin->name, -1, G_NORMALIZE_ALL); - normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL); - case_normalized_string = g_utf8_casefold (normalized_string, -1); - case_normalized_key = g_utf8_casefold (normalized_key, -1); - - key_len = strlen (case_normalized_key); - - /* Oddly enough, this callback must return whether to stop the search - * because we found a match, not whether we actually matched. - */ - retval = (strncmp (case_normalized_key, case_normalized_string, key_len) != 0); - - g_free (normalized_key); - g_free (normalized_string); - g_free (case_normalized_key); - g_free (case_normalized_string); - - return retval; -} - -static void -plugin_manager_construct_tree (GeditPluginManager *dialog) -{ - GtkTreeViewColumn *column; - GtkCellRenderer *cell; - GtkListStore *model; - - gedit_debug (DEBUG_PLUGINS, ""); - - model = gtk_list_store_new (2, G_TYPE_BOOLEAN, G_TYPE_POINTER); - gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tree), GTK_TREE_MODEL (model)); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (dialog->tree), TRUE); - gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (dialog->tree), TRUE); - - /* first column */ - cell = gtk_cell_renderer_toggle_new (); - g_signal_connect (G_OBJECT (cell), "toggled", G_CALLBACK (active_toggled_cb), dialog); - column = gtk_tree_view_column_new_with_attributes (PLUGIN_MANAGER_ACTIVE_TITLE, - cell, "active", - PLUGIN_MANAGER_ACTIVE_COLUMN, NULL); - gtk_tree_view_column_set_clickable (column, TRUE); - gtk_tree_view_column_set_resizable (column, TRUE); - g_signal_connect (G_OBJECT (column), "clicked", G_CALLBACK (column_clicked_cb), dialog); - gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tree), column); - - /* the second column */ - cell = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (PLUGIN_MANAGER_NAME_TITLE, cell, NULL); - gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_column_set_cell_data_func (column, cell, plugin_manager_view_cell_cb, - dialog, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tree), column); - - /* Enable search for our non-string column */ - gtk_tree_view_set_search_column (GTK_TREE_VIEW (dialog->tree), PLUGIN_MANAGER_NAME_COLUMN); - gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (dialog->tree), - name_search_cb, - NULL, - NULL); - - g_signal_connect (G_OBJECT (dialog->tree), "cursor_changed", - G_CALLBACK (cursor_changed_cb), dialog); - g_signal_connect (G_OBJECT (dialog->tree), "row_activated", - G_CALLBACK (row_activated_cb), dialog); - - g_object_unref (G_OBJECT (model)); - - gtk_widget_show (dialog->tree); -} - -GtkWidget * -gedit_plugin_manager_get_page (void) -{ - GeditPluginManager *pm = NULL; - GladeXML *gui; - GtkWidget *content; - GtkWidget *viewport; - - gedit_debug (DEBUG_PLUGINS, ""); - - gui = glade_xml_new (GEDIT_GLADEDIR "plugin-manager.glade2", - "plugin_manager_dialog_content", NULL); - - if (!gui) { - g_warning (_("Could not find plugin-manager.glade2, reinstall gedit.\n")); - return NULL; - } - - pm = g_new0 (GeditPluginManager, 1); - - pm->page = gtk_vbox_new (FALSE, 0); - - content = glade_xml_get_widget (gui, "plugin_manager_dialog_content"); - pm->tree = glade_xml_get_widget (gui, "plugin_tree"); - pm->notebook = glade_xml_get_widget (gui, "plugin_notebook"); - pm->desc = glade_xml_get_widget (gui, "desc_label"); - pm->author = glade_xml_get_widget (gui, "author_label"); - pm->filename = glade_xml_get_widget (gui, "file_label"); - pm->name = glade_xml_get_widget (gui, "name_label"); - pm->copyright = glade_xml_get_widget (gui, "copyright_label"); - pm->configure_button = glade_xml_get_widget (gui, "configure_button"); - viewport = glade_xml_get_widget (gui, "plugin_viewport"); - - if (!(content && pm->tree && pm->notebook && pm->desc && - pm->author && pm->filename && pm->configure_button && - viewport && pm->name && pm->copyright)) { - - g_warning (_("Invalid glade file for plugin manager -- not all widgets found.\n")); - g_object_unref (gui); - - return NULL; - } - - /* setup a window of a sane size. */ - gtk_widget_set_size_request (GTK_WIDGET (viewport), 270, 100); - - /* connect something to the "configure" button */ - g_signal_connect (G_OBJECT (pm->configure_button), "clicked", - G_CALLBACK (configure_button_cb), pm); - - plugin_manager_construct_tree (pm); - - gtk_box_pack_start (GTK_BOX (pm->page), - content, TRUE, TRUE, 0); - - g_signal_connect(G_OBJECT (pm->page), "destroy", - G_CALLBACK (plugin_manager_destroyed), pm); - - g_object_unref (gui); - - /* get the list of available plugins (or installed) */ - pm->plugins = gedit_plugins_engine_get_plugins_list (); - - plugin_manager_populate_lists (pm); - - return pm->page; -} - -static void -plugin_manager_destroyed (GtkObject *obj, void *pm_pointer) -{ - gedit_debug (DEBUG_PLUGINS, ""); - - if (pm_pointer != NULL) - g_free (pm_pointer); - -} - - - diff --git a/gedit/dialogs/gedit-plugin-manager.h b/gedit/dialogs/gedit-plugin-manager.h deleted file mode 100644 index caa73084e..000000000 --- a/gedit/dialogs/gedit-plugin-manager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-plugin-manager.h - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_PLUGIN_MANAGER_H__ -#define __GEDIT_PLUGIN_MANAGER_H__ - -#include <gtk/gtkwidget.h> - -GtkWidget *gedit_plugin_manager_get_page (void); - -#endif /* __GEDIT_PLUGIN_MANAGER_H__ */ diff --git a/gedit/dialogs/gedit-plugin-program-location-dialog.c b/gedit/dialogs/gedit-plugin-program-location-dialog.c deleted file mode 100644 index 6147c11d4..000000000 --- a/gedit/dialogs/gedit-plugin-program-location-dialog.c +++ /dev/null @@ -1,199 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-plugin-program-location-dialog.c - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <glade/glade-xml.h> -#include <libgnomeui/libgnomeui.h> -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-help.h> - -#include "gedit-dialogs.h" -#include "gedit-debug.h" - -#define PLUGIN_MANAGER_LOGO "/gedit-plugin-manager.png" - -static void error_dialog (const gchar* str, GtkWindow *parent); - -/* Return a newly allocated string containing the full location - * of program_name - */ -gchar * -gedit_plugin_program_location_dialog (gchar *program_name, gchar *plugin_name, - GtkWindow *parent) -{ - GladeXML *gui; - - GtkWidget *dialog; - GtkWidget *content; - GtkWidget *label; - GtkWidget *logo; - GtkWidget *program_location_entry; - - gchar *str_label; - gchar *program_location; - - gint ret; - - gedit_debug (DEBUG_PLUGINS, ""); - - - gui = glade_xml_new (GEDIT_GLADEDIR "program-location-dialog.glade2", - "dialog_content", NULL); - - if (!gui) { - g_warning - ("Could not find program-location-dialog.glade2, reinstall gedit.\n"); - return NULL; - } - - dialog = gtk_dialog_new_with_buttons (_("Set program location ..."), - parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, - NULL); - - g_return_val_if_fail (dialog != NULL, NULL); - - content = glade_xml_get_widget (gui, "dialog_content"); - program_location_entry = glade_xml_get_widget (gui, "program_location_file_entry"); - label = glade_xml_get_widget (gui, "label"); - logo = glade_xml_get_widget (gui, "logo"); - - g_object_unref (gui); - - if (!content || !program_location_entry || !label || !logo) - { - g_warning (_("Could not find the required widgets inside " - "program-location-dialog.glade2.\n")); - return NULL; - } - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - - str_label = g_strdup_printf(_("The %s plugin uses an external program, " - "called <tt>%s</tt>, to perform its task.\n\n" - "Please, specify the location of the <tt>%s</tt> program."), - plugin_name, program_name, program_name); - - gtk_label_set_markup (GTK_LABEL (label), str_label); - g_free(str_label); - - /* stick the plugin manager logo in there */ - gtk_image_set_from_file (GTK_IMAGE (logo), GNOME_ICONDIR PLUGIN_MANAGER_LOGO); - - program_location = g_find_program_in_path (program_name); - if (program_location != NULL) - { - gnome_file_entry_set_filename (GNOME_FILE_ENTRY (program_location_entry), - program_location); - - g_free (program_location); - } - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - content, FALSE, FALSE, 0); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), - GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - gtk_widget_grab_focus (gnome_file_entry_gtk_entry ( - GNOME_FILE_ENTRY (program_location_entry))); - - do - { - GError *error = NULL; - - program_location = NULL; - - ret = gtk_dialog_run (GTK_DIALOG (dialog)); - - switch (ret) { - case GTK_RESPONSE_OK: - program_location = gnome_file_entry_get_full_path ( - GNOME_FILE_ENTRY (program_location_entry), FALSE); - - if (!g_file_test (program_location, G_FILE_TEST_IS_EXECUTABLE)) - { - error_dialog (_("The selected file is not executable."), - GTK_WINDOW (dialog)); - } - else - gtk_widget_hide (dialog); - - break; - - case GTK_RESPONSE_HELP: - gnome_help_display ("gedit.xml", "gedit-use-plugins", &error); - - if (error != NULL) - { - g_warning (error->message); - - g_error_free (error); - } - - break; - - default: - gtk_widget_hide (dialog); - - } - - } while (GTK_WIDGET_VISIBLE (dialog)); - - gtk_widget_destroy (dialog); - - return program_location; -} - -static void -error_dialog (const gchar* str, GtkWindow *parent) -{ - GtkWidget *message_dlg; - - message_dlg = gtk_message_dialog_new ( - parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - str); - - gtk_dialog_set_default_response (GTK_DIALOG (message_dlg), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (message_dlg), FALSE); - - gtk_dialog_run (GTK_DIALOG (message_dlg)); - gtk_widget_destroy (message_dlg); -} - diff --git a/gedit/dialogs/gedit-preferences-dialog.c b/gedit/dialogs/gedit-preferences-dialog.c deleted file mode 100644 index a5237d112..000000000 --- a/gedit/dialogs/gedit-preferences-dialog.c +++ /dev/null @@ -1,1861 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-preferences-dialog.c - * This file is part of gedit - * - * Copyright (C) 2001 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/libgnome.h> -#include <libgnomeui/libgnomeui.h> - -#include <glade/glade-xml.h> - -#include "bonobo-mdi.h" -#include "gedit-preferences-dialog.h" -#include "gedit-debug.h" -#include "gedit-prefs-manager.h" -#include "gedit-view.h" -#include "gedit-utils.h" -#include "gedit2.h" -#include "gedit-plugin-manager.h" - -#include "gnome-print-font-picker.h" - -/* To be syncronized with gedit-preferences.glade2 */ -#define LOGO 3 -#define FONT_COLORS_SETTINGS 2 -#define SAVE_SETTINGS 4 -#define TABS_SETTINGS 0 -#define UNDO_SETTINGS 1 -#define WRAP_MODE_SETTINGS 5 -#define PRINT_SETTINGS 6 -#define LINE_NUMBERS_SETTINGS 7 -#define PRINT_FONTS_SETTINGS 8 -#define PLUGIN_MANAGER_SETTINGS 9 - -enum -{ - CATEGORY_COLUMN = 0, - PAGE_NUM_COLUMN, - NUM_COLUMNS -}; - -struct _GeditPreferencesDialogPrivate -{ - GtkWidget* categories_tree; - - GtkWidget* notebook; - - GtkTreeModel *categories_tree_model; - - /* Font & Colors page */ - GtkWidget *default_font_checkbutton; - GtkWidget *default_colors_checkbutton; - GtkWidget *fontpicker; - GtkWidget *text_colorpicker; - GtkWidget *background_colorpicker; - GtkWidget *sel_text_colorpicker; - GtkWidget *selection_colorpicker; - GtkWidget *colors_table; - GtkWidget *font_hbox; - - /* Undo page */ - GtkWidget *undo_checkbutton; - GtkWidget *undo_levels_spinbutton; - GtkWidget *undo_levels_label; - - /* Tabs page */ - GtkWidget *tabs_width_spinbutton; - - /* Wrap mode page */ - GtkWidget *wrap_never_radiobutton; - GtkWidget *wrap_word_radiobutton; - GtkWidget *wrap_char_radiobutton; - - /* Save page */ - GtkWidget *backup_copy_checkbutton; - GtkWidget *auto_save_checkbutton; - GtkWidget *auto_save_spinbutton; - GtkWidget *utf8_radiobutton; - GtkWidget *locale_if_possible_radiobutton; - GtkWidget *original_if_possible_radiobutton; - GtkWidget *create_frame; - GtkWidget *create_utf8_radiobutton; - GtkWidget *create_locale_if_possible_radiobutton; - - /* Print/page page */ - GtkWidget *add_header_checkbutton; - GtkWidget *wrap_lines_checkbutton; - GtkWidget *line_numbers_checkbutton; - GtkWidget *line_numbers_spinbutton; - - /* Line numbers page */ - GtkWidget *display_line_numbers_checkbutton; - - /* Print/Fonts page */ - GtkWidget *body_fontpicker; - GtkWidget *headers_fontpicker; - GtkWidget *numbers_fontpicker; - GtkWidget *restore_default_fonts_button; - - /* Plugin/Manager */ - GtkWidget *plugin_manager; - -}; - -typedef struct _CategoriesTreeItem CategoriesTreeItem; - -struct _CategoriesTreeItem -{ - gchar *category; - - CategoriesTreeItem *children; - - gint notebook_page; -}; - -static void gedit_preferences_dialog_class_init (GeditPreferencesDialogClass *klass); -static void gedit_preferences_dialog_init (GeditPreferencesDialog *dlg); -static void gedit_preferences_dialog_finalize (GObject *object); -static void gedit_preferences_dialog_response_handler (GtkDialog *dialog, gint res_id, - GeditPreferencesDialog *dlg); - -static void gedit_preferences_dialog_add_buttons (GeditPreferencesDialog *dlg); - -static GtkWidget* gedit_preferences_dialog_create_categories_tree - (GeditPreferencesDialog *dlg); -static GtkWidget* gedit_preferences_dialog_create_notebook - (GeditPreferencesDialog *dlg); -static GtkTreeModel* gedit_preferences_dialog_create_categories_tree_model (); - -static void gedit_preferences_dialog_categories_tree_selection_cb (GtkTreeSelection *selection, - GeditPreferencesDialog *dlg); -static gboolean gedit_preferences_dialog_setup_font_and_colors_page (GeditPreferencesDialog *dlg, - GladeXML *gui); -static gboolean gedit_preferences_dialog_setup_undo_page (GeditPreferencesDialog *dlg, GladeXML *gui); -static void gedit_preferences_dialog_undo_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg); -static gboolean gedit_preferences_dialog_setup_tabs_page (GeditPreferencesDialog *dlg, GladeXML *gui); -static gboolean gedit_preferences_dialog_setup_logo_page (GeditPreferencesDialog *dlg, GladeXML *gui); -static gboolean gedit_preferences_dialog_setup_wrap_mode_page (GeditPreferencesDialog *dlg, GladeXML *gui); -static void gedit_preferences_dialog_auto_save_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg); -static gboolean gedit_preferences_dialog_setup_save_page (GeditPreferencesDialog *dlg, GladeXML *gui); -static void gedit_preferences_dialog_line_numbers_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg); -static gboolean gedit_preferences_dialog_setup_page_page (GeditPreferencesDialog *dlg, GladeXML *gui); -static gboolean gedit_preferences_dialog_setup_line_numbers_page (GeditPreferencesDialog *dlg, - GladeXML *gui); -static gboolean gedit_preferences_dialog_setup_print_fonts_page (GeditPreferencesDialog *dlg, - GladeXML *gui); -static void gedit_preferences_dialog_print_font_restore_default_button_clicked ( - GtkButton *button, - GeditPreferencesDialog *dlg); -static gboolean gedit_preferences_dialog_selection_init (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - GeditPreferencesDialog *dlg); -static void gedit_preferences_dialog_categories_tree_realize (GtkWidget *widget, - GeditPreferencesDialog *dlg); -static void gedit_preferences_dialog_editor_font_picker_font_set (GnomeFontPicker *gfp, - const gchar *font_name, - GeditPreferencesDialog *dlg); -static void gedit_preferences_dialog_editor_color_picker_color_set (GnomeColorPicker *cp, - guint r, - guint g, - guint b, - guint a, - GeditPreferencesDialog *dlg); -static void gedit_preferences_dialog_wrap_mode_radiobutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg); -static void gedit_preferences_dialog_display_line_numbers_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg); -static gboolean gedit_preferences_dialog_setup_plugin_manager_page (GeditPreferencesDialog *dlg, - GladeXML *gui); - -static gint last_selected_page_num = FONT_COLORS_SETTINGS; -static GtkDialogClass* parent_class = NULL; - -static CategoriesTreeItem editor_behavior [] = -{ - {N_("Font & Colors"), NULL, FONT_COLORS_SETTINGS}, - - {N_("Tabs"), NULL, TABS_SETTINGS}, - {N_("Wrap mode"), NULL, WRAP_MODE_SETTINGS}, - {N_("Line numbers"), NULL , LINE_NUMBERS_SETTINGS}, - - {N_("Save"), NULL, SAVE_SETTINGS }, - {N_("Undo"), NULL, UNDO_SETTINGS}, - - - { NULL } -}; - -static CategoriesTreeItem print [] = -{ - {N_("Page"), NULL, PRINT_SETTINGS}, - - {N_("Fonts"), NULL, PRINT_FONTS_SETTINGS}, - - { NULL } -}; - -static CategoriesTreeItem plugins [] = -{ - {N_("Manager"), NULL, PLUGIN_MANAGER_SETTINGS}, - - { NULL } -}; - - -static CategoriesTreeItem toplevel [] = -{ - {N_("Editor"), editor_behavior, LOGO}, - {N_("Print"), print, LOGO}, - {N_("Plugins"), plugins, LOGO}, - - { NULL } -}; - -GType -gedit_preferences_dialog_get_type (void) -{ - static GType dialog_type = 0; - - if (!dialog_type) - { - static const GTypeInfo dialog_info = - { - sizeof (GeditPreferencesDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gedit_preferences_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GeditPreferencesDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gedit_preferences_dialog_init - }; - - dialog_type = g_type_register_static (GTK_TYPE_DIALOG, - "GeditPreferencesDialog", - &dialog_info, - 0); - } - - return dialog_type; -} - -static void -gedit_preferences_dialog_class_init (GeditPreferencesDialogClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - gedit_debug (DEBUG_PREFS, ""); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_preferences_dialog_finalize; -} - -static void -gedit_preferences_dialog_init (GeditPreferencesDialog *dlg) -{ - GtkWidget *hbox; - GtkWidget *r; - GtkWidget *l; - GtkWidget *ct; - GtkWidget *label; - - gedit_debug (DEBUG_PREFS, ""); - - dlg->priv = g_new0 (GeditPreferencesDialogPrivate, 1); - - gedit_preferences_dialog_add_buttons (dlg); - - hbox = gtk_hbox_new (FALSE, 12); - - gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); - - r = gtk_vbox_new (FALSE, 0); - - label = gtk_label_new_with_mnemonic (_("Cat_egories:")); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (label), "xalign", 0.0, NULL); - - ct = gedit_preferences_dialog_create_categories_tree (dlg); - - gtk_box_pack_start (GTK_BOX (r), label, FALSE, FALSE, 6); - gtk_box_pack_start (GTK_BOX (r), ct, TRUE, TRUE, 0); - - l = gedit_preferences_dialog_create_notebook (dlg); - - gtk_box_pack_start (GTK_BOX (hbox), r, FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (hbox), l, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), hbox, - FALSE, FALSE, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dlg->priv->categories_tree); - - gtk_widget_show_all (GTK_DIALOG (dlg)->vbox); - - gtk_window_set_title (GTK_WINDOW (dlg), _("Preferences")); - - gtk_window_set_resizable (GTK_WINDOW (dlg), FALSE); -} - -static void -gedit_preferences_dialog_finalize (GObject *object) -{ - GeditPreferencesDialog* dlg; - - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (object != NULL); - - dlg = GEDIT_PREFERENCES_DIALOG (object); - - g_return_if_fail (GEDIT_IS_PREFERENCES_DIALOG (dlg)); - g_return_if_fail (dlg->priv != NULL); - - g_object_unref (G_OBJECT (dlg->priv->categories_tree_model)); - - G_OBJECT_CLASS (parent_class)->finalize (object); - - g_free (dlg->priv); -} - -static void -gedit_preferences_dialog_response_handler (GtkDialog *dialog, gint res_id, - GeditPreferencesDialog *dlg) -{ - GError *error = NULL; - - gedit_debug (DEBUG_PREFS, ""); - - switch (res_id) - { - case GTK_RESPONSE_HELP: - gnome_help_display ("gedit.xml", "gedit-prefs", &error); - - if (error != NULL) - { - g_warning (error->message); - g_error_free (error); - } - - break; - - default: - gtk_widget_destroy (GTK_WIDGET(dialog)); - } -} - -static void -gedit_preferences_dialog_add_buttons (GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (GEDIT_IS_PREFERENCES_DIALOG (dlg)); - - gtk_dialog_add_button (GTK_DIALOG (dlg), - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE); - - gtk_dialog_add_button (GTK_DIALOG (dlg), - GTK_STOCK_HELP, - GTK_RESPONSE_HELP); - - gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_CLOSE); - - g_signal_connect(G_OBJECT (dlg), "response", - G_CALLBACK (gedit_preferences_dialog_response_handler), dlg); -} - -static GtkTreeModel* -gedit_preferences_dialog_create_categories_tree_model () -{ - GtkTreeStore *model; - GtkTreeIter iter; - CategoriesTreeItem *category = toplevel; - - gedit_debug (DEBUG_PREFS, ""); - - /* create tree store */ - model = gtk_tree_store_new (NUM_COLUMNS, - G_TYPE_STRING, - G_TYPE_INT); - - /* add data to the tree store */ - while (category->category) - { - CategoriesTreeItem *sub_category = category->children; - - gtk_tree_store_append (model, &iter, NULL); - - gtk_tree_store_set (model, &iter, - CATEGORY_COLUMN, gettext (category->category), - PAGE_NUM_COLUMN, category->notebook_page, - -1); - - /* add children */ - while (sub_category->category) - { - GtkTreeIter child_iter; - - gtk_tree_store_append (model, &child_iter, &iter); - - gtk_tree_store_set (model, &child_iter, - CATEGORY_COLUMN, gettext (sub_category->category), - PAGE_NUM_COLUMN, sub_category->notebook_page, - -1); - - sub_category++; - } - - category++; - } - - gedit_debug (DEBUG_PREFS, "Done"); - - return GTK_TREE_MODEL (model); - -} - -static void -gedit_preferences_dialog_categories_tree_selection_cb (GtkTreeSelection *selection, - GeditPreferencesDialog *dlg) -{ - GtkTreeIter iter; - GValue value = {0, }; - - gedit_debug (DEBUG_PREFS, ""); - - if (! gtk_tree_selection_get_selected (selection, NULL, &iter)) - return; - - gtk_tree_model_get_value (dlg->priv->categories_tree_model, &iter, - PAGE_NUM_COLUMN, - &value); - - last_selected_page_num = g_value_get_int (&value); - - if (dlg->priv->notebook != NULL) - gtk_notebook_set_current_page (GTK_NOTEBOOK (dlg->priv->notebook), - last_selected_page_num); - - g_value_unset (&value); -} - -static gboolean -gedit_preferences_dialog_selection_init ( - GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - GeditPreferencesDialog *dlg) -{ - GValue value = {0, }; - gint page_num; - - gedit_debug (DEBUG_PREFS, ""); - - gtk_tree_model_get_value (dlg->priv->categories_tree_model, iter, - PAGE_NUM_COLUMN, - &value); - - page_num = g_value_get_int (&value); - - g_value_unset (&value); - - if (page_num == last_selected_page_num) - { - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dlg->priv->categories_tree)); - g_return_val_if_fail (selection != NULL, TRUE); - - gtk_tree_selection_select_iter (selection, iter); - - g_return_val_if_fail (dlg->priv->notebook != NULL, TRUE); - gtk_notebook_set_current_page (GTK_NOTEBOOK (dlg->priv->notebook), page_num); - - return TRUE; - } - - return FALSE; -} - -static void -gedit_preferences_dialog_categories_tree_realize (GtkWidget *widget, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - gtk_tree_view_expand_all (GTK_TREE_VIEW (widget)); - - gtk_tree_model_foreach (dlg->priv->categories_tree_model, - (GtkTreeModelForeachFunc) gedit_preferences_dialog_selection_init, - (gpointer)dlg); -} - -static GtkWidget* -gedit_preferences_dialog_create_categories_tree (GeditPreferencesDialog *dlg) -{ - GtkWidget *sw; - GtkTreeModel *model; - GtkWidget *treeview; - GtkCellRenderer *renderer; - GtkTreeSelection *selection; - GtkTreeViewColumn *column; - gint col_offset; - - gedit_debug (DEBUG_PREFS, ""); - - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_widget_set_size_request (sw, 160, 240); - - model = gedit_preferences_dialog_create_categories_tree_model (); - - treeview = gtk_tree_view_new_with_model (model); - - dlg->priv->categories_tree = treeview; - dlg->priv->categories_tree_model = model; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)); - g_return_val_if_fail (selection != NULL, NULL); - - gtk_tree_selection_set_mode (selection, - GTK_SELECTION_SINGLE); - - /* add column for category */ - renderer = gtk_cell_renderer_text_new (); - g_object_set (G_OBJECT (renderer), "xalign", 0.0, NULL); - - col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), - -1, _("Categories"), - renderer, "text", - CATEGORY_COLUMN, - NULL); - - column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1); - gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), FALSE); - - g_signal_connect (selection, "changed", - G_CALLBACK (gedit_preferences_dialog_categories_tree_selection_cb), - dlg); - - gtk_container_add (GTK_CONTAINER (sw), treeview); - - g_signal_connect (G_OBJECT (treeview), "realize", - G_CALLBACK (gedit_preferences_dialog_categories_tree_realize), - dlg); - - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE); - - return sw; -} - -static GtkWidget* -gedit_preferences_dialog_create_notebook (GeditPreferencesDialog *dlg) -{ - GladeXML *gui; - - gedit_debug (DEBUG_PREFS, ""); - - gui = glade_xml_new (GEDIT_GLADEDIR "gedit-preferences.glade2", - "prefs_notebook", NULL); - - if (!gui) { - g_warning - ("Could not find gedit-preferences.glade2, reinstall gedit.\n"); - return NULL; - } - - dlg->priv->notebook = glade_xml_get_widget (gui, "prefs_notebook"); - - if (!dlg->priv->notebook) { - g_print - ("Could not find the required widgets inside gedit-preferences.glade2.\n"); - return NULL; - } - - gedit_preferences_dialog_setup_font_and_colors_page (dlg, gui); - gedit_preferences_dialog_setup_undo_page (dlg, gui); - gedit_preferences_dialog_setup_tabs_page (dlg, gui); - gedit_preferences_dialog_setup_logo_page (dlg, gui); - gedit_preferences_dialog_setup_wrap_mode_page (dlg, gui); - gedit_preferences_dialog_setup_save_page (dlg, gui); - gedit_preferences_dialog_setup_page_page (dlg, gui); - gedit_preferences_dialog_setup_line_numbers_page (dlg, gui); - gedit_preferences_dialog_setup_print_fonts_page (dlg, gui); - gedit_preferences_dialog_setup_plugin_manager_page (dlg, gui); - - gtk_notebook_set_current_page (GTK_NOTEBOOK (dlg->priv->notebook), LOGO); - - g_object_unref (G_OBJECT (gui)); - - return dlg->priv->notebook; -} - -GtkWidget* -gedit_preferences_dialog_new (GtkWindow *parent) -{ - GtkWidget *dlg; - - gedit_debug (DEBUG_PREFS, ""); - - dlg = GTK_WIDGET (g_object_new (GEDIT_TYPE_PREFERENCES_DIALOG, NULL)); - - if (parent) - gtk_window_set_transient_for (GTK_WINDOW (dlg), parent); - - gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE); - - return dlg; -} - -static void -gedit_preferences_dialog_default_font_colors_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - if (GTK_TOGGLE_BUTTON (dlg->priv->default_font_checkbutton) == button) - { - if (gtk_toggle_button_get_active (button)) - { - gtk_widget_set_sensitive (dlg->priv->font_hbox, FALSE); - gedit_prefs_manager_set_use_default_font (TRUE); - } - else - { - gtk_widget_set_sensitive (dlg->priv->font_hbox, - gedit_prefs_manager_editor_font_can_set ()); - gedit_prefs_manager_set_use_default_font (FALSE); - } - - return; - } - - if (GTK_TOGGLE_BUTTON (dlg->priv->default_colors_checkbutton) == button) - { - if (gtk_toggle_button_get_active (button)) - { - gtk_widget_set_sensitive (dlg->priv->colors_table, FALSE); - gedit_prefs_manager_set_use_default_colors (TRUE); - } - else - { - gedit_prefs_manager_set_use_default_colors (FALSE); - gtk_widget_set_sensitive (dlg->priv->colors_table, - gedit_prefs_manager_background_color_can_set () && - gedit_prefs_manager_text_color_can_set () && - gedit_prefs_manager_selection_color_can_set () && - gedit_prefs_manager_selected_text_color_can_set ()); - } - - return; - } - - g_return_if_fail (FALSE); -} - -static void -gedit_preferences_dialog_editor_font_picker_font_set (GnomeFontPicker *gfp, - const gchar *font_name, GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gfp == GNOME_FONT_PICKER (dlg->priv->fontpicker)); - g_return_if_fail (font_name != NULL); - - gedit_prefs_manager_set_editor_font (font_name); -} - -static void -gedit_preferences_dialog_editor_color_picker_color_set (GnomeColorPicker *cp, - guint r, guint g, guint b, guint a, GeditPreferencesDialog *dlg) -{ - GdkColor color; - - color.red = r; - color.green = g; - color.blue = b; - - if (cp == GNOME_COLOR_PICKER (dlg->priv->background_colorpicker)) - { - gedit_prefs_manager_set_background_color (color); - return; - } - - if (cp == GNOME_COLOR_PICKER (dlg->priv->text_colorpicker)) - { - gedit_prefs_manager_set_text_color (color); - return; - } - - if (cp == GNOME_COLOR_PICKER (dlg->priv->selection_colorpicker)) - { - gedit_prefs_manager_set_selection_color (color); - return; - } - - if (cp == GNOME_COLOR_PICKER (dlg->priv->sel_text_colorpicker)) - { - gedit_prefs_manager_set_selected_text_color (color); - return; - } - - g_return_if_fail (FALSE); -} - - -static gboolean -gedit_preferences_dialog_setup_font_and_colors_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *font_label; - - gboolean use_default_font; - gboolean use_default_colors; - - GdkColor background_color; - GdkColor text_color; - GdkColor selection_color; - GdkColor selected_text_color; - - gchar *editor_font = NULL; - - gedit_debug (DEBUG_PREFS, ""); - - dlg->priv->default_font_checkbutton = glade_xml_get_widget (gui, "default_font_checkbutton"); - dlg->priv->default_colors_checkbutton = glade_xml_get_widget (gui, "default_colors_checkbutton"); - - dlg->priv->text_colorpicker = glade_xml_get_widget (gui, "text_colorpicker"); - dlg->priv->background_colorpicker = glade_xml_get_widget (gui, "background_colorpicker"); - dlg->priv->sel_text_colorpicker = glade_xml_get_widget (gui, "sel_text_colorpicker"); - dlg->priv->selection_colorpicker = glade_xml_get_widget (gui, "selection_colorpicker"); - - dlg->priv->colors_table = glade_xml_get_widget (gui, "colors_table"); - dlg->priv->font_hbox = glade_xml_get_widget (gui, "font_hbox"); - - font_label = glade_xml_get_widget (gui, "font_label"); - - dlg->priv->fontpicker = gnome_font_picker_new (); - g_return_val_if_fail (dlg->priv->fontpicker, FALSE); - - gnome_font_picker_set_mode (GNOME_FONT_PICKER (dlg->priv->fontpicker), - GNOME_FONT_PICKER_MODE_FONT_INFO); - gnome_font_picker_fi_set_use_font_in_label (GNOME_FONT_PICKER (dlg->priv->fontpicker), - TRUE, 14); - gnome_font_picker_fi_set_show_size (GNOME_FONT_PICKER (dlg->priv->fontpicker), TRUE); - - g_return_val_if_fail (dlg->priv->default_font_checkbutton, FALSE); - g_return_val_if_fail (dlg->priv->default_colors_checkbutton, FALSE); - - g_return_val_if_fail (dlg->priv->text_colorpicker, FALSE); - g_return_val_if_fail (dlg->priv->background_colorpicker, FALSE); - g_return_val_if_fail (dlg->priv->sel_text_colorpicker, FALSE); - g_return_val_if_fail (dlg->priv->selection_colorpicker, FALSE); - - g_return_val_if_fail (dlg->priv->colors_table, FALSE); - g_return_val_if_fail (dlg->priv->font_hbox, FALSE); - - g_return_val_if_fail (font_label, FALSE); - - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->fontpicker, - _("Push this button to select the font to be used by the editor"), NULL); - - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->text_colorpicker, - _("Push this button to configure text color"), NULL); - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->background_colorpicker, - _("Push this button to configure background color"), NULL); - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->sel_text_colorpicker, - _("Push this button to configure the color in which the selected " - "text should appear"), NULL); - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->selection_colorpicker, - _("Push this button to configure the color in which the selected " - "text should be marked"), NULL); - - gtk_label_set_mnemonic_widget (GTK_LABEL (font_label), dlg->priv->fontpicker); - gedit_utils_set_atk_relation (dlg->priv->fontpicker, font_label, ATK_RELATION_LABELLED_BY); - gedit_utils_set_atk_relation (dlg->priv->fontpicker, dlg->priv->default_font_checkbutton, - ATK_RELATION_CONTROLLED_BY); - gedit_utils_set_atk_relation (dlg->priv->default_font_checkbutton, dlg->priv->fontpicker, - ATK_RELATION_CONTROLLER_FOR); - gtk_box_pack_start (GTK_BOX (dlg->priv->font_hbox), dlg->priv->fontpicker, TRUE, TRUE, 0); - - /* read config value */ - use_default_font = gedit_prefs_manager_get_use_default_font (); - use_default_colors = gedit_prefs_manager_get_use_default_colors (); - - background_color = gedit_prefs_manager_get_background_color (); - text_color = gedit_prefs_manager_get_text_color (); - selection_color = gedit_prefs_manager_get_selection_color (); - selected_text_color = gedit_prefs_manager_get_selected_text_color (); - - editor_font = gedit_prefs_manager_get_editor_font (); - - /* setup the initial states */ - gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (dlg->priv->background_colorpicker), - background_color.red, - background_color.green, - background_color.blue, 0); - - gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (dlg->priv->text_colorpicker), - text_color.red, - text_color.green, - text_color.blue, 0); - - gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (dlg->priv->selection_colorpicker), - selection_color.red, - selection_color.green, - selection_color.blue, 0); - - gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (dlg->priv->sel_text_colorpicker), - selected_text_color.red, - selected_text_color.green, - selected_text_color.blue, 0); - - if (editor_font != NULL) - { - gnome_font_picker_set_font_name (GNOME_FONT_PICKER (dlg->priv->fontpicker), - editor_font); - - g_free (editor_font); - } - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (dlg->priv->default_font_checkbutton), use_default_font); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (dlg->priv->default_colors_checkbutton), use_default_colors); - - /* Connect signals */ - - g_signal_connect (G_OBJECT (dlg->priv->default_font_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_default_font_colors_checkbutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->default_colors_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_default_font_colors_checkbutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->fontpicker), "font_set", - G_CALLBACK (gedit_preferences_dialog_editor_font_picker_font_set), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->background_colorpicker), "color_set", - G_CALLBACK (gedit_preferences_dialog_editor_color_picker_color_set), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->text_colorpicker), "color_set", - G_CALLBACK (gedit_preferences_dialog_editor_color_picker_color_set), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->selection_colorpicker), "color_set", - G_CALLBACK (gedit_preferences_dialog_editor_color_picker_color_set), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->sel_text_colorpicker), "color_set", - G_CALLBACK (gedit_preferences_dialog_editor_color_picker_color_set), - dlg); - - /* Set initial widget sensitivity */ - gtk_widget_set_sensitive (dlg->priv->default_font_checkbutton, - gedit_prefs_manager_use_default_font_can_set ()); - - gtk_widget_set_sensitive (dlg->priv->default_colors_checkbutton, - gedit_prefs_manager_use_default_colors_can_set ()); - - if (use_default_font) - gtk_widget_set_sensitive (dlg->priv->font_hbox, FALSE); - else - gtk_widget_set_sensitive (dlg->priv->font_hbox, - gedit_prefs_manager_editor_font_can_set ()); - - if (use_default_colors) - gtk_widget_set_sensitive (dlg->priv->colors_table, FALSE); - else - gtk_widget_set_sensitive (dlg->priv->colors_table, - gedit_prefs_manager_background_color_can_set () && - gedit_prefs_manager_text_color_can_set () && - gedit_prefs_manager_selection_color_can_set () && - gedit_prefs_manager_selected_text_color_can_set ()); - - return TRUE; -} - -static void -gedit_preferences_dialog_undo_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->undo_checkbutton)); - - if (gtk_toggle_button_get_active (button)) - { - gint undo_levels; - - gtk_widget_set_sensitive (dlg->priv->undo_levels_spinbutton, - gedit_prefs_manager_undo_actions_limit_can_set()); - /* - gtk_widget_grab_focus (dlg->priv->undo_levels_spinbutton); - */ - undo_levels = gtk_spin_button_get_value_as_int ( - GTK_SPIN_BUTTON (dlg->priv->undo_levels_spinbutton)); - g_return_if_fail (undo_levels >= 1); - - gedit_prefs_manager_set_undo_actions_limit (undo_levels); - } - else - { - gtk_widget_set_sensitive (dlg->priv->undo_levels_spinbutton, FALSE); - - gedit_prefs_manager_set_undo_actions_limit (-1); - } -} - -static void -gedit_preferences_dialog_undo_levels_spinbutton_value_changed (GtkSpinButton *spin_button, - GeditPreferencesDialog *dlg) -{ - gint undo_levels; - - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->undo_levels_spinbutton)); - - undo_levels = gtk_spin_button_get_value_as_int ( - GTK_SPIN_BUTTON (dlg->priv->undo_levels_spinbutton)); - g_return_if_fail (undo_levels >= 1); - - gedit_prefs_manager_set_undo_actions_limit (undo_levels); -} - -static gboolean -gedit_preferences_dialog_setup_undo_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - gint undo_levels; - gboolean can_set; - - gedit_debug (DEBUG_PREFS, ""); - - dlg->priv->undo_checkbutton = glade_xml_get_widget (gui, "undo_checkbutton"); - dlg->priv->undo_levels_spinbutton = glade_xml_get_widget (gui, "undo_levels_spinbutton"); - dlg->priv->undo_levels_label = glade_xml_get_widget (gui, "undo_levels_label"); - - g_return_val_if_fail (dlg->priv->undo_checkbutton, FALSE); - g_return_val_if_fail (dlg->priv->undo_levels_spinbutton, FALSE); - g_return_val_if_fail (dlg->priv->undo_levels_label, FALSE); - - /* Set initial value */ - undo_levels = gedit_prefs_manager_get_undo_actions_limit (); - - if (undo_levels > 0) - gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->undo_levels_spinbutton), - (guint) undo_levels); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->undo_checkbutton), - undo_levels > 0); - - /* Set widget sensitivity */ - can_set = gedit_prefs_manager_undo_actions_limit_can_set (); - - gtk_widget_set_sensitive (dlg->priv->undo_checkbutton, can_set); - gtk_widget_set_sensitive (dlg->priv->undo_levels_spinbutton, can_set && (undo_levels > 0)); - gtk_widget_set_sensitive (dlg->priv->undo_levels_label, can_set); - - /* Connect signals */ - if (can_set) - { - /* - if (undo_levels > 0) - gtk_widget_grab_focus (dlg->priv->undo_levels_spinbutton); - */ - - g_signal_connect (G_OBJECT (dlg->priv->undo_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_undo_checkbutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->undo_levels_spinbutton), "value_changed", - G_CALLBACK (gedit_preferences_dialog_undo_levels_spinbutton_value_changed), - dlg); - } - - return TRUE; -} - -static void -gedit_preferences_dialog_tabs_width_spinbutton_value_changed (GtkSpinButton *spin_button, - GeditPreferencesDialog *dlg) -{ - g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->tabs_width_spinbutton)); - - gedit_prefs_manager_set_tabs_size (gtk_spin_button_get_value_as_int (spin_button)); -} - -static gboolean -gedit_preferences_dialog_setup_tabs_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *tabs_width_hbox; - - gedit_debug (DEBUG_PREFS, ""); - - dlg->priv->tabs_width_spinbutton = glade_xml_get_widget (gui, "tabs_width_spinbutton"); - tabs_width_hbox = glade_xml_get_widget (gui, "tabs_width_hbox"); - - g_return_val_if_fail (dlg->priv->undo_levels_spinbutton, FALSE); - g_return_val_if_fail (tabs_width_hbox, FALSE); - - /* Set initial state */ - gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->tabs_width_spinbutton), - (guint) gedit_prefs_manager_get_tabs_size ()); - - /* Set widget sensitivity */ - gtk_widget_set_sensitive (tabs_width_hbox, - gedit_prefs_manager_tabs_size_can_set ()); - - /* Connect signal */ - g_signal_connect (G_OBJECT (dlg->priv->tabs_width_spinbutton), "value_changed", - G_CALLBACK (gedit_preferences_dialog_tabs_width_spinbutton_value_changed), - dlg); - return TRUE; -} - -static gboolean -gedit_preferences_dialog_setup_logo_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *logo; - GValue value = { 0, }; - - static const char* logo_file = GNOME_ICONDIR "/gedit-logo.png"; - - gedit_debug (DEBUG_PREFS, ""); - - logo = glade_xml_get_widget (gui, "logo_pixmap"); - - g_return_val_if_fail (logo, FALSE); - - g_value_init (&value, G_TYPE_STRING); - - g_value_set_static_string (&value, logo_file); - g_object_set_property (G_OBJECT (logo), "file" , &value); - - g_value_unset (&value); - - return TRUE; -} - -static void -gedit_preferences_dialog_wrap_mode_radiobutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - if (button == GTK_TOGGLE_BUTTON (dlg->priv->wrap_never_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - gedit_prefs_manager_set_wrap_mode (GTK_WRAP_NONE); - return; - } - } - - if (button == GTK_TOGGLE_BUTTON (dlg->priv->wrap_char_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - gedit_prefs_manager_set_wrap_mode (GTK_WRAP_CHAR); - return; - } - } - - if (button == GTK_TOGGLE_BUTTON (dlg->priv->wrap_word_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - gedit_prefs_manager_set_wrap_mode (GTK_WRAP_WORD); - return; - } - } -} - -static gboolean -gedit_preferences_dialog_setup_wrap_mode_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *wrap_mode_frame; - - gedit_debug (DEBUG_PREFS, ""); - - dlg->priv->wrap_never_radiobutton = glade_xml_get_widget (gui, "wrap_never_radiobutton"); - dlg->priv->wrap_word_radiobutton = glade_xml_get_widget (gui, "wrap_word_radiobutton"); - dlg->priv->wrap_char_radiobutton = glade_xml_get_widget (gui, "wrap_char_radiobutton"); - wrap_mode_frame = glade_xml_get_widget (gui, "wrap_mode_frame"); - - g_return_val_if_fail (dlg->priv->wrap_never_radiobutton, FALSE); - g_return_val_if_fail (dlg->priv->wrap_word_radiobutton, FALSE); - g_return_val_if_fail (dlg->priv->wrap_char_radiobutton, FALSE); - g_return_val_if_fail (wrap_mode_frame, FALSE); - - /* Set initial state */ - switch (gedit_prefs_manager_get_wrap_mode ()) - { - case GTK_WRAP_WORD: - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->wrap_word_radiobutton), TRUE); - break; - case GTK_WRAP_CHAR: - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->wrap_char_radiobutton), TRUE); - break; - default: - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->wrap_never_radiobutton), TRUE); - } - - /* Set widget sensitivity */ - gtk_widget_set_sensitive (wrap_mode_frame, - gedit_prefs_manager_wrap_mode_can_set ()); - - /* Connect signals */ - g_signal_connect (G_OBJECT (dlg->priv->wrap_never_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_wrap_mode_radiobutton_toggled), - dlg); - g_signal_connect (G_OBJECT (dlg->priv->wrap_word_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_wrap_mode_radiobutton_toggled), - dlg); - g_signal_connect (G_OBJECT (dlg->priv->wrap_char_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_wrap_mode_radiobutton_toggled), - dlg); - - - return TRUE; -} - -static void -gedit_preferences_dialog_auto_save_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton)); - - if (gtk_toggle_button_get_active (button)) - { - gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, - gedit_prefs_manager_auto_save_interval_can_set()); - /* - gtk_widget_grab_focus (dlg->priv->auto_save_spinbutton); - */ - gedit_prefs_manager_set_auto_save (TRUE); - } - else - { - gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, FALSE); - gedit_prefs_manager_set_auto_save (FALSE); - } -} - -static void -gedit_preferences_dialog_backup_copy_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton)); - - gedit_prefs_manager_set_create_backup_copy (gtk_toggle_button_get_active (button)); -} - -static void -gedit_preferences_dialog_auto_save_spinbutton_value_changed (GtkSpinButton *spin_button, - GeditPreferencesDialog *dlg) -{ - g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->auto_save_spinbutton)); - - gedit_prefs_manager_set_auto_save_interval ( - MAX (1, gtk_spin_button_get_value_as_int (spin_button))); -} - -static void -gedit_preferences_dialog_save_radiobutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - if (button == GTK_TOGGLE_BUTTON (dlg->priv->utf8_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - gedit_prefs_manager_set_save_encoding ( - GEDIT_SAVE_ALWAYS_UTF8); - - gtk_widget_set_sensitive (dlg->priv->create_frame, FALSE); - - return; - } - } - - if (button == GTK_TOGGLE_BUTTON (dlg->priv->locale_if_possible_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - gedit_prefs_manager_set_save_encoding ( - GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE); - - gtk_widget_set_sensitive (dlg->priv->create_frame, FALSE); - - return; - } - } - - if (button == GTK_TOGGLE_BUTTON (dlg->priv->original_if_possible_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->create_utf8_radiobutton))) - gedit_prefs_manager_set_save_encoding ( - GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE); - else - { - g_return_if_fail (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( - dlg->priv->create_locale_if_possible_radiobutton))); - - gedit_prefs_manager_set_save_encoding ( - GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL); - - } - - gtk_widget_set_sensitive (dlg->priv->create_frame, TRUE); - - return; - } - } - - if (button == GTK_TOGGLE_BUTTON (dlg->priv->create_utf8_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - g_return_if_fail (gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON (dlg->priv->original_if_possible_radiobutton))); - - gedit_prefs_manager_set_save_encoding ( - GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE); - - return; - } - } - - if (button == GTK_TOGGLE_BUTTON (dlg->priv->create_locale_if_possible_radiobutton)) - { - if (gtk_toggle_button_get_active (button)) - { - g_return_if_fail (gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON (dlg->priv->original_if_possible_radiobutton))); - - gedit_prefs_manager_set_save_encoding ( - GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL); - - return; - } - } -} - -static gboolean -gedit_preferences_dialog_setup_save_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *autosave_hbox; - GtkWidget *save_frame; - gboolean auto_save; - GeditSaveEncodingSetting encoding; - - gedit_debug (DEBUG_PREFS, ""); - - autosave_hbox = glade_xml_get_widget (gui, - "autosave_hbox"); - - save_frame = glade_xml_get_widget (gui, - "save_frame"); - - dlg->priv->backup_copy_checkbutton = glade_xml_get_widget (gui, - "backup_copy_checkbutton"); - - dlg->priv->auto_save_checkbutton = glade_xml_get_widget (gui, - "auto_save_checkbutton"); - - dlg->priv->auto_save_spinbutton = glade_xml_get_widget (gui, - "auto_save_spinbutton"); - - dlg->priv->utf8_radiobutton = glade_xml_get_widget (gui, - "utf8_radiobutton"); - dlg->priv->locale_if_possible_radiobutton= glade_xml_get_widget (gui, - "locale_if_possible_radiobutton"); - dlg->priv->original_if_possible_radiobutton = glade_xml_get_widget (gui, - "original_if_possible_radiobutton"); - - dlg->priv->create_frame = glade_xml_get_widget (gui, - "create_frame"); - dlg->priv->create_utf8_radiobutton = glade_xml_get_widget (gui, - "create_utf8_radiobutton"); - dlg->priv->create_locale_if_possible_radiobutton = glade_xml_get_widget (gui, - "create_locale_if_possible_radiobutton"); - - g_return_val_if_fail (autosave_hbox, FALSE); - g_return_val_if_fail (save_frame, FALSE); - - g_return_val_if_fail (dlg->priv->backup_copy_checkbutton, FALSE); - - g_return_val_if_fail (dlg->priv->utf8_radiobutton, FALSE); - g_return_val_if_fail (dlg->priv->locale_if_possible_radiobutton, FALSE); - g_return_val_if_fail (dlg->priv->original_if_possible_radiobutton, FALSE); - - g_return_val_if_fail (dlg->priv->create_frame, FALSE); - g_return_val_if_fail (dlg->priv->create_utf8_radiobutton, FALSE); - g_return_val_if_fail (dlg->priv->create_locale_if_possible_radiobutton, FALSE); - - /* FIXME */ - /* - gtk_widget_set_sensitive (dlg->priv->locale_if_previous_radiobutton, FALSE); - */ - /* Set current values */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton), - gedit_prefs_manager_get_create_backup_copy ()); - - auto_save = gedit_prefs_manager_get_auto_save (); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton), - auto_save ); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->auto_save_spinbutton), - gedit_prefs_manager_get_auto_save_interval ()); - - encoding = gedit_prefs_manager_get_save_encoding (); - - switch (encoding) - { - case GEDIT_SAVE_ALWAYS_UTF8: - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->utf8_radiobutton), TRUE); - break; - case GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE: - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->locale_if_possible_radiobutton), - TRUE); - break; - case GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE: - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->original_if_possible_radiobutton), - TRUE); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->create_utf8_radiobutton), - TRUE); - break; - case GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL: - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->original_if_possible_radiobutton), - TRUE); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (dlg->priv->create_locale_if_possible_radiobutton), - TRUE); - break; - - default: - /* Not possible */ - g_return_val_if_fail (FALSE, FALSE); - } - - /* Set sensitivity */ - gtk_widget_set_sensitive (dlg->priv->backup_copy_checkbutton, - gedit_prefs_manager_create_backup_copy_can_set ()); - - gtk_widget_set_sensitive (autosave_hbox, - gedit_prefs_manager_auto_save_can_set ()); - - gtk_widget_set_sensitive (save_frame, - gedit_prefs_manager_save_encoding_can_set ()); - - gtk_widget_set_sensitive (dlg->priv->create_frame, - gedit_prefs_manager_save_encoding_can_set () && - ((encoding == GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE) || - (encoding == GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL))); - - gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton, - auto_save && - gedit_prefs_manager_auto_save_interval_can_set ()); - - /* Connect signals */ - g_signal_connect (G_OBJECT (dlg->priv->auto_save_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_auto_save_checkbutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->backup_copy_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_backup_copy_checkbutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->auto_save_spinbutton), "value_changed", - G_CALLBACK (gedit_preferences_dialog_auto_save_spinbutton_value_changed), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->utf8_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_save_radiobutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->locale_if_possible_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_save_radiobutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->original_if_possible_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_save_radiobutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->create_utf8_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_save_radiobutton_toggled), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->create_locale_if_possible_radiobutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_save_radiobutton_toggled), - dlg); - - return TRUE; -} - -static void -gedit_preferences_dialog_line_numbers_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->line_numbers_checkbutton)); - - if (gtk_toggle_button_get_active (button)) - { - gtk_widget_set_sensitive (dlg->priv->line_numbers_spinbutton, - gedit_prefs_manager_print_line_numbers_can_set ()); - /* - gtk_widget_grab_focus (dlg->priv->line_numbers_spinbutton); - */ - - gedit_prefs_manager_set_print_line_numbers ( - MAX (1, gtk_spin_button_get_value_as_int ( - GTK_SPIN_BUTTON (dlg->priv->line_numbers_spinbutton)))); - } - else - { - gtk_widget_set_sensitive (dlg->priv->line_numbers_spinbutton, FALSE); - gedit_prefs_manager_set_print_line_numbers (0); - } -} - -static void -gedit_preferences_dialog_add_header_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->add_header_checkbutton)); - - gedit_prefs_manager_set_print_header (gtk_toggle_button_get_active (button)); -} - -static void -gedit_preferences_dialog_wrap_lines_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->wrap_lines_checkbutton)); - - gedit_prefs_manager_set_print_wrap_mode ( - gtk_toggle_button_get_active (button) ? GTK_WRAP_CHAR : GTK_WRAP_NONE); -} - -static void -gedit_preferences_dialog_line_numbers_spinbutton_value_changed (GtkSpinButton *spin_button, - GeditPreferencesDialog *dlg) -{ - g_return_if_fail (spin_button == GTK_SPIN_BUTTON (dlg->priv->line_numbers_spinbutton)); - - gedit_prefs_manager_set_print_line_numbers ( - MAX (1, gtk_spin_button_get_value_as_int (spin_button))); -} - -static gboolean -gedit_preferences_dialog_setup_page_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *line_numbers_hbox; - gint print_line_numbers; - - gedit_debug (DEBUG_PREFS, ""); - - line_numbers_hbox = glade_xml_get_widget (gui, - "line_numbers_hbox"); - dlg->priv->add_header_checkbutton = glade_xml_get_widget (gui, - "add_header_checkbutton"); - dlg->priv->wrap_lines_checkbutton= glade_xml_get_widget (gui, - "wrap_lines_checkbutton"); - dlg->priv->line_numbers_checkbutton = glade_xml_get_widget (gui, - "line_numbers_checkbutton"); - dlg->priv->line_numbers_spinbutton = glade_xml_get_widget (gui, - "line_numbers_spinbutton"); - - g_return_val_if_fail (line_numbers_hbox, FALSE); - g_return_val_if_fail (dlg->priv->add_header_checkbutton, FALSE); - g_return_val_if_fail (dlg->priv->wrap_lines_checkbutton, FALSE); - g_return_val_if_fail (dlg->priv->line_numbers_checkbutton, FALSE); - g_return_val_if_fail (dlg->priv->line_numbers_spinbutton, FALSE); - - /* Set initial values */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->add_header_checkbutton), - gedit_prefs_manager_get_print_header ()); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_lines_checkbutton), - gedit_prefs_manager_get_print_wrap_mode () != GTK_WRAP_NONE); - - print_line_numbers = gedit_prefs_manager_get_print_line_numbers (); - - if (print_line_numbers > 0) - { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->line_numbers_spinbutton), - (guint) print_line_numbers); - gtk_widget_set_sensitive (dlg->priv->line_numbers_spinbutton, - gedit_prefs_manager_print_line_numbers_can_set ()); - } - else - gtk_widget_set_sensitive (dlg->priv->line_numbers_spinbutton, FALSE); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->line_numbers_checkbutton), - print_line_numbers > 0); - - /* Set widget sensitivity */ - gtk_widget_set_sensitive (dlg->priv->add_header_checkbutton, - gedit_prefs_manager_print_header_can_set ()); - gtk_widget_set_sensitive (dlg->priv->wrap_lines_checkbutton, - gedit_prefs_manager_print_wrap_mode_can_set ()); - gtk_widget_set_sensitive (line_numbers_hbox, - gedit_prefs_manager_print_line_numbers_can_set ()); - - /* Connect signals */ - g_signal_connect (G_OBJECT (dlg->priv->line_numbers_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_line_numbers_checkbutton_toggled), dlg); - g_signal_connect (G_OBJECT (dlg->priv->add_header_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_add_header_checkbutton_toggled), dlg); - g_signal_connect (G_OBJECT (dlg->priv->wrap_lines_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_wrap_lines_checkbutton_toggled), dlg); - - g_signal_connect (G_OBJECT (dlg->priv->line_numbers_spinbutton), "value_changed", - G_CALLBACK (gedit_preferences_dialog_line_numbers_spinbutton_value_changed), - dlg); - return TRUE; -} - -static void -gedit_preferences_dialog_print_font_restore_default_button_clicked ( - GtkButton *button, GeditPreferencesDialog *dlg) -{ - g_return_if_fail (dlg->priv->body_fontpicker != NULL); - g_return_if_fail (dlg->priv->headers_fontpicker != NULL); - g_return_if_fail (dlg->priv->numbers_fontpicker != NULL); - - /* FIXME: define constants, or take them from schemas - Paolo */ - if (gedit_prefs_manager_print_font_body_can_set ()) - { - gnome_print_font_picker_set_font_name ( - GNOME_PRINT_FONT_PICKER (dlg->priv->body_fontpicker), - _("Courier 9")); - - gedit_prefs_manager_set_print_font_body (_("Courier 9")); - } - - if (gedit_prefs_manager_print_font_header_can_set ()) - { - gnome_print_font_picker_set_font_name ( - GNOME_PRINT_FONT_PICKER (dlg->priv->headers_fontpicker), - _("Helvetica 11")); - - gedit_prefs_manager_set_print_font_header (_("Helvetica 11")); - } - - if (gedit_prefs_manager_print_font_numbers_can_set ()) - { - gnome_print_font_picker_set_font_name ( - GNOME_PRINT_FONT_PICKER (dlg->priv->numbers_fontpicker), - _("Helvetica 8")); - - gedit_prefs_manager_set_print_font_numbers (_("Helvetica 8")); - } -} - -static void -gedit_preferences_dialog_body_font_picker_font_set (GnomePrintFontPicker *gfp, - const gchar *font_name, GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gfp == GNOME_PRINT_FONT_PICKER (dlg->priv->body_fontpicker)); - g_return_if_fail (font_name != NULL); - - gedit_prefs_manager_set_print_font_body (font_name); -} - -static void -gedit_preferences_dialog_headers_font_picker_font_set (GnomePrintFontPicker *gfp, - const gchar *font_name, GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gfp == GNOME_PRINT_FONT_PICKER (dlg->priv->headers_fontpicker)); - g_return_if_fail (font_name != NULL); - - gedit_prefs_manager_set_print_font_header (font_name); -} - -static void -gedit_preferences_dialog_numbers_font_picker_font_set (GnomePrintFontPicker *gfp, - const gchar *font_name, GeditPreferencesDialog *dlg) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gfp == GNOME_PRINT_FONT_PICKER (dlg->priv->numbers_fontpicker)); - g_return_if_fail (font_name != NULL); - - gedit_prefs_manager_set_print_font_numbers (font_name); -} - -static gboolean -gedit_preferences_dialog_setup_print_fonts_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *print_fonts_table; - GtkWidget *body_font_label; - GtkWidget *headers_font_label; - GtkWidget *numbers_font_label; - gboolean can_set; - gchar* font; - - gedit_debug (DEBUG_PREFS, ""); - - print_fonts_table = glade_xml_get_widget (gui, "print_fonts_table"); - body_font_label = glade_xml_get_widget (gui, "body_font_label"); - headers_font_label = glade_xml_get_widget (gui, "headers_font_label"); - numbers_font_label = glade_xml_get_widget (gui, "numbers_font_label"); - dlg->priv->restore_default_fonts_button = glade_xml_get_widget (gui, - "restore_default_fonts_button"); - - g_return_val_if_fail (print_fonts_table != NULL, FALSE); - g_return_val_if_fail (body_font_label != NULL, FALSE); - g_return_val_if_fail (headers_font_label != NULL, FALSE); - g_return_val_if_fail (numbers_font_label != NULL, FALSE); - g_return_val_if_fail (dlg->priv->restore_default_fonts_button != NULL, FALSE); - - /* Body font picker */ - dlg->priv->body_fontpicker = gnome_print_font_picker_new (); - - gnome_print_font_picker_set_mode ( - GNOME_PRINT_FONT_PICKER (dlg->priv->body_fontpicker), - GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO); - - gnome_print_font_picker_fi_set_show_size ( - GNOME_PRINT_FONT_PICKER (dlg->priv->body_fontpicker), TRUE); - - gnome_print_font_picker_fi_set_use_font_in_label ( - GNOME_PRINT_FONT_PICKER (dlg->priv->body_fontpicker), TRUE, 14); - - gtk_table_attach_defaults (GTK_TABLE (print_fonts_table), - dlg->priv->body_fontpicker, 1, 2, 0, 1); - - /* Headers font picker */ - dlg->priv->headers_fontpicker = gnome_print_font_picker_new (); - gnome_print_font_picker_set_mode ( - GNOME_PRINT_FONT_PICKER (dlg->priv->headers_fontpicker), - GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO); - - gnome_print_font_picker_fi_set_show_size ( - GNOME_PRINT_FONT_PICKER (dlg->priv->headers_fontpicker), TRUE); - - gnome_print_font_picker_fi_set_use_font_in_label ( - GNOME_PRINT_FONT_PICKER (dlg->priv->headers_fontpicker), TRUE, 14); - - gtk_table_attach_defaults (GTK_TABLE (print_fonts_table), - dlg->priv->headers_fontpicker, 1, 2, 1, 2); - - /* Numbers font picker */ - dlg->priv->numbers_fontpicker = gnome_print_font_picker_new (); - gnome_print_font_picker_set_mode ( - GNOME_PRINT_FONT_PICKER (dlg->priv->numbers_fontpicker), - GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO); - - gnome_print_font_picker_fi_set_show_size ( - GNOME_PRINT_FONT_PICKER (dlg->priv->numbers_fontpicker), TRUE); - - gnome_print_font_picker_fi_set_use_font_in_label ( - GNOME_PRINT_FONT_PICKER (dlg->priv->numbers_fontpicker), TRUE, 14); - - gtk_table_attach_defaults (GTK_TABLE (print_fonts_table), - dlg->priv->numbers_fontpicker, 1, 2, 2, 3); - - gtk_label_set_mnemonic_widget (GTK_LABEL (body_font_label), - dlg->priv->body_fontpicker); - - gtk_label_set_mnemonic_widget (GTK_LABEL (headers_font_label), - dlg->priv->headers_fontpicker); - - gtk_label_set_mnemonic_widget (GTK_LABEL (numbers_font_label), - dlg->priv->numbers_fontpicker); - - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->body_fontpicker, - _("Push this button to select the font to be used to print the body"), NULL); - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->headers_fontpicker, - _("Push this button to select the font to be used to print the headers"), NULL); - gtk_tooltips_set_tip (gtk_tooltips_new(), dlg->priv->numbers_fontpicker, - _("Push this button to select the font to be used to print line numbers"), NULL); - - gedit_utils_set_atk_relation (dlg->priv->body_fontpicker, body_font_label, - ATK_RELATION_LABELLED_BY); - gedit_utils_set_atk_relation (dlg->priv->headers_fontpicker, headers_font_label, - ATK_RELATION_LABELLED_BY); - gedit_utils_set_atk_relation (dlg->priv->numbers_fontpicker, numbers_font_label, - ATK_RELATION_LABELLED_BY); - - /* Set initial values */ - font = gedit_prefs_manager_get_print_font_body (); - g_return_val_if_fail (font, FALSE); - - gnome_print_font_picker_set_font_name ( - GNOME_PRINT_FONT_PICKER (dlg->priv->body_fontpicker), - font); - - g_free (font); - - font = gedit_prefs_manager_get_print_font_header (); - g_return_val_if_fail (font, FALSE); - - gnome_print_font_picker_set_font_name ( - GNOME_PRINT_FONT_PICKER (dlg->priv->headers_fontpicker), - font); - - g_free (font); - - font = gedit_prefs_manager_get_print_font_numbers (); - g_return_val_if_fail (font, FALSE); - - gnome_print_font_picker_set_font_name ( - GNOME_PRINT_FONT_PICKER (dlg->priv->numbers_fontpicker), - font); - - g_free (font); - - /* Set widgets sensitivity */ - can_set = gedit_prefs_manager_print_font_body_can_set (); - gtk_widget_set_sensitive (dlg->priv->body_fontpicker, can_set); - gtk_widget_set_sensitive (body_font_label, can_set); - - can_set = gedit_prefs_manager_print_font_header_can_set (); - gtk_widget_set_sensitive (dlg->priv->headers_fontpicker, can_set); - gtk_widget_set_sensitive (headers_font_label, can_set); - - can_set = gedit_prefs_manager_print_font_numbers_can_set (); - gtk_widget_set_sensitive (dlg->priv->numbers_fontpicker, can_set); - gtk_widget_set_sensitive (numbers_font_label, can_set); - - /* Connect signals */ - g_signal_connect (G_OBJECT (dlg->priv->restore_default_fonts_button), "clicked", - G_CALLBACK (gedit_preferences_dialog_print_font_restore_default_button_clicked), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->body_fontpicker), "font_set", - G_CALLBACK (gedit_preferences_dialog_body_font_picker_font_set), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->headers_fontpicker), "font_set", - G_CALLBACK (gedit_preferences_dialog_headers_font_picker_font_set), - dlg); - - g_signal_connect (G_OBJECT (dlg->priv->numbers_fontpicker), "font_set", - G_CALLBACK (gedit_preferences_dialog_numbers_font_picker_font_set), - dlg); - - - return TRUE; -} - -static void -gedit_preferences_dialog_display_line_numbers_checkbutton_toggled (GtkToggleButton *button, - GeditPreferencesDialog *dlg) -{ - g_return_if_fail (button == - GTK_TOGGLE_BUTTON (dlg->priv->display_line_numbers_checkbutton)); - - gedit_prefs_manager_set_display_line_numbers (gtk_toggle_button_get_active (button)); -} - -static gboolean -gedit_preferences_dialog_setup_line_numbers_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - gedit_debug (DEBUG_PREFS, ""); - - dlg->priv->display_line_numbers_checkbutton = glade_xml_get_widget (gui, - "display_line_numbers_checkbutton"); - - g_return_val_if_fail (dlg->priv->display_line_numbers_checkbutton != NULL, FALSE); - - /* Set initial state */ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->display_line_numbers_checkbutton), - gedit_prefs_manager_get_display_line_numbers ()); - - /* Set widget sensitivity */ - gtk_widget_set_sensitive (dlg->priv->display_line_numbers_checkbutton, - gedit_prefs_manager_display_line_numbers_can_set ()); - - /* Connect signal */ - g_signal_connect (G_OBJECT (dlg->priv->display_line_numbers_checkbutton), "toggled", - G_CALLBACK (gedit_preferences_dialog_display_line_numbers_checkbutton_toggled), - dlg); - - return TRUE; -} - -static gboolean -gedit_preferences_dialog_setup_plugin_manager_page (GeditPreferencesDialog *dlg, GladeXML *gui) -{ - GtkWidget *plugin_manager_page; - GtkWidget *page_content; - - gedit_debug (DEBUG_PREFS, ""); - - plugin_manager_page = glade_xml_get_widget (gui, "plugin_manager_page"); - g_return_val_if_fail (plugin_manager_page != NULL, FALSE); - - page_content = gedit_plugin_manager_get_page (); - g_return_val_if_fail (page_content != NULL, FALSE); - - gtk_box_pack_start (GTK_BOX (plugin_manager_page), page_content, TRUE, TRUE, 0); - - return TRUE; -} diff --git a/gedit/dialogs/gedit-preferences-dialog.h b/gedit/dialogs/gedit-preferences-dialog.h deleted file mode 100644 index 81c45a393..000000000 --- a/gedit/dialogs/gedit-preferences-dialog.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-preferences-dialog.h - * This file is part of gedit - * - * Copyright (C) 2001 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_PREFERENCES_DIALOG_H__ -#define __GEDIT_PREFERENCES_DIALOG_H__ - -#include <gtk/gtk.h> - -#define GEDIT_TYPE_PREFERENCES_DIALOG (gedit_preferences_dialog_get_type ()) -#define GEDIT_PREFERENCES_DIALOG(obj) (GTK_CHECK_CAST ((obj), GEDIT_TYPE_PREFERENCES_DIALOG, GeditPreferencesDialog)) -#define GEDIT_PREFERENCES_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_PREFERENCES_DIALOG, GeditPreferencesDialogClass)) -#define GEDIT_IS_PREFERENCES_DIALOG(obj) (GTK_CHECK_TYPE ((obj), GEDIT_TYPE_PREFERENCES_DIALOG)) -#define GEDIT_IS_PREFERENCES_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_PREFERENCES_DIALOG)) -#define GEDIT_PREFERENCES_DIALOG_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GEDIT_TYPE_PREFERENCES_DIALOG, GeditPreferencesDialogClass)) - - -typedef struct _GeditPreferencesDialog GeditPreferencesDialog; -typedef struct _GeditPreferencesDialogClass GeditPreferencesDialogClass; - -typedef struct _GeditPreferencesDialogPrivate GeditPreferencesDialogPrivate; - -struct _GeditPreferencesDialog -{ - GtkDialog parent_instance; - - GeditPreferencesDialogPrivate *priv; - -}; - -struct _GeditPreferencesDialogClass -{ - GtkDialogClass parent_class; -}; - -GtkType gedit_preferences_dialog_get_type (void) G_GNUC_CONST; - -GtkWidget* gedit_preferences_dialog_new (GtkWindow *parent); - -#endif /* __GEDIT_PREFERENCES_DIALOG_H__ */ diff --git a/gedit/dialogs/gedit-preferences.glade2 b/gedit/dialogs/gedit-preferences.glade2 deleted file mode 100644 index db3c8a735..000000000 --- a/gedit/dialogs/gedit-preferences.glade2 +++ /dev/null @@ -1,1852 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> -<requires lib="gnome"/> - -<widget class="GtkDialog" id="dialog1"> - <property name="title" translatable="yes"></property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">True</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button1"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-help</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button3"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button4"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkNotebook" id="prefs_notebook"> - <property name="visible">True</property> - <property name="show_tabs">False</property> - <property name="show_border">False</property> - <property name="tab_pos">GTK_POS_TOP</property> - <property name="scrollable">True</property> - <property name="tab_hborder">2</property> - <property name="tab_vborder">2</property> - <property name="enable_popup">False</property> - - <child> - <widget class="GtkVBox" id="vbox8"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkVBox" id="vbox81"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="label100"> - <property name="visible">True</property> - <property name="label" translatable="yes">The tabs settings let you customize the tabs width.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="tabs_width_hbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label98"> - <property name="visible">True</property> - <property name="label" translatable="yes">Set _tabs width equivalent to </property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">tabs_width_spinbutton</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="tabs_width_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">8 1 24 1 4 8</property> - <accessibility> - <atkrelation target="label98" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label99"> - <property name="visible">True</property> - <property name="label" translatable="yes"> character(s)</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label8"> - <property name="visible">True</property> - <property name="label" translatable="yes">Tabs</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox10"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="label95"> - <property name="visible">True</property> - <property name="label" translatable="yes">The undo settings let you set the maximum number of actions that gedit can undo.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox8"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkCheckButton" id="undo_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Set limit on _undo actions to</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">True</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <accessibility> - <atkrelation target="undo_levels_spinbutton" type="controller-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="undo_levels_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">25 1 250 1 10 10</property> - <accessibility> - <atkrelation target="undo_levels_label" type="labelled-by"/> - <atkrelation target="undo_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="undo_levels_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">action(s)</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <accessibility> - <atkrelation target="undo_levels_spinbutton" type="label-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label9"> - <property name="visible">True</property> - <property name="label" translatable="yes">Undo</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox12"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="label92"> - <property name="visible">True</property> - <property name="label" translatable="yes">The font & colors settings let you choose the font and the colors to be used in the editor windows.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame11"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkVBox" id="vbox13"> - <property name="border_width">5</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">5</property> - - <child> - <widget class="GtkCheckButton" id="default_font_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Use default theme font</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <accessibility> - <atkrelation target="font_label" type="controller-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="font_hbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">5</property> - - <child> - <widget class="GtkLabel" id="font_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Font used by the editor: </property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <accessibility> - <atkrelation target="default_font_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label101"> - <property name="visible">True</property> - <property name="label" translatable="yes">Font</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame12"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkVBox" id="vbox14"> - <property name="border_width">5</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">5</property> - - <child> - <widget class="GtkCheckButton" id="default_colors_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">U_se default theme colors</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <accessibility> - <atkrelation target="label27" type="controller-for"/> - <atkrelation target="label26" type="controller-for"/> - <atkrelation target="label25" type="controller-for"/> - <atkrelation target="label24" type="controller-for"/> - <atkrelation target="selection_colorpicker" type="controller-for"/> - <atkrelation target="sel_text_colorpicker" type="controller-for"/> - <atkrelation target="background_colorpicker" type="controller-for"/> - <atkrelation target="text_colorpicker" type="controller-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="colors_table"> - <property name="visible">True</property> - <property name="n_rows">4</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">5</property> - <property name="column_spacing">5</property> - - <child> - <widget class="GtkLabel" id="label24"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Text color:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">text_colorpicker</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label25"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Background color:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">background_colorpicker</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label26"> - <property name="visible">True</property> - <property name="label" translatable="yes">Selecte_d text color:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">sel_text_colorpicker</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label27"> - <property name="visible">True</property> - <property name="label" translatable="yes">Se_lection color:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">selection_colorpicker</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GnomeColorPicker" id="background_colorpicker"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="dither">True</property> - <property name="use_alpha">False</property> - <property name="title" translatable="yes">Pick the background color</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - <atkrelation target="label25" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - - <child> - <widget class="GnomeColorPicker" id="text_colorpicker"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="dither">True</property> - <property name="use_alpha">False</property> - <property name="title" translatable="yes">Pick the text color</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - <atkrelation target="label24" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - </packing> - </child> - - <child> - <widget class="GnomeColorPicker" id="sel_text_colorpicker"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="dither">True</property> - <property name="use_alpha">False</property> - <property name="title" translatable="yes">Pick the selected text color</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - <atkrelation target="label26" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - - <child> - <widget class="GnomeColorPicker" id="selection_colorpicker"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="dither">True</property> - <property name="use_alpha">False</property> - <property name="title" translatable="yes">Pick the selection color</property> - <accessibility> - <atkrelation target="default_colors_checkbutton" type="controlled-by"/> - <atkrelation target="label27" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label102"> - <property name="visible">True</property> - <property name="label" translatable="yes">Colors</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label19"> - <property name="visible">True</property> - <property name="label" translatable="yes">Fonts & Colors</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table9"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">0</property> - <property name="column_spacing">0</property> - - <child> - <widget class="GtkImage" id="logo_pixmap"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label93"> - <property name="visible">True</property> - <property name="label" translatable="yes">LOGO</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox80"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="label791"> - <property name="visible">True</property> - <property name="label" translatable="yes">The save settings let you customize how gedit saves files.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox10"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkCheckButton" id="backup_copy_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Create a _backup copy of files before saving</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="autosave_hbox"> - <property name="homogeneous">False</property> - <property name="spacing">3</property> - - <child> - <widget class="GtkCheckButton" id="auto_save_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Autosave current file every</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <accessibility> - <atkrelation target="auto_save_spinbutton" type="controller-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="auto_save_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">8 1 100 1 10 10</property> - <accessibility> - <atkrelation target="label97" type="labelled-by"/> - <atkrelation target="auto_save_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label97"> - <property name="visible">True</property> - <property name="label" translatable="yes">minutes</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <accessibility> - <atkrelation target="auto_save_spinbutton" type="label-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="save_frame"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkVBox" id="vbox18"> - <property name="border_width">5</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkRadioButton" id="utf8_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Always use _UTF-8 encoding (faster)</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">True</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <accessibility> - <atkproperty name="AtkObject::accessible_description" translatable="yes">Always use UTF-8 encoding (faster) when saving - -</atkproperty> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="locale_if_possible_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Use current _locale's encoding if possible</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">utf8_radiobutton</property> - <accessibility> - <atkproperty name="AtkObject::accessible_description" translatable="yes">Use current locale's encoding if possible when saving - -</atkproperty> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="original_if_possible_radiobutton"> - <property name="can_focus">True</property> - <property name="label" translatable="yes">U_se original file encoding if possible</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">utf8_radiobutton</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label792"> - <property name="visible">True</property> - <property name="label" translatable="yes">When saving...</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="create_frame"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkVBox" id="vbox182"> - <property name="border_width">5</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkRadioButton" id="create_utf8_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Always use U_TF-8 encoding (faster)</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">True</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <accessibility> - <atkproperty name="AtkObject::accessible_description" translatable="yes">Always use UTF-8 encoding (faster) when creating a new file - -</atkproperty> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="create_locale_if_possible_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Use cu_rrent locale's encoding if possible</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">create_utf8_radiobutton</property> - <accessibility> - <atkproperty name="AtkObject::accessible_description" translatable="yes">Use current locale's encoding if possible when creating a new file - -</atkproperty> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label793"> - <property name="visible">True</property> - <property name="label" translatable="yes">When creating a new file...</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label96"> - <property name="visible">True</property> - <property name="label" translatable="yes">Save</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox74"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="label791"> - <property name="visible">True</property> - <property name="label" translatable="yes">The wrap mode settings let you customize how lines have to be wrapped.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="wrap_mode_frame"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkVBox" id="vbox75"> - <property name="border_width">5</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkRadioButton" id="wrap_never_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Never wrap lines</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="wrap_word_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Wrap lines at _word boundaries</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">wrap_never_radiobutton</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="wrap_char_radiobutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Wrap lines at ch_aracter boundaries</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <property name="group">wrap_never_radiobutton</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label794"> - <property name="visible">True</property> - <property name="label" translatable="yes">Wrap mode</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label72"> - <property name="visible">True</property> - <property name="label" translatable="yes">Wrap mode</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox180"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="labe2791"> - <property name="visible">True</property> - <property name="label" translatable="yes">The print page settings let you customize how gedit prints documents.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox110"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkCheckButton" id="add_header_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Print _page headers</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox113"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkCheckButton" id="wrap_lines_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes"> _Wrap lines (at character boundaries)</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="line_numbers_hbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">3</property> - - <child> - <widget class="GtkCheckButton" id="line_numbers_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Print _line numbers every</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - <accessibility> - <atkrelation target="line_numbers_spinbutton" type="controller-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="line_numbers_spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">True</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">1 1 500 1 10 10</property> - <accessibility> - <atkrelation target="label67" type="labelled-by"/> - <atkrelation target="line_numbers_checkbutton" type="controlled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label67"> - <property name="visible">True</property> - <property name="label" translatable="yes"> line(s)</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <accessibility> - <atkrelation target="line_numbers_spinbutton" type="label-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label96"> - <property name="visible">True</property> - <property name="label" translatable="yes">Print</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="line_numbers_page"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="labe2791"> - <property name="visible">True</property> - <property name="label" translatable="yes">The line numbers setting lets you choose to display the line numbers on the left hand side of the window.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="ln_hbox"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkCheckButton" id="display_line_numbers_checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Display line numbers</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="ln_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Line numbers</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="print_fonts"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="labepf2791"> - <property name="visible">True</property> - <property name="label" translatable="yes">The print fonts settings let you choose the fonts to be used to print documents.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="print_fonts_table"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">1</property> - <property name="homogeneous">False</property> - <property name="row_spacing">5</property> - <property name="column_spacing">5</property> - - <child> - <widget class="GtkLabel" id="body_font_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Font used to print the _body:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="headers_font_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Font used to print headers:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="numbers_font_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Font used to print line _numbers:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHButtonBox" id="bbox"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkButton" id="restore_default_fonts_button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Restore default fonts</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="pf_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Print fonts</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="plugin_manager_page"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child> - <widget class="GtkLabel" id="labelpm1234"> - <property name="visible">True</property> - <property name="label" translatable="yes">The plugin manager settings let you choose which plugins you want to have loaded.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="pm_label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Plugin manager</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/gedit/dialogs/gnome-print-font-dialog.c b/gedit/dialogs/gnome-print-font-dialog.c deleted file mode 100644 index 074678862..000000000 --- a/gedit/dialogs/gnome-print-font-dialog.c +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gnome-print-font-dialog.c - * This file is part of gedit - * - * Copyright (C) 2001-2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <string.h> - -#include <gtk/gtkdialog.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbbox.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkentry.h> -#include <gtk/gtklabel.h> -#include "gedit2.h" -#include "gedit-utils.h" - -#include <libgnome/gnome-i18n.h> - -#include <gnome-print-font-dialog.h> - -struct _GnomePrintFontDialog { - GtkDialog dialog; - - GtkWidget *fontsel; - GtkWidget *preview; -}; - -struct _GnomePrintFontDialogClass { - GtkDialogClass parent_class; -}; - -static void gnome_print_font_dialog_class_init (GnomePrintFontDialogClass *klass); -static void gnome_print_font_dialog_init (GnomePrintFontDialog *fontseldiag); - -static void gfsd_update_preview (GnomeFontSelection * fs, GnomeFont * font, GnomePrintFontDialog * gfsd); - -static GtkDialogClass *gfsd_parent_class = NULL; - -GType -gnome_print_font_dialog_get_type (void) -{ - static GType font_dialog_type = 0; - - if (!font_dialog_type) - { - static const GTypeInfo dialog_info = - { - sizeof (GnomePrintFontDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gnome_print_font_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GnomePrintFontDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gnome_print_font_dialog_init - }; - - font_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, - "GnomePrintFontDialog", - &dialog_info, - 0); - } - - return font_dialog_type; - -} -static void -gfsd_modify_preview_phrase (GtkButton *button, GnomePrintFontDialog *fontseldiag) -{ - GtkWidget *dialog; - GtkWidget *label; - GtkWidget *entry; - GtkWidget *vbox; - - vbox = gtk_vbox_new (FALSE, 6); - entry = gtk_entry_new(); - - gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); - - label = gtk_label_new_with_mnemonic (_("_Insert a new preview phrase.")); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); - gedit_utils_set_atk_relation (entry, label, ATK_RELATION_LABELLED_BY); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - g_object_set (G_OBJECT (label), "xalign", 0.0, "yalign", 0.5, NULL); - - dialog = gtk_dialog_new_with_buttons (_("Modify preview phrase..."), - GTK_WINDOW (fontseldiag), - GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0); - - gtk_widget_show_all (vbox); - - gtk_widget_grab_focus (entry); - - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) - { - if (strlen (gtk_entry_get_text (GTK_ENTRY (entry))) > 0) - gnome_font_preview_set_phrase ( - GNOME_FONT_PREVIEW (fontseldiag->preview), - gtk_entry_get_text (GTK_ENTRY (entry))); - } - - gtk_widget_destroy (dialog); -} - - -static void -gnome_print_font_dialog_class_init (GnomePrintFontDialogClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - gfsd_parent_class = gtk_type_class (GTK_TYPE_DIALOG); -} - -static GtkWidget* -gnome_print_font_dialog_create_preview_frame (GnomePrintFontDialog *fontseldiag) -{ - GtkWidget *frame; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *button; - - frame = gtk_frame_new (_("Preview")); - vbox = gtk_vbox_new (FALSE, 6); - bbox = gtk_hbutton_box_new (); - - gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - - fontseldiag->preview = gnome_font_preview_new (); - gtk_box_pack_start (GTK_BOX (vbox), fontseldiag->preview, TRUE, TRUE, 0); - - - gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), - GTK_BUTTONBOX_END); - - button = gtk_button_new_with_mnemonic (_("_Modify preview phrase...")); - gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, TRUE, 0); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (gfsd_modify_preview_phrase), fontseldiag); - - gtk_box_pack_end (GTK_BOX (vbox), bbox, FALSE, TRUE, 0); - - gtk_container_add (GTK_CONTAINER (frame), vbox); - - return frame; -} - -static void -gnome_print_font_dialog_init (GnomePrintFontDialog *fontseldiag) -{ - GnomeFont *font; - GtkWidget *vbox; - GtkWidget *preview_frame; - - gtk_widget_set_size_request (GTK_WIDGET (fontseldiag), 450, 300); - - gtk_dialog_add_button (GTK_DIALOG (fontseldiag), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (GTK_DIALOG (fontseldiag), GTK_STOCK_OK, GTK_RESPONSE_OK); - - gtk_dialog_set_default_response (GTK_DIALOG (fontseldiag), GTK_RESPONSE_CANCEL); - - gtk_container_set_border_width (GTK_CONTAINER (fontseldiag), 4); - - gtk_window_set_resizable (GTK_WINDOW (fontseldiag), FALSE); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); - - fontseldiag->fontsel = gnome_font_selection_new (); - preview_frame = gnome_print_font_dialog_create_preview_frame (fontseldiag); - - gedit_utils_set_atk_relation (preview_frame, fontseldiag->fontsel, - ATK_RELATION_CONTROLLED_BY); - gedit_utils_set_atk_relation (fontseldiag->fontsel, preview_frame, - ATK_RELATION_CONTROLLER_FOR); - - gtk_box_pack_start (GTK_BOX (vbox), fontseldiag->fontsel, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), preview_frame, TRUE, TRUE, 0); - - font = gnome_font_selection_get_font (GNOME_FONT_SELECTION (fontseldiag->fontsel)); - gnome_font_preview_set_font (GNOME_FONT_PREVIEW (fontseldiag->preview), font); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (fontseldiag)->vbox), vbox, TRUE, TRUE, 0); - - g_signal_connect (G_OBJECT (fontseldiag->fontsel), "font_set", - G_CALLBACK (gfsd_update_preview), fontseldiag); - - gtk_widget_show_all (vbox); -} - -GtkWidget* -gnome_print_font_dialog_new (const gchar *title) -{ - GnomePrintFontDialog *fontseldiag; - - fontseldiag = g_object_new (GNOME_PRINT_TYPE_FONT_DIALOG, NULL); - - gtk_window_set_title (GTK_WINDOW (fontseldiag), title ? title : _("Font Selection")); - - return GTK_WIDGET (fontseldiag); -} - -GtkWidget * -gnome_print_font_dialog_get_fontsel (GnomePrintFontDialog *gfsd) -{ - g_return_val_if_fail (gfsd != NULL, NULL); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_DIALOG (gfsd), NULL); - - return gfsd->fontsel; -} - -GtkWidget * -gnome_print_font_dialog_get_preview (GnomePrintFontDialog *gfsd) -{ - g_return_val_if_fail (gfsd != NULL, NULL); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_DIALOG (gfsd), NULL); - - return gfsd->preview; -} - -static void -gfsd_update_preview (GnomeFontSelection * fs, GnomeFont * font, GnomePrintFontDialog * gfsd) -{ - gnome_font_preview_set_font ((GnomeFontPreview *) gfsd->preview, font); -} - diff --git a/gedit/dialogs/gnome-print-font-dialog.h b/gedit/dialogs/gnome-print-font-dialog.h deleted file mode 100644 index 617d9bea2..000000000 --- a/gedit/dialogs/gnome-print-font-dialog.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gnome-print-font-dialog.h - * This file is part of gedit - * - * Copyright (C) 2001-2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GNOME_PRINT_FONT_DIALOG_H__ -#define __GNOME_PRINT_FONT_DIALOG_H__ - -#include <libgnomeprintui/gnome-font-dialog.h> - -#define GNOME_PRINT_TYPE_FONT_DIALOG (gnome_print_font_dialog_get_type ()) -#define GNOME_PRINT_FONT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNOME_PRINT_TYPE_FONT_DIALOG, GnomePrintFontDialog)) -#define GNOME_PRINT_FONT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GNOME_PRINT_TYPE_FONT_DIALOG, GnomePrintFontDialogClass)) -#define GNOME_PRINT_IS_FONT_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNOME_PRINT_TYPE_FONT_DIALOG)) -#define GNOME_PRINT_IS_FONT_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNOME_PRINT_TYPE_FONT_DIALOG)) -#define GNOME_PRINT_FONT_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNOME_PRINT_TYPE_FONT_DIALOG, GnomePrintFontDialogClass)) - -typedef struct _GnomePrintFontDialog GnomePrintFontDialog; -typedef struct _GnomePrintFontDialogClass GnomePrintFontDialogClass; - -GType gnome_print_font_dialog_get_type (void); - -GtkWidget *gnome_print_font_dialog_new (const gchar *title); - -GtkWidget *gnome_print_font_dialog_get_fontsel (GnomePrintFontDialog *gfsd); - -GtkWidget *gnome_print_font_dialog_get_preview (GnomePrintFontDialog *gfsd); - -#endif /* __GNOME_PRINT_FONT_DIALOG_H__ */ - diff --git a/gedit/dialogs/gnome-print-font-picker.c b/gedit/dialogs/gnome-print-font-picker.c deleted file mode 100644 index 4594f1c2a..000000000 --- a/gedit/dialogs/gnome-print-font-picker.c +++ /dev/null @@ -1,1088 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gnome-print-font-picker.c - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * This widget is based on GnomeFontPicker - */ - -/* GNOME font picker button. - * Copyright (C) 1998 David Abilleira Freijeiro <odaf@nexo.es> - * All rights reserved. - * - * Based on gnome-color-picker by Federico Mena <federico@nuclecu.unam.mx> - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <config.h> -#include <libgnome/gnome-macros.h> - -/* Must be before all other gnome includes!! */ -#include <libgnome/gnome-i18n.h> - -#include <gtk/gtksignal.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkalignment.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkvseparator.h> -#include <gtk/gtkfontsel.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkstock.h> - -#include <gnome-print-font-dialog.h> -/* -#include "gnometypebuiltins.h" -*/ - -#include "gnome-print-font-picker.h" - -#include <string.h> -#include <stdio.h> - -struct _GnomePrintFontPickerPrivate { - gchar *title; - - gchar *font_name; - GnomeFont *font; - - gchar *preview_text; - - int use_font_in_label_size; - - GnomePrintFontPickerMode mode : 2; - - /* Only for GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO */ - gboolean use_font_in_label : 1; - gboolean show_size : 1; - - GtkWidget *font_dialog; - GtkWidget *inside; - GtkWidget *font_label, *vsep, *size_label; -}; - - -#define DEF_FONT_NAME N_("sans 12") -#define DEF_PREVIEW_TEXT N_("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz") -#define DEF_TITLE N_("Pick a Font") - -/* Signals */ -enum { - FONT_SET, - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_TITLE, - PROP_MODE, - PROP_FONT_NAME, - PROP_PREVIEW_TEXT, - PROP_USE_FONT_IN_LABEL, - PROP_LABEL_FONT_SIZE, - PROP_SHOW_SIZE, - PROP_FONT -}; - -/* Prototypes */ -static void gnome_print_font_picker_destroy (GtkObject *object); -static void gnome_print_font_picker_finalize (GObject *object); -static void gnome_print_font_picker_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void gnome_print_font_picker_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); - -static void gnome_print_font_picker_clicked (GtkButton *button); - -/* Dialog response functions */ -static void gnome_print_font_picker_dialog_ok_clicked (GtkWidget *widget, - gpointer data); -static void gnome_print_font_picker_dialog_cancel_clicked (GtkWidget *widget, - gpointer data); - -static gboolean gnome_print_font_picker_dialog_delete_event (GtkWidget *widget, - GdkEventAny *ev, - gpointer data); -static void gnome_print_font_picker_dialog_destroy (GtkWidget *widget, - gpointer data); - -/* Auxiliary functions */ -static GtkWidget *gnome_print_font_picker_create_inside (GnomePrintFontPicker *gfs); - -static void gnome_print_font_picker_label_use_font_in_label (GnomePrintFontPicker *gfs); -static void gnome_print_font_picker_update_font_info (GnomePrintFontPicker *gfs); - - - - -static guint font_picker_signals[LAST_SIGNAL] = { 0 }; - -GNOME_CLASS_BOILERPLATE (GnomePrintFontPicker, gnome_print_font_picker, - GtkButton, GTK_TYPE_BUTTON) - -static void -gnome_print_font_picker_class_init (GnomePrintFontPickerClass *class) -{ - GtkObjectClass *object_class; - GObjectClass *gobject_class; - GtkButtonClass *button_class; - - object_class = (GtkObjectClass *) class; - gobject_class = (GObjectClass *) class; - button_class = (GtkButtonClass *) class; - - object_class->destroy = gnome_print_font_picker_destroy; - - gobject_class->finalize = gnome_print_font_picker_finalize; - gobject_class->set_property = gnome_print_font_picker_set_property; - gobject_class->get_property = gnome_print_font_picker_get_property; - - button_class->clicked = gnome_print_font_picker_clicked; - - class->font_set = NULL; - - g_object_class_install_property - (gobject_class, - PROP_TITLE, - g_param_spec_string ("title", - _("Title"), - _("The title of the selection dialog box"), - _(DEF_TITLE), - (G_PARAM_READABLE | - G_PARAM_WRITABLE))); -/* - g_object_class_install_property - (gobject_class, - PROP_MODE, - g_param_spec_enum ("mode", - _("Mode"), - _("The mode of operation of the font picker"), - GnomePrintFontPickerMode, - GNOME_PRINT_FONT_PICKER_MODE_PIXMAP, - (G_PARAM_READABLE | - G_PARAM_WRITABLE))); - */ - g_object_class_install_property - (gobject_class, - PROP_FONT_NAME, - g_param_spec_string ("font_name", - _("Font name"), - _("Name of the selected font"), - _(DEF_FONT_NAME), - (G_PARAM_READABLE | - G_PARAM_WRITABLE))); - g_object_class_install_property - (gobject_class, - PROP_PREVIEW_TEXT, - g_param_spec_string ("preview_text", - _("Preview text"), - _("Preview text shown in the dialog"), - _(DEF_PREVIEW_TEXT), - (G_PARAM_READABLE | - G_PARAM_WRITABLE))); - g_object_class_install_property - (gobject_class, - PROP_USE_FONT_IN_LABEL, - g_param_spec_boolean ("use-font-in-label", - _("Use font in label"), - _("Use font in the label in font info mode"), - FALSE, - (G_PARAM_READABLE | - G_PARAM_WRITABLE))); - g_object_class_install_property - (gobject_class, - PROP_LABEL_FONT_SIZE, - g_param_spec_int ("label-font-size", - _("Font size for label"), - _("Font size for label in font info mode"), - 8 /* min */, - 72 /* max */, - 14 /* default */, - (G_PARAM_READABLE | - G_PARAM_WRITABLE))); - g_object_class_install_property - (gobject_class, - PROP_SHOW_SIZE, - g_param_spec_boolean ("show-size", - _("Show size"), - _("Show size in font info mode"), - TRUE, - (G_PARAM_READABLE | - G_PARAM_WRITABLE))); - - font_picker_signals[FONT_SET] = - g_signal_new ("font_set", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GnomePrintFontPickerClass, font_set), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - -} - -static void -gnome_print_font_picker_instance_init (GnomePrintFontPicker *gfp) -{ - - gfp->_priv = g_new0(GnomePrintFontPickerPrivate, 1); - - /* Initialize fields */ - gfp->_priv->mode = GNOME_PRINT_FONT_PICKER_MODE_PIXMAP; - gfp->_priv->font_name = NULL; - gfp->_priv->preview_text = NULL; - gfp->_priv->use_font_in_label = FALSE; - gfp->_priv->use_font_in_label_size = 14; - gfp->_priv->show_size = TRUE; - gfp->_priv->font_dialog = NULL; - gfp->_priv->title = g_strdup(_(DEF_TITLE)); - - - /* Create pixmap or info widgets */ - gfp->_priv->inside = gnome_print_font_picker_create_inside(gfp); - if (gfp->_priv->inside) - gtk_container_add(GTK_CONTAINER(gfp), gfp->_priv->inside); - - gnome_print_font_picker_set_font_name(gfp, _(DEF_FONT_NAME)); - gnome_print_font_picker_set_preview_text(gfp, _(DEF_PREVIEW_TEXT)); - - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO) { - /* Update */ - gnome_print_font_picker_update_font_info(gfp); - } -} - -static void -gnome_print_font_picker_destroy (GtkObject *object) -{ - GnomePrintFontPicker *gfp; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (object)); - - /* remember, destroy can be run multiple times! */ - - gfp = GNOME_PRINT_FONT_PICKER (object); - - if (gfp->_priv->font_dialog != NULL) { - gtk_widget_destroy (gfp->_priv->font_dialog); - gfp->_priv->font_dialog = NULL; - } - - GNOME_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); - -} /* gnome_print_font_picker_destroy */ - -static void -gnome_print_font_picker_finalize (GObject *object) -{ - GnomePrintFontPicker *gfp; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (object)); - - gfp = GNOME_PRINT_FONT_PICKER(object); - - /* g_free handles NULL */ - g_free(gfp->_priv->font_name); - gfp->_priv->font_name = NULL; - - g_object_unref (gfp->_priv->font); - gfp->_priv->font = NULL; - - /* g_free handles NULL */ - g_free(gfp->_priv->preview_text); - gfp->_priv->preview_text = NULL; - - /* g_free handles NULL */ - g_free(gfp->_priv->title); - gfp->_priv->title = NULL; - - /* g_free handles NULL */ - g_free(gfp->_priv); - gfp->_priv = NULL; - - GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); - -} /* gnome_print_font_picker_finalize */ - -static void -gnome_print_font_picker_set_property (GObject *object, - guint param_id, - const GValue * value, - GParamSpec * pspec) -{ - GnomePrintFontPicker *self; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (object)); - - self = GNOME_PRINT_FONT_PICKER (object); - - switch (param_id) { - case PROP_TITLE: - gnome_print_font_picker_set_title (self, g_value_get_string (value)); - break; - case PROP_MODE: - gnome_print_font_picker_set_mode (self, g_value_get_enum (value)); - break; - case PROP_FONT_NAME: - gnome_print_font_picker_set_font_name (self, - g_value_get_string (value)); - break; - case PROP_PREVIEW_TEXT: - gnome_print_font_picker_set_preview_text - (self, g_value_get_string (value)); - break; - case PROP_USE_FONT_IN_LABEL: - gnome_print_font_picker_fi_set_use_font_in_label - (self, g_value_get_boolean (value), - self->_priv->use_font_in_label_size); - break; - case PROP_LABEL_FONT_SIZE: - gnome_print_font_picker_fi_set_use_font_in_label - (self, - self->_priv->use_font_in_label, - g_value_get_int (value)); - break; - case PROP_SHOW_SIZE: - gnome_print_font_picker_fi_set_show_size - (self, g_value_get_boolean (value)); - break; - - default: - break; - } -} /* gnome_print_font_picker_set_property */ - -static void -gnome_print_font_picker_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec * pspec) -{ - GnomePrintFontPicker *self; - - g_return_if_fail (object != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (object)); - - self = GNOME_PRINT_FONT_PICKER (object); - - switch (param_id) { - case PROP_TITLE: - g_value_set_string (value, gnome_print_font_picker_get_title (self)); - break; - case PROP_MODE: - g_value_set_string (value, gnome_print_font_picker_get_title (self)); - break; - case PROP_FONT_NAME: - g_value_set_string (value, - gnome_print_font_picker_get_font_name (self)); - break; - case PROP_PREVIEW_TEXT: - g_value_set_string (value, - gnome_print_font_picker_get_preview_text (self)); - break; - case PROP_USE_FONT_IN_LABEL: - g_value_set_boolean (value, - self->_priv->use_font_in_label); - break; - case PROP_LABEL_FONT_SIZE: - g_value_set_int (value, - self->_priv->use_font_in_label_size); - break; - case PROP_SHOW_SIZE: - g_value_set_boolean (value, - self->_priv->show_size); - break; - - default: - break; - } -} /* gnome_print_font_picker_get_property */ - -/************************************************************************* - Public functions - *************************************************************************/ - - -/** - * gnome_print_font_picker_new - * - * Description: - * Create new font picker widget. - * - * Returns: - * Pointer to new font picker widget. - */ - -GtkWidget * -gnome_print_font_picker_new (void) -{ - return g_object_new (GNOME_PRINT_TYPE_FONT_PICKER, NULL); -} /* gnome_print_font_picker_new */ - - - -/** - * gnome_print_font_picker_set_title - * @gfp: Pointer to GNOME font picker widget. - * @title: String containing font selection dialog title. - * - * Description: - * Sets the title for the font selection dialog. If @title is %NULL, - * then the default is used. - */ - -void -gnome_print_font_picker_set_title (GnomePrintFontPicker *gfp, const gchar *title) -{ - g_return_if_fail (gfp != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp)); - - if ( ! title) - title = _(DEF_TITLE); - - /* g_free handles NULL */ - g_free (gfp->_priv->title); - gfp->_priv->title = g_strdup (title); - - /* If FontDialog is created change title */ - if (gfp->_priv->font_dialog) - gtk_window_set_title(GTK_WINDOW(gfp->_priv->font_dialog), - gfp->_priv->title); -} /* gnome_print_font_picker_set_title */ - -/** - * gnome_print_font_picker_get_title - * @gfp: Pointer to GNOME font picker widget. - * - * Description: - * Retrieve name of the font selection dialog title - * - * Returns: - * Pointer to an internal copy of the title string - */ - -const gchar* -gnome_print_font_picker_get_title(GnomePrintFontPicker *gfp) -{ - g_return_val_if_fail (gfp != NULL, NULL); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp), NULL); - - return gfp->_priv->title; -} /* gnome_print_font_picker_get_title */ - -/** - * gnome_print_font_picker_get_mode - * @gfp: Pointer to GNOME font picker widget. - * - * Description: - * Returns current font picker button mode (or what to show). Possible - * values include %GNOME_PRINT_FONT_PICKER_MODE_PIXMAP, - * %GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO, and - * %GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET. - * - * Returns: - * Button mode currently set in font picker widget, or - * %GNOME_PRINT_FONT_PICKER_MODE_UNKNOWN on error. - */ - -GnomePrintFontPickerMode -gnome_print_font_picker_get_mode (GnomePrintFontPicker *gfp) -{ - g_return_val_if_fail (gfp != NULL, GNOME_PRINT_FONT_PICKER_MODE_UNKNOWN); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp), - GNOME_PRINT_FONT_PICKER_MODE_UNKNOWN); - - return gfp->_priv->mode; -} /* gnome_print_font_picker_get_mode */ - - -/** - * gnome_print_font_picker_set_mode - * @gfp: Pointer to GNOME font picker widget. - * @mode: Value of subsequent font picker button mode (or what to show) - * - * Description: - * Set value of subsequent font picker button mode (or what to show). - */ - -void gnome_print_font_picker_set_mode (GnomePrintFontPicker *gfp, - GnomePrintFontPickerMode mode) -{ - g_return_if_fail (gfp != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp)); - g_return_if_fail (mode >= 0 && mode < GNOME_PRINT_FONT_PICKER_MODE_UNKNOWN); - - if (gfp->_priv->mode != mode) { - - gfp->_priv->mode = mode; - - /* Next sentence will destroy gfp->_priv->inside after removing it */ - gtk_container_remove(GTK_CONTAINER(gfp), gfp->_priv->inside); - gfp->_priv->inside = gnome_print_font_picker_create_inside(gfp); - if (gfp->_priv->inside) - gtk_container_add(GTK_CONTAINER(gfp), gfp->_priv->inside); - - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO) { - /* Update */ - gnome_print_font_picker_update_font_info(gfp); - } - } -} /* gnome_print_font_picker_set_mode */ - - -/** - * gnome_print_font_picker_fi_set_use_font_in_label - * @gfp: Pointer to GNOME font picker widget. - * @use_font_in_label: If %TRUE, font name will be written using font chosen. - * @size: Display font using this point size. - * - * Description: - * If @use_font_in_label is %TRUE, font name will be written using font chosen - * by user and using @size passed to this function. This only applies if - * current button mode is %GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO. - */ - -void gnome_print_font_picker_fi_set_use_font_in_label (GnomePrintFontPicker *gfp, - gboolean use_font_in_label, - gint size) -{ - gboolean old_use_font_in_label; - int old_size; - - g_return_if_fail (gfp != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp)); - - old_use_font_in_label = gfp->_priv->use_font_in_label; - old_size = gfp->_priv->use_font_in_label_size; - gfp->_priv->use_font_in_label = use_font_in_label; - gfp->_priv->use_font_in_label_size = size; - - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO && - (old_use_font_in_label != use_font_in_label || - old_size != size)) { - if (gfp->_priv->use_font_in_label) - gnome_print_font_picker_label_use_font_in_label (gfp); - else - gtk_widget_set_style (gfp->_priv->font_label, NULL); - } -} /* gnome_print_font_picker_fi_set_use_font_in_label */ - - -/** - * gnome_print_font_picker_fi_set_show_size - * @gfp: Pointer to GNOME font picker widget. - * @show_size: %TRUE if font size should be displayed in dialog. - * - * Description: - * If @show_size is %TRUE, font size will be displayed along with font chosen - * by user. This only applies if current button mode is - * %GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO. - */ - -void -gnome_print_font_picker_fi_set_show_size (GnomePrintFontPicker *gfp, - gboolean show_size) -{ - gboolean old_show_size; - - g_return_if_fail (gfp != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp)); - - /* Make sure it's normalized to 1/0 */ - old_show_size = gfp->_priv->show_size ? 1 : 0; - gfp->_priv->show_size = show_size ? 1 : 0; - - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO && - old_show_size != gfp->_priv->show_size) { - /* Next sentence will destroy gfp->_priv->inside - * after removing it */ - if (gfp->_priv->inside != NULL) - gtk_container_remove (GTK_CONTAINER (gfp), - gfp->_priv->inside); - - gfp->_priv->inside = gnome_print_font_picker_create_inside (gfp); - if (gfp->_priv->inside != NULL) - gtk_container_add (GTK_CONTAINER (gfp), - gfp->_priv->inside); - - gnome_print_font_picker_update_font_info (gfp); - } -} /* gnome_print_font_picker_fi_set_show_size */ - - -/** - * gnome_print_font_picker_uw_set_widget - * @gfp: Pointer to GNOME font picker widget. - * @widget: User widget to display for inside of font picker. - * - * Set the user-supplied @widget as the inside of the font picker. - * This only applies with GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET. - */ - -void -gnome_print_font_picker_uw_set_widget (GnomePrintFontPicker *gfp, - GtkWidget *widget) -{ - g_return_if_fail (gfp != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp)); - - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET && - gfp->_priv->inside != widget) { - if (gfp->_priv->inside != NULL) - gtk_container_remove (GTK_CONTAINER (gfp), - gfp->_priv->inside); - - gfp->_priv->inside = widget; - if (gfp->_priv->inside != NULL) - gtk_container_add (GTK_CONTAINER (gfp), - gfp->_priv->inside); - } - -} /* gnome_print_font_picker_uw_set_widget */ - -/** - * gnome_print_font_picker_uw_get_widget - * @gfp: Pointer to GNOME font picker widget. - * - * Get the user-supplied widget inside of the font picker. - * This only applies with GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET. - * - * Returns: a #GtkWidget, or %NULL if - * not in GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET mode - */ - -GtkWidget * -gnome_print_font_picker_uw_get_widget (GnomePrintFontPicker *gfp) -{ - g_return_val_if_fail (gfp != NULL, NULL); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp), NULL); - - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET) { - return gfp->_priv->inside; - } else { - return NULL; - } -} /* gnome_print_font_picker_uw_set_widget */ - -/** - * gnome_print_font_picker_get_font_name - * @gfp: Pointer to GNOME font picker widget. - * - * Description: - * Retrieve name of font from font selection dialog. - * - * Returns: - * Pointer to an internal copy of the font name. - */ - -const gchar* gnome_print_font_picker_get_font_name (GnomePrintFontPicker *gfp) -{ - g_return_val_if_fail (gfp != NULL, NULL); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp), NULL); - - if (gfp->_priv->font_dialog) { - /* g_free handles NULL */ - GnomeFont *font; - GtkWidget *font_sel; - - g_free (gfp->_priv->font_name); - - if (gfp->_priv->font) - g_object_unref (gfp->_priv->font); - - font_sel = gnome_print_font_dialog_get_fontsel (GNOME_PRINT_FONT_DIALOG (gfp->_priv->font_dialog)); - font = gnome_font_selection_get_font (GNOME_FONT_SELECTION (font_sel)); - - gfp->_priv->font_name = g_strdup (gnome_font_get_full_name (font)); - gfp->_priv->font = font; - } - - return gfp->_priv->font_name; -} /* gnome_print_font_picker_get_font_name */ - - -/** - * gnome_print_font_picker_set_font_name - * @gfp: Pointer to GNOME font picker widget. - * @fontname: Name of font to display in font selection dialog - * - * Description: - * Set or update currently-displayed font in font picker dialog. - * - * Returns: - * Return value of gtk_font_selection_dialog_set_font_name if the - * font selection dialog exists, otherwise %FALSE. - */ - -gboolean gnome_print_font_picker_set_font_name (GnomePrintFontPicker *gfp, - const gchar *fontname) -{ - g_return_val_if_fail (gfp != NULL, FALSE); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp), FALSE); - g_return_val_if_fail (fontname != NULL, FALSE); - - if (gfp->_priv->font_name != fontname) { - g_free(gfp->_priv->font_name); - gfp->_priv->font_name = g_strdup (fontname); - - if (gfp->_priv->font != NULL) - g_object_unref (gfp->_priv->font); - - gfp->_priv->font = gnome_font_find_closest_from_full_name (fontname); - } - - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO) - gnome_print_font_picker_update_font_info (gfp); - - if (gfp->_priv->font_dialog) - { - GtkWidget *font_sel; - - font_sel = gnome_print_font_dialog_get_fontsel (GNOME_PRINT_FONT_DIALOG (gfp->_priv->font_dialog)); - gnome_font_selection_set_font (GNOME_FONT_SELECTION (font_sel), gfp->_priv->font); - - return TRUE; - } - else - return FALSE; -} /* gnome_print_font_picker_set_font_name */ - - -/** - * gnome_print_font_picker_get_preview_text - * @gfp: Pointer to GNOME font picker widget. - * - * Description: - * Retrieve preview text from font selection dialog if available. - * - * Returns: - * Reference to internal copy of preview text string, or %NULL if no - * font dialog is being displayed. - */ - -const gchar* gnome_print_font_picker_get_preview_text (GnomePrintFontPicker *gfp) -{ - g_return_val_if_fail (gfp != NULL, NULL); - g_return_val_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp), NULL); - - if (gfp->_priv->font_dialog) { - /* g_free handles NULL */ - g_free (gfp->_priv->preview_text); - /* FIXME */ - gfp->_priv->preview_text = g_strdup (DEF_PREVIEW_TEXT); - } - - return gfp->_priv->preview_text; - -} /* gnome_print_font_picker_get_preview_text */ - - -/** - * gnome_print_font_picker_set_preview_text - * @gfp: Pointer to GNOME font picker widget. - * @text: New preview text - * - * Description: - * Set preview text in font picker, and in font selection dialog if one - * is being displayed. - */ - -void gnome_print_font_picker_set_preview_text (GnomePrintFontPicker *gfp, - const gchar *text) -{ - g_return_if_fail (gfp != NULL); - g_return_if_fail (GNOME_PRINT_IS_FONT_PICKER (gfp)); - g_return_if_fail (text != NULL); - - if (gfp->_priv->preview_text != text) { - g_free(gfp->_priv->preview_text); - gfp->_priv->preview_text = g_strdup (text); - } - - if (gfp->_priv->font_dialog) - { - GtkWidget *preview; - - preview = gnome_print_font_dialog_get_preview (GNOME_PRINT_FONT_DIALOG (gfp->_priv->font_dialog)); - - gnome_font_preview_set_phrase (GNOME_FONT_PREVIEW (preview), gfp->_priv->preview_text);; - } - -} /* gnome_print_font_picker_set_preview_text */ - -/* ************************************************************************ - Internal functions - **************************************************************************/ -static void -gnome_print_font_dialog_response_handler (GtkWidget *dialog, - gint response_id, gpointer data) -{ - switch (response_id) { - case GTK_RESPONSE_OK: - gnome_print_font_picker_dialog_ok_clicked (NULL, data); - case GTK_RESPONSE_CANCEL: - gnome_print_font_picker_dialog_cancel_clicked (NULL, data); - default: - gnome_print_font_picker_dialog_delete_event (NULL, NULL, data); - } - -} - -static void -gnome_print_font_picker_clicked (GtkButton *button) -{ - GnomePrintFontPicker *gfp; - GnomePrintFontDialog *fsd; - - gfp = GNOME_PRINT_FONT_PICKER(button); - - if (!gfp->_priv->font_dialog) { - GtkWidget *parent; - - parent = gtk_widget_get_toplevel (GTK_WIDGET (gfp)); - - gfp->_priv->font_dialog = gnome_print_font_dialog_new (gfp->_priv->title); - - if (parent) - gtk_window_set_transient_for(GTK_WINDOW(gfp->_priv->font_dialog), - GTK_WINDOW(parent)); - - fsd = GNOME_PRINT_FONT_DIALOG (gfp->_priv->font_dialog); - - /* If there is a grabed window, set new dialog as modal */ - if (gtk_grab_get_current()) - gtk_window_set_modal(GTK_WINDOW(gfp->_priv->font_dialog), TRUE); - - g_signal_connect(fsd, "response", - G_CALLBACK (gnome_print_font_dialog_response_handler), - gfp); -/* - g_signal_connect(fsd->ok_button, "clicked", - G_CALLBACK (gnome_print_font_picker_dialog_ok_clicked), - gfp); - - g_signal_connect(fsd->cancel_button, "clicked", - G_CALLBACK (gnome_print_font_picker_dialog_cancel_clicked), - gfp); - g_signal_connect(fsd,"delete_event", - G_CALLBACK (gnome_print_font_picker_dialog_delete_event), - gfp); -*/ - g_signal_connect(fsd, "destroy", - G_CALLBACK (gnome_print_font_picker_dialog_destroy), - gfp); - } /* if */ - - if (!GTK_WIDGET_VISIBLE(gfp->_priv->font_dialog)) { - - /* Set font and preview text */ - GtkWidget *font_sel; - GtkWidget *preview; - - font_sel = gnome_print_font_dialog_get_fontsel (GNOME_PRINT_FONT_DIALOG (gfp->_priv->font_dialog)); - gnome_font_selection_set_font (GNOME_FONT_SELECTION (font_sel), gfp->_priv->font); - - preview = gnome_print_font_dialog_get_preview (GNOME_PRINT_FONT_DIALOG (gfp->_priv->font_dialog)); - - gnome_font_preview_set_phrase (GNOME_FONT_PREVIEW (preview), gfp->_priv->preview_text);; - - gtk_widget_show(gfp->_priv->font_dialog); - } else if (gfp->_priv->font_dialog->window) { - /*raise the window so that if it is obscured that we see it*/ - gdk_window_raise(gfp->_priv->font_dialog->window); - }/* if */ -} /* gnome_print_font_picker_clicked */ - -static void -gnome_print_font_picker_dialog_ok_clicked(GtkWidget *widget, - gpointer data) -{ - GnomePrintFontPicker *gfp; - - gfp = GNOME_PRINT_FONT_PICKER (data); - - gtk_widget_hide(gfp->_priv->font_dialog); - - /* These calls will update gfp->_priv->font_name and gfp->_priv->preview_text */ - gnome_print_font_picker_get_font_name(gfp); - gnome_print_font_picker_get_preview_text(gfp); - - /* Set label font */ - if (gfp->_priv->mode == GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO) - gnome_print_font_picker_update_font_info(gfp); - - /* Emit font_set signal */ - g_signal_emit(gfp, font_picker_signals[FONT_SET], 0, - gfp->_priv->font_name); - -} /* gnome_print_font_picker_dialog_ok_clicked */ - - -static void -gnome_print_font_picker_dialog_cancel_clicked(GtkWidget *widget, - gpointer data) -{ - GnomePrintFontPicker *gfp; - - gfp = GNOME_PRINT_FONT_PICKER (data); - - gtk_widget_hide(gfp->_priv->font_dialog); - - /* FIXME: is this necessary? bug #67587 */ - /* Restore old values */ - gnome_print_font_picker_set_font_name(gfp,gfp->_priv->font_name); - gnome_print_font_picker_set_preview_text(gfp,gfp->_priv->preview_text); - -} /* gnome_print_font_picker_dialog_cancel_clicked */ - -static gboolean -gnome_print_font_picker_dialog_delete_event(GtkWidget *widget, GdkEventAny *ev, - gpointer data) -{ - GnomePrintFontPicker *gfp; - - gfp = GNOME_PRINT_FONT_PICKER (data); - - /* FIXME: is this necessary? bug #67587 */ - /* Here we restore old values */ - gnome_print_font_picker_set_font_name(gfp,gfp->_priv->font_name); - gnome_print_font_picker_set_preview_text(gfp,gfp->_priv->preview_text); - - return FALSE; -} /* gnome_print_font_picker_dialog_delete_event */ - -static void -gnome_print_font_picker_dialog_destroy(GtkWidget *widget, - gpointer data) -{ - GnomePrintFontPicker *gfp; - - gfp = GNOME_PRINT_FONT_PICKER (data); - - /* Query GtkFontSelectionDialog before it get destroyed */ - /* These calls will update gfp->_priv->font_name and gfp->_priv->preview_text */ - gnome_print_font_picker_get_font_name(gfp); - gnome_print_font_picker_get_preview_text(gfp); - - /* Dialog will get destroyed so reference is no valid now */ - gfp->_priv->font_dialog = NULL; -} /* gnome_print_font_picker_dialog_destroy */ - -GtkWidget *gnome_print_font_picker_create_inside(GnomePrintFontPicker *gfp) -{ - GtkWidget *widget; - - if (gfp->_priv->mode==GNOME_PRINT_FONT_PICKER_MODE_PIXMAP) { - widget=gtk_image_new_from_stock(GTK_STOCK_SELECT_FONT, - GTK_ICON_SIZE_BUTTON); - gtk_widget_show(widget); - } else if (gfp->_priv->mode==GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO) { - widget=gtk_hbox_new(FALSE,0); - - gfp->_priv->font_label=gtk_label_new(_("Font")); - - gtk_label_set_justify(GTK_LABEL(gfp->_priv->font_label),GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(widget),gfp->_priv->font_label,TRUE,TRUE,5); - - if (gfp->_priv->show_size) { - gfp->_priv->vsep=gtk_vseparator_new(); - gtk_box_pack_start(GTK_BOX(widget),gfp->_priv->vsep,FALSE,FALSE,0); - - gfp->_priv->size_label=gtk_label_new("14"); - gtk_box_pack_start(GTK_BOX(widget),gfp->_priv->size_label,FALSE,FALSE,5); - } - - gtk_widget_show_all(widget); - - } else /* GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET */ { - widget=NULL; - } - - return widget; - -} /* gnome_print_font_picker_create_inside */ - -static void -gnome_print_font_picker_label_use_font_in_label (GnomePrintFontPicker *gfp) -{ - PangoFontDescription *desc; - GtkStyle *style; - - desc = gnome_font_get_pango_description (gfp->_priv->font, 1 /*FIXME*/); - if (desc == NULL) { - return; /* Use widget default */ - } - - /* Change size */ - pango_font_description_set_size (desc, - gfp->_priv->use_font_in_label_size * - PANGO_SCALE); - - /* FIXME: listen for style changes */ - /* Change label style */ - gtk_widget_ensure_style (gfp->_priv->font_label); - style = gtk_style_copy (gfp->_priv->font_label->style); - if (style->font_desc != NULL) - pango_font_description_free (style->font_desc); - - style->font_desc = desc; - - gtk_widget_set_style (gfp->_priv->font_label, style); - g_object_unref (G_OBJECT (style)); -} /* gnome_print_font_picker_set_label_font */ - -static void -gnome_print_font_picker_update_font_info (GnomePrintFontPicker *gfp) -{ - const char *name; - - name = gnome_font_get_family_name (gfp->_priv->font); - - gtk_label_set_text (GTK_LABEL (gfp->_priv->font_label), name); - - /* Extract font size */ - if (gfp->_priv->show_size) { - gdouble size = gnome_font_get_size (gfp->_priv->font); - gchar *size_str = g_strdup_printf ("%.1f", size); - - gtk_label_set_text (GTK_LABEL (gfp->_priv->size_label), size_str); - - g_free (size_str); - } - - if (gfp->_priv->use_font_in_label) { - gnome_print_font_picker_label_use_font_in_label (gfp); - } -} /* gnome_print_font_picker_update_font_info */ diff --git a/gedit/dialogs/gnome-print-font-picker.h b/gedit/dialogs/gnome-print-font-picker.h deleted file mode 100644 index 1208ccf31..000000000 --- a/gedit/dialogs/gnome-print-font-picker.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gnome-print-font-picker.c - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * This widget is based on GnomeFontPicker - */ - -/* GNOME font picker button. - * Copyright (C) 1998 David Abilleira Freijeiro <odaf@nexo.es> - * All rights reserved. - * - * Based on gnome-color-picker by Federico Mena <federico@nuclecu.unam.mx> - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef GNOME_PRINT_FONT_PICKER_H -#define GNOME_PRINT_FONT_PICKER_H - -#include <gtk/gtkbutton.h> -#include <libgnomeprint/gnome-font.h> - - -G_BEGIN_DECLS - -/* GnomePrintFontPicker is a button widget that allow user to select a - * gnome print font. - */ - -/* Button Mode or What to show */ -typedef enum { - GNOME_PRINT_FONT_PICKER_MODE_PIXMAP, - GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO, - GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET, - GNOME_PRINT_FONT_PICKER_MODE_UNKNOWN -} GnomePrintFontPickerMode; - - -#define GNOME_PRINT_TYPE_FONT_PICKER (gnome_print_font_picker_get_type ()) -#define GNOME_PRINT_FONT_PICKER(obj) (GTK_CHECK_CAST ((obj), GNOME_PRINT_TYPE_FONT_PICKER, GnomePrintFontPicker)) -#define GNOME_PRINT_FONT_PICKER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_PRINT_TYPE_FONT_PICKER, GnomePrintFontPickerClass)) -#define GNOME_PRINT_IS_FONT_PICKER(obj) (GTK_CHECK_TYPE ((obj), GNOME_PRINT_TYPE_FONT_PICKER)) -#define GNOME_PRINT_IS_FONT_PICKER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_PRINT_TYPE_FONT_PICKER)) -#define GNOME_PRINT_FONT_PICKER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GNOME_PRINT_TYPE_FONT_PICKER, GnomePrintFontPickerClass)) - -typedef struct _GnomePrintFontPicker GnomePrintFontPicker; -typedef struct _GnomePrintFontPickerPrivate GnomePrintFontPickerPrivate; -typedef struct _GnomePrintFontPickerClass GnomePrintFontPickerClass; - -struct _GnomePrintFontPicker { - GtkButton button; - - /*< private >*/ - GnomePrintFontPickerPrivate *_priv; -}; - -struct _GnomePrintFontPickerClass { - GtkButtonClass parent_class; - - /* font_set signal is emitted when font is choosed */ - void (* font_set) (GnomePrintFontPicker *gfp, const gchar *font_name); - - /* It is possible we may need more signals */ - gpointer padding1; - gpointer padding2; -}; - - -/* Standard Gtk function */ -GType gnome_print_font_picker_get_type (void) G_GNUC_CONST; - -/* Creates a new font picker widget */ -GtkWidget *gnome_print_font_picker_new (void); - -/* Sets the title for the font selection dialog */ -void gnome_print_font_picker_set_title (GnomePrintFontPicker *gfp, - const gchar *title); -const gchar *gnome_print_font_picker_get_title (GnomePrintFontPicker *gfp); - -/* Button mode */ -GnomePrintFontPickerMode - gnome_print_font_picker_get_mode (GnomePrintFontPicker *gfp); - -void gnome_print_font_picker_set_mode (GnomePrintFontPicker *gfp, - GnomePrintFontPickerMode mode); -/* With GNOME_PRINT_FONT_PICKER_MODE_FONT_INFO */ -/* If use_font_in_label is true, font name will be writen using font choosed by user and - using size passed to this function*/ -void gnome_print_font_picker_fi_set_use_font_in_label (GnomePrintFontPicker *gfp, - gboolean use_font_in_label, - gint size); - -void gnome_print_font_picker_fi_set_show_size (GnomePrintFontPicker *gfp, - gboolean show_size); - -/* With GNOME_PRINT_FONT_PICKER_MODE_USER_WIDGET */ -void gnome_print_font_picker_uw_set_widget (GnomePrintFontPicker *gfp, - GtkWidget *widget); -GtkWidget *gnome_print_font_picker_uw_get_widget (GnomePrintFontPicker *gfp); - -/* Functions to interface with GtkFontSelectionDialog */ -const gchar *gnome_print_font_picker_get_font_name (GnomePrintFontPicker *gfp); - -gboolean gnome_print_font_picker_set_font_name (GnomePrintFontPicker *gfp, - const gchar *fontname); -#include <gtk/gtkbutton.h> - -const gchar *gnome_print_font_picker_get_preview_text (GnomePrintFontPicker *gfp); - -void gnome_print_font_picker_set_preview_text (GnomePrintFontPicker *gfp, - const gchar *text); - -G_END_DECLS - -#endif /* GNOME_PRINT_FONT_PICKER_H */ diff --git a/gedit/dialogs/goto-line.glade2 b/gedit/dialogs/goto-line.glade2 deleted file mode 100644 index 1a5296d76..000000000 --- a/gedit/dialogs/goto-line.glade2 +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" > - -<glade-interface> - <widget class="GtkDialog" id="dialog"> - <property name="visible">no</property> - <property name="title" translatable="yes">Goto Line</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="modal">yes</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">no</property> - <property name="auto_close">no</property> - <property name="hide_on_close">no</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="can_default">yes</property> - <property name="has_default">yes</property> - <property name="can_focus">yes</property> - <property name="homogeneous">no</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkButton" id="button1"> - <property name="can_default">yes</property> - <property name="has_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-ok</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button3"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-cancel</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">yes</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="goto_line_dialog_content"> - <property name="border_width">6</property> - <property name="homogeneous">no</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkLabel" id="label"> - <property name="label" translatable="yes">_Line number:</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">no</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - <property name="mnemonic_widget">entry</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry"> - <property name="activates_default">yes</property> - <property name="editable">yes</property> - <property name="text" translatable="yes"></property> - <property name="width-request">100</property> - <property name="max-length">0</property> - <property name="visibility">yes</property> - <property name="visible">yes</property> - <accessibility> - <atkrelation target="label" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">4</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> -</glade-interface> diff --git a/gedit/dialogs/plugin-manager.glade2 b/gedit/dialogs/plugin-manager.glade2 deleted file mode 100644 index 5da8a82cd..000000000 --- a/gedit/dialogs/plugin-manager.glade2 +++ /dev/null @@ -1,366 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" > - -<glade-interface> - <widget class="GtkDialog" id="dialog1"> - <property name="title" translatable="yes">dialog1</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="modal">no</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">yes</property> - <property name="visible">no</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">yes</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="border_width">10</property> - <property name="homogeneous">yes</property> - <property name="spacing">5</property> - <property name="visible">yes</property> - - <child> - <widget class="Placeholder" id="None"> - <property name="visible">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">yes</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="plugin_manager_dialog_content"> - <property name="homogeneous">no</property> - <property name="spacing">5</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkScrolledWindow" id="plugin_viewport"> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkTreeView" id="plugin_tree"> - <property name="visible">yes</property> - </widget> - </child> - - <child internal-child="hscrollbar"> - <widget class="GtkHScrollbar" id="pmconvertwidget1"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - - <child internal-child="vscrollbar"> - <widget class="GtkVScrollbar" id="pmconvertwidget2"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox2"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkLayout" id="layout1"> - <property name="visible">yes</property> - <property name="hadjustment">0 0 100 0 10 10</property> - <property name="vadjustment">0 0 100 0 10 10</property> - <property name="width">400</property> - <property name="height">300</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="configure_button"> - <property name="tooltip" translatable="yes">Configure the selected plugin</property> - <property name="can_focus">yes</property> - <property name="label" translatable="yes">C_onfigure plugin</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="width-request">0</property> - <property name="height-request">0</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">5</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkNotebook" id="plugin_notebook"> - <property name="can_focus">yes</property> - <property name="show_tabs">yes</property> - <property name="show_border">yes</property> - <property name="tab_pos">GTK_POS_BOTTOM</property> - <property name="scrollable">yes</property> - <property name="tab_hborder">2</property> - <property name="tab_vborder">2</property> - <property name="enable-popup">no</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkScrolledWindow" id="sw1"> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <property name="visible">yes</property> - <property name="border_width">5</property> - - <child> - <widget class="GtkViewport" id="vp112"> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkVBox" id="vbox112"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkLabel" id="desc_label"> - <property name="label" translatable="yes"></property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">yes</property> - <property name="xalign">0.0</property> - <property name="yalign">0.0</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - - <child internal-child="hscrollbar"> - <widget class="GtkHScrollbar" id="pmconvertwidget21"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - - <child internal-child="vscrollbar"> - <widget class="GtkVScrollbar" id="pmconvertwidget22"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="pmlabel2"> - <property name="label" translatable="yes">_Description</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">no</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkScrolledWindow" id="pmsw31"> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <property name="visible">yes</property> - <property name="border_width">5</property> - - <child> - <widget class="GtkViewport" id="pmvp1132"> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkVBox" id="pmvbox2"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">yes</property> - <child> - <widget class="GtkLabel" id="name_label"> - <property name="label" translatable="yes"></property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">yes</property> - <property name="xalign">0.0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="copyright_label"> - <property name="label" translatable="yes"></property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">yes</property> - <property name="xalign">0.0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="author_label"> - <property name="label" translatable="yes"></property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">yes</property> - <property name="xalign">0.0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="padding">10</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="file_label"> - <property name="label" translatable="yes"></property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">no</property> - <property name="xalign">0.0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - - <child internal-child="hscrollbar"> - <widget class="GtkHScrollbar" id="pmconvertwidget321"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - - <child internal-child="vscrollbar"> - <widget class="GtkVScrollbar" id="pmconvertwidget322"> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="visible">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="pmlabel3"> - <property name="label" translatable="yes">De_tails</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">no</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/gedit/dialogs/program-location-dialog.glade2 b/gedit/dialogs/program-location-dialog.glade2 deleted file mode 100644 index 336836410..000000000 --- a/gedit/dialogs/program-location-dialog.glade2 +++ /dev/null @@ -1,192 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" > - -<glade-interface> - <requires lib="gnome" /> - - <widget class="GtkDialog" id="program_location_dialog"> - <property name="title" translatable="yes">Set program location...</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="modal">no</property> - <property name="default_width">450</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">yes</property> - <property name="visible">no</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox2"> - <property name="homogeneous">no</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area2"> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkButton" id="button2"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-cancel</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button4"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-ok</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">yes</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="dialog_content"> - <property name="homogeneous">no</property> - <property name="spacing">8</property> - <property name="border_width">6</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="homogeneous">no</property> - <property name="spacing">12</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkImage" id="logo"> - <property name="xalign">0.0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label"> - <property name="label" translatable="yes">label</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">yes</property> - <property name="use_markup">yes</property> - <property name="xalign">0.0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">8</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox3"> - <property name="homogeneous">no</property> - <property name="spacing">4</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkLabel" id="label3"> - <property name="label" translatable="yes">_Location to search for:</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">no</property> - <property name="xalign">7.45058e-09</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - <property name="mnemonic_widget">entry1</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GnomeFileEntry" id="program_location_file_entry"> - <property name="modal">yes</property> - <property name="directory_entry">no</property> - <property name="browse_dialog_title">Browse for program location...</property> - <property name="visible">yes</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="entry1"> - <property name="can_default">yes</property> - <property name="has_default">yes</property> - <property name="can_focus">yes</property> - <property name="has_focus">yes</property> - <property name="editable">yes</property> - <property name="text" translatable="yes"></property> - <property name="max-length">0</property> - <property name="visibility">yes</property> - <property name="visible">yes</property> - <property name="activates_default">yes</property> - <accessibility> - <atkrelation target="label3" type="labelled-by"/> - </accessibility> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">4</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> -</glade-interface> diff --git a/gedit/dialogs/replace.glade2 b/gedit/dialogs/replace.glade2 deleted file mode 100644 index 447720656..000000000 --- a/gedit/dialogs/replace.glade2 +++ /dev/null @@ -1,284 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" > - -<glade-interface> - - <widget class="GtkDialog" id="dialog"> - <property name="visible">no</property> - <property name="title" translatable="yes">Replace</property> - <property name="type">GTK_WINDOW_DIALOG</property> - <property name="modal">no</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">no</property> - <property name="auto_close">no</property> - <property name="hide_on_close">no</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="homogeneous">no</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkButton" id="find_next_button"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="label" translatable="no">Find Next</property> - <property name="visible">yes</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="replace_button"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="label" translatable="no">Replace</property> - <property name="visible">yes</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="replace_all_button"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="label" translatable="no">Replace All</property> - <property name="visible">yes</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="close_button"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-close</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="replace_dialog_content"> - <property name="border_width">5</property> - <property name="homogeneous">no</property> - <property name="spacing">6</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkHBox" id="hbox2"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkLabel" id="label1"> - <property name="label" translatable="yes">_Search for: </property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">yes</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="width-request">90</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - <property name="mnemonic_widget">search_for_text_entry</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="search_for_text_entry"> - <property name="activates_default">yes</property> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="has_focus">yes</property> - <property name="editable">yes</property> - <property name="text" translatable="yes"></property> - <property name="width-request">300</property> - <property name="max-length">0</property> - <property name="visibility">yes</property> - <property name="visible">yes</property> - <accessibility> - <atkrelation target="label1" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox_replace_with"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">no</property> - - <child> - <widget class="GtkLabel" id="label2"> - <property name="label" translatable="yes">Replace _with: </property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">yes</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="width-request">90</property> - <property name="mnemonic_widget">replace_with_text_entry</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="replace_with_text_entry"> - <property name="activates_default">yes</property> - <property name="can_focus">yes</property> - <property name="editable">yes</property> - <property name="text" translatable="yes"></property> - <property name="width-request">220</property> - <property name="max-length">0</property> - <property name="visibility">yes</property> - <property name="visible">yes</property> - <accessibility> - <atkrelation target="label2" type="labelled-by"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox_start_from"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkRadioButton" id="beginning_radio_button"> - <property name="can_focus">yes</property> - <property name="label" translatable="yes">Search fro_m the beginning of the document</property> - <property name="active">yes</property> - <property name="draw_indicator">yes</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkRadioButton" id="cursor_radio_button"> - <property name="can_focus">yes</property> - <property name="label" translatable="yes">Search from the c_ursor position</property> - <property name="active">no</property> - <property name="draw_indicator">yes</property> - <property name="visible">yes</property> - <property name="group">beginning_radio_button</property> - <property name="use_underline">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">4</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox2"> - <property name="homogeneous">no</property> - <property name="spacing">0</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkCheckButton" id="case_sensitive"> - <property name="can_focus">yes</property> - <property name="label" translatable="yes">Case sensi_tive</property> - <property name="active">yes</property> - <property name="draw_indicator">yes</property> - <property name="visible">yes</property> - <property name="use_underline">yes</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">4</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> -</glade-interface> diff --git a/gedit/dialogs/uri.glade2 b/gedit/dialogs/uri.glade2 deleted file mode 100644 index 318b277a1..000000000 --- a/gedit/dialogs/uri.glade2 +++ /dev/null @@ -1,141 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd" > - -<glade-interface> - <requires lib="gnome" /> - - <widget class="GtkDialog" id="open_uri_dialog"> - <property name="visible">no</property> - <property name="title" translatable="yes">Open from URI</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="modal">no</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">no</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox2"> - <property name="homogeneous">no</property> - <property name="visible">yes</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area2"> - <property name="layout_style">GTK_BUTTONBOX_END</property> - <property name="visible">yes</property> - <property name="spacing">10</property> - - <child> - <widget class="GtkButton" id="open_button"> - <property name="can_default">yes</property> - <property name="has_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-open</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="cancel_button"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-cancel</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="help_button"> - <property name="can_default">yes</property> - <property name="can_focus">yes</property> - <property name="visible">yes</property> - <property name="label" translatable="no">gtk-help</property> - <property name="use_stock">yes</property> - <property name="use_underline">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="expand">no</property> - <property name="fill">yes</property> - <property name="pack">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="open_uri_dialog_content"> - <property name="border_width">5</property> - <property name="homogeneous">no</property> - <property name="spacing">8</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkLabel" id="label1"> - <property name="label" translatable="yes">Enter the location (URI) of the file you would like to open:</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">no</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="visible">yes</property> - <accessibility> - <atkrelation target="uri" type="label-for"/> - </accessibility> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">no</property> - </packing> - </child> - - <child> - <widget class="GnomeEntry" id="uri_list"> - <property name="history_id">gedit2_uri_list</property> - <property name="width-request">380</property> - <property name="visible">yes</property> - <property name="has_focus">yes</property> - <property name="case_sensitive">yes</property> - <property name="allow_empty">no</property> - <child internal-child="entry"> - <widget class="GtkEntry" id="uri"> - <property name="activates_default">yes</property> - <property name="can_focus">yes</property> - <property name="has_focus">yes</property> - <property name="editable">yes</property> - <property name="text" translatable="yes"></property> - <property name="max-length">0</property> - <property name="visibility">yes</property> - <property name="visible">yes</property> - <accessibility> - <atkrelation target="label1" type="labelled-by"/> - </accessibility> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">4</property> - <property name="expand">yes</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> -</glade-interface> diff --git a/gedit/gedit-application-server.c b/gedit/gedit-application-server.c deleted file mode 100644 index 17bfdddcb..000000000 --- a/gedit/gedit-application-server.c +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-application-server.c - * This file is part of gedit - * - * Copyright (C) 2002 James Willcox - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - - -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-context.h> - -#include "gedit-application-server.h" -#include "gedit-document-server.h" -#include "gedit-window-server.h" -#include "GNOME_Gedit.h" -#include "gedit-file.h" -#include "gedit-mdi.h" -#include "gedit2.h" - - -static void gedit_application_server_class_init (GeditApplicationServerClass *klass); -static void gedit_application_server_init (GeditApplicationServer *a); -static void gedit_application_server_object_finalize (GObject *object); -static GObjectClass *gedit_application_server_parent_class; - -static BonoboObject * -gedit_application_server_factory (BonoboGenericFactory *this_factory, - const char *iid, - gpointer user_data) -{ - GeditApplicationServer *a; - - a = g_object_new (GEDIT_APPLICATION_SERVER_TYPE, NULL); - - return BONOBO_OBJECT (a); -} - -BonoboObject * -gedit_application_server_new (void) -{ - BonoboGenericFactory *factory; - - factory = bonobo_generic_factory_new ("OAFIID:GNOME_Gedit_Factory", - gedit_application_server_factory, - NULL); - - return BONOBO_OBJECT (factory); -} - -static GNOME_Gedit_Window -impl_gedit_application_server_newWindow (PortableServer_Servant _servant, - CORBA_Environment * ev) -{ - BonoboWindow *win; - BonoboObject *win_server; - - bonobo_mdi_open_toplevel (BONOBO_MDI (gedit_mdi), NULL); - gedit_file_new (); - - /* let the UI update */ - while (gtk_events_pending ()) - gtk_main_iteration (); - - win = bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi)); - - win_server = gedit_window_server_new (win); - - return BONOBO_OBJREF (win_server); -} - - -static GNOME_Gedit_Window -impl_gedit_application_server_getActiveWindow (PortableServer_Servant _servant, - CORBA_Environment * ev) -{ - BonoboWindow *win; - BonoboObject *win_server; - - win = bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi)); - - win_server = gedit_window_server_new (win); - - return BONOBO_OBJREF (win_server); -} - -static GNOME_Gedit_Window -impl_gedit_application_server_getActiveDocument (PortableServer_Servant _servant, - CORBA_Environment * ev) -{ - GeditDocument *doc; - BonoboObject *doc_server; - - doc = gedit_get_active_document (); - - doc_server = gedit_document_server_new (doc); - - return BONOBO_OBJREF (doc_server); -} - -static void -impl_gedit_application_server_quit (PortableServer_Servant _servant, - CORBA_Environment * ev) -{ - gedit_file_exit (); -} - -static void -gedit_application_server_class_init (GeditApplicationServerClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - POA_GNOME_Gedit_Application__epv *epv = &klass->epv; - - gedit_application_server_parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_application_server_object_finalize; - - /* connect implementation callbacks */ - epv->newWindow = impl_gedit_application_server_newWindow; - epv->getActiveDocument = impl_gedit_application_server_getActiveDocument; - epv->getActiveWindow = impl_gedit_application_server_getActiveWindow; - - epv->quit = impl_gedit_application_server_quit; -} - -static void -gedit_application_server_init (GeditApplicationServer *c) -{ -} - -static void -gedit_application_server_object_finalize (GObject *object) -{ - GeditApplicationServer *a = GEDIT_APPLICATION_SERVER (object); - - gedit_application_server_parent_class->finalize (G_OBJECT (a)); -} - -BONOBO_TYPE_FUNC_FULL ( - GeditApplicationServer, - GNOME_Gedit_Application, - BONOBO_TYPE_OBJECT, - gedit_application_server); diff --git a/gedit/gedit-application-server.h b/gedit/gedit-application-server.h deleted file mode 100644 index 98b2f13b4..000000000 --- a/gedit/gedit-application-server.h +++ /dev/null @@ -1,36 +0,0 @@ - -#ifndef __GEDIT_APPLICATION_SERVER_H -#define __GEDIT_APPLICATION_SERVER_H - -#include "GNOME_Gedit.h" -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-object.h> - -G_BEGIN_DECLS - -#define GEDIT_APPLICATION_SERVER_TYPE (gedit_application_server_get_type ()) -#define GEDIT_APPLICATION_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GEDIT_APPLICATION_SERVER_TYPE, GeditApplicationServer)) -#define GEDIT_APPLICATION_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GEDIT_APPLICATION_SERVER_TYPE, GeditApplicationServerClass)) -#define GEDIT_APPLICATION_SERVER_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GEDIT_APPLICATION_SERVER_TYPE)) -#define GEDIT_APPLICATION_SERVER_IS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GEDIT_APPLICATION_SERVER_TYPE)) -#define GEDIT_APPLICATION_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GEDIT_APPLICATION_SERVER_TYPE, GeditApplicationServerClass)) - -typedef struct -{ - BonoboObject parent; -} GeditApplicationServer; - -typedef struct -{ - BonoboObjectClass parent_class; - - POA_GNOME_Gedit_Application__epv epv; -} GeditApplicationServerClass; - -GType gedit_application_server_get_type (void); - -BonoboObject *gedit_application_server_new (void); - -G_END_DECLS - -#endif /* __GEDIT_APPLICATION_SERVER_H */ diff --git a/gedit/gedit-commands.c b/gedit/gedit-commands.c deleted file mode 100644 index 8fd6c5ccf..000000000 --- a/gedit/gedit-commands.c +++ /dev/null @@ -1,485 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-commands.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <gtk/gtk.h> -#include <libgnome/libgnome.h> -#include <libgnomeui/libgnomeui.h> - -#include "gedit-commands.h" -#include "gedit2.h" -#include "gedit-mdi-child.h" -#include "gedit-debug.h" -#include "gedit-view.h" -#include "gedit-file.h" -#include "gedit-print.h" -#include "dialogs/gedit-dialogs.h" -#include "dialogs/gedit-preferences-dialog.h" - -#define TO_BE_IMPLEMENTED { GtkWidget *message_dlg; \ - message_dlg = gtk_message_dialog_new ( \ - GTK_WINDOW (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi))), \ - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, \ - GTK_MESSAGE_INFO, \ - GTK_BUTTONS_OK, \ - _("Not yet implemented.")); \ - gtk_dialog_set_default_response (GTK_DIALOG (message_dlg), GTK_RESPONSE_OK); \ - gtk_dialog_run (GTK_DIALOG (message_dlg)); \ - gtk_widget_destroy (message_dlg); } - -void -gedit_cmd_file_new (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, "verbname: %s", verbname); - - gedit_file_new (); -} - -void -gedit_cmd_file_open (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - BonoboMDIChild *active_child; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_child = bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)); - - gedit_file_open ((GeditMDIChild*) active_child); -} - -void -gedit_cmd_file_save (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditMDIChild *active_child; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - if (active_child == NULL) - return; - - gedit_file_save (active_child); -} - -void -gedit_cmd_file_save_as (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditMDIChild *active_child; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - if (active_child == NULL) - return; - - gedit_file_save_as (active_child); -} - -void -gedit_cmd_file_save_all (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, ""); - - gedit_file_save_all (); -} - -void -gedit_cmd_file_revert (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditMDIChild *active_child; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - if (active_child == NULL) - return; - - gedit_file_revert (active_child); -} - -void -gedit_cmd_file_open_uri (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, ""); - - gedit_dialog_open_uri (); -} - -void -gedit_cmd_file_print (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditMDIChild *active_child; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - if (active_child == NULL) - return; - - gedit_print (active_child); - -} - -void -gedit_cmd_file_print_preview (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditMDIChild *active_child; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - if (active_child == NULL) - return; - - gedit_print_preview (active_child); -} - -void -gedit_cmd_file_close (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GtkWidget *active_view; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_view = bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi)); - - if (active_view == NULL) - return; - - gedit_close_x_button_pressed = TRUE; - - gedit_file_close (active_view); - - gedit_close_x_button_pressed = FALSE; -} - -void -gedit_cmd_file_close_all (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, ""); - - gedit_close_x_button_pressed = TRUE; - - gedit_file_close_all (); - - gedit_close_x_button_pressed = FALSE; -} - -void -gedit_cmd_file_exit (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, ""); - - gedit_exit_button_pressed = TRUE; - - gedit_file_exit (); - - gedit_exit_button_pressed = FALSE; -} - -void -gedit_cmd_edit_undo (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditView* active_view; - GeditDocument* active_document; - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - active_document = gedit_view_get_document (active_view); - g_return_if_fail (active_document); - - gedit_document_undo (active_document); - - /* TODO: Move the cursor */ -} - -void -gedit_cmd_edit_redo (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditView* active_view; - GeditDocument* active_document; - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - active_document = gedit_view_get_document (active_view); - g_return_if_fail (active_document); - - gedit_document_redo (active_document); - - /* TODO: Move the cursor */ -} - -void -gedit_cmd_edit_cut (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditView* active_view; - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - gedit_view_cut_clipboard (active_view); -} - -void -gedit_cmd_edit_copy (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditView* active_view; - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - gedit_view_copy_clipboard (active_view); -} - -void -gedit_cmd_edit_paste (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditView* active_view; - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - gedit_view_paste_clipboard (active_view); -} - -void -gedit_cmd_edit_clear (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditView* active_view; - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - gedit_view_delete_selection (active_view); -} - -void -gedit_cmd_edit_select_all (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditView* active_view; - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view); - - gedit_view_select_all (active_view); -} - -void -gedit_cmd_search_find (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, ""); - - gedit_dialog_find (); -} - -void -gedit_cmd_search_find_again (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GeditMDIChild *active_child; - GeditDocument *doc; - GeditView *active_view; - gchar* last_searched_text; - - gedit_debug (DEBUG_COMMANDS, ""); - - active_child = GEDIT_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_child); - - active_view = GEDIT_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))); - g_return_if_fail (active_view != NULL); - - doc = GEDIT_DOCUMENT (active_child->document); - g_return_if_fail (doc); - - last_searched_text = gedit_document_get_last_searched_text (doc); - if (last_searched_text != NULL) - { - if (!gedit_document_find_again (doc)) - { - GtkWidget *message_dlg; - - message_dlg = gtk_message_dialog_new ( - GTK_WINDOW (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("The string \"%s\" has not been found."), last_searched_text); - - gtk_dialog_set_default_response (GTK_DIALOG (message_dlg), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (message_dlg), FALSE); - - gtk_dialog_run (GTK_DIALOG (message_dlg)); - gtk_widget_destroy (message_dlg); - } - else - gedit_view_scroll_to_cursor (active_view); - - } - else - { - g_free (last_searched_text); - gedit_dialog_find (); - } -} - - -void -gedit_cmd_search_replace (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, ""); - - gedit_dialog_replace (); -} - -void -gedit_cmd_search_goto_line (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - gedit_debug (DEBUG_COMMANDS, ""); - - gedit_dialog_goto_line (); -} - -void -gedit_cmd_settings_preferences (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - static GtkWidget *dlg = NULL; - - gedit_debug (DEBUG_COMMANDS, ""); - - if (dlg != NULL) - { - gtk_window_present (GTK_WINDOW (dlg)); - gtk_window_set_transient_for (GTK_WINDOW (dlg), - GTK_WINDOW (gedit_get_active_window ())); - - return; - } - - dlg = gedit_preferences_dialog_new (GTK_WINDOW (gedit_get_active_window ())); - - g_signal_connect (G_OBJECT (dlg), "destroy", - G_CALLBACK (gtk_widget_destroyed), &dlg); - - gtk_widget_show (dlg); -} - -void -gedit_cmd_help_contents (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - GError *error = NULL; - - gedit_debug (DEBUG_COMMANDS, ""); - - gnome_help_display ("gedit.xml", NULL, &error); - - if (error != NULL) - { - g_warning (error->message); - - g_error_free (error); - } -} - -void -gedit_cmd_help_about (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname) -{ - static GtkWidget *about = NULL; - GdkPixbuf* pixbuf = NULL; - - gchar *authors[] = { - "Paolo Maggi <maggi@athena.polito.it>", - "Chema Celorio <chema@ximian.com>", - "James Willcox <jwillcox@cs.indiana.edu>", - "Federico Mena Quintero <federico@ximian.com>", - NULL - }; - - gchar *documenters[] = { - "Sun GNOME Documentation Team <gdocteam@sun.com>", - "Eric Baudais <baudais@okstate.edu>", - NULL - }; - - gchar *translator_credits = _("translator_credits"); - - gedit_debug (DEBUG_COMMANDS, ""); - - if (about != NULL) - { - gdk_window_show (about->window); - gdk_window_raise (about->window); - return; - } - - pixbuf = gdk_pixbuf_new_from_file ( GNOME_ICONDIR "/gedit-logo.png", NULL); - if (pixbuf != NULL) - { - GdkPixbuf* temp_pixbuf = NULL; - - temp_pixbuf = gdk_pixbuf_scale_simple (pixbuf, - gdk_pixbuf_get_width (pixbuf) / 2, - gdk_pixbuf_get_height (pixbuf) / 2, - GDK_INTERP_HYPER); - g_object_unref (pixbuf); - - pixbuf = temp_pixbuf; - } - - about = gnome_about_new (_("gedit"), VERSION, - _("(C) 1998-2000 Evan Lawrence and Alex Robert\n" - "(C) 2000-2002 Chema Celorio and Paolo Maggi"), - _("gedit is a small and lightweight text editor for Gnome"), - (const char **)authors, - (const char **)documenters, - strcmp (translator_credits, "translator_credits") != 0 ? (const char *)translator_credits : NULL, - pixbuf); - - gtk_window_set_transient_for (GTK_WINDOW (about), - GTK_WINDOW (gedit_get_active_window ())); - - gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE); - - if (pixbuf != NULL) - g_object_unref (pixbuf); - - g_signal_connect (G_OBJECT (about), "destroy", - G_CALLBACK (gtk_widget_destroyed), &about); - - gtk_widget_show (about); -} - - diff --git a/gedit/gedit-commands.h b/gedit/gedit-commands.h deleted file mode 100644 index b24255eb1..000000000 --- a/gedit/gedit-commands.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-commands.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_COMMANDS_H__ -#define __GEDIT_COMMANDS_H__ - -#include <bonobo/bonobo-ui-component.h> - -void gedit_cmd_file_new (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_open (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_save (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_save_as (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_save_all (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_revert (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_open_uri (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_print (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_print_preview - (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_close (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_close_all (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_file_exit (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); - -void gedit_cmd_edit_undo (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_edit_redo (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_edit_cut (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_edit_copy (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_edit_paste (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_edit_clear (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_edit_select_all (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); - -void gedit_cmd_search_find (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_search_find_again (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_search_replace (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_search_goto_line (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); - -void gedit_cmd_settings_preferences (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); - -void gedit_cmd_help_contents (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); -void gedit_cmd_help_about (BonoboUIComponent *uic, gpointer user_data, const gchar* verbname); - -#endif /* __GEDIT_COMMANDS_H__ */ diff --git a/gedit/gedit-debug.c b/gedit/gedit-debug.c deleted file mode 100644 index ecc3e932c..000000000 --- a/gedit/gedit-debug.c +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-debug.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <glib.h> - -#include "gedit-debug.h" - -/* External debug options, used here and in gedit.c */ -gint debug = 0; -gint debug_view = 0; -gint debug_undo = 0; -gint debug_search = 0; -gint debug_prefs = 0; -gint debug_print = 0; -gint debug_plugins = 0; -gint debug_file = 0; -gint debug_document = 0; -gint debug_commands = 0; -gint debug_recent = 0; -gint debug_mdi = 0; -gint debug_session = 0; - -void -gedit_debug (gint section, gchar *file, gint line, gchar* function, gchar* format, ...) -{ - va_list args; - gchar *msg; - - g_return_if_fail (format != NULL); - - va_start (args, format); - msg = g_strdup_vprintf (format, args); - va_end (args); - - if (debug || - (debug_view && section == GEDIT_DEBUG_VIEW) || - (debug_undo && section == GEDIT_DEBUG_UNDO) || - (debug_search && section == GEDIT_DEBUG_SEARCH) || - (debug_print && section == GEDIT_DEBUG_PRINT) || - (debug_prefs && section == GEDIT_DEBUG_PREFS) || - (debug_plugins && section == GEDIT_DEBUG_PLUGINS) || - (debug_file && section == GEDIT_DEBUG_FILE) || - (debug_document && section == GEDIT_DEBUG_DOCUMENT) || - (debug_commands && section == GEDIT_DEBUG_COMMANDS) || - (debug_recent && section == GEDIT_DEBUG_RECENT) || - (debug_session && section == GEDIT_DEBUG_SESSION) || - (debug_mdi && section == GEDIT_DEBUG_MDI) ) - g_print ("%s:%d (%s) %s\n", file, line, function, msg); - - g_free (msg); -} diff --git a/gedit/gedit-debug.h b/gedit/gedit-debug.h deleted file mode 100644 index c209ba8a5..000000000 --- a/gedit/gedit-debug.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-debug.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_DEBUG_H__ -#define __GEDIT_DEBUG_H__ - -typedef enum { - GEDIT_DEBUG_VIEW, - GEDIT_DEBUG_UNDO, - GEDIT_DEBUG_SEARCH, - GEDIT_DEBUG_PRINT, - GEDIT_DEBUG_PREFS, - GEDIT_DEBUG_PLUGINS, - GEDIT_DEBUG_FILE, - GEDIT_DEBUG_DOCUMENT, - GEDIT_DEBUG_RECENT, - GEDIT_DEBUG_COMMANDS, - GEDIT_DEBUG_MDI, - GEDIT_DEBUG_SESSION -} GeditDebugSection; - -extern gint debug; -extern gint debug_view; -extern gint debug_undo; -extern gint debug_search; -extern gint debug_print; -extern gint debug_prefs; -extern gint debug_plugins; -extern gint debug_file; -extern gint debug_document; -extern gint debug_commands; -extern gint debug_recent; -extern gint debug_mdi; -extern gint debug_session; - -/* __FUNCTION_ is not defined in Irix according to David Kaelbling <drk@sgi.com>*/ -#ifndef __GNUC__ -#define __FUNCTION__ "" -#endif - -#define DEBUG_VIEW GEDIT_DEBUG_VIEW, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_UNDO GEDIT_DEBUG_UNDO, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_SEARCH GEDIT_DEBUG_SEARCH, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_PRINT GEDIT_DEBUG_PRINT, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_PREFS GEDIT_DEBUG_PREFS, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_PLUGINS GEDIT_DEBUG_PLUGINS, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_FILE GEDIT_DEBUG_FILE, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_DOCUMENT GEDIT_DEBUG_DOCUMENT,__FILE__, __LINE__, __FUNCTION__ -#define DEBUG_RECENT GEDIT_DEBUG_RECENT, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_COMMANDS GEDIT_DEBUG_COMMANDS,__FILE__, __LINE__, __FUNCTION__ -#define DEBUG_MDI GEDIT_DEBUG_MDI, __FILE__, __LINE__, __FUNCTION__ -#define DEBUG_SESSION GEDIT_DEBUG_SESSION, __FILE__, __LINE__, __FUNCTION__ - -void gedit_debug (gint section, gchar *file, - gint line, gchar* function, gchar* format, ...); - -#endif /* __GEDIT_DEBUG_H__ */ diff --git a/gedit/gedit-document-server.c b/gedit/gedit-document-server.c deleted file mode 100644 index 366a38ba1..000000000 --- a/gedit/gedit-document-server.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-document-server.c - * This file is part of gedit - * - * Copyright (C) 2002 James Willcox - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-context.h> - -#include "gedit-document-server.h" -#include "GNOME_Gedit.h" -#include "gedit-file.h" -#include "gedit-document.h" -#include "gedit-mdi.h" -#include "gedit2.h" - -static void gedit_document_server_class_init (GeditDocumentServerClass *klass); -static void gedit_document_server_init (GeditDocumentServer *a); -static void gedit_document_server_object_finalize (GObject *object); - -static GObjectClass *gedit_document_server_parent_class; - -BonoboObject * -gedit_document_server_new (GeditDocument *doc) -{ - GeditDocumentServer *doc_server; - - g_return_val_if_fail (doc != NULL, NULL); - - doc_server = g_object_new (GEDIT_DOCUMENT_SERVER_TYPE, NULL); - - doc_server->doc = doc; - - return BONOBO_OBJECT (doc_server); -} - -static void -impl_gedit_document_server_setLinePosition (PortableServer_Servant _servant, - CORBA_long position, - CORBA_Environment * ev) -{ - GeditDocumentServer *doc_server; - - - doc_server = GEDIT_DOCUMENT_SERVER (bonobo_object_from_servant (_servant)); - - gedit_document_goto_line (doc_server->doc, position); -} - - -static void -gedit_document_server_class_init (GeditDocumentServerClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - POA_GNOME_Gedit_Document__epv *epv = &klass->epv; - - gedit_document_server_parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_document_server_object_finalize; - - /* connect implementation callbacks */ - epv->setLinePosition = impl_gedit_document_server_setLinePosition; -} - -static void -gedit_document_server_init (GeditDocumentServer *c) -{ -} - -static void -gedit_document_server_object_finalize (GObject *object) -{ - GeditDocumentServer *a = GEDIT_DOCUMENT_SERVER (object); - - gedit_document_server_parent_class->finalize (G_OBJECT (a)); -} - -BONOBO_TYPE_FUNC_FULL ( - GeditDocumentServer, - GNOME_Gedit_Document, - BONOBO_TYPE_OBJECT, - gedit_document_server); diff --git a/gedit/gedit-document-server.h b/gedit/gedit-document-server.h deleted file mode 100644 index eacac25ce..000000000 --- a/gedit/gedit-document-server.h +++ /dev/null @@ -1,39 +0,0 @@ - -#ifndef __GEDIT_DOCUMENT_SERVER_H -#define __GEDIT_DOCUMENT_SERVER_H - -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-object.h> -#include "gedit-document.h" -#include "GNOME_Gedit.h" - -G_BEGIN_DECLS - -#define GEDIT_DOCUMENT_SERVER_TYPE (gedit_document_server_get_type ()) -#define GEDIT_DOCUMENT_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GEDIT_DOCUMENT_SERVER_TYPE, GeditDocumentServer)) -#define GEDIT_DOCUMENT_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GEDIT_DOCUMENT_SERVER_TYPE, GeditDocumentServerClass)) -#define GEDIT_DOCUMENT_SERVER_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GEDIT_DOCUMENT_SERVER_TYPE)) -#define GEDIT_DOCUMENT_SERVER_IS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GEDIT_DOCUMENT_SERVER_TYPE)) -#define GEDIT_DOCUMENT_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GEDIT_DOCUMENT_SERVER_TYPE, GeditDocumentServerClass)) - -typedef struct -{ - BonoboObject parent; - - GeditDocument *doc; -} GeditDocumentServer; - -typedef struct -{ - BonoboObjectClass parent_class; - - POA_GNOME_Gedit_Document__epv epv; -} GeditDocumentServerClass; - -GType gedit_document_server_get_type (void); - -BonoboObject *gedit_document_server_new (GeditDocument *doc); - -G_END_DECLS - -#endif /* __GEDIT_DOCUMENT_SERVER_H */ diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c deleted file mode 100644 index f93e44e50..000000000 --- a/gedit/gedit-document.c +++ /dev/null @@ -1,2143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-document.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <fcntl.h> - -#include <libgnome/libgnome.h> -#include <libgnomevfs/gnome-vfs.h> -#include <eel/eel-vfs-extensions.h> - -#include "gedit-prefs-manager.h" -#include "gedit-document.h" -#include "gedit-debug.h" -#include "gedit-utils.h" -#include "gedit-undo-manager.h" - -#include "gedit-marshal.h" - -#define NOT_EDITABLE_TAG_NAME "not_editable_tag" - -#ifdef MAXPATHLEN -#define GEDIT_MAX_PATH_LEN MAXPATHLEN -#elif defined (PATH_MAX) -#define GEDIT_MAX_PATH_LEN PATH_MAX -#else -#define GEDIT_MAX_PATH_LEN 2048 -#endif - -#define DEFAULT_ENCODING "ISO-8859-15" - -struct _GeditDocumentPrivate -{ - gchar *uri; - gint untitled_number; - - gchar *encoding; - - gchar *last_searched_text; - gchar *last_replace_text; - gboolean last_search_was_case_sensitive; - - guint auto_save_timeout; - gboolean last_save_was_manually; - - gboolean readonly; - - GeditUndoManager *undo_manager; -}; - -enum { - NAME_CHANGED, - SAVED, - LOADED, - READONLY_CHANGED, - CAN_UNDO, - CAN_REDO, - LAST_SIGNAL -}; - -static void gedit_document_base_init (GeditDocumentClass *klass); -static void gedit_document_base_finalize (GeditDocumentClass *klass); -static void gedit_document_class_init (GeditDocumentClass *klass); -static void gedit_document_init (GeditDocument *document); -static void gedit_document_finalize (GObject *object); - -static void gedit_document_real_name_changed (GeditDocument *document); -static void gedit_document_real_loaded (GeditDocument *document); -static void gedit_document_real_saved (GeditDocument *document); -static void gedit_document_real_readonly_changed (GeditDocument *document, - gboolean readonly); - -static gboolean gedit_document_save_as_real (GeditDocument* doc, const gchar *uri, - gboolean create_backup_copy, GError **error); -static void gedit_document_set_uri (GeditDocument* doc, const gchar* uri); - -static void gedit_document_can_undo_handler (GeditUndoManager* um, gboolean can_undo, - GeditDocument* doc); - -static void gedit_document_can_redo_handler (GeditUndoManager* um, gboolean can_redo, - GeditDocument* doc); -static gboolean gedit_document_auto_save (GeditDocument *doc, GError **error); -static gboolean gedit_document_auto_save_timeout (GeditDocument *doc); - -static GtkTextBufferClass *parent_class = NULL; -static guint document_signals[LAST_SIGNAL] = { 0 }; - -static GHashTable* allocated_untitled_numbers = NULL; - -static gint gedit_document_get_untitled_number (void); -static void gedit_document_release_untitled_number (gint n); - -static gint -gedit_document_get_untitled_number (void) -{ - gint i = 1; - - gedit_debug (DEBUG_DOCUMENT, ""); - - if (allocated_untitled_numbers == NULL) - allocated_untitled_numbers = g_hash_table_new (NULL, NULL); - - g_return_val_if_fail (allocated_untitled_numbers != NULL, -1); - - while (TRUE) - { - if (g_hash_table_lookup (allocated_untitled_numbers, GINT_TO_POINTER (i)) == NULL) - { - g_hash_table_insert (allocated_untitled_numbers, - GINT_TO_POINTER (i), - GINT_TO_POINTER (i)); - - return i; - } - - ++i; - } -} - -static void -gedit_document_release_untitled_number (gint n) -{ - gboolean ret; - - g_return_if_fail (allocated_untitled_numbers != NULL); - - gedit_debug (DEBUG_DOCUMENT, ""); - - ret = g_hash_table_remove (allocated_untitled_numbers, GINT_TO_POINTER (n)); - g_return_if_fail (ret); -} - - - -GType -gedit_document_get_type (void) -{ - static GType document_type = 0; - - if (document_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GeditDocumentClass), - (GBaseInitFunc) gedit_document_base_init, - (GBaseFinalizeFunc) gedit_document_base_finalize, - (GClassInitFunc) gedit_document_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GeditDocument), - 0, /* n_preallocs */ - (GInstanceInitFunc) gedit_document_init - }; - - document_type = g_type_register_static (GTK_TYPE_TEXT_BUFFER, - "GeditDocument", - &our_info, - 0); - } - - return document_type; -} - -static void -gedit_document_base_init (GeditDocumentClass *klass) -{ - GtkTextTag *not_editable_tag; - - klass->tag_table = gtk_text_tag_table_new (); - - not_editable_tag = gtk_text_tag_new (NOT_EDITABLE_TAG_NAME); - g_object_set (G_OBJECT (not_editable_tag), "editable", FALSE, NULL); - - gtk_text_tag_table_add (klass->tag_table, not_editable_tag); -} - -static void -gedit_document_base_finalize (GeditDocumentClass *klass) -{ - g_object_unref (G_OBJECT (klass->tag_table)); - klass->tag_table = NULL; -} - -static void -gedit_document_class_init (GeditDocumentClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_document_finalize; - - klass->name_changed = gedit_document_real_name_changed; - klass->loaded = gedit_document_real_loaded; - klass->saved = gedit_document_real_saved; - klass->readonly_changed = gedit_document_real_readonly_changed; - klass->can_undo = NULL; - klass->can_redo = NULL; - - document_signals[NAME_CHANGED] = - g_signal_new ("name_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditDocumentClass, name_changed), - NULL, NULL, - gedit_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - document_signals[LOADED] = - g_signal_new ("loaded", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditDocumentClass, loaded), - NULL, NULL, - gedit_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - document_signals[SAVED] = - g_signal_new ("saved", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditDocumentClass, saved), - NULL, NULL, - gedit_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - document_signals[READONLY_CHANGED] = - g_signal_new ("readonly_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditDocumentClass, readonly_changed), - NULL, NULL, - gedit_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - - document_signals[CAN_UNDO] = - g_signal_new ("can_undo", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditDocumentClass, can_undo), - NULL, NULL, - gedit_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - - document_signals[CAN_REDO] = - g_signal_new ("can_redo", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditDocumentClass, can_redo), - NULL, NULL, - gedit_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - -} - -static void -gedit_document_init (GeditDocument *document) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (document->buffer.tag_table == NULL); - document->buffer.tag_table = (GEDIT_DOCUMENT_GET_CLASS (document))->tag_table; - g_object_ref (G_OBJECT (document->buffer.tag_table)); - - document->priv = g_new0 (GeditDocumentPrivate, 1); - - document->priv->uri = NULL; - document->priv->untitled_number = 0; - - document->priv->readonly = FALSE; - - document->priv->last_save_was_manually = TRUE; - - document->priv->undo_manager = gedit_undo_manager_new (document); - - if (gedit_prefs_manager_get_save_encoding () == - GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL) - { - const gchar *encoding = NULL; - g_get_charset(&encoding); - - document->priv->encoding = g_strdup (encoding); - } - else - document->priv->encoding = NULL; - - g_signal_connect (G_OBJECT (document->priv->undo_manager), "can_undo", - G_CALLBACK (gedit_document_can_undo_handler), - document); - - g_signal_connect (G_OBJECT (document->priv->undo_manager), "can_redo", - G_CALLBACK (gedit_document_can_redo_handler), - document); -} - -static void -gedit_document_finalize (GObject *object) -{ - GeditDocument *document; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (object != NULL); - g_return_if_fail (GEDIT_IS_DOCUMENT (object)); - - document = GEDIT_DOCUMENT (object); - - g_return_if_fail (document->priv != NULL); - - if (document->priv->auto_save_timeout > 0) - g_source_remove (document->priv->auto_save_timeout); - - if (document->priv->untitled_number > 0) - { - g_return_if_fail (document->priv->uri == NULL); - gedit_document_release_untitled_number ( - document->priv->untitled_number); - } - - if (document->priv->uri) - { - g_free (document->priv->uri); - document->priv->uri = NULL; - } - - if (document->priv->last_searched_text) - g_free (document->priv->last_searched_text); - - if (document->priv->last_replace_text) - g_free (document->priv->last_replace_text); - - - g_object_unref (G_OBJECT (document->priv->undo_manager)); - - g_free (document->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/** - * gedit_document_new: - * - * Creates a new untitled document. - * - * Return value: a new untitled document - **/ -GeditDocument* -gedit_document_new (void) -{ - GeditDocument *document; - - gedit_debug (DEBUG_DOCUMENT, ""); - - document = GEDIT_DOCUMENT (g_object_new (GEDIT_TYPE_DOCUMENT, NULL)); - - g_return_val_if_fail (document->priv != NULL, NULL); - - document->priv->untitled_number = gedit_document_get_untitled_number (); - g_return_val_if_fail (document->priv->untitled_number > 0, NULL); - - return document; -} - -/** - * gedit_document_new_with_uri: - * @uri: the URI of the file that has to be loaded - * @error: return location for error or NULL - * - * Creates a new document. - * - * Return value: a new document - **/ -GeditDocument* -gedit_document_new_with_uri (const gchar *uri, GError **error) -{ - GeditDocument *document; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (uri != NULL, NULL); - - document = GEDIT_DOCUMENT (g_object_new (GEDIT_TYPE_DOCUMENT, NULL)); - - g_return_val_if_fail (document->priv != NULL, NULL); - document->priv->uri = g_strdup (uri); - - if (!gedit_document_load (document, uri, error)) - { - gedit_debug (DEBUG_DOCUMENT, "ERROR"); - - g_object_unref (document); - return NULL; - } - - return document; -} - -/** - * gedit_document_set_readonly: - * @document: a #GeditDocument - * @readonly: if TRUE (FALSE) the @document will be set as (not) readonly - * - * Set the value of the readonly flag. - **/ -void -gedit_document_set_readonly (GeditDocument *document, gboolean readonly) -{ - gboolean auto_save; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (document != NULL); - g_return_if_fail (document->priv != NULL); - - auto_save = gedit_prefs_manager_get_auto_save (); - - if (readonly) - { - if (auto_save && (document->priv->auto_save_timeout > 0)) - { - gedit_debug (DEBUG_DOCUMENT, "Remove autosave timeout"); - - g_source_remove (document->priv->auto_save_timeout); - document->priv->auto_save_timeout = 0; - } - } - else - { - if (auto_save && (document->priv->auto_save_timeout <= 0)) - { - gint auto_save_interval; - - gedit_debug (DEBUG_DOCUMENT, "Install autosave timeout"); - - auto_save_interval = - gedit_prefs_manager_get_auto_save_interval (); - - document->priv->auto_save_timeout = g_timeout_add - (auto_save_interval * 1000 * 60, - (GSourceFunc)gedit_document_auto_save_timeout, - document); - } - } - - if (document->priv->readonly == readonly) - return; - - document->priv->readonly = readonly; - - g_signal_emit (G_OBJECT (document), - document_signals[READONLY_CHANGED], - 0, - readonly); -} - -/** - * gedit_document_is_readonly: - * @document: a #GeditDocument - * - * Returns TRUE is @document is readonly. - * - * Return value: TRUE if @document is readonly. FALSE otherwise. - **/ -gboolean -gedit_document_is_readonly (GeditDocument *document) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (document != NULL, TRUE); - g_return_val_if_fail (document->priv != NULL, TRUE); - - return document->priv->readonly; -} - -static void -gedit_document_real_name_changed (GeditDocument *document) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (document != NULL); -} - -static void -gedit_document_real_loaded (GeditDocument *document) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (document != NULL); -} - -static void -gedit_document_real_saved (GeditDocument *document) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (document != NULL); -} - -static void -gedit_document_real_readonly_changed (GeditDocument *document, gboolean readonly) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (document != NULL); -} - - -gchar* -gedit_document_get_raw_uri (const GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - if (doc->priv->uri == NULL) - return NULL; - else - return g_strdup (doc->priv->uri); -} - -/* - * Returns a well formatted (ready to display) URI in UTF-8 format - * See: gedit_document_get_raw_uri to have a raw uri (non UTF-8) - */ -gchar* -gedit_document_get_uri (const GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - if (doc->priv->uri == NULL) - return g_strdup_printf (_("%s %d"), _("Untitled"), doc->priv->untitled_number); - else - { - gchar *res; - - res = eel_format_uri_for_display (doc->priv->uri); - g_return_val_if_fail (res != NULL, g_strdup (_("Invalid file name"))); - - return res; - } -} - -gchar* -gedit_document_get_short_name (const GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - if (doc->priv->uri == NULL) - return g_strdup_printf (_("%s %d"), _("Untitled"), doc->priv->untitled_number); - else - { - gchar *basename; - gchar *utf8_basename; - - basename = eel_uri_get_basename (doc->priv->uri); - - if (basename != NULL) - { - gboolean filenames_are_locale_encoded; - filenames_are_locale_encoded = g_getenv ("G_BROKEN_FILENAMES") != NULL; - - if (filenames_are_locale_encoded) - { - utf8_basename = g_locale_to_utf8 (basename, -1, NULL, NULL, NULL); - - if (utf8_basename != NULL) - { - g_free (basename); - return utf8_basename; - } - } - else - { - if (g_utf8_validate (basename, -1, NULL)) - return basename; - } - - /* there are problems */ - utf8_basename = eel_make_valid_utf8 (basename); - g_free (basename); - return utf8_basename; - } - else - return g_strdup (_("Invalid file name")); - } -} - -GQuark -gedit_document_io_error_quark (void) -{ - static GQuark quark; - - if (!quark) - quark = g_quark_from_static_string ("gedit_io_load_error"); - - return quark; -} - -static gboolean -gedit_document_auto_save_timeout (GeditDocument *doc) -{ - GError *error = NULL; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (!gedit_document_is_readonly (doc), FALSE); - - /* Remove timeout if now auto_save is FALSE */ - if (!gedit_prefs_manager_get_auto_save ()) - return FALSE; - - if (!gedit_document_get_modified (doc)) - return TRUE; - - gedit_document_auto_save (doc, &error); - - if (error) - { - /* FIXME - Should we actually tell - * the user there was an error? - James */ - g_error_free (error); - return TRUE; - } - - return TRUE; -} - -static gboolean -gedit_document_auto_save (GeditDocument* doc, GError **error) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - - if (gedit_document_save_as_real (doc, doc->priv->uri, doc->priv->last_save_was_manually, NULL)) - doc->priv->last_save_was_manually = FALSE; - - return TRUE; -} - -/** - * gedit_document_load: - * @doc: a GeditDocument - * @uri: the URI of the file that has to be loaded - * @error: return location for error or NULL - * - * Read a document from a file - * - * Return value: TRUE if the file is correctly loaded - **/ -gboolean -gedit_document_load (GeditDocument* doc, const gchar *uri, GError **error) -{ - char* file_contents; - GnomeVFSResult res; - gsize file_size; - GtkTextIter iter, end; - - gedit_debug (DEBUG_DOCUMENT, "File to load: %s", uri); - - g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (uri != NULL, FALSE); - - res = eel_read_entire_file (uri, &file_size, &file_contents); - - gedit_debug (DEBUG_DOCUMENT, "End reading %s (result: %s)", uri, gnome_vfs_result_to_string (res)); - - if (res != GNOME_VFS_OK) - { - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, res, - gnome_vfs_result_to_string (res)); - return FALSE; - } - - if (file_size > 0) - { - if (!g_utf8_validate (file_contents, file_size, NULL)) - { - /* The file contains invalid UTF8 data */ - /* Try to convert it to UTF-8 from currence locale */ - GError *conv_error = NULL; - gchar* converted_file_contents = NULL; - gsize bytes_written; - - converted_file_contents = g_locale_to_utf8 (file_contents, file_size, - NULL, &bytes_written, &conv_error); - - if ((conv_error != NULL) || - !g_utf8_validate (converted_file_contents, bytes_written, NULL)) - { - /* Coversion failed */ - if (conv_error != NULL) { - g_error_free (conv_error); - conv_error = NULL; - } - - if (converted_file_contents != NULL) - g_free (converted_file_contents); - - /* Try to convert it to UTF-8 from default encoding */ - converted_file_contents = g_convert (file_contents, file_size, - "UTF-8", DEFAULT_ENCODING, - NULL, &bytes_written, &conv_error); - - if ((conv_error != NULL) || - !g_utf8_validate (converted_file_contents, bytes_written, NULL)) - { - /* Coversion failed */ - if (conv_error != NULL) - g_error_free (conv_error); - - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, - GEDIT_ERROR_INVALID_UTF8_DATA, - _("Invalid UTF-8 data")); - - if (converted_file_contents != NULL) - g_free (converted_file_contents); - - g_free (file_contents); - - return FALSE; - } - else - { - if (doc->priv->encoding != NULL) - g_free (doc->priv->encoding); - - doc->priv->encoding = g_strdup (DEFAULT_ENCODING); - } - - } - else - { - const gchar *encoding = NULL; - g_get_charset(&encoding); - - if (doc->priv->encoding != NULL) - g_free (doc->priv->encoding); - - doc->priv->encoding = g_strdup (encoding); - } - - g_free (file_contents); - - file_contents = converted_file_contents; - file_size = bytes_written; - } - else - { - if (doc->priv->encoding != NULL) - { - g_free (doc->priv->encoding); - doc->priv->encoding = NULL; - } - } - - gedit_debug (DEBUG_DOCUMENT, "Document encoding: %s", - doc->priv->encoding == NULL ? "UTF-8 (Null)" : doc->priv->encoding); - - gedit_undo_manager_begin_not_undoable_action (doc->priv->undo_manager); - /* Insert text in the buffer */ - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, 0); - gtk_text_buffer_insert (GTK_TEXT_BUFFER (doc), &iter, file_contents, file_size); - - /* We had a newline in the buffer to begin with. (The buffer always contains - * a newline, so we delete to the end of the buffer to clean up. */ - gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &end); - gtk_text_buffer_delete (GTK_TEXT_BUFFER (doc), &iter, &end); - - /* Place the cursor at the start of the document */ - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, 0); - gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &iter); - - gedit_undo_manager_end_not_undoable_action (doc->priv->undo_manager); - } - - g_free (file_contents); - - if (gedit_utils_is_uri_read_only (uri)) - { - gedit_debug (DEBUG_DOCUMENT, "READ-ONLY"); - - gedit_document_set_readonly (doc, TRUE); - } - else - { - gedit_debug (DEBUG_DOCUMENT, "NOT READ-ONLY"); - - gedit_document_set_readonly (doc, FALSE); - } - - gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), FALSE); - - gedit_document_set_uri (doc, uri); - - g_signal_emit (G_OBJECT (doc), document_signals[LOADED], 0); - - return TRUE; -} - -#define GEDIT_STDIN_BUFSIZE 1024 - -gboolean -gedit_document_load_from_stdin (GeditDocument* doc, GError **error) -{ - GString * file_contents; - gchar *tmp_buf = NULL; - struct stat stats; - guint buffer_length; - - GtkTextIter iter, end; - GnomeVFSResult res; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - - fstat (STDIN_FILENO, &stats); - - if (stats.st_size == 0) - return FALSE; - - tmp_buf = g_new0 (gchar, GEDIT_STDIN_BUFSIZE + 1); - g_return_val_if_fail (tmp_buf != NULL, FALSE); - - file_contents = g_string_new (NULL); - - while (feof (stdin) == 0) - { - buffer_length = fread (tmp_buf, 1, GEDIT_STDIN_BUFSIZE, stdin); - tmp_buf [buffer_length] = '\0'; - g_string_append (file_contents, tmp_buf); - - if (ferror (stdin) != 0) - { - res = gnome_vfs_result_from_errno (); - - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, res, - gnome_vfs_result_to_string (res)); - - g_free (tmp_buf); - g_string_free (file_contents, TRUE); - return FALSE; - } - } - - fclose (stdin); - - if (file_contents->len > 0) - { - if (!g_utf8_validate (file_contents->str, file_contents->len, NULL)) - { - /* The file contains invalid UTF8 data */ - /* Try to convert it to UTF-8 from currence locale */ - GError *conv_error = NULL; - gchar* converted_file_contents = NULL; - gsize bytes_written; - - converted_file_contents = g_locale_to_utf8 (file_contents->str, file_contents->len, - NULL, &bytes_written, &conv_error); - - if ((conv_error != NULL) || - !g_utf8_validate (converted_file_contents, bytes_written, NULL)) - { - - /* Coversion failed */ - if (conv_error != NULL) - g_error_free (conv_error); - - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, - GEDIT_ERROR_INVALID_UTF8_DATA, - _("Invalid UTF-8 data")); - - if (converted_file_contents != NULL) - g_free (converted_file_contents); - - g_string_free (file_contents, TRUE); - - return FALSE; - } - - g_string_free (file_contents, TRUE); - - /* FIXME: this could be more efficient */ - file_contents = g_string_new (converted_file_contents); - } - - gedit_undo_manager_begin_not_undoable_action (doc->priv->undo_manager); - /* Insert text in the buffer */ - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, 0); - gtk_text_buffer_insert (GTK_TEXT_BUFFER (doc), &iter, file_contents->str, file_contents->len); - - /* We had a newline in the buffer to begin with. (The buffer always contains - * a newline, so we delete to the end of the buffer to clean up. */ - gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &end); - gtk_text_buffer_delete (GTK_TEXT_BUFFER (doc), &iter, &end); - - /* Place the cursor at the start of the document */ - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, 0); - gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &iter); - - gedit_undo_manager_end_not_undoable_action (doc->priv->undo_manager); - } - - g_string_free (file_contents, TRUE); - - gedit_document_set_readonly (doc, FALSE); - gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), TRUE); - - g_signal_emit (G_OBJECT (doc), document_signals [LOADED], 0); - - return TRUE; -} - - -gboolean -gedit_document_is_untouched (const GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - return (doc->priv->uri == NULL) && - (!gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc))); -} - -static void -gedit_document_set_uri (GeditDocument* doc, const gchar* uri) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (doc != NULL); - g_return_if_fail (doc->priv != NULL); - - if (doc->priv->uri == uri) - return; - - if (doc->priv->uri != NULL) - g_free (doc->priv->uri); - - doc->priv->uri = g_strdup (uri); - - if (doc->priv->untitled_number > 0) - { - gedit_document_release_untitled_number (doc->priv->untitled_number); - doc->priv->untitled_number = 0; - } - - g_signal_emit (G_OBJECT (doc), document_signals[NAME_CHANGED], 0); -} - -gboolean -gedit_document_save (GeditDocument* doc, GError **error) -{ - gboolean auto_save; - gboolean create_backup_copy; - - gboolean ret; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - g_return_val_if_fail (!doc->priv->readonly, FALSE); - g_return_val_if_fail (doc->priv->uri != NULL, FALSE); - - auto_save = gedit_prefs_manager_get_auto_save (); - create_backup_copy = gedit_prefs_manager_get_create_backup_copy (); - - if (auto_save) - { - if (doc->priv->auto_save_timeout > 0) - { - g_source_remove (doc->priv->auto_save_timeout); - doc->priv->auto_save_timeout = 0; - } - } - - ret = gedit_document_save_as_real (doc, - doc->priv->uri, - create_backup_copy, - error); - - if (ret) - doc->priv->last_save_was_manually = TRUE; - - if (auto_save && (doc->priv->auto_save_timeout <= 0)) - { - gint auto_save_interval = - gedit_prefs_manager_get_auto_save_interval (); - - doc->priv->auto_save_timeout = - g_timeout_add (auto_save_interval * 1000 * 60, - (GSourceFunc) gedit_document_auto_save, - doc); - } - - return ret; -} - -gboolean -gedit_document_save_as (GeditDocument* doc, const gchar *uri, GError **error) -{ - gboolean auto_save; - - gboolean ret = FALSE; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - g_return_val_if_fail (uri != NULL, FALSE); - - auto_save = gedit_prefs_manager_get_auto_save (); - - if (auto_save) - { - - if (doc->priv->auto_save_timeout > 0) - { - g_source_remove (doc->priv->auto_save_timeout); - doc->priv->auto_save_timeout = 0; - } - } - - if (gedit_document_save_as_real (doc, uri, TRUE, error)) - { - gedit_document_set_uri (doc, uri); - gedit_document_set_readonly (doc, FALSE); - doc->priv->last_save_was_manually = TRUE; - - ret = TRUE; - } - - if (auto_save && (doc->priv->auto_save_timeout <= 0)) - { - gint auto_save_interval = - gedit_prefs_manager_get_auto_save_interval (); - - doc->priv->auto_save_timeout = - g_timeout_add (auto_save_interval * 1000 * 60, - (GSourceFunc)gedit_document_auto_save, doc); - } - - return ret; -} - -gboolean -gedit_document_save_a_copy_as (GeditDocument* doc, const gchar *uri, GError **error) -{ - gboolean m; - gboolean ret; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - g_return_val_if_fail (uri != NULL, FALSE); - - m = gedit_document_get_modified (doc); - - ret = gedit_document_save_as_real (doc, uri, FALSE, error); - - gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), m); - - return ret; -} - -#define MAX_LINK_LEVEL 256 - -/* Does readlink() recursively until we find a real filename. */ -static char * -follow_symlinks (const gchar *filename, GError **error) -{ - gchar *followed_filename; - gint link_count; - - g_return_val_if_fail (filename != NULL, NULL); - - gedit_debug (DEBUG_DOCUMENT, "Filename: %s", filename); - g_return_val_if_fail (strlen (filename) + 1 <= GEDIT_MAX_PATH_LEN, NULL); - - followed_filename = g_strdup (filename); - link_count = 0; - - while (link_count < MAX_LINK_LEVEL) - { - struct stat st; - - if (lstat (followed_filename, &st) != 0) - /* We could not access the file, so perhaps it does not - * exist. Return this as a real name so that we can - * attempt to create the file. - */ - return followed_filename; - - if (S_ISLNK (st.st_mode)) - { - gint len; - gchar linkname[GEDIT_MAX_PATH_LEN]; - - link_count++; - - len = readlink (followed_filename, linkname, GEDIT_MAX_PATH_LEN - 1); - - if (len == -1) - { - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, - _("Could not read symbolic link information " - "for %s"), followed_filename); - g_free (followed_filename); - return NULL; - } - - linkname[len] = '\0'; - - /* If the linkname is not an absolute path name, append - * it to the directory name of the followed filename. E.g. - * we may have /foo/bar/baz.lnk -> eek.txt, which really - * is /foo/bar/eek.txt. - */ - - if (linkname[0] != G_DIR_SEPARATOR) - { - gchar *slashpos; - gchar *tmp; - - slashpos = strrchr (followed_filename, G_DIR_SEPARATOR); - - if (slashpos) - *slashpos = '\0'; - else - { - tmp = g_strconcat ("./", followed_filename, NULL); - g_free (followed_filename); - followed_filename = tmp; - } - - tmp = g_build_filename (followed_filename, linkname, NULL); - g_free (followed_filename); - followed_filename = tmp; - } - else - { - g_free (followed_filename); - followed_filename = g_strdup (linkname); - } - } else - return followed_filename; - } - - /* Too many symlinks */ - - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, ELOOP, - _("The file has too many symbolic links.")); - - return NULL; -} - -/* FIXME: define new ERROR_CODE and remove the error - * strings from here -- Paolo - */ - -static gboolean -gedit_document_save_as_real (GeditDocument* doc, const gchar *uri, - gboolean create_backup_copy, GError **error) -{ - gchar *filename; /* Filename without URI scheme */ - gchar *real_filename; /* Final filename with no symlinks */ - gchar *backup_filename; /* Backup filename, like real_filename.bak */ - gchar *temp_filename; /* Filename for saving */ - gchar *slashpos; - gchar *dirname; - mode_t saved_umask; - struct stat st; - char *chars; - gint chars_len; - gint fd; - gint retval; - GeditSaveEncodingSetting encoding_setting; - gboolean res; - gboolean add_cr; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - g_return_val_if_fail (uri != NULL, FALSE); - - retval = FALSE; - - filename = NULL; - real_filename = NULL; - backup_filename = NULL; - temp_filename = NULL; - - /* We don't support non-file:/// stuff */ - - if (!gedit_utils_uri_has_file_scheme (uri)) - { - gchar *error_message; - gchar *scheme_string; - - gchar *temp = eel_uri_get_scheme (uri); - scheme_string = eel_make_valid_utf8 (temp); - g_free (temp); - - if (scheme_string != NULL) - { - error_message = g_strdup_printf ( - _("gedit cannot handle %s: locations in write mode."), - scheme_string); - - g_free (scheme_string); - } - else - error_message = g_strdup_printf ( - _("gedit cannot handle this kind of location in write mode.")); - - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, EROFS, error_message); - g_free (error_message); - return FALSE; - } - - /* Get filename from uri */ - filename = gnome_vfs_get_local_path_from_uri (uri); - - if (!filename) - { - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, 0, - _("Invalid filename.")); - goto out; - } - - /* Get the real filename and file permissions */ - - real_filename = follow_symlinks (filename, error); - - if (!real_filename) - goto out; - - /* Get the directory in which the real filename lives */ - - slashpos = strrchr (real_filename, G_DIR_SEPARATOR); - - if (slashpos) - { - dirname = g_strdup (real_filename); - dirname[slashpos - real_filename + 1] = '\0'; - } - else - dirname = g_strdup ("."); - - /* If there is not an existing file with that name, compute the - * permissions and uid/gid that we will use for the newly-created file. - */ - - if (stat (real_filename, &st) != 0) - { - struct stat dir_st; - int result; - - /* File does not exist? */ - create_backup_copy = FALSE; - - /* Use default permissions */ - saved_umask = umask (0); - st.st_mode = 0666 & ~saved_umask; - umask (saved_umask); - st.st_uid = getuid (); - - result = stat (dirname, &dir_st); - - if (result == 0 && (dir_st.st_mode & S_ISGID)) - st.st_gid = dir_st.st_gid; - else - st.st_gid = getgid (); - } - - /* Save to a temporary file. We set the umask because some (buggy) - * implementations of mkstemp() use permissions 0666 and we want 0600. - */ - - temp_filename = g_build_filename (dirname, ".gedit-save-XXXXXX", NULL); - g_free (dirname); - - saved_umask = umask (0077); - fd = g_mkstemp (temp_filename); /* this modifies temp_filename to the used name */ - umask (saved_umask); - - if (fd == -1) - { - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, " "); - goto out; - } - - chars = gedit_document_get_buffer (doc); - - encoding_setting = gedit_prefs_manager_get_save_encoding (); - - if (encoding_setting == GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE) - { - GError *conv_error = NULL; - gchar* converted_file_contents = NULL; - - gedit_debug (DEBUG_DOCUMENT, "Using current locale's encoding"); - - converted_file_contents = g_locale_from_utf8 (chars, -1, NULL, NULL, &conv_error); - - if (conv_error != NULL) - { - /* Conversion error */ - g_error_free (conv_error); - } - else - { - g_free (chars); - chars = converted_file_contents; - } - } - else - { - if ((doc->priv->encoding != NULL) && - ((encoding_setting == GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE) || - (encoding_setting == GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL))) - { - GError *conv_error = NULL; - gchar* converted_file_contents = NULL; - - gedit_debug (DEBUG_DOCUMENT, "Using encoding %s", doc->priv->encoding); - - /* Try to convert it from UTF-8 to original encoding */ - converted_file_contents = g_convert (chars, -1, - doc->priv->encoding, "UTF-8", - NULL, NULL, &conv_error); - - if (conv_error != NULL) - { - /* Conversion error */ - g_error_free (conv_error); - } - else - { - g_free (chars); - chars = converted_file_contents; - } - } - else - gedit_debug (DEBUG_DOCUMENT, "Using UTF-8 (Null)"); - - } - - chars_len = strlen (chars); - - add_cr = (*(chars + chars_len - 1) != '\n'); - - /* Save the file content */ - res = (write (fd, chars, chars_len) == chars_len); - - if (res && add_cr) - /* Add \n if needed */ - res = (write (fd, "\n", 1) == 1); - - if (!res) - { - gchar *msg; - - switch (errno) - { - case ENOSPC: - msg = _("There is not enough disk space to save the file.\n" - "Please free some disk space and try again."); - break; - - case EFBIG: - msg = _("The disk where you are trying to save the file has " - "a limitation on file sizes. Please try saving " - "a smaller file or saving it to a disk that does not " - "have this limitation."); - break; - - default: - msg = " "; - break; - } - - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, msg); - close (fd); - unlink (temp_filename); - goto out; - } - - if (close (fd) != 0) - { - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, " "); - unlink (temp_filename); - goto out; - } - - /* Move the original file to a backup */ - - if (create_backup_copy) - { - gint result; - - backup_filename = g_strconcat (real_filename, - gedit_prefs_manager_get_backup_extension (), - NULL); - - result = rename (real_filename, backup_filename); - - if (result != 0) - { - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, - _("Could not create a backup file.")); - unlink (temp_filename); - goto out; - } - } - - /* Move the temp file to the original file */ - - if (rename (temp_filename, real_filename) != 0) - { - gint saved_errno; - - saved_errno = errno; - - if (create_backup_copy && rename (backup_filename, real_filename) != 0) - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, errno, - " "); - else - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, saved_errno, - " "); - - goto out; - } - - /* Restore permissions. There is not much error checking we can do - * here, I'm afraid. The final data is saved anyways. - */ - - chmod (real_filename, st.st_mode); - chown (real_filename, st.st_uid, st.st_gid); - - gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), FALSE); - - retval = TRUE; - - /* Done */ - - out: - - g_free (filename); - g_free (real_filename); - g_free (backup_filename); - g_free (temp_filename); - - return retval; -} - -gchar* -gedit_document_get_buffer (const GeditDocument *doc) -{ - GtkTextIter start, end; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &start, 0); - gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &end); - - return gtk_text_buffer_get_slice (GTK_TEXT_BUFFER (doc), &start, &end, TRUE); -} - -gboolean -gedit_document_is_untitled (const GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - - return (doc->priv->uri == NULL); -} - -gboolean -gedit_document_get_modified (const GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - - return gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)); -} - -/** - * gedit_document_get_char_count: - * @doc: a #GeditDocument - * - * Gets the number of characters in the buffer; note that characters - * and bytes are not the same, you can't e.g. expect the contents of - * the buffer in string form to be this many bytes long. - * - * Return value: number of characters in the document - **/ -gint -gedit_document_get_char_count (const GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - - return gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (doc)); -} - -/** - * gedit_document_get_line_count: - * @doc: a #GeditDocument - * - * Obtains the number of lines in the buffer. - * - * Return value: number of lines in the document - **/ -gint -gedit_document_get_line_count (const GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - - return gtk_text_buffer_get_line_count (GTK_TEXT_BUFFER (doc)); -} - -void -gedit_document_delete_all_text (GeditDocument *doc) -{ - GtkTextIter start, end; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (doc != NULL); - - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &start, 0); - gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &end); - - gtk_text_buffer_delete (GTK_TEXT_BUFFER (doc), &start, &end); -} - -gboolean -gedit_document_revert (GeditDocument *doc, GError **error) -{ - gchar* buffer = NULL; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (doc != NULL, FALSE); - - if (gedit_document_is_untitled (doc)) - { - g_set_error (error, GEDIT_DOCUMENT_IO_ERROR, GEDIT_ERROR_UNTITLED, - _("It is not possible to revert an Untitled document")); - return FALSE; - } - - buffer = gedit_document_get_buffer (doc); - - gedit_undo_manager_begin_not_undoable_action (doc->priv->undo_manager); - - gedit_document_delete_all_text (doc); - - if (!gedit_document_load (doc, doc->priv->uri, error)) - { - GtkTextIter iter; - - /* Insert text in the buffer */ - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, 0); - gtk_text_buffer_insert (GTK_TEXT_BUFFER (doc), &iter, buffer, -1); - - g_free (buffer); - - gedit_undo_manager_end_not_undoable_action (doc->priv->undo_manager); - - return FALSE; - } - - gedit_undo_manager_end_not_undoable_action (doc->priv->undo_manager); - - g_free (buffer); - - return TRUE; -} - -void -gedit_document_insert_text (GeditDocument *doc, gint pos, const gchar *text, gint len) -{ - GtkTextIter iter; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (pos >= 0); - g_return_if_fail (text != NULL); - g_return_if_fail (g_utf8_validate (text, len, NULL)); - - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, pos); - - gtk_text_buffer_insert (GTK_TEXT_BUFFER (doc), &iter, text, len); -} - -void -gedit_document_insert_text_at_cursor (GeditDocument *doc, const gchar *text, gint len) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (text != NULL); - g_return_if_fail (g_utf8_validate (text, len, NULL)); - - gtk_text_buffer_insert_at_cursor (GTK_TEXT_BUFFER (doc), text, len); -} - - -void -gedit_document_delete_text (GeditDocument *doc, gint start, gint end) -{ - GtkTextIter start_iter; - GtkTextIter end_iter; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (start >= 0); - g_return_if_fail (end >= 0); - - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &start_iter, start); - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &end_iter, end); - - gtk_text_buffer_delete (GTK_TEXT_BUFFER (doc), &start_iter, &end_iter); -} - -gchar* -gedit_document_get_chars (GeditDocument *doc, gint start, gint end) -{ - GtkTextIter start_iter; - GtkTextIter end_iter; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL); - g_return_val_if_fail (start >= 0, NULL); - g_return_val_if_fail (end >= 0, NULL); - - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &start_iter, start); - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &end_iter, end); - - return gtk_text_buffer_get_slice (GTK_TEXT_BUFFER (doc), &start_iter, &end_iter, TRUE); -} - - -gboolean -gedit_document_can_undo (const GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - - return gedit_undo_manager_can_undo (doc->priv->undo_manager); -} - -gboolean -gedit_document_can_redo (const GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - - return gedit_undo_manager_can_redo (doc->priv->undo_manager); -} - -void -gedit_document_undo (GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (doc->priv != NULL); - g_return_if_fail (gedit_undo_manager_can_undo (doc->priv->undo_manager)); - - gedit_undo_manager_undo (doc->priv->undo_manager); -} - -void -gedit_document_redo (GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (doc->priv != NULL); - g_return_if_fail (gedit_undo_manager_can_redo (doc->priv->undo_manager)); - - gedit_undo_manager_redo (doc->priv->undo_manager); -} - -void -gedit_document_begin_not_undoable_action (GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (doc->priv != NULL); - - gedit_undo_manager_begin_not_undoable_action (doc->priv->undo_manager); -} - -void -gedit_document_end_not_undoable_action (GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (doc->priv != NULL); - - gedit_undo_manager_end_not_undoable_action (doc->priv->undo_manager); -} - -void -gedit_document_begin_user_action (GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - - gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (doc)); -} - -void -gedit_document_end_user_action (GeditDocument *doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - - gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (doc)); -} - - -static void -gedit_document_can_undo_handler (GeditUndoManager* um, gboolean can_undo, GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - - g_signal_emit (G_OBJECT (doc), - document_signals [CAN_UNDO], - 0, - can_undo); -} - -static void -gedit_document_can_redo_handler (GeditUndoManager* um, gboolean can_redo, GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - - g_signal_emit (G_OBJECT (doc), - document_signals [CAN_REDO], - 0, - can_redo); -} - -void -gedit_document_goto_line (GeditDocument* doc, guint line) -{ - guint line_count; - GtkTextIter iter; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (doc->priv != NULL); - - line_count = gtk_text_buffer_get_line_count (GTK_TEXT_BUFFER (doc)); - - if (line > line_count) - line = line_count; - - gtk_text_buffer_get_iter_at_line (GTK_TEXT_BUFFER (doc), &iter, line); - gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &iter); -} - -gchar* -gedit_document_get_last_searched_text (GeditDocument* doc) -{ - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - - return doc->priv->last_searched_text != NULL ? - g_strdup (doc->priv->last_searched_text) : NULL; -} - -gchar* -gedit_document_get_last_replace_text (GeditDocument* doc) -{ - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - - return doc->priv->last_replace_text != NULL ? - g_strdup (doc->priv->last_replace_text) : NULL; -} - -gboolean -gedit_document_find (GeditDocument* doc, const gchar* str, - gboolean from_cursor, gboolean case_sensitive) -{ - GtkTextIter iter; - gboolean found = FALSE; - GtkTextSearchFlags search_flags; - gchar *converted_str; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - g_return_val_if_fail (str != NULL, FALSE); - - converted_str = gedit_utils_convert_search_text (str); - g_return_val_if_fail (converted_str != NULL, FALSE); - - gedit_debug (DEBUG_DOCUMENT, "str: %s", str); - gedit_debug (DEBUG_DOCUMENT, "converted_str: %s", converted_str); - - search_flags = GTK_TEXT_SEARCH_VISIBLE_ONLY | GTK_TEXT_SEARCH_TEXT_ONLY; - - if (!case_sensitive) - { - search_flags = search_flags | GTK_TEXT_SEARCH_CASE_INSENSITIVE; - } - - if (from_cursor) - { - GtkTextIter sel_bound; - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &iter, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "insert")); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &sel_bound, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "selection_bound")); - - gtk_text_iter_order (&sel_bound, &iter); - } - else - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, 0); - - if (*converted_str != '\0') - { - GtkTextIter match_start, match_end; - - found = gedit_text_iter_forward_search (&iter, converted_str, search_flags, - &match_start, &match_end, - NULL); - if (found) - { - gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), - &match_start); - - gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc), - "selection_bound", &match_end); - } - - if (doc->priv->last_searched_text) - g_free (doc->priv->last_searched_text); - - doc->priv->last_searched_text = g_strdup (str); - doc->priv->last_search_was_case_sensitive = case_sensitive; - } - - g_free (converted_str); - - return found; -} - -gboolean -gedit_document_find_again (GeditDocument* doc) -{ - gchar* last_searched_text; - gboolean found; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail (doc->priv != NULL, FALSE); - - last_searched_text = gedit_document_get_last_searched_text (doc); - - if (last_searched_text == NULL) - return FALSE; - - found = gedit_document_find (doc, last_searched_text, TRUE, - doc->priv->last_search_was_case_sensitive); - g_free (last_searched_text); - - return found; -} - -gchar* -gedit_document_get_selected_text (GeditDocument *doc, gint *start, gint *end) -{ - GtkTextIter iter; - GtkTextIter sel_bound; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &iter, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "insert")); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &sel_bound, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "selection_bound")); - gtk_text_iter_order (&iter, &sel_bound); - - if (start != NULL) - *start = gtk_text_iter_get_offset (&iter); - - if (end != NULL) - *end = gtk_text_iter_get_offset (&sel_bound); - - if (gtk_text_iter_equal (&sel_bound, &iter)) - { - gedit_debug (DEBUG_DOCUMENT, "There is no selected text"); - - return NULL; - } - return gtk_text_buffer_get_slice (GTK_TEXT_BUFFER (doc), &iter, &sel_bound, TRUE); -} - -gboolean -gedit_document_has_selected_text (GeditDocument *doc) -{ - GtkTextIter iter; - GtkTextIter sel_bound; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &iter, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "insert")); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &sel_bound, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "selection_bound")); - - return !gtk_text_iter_equal (&sel_bound, &iter); -} - -void -gedit_document_replace_selected_text (GeditDocument *doc, const gchar *replace) -{ - GtkTextIter iter; - GtkTextIter sel_bound; - gchar *converted_replace; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - g_return_if_fail (replace != NULL); - - converted_replace = gedit_utils_convert_search_text (replace); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &iter, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "insert")); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &sel_bound, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "selection_bound")); - - if (gtk_text_iter_equal (&sel_bound, &iter)) - { - gedit_debug (DEBUG_DOCUMENT, "There is no selected text"); - - return; - } - - gtk_text_iter_order (&sel_bound, &iter); - - gedit_document_begin_user_action (doc); - - gtk_text_buffer_delete (GTK_TEXT_BUFFER (doc), - &iter, - &sel_bound); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &iter, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "insert")); - if (*converted_replace != '\0') - gtk_text_buffer_insert (GTK_TEXT_BUFFER (doc), - &iter, - converted_replace, strlen (converted_replace)); - - if (doc->priv->last_replace_text != NULL) - g_free (doc->priv->last_replace_text); - - doc->priv->last_replace_text = g_strdup (replace); - - gedit_document_end_user_action (doc); - g_free (converted_replace); -} - -gboolean -gedit_document_replace_all (GeditDocument *doc, - const gchar *find, const gchar *replace, gboolean case_sensitive) -{ - gboolean from_cursor = FALSE; - gboolean cont = 0; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE); - g_return_val_if_fail (find != NULL, FALSE); - g_return_val_if_fail (replace != NULL, FALSE); - - gedit_document_begin_user_action (doc); - - while (gedit_document_find (doc, find, from_cursor, case_sensitive)) - { - gedit_document_replace_selected_text (doc, replace); - - from_cursor = TRUE; - ++cont; - } - - gedit_document_end_user_action (doc); - - return cont; -} - -guint -gedit_document_get_line_at_offset (const GeditDocument *doc, guint offset) -{ - GtkTextIter iter; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), 0); - - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, offset); - - return gtk_text_iter_get_line (&iter); -} - -gint gedit_document_get_cursor (GeditDocument *doc) -{ - GtkTextIter iter; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), 0); - - gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), - &iter, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), - "insert")); - - return gtk_text_iter_get_offset (&iter); -} - -void -gedit_document_set_cursor (GeditDocument *doc, gint cursor) -{ - GtkTextIter iter; - - gedit_debug (DEBUG_DOCUMENT, ""); - - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - - /* Place the cursor at the requested position */ - gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (doc), &iter, cursor); - gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &iter); -} diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h deleted file mode 100644 index 0f60579c7..000000000 --- a/gedit/gedit-document.h +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-document.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_DOCUMENT_H__ -#define __GEDIT_DOCUMENT_H__ - - -#include <gtk/gtk.h> - - -#define GEDIT_TYPE_DOCUMENT (gedit_document_get_type ()) -#define GEDIT_DOCUMENT(obj) (GTK_CHECK_CAST ((obj), GEDIT_TYPE_DOCUMENT, GeditDocument)) -#define GEDIT_DOCUMENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_DOCUMENT, GeditDocumentClass)) -#define GEDIT_IS_DOCUMENT(obj) (GTK_CHECK_TYPE ((obj), GEDIT_TYPE_DOCUMENT)) -#define GEDIT_IS_DOCUMENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_DOCUMENT)) -#define GEDIT_DOCUMENT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GEDIT_TYPE_DOCUMENT, GeditDocumentClass)) - - -typedef struct _GeditDocument GeditDocument; -typedef struct _GeditDocumentClass GeditDocumentClass; - -typedef struct _GeditDocumentPrivate GeditDocumentPrivate; - -struct _GeditDocument -{ - GtkTextBuffer buffer; - - GeditDocumentPrivate *priv; -}; - -struct _GeditDocumentClass -{ - GtkTextBufferClass parent_class; - - GtkTextTagTable *tag_table; - - /* File name (uri) changed */ - void (* name_changed) (GeditDocument *document); - - /* Document loaded */ - void (* loaded) (GeditDocument *document); - - /* Document saved */ - void (* saved) (GeditDocument *document); - - /* Readonly flag changed */ - void (* readonly_changed) (GeditDocument *document, - gboolean readonly); - - void (* can_undo) (GeditDocument *document, - gboolean can_undo); - void (* can_redo) (GeditDocument *document, - gboolean can_redo); - -}; -#define GEDIT_ERROR_INVALID_UTF8_DATA 1024 -#define GEDIT_ERROR_UNTITLED 1025 -#define GEDIT_DOCUMENT_IO_ERROR gedit_document_io_error_quark () -GQuark gedit_document_io_error_quark (void); - -GType gedit_document_get_type (void) G_GNUC_CONST; - -GeditDocument* gedit_document_new (void); -GeditDocument* gedit_document_new_with_uri (const gchar *uri, GError **error); - -void gedit_document_set_readonly (GeditDocument *doc, gboolean readonly); -gboolean gedit_document_is_readonly (GeditDocument *doc); - -gchar* gedit_document_get_raw_uri (const GeditDocument* doc); -gchar* gedit_document_get_uri (const GeditDocument* doc); -gchar* gedit_document_get_short_name (const GeditDocument* doc); - -gboolean gedit_document_load (GeditDocument* doc, - const gchar *uri, GError **error); -gboolean gedit_document_load_from_stdin (GeditDocument* doc, GError **error); - -gboolean gedit_document_is_untouched (const GeditDocument *doc); - -gboolean gedit_document_save (GeditDocument* doc, GError **error); -gboolean gedit_document_save_as (GeditDocument* doc, - const gchar *uri, GError **error); - -gboolean gedit_document_save_a_copy_as (GeditDocument* doc, - const gchar *uri, GError **error); - -gboolean gedit_document_revert (GeditDocument *doc, GError **error); - -gboolean gedit_document_is_untitled (const GeditDocument* doc); -gboolean gedit_document_get_modified (const GeditDocument* doc); - -gchar* gedit_document_get_buffer (const GeditDocument *doc); -gint gedit_document_get_char_count (const GeditDocument *doc); -gint gedit_document_get_line_count (const GeditDocument *doc); - -void gedit_document_delete_all_text (GeditDocument *doc); - -void gedit_document_insert_text (GeditDocument *doc, - gint pos, - const gchar *text, - gint len); - -void gedit_document_insert_text_at_cursor (GeditDocument *doc, - const gchar *text, - gint len); - -gint gedit_document_get_cursor (GeditDocument *doc); -void gedit_document_set_cursor (GeditDocument *doc, gint cursor); - -void gedit_document_delete_text (GeditDocument *doc, - gint start, gint end); - -gchar* gedit_document_get_chars (GeditDocument *doc, - gint start, gint end); - -gchar* gedit_document_get_selected_text (GeditDocument *doc, - gint* start, gint* end); - -gboolean gedit_document_has_selected_text (GeditDocument *doc); - -/* Multi-level Undo/Redo operations */ -gboolean gedit_document_can_undo (const GeditDocument *doc); -gboolean gedit_document_can_redo (const GeditDocument *doc); - -void gedit_document_undo (GeditDocument *doc); -void gedit_document_redo (GeditDocument *doc); - -void gedit_document_begin_not_undoable_action (GeditDocument *doc); -void gedit_document_end_not_undoable_action (GeditDocument *doc); - -void gedit_document_begin_user_action (GeditDocument *doc); -void gedit_document_end_user_action (GeditDocument *doc); - -void gedit_document_goto_line (GeditDocument* doc, guint line); - -gchar* gedit_document_get_last_searched_text (GeditDocument* doc); -gchar* gedit_document_get_last_replace_text (GeditDocument* doc); - -gboolean gedit_document_find (GeditDocument* doc, const gchar* str, - gboolean from_cursor, - gboolean case_sensitive); -gboolean gedit_document_find_again (GeditDocument* doc); - -void gedit_document_replace_selected_text (GeditDocument *doc, - const gchar *replace); -gboolean gedit_document_replace_all (GeditDocument *doc, - const gchar *find, const gchar *replace, - gboolean case_sensitive); -guint gedit_document_get_line_at_offset (const GeditDocument *doc, guint offset); - -#endif /* __GEDIT_DOCUMENT_H__ */ - - - diff --git a/gedit/gedit-file-selector-util.c b/gedit/gedit-file-selector-util.c deleted file mode 100644 index 12bd89f98..000000000 --- a/gedit/gedit-file-selector-util.c +++ /dev/null @@ -1,546 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-file-selector-util.c - * This file is part of gedit - * - * Copyright (C) 2001-2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -/* This file is a modified version of bonobo-file-selector-util.c - * taken from libbonoboui - */ - -/* - * bonobo-file-selector-util.c - functions for getting files from a - * selector - * - * Authors: - * Jacob Berkman <jacob@ximian.com> - * - * Copyright 2001 Ximian, Inc. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gedit-file-selector-util.h" - -#include <bonobo/bonobo-file-selector-util.h> - -#include <string.h> -#include <unistd.h> -#include <errno.h> - -#include <bonobo/bonobo-event-source.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-widget.h> - -#include <gtk/gtkmain.h> -#include <gtk/gtkclist.h> -#include <gtk/gtkfilesel.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkmessagedialog.h> -#include <gtk/gtkeditable.h> -#include <gtk/gtkstock.h> - -#include <bonobo/bonobo-i18n.h> - -#include <libgnomevfs/gnome-vfs.h> -#include <eel/eel-vfs-extensions.h> -#include <eel/eel-string.h> - -#include "gedit-utils.h" - -static GQuark user_data_id = 0; - -static gint -delete_file_selector (GtkWidget *d, GdkEventAny *e, gpointer data) -{ - gtk_widget_hide (d); - gtk_main_quit (); - return TRUE; -} - -/* Displays a confirmation dialog for whether to replace a file. The message - * should contain a %s to include the file name. - */ -static gboolean -replace_dialog (GtkWindow *parent, const gchar *message, const gchar *file_name) -{ - GtkWidget *msgbox; - gint ret; - gchar *full_formatted_uri; - gchar *uri_for_display ; - gchar *uri; - - uri = eel_make_uri_from_shell_arg (file_name); - g_return_val_if_fail (uri != NULL, FALSE); - - full_formatted_uri = eel_format_uri_for_display (uri); - g_return_val_if_fail (full_formatted_uri != NULL, FALSE); - g_free (uri); - - /* Truncate the URI so it doesn't get insanely wide. Note that even - * though the dialog uses wrapped text, if the URI doesn't contain - * white space then the text-wrapping code is too stupid to wrap it. - */ - uri_for_display = eel_str_middle_truncate (full_formatted_uri, 50); - g_return_val_if_fail (uri_for_display != NULL, FALSE); - - g_free (full_formatted_uri); - - msgbox = gtk_message_dialog_new (parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - message, - uri_for_display); - g_free (uri_for_display); - - /* Add Don't Replace button */ - gedit_dialog_add_button (GTK_DIALOG (msgbox), - _("Do_n't replace"), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - - /* Add Replace button */ - gedit_dialog_add_button (GTK_DIALOG (msgbox), - _("_Replace"), GTK_STOCK_REFRESH, GTK_RESPONSE_YES); - - gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_CANCEL); - - gtk_window_set_resizable (GTK_WINDOW (msgbox), FALSE); - - ret = gtk_dialog_run (GTK_DIALOG (msgbox)); - - gtk_widget_destroy (msgbox); - - return (ret == GTK_RESPONSE_YES); -} - -/* Presents a confirmation dialog for whether to replace an existing file */ -static gboolean -replace_existing_file (GtkWindow *parent, const gchar* file_name) -{ - return replace_dialog (parent, - _("A file named \"%s\" already exists.\n" - "Do you want to replace it with the " - "one you are saving?"), - file_name); -} - -/* Presents a confirmation dialog for whether to replace a read-only file */ -static gboolean -replace_read_only_file (GtkWindow *parent, const gchar* file_name) -{ - return replace_dialog (parent, - _("The file \"%s\" is read-only.\n" - "Do you want to try to replace it with the " - "one you are saving?"), - file_name); -} - -static void -listener_cb (BonoboListener *listener, - const gchar *event_name, - const CORBA_any *any, - CORBA_Environment *ev, - gpointer data) -{ - GtkWidget *dialog; - CORBA_sequence_CORBA_string *seq; - char *subtype; - GnomeVFSURI *uri; - - dialog = data; - - subtype = bonobo_event_subtype (event_name); - if (!strcmp (subtype, "Cancel")) - goto cancel_clicked; - - seq = any->_value; - if (seq->_length < 1) - goto cancel_clicked; - - - /* FIXME: does seq->_buffer[0] represent a canonical URI ?*/ - uri = gnome_vfs_uri_new (seq->_buffer[0]); - - if (gnome_vfs_uri_exists (uri)) - { - if (!replace_existing_file (GTK_WINDOW (dialog), seq->_buffer[0])) - { - gnome_vfs_uri_unref (uri); - g_free (subtype); - return; - } - } - - gnome_vfs_uri_unref (uri); - - g_object_set_qdata (G_OBJECT (dialog), - user_data_id, - g_strdup (seq->_buffer[0])); - - cancel_clicked: - gtk_widget_hide (dialog); - - g_free (subtype); - gtk_main_quit (); -} - -static BonoboWidget * -create_control (gboolean enable_vfs) -{ - CORBA_Environment ev; - BonoboWidget *bw; - char *moniker; - - moniker = g_strdup_printf ( - "OAFIID:GNOME_FileSelector_Control!" - "Application=%s;" - "EnableVFS=%d;" - "MultipleSelection=%d;" - "SaveMode=%d", - g_get_prgname (), - enable_vfs, - FALSE, - TRUE); - - bw = g_object_new (BONOBO_TYPE_WIDGET, NULL); - CORBA_exception_init (&ev); - - bw = bonobo_widget_construct_control ( - bw, moniker, CORBA_OBJECT_NIL, &ev); - - CORBA_exception_free (&ev); - g_free (moniker); - - return bw; -} - -static GtkWindow * -create_bonobo_selector (gboolean enable_vfs, - const char *mime_types, - const char *default_path, - const char *default_filename) - -{ - GtkWidget *dialog; - BonoboWidget *control; - - control = create_control (enable_vfs); - if (!control) - return NULL; - - dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (control)); - gtk_widget_set_size_request (dialog, 560, 450); - - bonobo_event_source_client_add_listener ( - bonobo_widget_get_objref (control), - listener_cb, - "GNOME/FileSelector/Control:ButtonClicked", - NULL, dialog); - - if (mime_types) - bonobo_widget_set_property ( - control, "MimeTypes", mime_types, NULL); - - if (default_path) - bonobo_widget_set_property ( - control, "DefaultLocation", default_path, NULL); - - if (default_filename) - bonobo_widget_set_property ( - control, "DefaultFileName", default_filename, NULL); - - return GTK_WINDOW (dialog); -} - -static char * -concat_dir_and_file (const char *dir, const char *file) -{ - g_return_val_if_fail (dir != NULL, NULL); - g_return_val_if_fail (file != NULL, NULL); - - /* If the directory name doesn't have a / on the end, we need - to add one so we get a proper path to the file */ - if (dir[0] != '\0' && dir [strlen(dir) - 1] != G_DIR_SEPARATOR) - return g_strconcat (dir, G_DIR_SEPARATOR_S, file, NULL); - else - return g_strconcat (dir, file, NULL); -} - -/* Tests whether we have write permissions for a file */ -static gboolean -is_read_only (const gchar *filename) -{ - if (access (filename, W_OK) == -1) - return (errno == EACCES); - else - return FALSE; -} - -static void -ok_clicked_cb (GtkWidget *widget, gpointer data) -{ - GtkFileSelection *fsel; - const gchar *file_name; - - fsel = data; - - file_name = gtk_file_selection_get_filename (fsel); - - if (!strlen (file_name)) - return; - - /* Change into directory if that's what user selected */ - if (g_file_test (file_name, G_FILE_TEST_IS_DIR)) { - gint name_len; - gchar *dir_name; - - name_len = strlen (file_name); - if (name_len < 1 || file_name [name_len - 1] != '/') { - /* The file selector needs a '/' at the end of a directory name */ - dir_name = g_strconcat (file_name, "/", NULL); - } else { - dir_name = g_strdup (file_name); - } - gtk_file_selection_set_filename (fsel, dir_name); - g_free (dir_name); - } - else - { - if (g_file_test (file_name, G_FILE_TEST_EXISTS)) - { - if (is_read_only (file_name)) - { - if (!replace_read_only_file (GTK_WINDOW (fsel), file_name)) - return; - } - else if (!replace_existing_file (GTK_WINDOW (fsel), file_name)) - return; - } - - gtk_widget_hide (GTK_WIDGET (fsel)); - - g_object_set_qdata (G_OBJECT (fsel), - user_data_id, - g_strdup (file_name)); - gtk_main_quit (); - } -} - -static void -cancel_clicked_cb (GtkWidget *widget, gpointer data) -{ - gtk_widget_hide (GTK_WIDGET (data)); - gtk_main_quit (); - - g_object_set_qdata (G_OBJECT (data), - user_data_id, - NULL); -} - - -static GtkWindow * -create_gtk_selector (const char *default_path, - const char *default_filename) -{ - GtkWidget *filesel; - - gchar* path; - - filesel = gtk_file_selection_new (NULL); - - g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button), - "clicked", G_CALLBACK (ok_clicked_cb), - filesel); - - g_signal_connect (G_OBJECT (GTK_FILE_SELECTION (filesel)->cancel_button), - "clicked", G_CALLBACK (cancel_clicked_cb), - filesel); - - if (default_path) - path = g_strconcat (default_path, - default_path[strlen (default_path) - 1] == '/' ? NULL : - "/", NULL); - else - path = g_strdup ("./"); - - if (default_filename) { - gchar* file_name = concat_dir_and_file (path, default_filename); - gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), file_name); - g_free (file_name); - - /* Select file name */ - gtk_editable_select_region (GTK_EDITABLE ( - GTK_FILE_SELECTION (filesel)->selection_entry), - 0, -1); - } - else - gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), path); - - g_free (path); - - return GTK_WINDOW (filesel); -} - -static gpointer -run_file_selector (GtkWindow *parent, - gboolean enable_vfs, - const char *title, - const char *mime_types, - const char *default_path, - const char *default_filename) - -{ - GtkWindow *dialog = NULL; - gpointer retval; - gpointer data; - gboolean using_bonobo_filesel = FALSE; - - if (!user_data_id) - user_data_id = g_quark_from_static_string ("GeditUserData"); - - if (!g_getenv ("GNOME_FILESEL_DISABLE_BONOBO")) - dialog = create_bonobo_selector (enable_vfs, mime_types, - default_path, default_filename); - - if (!dialog) - dialog = create_gtk_selector (default_path, default_filename); - else - using_bonobo_filesel = TRUE; - - gtk_window_set_title (dialog, title); - gtk_window_set_modal (dialog, TRUE); - - if (parent) - gtk_window_set_transient_for (dialog, parent); - - g_signal_connect (G_OBJECT (dialog), "delete_event", - G_CALLBACK (delete_file_selector), - dialog); - - gtk_widget_show_all (GTK_WIDGET (dialog)); - - gtk_main (); - - data = g_object_get_qdata (G_OBJECT (dialog), user_data_id); - - if ((data != NULL) && enable_vfs && !using_bonobo_filesel) - { - retval = gnome_vfs_get_uri_from_local_path (data); - g_free (data); - } - else - retval = data; - - gtk_widget_destroy (GTK_WIDGET (dialog)); - - return retval; -} - -/** - * gedit_file_selector_open: - * @parent: optional window the dialog should be a transient for. - * @enable_vfs: if FALSE, restrict files to local paths. - * @title: optional window title to use - * @mime_types: optional list of mime types to provide filters for. - * These are of the form: "HTML Files:text/html|Text Files:text/html,text/plain" - * @default_path: optional directory to start in - * - * Creates and shows a modal open file dialog, waiting for the user to - * select a file or cancel before returning. - * - * Return value: the URI (or plain file path if @enable_vfs is FALSE) - * of the file selected, or NULL if cancel was pressed. - **/ -char * -gedit_file_selector_open (GtkWindow *parent, - gboolean enable_vfs, - const char *title, - const char *mime_types, - const char *default_path) -{ - return bonobo_file_selector_open (parent, enable_vfs, - title, mime_types, default_path); -} - -/** - * gedit_file_selector_open_multi: - * @parent: optional window the dialog should be a transient for - * @enable_vfs: if FALSE, restrict files to local paths. - * @title: optional window title to use - * @mime_types: optional list of mime types to provide filters for. - * These are of the form: "HTML Files:text/html|Text Files:text/html,text/plain" - * @default_path: optional directory to start in - * - * Creates and shows a modal open file dialog, waiting for the user to - * select a file or cancel before returning. - * - * Return value: a NULL terminated string array of the selected URIs - * (or local file paths if @enable_vfs is FALSE), or NULL if cancel - * was pressed. - **/ -char ** -gedit_file_selector_open_multi (GtkWindow *parent, - gboolean enable_vfs, - const char *title, - const char *mime_types, - const char *default_path) -{ - return bonobo_file_selector_open_multi (parent, enable_vfs, - title, mime_types, default_path); -} - -/** - * gedit_file_selector_save: - * @parent: optional window the dialog should be a transient for - * @enable_vfs: if FALSE, restrict files to local paths. - * @title: optional window title to use - * @mime_types: optional list of mime types to provide filters for. - * These are of the form: "HTML Files:text/html|Text Files:text/html,text/plain" - * @default_path: optional directory to start in - * @default_filename: optional file name to default to - * - * Creates and shows a modal save file dialog, waiting for the user to - * select a file or cancel before returning. - * - * Return value: the URI (or plain file path if @enable_vfs is FALSE) - * of the file selected, or NULL if cancel was pressed. - **/ -char * -gedit_file_selector_save (GtkWindow *parent, - gboolean enable_vfs, - const char *title, - const char *mime_types, - const char *default_path, - const char *default_filename) -{ - return run_file_selector (parent, enable_vfs, - title ? title : _("Select a filename to save"), - mime_types, default_path, default_filename); -} diff --git a/gedit/gedit-file-selector-util.h b/gedit/gedit-file-selector-util.h deleted file mode 100644 index f5ee9aae3..000000000 --- a/gedit/gedit-file-selector-util.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-file-selector-util.h - * This file is part of gedit - * - * Copyright (C) 2001-2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -/* This file is a modified version of bonobo-file-selector-util.c - * taken from libbonoboui - */ - -/* - * bonobo-file-selector-util.h - functions for getting files from a - * selector - * - * Authors: - * Jacob Berkman <jacob@ximian.com> - * - * Copyright 2001 Ximian, Inc. - * - */ - -#ifndef __GEDIT_FILE_SELECTOR_UTIL_H_ -#define __GEDIT_FILE_SELECTOR_UTIL_H_ - -#include <glib/gmacros.h> -#include <gtk/gtkwindow.h> - -G_BEGIN_DECLS - -char *gedit_file_selector_open (GtkWindow *parent, - gboolean enable_vfs, - const char *title, - const char *mime_types, - const char *default_path); - -char **gedit_file_selector_open_multi (GtkWindow *parent, - gboolean enable_vfs, - const char *title, - const char *mime_types, - const char *default_path); - -char *gedit_file_selector_save (GtkWindow *parent, - gboolean enable_vfs, - const char *title, - const char *mime_types, - const char *default_path, - const char *default_filename); - -G_END_DECLS - -#endif /* __GEDIT_FILE_SELECTOR_UTIL_H_ */ diff --git a/gedit/gedit-file.c b/gedit/gedit-file.c deleted file mode 100644 index 25ed9df87..000000000 --- a/gedit/gedit-file.c +++ /dev/null @@ -1,920 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-file.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/libgnome.h> -#include <libgnomeui/libgnomeui.h> -#include <libgnomevfs/gnome-vfs.h> - -#include <eel/eel-vfs-extensions.h> - -#include "gedit2.h" -#include "gedit-file.h" -#include "gedit-debug.h" -#include "gedit-utils.h" -#include "gedit-mdi.h" -#include "gedit-recent.h" -#include "gedit-file-selector-util.h" -#include "gedit-plugins-engine.h" -#include "gnome-recent-model.h" -#include "gedit-prefs-manager.h" - -static gchar *get_dirname_from_uri (const char *uri); -static gboolean gedit_file_open_real (const gchar* file_name, - GeditMDIChild* child); -static gboolean gedit_file_save_as_real (const gchar* file_name, - GeditMDIChild *child); - -static gchar* gedit_default_path = NULL; - -static gchar * -get_dirname_from_uri (const char *uri) -{ - GnomeVFSURI *vfs_uri; - char *name; - - /* Make VFS version of URI. */ - vfs_uri = gnome_vfs_uri_new (uri); - if (vfs_uri == NULL) { - return NULL; - } - - /* Extract name part. */ - name = gnome_vfs_uri_extract_dirname (vfs_uri); - gnome_vfs_uri_unref (vfs_uri); - - return name; -} - - -void -gedit_file_new (void) -{ - gint ret; - GeditMDIChild* new_child = NULL; - - gedit_debug (DEBUG_FILE, ""); - - new_child = gedit_mdi_child_new (); - - g_return_if_fail (new_child != NULL); - g_return_if_fail (gedit_mdi != NULL); - - ret = bonobo_mdi_add_child (BONOBO_MDI (gedit_mdi), BONOBO_MDI_CHILD (new_child)); - g_return_if_fail (ret != FALSE); - gedit_debug (DEBUG_COMMANDS, "Child added."); - - ret = bonobo_mdi_add_view (BONOBO_MDI (gedit_mdi), BONOBO_MDI_CHILD (new_child)); - g_return_if_fail (ret != FALSE); - gedit_debug (DEBUG_COMMANDS, "View added."); - - gtk_widget_grab_focus (GTK_WIDGET (gedit_get_active_view ())); -} - -void -gedit_file_close (GtkWidget *view) -{ - gint ret; - BonoboMDIChild* child; - - gedit_debug (DEBUG_FILE, ""); - - g_return_if_fail (view != NULL); - - child = bonobo_mdi_get_child_from_view (view); - g_return_if_fail (child != NULL); - - if (g_list_length (bonobo_mdi_child_get_views (child)) > 1) - { - ret = bonobo_mdi_remove_view (BONOBO_MDI (gedit_mdi), view, FALSE); - gedit_debug (DEBUG_COMMANDS, "View removed."); - } - else - { - ret = bonobo_mdi_remove_child (BONOBO_MDI (gedit_mdi), child, FALSE); - gedit_debug (DEBUG_COMMANDS, "Child removed."); - } - - if (ret) - gedit_mdi_set_active_window_title (BONOBO_MDI (gedit_mdi)); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) == NULL) - { - gedit_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (gedit_mdi)); - gedit_mdi_clear_active_window_statusbar (gedit_mdi); - } - - gedit_debug (DEBUG_FILE, "END"); -} - -void -gedit_file_open (GeditMDIChild *active_child) -{ - gchar** files; - - gedit_debug (DEBUG_FILE, ""); - - files = gedit_file_selector_open_multi ( - GTK_WINDOW (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi))), - TRUE, - _("Open File ..."), - NULL, - gedit_default_path); - - if (files) - { - gint i; - for (i = 0; files[i]; ++i) - { - gedit_debug (DEBUG_FILE, "[%d]: %s", i, files[i]); - - if (gedit_file_open_real (files[i], active_child)) - { - gchar *uri_utf8; - - if (gedit_utils_uri_has_file_scheme (files[i])) - { - if (gedit_default_path != NULL) - g_free (gedit_default_path); - - gedit_default_path = get_dirname_from_uri (files[i]); - } - - uri_utf8 = eel_format_uri_for_display (files[i]); - if (uri_utf8 != NULL) - { - gedit_utils_flash_va (_("Loaded file '%s'"), uri_utf8); - - g_free (uri_utf8); - } - - } - - gedit_debug (DEBUG_FILE, "File: %s", files[i]); - } - - g_strfreev (files); - } -} - -static gboolean -gedit_file_open_real (const gchar* file_name, GeditMDIChild* active_child) -{ - GError *error = NULL; - gchar *uri; - - GnomeRecentModel *recent; - - gedit_debug (DEBUG_FILE, "File name: %s", file_name); - - uri = eel_make_uri_canonical (file_name); - g_return_val_if_fail (uri != NULL, FALSE); - gedit_debug (DEBUG_FILE, "Canonical uri: %s", uri); - - if (active_child == NULL || - !gedit_document_is_untouched (active_child->document)) - { - gint ret; - GeditMDIChild* new_child = NULL; - - new_child = gedit_mdi_child_new_with_uri (uri, &error); - - if (error) - { - gedit_utils_error_reporting_loading_file (uri, error, - GTK_WINDOW (gedit_get_active_window ())); - - g_error_free (error); - g_free (uri); - return FALSE; - } - - g_return_val_if_fail (new_child != NULL, FALSE); - g_return_val_if_fail (gedit_mdi != NULL, FALSE); - - ret = bonobo_mdi_add_child (BONOBO_MDI (gedit_mdi), BONOBO_MDI_CHILD (new_child)); - g_return_val_if_fail (ret != FALSE, FALSE); - gedit_debug (DEBUG_FILE, "Child added."); - - ret = bonobo_mdi_add_view (BONOBO_MDI (gedit_mdi), BONOBO_MDI_CHILD (new_child)); - g_return_val_if_fail (ret != FALSE, FALSE); - gedit_debug (DEBUG_FILE, "View added."); - } - else - { - gedit_document_load (active_child->document, uri, &error); - - if (error) - { - gedit_utils_error_reporting_loading_file (uri, error, - GTK_WINDOW (gedit_get_active_window ())); - - g_error_free (error); - g_free (uri); - return FALSE; - } - } - - recent = gedit_recent_get_model (); - gnome_recent_model_add (recent, uri); - - g_free (uri); - - gedit_debug (DEBUG_FILE, "END: %s\n", file_name); - - return TRUE; -} - -gboolean -gedit_file_save (GeditMDIChild* child) -{ - gint ret; - GeditDocument* doc = NULL; - GError *error = NULL; - gchar *uri = NULL; - - gedit_debug (DEBUG_FILE, ""); - - g_return_val_if_fail (child != NULL, FALSE); - - doc = child->document; - g_return_val_if_fail (doc != NULL, FALSE); - - if (gedit_document_is_untitled (doc)) - { - gedit_debug (DEBUG_FILE, "Untitled"); - - return gedit_file_save_as (child); - } - - if (!gedit_document_get_modified (doc)) - { - gchar *raw_uri; - gboolean deleted = FALSE; - - gedit_debug (DEBUG_FILE, "Not modified"); - - raw_uri = gedit_document_get_raw_uri (doc); - if (raw_uri != NULL) - { - if (gedit_document_is_readonly (doc)) - deleted = FALSE; - else - deleted = !gedit_utils_uri_exists (raw_uri); - } - g_free (raw_uri); - - if (!deleted) - return TRUE; - } - - uri = gedit_document_get_uri (doc); - g_return_val_if_fail (uri != NULL, FALSE); - - gedit_utils_flash_va (_("Saving file '%s' ..."), uri); - - ret = gedit_document_save (doc, &error); - - if (!ret) - { - GtkWidget *view; - - g_return_val_if_fail (error != NULL, FALSE); - gedit_debug (DEBUG_FILE, "FAILED"); - - view = GTK_WIDGET (g_list_nth_data ( - bonobo_mdi_child_get_views (BONOBO_MDI_CHILD (child)), 0)); - if (view != NULL) - { - GtkWindow *window; - - window = GTK_WINDOW (bonobo_mdi_get_window_from_view (view)); - gtk_window_present (window); - - bonobo_mdi_set_active_view (BONOBO_MDI (gedit_mdi), view); - } - - gedit_utils_error_reporting_saving_file (uri, error, - GTK_WINDOW (gedit_get_active_window ())); - - g_error_free (error); - - gedit_utils_flash_va (_("The document has not been saved.")); - - g_free (uri); - - return FALSE; - } - else - { - GnomeRecentModel *recent; - gchar *raw_uri; - - gedit_debug (DEBUG_FILE, "OK"); - - gedit_utils_flash_va (_("File '%s' saved."), uri); - - g_free (uri); - - raw_uri = gedit_document_get_raw_uri (doc); - g_return_val_if_fail (raw_uri != NULL, TRUE); - - recent = gedit_recent_get_model (); - gnome_recent_model_add (recent, raw_uri); - - g_free (raw_uri); - - return TRUE; - } -} - -gboolean -gedit_file_save_as (GeditMDIChild *child) -{ - gchar *file; - gboolean ret = FALSE; - GeditDocument *doc; - gchar *fname = NULL; - gchar *path = NULL; - gchar *raw_uri = NULL; - - gedit_debug (DEBUG_FILE, ""); - - g_return_val_if_fail (child != NULL, FALSE); - - doc = child->document; - g_return_val_if_fail (doc != NULL, FALSE); - - raw_uri = gedit_document_get_raw_uri (doc); - - if (gedit_document_is_untitled (doc)) - { - char *tmpstr; - - path = (gedit_default_path != NULL) ? - g_strdup (gedit_default_path) : NULL; - - tmpstr = gedit_document_get_uri (doc); - fname = g_filename_from_utf8 (tmpstr, -1, NULL, NULL, NULL); - if (!fname) - /* FIXME: should fname remain NULL in this case? - Paolo */ - fname = g_strdup ("Untitled"); /* Use ASCII */ - g_free (tmpstr); - } - else - { - g_return_val_if_fail (raw_uri != NULL, FALSE); - - fname = eel_uri_get_basename (raw_uri); - - if (gedit_utils_uri_has_file_scheme (raw_uri)) - path = get_dirname_from_uri (raw_uri); - else - path = (gedit_default_path != NULL) ? - g_strdup (gedit_default_path) : NULL; - } - - g_return_val_if_fail (fname != NULL, FALSE); - - file = gedit_file_selector_save ( - GTK_WINDOW (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi))), - FALSE, - _("Save as ..."), - NULL, - path, - fname); - - g_free (raw_uri); - g_free (fname); - - if (path != NULL) - g_free (path); - - if (file != NULL) - { - gchar *uri; - gchar *file_utf8; - - uri = eel_make_uri_from_shell_arg (file); - g_return_val_if_fail (uri != NULL, FALSE); - - file_utf8 = eel_format_uri_for_display (uri); - if (file_utf8 != NULL) - gedit_utils_flash_va (_("Saving file '%s' ..."), file_utf8); - - ret = gedit_file_save_as_real (uri, child); - - if (ret) - { - if (gedit_default_path != NULL) - g_free (gedit_default_path); - - gedit_default_path = get_dirname_from_uri (file); - - if (file_utf8 != NULL) - gedit_utils_flash_va (_("File '%s' saved."), file_utf8); - } - else - gedit_utils_flash_va (_("The document has not been saved.")); - - gedit_debug (DEBUG_FILE, "File: %s", file); - g_free (uri); - g_free (file); - - if (file_utf8 != NULL) - g_free (file_utf8); - - } - - return ret; -} - -static gboolean -gedit_file_save_as_real (const gchar* file_name, GeditMDIChild *child) -{ - gchar *uri; - gboolean ret; - GeditDocument *doc = NULL; - GError *error = NULL; - - gedit_debug (DEBUG_FILE, ""); - - g_return_val_if_fail (child != NULL, FALSE); - - doc = child->document; - g_return_val_if_fail (doc != NULL, FALSE); - - uri = eel_make_uri_canonical (file_name); - g_return_val_if_fail (uri != NULL, FALSE); - - ret = gedit_document_save_as (doc, uri, &error); - - if (!ret) - { - g_return_val_if_fail (error != NULL, FALSE); - - gedit_utils_error_reporting_saving_file (file_name, error, - GTK_WINDOW (gedit_get_active_window ())); - - g_error_free (error); - - g_free (uri); - - return FALSE; - - } - else - { -#if 0 - gchar *temp; - - gedit_debug (DEBUG_FILE, "OK"); - - /* uri is not valid utf8 */ - temp = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL); - - if (temp != NULL) - { - GnomeRecentModel *recent; - - recent = gedit_recent_get_model (); - gnome_recent_model_add (recent, temp); - - g_free (temp); - } - -#endif - GnomeRecentModel *recent; - - recent = gedit_recent_get_model (); - gnome_recent_model_add (recent, uri); - - g_free (uri); - - return TRUE; - } -} - - -gboolean -gedit_file_close_all (void) -{ - gboolean ret; - gedit_debug (DEBUG_FILE, ""); - - ret = bonobo_mdi_remove_all (BONOBO_MDI (gedit_mdi), FALSE); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) == NULL) - { - gedit_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (gedit_mdi)); - gedit_mdi_clear_active_window_statusbar (gedit_mdi); - } - - return ret; -} - -void -gedit_file_exit (void) -{ - gedit_debug (DEBUG_FILE, ""); - - if (!gedit_file_close_all ()) - return; - - gedit_debug (DEBUG_FILE, "All files closed."); - - gedit_plugins_engine_save_settings (); - - gedit_prefs_manager_shutdown (); - - gedit_debug (DEBUG_FILE, "Unref gedit_mdi."); - - g_object_unref (G_OBJECT (gedit_mdi)); - - gedit_debug (DEBUG_FILE, "Unref gedit_mdi: DONE"); - - gedit_debug (DEBUG_FILE, "Unref gedit_app_server."); - - bonobo_object_unref (gedit_app_server); - - gedit_debug (DEBUG_FILE, "Unref gedit_app_server: DONE"); - - gtk_main_quit (); -} - -void -gedit_file_save_all (void) -{ - guint i = 0; - GeditMDIChild* child; - GtkWidget* view; - - gedit_debug (DEBUG_FILE, ""); - - view = bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi)); - - for (i = 0; i < g_list_length (bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi))); i++) - { - child = GEDIT_MDI_CHILD (g_list_nth_data ( - bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi)), i)); - - if (gedit_document_get_modified (child->document)) - { - gedit_file_save (child); - } - } - - if (view != bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi))) - { - GtkWindow *window; - - window = GTK_WINDOW (bonobo_mdi_get_window_from_view (view)); - gtk_window_present (window); - - bonobo_mdi_set_active_view (BONOBO_MDI (gedit_mdi), view); - } -} - -gboolean -gedit_file_revert (GeditMDIChild *child) -{ - gint ret; - GeditDocument* doc = NULL; - GError *error = NULL; - gchar* uri = NULL; - - gedit_debug (DEBUG_FILE, ""); - - g_return_val_if_fail (child != NULL, FALSE); - - doc = child->document; - g_return_val_if_fail (doc != NULL, FALSE); - - uri = gedit_document_get_uri (doc); - g_return_val_if_fail (uri != NULL, FALSE); - - gedit_utils_flash_va (_("Reverting file '%s' ..."), uri); - - ret = gedit_document_revert (doc, &error); - - if (!ret) - { - g_return_val_if_fail (error != NULL, FALSE); - - gedit_utils_error_reporting_reverting_file (uri, error, - GTK_WINDOW (gedit_get_active_window ())); - - g_error_free (error); - - gedit_utils_flash_va (_("The document has not been reverted.")); - - g_free (uri); - - return FALSE; - } - else - { - gedit_debug (DEBUG_FILE, "OK"); - - gedit_utils_flash_va (_("File '%s' reverted."), uri); - - g_free (uri); - - return TRUE; - } -} - -gboolean -gedit_file_open_uri_list (GList* uri_list, gint line, gboolean create) -{ - gchar *full_path; - gboolean ret = FALSE; - gint loaded_files = 0; - BonoboMDIChild *active_child = NULL; - GeditView* view = NULL; - gint l; - - gedit_debug (DEBUG_FILE, ""); - - if (uri_list == NULL) - return FALSE; - - l = g_list_length (uri_list); - - if (l > 1) - gedit_utils_flash_va (_("Loading %d files..."), l); - - active_child = bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)); - - /* create a file for each document in the parameter list */ - for ( ; uri_list; uri_list = g_list_next (uri_list)) - { - full_path = eel_make_uri_from_shell_arg (uri_list->data); - - if (full_path != NULL) - { - if (!gedit_utils_uri_has_file_scheme (full_path) || gedit_utils_uri_exists (full_path)) - { - if (gedit_file_open_real (full_path, - (active_child != NULL) ? GEDIT_MDI_CHILD (active_child): NULL)) - { - ++loaded_files; - ret |= TRUE; - } - } - else - { - if (create) - { - GtkWidget *dialog; - gboolean created = FALSE; - gchar *formatted_path; - - formatted_path = eel_format_uri_for_display (full_path); - g_return_val_if_fail (formatted_path != NULL, FALSE); - - dialog = gtk_message_dialog_new ( - GTK_WINDOW (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - _("The file \"%s\" does not exist. Would you like to create it?"), - formatted_path); - - g_free (formatted_path); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) - { - created = gedit_utils_create_empty_file (full_path); - - if (!created) - gedit_utils_error_reporting_creating_file (full_path, errno, GTK_WINDOW (dialog)); - } - - gtk_widget_destroy (dialog); - - if (created) - { - if (gedit_file_open_real (full_path, - (active_child != NULL) ? GEDIT_MDI_CHILD (active_child): NULL)) - { - ++loaded_files; - ret |= TRUE; - } - } - } - } - - g_free (full_path); - } - - if (view == NULL) - view = gedit_get_active_view (); - } - - if (view != NULL) - { - GeditDocument *doc; - GtkWindow *window; - - doc = gedit_view_get_document (view); - g_return_val_if_fail (doc, FALSE); - - gedit_document_goto_line (doc, MAX (0, line - 1)); - - window = GTK_WINDOW (bonobo_mdi_get_window_from_view (GTK_WIDGET (view))); - gtk_window_present (window); - - bonobo_mdi_set_active_view (BONOBO_MDI (gedit_mdi), GTK_WIDGET (view)); - } - - if (loaded_files > 1) - gedit_utils_flash_va (_("Loaded %i files"), loaded_files); - - return ret; -} - -gboolean -gedit_file_open_recent (GnomeRecentView *view, const gchar *uri, gpointer data) -{ - gboolean ret = FALSE; - GeditView* active_view; - - gedit_debug (DEBUG_FILE, "Open : %s", uri); - - /* Note that gedit_file_open_single_uri takes a possibly mangled "uri", in UTF8 */ - - ret = gedit_file_open_single_uri (uri); - - if (!ret) - { - GnomeRecentModel *model; - - model = gedit_recent_get_model (); - gnome_recent_model_delete (model, uri); - } - - active_view = gedit_get_active_view (); - if (active_view != NULL) - gtk_widget_grab_focus (GTK_WIDGET (active_view)); - - gedit_debug (DEBUG_FILE, "END"); - - return ret; -} - -/* - * uri: a possibly mangled "uri", in UTF8 - */ -gboolean -gedit_file_open_single_uri (const gchar* uri) -{ - gchar *full_path; - gboolean ret = TRUE; - - gedit_debug (DEBUG_FILE, ""); - - if (uri == NULL) return FALSE; - - full_path = eel_make_uri_from_input (uri); - - if (full_path != NULL) - { - BonoboMDIChild *active_child = NULL; - - active_child = bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)); - - ret = gedit_file_open_real (full_path, - (active_child != NULL) ? GEDIT_MDI_CHILD (active_child): NULL); - if (ret) - { - gchar *uri_utf8; - - uri_utf8 = eel_format_uri_for_display (full_path); - - if (uri_utf8 != NULL) - { - gedit_utils_flash_va (_("Loaded file '%s'"), uri_utf8); - - g_free (uri_utf8); - } - } - - g_free (full_path); - } - - return ret; -} - -/* FIXME: it is broken */ -gboolean -gedit_file_open_from_stdin (GeditMDIChild *active_child) -{ - struct stat stats; - gboolean ret = TRUE; - GeditDocument *doc = NULL; - GError *error = NULL; - GeditMDIChild *child; - GeditMDIChild* new_child = NULL; - - gedit_debug (DEBUG_FILE, ""); - - fstat (STDIN_FILENO, &stats); - - if (stats.st_size == 0) - return FALSE; - - child = active_child; - - if (active_child == NULL || - !gedit_document_is_untouched (active_child->document)) - { - new_child = gedit_mdi_child_new (); - - g_return_val_if_fail (new_child != NULL, FALSE); - g_return_val_if_fail (gedit_mdi != NULL, FALSE); - - ret = bonobo_mdi_add_child (BONOBO_MDI (gedit_mdi), BONOBO_MDI_CHILD (new_child)); - g_return_val_if_fail (ret != FALSE, FALSE); - gedit_debug (DEBUG_FILE, "Child added."); - - child= new_child; - } - - doc = child->document; - g_return_val_if_fail (doc != NULL, FALSE); - - ret = gedit_document_load_from_stdin (doc, &error); - - if (error) - { - GtkWidget *dialog; - /* FIXME: do a more user friendly error reporting */ - gchar *errstr; - - errstr = g_strdup_printf (_("Could not read data from stdin.")); - - dialog = gtk_message_dialog_new ( - GTK_WINDOW (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - errstr); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (errstr); - g_error_free (error); - - ret = FALSE; - } - - if (new_child != NULL) - { - ret = bonobo_mdi_add_view (BONOBO_MDI (gedit_mdi), BONOBO_MDI_CHILD (new_child)); - g_return_val_if_fail (ret != FALSE, FALSE); - gedit_debug (DEBUG_FILE, "View added."); - } - - return ret; -} - diff --git a/gedit/gedit-file.h b/gedit/gedit-file.h deleted file mode 100644 index 0f89ae4bd..000000000 --- a/gedit/gedit-file.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-file.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_FILE_H__ -#define __GEDIT_FILE_H__ - -#include "gedit-mdi-child.h" -#include "gnome-recent-view.h" - -void gedit_file_new (void); -void gedit_file_open (GeditMDIChild *active_child); -void gedit_file_close (GtkWidget *view); -gboolean gedit_file_save (GeditMDIChild *child); -gboolean gedit_file_save_as (GeditMDIChild *child); -void gedit_file_save_all (void); -gboolean gedit_file_close_all (void); -void gedit_file_exit (void); -gboolean gedit_file_revert (GeditMDIChild *child); - -gboolean gedit_file_open_uri_list (GList* uri_list, gint line, gboolean create); -gboolean gedit_file_open_recent (GnomeRecentView *view, const gchar* uri, gpointer data); -gboolean gedit_file_open_single_uri (const gchar* uri); - -gboolean gedit_file_open_from_stdin (GeditMDIChild *active_child); - -#endif /* __GEDIT_FILE_H__ */ - - diff --git a/gedit/gedit-marshal.list b/gedit/gedit-marshal.list deleted file mode 100644 index 6f82893f4..000000000 --- a/gedit/gedit-marshal.list +++ /dev/null @@ -1,3 +0,0 @@ -BOOLEAN:OBJECT -VOID:VOID -VOID:BOOLEAN diff --git a/gedit/gedit-mdi-child.c b/gedit/gedit-mdi-child.c deleted file mode 100644 index f136fce2f..000000000 --- a/gedit/gedit-mdi-child.c +++ /dev/null @@ -1,355 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-mdi-child.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include "gedit-mdi-child.h" -#include "gedit-debug.h" -#include "gedit-view.h" -#include "gedit-marshal.h" - -struct _GeditMDIChildPrivate -{ - GtkWidget *tab_label; -}; - -enum { - STATE_CHANGED, - UNDO_REDO_STATE_CHANGED, - LAST_SIGNAL -}; - -static void gedit_mdi_child_class_init (GeditMDIChildClass *klass); -static void gedit_mdi_child_init (GeditMDIChild *mdi); -static void gedit_mdi_child_finalize (GObject *obj); - -static void gedit_mdi_child_real_state_changed (GeditMDIChild* child); - -static GtkWidget *gedit_mdi_child_create_view (BonoboMDIChild *child); - -static void gedit_mdi_child_document_state_changed_handler (GeditDocument *document, - GeditMDIChild* child); -static void gedit_mdi_child_document_readonly_changed_handler (GeditDocument *document, - gboolean readonly, GeditMDIChild* child); - -static void gedit_mdi_child_document_can_undo_redo_handler (GeditDocument *document, - gboolean can, GeditMDIChild* child); - -static gchar* gedit_mdi_child_get_config_string (BonoboMDIChild *child, gpointer data); - -static BonoboMDIChildClass *parent_class = NULL; -static guint mdi_child_signals[LAST_SIGNAL] = { 0 }; - - -GType -gedit_mdi_child_get_type (void) -{ - static GType mdi_child_type = 0; - - if (mdi_child_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GeditMDIChildClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gedit_mdi_child_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GeditMDIChild), - 0, /* n_preallocs */ - (GInstanceInitFunc) gedit_mdi_child_init - }; - - mdi_child_type = g_type_register_static (BONOBO_TYPE_MDI_CHILD, - "GeditMDIChild", - &our_info, - 0); - } - - return mdi_child_type; -} - -static void -gedit_mdi_child_class_init (GeditMDIChildClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->finalize = gedit_mdi_child_finalize; - - klass->state_changed = gedit_mdi_child_real_state_changed; - klass->undo_redo_state_changed = NULL; - - mdi_child_signals [STATE_CHANGED] = - g_signal_new ("state_changed", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GeditMDIChildClass, state_changed), - NULL, NULL, - gedit_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - mdi_child_signals [UNDO_REDO_STATE_CHANGED] = - g_signal_new ("undo_redo_state_changed", - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GeditMDIChildClass, undo_redo_state_changed), - NULL, NULL, - gedit_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - BONOBO_MDI_CHILD_CLASS (klass)->create_view = - (BonoboMDIChildViewCreator)(gedit_mdi_child_create_view); - - BONOBO_MDI_CHILD_CLASS (klass)->get_config_string = - (BonoboMDIChildConfigFunc)(gedit_mdi_child_get_config_string); -} - -static void -gedit_mdi_child_init (GeditMDIChild *child) -{ - gedit_debug (DEBUG_MDI, "START"); - - child->priv = g_new0 (GeditMDIChildPrivate, 1); - - child->priv->tab_label = NULL; - - gedit_debug (DEBUG_MDI, "END"); -} - -static void -gedit_mdi_child_finalize (GObject *obj) -{ - GeditMDIChild *child; - - gedit_debug (DEBUG_MDI, "START"); - - g_return_if_fail (obj != NULL); - - child = GEDIT_MDI_CHILD (obj); - - g_return_if_fail (GEDIT_IS_MDI_CHILD (child)); - g_return_if_fail (child->priv != NULL); - - if (child->document != NULL) - g_object_unref (G_OBJECT (child->document)); - - g_free (child->priv); - - G_OBJECT_CLASS (parent_class)->finalize (obj); - - gedit_debug (DEBUG_MDI, "END"); -} - -static void -gedit_mdi_child_real_state_changed (GeditMDIChild* child) -{ - gchar* docname = NULL; - gchar* tab_name = NULL; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (child != NULL); - g_return_if_fail (child->document != NULL); - - docname = gedit_document_get_short_name (child->document); - g_return_if_fail (docname != NULL); - - if (gedit_document_get_modified (child->document)) - { - tab_name = g_strdup_printf ("%s*", docname); - } - else - { - if (gedit_document_is_readonly (child->document)) - { - tab_name = g_strdup_printf ("RO - %s", docname); - } - else - { - tab_name = g_strdup_printf ("%s", docname); - } - } - - g_free (docname); - - g_return_if_fail (tab_name != NULL); - - bonobo_mdi_child_set_name (BONOBO_MDI_CHILD (child), tab_name); - - g_free (tab_name); -} - -static void -gedit_mdi_child_document_state_changed_handler (GeditDocument *document, GeditMDIChild* child) -{ - gedit_debug (DEBUG_MDI, ""); - g_return_if_fail (child->document == document); - - g_signal_emit (G_OBJECT (child), mdi_child_signals [STATE_CHANGED], 0); -} - -static void -gedit_mdi_child_document_readonly_changed_handler (GeditDocument *document, gboolean readonly, - GeditMDIChild* child) -{ - gedit_debug (DEBUG_MDI, ""); - g_return_if_fail (child->document == document); - - g_signal_emit (G_OBJECT (child), mdi_child_signals [STATE_CHANGED], 0); -} - -static void -gedit_mdi_child_document_can_undo_redo_handler (GeditDocument *document, gboolean can, - GeditMDIChild* child) -{ - gedit_debug (DEBUG_MDI, ""); - g_return_if_fail (child->document == document); - - g_signal_emit (G_OBJECT (child), mdi_child_signals [UNDO_REDO_STATE_CHANGED], 0); -} - - -static void -gedit_mdi_child_connect_signals (GeditMDIChild *child) -{ - g_signal_connect (G_OBJECT (child->document), "name_changed", - G_CALLBACK (gedit_mdi_child_document_state_changed_handler), - child); - g_signal_connect (G_OBJECT (child->document), "readonly_changed", - G_CALLBACK (gedit_mdi_child_document_readonly_changed_handler), - child); - g_signal_connect (G_OBJECT (child->document), "modified_changed", - G_CALLBACK (gedit_mdi_child_document_state_changed_handler), - child); - g_signal_connect (G_OBJECT (child->document), "can_undo", - G_CALLBACK (gedit_mdi_child_document_can_undo_redo_handler), - child); - g_signal_connect (G_OBJECT (child->document), "can_redo", - G_CALLBACK (gedit_mdi_child_document_can_undo_redo_handler), - child); -} - -/** - * gedit_mdi_child_new: - * - * Creates a new #GeditMDIChild object. - * - * Return value: a new #GeditMDIChild - **/ -GeditMDIChild* -gedit_mdi_child_new (void) -{ - GeditMDIChild *child; - gchar* doc_name; - - gedit_debug (DEBUG_MDI, ""); - - child = GEDIT_MDI_CHILD (g_object_new (GEDIT_TYPE_MDI_CHILD, NULL)); - g_return_val_if_fail (child != NULL, NULL); - - child->document = gedit_document_new (); - g_return_val_if_fail (child->document != NULL, NULL); - - doc_name = gedit_document_get_short_name (child->document); - bonobo_mdi_child_set_name (BONOBO_MDI_CHILD (child), doc_name); - g_free(doc_name); - - gedit_mdi_child_connect_signals (child); - - gedit_debug (DEBUG_MDI, "END"); - - return child; -} - -GeditMDIChild* -gedit_mdi_child_new_with_uri (const gchar *uri, GError **error) -{ - GeditMDIChild *child; - GeditDocument* doc; - - gedit_debug (DEBUG_MDI, ""); - - doc = gedit_document_new_with_uri (uri, error); - - if (doc == NULL) - { - gedit_debug (DEBUG_MDI, "ERROR: %s", (*error)->message); - return NULL; - } - - child = GEDIT_MDI_CHILD (g_object_new (GEDIT_TYPE_MDI_CHILD, NULL)); - g_return_val_if_fail (child != NULL, NULL); - - child->document = doc; - g_return_val_if_fail (child->document != NULL, NULL); - - gedit_mdi_child_real_state_changed (child); - - gedit_mdi_child_connect_signals (child); - - gedit_debug (DEBUG_MDI, "END"); - - return child; -} - -static GtkWidget * -gedit_mdi_child_create_view (BonoboMDIChild *child) -{ - GeditView *new_view; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (child != NULL, NULL); - g_return_val_if_fail (GEDIT_IS_MDI_CHILD (child), NULL); - - new_view = gedit_view_new (GEDIT_MDI_CHILD (child)->document); - - gtk_widget_show_all (GTK_WIDGET (new_view)); - - return GTK_WIDGET (new_view); -} - -static gchar* -gedit_mdi_child_get_config_string (BonoboMDIChild *child, gpointer data) -{ - GeditMDIChild *c; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (child != NULL, NULL); - g_return_val_if_fail (GEDIT_IS_MDI_CHILD (child), NULL); - - c = GEDIT_MDI_CHILD (child); - - return gedit_document_get_raw_uri (c->document); -} diff --git a/gedit/gedit-mdi-child.h b/gedit/gedit-mdi-child.h deleted file mode 100644 index e93532b4a..000000000 --- a/gedit/gedit-mdi-child.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-mdi-child.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_MDI_CHILD_H__ -#define __GEDIT_MDI_CHILD_H__ - -#include <bonobo-mdi.h> - -#include "gedit-document.h" - -#define GEDIT_TYPE_MDI_CHILD (gedit_mdi_child_get_type ()) -#define GEDIT_MDI_CHILD(o) (GTK_CHECK_CAST ((o), GEDIT_TYPE_MDI_CHILD, GeditMDIChild)) -#define GEDIT_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_MDI_CHILD, \ - GeditMDIChildClass)) -#define GEDIT_IS_MDI_CHILD(o) (GTK_CHECK_TYPE ((o), GEDIT_TYPE_MDI_CHILD)) -#define GEDIT_IS_MDI_CHILD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_MDI_CHILD)) -#define GEDIT_MDI_CHILD_GET_CLASS(o) (GTK_CHECK_GET_CLASS ((o), GEDIT_TYPE_MDI_CHILD, GeditMdiChildClass)) - - -typedef struct _GeditMDIChild GeditMDIChild; -typedef struct _GeditMDIChildClass GeditMDIChildClass; - -typedef struct _GeditMDIChildPrivate GeditMDIChildPrivate; - -struct _GeditMDIChild -{ - BonoboMDIChild child; - - GeditDocument* document; - GeditMDIChildPrivate *priv; -}; - -struct _GeditMDIChildClass -{ - BonoboMDIChildClass parent_class; - - /* MDI child state changed */ - void (*state_changed) (GeditMDIChild *child); - - void (*undo_redo_state_changed) (GeditMDIChild *child); -}; - - -GtkType gedit_mdi_child_get_type (void) G_GNUC_CONST; - -GeditMDIChild* gedit_mdi_child_new (void); -GeditMDIChild* gedit_mdi_child_new_with_uri (const gchar *uri, GError **error); - -#endif /* __GEDIT_MDI_CHILD_H__ */ - diff --git a/gedit/gedit-mdi.c b/gedit/gedit-mdi.c deleted file mode 100644 index f720f15e3..000000000 --- a/gedit/gedit-mdi.c +++ /dev/null @@ -1,1247 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-mdi.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/libgnome.h> -#include <libgnomeui/libgnomeui.h> -#include <libgnomevfs/gnome-vfs.h> - -#include <string.h> - -#include "gedit-mdi.h" -#include "gedit-mdi-child.h" -#include "gedit2.h" -#include "gedit-menus.h" -#include "gedit-debug.h" -#include "gedit-prefs-manager.h" -#include "gedit-recent.h" -#include "gedit-file.h" -#include "gedit-view.h" -#include "gedit-utils.h" -#include "gedit-plugins-engine.h" -#include "gnome-recent-view-bonobo.h" - -#include <bonobo/bonobo-ui-util.h> -#include <bonobo/bonobo-control.h> - -#include <gconf/gconf-client.h> - -#define RECENT_KEY "GeditRecent" - -struct _GeditMDIPrivate -{ - gint dummy; -}; - -typedef struct _GeditWindowPrefs GeditWindowPrefs; - -struct _GeditWindowPrefs -{ - gboolean toolbar_visible; - GeditToolbarSetting toolbar_buttons_style; - - gboolean statusbar_visible; - gboolean statusbar_show_cursor_position; - gboolean statusbar_show_overwrite_mode; -}; - -static void gedit_mdi_class_init (GeditMDIClass *klass); -static void gedit_mdi_init (GeditMDI *mdi); -static void gedit_mdi_finalize (GObject *object); - -static void gedit_mdi_app_created_handler (BonoboMDI *mdi, BonoboWindow *win); -static void gedit_mdi_drag_data_received_handler (GtkWidget *widget, GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, guint time); -static void gedit_mdi_set_app_toolbar_style (BonoboWindow *win); -static void gedit_mdi_set_app_statusbar_style (BonoboWindow *win); - -static gint gedit_mdi_add_child_handler (BonoboMDI *mdi, BonoboMDIChild *child); -static gint gedit_mdi_add_view_handler (BonoboMDI *mdi, GtkWidget *view); -static gint gedit_mdi_remove_child_handler (BonoboMDI *mdi, BonoboMDIChild *child); -static gint gedit_mdi_remove_view_handler (BonoboMDI *mdi, GtkWidget *view); - -static void gedit_mdi_view_changed_handler (BonoboMDI *mdi, GtkWidget *old_view); -static void gedit_mdi_child_changed_handler (BonoboMDI *mdi, BonoboMDIChild *old_child); -static void gedit_mdi_child_state_changed_handler (GeditMDIChild *child); - -static void gedit_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi); - -static void gedit_mdi_app_destroy_handler (BonoboMDI *mdi, BonoboWindow *window); - -static void gedit_mdi_view_menu_item_toggled_handler ( - BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - BonoboWindow *win); - - -static GQuark window_prefs_id = 0; - -static GeditWindowPrefs *gedit_window_prefs_new (void); -static void gedit_window_prefs_attach_to_window (GeditWindowPrefs *prefs, - BonoboWindow *win); -static GeditWindowPrefs *gedit_window_prefs_get_from_window (BonoboWindow *win); -static void gedit_window_prefs_save (GeditWindowPrefs *prefs); - -static BonoboMDIClass *parent_class = NULL; - -GType -gedit_mdi_get_type (void) -{ - static GType mdi_type = 0; - - if (mdi_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GeditMDIClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gedit_mdi_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GeditMDI), - 0, /* n_preallocs */ - (GInstanceInitFunc) gedit_mdi_init - }; - - mdi_type = g_type_register_static (BONOBO_TYPE_MDI, - "GeditMDI", - &our_info, - 0); - } - - return mdi_type; -} - -static void -gedit_mdi_class_init (GeditMDIClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_mdi_finalize; -} - -static void -gedit_mdi_init (GeditMDI *mdi) -{ - gedit_debug (DEBUG_MDI, "START"); - - bonobo_mdi_construct (BONOBO_MDI (mdi), - "gedit-2", - "gedit", - gedit_prefs_manager_get_default_window_width (), - gedit_prefs_manager_get_default_window_height ()); - - mdi->priv = g_new0 (GeditMDIPrivate, 1); - - bonobo_mdi_set_ui_template_file (BONOBO_MDI (mdi), GEDIT_UI_DIR "gedit-ui.xml", gedit_verbs); - - bonobo_mdi_set_child_list_path (BONOBO_MDI (mdi), "/menu/Documents/"); - - /* Connect signals */ - g_signal_connect (G_OBJECT (mdi), "top_window_created", - G_CALLBACK (gedit_mdi_app_created_handler), NULL); - - g_signal_connect (G_OBJECT (mdi), "add_child", - G_CALLBACK (gedit_mdi_add_child_handler), NULL); - g_signal_connect (G_OBJECT (mdi), "add_view", - G_CALLBACK (gedit_mdi_add_view_handler), NULL); - - g_signal_connect (G_OBJECT (mdi), "remove_child", - G_CALLBACK (gedit_mdi_remove_child_handler), NULL); - g_signal_connect (G_OBJECT (mdi), "remove_view", - G_CALLBACK (gedit_mdi_remove_view_handler), NULL); - - g_signal_connect (G_OBJECT (mdi), "child_changed", - G_CALLBACK (gedit_mdi_child_changed_handler), NULL); - g_signal_connect (G_OBJECT (mdi), "view_changed", - G_CALLBACK (gedit_mdi_view_changed_handler), NULL); - - g_signal_connect (G_OBJECT (mdi), "all_windows_destroyed", - G_CALLBACK (gedit_file_exit), NULL); - - g_signal_connect (G_OBJECT (mdi), "top_window_destroy", - G_CALLBACK (gedit_mdi_app_destroy_handler), NULL); - - - gedit_debug (DEBUG_MDI, "END"); -} - -static void -gedit_mdi_finalize (GObject *object) -{ - GeditMDI *mdi; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (object != NULL); - - mdi = GEDIT_MDI (object); - - g_return_if_fail (GEDIT_IS_MDI (mdi)); - g_return_if_fail (mdi->priv != NULL); - - g_free (mdi->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - - -/** - * gedit_mdi_new: - * - * Creates a new #GeditMDI object. - * - * Return value: a new #GeditMDI - **/ -GeditMDI* -gedit_mdi_new (void) -{ - GeditMDI *mdi; - - gedit_debug (DEBUG_MDI, ""); - - mdi = GEDIT_MDI (g_object_new (GEDIT_TYPE_MDI, NULL)); - g_return_val_if_fail (mdi != NULL, NULL); - - return mdi; -} - -static void -gedit_mdi_app_created_handler (BonoboMDI *mdi, BonoboWindow *win) -{ - GtkWidget *widget; - BonoboControl *control; - BonoboUIComponent *ui_component; - GnomeRecentView *view; - GnomeRecentModel *model; - GeditWindowPrefs *prefs; - GdkWindowState state; - - static GtkTargetEntry drag_types[] = - { - { "text/uri-list", 0, 0 }, - }; - - static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]); - - gedit_debug (DEBUG_MDI, ""); - - ui_component = bonobo_mdi_get_ui_component_from_window (win); - g_return_if_fail (ui_component != NULL); - - /* Drag and drop support */ - gtk_drag_dest_set (GTK_WIDGET (win), - GTK_DEST_DEFAULT_MOTION | - GTK_DEST_DEFAULT_HIGHLIGHT | - GTK_DEST_DEFAULT_DROP, - drag_types, n_drag_types, - GDK_ACTION_COPY); - - g_signal_connect (G_OBJECT (win), "drag_data_received", - G_CALLBACK (gedit_mdi_drag_data_received_handler), - NULL); - - /* Add cursor position status bar */ - widget = gtk_statusbar_new (); - control = bonobo_control_new (widget); - - gtk_widget_set_size_request (widget, 150, 10); - gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (widget), FALSE); - - bonobo_ui_component_object_set (ui_component, - "/status/CursorPosition", - BONOBO_OBJREF (control), - NULL); - - bonobo_object_unref (BONOBO_OBJECT (control)); - - g_object_set_data (G_OBJECT (win), "CursorPosition", widget); - - /* Add overwrite mode status bar */ - widget = gtk_statusbar_new (); - control = bonobo_control_new (widget); - - gtk_widget_set_size_request (widget, 80, 10); - - bonobo_ui_component_object_set (ui_component, - "/status/OverwriteMode", - BONOBO_OBJREF (control), - NULL); - - bonobo_object_unref (BONOBO_OBJECT (control)); - - g_object_set_data (G_OBJECT (win), "OverwriteMode", widget); - - prefs = gedit_window_prefs_new (); - gedit_window_prefs_attach_to_window (prefs, win); - - /* Set the statusbar style according to prefs */ - gedit_mdi_set_app_statusbar_style (win); - - /* Set the toolbar style according to prefs */ - gedit_mdi_set_app_toolbar_style (win); - - /* Add listener fo the view menu */ - bonobo_ui_component_add_listener (ui_component, "ViewToolbar", - (BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "ViewStatusbar", - (BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, - (gpointer)win); - - bonobo_ui_component_add_listener (ui_component, "ToolbarSystem", - (BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "ToolbarIcon", - (BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "ToolbarIconText", - (BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, - (gpointer)win); - - bonobo_ui_component_add_listener (ui_component, "StatusBarCursorPosition", - (BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "StatusBarOverwriteMode", - (BonoboUIListenerFn)gedit_mdi_view_menu_item_toggled_handler, - (gpointer)win); - - /* add a GeditRecentView object */ - model = gedit_recent_get_model (); - view = GNOME_RECENT_VIEW (gnome_recent_view_bonobo_new ( - ui_component, "/menu/File/Recents")); - gnome_recent_view_set_model (view, model); - - g_signal_connect (G_OBJECT (view), "activate", - G_CALLBACK (gedit_file_open_recent), NULL); - - g_object_set_data_full (G_OBJECT (win), RECENT_KEY, view, - g_object_unref); - - /* Set window state and size, but only if the session is not being restored */ - if (!bonobo_mdi_get_restoring_state (mdi)) - { - state = gedit_prefs_manager_get_window_state (); - - if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0) - { - gtk_window_set_default_size (GTK_WINDOW (win), - gedit_prefs_manager_get_default_window_width (), - gedit_prefs_manager_get_default_window_height ()); - - gtk_window_maximize (GTK_WINDOW (win)); - } - else - { - gtk_window_set_default_size (GTK_WINDOW (win), - gedit_prefs_manager_get_window_width (), - gedit_prefs_manager_get_window_height ()); - - gtk_window_unmaximize (GTK_WINDOW (win)); - } - - if ((state & GDK_WINDOW_STATE_STICKY ) != 0) - gtk_window_stick (GTK_WINDOW (win)); - else - gtk_window_unstick (GTK_WINDOW (win)); - } - - /* Add the plugins menus */ - gedit_plugins_engine_update_plugins_ui (win, TRUE); -} - -static void -gedit_mdi_app_destroy_handler (BonoboMDI *mdi, BonoboWindow *window) -{ - const BonoboMDIWindowInfo *window_info; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (window != NULL); - g_return_if_fail (BONOBO_IS_WINDOW (window)); - - window_info = bonobo_mdi_get_window_info (window); - g_return_if_fail (window_info != NULL); - - if (gedit_prefs_manager_window_height_can_set ()) - gedit_prefs_manager_set_window_height (window_info->height); - - if (gedit_prefs_manager_window_width_can_set ()) - gedit_prefs_manager_set_window_width (window_info->width); - - if (gedit_prefs_manager_window_state_can_set ()) - gedit_prefs_manager_set_window_state (window_info->state); -} - -static void -gedit_mdi_view_menu_item_toggled_handler ( - BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - BonoboWindow *win) -{ - gboolean s; - GeditWindowPrefs *prefs; - - gedit_debug (DEBUG_MDI, "%s toggled to '%s'", path, state); - - prefs = gedit_window_prefs_get_from_window (win); - g_return_if_fail (prefs != NULL); - - s = (strcmp (state, "1") == 0); - - if (strcmp (path, "ViewToolbar") == 0) - { - if (s != prefs->toolbar_visible) - { - prefs->toolbar_visible = s; - gedit_mdi_set_app_toolbar_style (win); - } - - goto save_prefs; - } - - if (strcmp (path, "ViewStatusbar") == 0) - { - if (s != prefs->statusbar_visible) - { - prefs->statusbar_visible = s; - gedit_mdi_set_app_statusbar_style (win); - } - - goto save_prefs; - } - - if (s && (strcmp (path, "ToolbarSystem") == 0)) - { - if (prefs->toolbar_buttons_style != GEDIT_TOOLBAR_SYSTEM) - { - prefs->toolbar_buttons_style = GEDIT_TOOLBAR_SYSTEM; - gedit_mdi_set_app_toolbar_style (win); - } - - goto save_prefs; - } - - if (s && (strcmp (path, "ToolbarIcon") == 0)) - { - if (prefs->toolbar_buttons_style != GEDIT_TOOLBAR_ICONS) - { - prefs->toolbar_buttons_style = GEDIT_TOOLBAR_ICONS; - gedit_mdi_set_app_toolbar_style (win); - } - - goto save_prefs; - } - - if (s && (strcmp (path, "ToolbarIconText") == 0)) - { - if (prefs->toolbar_buttons_style != GEDIT_TOOLBAR_ICONS_AND_TEXT) - { - prefs->toolbar_buttons_style = GEDIT_TOOLBAR_ICONS_AND_TEXT; - gedit_mdi_set_app_toolbar_style (win); - } - - goto save_prefs; - } - - if (strcmp (path, "StatusBarCursorPosition") == 0) - { - if (s != prefs->statusbar_show_cursor_position) - { - prefs->statusbar_show_cursor_position = s; - gedit_mdi_set_app_statusbar_style (win); - } - - goto save_prefs; - } - - if (strcmp (path, "StatusBarOverwriteMode") == 0) - { - if (s != prefs->statusbar_show_overwrite_mode) - { - prefs->statusbar_show_overwrite_mode = s; - gedit_mdi_set_app_statusbar_style (win); - } - - goto save_prefs; - } - -save_prefs: - gedit_window_prefs_save (prefs); -} - -static void -gedit_mdi_drag_data_received_handler (GtkWidget *widget, GdkDragContext *context, - gint x, gint y, GtkSelectionData *selection_data, - guint info, guint time) -{ - GList *list = NULL; - GList *file_list = NULL; - GList *p = NULL; - - gedit_debug (DEBUG_MDI, ""); - - list = gnome_vfs_uri_list_parse (selection_data->data); - p = list; - - while (p != NULL) - { - file_list = g_list_append (file_list, - gnome_vfs_uri_to_string ((const GnomeVFSURI*)(p->data), - GNOME_VFS_URI_HIDE_NONE)); - p = p->next; - } - - gnome_vfs_uri_list_free (list); - - gedit_file_open_uri_list (file_list, 0, FALSE); - - if (file_list == NULL) - return; - - for (p = file_list; p != NULL; p = p->next) { - g_free (p->data); - } - - g_list_free (file_list); -} - -static void -gedit_mdi_set_app_toolbar_style (BonoboWindow *win) -{ - BonoboUIComponent *ui_component; - GeditWindowPrefs *prefs = NULL; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (BONOBO_IS_WINDOW (win)); - - prefs = gedit_window_prefs_get_from_window (win); - g_return_if_fail (prefs != NULL); - - ui_component = bonobo_mdi_get_ui_component_from_window (win); - g_return_if_fail (ui_component != NULL); - - bonobo_ui_component_freeze (ui_component, NULL); - - /* Updated view menu */ - gedit_menus_set_verb_state (ui_component, - "/commands/ViewToolbar", - prefs->toolbar_visible); - - gedit_menus_set_verb_sensitive (ui_component, - "/commands/ToolbarSystem", - prefs->toolbar_visible); - gedit_menus_set_verb_sensitive (ui_component, - "/commands/ToolbarIcon", - prefs->toolbar_visible); - gedit_menus_set_verb_sensitive (ui_component, - "/commands/ToolbarIconText", - prefs->toolbar_visible); - gedit_menus_set_verb_sensitive (ui_component, - "/commands/ToolbarTooltips", - prefs->toolbar_visible); - - gedit_menus_set_verb_state (ui_component, - "/commands/ToolbarSystem", - prefs->toolbar_buttons_style == GEDIT_TOOLBAR_SYSTEM); - - gedit_menus_set_verb_state (ui_component, - "/commands/ToolbarIcon", - prefs->toolbar_buttons_style == GEDIT_TOOLBAR_ICONS); - - gedit_menus_set_verb_state (ui_component, - "/commands/ToolbarIconText", - prefs->toolbar_buttons_style == GEDIT_TOOLBAR_ICONS_AND_TEXT); - - switch (prefs->toolbar_buttons_style) - { - case GEDIT_TOOLBAR_SYSTEM: - gedit_debug (DEBUG_MDI, "GEDIT: SYSTEM"); - bonobo_ui_component_set_prop ( - ui_component, "/Toolbar", "look", "system", NULL); - - break; - - case GEDIT_TOOLBAR_ICONS: - gedit_debug (DEBUG_MDI, "GEDIT: ICONS"); - bonobo_ui_component_set_prop ( - ui_component, "/Toolbar", "look", "icon", NULL); - - break; - - case GEDIT_TOOLBAR_ICONS_AND_TEXT: - gedit_debug (DEBUG_MDI, "GEDIT: ICONS_AND_TEXT"); - bonobo_ui_component_set_prop ( - ui_component, "/Toolbar", "look", "both", NULL); - - break; - default: - goto error; - break; - } - - bonobo_ui_component_set_prop ( - ui_component, "/Toolbar", - "hidden", prefs->toolbar_visible ? "0":"1", NULL); - - error: - bonobo_ui_component_thaw (ui_component, NULL); -} - -static void -gedit_mdi_set_app_statusbar_style (BonoboWindow *win) -{ - GeditWindowPrefs *prefs = NULL; - BonoboUIComponent *ui_component; - GtkWidget *cp, *om; - - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (BONOBO_IS_WINDOW (win)); - - prefs = gedit_window_prefs_get_from_window (win); - g_return_if_fail (prefs != NULL); - - ui_component = bonobo_mdi_get_ui_component_from_window (win); - g_return_if_fail (ui_component != NULL); - - bonobo_ui_component_freeze (ui_component, NULL); - - /* Update menu */ - gedit_menus_set_verb_state (ui_component, - "/commands/ViewStatusbar", - prefs->statusbar_visible); - - gedit_menus_set_verb_sensitive (ui_component, - "/commands/StatusBarCursorPosition", - prefs->statusbar_visible); - - gedit_menus_set_verb_sensitive (ui_component, - "/commands/StatusBarOverwriteMode", - prefs->statusbar_visible); - - gedit_menus_set_verb_state (ui_component, - "/commands/StatusBarCursorPosition", - prefs->statusbar_show_cursor_position); - - gedit_menus_set_verb_state (ui_component, - "/commands/StatusBarOverwriteMode", - prefs->statusbar_show_overwrite_mode); - - /* Actually update status bar style */ - bonobo_ui_component_set_prop ( - ui_component, "/status", - "hidden", prefs->statusbar_visible ? "0" : "1", - NULL); - - cp = GTK_WIDGET (g_object_get_data (G_OBJECT (win), "CursorPosition")); - if (cp == NULL) - goto error; - - if (prefs->statusbar_show_cursor_position) - { - bonobo_ui_component_set_prop ( - ui_component, "/status/CursorPosition", "hidden", "0", NULL); - - gtk_widget_show (cp); - } - else - { - bonobo_ui_component_set_prop ( - ui_component, "/status/CursorPosition", "hidden", "1", NULL); - - gtk_widget_hide (cp); - } - - om = GTK_WIDGET (g_object_get_data (G_OBJECT (win), "OverwriteMode")); - if (om == NULL) - goto error; - - if (prefs->statusbar_show_overwrite_mode) - { - gtk_widget_show (om); - - bonobo_ui_component_set_prop ( - ui_component, "/status/OverwriteMode", "hidden", "0", NULL); - } - else - { - bonobo_ui_component_set_prop ( - ui_component, "/status/OverwriteMode", "hidden", "1", NULL); - - gtk_widget_hide (om); - } - - if (!prefs->statusbar_show_overwrite_mode) - gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (cp), TRUE); - else - gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (cp), FALSE); - - if (!prefs->statusbar_show_cursor_position && - !prefs->statusbar_show_overwrite_mode) - bonobo_ui_component_set_prop ( - ui_component, "/status", "resize_grip", "1", NULL); - else - bonobo_ui_component_set_prop ( - ui_component, "/status", "resize_grip", "0", NULL); - -error: - bonobo_ui_component_thaw (ui_component, NULL); - -} - -static void -gedit_mdi_child_state_changed_handler (GeditMDIChild *child) -{ - gedit_debug (DEBUG_MDI, ""); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) != BONOBO_MDI_CHILD (child)) - return; - - gedit_mdi_set_active_window_title (BONOBO_MDI (gedit_mdi)); - gedit_mdi_set_active_window_verbs_sensitivity (BONOBO_MDI (gedit_mdi)); -} - -static void -gedit_mdi_child_undo_redo_state_changed_handler (GeditMDIChild *child) -{ - gedit_debug (DEBUG_MDI, ""); - - if (bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)) != BONOBO_MDI_CHILD (child)) - return; - - gedit_mdi_set_active_window_undo_redo_verbs_sensitivity (BONOBO_MDI (gedit_mdi)); -} - -static gint -gedit_mdi_add_child_handler (BonoboMDI *mdi, BonoboMDIChild *child) -{ - gedit_debug (DEBUG_MDI, ""); - - g_signal_connect (G_OBJECT (child), "state_changed", - G_CALLBACK (gedit_mdi_child_state_changed_handler), - NULL); - g_signal_connect (G_OBJECT (child), "undo_redo_state_changed", - G_CALLBACK (gedit_mdi_child_undo_redo_state_changed_handler), - NULL); - - return TRUE; -} - -static gint -gedit_mdi_add_view_handler (BonoboMDI *mdi, GtkWidget *view) -{ - static GtkTargetEntry drag_types[] = - { - { "text/uri-list", 0, 0 }, - }; - - static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]); - - gedit_debug (DEBUG_MDI, ""); - - /* FIXME */ - /* Drag and drop support */ - gtk_drag_dest_set (view, - GTK_DEST_DEFAULT_MOTION | - GTK_DEST_DEFAULT_HIGHLIGHT | - GTK_DEST_DEFAULT_DROP, - drag_types, n_drag_types, - GDK_ACTION_COPY); - - g_signal_connect (G_OBJECT (view), "drag_data_received", - G_CALLBACK (gedit_mdi_drag_data_received_handler), - NULL); - - return TRUE; -} - -static gint -gedit_mdi_remove_child_handler (BonoboMDI *mdi, BonoboMDIChild *child) -{ - GeditDocument* doc; - gboolean close = TRUE; - gchar *raw_uri; - gboolean deleted = FALSE; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (child != NULL, FALSE); - g_return_val_if_fail (GEDIT_MDI_CHILD (child)->document != NULL, FALSE); - - doc = GEDIT_MDI_CHILD (child)->document; - - raw_uri = gedit_document_get_raw_uri (doc); - if (raw_uri != NULL) - { - if (gedit_document_is_readonly (doc)) - deleted = FALSE; - else - deleted = !gedit_utils_uri_exists (raw_uri); - } - g_free (raw_uri); - - if (gedit_document_get_modified (doc) || deleted) - { - GtkWidget *msgbox, *w; - gchar *fname = NULL, *msg = NULL; - gint ret; - gboolean exiting; - - w = GTK_WIDGET (g_list_nth_data (bonobo_mdi_child_get_views (child), 0)); - - if(w != NULL) - { - GtkWindow *window; - - window = GTK_WINDOW (bonobo_mdi_get_window_from_view (w)); - gtk_window_present (window); - - bonobo_mdi_set_active_view (mdi, w); - } - - fname = gedit_document_get_short_name (doc); - - msgbox = gtk_message_dialog_new (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - _("Do you want to save the changes you made to the document \"%s\"? \n\n" - "Your changes will be lost if you don't save them."), - fname); - - gedit_dialog_add_button (GTK_DIALOG (msgbox), - _("Do_n't save"), GTK_STOCK_NO, - GTK_RESPONSE_NO); - - if (gedit_close_x_button_pressed) - exiting = FALSE; - else if (gedit_exit_button_pressed) - exiting = TRUE; - else - { - /* Delete event generated */ - if (g_list_length (bonobo_mdi_get_windows (BONOBO_MDI (gedit_mdi))) == 1) - exiting = TRUE; - else - exiting = FALSE; - } - -#if 0 - if (exiting) - gedit_dialog_add_button (GTK_DIALOG (msgbox), - _("_Don't quit"), GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - else - gedit_dialog_add_button (GTK_DIALOG (msgbox), - _("_Don't close"), GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); -#endif - - gtk_dialog_add_button (GTK_DIALOG (msgbox), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - - gtk_dialog_add_button (GTK_DIALOG (msgbox), - GTK_STOCK_SAVE, - GTK_RESPONSE_YES); - - gtk_dialog_set_default_response (GTK_DIALOG (msgbox), GTK_RESPONSE_YES); - - gtk_window_set_resizable (GTK_WINDOW (msgbox), FALSE); - - gtk_widget_show (msgbox); - gtk_window_present (GTK_WINDOW (msgbox)); - - ret = gtk_dialog_run (GTK_DIALOG (msgbox)); - - gtk_widget_destroy (msgbox); - - g_free (fname); - g_free (msg); - - switch (ret) - { - case GTK_RESPONSE_YES: - close = gedit_file_save (GEDIT_MDI_CHILD (child)); - break; - case GTK_RESPONSE_NO: - close = TRUE; - break; - default: - close = FALSE; - } - - gedit_debug (DEBUG_MDI, "CLOSE: %s", close ? "TRUE" : "FALSE"); - } - - /* FIXME: there is a bug if you "close all" >1 docs, don't save the document - * and then don't close the last one. - */ - /* Disable to avoid the bug */ - /* - if (close) - { - g_signal_handlers_disconnect_by_func (child, - G_CALLBACK (gedit_mdi_child_state_changed_handler), - NULL); - g_signal_handlers_disconnect_by_func (GTK_OBJECT (child), - G_CALLBACK (gedit_mdi_child_undo_redo_state_changed_handler), - NULL); - } - */ - - return close; -} - -static gint -gedit_mdi_remove_view_handler (BonoboMDI *mdi, GtkWidget *view) -{ - gedit_debug (DEBUG_MDI, ""); - - return TRUE; -} - -void -gedit_mdi_set_active_window_title (BonoboMDI *mdi) -{ - BonoboMDIChild* active_child = NULL; - GeditDocument* doc = NULL; - gchar* docname = NULL; - gchar* title = NULL; - - gedit_debug (DEBUG_MDI, ""); - - - active_child = bonobo_mdi_get_active_child (mdi); - if (active_child == NULL) - return; - - doc = GEDIT_MDI_CHILD (active_child)->document; - g_return_if_fail (doc != NULL); - - /* Set active window title */ - docname = gedit_document_get_uri (doc); - g_return_if_fail (docname != NULL); - - if (gedit_document_get_modified (doc)) - { - title = g_strdup_printf ("%s %s - gedit", docname, _("(modified)")); - } - else - { - if (gedit_document_is_readonly (doc)) - { - title = g_strdup_printf ("%s %s - gedit", docname, _("(readonly)")); - } - else - { - title = g_strdup_printf ("%s - gedit", docname); - } - - } - - gtk_window_set_title (GTK_WINDOW (bonobo_mdi_get_active_window (mdi)), title); - - g_free (docname); - g_free (title); -} - -static -void gedit_mdi_child_changed_handler (BonoboMDI *mdi, BonoboMDIChild *old_child) -{ - gedit_debug (DEBUG_MDI, ""); - - gedit_mdi_set_active_window_title (mdi); -} - -static -void gedit_mdi_view_changed_handler (BonoboMDI *mdi, GtkWidget *old_view) -{ - BonoboWindow *win; - GtkWidget *status; - GtkWidget *active_view; - - gedit_debug (DEBUG_MDI, ""); - - gedit_mdi_set_active_window_verbs_sensitivity (mdi); - - active_view = bonobo_mdi_get_active_view (mdi); - - win = bonobo_mdi_get_active_window (mdi); - g_return_if_fail (win != NULL); - - if (old_view != NULL) - { - gedit_view_set_cursor_position_statusbar (GEDIT_VIEW (old_view), NULL); - gedit_view_set_overwrite_mode_statusbar (GEDIT_VIEW (old_view), NULL); - } - - if (active_view == NULL) - return; - - /* - gtk_widget_grab_focus (active_view); - */ - - status = g_object_get_data (G_OBJECT (win), "CursorPosition"); - gedit_view_set_cursor_position_statusbar (GEDIT_VIEW (active_view), status); - - status = g_object_get_data (G_OBJECT (win), "OverwriteMode"); - gedit_view_set_overwrite_mode_statusbar (GEDIT_VIEW (active_view), status); -} - -void -gedit_mdi_clear_active_window_statusbar (GeditMDI *mdi) -{ - gpointer status; - BonoboWindow *win; - - win = bonobo_mdi_get_active_window (BONOBO_MDI (mdi)); - if (win == NULL) - return; - - status = g_object_get_data (G_OBJECT (win), "CursorPosition"); - g_return_if_fail (status != NULL); - g_return_if_fail (GTK_IS_STATUSBAR (status)); - - /* clear any previous message, underflow is allowed */ - gtk_statusbar_pop (GTK_STATUSBAR (status), 0); - - status = g_object_get_data (G_OBJECT (win), "OverwriteMode"); - g_return_if_fail (status != NULL); - g_return_if_fail (GTK_IS_STATUSBAR (status)); - - /* clear any previous message, underflow is allowed */ - gtk_statusbar_pop (GTK_STATUSBAR (status), 0); -} - -void -gedit_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi) -{ - /* FIXME: it is too slooooooow! - Paolo */ - - BonoboWindow* active_window = NULL; - BonoboMDIChild* active_child = NULL; - GeditDocument* doc = NULL; - BonoboUIComponent *ui_component; - - gedit_debug (DEBUG_MDI, ""); - - active_window = bonobo_mdi_get_active_window (mdi); - - if (active_window == NULL) - return; - - ui_component = bonobo_mdi_get_ui_component_from_window (active_window); - g_return_if_fail (ui_component != NULL); - - active_child = bonobo_mdi_get_active_child (mdi); - - bonobo_ui_component_freeze (ui_component, NULL); - - gedit_plugins_engine_update_plugins_ui (active_window, FALSE); - - if (active_child == NULL) - { - gedit_menus_set_verb_list_sensitive (ui_component, - gedit_menus_no_docs_sensible_verbs, FALSE); - goto end; - } - else - { - gedit_menus_set_verb_list_sensitive (ui_component, - gedit_menus_all_sensible_verbs, TRUE); - } - - doc = GEDIT_MDI_CHILD (active_child)->document; - g_return_if_fail (doc != NULL); - - if (gedit_document_is_readonly (doc)) - { - gedit_menus_set_verb_list_sensitive (ui_component, - gedit_menus_ro_sensible_verbs, FALSE); - goto end; - } - - if (!gedit_document_can_undo (doc)) - gedit_menus_set_verb_sensitive (ui_component, "/commands/EditUndo", FALSE); - - if (!gedit_document_can_redo (doc)) - gedit_menus_set_verb_sensitive (ui_component, "/commands/EditRedo", FALSE); - - if (!gedit_document_get_modified (doc)) - { - gedit_menus_set_verb_list_sensitive (ui_component, - gedit_menus_not_modified_doc_sensible_verbs, FALSE); - goto end; - } - - if (gedit_document_is_untitled (doc)) - { - gedit_menus_set_verb_list_sensitive (ui_component, - gedit_menus_untitled_doc_sensible_verbs, FALSE); - } - -end: - bonobo_ui_component_thaw (ui_component, NULL); -} - - -static void -gedit_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi) -{ - BonoboWindow* active_window = NULL; - BonoboMDIChild* active_child = NULL; - GeditDocument* doc = NULL; - BonoboUIComponent *ui_component; - - gedit_debug (DEBUG_MDI, ""); - - active_window = bonobo_mdi_get_active_window (mdi); - g_return_if_fail (active_window != NULL); - - ui_component = bonobo_mdi_get_ui_component_from_window (active_window); - g_return_if_fail (ui_component != NULL); - - active_child = bonobo_mdi_get_active_child (mdi); - doc = GEDIT_MDI_CHILD (active_child)->document; - g_return_if_fail (doc != NULL); - - bonobo_ui_component_freeze (ui_component, NULL); - - gedit_menus_set_verb_sensitive (ui_component, "/commands/EditUndo", - gedit_document_can_undo (doc)); - - gedit_menus_set_verb_sensitive (ui_component, "/commands/EditRedo", - gedit_document_can_redo (doc)); - - bonobo_ui_component_thaw (ui_component, NULL); -} - -GnomeRecentView * -gedit_mdi_get_recent_view_from_window (BonoboWindow* win) -{ - gpointer r; - gedit_debug (DEBUG_MDI, ""); - - r = g_object_get_data (G_OBJECT (win), RECENT_KEY); - - return (r != NULL) ? GNOME_RECENT_VIEW (r) : NULL; -} - - -static GeditWindowPrefs * -gedit_window_prefs_new (void) -{ - GeditWindowPrefs *prefs; - - gedit_debug (DEBUG_MDI, ""); - - prefs = g_new0 (GeditWindowPrefs, 1); - - prefs->toolbar_visible = gedit_prefs_manager_get_toolbar_visible (); - prefs->toolbar_buttons_style = gedit_prefs_manager_get_toolbar_buttons_style (); - - prefs->statusbar_visible = gedit_prefs_manager_get_statusbar_visible (); - prefs->statusbar_show_cursor_position = gedit_prefs_manager_get_statusbar_show_cursor_position (); - prefs->statusbar_show_overwrite_mode = gedit_prefs_manager_get_statusbar_show_overwrite_mode (); - - return prefs; -} - -static void -gedit_window_prefs_attach_to_window (GeditWindowPrefs *prefs, BonoboWindow *win) -{ - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (prefs != NULL); - g_return_if_fail (win != NULL); - g_return_if_fail (BONOBO_IS_WINDOW (win)); - - if (!window_prefs_id) - window_prefs_id = g_quark_from_static_string ("GeditWindowPrefsData"); - - g_object_set_qdata_full (G_OBJECT (win), window_prefs_id, prefs, g_free); -} - -static GeditWindowPrefs * -gedit_window_prefs_get_from_window (BonoboWindow *win) -{ - GeditWindowPrefs *prefs; - - gedit_debug (DEBUG_MDI, ""); - - g_return_val_if_fail (win != NULL, NULL); - g_return_val_if_fail (BONOBO_IS_WINDOW (win), NULL); - - prefs = g_object_get_qdata (G_OBJECT (win), window_prefs_id); - - return (prefs != NULL) ? (GeditWindowPrefs*)prefs : NULL; -} - -static void -gedit_window_prefs_save (GeditWindowPrefs *prefs) -{ - gedit_debug (DEBUG_MDI, ""); - - g_return_if_fail (prefs != NULL); - - if (prefs->toolbar_visible != gedit_prefs_manager_get_toolbar_visible ()) - gedit_prefs_manager_set_toolbar_visible (prefs->toolbar_visible); - - if (prefs->toolbar_buttons_style != gedit_prefs_manager_get_toolbar_buttons_style ()) - gedit_prefs_manager_set_toolbar_buttons_style (prefs->toolbar_buttons_style); - - if (prefs->statusbar_visible != gedit_prefs_manager_get_statusbar_visible ()) - gedit_prefs_manager_set_statusbar_visible (prefs->statusbar_visible); - - if (prefs->statusbar_show_cursor_position != - gedit_prefs_manager_get_statusbar_show_cursor_position ()) - gedit_prefs_manager_set_statusbar_show_cursor_position ( - prefs->statusbar_show_cursor_position); - - if (prefs->statusbar_show_overwrite_mode != - gedit_prefs_manager_get_statusbar_show_overwrite_mode ()) - gedit_prefs_manager_set_statusbar_show_overwrite_mode ( - prefs->statusbar_show_overwrite_mode); -} diff --git a/gedit/gedit-mdi.h b/gedit/gedit-mdi.h deleted file mode 100644 index b858d4cc2..000000000 --- a/gedit/gedit-mdi.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-mdi.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_MDI_H__ -#define __GEDIT_MDI_H__ - -#include <bonobo-mdi.h> -#include "gedit-recent.h" -#include "gnome-recent-view.h" - -#define GEDIT_TYPE_MDI (gedit_mdi_get_type ()) -#define GEDIT_MDI(obj) (GTK_CHECK_CAST ((obj), GEDIT_TYPE_MDI, GeditMDI)) -#define GEDIT_MDI_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_MDI, GeditMDIClass)) -#define GEDIT_IS_MDI(obj) (GTK_CHECK_TYPE ((obj), GEDIT_TYPE_MDI)) -#define GEDIT_IS_MDI_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_MDI)) -#define GEDIT_MDI_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GEDIT_TYPE_MDI, GeditMdiClass)) - - -typedef struct _GeditMDI GeditMDI; -typedef struct _GeditMDIClass GeditMDIClass; - -typedef struct _GeditMDIPrivate GeditMDIPrivate; - -struct _GeditMDI -{ - BonoboMDI mdi; - - GeditMDIPrivate *priv; -}; - -struct _GeditMDIClass -{ - BonoboMDIClass parent_class; -}; - - -GtkType gedit_mdi_get_type (void) G_GNUC_CONST; - -GeditMDI* gedit_mdi_new (void); - -void gedit_mdi_set_active_window_title (BonoboMDI *mdi); - -/* FIXME: should be static ??? */ -void gedit_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi); - -void gedit_mdi_clear_active_window_statusbar (GeditMDI *mdi); - -GnomeRecentView *gedit_mdi_get_recent_view_from_window (BonoboWindow* win); - -#endif /* __GEDIT_MDI_H__ */ - diff --git a/gedit/gedit-menus.c b/gedit/gedit-menus.c deleted file mode 100644 index 9e30d02a2..000000000 --- a/gedit/gedit-menus.c +++ /dev/null @@ -1,340 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-menus.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gedit-menus.h" -#include "gedit-commands.h" -#include "gedit2.h" - -BonoboUIVerb gedit_verbs [] = { - BONOBO_UI_VERB ("FileNew", gedit_cmd_file_new), - BONOBO_UI_VERB ("FileOpen", gedit_cmd_file_open), - BONOBO_UI_VERB ("FileSave", gedit_cmd_file_save), - BONOBO_UI_VERB ("FileSaveAs", gedit_cmd_file_save_as), - BONOBO_UI_VERB ("FileSaveAll", gedit_cmd_file_save_all), - BONOBO_UI_VERB ("FileRevert", gedit_cmd_file_revert), - BONOBO_UI_VERB ("FileOpenURI", gedit_cmd_file_open_uri), - BONOBO_UI_VERB ("FilePrint", gedit_cmd_file_print), - BONOBO_UI_VERB ("FilePrintPreview", gedit_cmd_file_print_preview), - BONOBO_UI_VERB ("FileClose", gedit_cmd_file_close), - BONOBO_UI_VERB ("FileCloseAll", gedit_cmd_file_close_all), - BONOBO_UI_VERB ("FileExit", gedit_cmd_file_exit), - BONOBO_UI_VERB ("EditUndo", gedit_cmd_edit_undo), - BONOBO_UI_VERB ("EditRedo", gedit_cmd_edit_redo), - BONOBO_UI_VERB ("EditCut", gedit_cmd_edit_cut), - BONOBO_UI_VERB ("EditCopy", gedit_cmd_edit_copy), - BONOBO_UI_VERB ("EditPaste", gedit_cmd_edit_paste), - BONOBO_UI_VERB ("EditClear", gedit_cmd_edit_clear), - BONOBO_UI_VERB ("EditSelectAll", gedit_cmd_edit_select_all), - BONOBO_UI_VERB ("SearchFind", gedit_cmd_search_find), - BONOBO_UI_VERB ("SearchFindAgain", gedit_cmd_search_find_again), - BONOBO_UI_VERB ("SearchReplace", gedit_cmd_search_replace), - BONOBO_UI_VERB ("SearchGoToLine", gedit_cmd_search_goto_line), - BONOBO_UI_VERB ("SettingsPreferences", gedit_cmd_settings_preferences), - BONOBO_UI_VERB ("HelpContents", gedit_cmd_help_contents), - BONOBO_UI_VERB ("About", gedit_cmd_help_about), - - BONOBO_UI_VERB_END -}; - -gchar* gedit_menus_ro_sensible_verbs [] = { - "/commands/FileSave", - "/commands/FileRevert", - "/commands/EditUndo", - "/commands/EditRedo", - "/commands/EditCut", - "/commands/EditPaste", - "/commands/EditClear", - "/commands/SearchReplace", - - NULL -}; - -gchar* gedit_menus_no_docs_sensible_verbs [] = { - "/commands/FileSave", - "/commands/FileSaveAll", - "/commands/FileSaveAs", - "/commands/FileRevert", - "/commands/FilePrint", - "/commands/FilePrintPreview", - "/commands/FileClose", - "/commands/FileCloseAll", - "/commands/EditUndo", - "/commands/EditRedo", - "/commands/EditCut", - "/commands/EditCopy", - "/commands/EditPaste", - "/commands/EditClear", - "/commands/EditSelectAll", - "/commands/SearchFind", - "/commands/SearchFindAgain", - "/commands/SearchReplace", - "/commands/SearchGoToLine", - - NULL -}; - -gchar* gedit_menus_untitled_doc_sensible_verbs [] = { - "/commands/FileRevert", - - NULL -}; - -gchar* gedit_menus_not_modified_doc_sensible_verbs [] = { - "/commands/FileSave", - "/commands/FileRevert", - - NULL -}; - - -void -gedit_menus_set_verb_sensitive (BonoboUIComponent *ui_component, gchar* cname, gboolean sensitive) -{ - g_return_if_fail (cname != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); - - bonobo_ui_component_set_prop ( - ui_component, cname, "sensitive", sensitive ? "1" : "0", NULL); -} - -void -gedit_menus_set_verb_list_sensitive (BonoboUIComponent *ui_component, gchar** vlist, gboolean sensitive) -{ - g_return_if_fail (vlist != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); - - for ( ; *vlist; ++vlist) - { - bonobo_ui_component_set_prop ( - ui_component, *vlist, "sensitive", sensitive ? "1" : "0", NULL); - } -} - -void -gedit_menus_set_verb_state (BonoboUIComponent *ui_component, gchar* cname, gboolean state) -{ - g_return_if_fail (cname != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); - - bonobo_ui_component_set_prop ( - ui_component, cname, "state", state ? "1" : "0", NULL); -} - -void -gedit_menus_add_menu_item (BonoboWindow *window, const gchar *path, - const gchar *name, const gchar *label, - const gchar *tooltip, const gchar *stock_pixmap, - BonoboUIVerbFn cb) -{ - BonoboUIComponent *ui_component; - gchar *item_path; - gchar *cmd; - - g_return_if_fail (window != NULL); - g_return_if_fail (path != NULL); - g_return_if_fail (label != NULL); - g_return_if_fail (cb != NULL); - - item_path = g_strconcat (path, name, NULL); - ui_component = gedit_get_ui_component_from_window (BONOBO_WINDOW (window)); - if (!bonobo_ui_component_path_exists (ui_component, item_path, NULL)) { - gchar *xml; - - xml = g_strdup_printf ("<menuitem name=\"%s\" verb=\"\"" - " _label=\"%s\"" - " _tip=\"%s\" hidden=\"0\" />", name, - label, tooltip); - - - if (stock_pixmap != NULL) { - cmd = g_strdup_printf ("<cmd name=\"%s\"" - " pixtype=\"stock\" pixname=\"%s\" />", - name, stock_pixmap); - } - else { - cmd = g_strdup_printf ("<cmd name=\"%s\" />", name); - } - - - bonobo_ui_component_set_translate (ui_component, path, - xml, NULL); - - bonobo_ui_component_set_translate (ui_component, "/commands/", - cmd, NULL); - - bonobo_ui_component_add_verb (ui_component, name, cb, NULL); - - g_free (xml); - g_free (cmd); - } - - g_free (item_path); -} - -void -gedit_menus_remove_menu_item (BonoboWindow *window, const gchar *path, - const gchar *name) -{ - BonoboUIComponent *ui_component; - gchar *item_path; - - g_return_if_fail (window != NULL); - g_return_if_fail (path != NULL); - g_return_if_fail (name != NULL); - - item_path = g_strconcat (path, name, NULL); - ui_component = gedit_get_ui_component_from_window (BONOBO_WINDOW (window)); - - if (bonobo_ui_component_path_exists (ui_component, item_path, NULL)) { - gchar *cmd; - - cmd = g_strdup_printf ("/commands/%s", name); - - bonobo_ui_component_rm (ui_component, item_path, NULL); - bonobo_ui_component_rm (ui_component, cmd, NULL); - - g_free (cmd); - } - - g_free (item_path); -} - -void -gedit_menus_add_menu_item_all (const gchar *path, const gchar *name, - const gchar *label, const gchar *tooltip, - const gchar *stock_pixmap, - BonoboUIVerbFn cb) -{ - GList* top_windows; - - top_windows = gedit_get_top_windows (); - g_return_if_fail (top_windows != NULL); - - while (top_windows) - { - BonoboWindow* window = BONOBO_WINDOW (top_windows->data); - - - gedit_menus_add_menu_item (window, path, name, label, tooltip, - stock_pixmap, cb); - - top_windows = g_list_next (top_windows); - } -} - -void -gedit_menus_remove_menu_item_all (const gchar *path, const gchar *name) -{ - GList* top_windows; - - top_windows = gedit_get_top_windows (); - g_return_if_fail (top_windows != NULL); - - while (top_windows) - { - BonoboWindow* window = BONOBO_WINDOW (top_windows->data); - - gedit_menus_remove_menu_item (window, path, name); - - top_windows = g_list_next (top_windows); - } -} - - -void -gedit_menus_add_menu_item_toggle (BonoboWindow *window, const gchar *path, - const gchar *name, const gchar *label, const gchar *tooltip, - BonoboUIListenerFn lt, gpointer data) -{ - BonoboUIComponent *ui_component; - gchar *item_path; - gchar *cmd; - - g_return_if_fail (window != NULL); - g_return_if_fail (path != NULL); - g_return_if_fail (label != NULL); - g_return_if_fail (lt != NULL); - - item_path = g_strconcat (path, name, NULL); - ui_component = gedit_get_ui_component_from_window (BONOBO_WINDOW (window)); - if (!bonobo_ui_component_path_exists (ui_component, item_path, NULL)) - { - gchar *xml; - - xml = g_strdup_printf ("<menuitem name=\"%s\" id=\"%s\" verb=\"\" />", - name, name); - - cmd = g_strdup_printf ("<cmd name=\"%s\" _label=\"%s\" type=\"toggle\" _tip=\"%s\" state=\"0\"/>", - name, label, tooltip); - - bonobo_ui_component_set_translate (ui_component, "/commands/", - cmd, NULL); - - bonobo_ui_component_set_translate (ui_component, path, - xml, NULL); - - bonobo_ui_component_add_listener (ui_component, name, lt, data); - - g_free (xml); - g_free (cmd); - } - - g_free (item_path); -} - - -void -gedit_menus_add_menu_item_toggle_all (const gchar *path, - const gchar *name, const gchar *label, const gchar *tooltip, - BonoboUIListenerFn lt, gpointer data) -{ - GList* top_windows; - - top_windows = gedit_get_top_windows (); - g_return_if_fail (top_windows != NULL); - - while (top_windows) - { - BonoboWindow* window = BONOBO_WINDOW (top_windows->data); - - - gedit_menus_add_menu_item_toggle (window, path, name, label, tooltip, - lt, data); - - top_windows = g_list_next (top_windows); - } -} - - diff --git a/gedit/gedit-menus.h b/gedit/gedit-menus.h deleted file mode 100644 index 021cba1b4..000000000 --- a/gedit/gedit-menus.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-menus.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_MENU_H__ -#define __GEDIT_MENU_H__ - -#include <bonobo/bonobo-ui-component.h> -#include <bonobo/bonobo-ui-engine.h> -#include <bonobo/bonobo-window.h> - -extern BonoboUIVerb gedit_verbs []; -extern gchar* gedit_menus_ro_sensible_verbs []; -extern gchar* gedit_menus_no_docs_sensible_verbs []; -extern gchar* gedit_menus_untitled_doc_sensible_verbs []; -extern gchar* gedit_menus_not_modified_doc_sensible_verbs []; - -#define gedit_menus_all_sensible_verbs gedit_menus_no_docs_sensible_verbs - -void gedit_menus_set_verb_sensitive (BonoboUIComponent *ui_component, - gchar *cname, - gboolean sensitive); -void gedit_menus_set_verb_list_sensitive (BonoboUIComponent *ui_component, - gchar **vlist, - gboolean sensitive); -void gedit_menus_set_verb_state (BonoboUIComponent *ui_component, - gchar* cname, - gboolean state); - -/* convenience functions for plugins */ - -void gedit_menus_add_menu_item (BonoboWindow *window, - const gchar *path, - const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *stock_pixmap, - BonoboUIVerbFn cb); - -void gedit_menus_remove_menu_item (BonoboWindow *window, - const gchar *path, - const gchar *name); - - -void gedit_menus_add_menu_item_all (const gchar *path, - const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *stock_pixmap, - BonoboUIVerbFn cb); - -void gedit_menus_remove_menu_item_all (const gchar *path, - const gchar *name); - -void gedit_menus_add_menu_item_toggle (BonoboWindow *window, - const gchar *path, - const gchar *name, - const gchar *label, - const gchar *tooltip, - BonoboUIListenerFn lt, - gpointer data); - -void gedit_menus_add_menu_item_toggle_all (const gchar *path, - const gchar *name, - const gchar *label, - const gchar *tooltip, - BonoboUIListenerFn lt, - gpointer data); - -#define gedit_menus_remove_menu_item_toggle gedit_menus_remove_menu_item -#define gedit_menus_remove_menu_item_toggle_all gedit_menus_remove_menu_item_all - -#endif /* __GEDIT_MENU_H__ */ diff --git a/gedit/gedit-plugin.c b/gedit/gedit-plugin.c deleted file mode 100644 index 57bbb2f5f..000000000 --- a/gedit/gedit-plugin.c +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-plugin.h - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include "gedit-plugin.h" -#include "dialogs/gedit-dialogs.h" - -gchar* -gedit_plugin_locate_program (gchar *program_name, gchar *plugin_name, GtkWindow *parent) -{ - return gedit_plugin_program_location_dialog (program_name, plugin_name, parent); -} - diff --git a/gedit/gedit-plugin.h b/gedit/gedit-plugin.h deleted file mode 100644 index 7e0b91d98..000000000 --- a/gedit/gedit-plugin.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-plugin.h - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_PLUGIN_H__ -#define __GEDIT_PLUGIN_H__ - -#include <glib.h> -#include <gmodule.h> -#include "gedit2.h" - -typedef enum -{ - PLUGIN_OK, - PLUGIN_ERROR, - PLUGIN_DEAD -} GeditPluginState; - -typedef struct _GeditPlugin GeditPlugin; - -struct _GeditPlugin -{ - gchar *file; - GModule *handle; - - /* The following fields are compulsory */ - gchar *name; - gchar *desc; - gchar *author; - gchar *copyright; - - /* The following fields are compulsory */ - GeditPluginState (*init) (GeditPlugin *p); - GeditPluginState (*activate) (GeditPlugin *p); - GeditPluginState (*deactivate) (GeditPlugin *p); - - /* The following fields are optional */ - GeditPluginState (*configure) (GeditPlugin *p, GtkWidget *parent); - GeditPluginState (*save_settings)(GeditPlugin *p); - GeditPluginState (*update_ui) (GeditPlugin *p, BonoboWindow *w); - GeditPluginState (*destroy) (GeditPlugin *p); - - /* Eventually filled in by the plugin */ - gpointer private_data; -}; - -gchar* gedit_plugin_locate_program (gchar *program_name, - gchar *plugin_name, - GtkWindow *parent); - -#endif /* __GEDIT_PLUGIN_H__ */ - - diff --git a/gedit/gedit-plugins-engine.c b/gedit/gedit-plugins-engine.c deleted file mode 100644 index 2475467b7..000000000 --- a/gedit/gedit-plugins-engine.c +++ /dev/null @@ -1,519 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-plugins-engine.c - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <dirent.h> -#include <string.h> - -#include <libgnome/gnome-util.h> -#include <libgnome/gnome-i18n.h> - -#include <gconf/gconf-client.h> - -#include "gedit-plugins-engine.h" -#include "gedit-debug.h" - -#define USER_GEDIT_PLUGINS_LOCATION ".gedit-2/plugins/" - -#define GEDIT_PLUGINS_ENGINE_BASE_KEY "/apps/gedit-2/plugins" - -#define SOEXT ("." G_MODULE_SUFFIX) -#define SOEXT_LEN (strlen (SOEXT)) - -static void gedit_plugins_engine_load_all (void); -static void gedit_plugins_engine_load_dir (const gchar *dir); -static GeditPlugin *gedit_plugins_engine_load (const gchar *file); - -static GeditPluginInfo *gedit_plugins_engine_find_plugin_info (GeditPlugin *plugin); -static void gedit_plugins_engine_reactivate_all (void); - -static GList *gedit_plugins_list = NULL; - -static GConfClient *gedit_plugins_engine_gconf_client = NULL; - -gboolean -gedit_plugins_engine_init (void) -{ - gedit_debug (DEBUG_PLUGINS, ""); - - if (!g_module_supported ()) - return FALSE; - - gedit_plugins_engine_gconf_client = gconf_client_get_default (); - g_return_val_if_fail (gedit_plugins_engine_gconf_client != NULL, FALSE); - - gconf_client_add_dir (gedit_plugins_engine_gconf_client, - GEDIT_PLUGINS_ENGINE_BASE_KEY, - GCONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - - gedit_plugins_engine_load_all (); - - return TRUE; -} - -static void -gedit_plugins_engine_load_all (void) -{ - gchar *pdir; - - gchar const * const home = g_get_home_dir (); - - gedit_debug (DEBUG_PLUGINS, ""); - - /* load user's plugins */ - if (home != NULL) - { - pdir = gnome_util_prepend_user_home (USER_GEDIT_PLUGINS_LOCATION); - gedit_plugins_engine_load_dir (pdir); - g_free (pdir); - } - - /* load system plugins */ - gedit_plugins_engine_load_dir (GEDIT_PLUGINDIR "/"); -} - -static void -gedit_plugins_engine_load_dir (const gchar *dir) -{ - DIR *d; - struct dirent *e; - - gedit_debug (DEBUG_PLUGINS, "DIR: %s", dir); - - d = opendir (dir); - - if (d == NULL) - { - gedit_debug (DEBUG_PLUGINS, "%s", strerror (errno)); - return; - } - - while ((e = readdir (d)) != NULL) - { - if (strncmp (e->d_name + strlen (e->d_name) - SOEXT_LEN, SOEXT, SOEXT_LEN) == 0) - { - gchar *plugin = g_strconcat (dir, e->d_name, NULL); - gedit_plugins_engine_load (plugin); - g_free (plugin); - } - } - closedir (d); -} - -static GeditPlugin * -gedit_plugins_engine_load (const gchar *file) -{ - GeditPluginInfo *info; - - GeditPlugin *plugin; - guint res; - gboolean to_be_activated; - gchar *key; - gchar *basename; - - gedit_debug (DEBUG_PLUGINS, ""); - - g_return_val_if_fail (file != NULL, NULL); - g_return_val_if_fail (gedit_plugins_engine_gconf_client != NULL, NULL); - - info = g_new0 (GeditPluginInfo, 1); - g_return_val_if_fail (info != NULL, NULL); - - plugin = g_new0 (GeditPlugin, 1); - g_return_val_if_fail (plugin != NULL, NULL); - - info->plugin = plugin; - - plugin->file = g_strdup (file); - plugin->handle = g_module_open (file, G_MODULE_BIND_LAZY); - - if (plugin->handle == NULL) - { - g_warning (_("Error, unable to open module file '%s'\n"), - g_module_error ()); - - g_free (plugin->file); - g_free (plugin); - - g_free (info); - - return NULL; - } - - /* Load "init" symbol */ - if (!g_module_symbol (plugin->handle, "init", - (gpointer*)&plugin->init)) - { - g_warning (_("Error, plugin '%s' does not contain init function."), - file); - - goto error; - } - - /* Load "activate" symbol */ - if (!g_module_symbol (plugin->handle, "activate", - (gpointer*)&plugin->activate)) - { - g_warning (_("Error, plugin '%s' does not contain activate function."), - file); - - goto error; - } - - /* Load "deactivate" symbol */ - if (!g_module_symbol (plugin->handle, "deactivate", - (gpointer*)&plugin->deactivate)) - { - g_warning (_("Error, plugin '%s' does not contain deactivate function."), - file); - - goto error; - } - - /* Load "configure" symbol */ - if (!g_module_symbol (plugin->handle, "configure", - (gpointer*)&plugin->configure)) - plugin->configure = NULL; - - /* Load "save_settings" symbol */ - if (!g_module_symbol (plugin->handle, "save_settings", - (gpointer*)&plugin->save_settings)) - plugin->save_settings = NULL; - - /* Load "update_ui" symbol */ - if (!g_module_symbol (plugin->handle, "update_ui", - (gpointer*)&plugin->update_ui)) - plugin->update_ui = NULL; - - /* Load "destroy" symbol */ - if (!g_module_symbol (plugin->handle, "destroy", - (gpointer*)&plugin->destroy)) - plugin->destroy = NULL; - - /* Initialize plugin */ - res = plugin->init (plugin); - if (res != PLUGIN_OK) - { - g_warning (_("Error, impossible to initialize plugin '%s'"), - file); - - goto error; - } - - if (plugin->name == NULL) - { - g_warning (_("Error, the plugin '%s' did not specified a name"), - file); - - goto error; - } - - basename = g_path_get_basename (plugin->file); - - key = g_strdup_printf ("%s%s", - GEDIT_PLUGINS_ENGINE_BASE_KEY, - basename); - - g_free (basename); - - to_be_activated = gconf_client_get_bool ( - gedit_plugins_engine_gconf_client, - key, - NULL); - - g_free (key); - - /* Actually, the plugin will be activated when reactivate_all - * will be called for the first time. - * */ - if (to_be_activated) - info->state = GEDIT_PLUGIN_ACTIVATED; - else - info->state = GEDIT_PLUGIN_DEACTIVATED; - - gedit_plugins_list = g_list_append (gedit_plugins_list, info); - - gedit_debug (DEBUG_PLUGINS, "Plugin: %s (INSTALLED)", plugin->name); - - return plugin; - -error: - g_free (info); - - g_module_close (plugin->handle); - - g_free (plugin->file); - g_free (plugin->name); - g_free (plugin->desc); - g_free (plugin->author); - g_free (plugin->copyright); - - g_free (plugin); - - return NULL; -} - -void -gedit_plugins_engine_save_settings (void) -{ - GList *pl; - - gedit_debug (DEBUG_PLUGINS, ""); - - g_return_if_fail (gedit_plugins_engine_gconf_client != NULL); - - /* save settings of all the plugins that implement the - * save_settings function - */ - pl = gedit_plugins_list; - - while (pl) - { - gchar *key; - gchar *basename; - GeditPluginInfo *info = (GeditPluginInfo*)pl->data; - - if (info->plugin->save_settings != NULL) - { - gint r; - gedit_debug (DEBUG_PLUGINS, "Save settings of %s", info->plugin->name); - - r = info->plugin->save_settings (info->plugin); - - if (r != PLUGIN_OK) - { - g_warning (_("Error, impossible to save settings of the plugin '%s'"), - info->plugin->name); - } - } - - basename = g_path_get_basename (info->plugin->file); - - key = g_strdup_printf ("%s%s", - GEDIT_PLUGINS_ENGINE_BASE_KEY, - basename); - - g_free (basename); - - gconf_client_set_bool ( - gedit_plugins_engine_gconf_client, - key, - info->state == GEDIT_PLUGIN_ACTIVATED, - NULL); - - g_free (key); - - pl = g_list_next (pl); - } -} - - -const GList * -gedit_plugins_engine_get_plugins_list (void) -{ - gedit_debug (DEBUG_PLUGINS, ""); - - return gedit_plugins_list; -} - -static GeditPluginInfo * -gedit_plugins_engine_find_plugin_info (GeditPlugin *plugin) -{ - GList *pl; - - gedit_debug (DEBUG_PLUGINS, ""); - - pl = gedit_plugins_list; - - while (pl) - { - GeditPluginInfo *info = (GeditPluginInfo*)pl->data; - - if (info->plugin == plugin) - return info; - - pl = g_list_next (pl); - } - - return NULL; -} - - -gboolean -gedit_plugins_engine_activate_plugin (GeditPlugin *plugin) -{ - gboolean res; - GeditPluginInfo *info; - - gedit_debug (DEBUG_PLUGINS, ""); - - info = gedit_plugins_engine_find_plugin_info (plugin); - g_return_val_if_fail (info != NULL, FALSE); - - /* Activate plugin */ - res = plugin->activate (plugin); - if (res != PLUGIN_OK) - { - g_warning (_("Error, impossible to activate plugin '%s'"), - plugin->name); - - return FALSE; - } - - /* Update plugin state */ - info->state = GEDIT_PLUGIN_ACTIVATED; - - return TRUE; -} - -gboolean -gedit_plugins_engine_deactivate_plugin (GeditPlugin *plugin) -{ - gboolean res; - GeditPluginInfo *info; - - gedit_debug (DEBUG_PLUGINS, ""); - - info = gedit_plugins_engine_find_plugin_info (plugin); - g_return_val_if_fail (info != NULL, FALSE); - - /* Activate plugin */ - res = plugin->deactivate (plugin); - if (res != PLUGIN_OK) - { - g_warning (_("Error, impossible to deactivate plugin '%s'"), - plugin->name); - - return FALSE; - } - - /* Update plugin state */ - info->state = GEDIT_PLUGIN_DEACTIVATED; - - return TRUE; -} - -static void -gedit_plugins_engine_reactivate_all (void) -{ - GList *pl; - - gedit_debug (DEBUG_PLUGINS, ""); - - pl = gedit_plugins_list; - - while (pl) - { - GeditPluginInfo *info = (GeditPluginInfo*)pl->data; - - if (info->state == GEDIT_PLUGIN_ACTIVATED) - { - gint r = info->plugin->activate (info->plugin); - - if (r != PLUGIN_OK) - { - g_warning (_("Error, impossible to activate plugin '%s'"), - info->plugin->name); - - info->state = GEDIT_PLUGIN_DEACTIVATED; - } - } - - pl = g_list_next (pl); - } - -} - -void -gedit_plugins_engine_update_plugins_ui (BonoboWindow* window, gboolean new_window) -{ - GList *pl; - - gedit_debug (DEBUG_PLUGINS, ""); - - g_return_if_fail (window != NULL); - g_return_if_fail (BONOBO_IS_WINDOW (window)); - - if (new_window) - gedit_plugins_engine_reactivate_all (); - - /* updated ui of all the plugins that implement thae - * update_ui function - */ - pl = gedit_plugins_list; - - while (pl) - { - GeditPluginInfo *info = (GeditPluginInfo*)pl->data; - - if ((info->state == GEDIT_PLUGIN_ACTIVATED) && - (info->plugin->update_ui != NULL)) - { - gint r; - gedit_debug (DEBUG_PLUGINS, "Updating UI of %s", info->plugin->name); - - r = info->plugin->update_ui (info->plugin, window); - - if (r != PLUGIN_OK) - { - g_warning (_("Error, impossible to update ui of the plugin '%s'"), - info->plugin->name); - } - } - - pl = g_list_next (pl); - } - - gedit_debug (DEBUG_PLUGINS, "END"); -} - -gboolean -gedit_plugins_engine_is_a_configurable_plugin (GeditPlugin *plugin) -{ - gedit_debug (DEBUG_PLUGINS, ""); - - g_return_val_if_fail (plugin != NULL, FALSE); - - return (plugin->configure != NULL); -} - -gboolean -gedit_plugins_engine_configure_plugin (GeditPlugin *plugin, GtkWidget* parent) -{ - gedit_debug (DEBUG_PLUGINS, ""); - - g_return_val_if_fail (plugin != NULL, FALSE); - g_return_val_if_fail (plugin->configure != NULL, FALSE); - - return (plugin->configure (plugin, parent) == PLUGIN_OK); -} diff --git a/gedit/gedit-plugins-engine.h b/gedit/gedit-plugins-engine.h deleted file mode 100644 index be36b0be1..000000000 --- a/gedit/gedit-plugins-engine.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-plugins-engine.h - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_PLUGINS_ENGINE_H__ -#define __GEDIT_PLUGINS_ENGINE_H__ - -#include "gedit-plugin.h" - -typedef struct _GeditPluginInfo GeditPluginInfo; - -typedef enum { - GEDIT_PLUGIN_ACTIVATED, - GEDIT_PLUGIN_DEACTIVATED -} GeditPluginActivationState; - -struct _GeditPluginInfo -{ - GeditPlugin *plugin; - GeditPluginActivationState state; -}; - -gboolean gedit_plugins_engine_init (void); -void gedit_plugins_engine_save_settings (void); - -const GList *gedit_plugins_engine_get_plugins_list (void); - -gboolean gedit_plugins_engine_activate_plugin (GeditPlugin *plugin); -gboolean gedit_plugins_engine_deactivate_plugin (GeditPlugin *plugin); -gboolean gedit_plugins_engine_configure_plugin (GeditPlugin *plugin, GtkWidget* parent); - - -/* - * new_window == TRUE if this function is called because a new top window - * has been created - */ -void gedit_plugins_engine_update_plugins_ui (BonoboWindow *window, gboolean new_window); - -gboolean gedit_plugins_engine_is_a_configurable_plugin (GeditPlugin *plugin); - -#endif /* __GEDIT_PLUGINS_ENGINE_H__ */ - - diff --git a/gedit/gedit-prefs-manager.c b/gedit/gedit-prefs-manager.c deleted file mode 100644 index b6ed24cef..000000000 --- a/gedit/gedit-prefs-manager.c +++ /dev/null @@ -1,1694 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-prefs-manager.c - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <string.h> - -#include <gconf/gconf-client.h> -#include <gconf/gconf-value.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-config.h> - -#include "gedit-prefs-manager.h" -#include "gedit-debug.h" - -#include "gedit-view.h" -#include "gedit-mdi.h" -#include "gedit2.h" - - -#define GPM_PREFS_DIR GEDIT_BASE_KEY "/preferences" - -/* Editor */ -#define GPM_FONT_DIR GPM_PREFS_DIR "/editor/font" -#define GPM_USE_DEFAULT_FONT GPM_FONT_DIR "/use_default_font" -#define GPM_EDITOR_FONT GPM_FONT_DIR "/editor_font" - -#define GPM_COLORS_DIR GPM_PREFS_DIR "/editor/colors" -#define GPM_USE_DEFAULT_COLORS GPM_COLORS_DIR "/use_default_colors" -#define GPM_BACKGROUND_COLOR GPM_COLORS_DIR "/background_color" -#define GPM_TEXT_COLOR GPM_COLORS_DIR "/text_color" -#define GPM_SELECTED_TEXT_COLOR GPM_COLORS_DIR "/selected_text_color" -#define GPM_SELECTION_COLOR GPM_COLORS_DIR "/selection_color" - -#define GPM_SAVE_DIR GPM_PREFS_DIR "/editor/save" -#define GPM_CREATE_BACKUP_COPY GPM_SAVE_DIR "/create_backup_copy" -#define GPM_BACKUP_COPY_EXTENSION GPM_SAVE_DIR "/backup_copy_extension" - -#define GPM_AUTO_SAVE GPM_SAVE_DIR "/auto_save" -#define GPM_AUTO_SAVE_INTERVAL GPM_SAVE_DIR "/auto_save_interval" - -#define GPM_SAVE_ENCODING GPM_SAVE_DIR "/save_encoding" - -#define GPM_UNDO_DIR GPM_PREFS_DIR "/editor/undo" -#define GPM_UNDO_ACTIONS_LIMIT GPM_UNDO_DIR "/undo_actions_limit" - -#define GPM_WRAP_MODE_DIR GPM_PREFS_DIR "/editor/wrap_mode" -#define GPM_WRAP_MODE GPM_WRAP_MODE_DIR "/wrap_mode" - -#define GPM_TABS_DIR GPM_PREFS_DIR "/editor/tabs" -#define GPM_TABS_SIZE GPM_TABS_DIR "/tabs_size" - -#define GPM_LINE_NUMBERS_DIR GPM_PREFS_DIR "/editor/line_numbers" -#define GPM_DISPLAY_LINE_NUMBERS GPM_LINE_NUMBERS_DIR "/display_line_numbers" - -/* UI */ -#define GPM_TOOLBAR_DIR GPM_PREFS_DIR "/ui/toolbar" -#define GPM_TOOLBAR_VISIBLE GPM_TOOLBAR_DIR "/toolbar_visible" -#define GPM_TOOLBAR_BUTTONS_STYLE GPM_TOOLBAR_DIR "/toolbar_buttons_style" - -#define GPM_STATUSBAR_DIR GPM_PREFS_DIR "/ui/statusbar" -#define GPM_STATUSBAR_VISIBLE GPM_STATUSBAR_DIR "/statusbar_visible" -#define GPM_STATUSBAR_SHOW_CURSOR_POSITION GPM_STATUSBAR_DIR "/statusbar_show_cursor_position" -#define GPM_STATUSBAR_SHOW_OVERWRITE_MODE GPM_STATUSBAR_DIR "/statusbar_show_overwrite_mode" - -#define GRM_RECENTS_DIR GPM_PREFS_DIR "/ui/recents" -#define GPM_MAX_RECENTS GRM_RECENTS_DIR "/max_recents" - -/* Print*/ -#define GPM_PRINT_PAGE_DIR GPM_PREFS_DIR "/print/page" -#define GPM_PRINT_HEADER GPM_PRINT_PAGE_DIR "/print_header" -#define GPM_PRINT_WRAP_MODE GPM_PRINT_PAGE_DIR "/print_wrap_mode" -#define GPM_PRINT_LINE_NUMBERS GPM_PRINT_PAGE_DIR "/print_line_numbers" - -#define GPM_PRINT_FONT_DIR GPM_PREFS_DIR "/print/fonts" -#define GPM_PRINT_FONT_BODY GPM_PRINT_FONT_DIR "/print_font_body" -#define GPM_PRINT_FONT_HEADER GPM_PRINT_FONT_DIR "/print_font_header" -#define GPM_PRINT_FONT_NUMBERS GPM_PRINT_FONT_DIR "/print_font_numbers" - -#define GPM_WINDOW_DIR "/gedit-2/window" -#define GPM_WINDOW_STATE GPM_WINDOW_DIR "/state" -#define GPM_WINDOW_WIDTH GPM_WINDOW_DIR "/width" -#define GPM_WINDOW_HEIGHT GPM_WINDOW_DIR "/height" - -/* Fallback default values. Keep in sync with gedit.schemas */ - -#define GPM_DEFAULT_USE_DEFAULT_FONT 0 /* FALSE */ -#define GPM_DEFAULT_EDITOR_FONT (const gchar*) "Courier Medium 12" - -#define GPM_DEFAULT_USE_DEFAULT_COLORS 1 /* TRUE */ -#define GPM_DEFAULT_BACKGROUND_COLOR (const gchar*) "#ffffffffffff" -#define GPM_DEFAULT_TEXT_COLOR (const gchar*) "#000000000000" -#define GPM_DEFAULT_SELECTED_TEXT_COLOR (const gchar*) "#ffffffffffff" -#define GPM_DEFAULT_SELECTION_COLOR (const gchar*) "#000000009c9c" - -#define GPM_DEFAULT_CREATE_BACKUP_COPY 1 /* TRUE */ -#define GPM_DEFAULT_BACKUP_COPY_EXTENSION (const gchar*) "~" - -#define GPM_DEFAULT_AUTO_SAVE 0 /* FALSE */ -#define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */ - -#define GPM_DEFAULT_SAVE_ENCODING (const gchar*) "GEDIT_SAVE_ALWAYS_UTF8" - -#define GPM_DEFAULT_UNDO_ACTIONS_LIMIT 25 /* actions */ - -#define GPM_DEFAULT_WRAP_MODE "GTK_WRAP_WORD" - -#define GPM_DEFAULT_TABS_SIZE 8 - -#define GPM_DEFAULT_DISPLAY_LINE_NUMBERS 0 /* FALSE */ - -#define GPM_DEFAULT_TOOLBAR_VISIBLE 1 /* TRUE */ -#define GPM_DEFAULT_TOOLBAR_BUTTONS_STYLE "GEDIT_TOOLBAR_SYSTEM" -#define GPM_DEFAULT_TOOLBAR_SHOW_TOOLTIPS 1 /* TRUE */ - -#define GPM_DEFAULT_STATUSBAR_VISIBLE 1 /* TRUE */ -#define GPM_DEFAULT_STATUSBAR_SHOW_CURSOR_POSITION 1 /* TRUE */ -#define GPM_DEFAULT_STATUSBAR_SHOW_OVERWRITE_MODE 1 /* TRUE */ - -#define GPM_DEFAULT_PRINT_HEADER 1 /* TRUE */ -#define GPM_DEFAULT_PRINT_WRAP_MODE "GTK_WRAP_CHAR" -#define GPM_DEFAULT_PRINT_LINE_NUMBERS 0 /* No numbers */ - -#define GPM_DEFAULT_PRINT_FONT_BODY (const gchar*) "Courier 9" -#define GPM_DEFAULT_PRINT_FONT_HEADER (const gchar*) "Helvetica 11" -#define GPM_DEFAULT_PRINT_FONT_NUMBERS (const gchar*) "Helvetica 8" - -#define GPM_DEFAULT_MAX_RECENTS 5 - -#define GPM_DEFAULT_WINDOW_STATE 0 -#define GPM_DEFAULT_WINDOW_WIDTH 650 -#define GPM_DEFAULT_WINDOW_HEIGHT 500 - -#define GPM_DEFAULT_WINDOW_STATE_STR "0" -#define GPM_DEFAULT_WINDOW_WIDTH_STR "650" -#define GPM_DEFAULT_WINDOW_HEIGHT_STR "500" - - - -#define DEFINE_BOOL_PREF(name, key, def) gboolean \ -gedit_prefs_manager_get_ ## name (void) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - return gedit_prefs_manager_get_bool (key, \ - (def)); \ -} \ - \ -void \ -gedit_prefs_manager_set_ ## name (gboolean v) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - gedit_prefs_manager_set_bool (key, \ - v); \ -} \ - \ -gboolean \ -gedit_prefs_manager_ ## name ## _can_set (void) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - return gedit_prefs_manager_key_is_writable (key);\ -} - - - -#define DEFINE_INT_PREF(name, key, def) gint \ -gedit_prefs_manager_get_ ## name (void) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - return gedit_prefs_manager_get_int (key, \ - (def)); \ -} \ - \ -void \ -gedit_prefs_manager_set_ ## name (gint v) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - gedit_prefs_manager_set_int (key, \ - v); \ -} \ - \ -gboolean \ -gedit_prefs_manager_ ## name ## _can_set (void) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - return gedit_prefs_manager_key_is_writable (key);\ -} - - - -#define DEFINE_STRING_PREF(name, key, def) gchar* \ -gedit_prefs_manager_get_ ## name (void) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - return gedit_prefs_manager_get_string (key, \ - def); \ -} \ - \ -void \ -gedit_prefs_manager_set_ ## name (const gchar* v) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - gedit_prefs_manager_set_string (key, \ - v); \ -} \ - \ -gboolean \ -gedit_prefs_manager_ ## name ## _can_set (void) \ -{ \ - gedit_debug (DEBUG_PREFS, ""); \ - \ - return gedit_prefs_manager_key_is_writable (key);\ -} - - -typedef struct _GeditPrefsManager GeditPrefsManager; - -struct _GeditPrefsManager { - GConfClient *gconf_client; -}; - -static GeditPrefsManager *gedit_prefs_manager = NULL; - - -static GtkWrapMode get_wrap_mode_from_string (const gchar* str); - -static gboolean gconf_client_get_bool_with_default (GConfClient* client, - const gchar* key, - gboolean def, - GError** err); - -static gchar *gconf_client_get_string_with_default (GConfClient* client, - const gchar* key, - const gchar* def, - GError** err); - -static gint gconf_client_get_int_with_default (GConfClient* client, - const gchar* key, - gint def, - GError** err); - -static gboolean gedit_prefs_manager_get_bool (const gchar* key, - gboolean def); - -static gint gedit_prefs_manager_get_int (const gchar* key, - gint def); - -static gchar *gedit_prefs_manager_get_string (const gchar* key, - const gchar* def); - -gboolean gconf_client_set_color (GConfClient* client, - const gchar* key, - GdkColor val, - GError** err); - - -static void gedit_prefs_manager_editor_font_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data); - -static void gedit_prefs_manager_editor_colors_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data); -static void gedit_prefs_manager_tabs_size_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data); -static void gedit_prefs_manager_wrap_mode_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data); -static void gedit_prefs_manager_line_numbers_changed (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data); - -gboolean -gedit_prefs_manager_init (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - if (gedit_prefs_manager == NULL) - { - GConfClient *gconf_client; - - gconf_client = gconf_client_get_default (); - if (gconf_client == NULL) - { - g_warning (_("Cannot initialize preferences manager.")); - return FALSE; - } - - gedit_prefs_manager = g_new0 (GeditPrefsManager, 1); - - gedit_prefs_manager->gconf_client = gconf_client; - - /* TODO: notify, add dirs */ - gconf_client_add_dir (gedit_prefs_manager->gconf_client, - GPM_PREFS_DIR, - GCONF_CLIENT_PRELOAD_RECURSIVE, - NULL); - - gconf_client_notify_add (gedit_prefs_manager->gconf_client, - GPM_FONT_DIR, - gedit_prefs_manager_editor_font_changed, - NULL, NULL, NULL); - - gconf_client_notify_add (gedit_prefs_manager->gconf_client, - GPM_COLORS_DIR, - gedit_prefs_manager_editor_colors_changed, - NULL, NULL, NULL); - - gconf_client_notify_add (gedit_prefs_manager->gconf_client, - GPM_TABS_DIR, - gedit_prefs_manager_tabs_size_changed, - NULL, NULL, NULL); - - gconf_client_notify_add (gedit_prefs_manager->gconf_client, - GPM_WRAP_MODE_DIR, - gedit_prefs_manager_wrap_mode_changed, - NULL, NULL, NULL); - - gconf_client_notify_add (gedit_prefs_manager->gconf_client, - GPM_LINE_NUMBERS_DIR, - gedit_prefs_manager_line_numbers_changed, - NULL, NULL, NULL); - } - - if (gedit_prefs_manager->gconf_client == NULL) - { - g_free (gedit_prefs_manager); - gedit_prefs_manager = NULL; - } - - return gedit_prefs_manager != NULL; - -} - -/* This function must be called before exiting gedit */ -void -gedit_prefs_manager_shutdown () -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gedit_prefs_manager != NULL); - - gnome_config_sync (); - - g_object_unref (gedit_prefs_manager->gconf_client); - gedit_prefs_manager->gconf_client = NULL; -} - -static gboolean -gedit_prefs_manager_get_bool (const gchar* key, gboolean def) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_val_if_fail (gedit_prefs_manager != NULL, def); - g_return_val_if_fail (gedit_prefs_manager->gconf_client != NULL, def); - - return gconf_client_get_bool_with_default (gedit_prefs_manager->gconf_client, - key, - def, - NULL); -} - -static gint -gedit_prefs_manager_get_int (const gchar* key, gint def) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_val_if_fail (gedit_prefs_manager != NULL, def); - g_return_val_if_fail (gedit_prefs_manager->gconf_client != NULL, def); - - return gconf_client_get_int_with_default (gedit_prefs_manager->gconf_client, - key, - def, - NULL); -} - -static gchar * -gedit_prefs_manager_get_string (const gchar* key, const gchar* def) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_val_if_fail (gedit_prefs_manager != NULL, - def ? g_strdup (def) : NULL); - g_return_val_if_fail (gedit_prefs_manager->gconf_client != NULL, - def ? g_strdup (def) : NULL); - - return gconf_client_get_string_with_default (gedit_prefs_manager->gconf_client, - key, - def, - NULL); -} - -static void -gedit_prefs_manager_set_bool (const gchar* key, gboolean value) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gedit_prefs_manager != NULL); - g_return_if_fail (gedit_prefs_manager->gconf_client != NULL); - g_return_if_fail (gconf_client_key_is_writable ( - gedit_prefs_manager->gconf_client, key, NULL)); - - gconf_client_set_bool (gedit_prefs_manager->gconf_client, key, value, NULL); -} - -static void -gedit_prefs_manager_set_int (const gchar* key, gint value) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gedit_prefs_manager != NULL); - g_return_if_fail (gedit_prefs_manager->gconf_client != NULL); - g_return_if_fail (gconf_client_key_is_writable ( - gedit_prefs_manager->gconf_client, key, NULL)); - - gconf_client_set_int (gedit_prefs_manager->gconf_client, key, value, NULL); -} - -static void -gedit_prefs_manager_set_string (const gchar* key, const gchar* value) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (value != NULL); - - g_return_if_fail (gedit_prefs_manager != NULL); - g_return_if_fail (gedit_prefs_manager->gconf_client != NULL); - g_return_if_fail (gconf_client_key_is_writable ( - gedit_prefs_manager->gconf_client, key, NULL)); - - gconf_client_set_string (gedit_prefs_manager->gconf_client, key, value, NULL); -} - -static gboolean -gedit_prefs_manager_key_is_writable (const gchar* key) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_val_if_fail (gedit_prefs_manager != NULL, FALSE); - g_return_val_if_fail (gedit_prefs_manager->gconf_client != NULL, FALSE); - - return gconf_client_key_is_writable (gedit_prefs_manager->gconf_client, key, NULL); -} - -static gchar* -gdk_color_to_string (GdkColor color) -{ - gedit_debug (DEBUG_PREFS, ""); - - return g_strdup_printf ("#%04x%04x%04x", - color.red, - color.green, - color.blue); -} - -static GdkColor -gconf_client_get_color_with_default (GConfClient* client, const gchar* key, - const gchar* def, GError** err) -{ - gchar *str_color = NULL; - GdkColor color; - - gedit_debug (DEBUG_PREFS, ""); - - g_return_val_if_fail (client != NULL, color); - g_return_val_if_fail (GCONF_IS_CLIENT (client), color); - g_return_val_if_fail (key != NULL, color); - g_return_val_if_fail (def != NULL, color); - - str_color = gconf_client_get_string_with_default (client, - key, - def, - NULL); - - g_return_val_if_fail (str_color != NULL, color); - - gdk_color_parse (str_color, &color); - g_free (str_color); - - return color; -} - -gboolean -gconf_client_set_color (GConfClient* client, const gchar* key, - GdkColor val, GError** err) -{ - gchar *str_color = NULL; - gboolean res; - - gedit_debug (DEBUG_PREFS, ""); - - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (GCONF_IS_CLIENT (client), FALSE); - g_return_val_if_fail (key != NULL, FALSE); - - str_color = gdk_color_to_string (val); - g_return_val_if_fail (str_color != NULL, FALSE); - - res = gconf_client_set_string (client, - key, - str_color, - err); - g_free (str_color); - - return res; -} - -static GdkColor -gedit_prefs_manager_get_color (const gchar* key, const gchar* def) -{ - GdkColor color; - - gedit_debug (DEBUG_PREFS, ""); - - if (def != NULL) - gdk_color_parse (def, &color); - - g_return_val_if_fail (gedit_prefs_manager != NULL, color); - g_return_val_if_fail (gedit_prefs_manager->gconf_client != NULL, color); - - return gconf_client_get_color_with_default (gedit_prefs_manager->gconf_client, - key, - def, - NULL); -} - -static void -gedit_prefs_manager_set_color (const gchar* key, GdkColor value) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (gedit_prefs_manager != NULL); - g_return_if_fail (gedit_prefs_manager->gconf_client != NULL); - g_return_if_fail (gconf_client_key_is_writable ( - gedit_prefs_manager->gconf_client, key, NULL)); - - gconf_client_set_color (gedit_prefs_manager->gconf_client, key, value, NULL); -} - - -/* Use default font */ -DEFINE_BOOL_PREF (use_default_font, - GPM_USE_DEFAULT_FONT, - GPM_DEFAULT_USE_DEFAULT_FONT) - -/* Editor font */ -DEFINE_STRING_PREF (editor_font, - GPM_EDITOR_FONT, - GPM_DEFAULT_EDITOR_FONT); - - -/* Use default colors */ -DEFINE_BOOL_PREF (use_default_colors, - GPM_USE_DEFAULT_COLORS, - GPM_DEFAULT_USE_DEFAULT_COLORS); - - -/* Background color */ -GdkColor -gedit_prefs_manager_get_background_color (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_get_color (GPM_BACKGROUND_COLOR, - GPM_DEFAULT_BACKGROUND_COLOR); -} - -void -gedit_prefs_manager_set_background_color (GdkColor color) -{ - gedit_debug (DEBUG_PREFS, ""); - - gedit_prefs_manager_set_color (GPM_BACKGROUND_COLOR, - color); -} - -gboolean -gedit_prefs_manager_background_color_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_BACKGROUND_COLOR); -} - -/* Text color */ -GdkColor -gedit_prefs_manager_get_text_color (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_get_color (GPM_TEXT_COLOR, - GPM_DEFAULT_TEXT_COLOR); -} - -void -gedit_prefs_manager_set_text_color (GdkColor color) -{ - gedit_debug (DEBUG_PREFS, ""); - - gedit_prefs_manager_set_color (GPM_TEXT_COLOR, - color); -} - -gboolean -gedit_prefs_manager_text_color_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_TEXT_COLOR); -} - -/* Selected text color */ -GdkColor -gedit_prefs_manager_get_selected_text_color (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_get_color (GPM_SELECTED_TEXT_COLOR, - GPM_DEFAULT_SELECTED_TEXT_COLOR); -} - -void -gedit_prefs_manager_set_selected_text_color (GdkColor color) -{ - gedit_debug (DEBUG_PREFS, ""); - - gedit_prefs_manager_set_color (GPM_SELECTED_TEXT_COLOR, - color); -} - -gboolean -gedit_prefs_manager_selected_text_color_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_SELECTED_TEXT_COLOR); -} - -/* Selection color */ -GdkColor -gedit_prefs_manager_get_selection_color (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_get_color (GPM_SELECTION_COLOR, - GPM_DEFAULT_SELECTION_COLOR); -} - -void -gedit_prefs_manager_set_selection_color (GdkColor color) -{ - gedit_debug (DEBUG_PREFS, ""); - - gedit_prefs_manager_set_color (GPM_SELECTION_COLOR, - color); -} - -gboolean -gedit_prefs_manager_selection_color_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_SELECTION_COLOR); -} - - -/* Create backup copy */ -DEFINE_BOOL_PREF (create_backup_copy, - GPM_CREATE_BACKUP_COPY, - GPM_DEFAULT_CREATE_BACKUP_COPY); - -/* Backup extension. This is configurable only using gconftool or gconf-editor */ -gchar* \ -gedit_prefs_manager_get_backup_extension (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_get_string (GPM_BACKUP_COPY_EXTENSION, - GPM_DEFAULT_BACKUP_COPY_EXTENSION); -} - -/* Auto save */ -DEFINE_BOOL_PREF (auto_save, - GPM_AUTO_SAVE, - GPM_DEFAULT_AUTO_SAVE); - -/* Auto save interval */ -DEFINE_INT_PREF (auto_save_interval, - GPM_AUTO_SAVE_INTERVAL, - GPM_DEFAULT_AUTO_SAVE_INTERVAL); - - -/* Save encoding */ -GeditSaveEncodingSetting -gedit_prefs_manager_get_save_encoding (void) -{ - gchar *str; - GeditSaveEncodingSetting res; - - gedit_debug (DEBUG_PREFS, ""); - - str = gedit_prefs_manager_get_string (GPM_SAVE_ENCODING, - GPM_DEFAULT_SAVE_ENCODING); - - if (strcmp (str, "GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE") == 0) - res = GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE; - else - { - if (strcmp (str, "GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE") == 0) - res = GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE; - else - { - if (strcmp (str, "GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL") == 0) - res = GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL; - else - res = GEDIT_SAVE_ALWAYS_UTF8; - } - } - - g_free (str); - - return res; -} - - -void -gedit_prefs_manager_set_save_encoding (GeditSaveEncodingSetting se) -{ - const gchar * str; - - gedit_debug (DEBUG_PREFS, ""); - - switch (se) - { - case GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE: - str = "GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE"; - break; - - case GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE: - str = "GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE"; - break; - - case GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL: - str = "GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL"; - break; - - default: /* GEDIT_SAVE_ALWAYS_UTF8 */ - str = "GEDIT_SAVE_ALWAYS_UTF8"; - } - - gedit_prefs_manager_set_string (GPM_SAVE_ENCODING, - str); -} - -gboolean -gedit_prefs_manager_save_encoding_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_SAVE_ENCODING); -} - -/* Undo actions limit: if < 1 then no limits */ -DEFINE_INT_PREF (undo_actions_limit, - GPM_UNDO_ACTIONS_LIMIT, - GPM_DEFAULT_UNDO_ACTIONS_LIMIT) - -static GtkWrapMode -get_wrap_mode_from_string (const gchar* str) -{ - GtkWrapMode res; - - g_return_val_if_fail (str != NULL, GTK_WRAP_WORD); - - if (strcmp (str, "GTK_WRAP_NONE") == 0) - res = GTK_WRAP_NONE; - else - { - if (strcmp (str, "GTK_WRAP_CHAR") == 0) - res = GTK_WRAP_CHAR; - else - res = GTK_WRAP_WORD; - } - - return res; -} - -/* Wrap mode */ -GtkWrapMode -gedit_prefs_manager_get_wrap_mode (void) -{ - gchar *str; - GtkWrapMode res; - - gedit_debug (DEBUG_PREFS, ""); - - str = gedit_prefs_manager_get_string (GPM_WRAP_MODE, - GPM_DEFAULT_WRAP_MODE); - - res = get_wrap_mode_from_string (str); - - g_free (str); - - return res; -} - -void -gedit_prefs_manager_set_wrap_mode (GtkWrapMode wp) -{ - const gchar * str; - - gedit_debug (DEBUG_PREFS, ""); - - switch (wp) - { - case GTK_WRAP_NONE: - str = "GTK_WRAP_NONE"; - break; - - case GTK_WRAP_CHAR: - str = "GTK_WRAP_CHAR"; - break; - - default: /* GTK_WRAP_WORD */ - str = "GTK_WRAP_WORD"; - } - - gedit_prefs_manager_set_string (GPM_WRAP_MODE, - str); -} - - -gboolean -gedit_prefs_manager_wrap_mode_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_WRAP_MODE); -} - - -/* Tabs size */ -DEFINE_INT_PREF (tabs_size, - GPM_TABS_SIZE, - GPM_DEFAULT_TABS_SIZE); - -/* Display line numbers */ -DEFINE_BOOL_PREF (display_line_numbers, - GPM_DISPLAY_LINE_NUMBERS, - GPM_DEFAULT_DISPLAY_LINE_NUMBERS) - -/* Toolbar visibility */ -DEFINE_BOOL_PREF (toolbar_visible, - GPM_TOOLBAR_VISIBLE, - GPM_DEFAULT_TOOLBAR_VISIBLE); - - -/* Toolbar suttons style */ -GeditToolbarSetting -gedit_prefs_manager_get_toolbar_buttons_style (void) -{ - gchar *str; - GeditToolbarSetting res; - - gedit_debug (DEBUG_PREFS, ""); - - str = gedit_prefs_manager_get_string (GPM_TOOLBAR_BUTTONS_STYLE, - GPM_DEFAULT_TOOLBAR_BUTTONS_STYLE); - - if (strcmp (str, "GEDIT_TOOLBAR_ICONS") == 0) - res = GEDIT_TOOLBAR_ICONS; - else - { - if (strcmp (str, "GEDIT_TOOLBAR_ICONS_AND_TEXT") == 0) - res = GEDIT_TOOLBAR_ICONS_AND_TEXT; - else - res = GEDIT_TOOLBAR_SYSTEM; - } - - g_free (str); - - return res; - -} - -void -gedit_prefs_manager_set_toolbar_buttons_style (GeditToolbarSetting tbs) -{ - const gchar * str; - - gedit_debug (DEBUG_PREFS, ""); - - switch (tbs) - { - case GEDIT_TOOLBAR_ICONS: - str = "GEDIT_TOOLBAR_ICONS"; - break; - - case GEDIT_TOOLBAR_ICONS_AND_TEXT: - str = "GEDIT_TOOLBAR_ICONS_AND_TEXT"; - break; - - default: /* GEDIT_TOOLBAR_SYSTEM */ - str = "GEDIT_TOOLBAR_SYSTEM"; - } - - gedit_prefs_manager_set_string (GPM_TOOLBAR_BUTTONS_STYLE, - str); - -} - -gboolean -gedit_prefs_manager_toolbar_buttons_style_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_TOOLBAR_BUTTONS_STYLE); - -} - -/* Statusbar visiblity */ -DEFINE_BOOL_PREF (statusbar_visible, - GPM_STATUSBAR_VISIBLE, - GPM_DEFAULT_STATUSBAR_VISIBLE) - -/* Show cursor position in statusbar */ -DEFINE_BOOL_PREF (statusbar_show_cursor_position, - GPM_STATUSBAR_SHOW_CURSOR_POSITION, - GPM_DEFAULT_STATUSBAR_SHOW_CURSOR_POSITION) - -/* Show overwrite mode in statusbar */ -DEFINE_BOOL_PREF (statusbar_show_overwrite_mode, - GPM_STATUSBAR_SHOW_OVERWRITE_MODE, - GPM_DEFAULT_STATUSBAR_SHOW_OVERWRITE_MODE) - -/* Print header */ -DEFINE_BOOL_PREF (print_header, - GPM_PRINT_HEADER, - GPM_DEFAULT_PRINT_HEADER) - - -/* Print Wrap mode */ -GtkWrapMode -gedit_prefs_manager_get_print_wrap_mode (void) -{ - gchar *str; - GtkWrapMode res; - - gedit_debug (DEBUG_PREFS, ""); - - str = gedit_prefs_manager_get_string (GPM_PRINT_WRAP_MODE, - GPM_DEFAULT_PRINT_WRAP_MODE); - - if (strcmp (str, "GTK_WRAP_NONE") == 0) - res = GTK_WRAP_NONE; - else - { - if (strcmp (str, "GTK_WRAP_WORD") == 0) - res = GTK_WRAP_WORD; - else - res = GTK_WRAP_CHAR; - } - - g_free (str); - - return res; -} - -void -gedit_prefs_manager_set_print_wrap_mode (GtkWrapMode pwp) -{ - const gchar * str; - - gedit_debug (DEBUG_PREFS, ""); - - switch (pwp) - { - case GTK_WRAP_NONE: - str = "GTK_WRAP_NONE"; - break; - - case GTK_WRAP_WORD: - str = "GTK_WRAP_WORD"; - break; - - default: /* GTK_WRAP_CHAR */ - str = "GTK_WRAP_CHAR"; - } - - gedit_prefs_manager_set_string (GPM_PRINT_WRAP_MODE, - str); -} - - -gboolean -gedit_prefs_manager_print_wrap_mode_can_set (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_key_is_writable (GPM_PRINT_WRAP_MODE); -} - -/* Print line numbers */ -DEFINE_INT_PREF (print_line_numbers, - GPM_PRINT_LINE_NUMBERS, - GPM_DEFAULT_PRINT_LINE_NUMBERS) - - -/* Font used to print the body of documents */ -DEFINE_STRING_PREF (print_font_body, - GPM_PRINT_FONT_BODY, - GPM_DEFAULT_PRINT_FONT_BODY); - -/* Font used to print headers */ -DEFINE_STRING_PREF (print_font_header, - GPM_PRINT_FONT_HEADER, - GPM_DEFAULT_PRINT_FONT_HEADER); - -/* Font used to print line numbers */ -DEFINE_STRING_PREF (print_font_numbers, - GPM_PRINT_FONT_NUMBERS, - GPM_DEFAULT_PRINT_FONT_NUMBERS); - - -/* Max number of files in "Recent Files" menu. - * This is configurable only using gconftool or gconf-editor - */ -gint -gedit_prefs_manager_get_max_recents (void) -{ - gedit_debug (DEBUG_PREFS, ""); - - return gedit_prefs_manager_get_int (GPM_MAX_RECENTS, - GPM_DEFAULT_MAX_RECENTS); - -} - - - -static void -gedit_prefs_manager_editor_font_changed (GConfClient *client, - guint cnxn_id, GConfEntry *entry, gpointer user_data) -{ - GList *children; - gchar *font = NULL; - gboolean def = TRUE; - - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_USE_DEFAULT_FONT) == 0) - { - if (entry->value->type == GCONF_VALUE_BOOL) - def = gconf_value_get_bool (entry->value); - else - def = GPM_DEFAULT_USE_DEFAULT_FONT; - - font = NULL; - } - else - if (strcmp (entry->key, GPM_EDITOR_FONT) == 0) - { - if (entry->value->type == GCONF_VALUE_STRING) - font = g_strdup (gconf_value_get_string (entry->value)); - else - font = g_strdup (GPM_DEFAULT_EDITOR_FONT); - - def = gedit_prefs_manager_get_use_default_font (); - } - else - return; - - if ((font == NULL) && !def) - font = gedit_prefs_manager_get_editor_font (); - - children = bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi)); - - while (children != NULL) - { - GList *views = bonobo_mdi_child_get_views (BONOBO_MDI_CHILD (children->data)); - - while (views != NULL) - { - GeditView *v = GEDIT_VIEW (views->data); - - gedit_view_set_font (v, def, font); - views = views->next; - } - - children = children->next; - } - - if (font != NULL) - g_free (font); -} - - -static void -set_colors (gboolean def, GdkColor* backgroud, GdkColor* text, - GdkColor* selection, GdkColor* sel_text) -{ - GList *children; - - children = bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi)); - - while (children != NULL) - { - GList *views = bonobo_mdi_child_get_views (BONOBO_MDI_CHILD (children->data)); - - while (views != NULL) - { - GeditView *v = GEDIT_VIEW (views->data); - - gedit_view_set_colors (v, - def, - backgroud, - text, - selection, - sel_text); - views = views->next; - } - - children = children->next; - } -} - -static void -gedit_prefs_manager_editor_colors_changed (GConfClient *client, - guint cnxn_id, GConfEntry *entry, gpointer user_data) -{ - gboolean def = TRUE; - gchar *str_color; - GdkColor color; - - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_USE_DEFAULT_COLORS) == 0) - { - if (entry->value->type == GCONF_VALUE_BOOL) - def = gconf_value_get_bool (entry->value); - else - def = GPM_DEFAULT_USE_DEFAULT_COLORS; - - if (def) - set_colors (TRUE, NULL, NULL, NULL, NULL); - else - { - GdkColor background, text, selection, sel_text; - - background = gedit_prefs_manager_get_background_color (); - text = gedit_prefs_manager_get_text_color (); - selection = gedit_prefs_manager_get_selection_color (); - sel_text = gedit_prefs_manager_get_selected_text_color (); - - set_colors (FALSE, - &background, - &text, - &selection, - &sel_text); - } - - return; - } - - if (strcmp (entry->key, GPM_BACKGROUND_COLOR) == 0) - { - if (entry->value->type == GCONF_VALUE_STRING) - str_color = g_strdup (gconf_value_get_string (entry->value)); - else - str_color = g_strdup (GPM_DEFAULT_BACKGROUND_COLOR); - - def = gedit_prefs_manager_get_use_default_colors (); - - gdk_color_parse (str_color, &color); - g_free (str_color); - - set_colors (def, &color, NULL, NULL, NULL); - - return; - } - - if (strcmp (entry->key, GPM_TEXT_COLOR) == 0) - { - if (entry->value->type == GCONF_VALUE_STRING) - str_color = g_strdup (gconf_value_get_string (entry->value)); - else - str_color = g_strdup (GPM_DEFAULT_TEXT_COLOR); - - def = gedit_prefs_manager_get_use_default_colors (); - - gdk_color_parse (str_color, &color); - g_free (str_color); - - set_colors (def, NULL, &color, NULL, NULL); - - return; - } - - if (strcmp (entry->key, GPM_SELECTION_COLOR) == 0) - { - if (entry->value->type == GCONF_VALUE_STRING) - str_color = g_strdup (gconf_value_get_string (entry->value)); - else - str_color = g_strdup (GPM_DEFAULT_SELECTION_COLOR); - - def = gedit_prefs_manager_get_use_default_colors (); - - gdk_color_parse (str_color, &color); - g_free (str_color); - - set_colors (def, NULL, NULL, &color, NULL); - - return; - } - - if (strcmp (entry->key, GPM_SELECTED_TEXT_COLOR) == 0) - { - if (entry->value->type == GCONF_VALUE_STRING) - str_color = g_strdup (gconf_value_get_string (entry->value)); - else - str_color = g_strdup (GPM_DEFAULT_SELECTED_TEXT_COLOR); - - def = gedit_prefs_manager_get_use_default_colors (); - - gdk_color_parse (str_color, &color); - g_free (str_color); - - set_colors (def, NULL, NULL, NULL, &color); - - return; - } -} - -static void -gedit_prefs_manager_tabs_size_changed (GConfClient *client, - guint cnxn_id, GConfEntry *entry, gpointer user_data) -{ - - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_TABS_SIZE) == 0) - { - gint tabs_size; - GList *children; - - if (entry->value->type == GCONF_VALUE_INT) - tabs_size = gconf_value_get_int (entry->value); - else - tabs_size = GPM_DEFAULT_TABS_SIZE; - - tabs_size = CLAMP (tabs_size, 1, 24); - - children = bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi)); - - while (children != NULL) - { - GList *views = bonobo_mdi_child_get_views (BONOBO_MDI_CHILD (children->data)); - - while (views != NULL) - { - GeditView *v = GEDIT_VIEW (views->data); - - gedit_view_set_tab_size (v, tabs_size); - - views = views->next; - } - - children = children->next; - } - } -} - -static void -gedit_prefs_manager_wrap_mode_changed (GConfClient *client, - guint cnxn_id, GConfEntry *entry, gpointer user_data) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_WRAP_MODE) == 0) - { - GtkWrapMode wrap_mode; - - GList *children; - - if (entry->value->type == GCONF_VALUE_STRING) - wrap_mode = - get_wrap_mode_from_string (gconf_value_get_string (entry->value)); - else - wrap_mode = get_wrap_mode_from_string (GPM_DEFAULT_WRAP_MODE); - - children = bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi)); - - while (children != NULL) - { - GList *views = bonobo_mdi_child_get_views (BONOBO_MDI_CHILD (children->data)); - - while (views != NULL) - { - GeditView *v = GEDIT_VIEW (views->data); - - gedit_view_set_wrap_mode (v, wrap_mode); - - views = views->next; - } - - children = children->next; - } - } - -} - -static void -gedit_prefs_manager_line_numbers_changed (GConfClient *client, - guint cnxn_id, GConfEntry *entry, gpointer user_data) -{ - gedit_debug (DEBUG_PREFS, ""); - - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_DISPLAY_LINE_NUMBERS) == 0) - { - gboolean dln; - - GList *children; - - if (entry->value->type == GCONF_VALUE_BOOL) - dln = gconf_value_get_bool (entry->value); - else - dln = GPM_DEFAULT_DISPLAY_LINE_NUMBERS; - - children = bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi)); - - while (children != NULL) - { - GList *views = bonobo_mdi_child_get_views (BONOBO_MDI_CHILD (children->data)); - - while (views != NULL) - { - GeditView *v = GEDIT_VIEW (views->data); - - gedit_view_show_line_numbers (v, dln); - - views = views->next; - } - - children = children->next; - } - } -} - -static gint window_state = -1; -static gint window_height = -1; -static gint window_width = -1; - -/* Window state */ -gint gedit_prefs_manager_get_window_state (void) -{ - if (window_state == -1) - window_state = gnome_config_get_int (GPM_WINDOW_STATE "=" GPM_DEFAULT_WINDOW_STATE_STR); - - return window_state; -} - -void -gedit_prefs_manager_set_window_state (gint ws) -{ - g_return_if_fail (ws != -1); - - window_state = ws; - gnome_config_set_int (GPM_WINDOW_STATE, ws); -} - -gboolean -gedit_prefs_manager_window_state_can_set (void) -{ - return TRUE; -} - -/* Window height */ -gint -gedit_prefs_manager_get_window_height (void) -{ - if (window_height == -1) - window_height = gnome_config_get_int (GPM_WINDOW_HEIGHT "=" GPM_DEFAULT_WINDOW_HEIGHT_STR); - - return window_height; -} - - -gint -gedit_prefs_manager_get_default_window_height (void) -{ - return GPM_DEFAULT_WINDOW_HEIGHT; -} - -void gedit_prefs_manager_set_window_height (gint wh) -{ - g_return_if_fail (wh != -1); - - window_height = wh; - gnome_config_set_int (GPM_WINDOW_HEIGHT, wh); -} - -gboolean -gedit_prefs_manager_window_height_can_set (void) -{ - return TRUE; -} - -/* Window width */ -gint -gedit_prefs_manager_get_window_width (void) -{ - if (window_width == -1) - window_width = gnome_config_get_int (GPM_WINDOW_WIDTH "=" GPM_DEFAULT_WINDOW_WIDTH_STR); - - return window_width; -} - -gint -gedit_prefs_manager_get_default_window_width (void) -{ - return GPM_DEFAULT_WINDOW_WIDTH; -} - -void -gedit_prefs_manager_set_window_width (gint ww) -{ - g_return_if_fail (ww != -1); - - window_width = ww; - gnome_config_set_int (GPM_WINDOW_WIDTH, ww); -} - -gboolean -gedit_prefs_manager_window_width_can_set (void) -{ - return TRUE; -} - - -/* The following functions are taken from gconf-client.c - * and partially modified. - * The licensing terms on these is: - * - * - * GConf - * Copyright (C) 1999, 2000, 2000 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -static const gchar* -gconf_value_type_to_string(GConfValueType type) -{ - switch (type) - { - case GCONF_VALUE_INT: - return "int"; - break; - case GCONF_VALUE_STRING: - return "string"; - break; - case GCONF_VALUE_FLOAT: - return "float"; - break; - case GCONF_VALUE_BOOL: - return "bool"; - break; - case GCONF_VALUE_SCHEMA: - return "schema"; - break; - case GCONF_VALUE_LIST: - return "list"; - break; - case GCONF_VALUE_PAIR: - return "pair"; - break; - case GCONF_VALUE_INVALID: - return "*invalid*"; - break; - default: - g_assert_not_reached(); - return NULL; /* for warnings */ - break; - } -} - -/* Emit the proper signals for the error, and fill in err */ -static gboolean -handle_error (GConfClient* client, GError* error, GError** err) -{ - if (error != NULL) - { - gconf_client_error(client, error); - - if (err == NULL) - { - gconf_client_unreturned_error(client, error); - - g_error_free(error); - } - else - *err = error; - - return TRUE; - } - else - return FALSE; -} - -static gboolean -check_type(const gchar* key, GConfValue* val, GConfValueType t, GError** err) -{ - if (val->type != t) - { - /* - gconf_set_error(err, GCONF_ERROR_TYPE_MISMATCH, - _("Expected `%s' got `%s' for key %s"), - gconf_value_type_to_string(t), - gconf_value_type_to_string(val->type), - key); - */ - g_set_error (err, GCONF_ERROR, GCONF_ERROR_TYPE_MISMATCH, - _("Expected `%s' got `%s' for key %s"), - gconf_value_type_to_string(t), - gconf_value_type_to_string(val->type), - key); - - return FALSE; - } - else - return TRUE; -} - -static gboolean -gconf_client_get_bool_with_default (GConfClient* client, const gchar* key, - gboolean def, GError** err) -{ - GError* error = NULL; - GConfValue* val; - - g_return_val_if_fail (err == NULL || *err == NULL, FALSE); - - val = gconf_client_get (client, key, &error); - - if (val != NULL) - { - gboolean retval = def; - - g_assert (error == NULL); - - if (check_type (key, val, GCONF_VALUE_BOOL, &error)) - retval = gconf_value_get_bool (val); - else - handle_error (client, error, err); - - gconf_value_free (val); - - return retval; - } - else - { - if (error != NULL) - handle_error (client, error, err); - return def; - } -} - -static gchar* -gconf_client_get_string_with_default (GConfClient* client, const gchar* key, - const gchar* def, GError** err) -{ - GError* error = NULL; - gchar* val; - - g_return_val_if_fail (err == NULL || *err == NULL, NULL); - - val = gconf_client_get_string (client, key, &error); - - if (val != NULL) - { - g_assert(error == NULL); - - return val; - } - else - { - if (error != NULL) - *err = error; - return def ? g_strdup (def) : NULL; - } -} - -static gint -gconf_client_get_int_with_default (GConfClient* client, const gchar* key, - gint def, GError** err) -{ - GError* error = NULL; - GConfValue* val; - - g_return_val_if_fail (err == NULL || *err == NULL, 0); - - val = gconf_client_get (client, key, &error); - - if (val != NULL) - { - gint retval = def; - - g_assert(error == NULL); - - if (check_type (key, val, GCONF_VALUE_INT, &error)) - retval = gconf_value_get_int(val); - else - handle_error (client, error, err); - - gconf_value_free (val); - - return retval; - } - else - { - if (error != NULL) - handle_error (client, error, err); - return def; - } -} - - - diff --git a/gedit/gedit-prefs-manager.h b/gedit/gedit-prefs-manager.h deleted file mode 100644 index d75f86530..000000000 --- a/gedit/gedit-prefs-manager.h +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-prefs-manager.h - * This file is part of gedit - * - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_PREFS_MANAGER_H__ -#define __GEDIT_PREFS_MANAGER_H__ - -#include <gdk/gdkcolor.h> -#include <gtk/gtkenums.h> - -#define GEDIT_BASE_KEY "/apps/gedit-2" - -typedef enum { - GEDIT_TOOLBAR_SYSTEM = 0, - GEDIT_TOOLBAR_ICONS, - GEDIT_TOOLBAR_ICONS_AND_TEXT -} GeditToolbarSetting; - -typedef enum { - GEDIT_SAVE_ALWAYS_UTF8 = 0, - GEDIT_SAVE_CURRENT_LOCALE_IF_POSSIBLE, - GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE, - GEDIT_SAVE_ORIGINAL_FILE_ENCODING_IF_POSSIBLE_NCL -} GeditSaveEncodingSetting; - -/** LIFE CYCLE MANAGEMENT FUNCTIONS **/ - -gboolean gedit_prefs_manager_init (void); - -/* This function must be called before exiting gedit */ -void gedit_prefs_manager_shutdown (void); - - -/** PREFS MANAGEMENT FUNCTIONS **/ - -/* Use default font */ -gboolean gedit_prefs_manager_get_use_default_font (void); -void gedit_prefs_manager_set_use_default_font (gboolean udf); -gboolean gedit_prefs_manager_use_default_font_can_set (void); - -/* Editor font */ -gchar *gedit_prefs_manager_get_editor_font (void); -void gedit_prefs_manager_set_editor_font (const gchar *font); -gboolean gedit_prefs_manager_editor_font_can_set (void); - -/* Use default colors */ -gboolean gedit_prefs_manager_get_use_default_colors (void); -void gedit_prefs_manager_set_use_default_colors (gboolean udc); -gboolean gedit_prefs_manager_use_default_colors_can_set (void); - -/* Background color */ -GdkColor gedit_prefs_manager_get_background_color (void); -void gedit_prefs_manager_set_background_color (GdkColor color); -gboolean gedit_prefs_manager_background_color_can_set (void); - -/* Text color */ -GdkColor gedit_prefs_manager_get_text_color (void); -void gedit_prefs_manager_set_text_color (GdkColor color); -gboolean gedit_prefs_manager_text_color_can_set (void); - -/* Selection color */ -GdkColor gedit_prefs_manager_get_selection_color (void); -void gedit_prefs_manager_set_selection_color (GdkColor color); -gboolean gedit_prefs_manager_selection_color_can_set (void); - -/* Selected text color */ -GdkColor gedit_prefs_manager_get_selected_text_color (void); -void gedit_prefs_manager_set_selected_text_color (GdkColor color); -gboolean gedit_prefs_manager_selected_text_color_can_set(void); - -/* Create backup copy */ -gboolean gedit_prefs_manager_get_create_backup_copy (void); -void gedit_prefs_manager_set_create_backup_copy (gboolean cbc); -gboolean gedit_prefs_manager_create_backup_copy_can_set (void); - -/* Backup extension. This is configurable only using gconftool or gconf-editor */ -gchar *gedit_prefs_manager_get_backup_extension (void); - -/* Auto save */ -gboolean gedit_prefs_manager_get_auto_save (void); -void gedit_prefs_manager_set_auto_save (gboolean as); -gboolean gedit_prefs_manager_auto_save_can_set (void); - -/* Auto save interval */ -gint gedit_prefs_manager_get_auto_save_interval (void); -void gedit_prefs_manager_set_auto_save_interval (gint asi); -gboolean gedit_prefs_manager_auto_save_interval_can_set (void); - -/* Save encoding */ -GeditSaveEncodingSetting gedit_prefs_manager_get_save_encoding (void); -void gedit_prefs_manager_set_save_encoding (GeditSaveEncodingSetting se); -gboolean gedit_prefs_manager_save_encoding_can_set (void); - -/* Undo actions limit: if < 1 then no limits */ -gint gedit_prefs_manager_get_undo_actions_limit (void); -void gedit_prefs_manager_set_undo_actions_limit (gint ual); -gboolean gedit_prefs_manager_undo_actions_limit_can_set (void); - -/* Wrap mode */ -GtkWrapMode gedit_prefs_manager_get_wrap_mode (void); -void gedit_prefs_manager_set_wrap_mode (GtkWrapMode wp); -gboolean gedit_prefs_manager_wrap_mode_can_set (void); - -/* Tabs size */ -gint gedit_prefs_manager_get_tabs_size (void); -void gedit_prefs_manager_set_tabs_size (gint ts); -gboolean gedit_prefs_manager_tabs_size_can_set (void); - -/* Display line numbers */ -gboolean gedit_prefs_manager_get_display_line_numbers (void); -void gedit_prefs_manager_set_display_line_numbers (gboolean dln); -gboolean gedit_prefs_manager_display_line_numbers_can_set (void); - -/* Toolbar visible */ -gboolean gedit_prefs_manager_get_toolbar_visible (void); -void gedit_prefs_manager_set_toolbar_visible (gboolean tv); -gboolean gedit_prefs_manager_toolbar_visible_can_set (void); - -/* Toolbar buttons style */ -GeditToolbarSetting gedit_prefs_manager_get_toolbar_buttons_style (void); -void gedit_prefs_manager_set_toolbar_buttons_style (GeditToolbarSetting tbs); -gboolean gedit_prefs_manager_toolbar_buttons_style_can_set (void); - -/* Statusbar visible */ -gboolean gedit_prefs_manager_get_statusbar_visible (void); -void gedit_prefs_manager_set_statusbar_visible (gboolean sv); -gboolean gedit_prefs_manager_statusbar_visible_can_set (void); - -/* Show cursor position in statusbar */ -gboolean gedit_prefs_manager_get_statusbar_show_cursor_position (void); -void gedit_prefs_manager_set_statusbar_show_cursor_position (gboolean scp); -gboolean gedit_prefs_manager_statusbar_show_cursor_position_can_set (void); - -/* Show overwrite mode in statusbar */ -gboolean gedit_prefs_manager_get_statusbar_show_overwrite_mode (void); -void gedit_prefs_manager_set_statusbar_show_overwrite_mode (gboolean som); -gboolean gedit_prefs_manager_statusbar_show_overwrite_mode_can_set (void); - -/* Print header */ -gboolean gedit_prefs_manager_get_print_header (void); -void gedit_prefs_manager_set_print_header (gboolean ph); -gboolean gedit_prefs_manager_print_header_can_set (void); - -/* Wrap mode while printing */ -GtkWrapMode gedit_prefs_manager_get_print_wrap_mode (void); -void gedit_prefs_manager_set_print_wrap_mode (GtkWrapMode pwm); -gboolean gedit_prefs_manager_print_wrap_mode_can_set (void); - -/* Print line numbers */ -gint gedit_prefs_manager_get_print_line_numbers (void); -void gedit_prefs_manager_set_print_line_numbers (gint pln); -gboolean gedit_prefs_manager_print_line_numbers_can_set (void); - -/* Font used to print the body of documents */ -gchar *gedit_prefs_manager_get_print_font_body (void); -void gedit_prefs_manager_set_print_font_body (const gchar *font); -gboolean gedit_prefs_manager_print_font_body_can_set (void); - -/* Font used to print headers */ -gchar *gedit_prefs_manager_get_print_font_header (void); -void gedit_prefs_manager_set_print_font_header (const gchar *font); -gboolean gedit_prefs_manager_print_font_header_can_set (void); - -/* Font used to print line numbers */ -gchar *gedit_prefs_manager_get_print_font_numbers (void); -void gedit_prefs_manager_set_print_font_numbers (const gchar *font); -gboolean gedit_prefs_manager_print_font_numbers_can_set (void); - -/* Max number of files in "Recent Files" menu. - * This is configurable only using gconftool or gconf-editor - */ -gint gedit_prefs_manager_get_max_recents (void); - -/* Window state */ -gint gedit_prefs_manager_get_window_state (void); -void gedit_prefs_manager_set_window_state (gint ws); -gboolean gedit_prefs_manager_window_state_can_set (void); - -/* Window height */ -gint gedit_prefs_manager_get_window_height (void); -gint gedit_prefs_manager_get_default_window_height (void); -void gedit_prefs_manager_set_window_height (gint wh); -gboolean gedit_prefs_manager_window_height_can_set (void); - -/* Window width */ -gint gedit_prefs_manager_get_window_width (void); -gint gedit_prefs_manager_get_default_window_width (void); -void gedit_prefs_manager_set_window_width (gint ww); -gboolean gedit_prefs_manager_window_width_can_set (void); - - -#endif /* __GEDIT_PREFS_MANAGER_H__ */ - - diff --git a/gedit/gedit-print.c b/gedit/gedit-print.c deleted file mode 100644 index 5b1109429..000000000 --- a/gedit/gedit-print.c +++ /dev/null @@ -1,925 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-print.c - * This file is part of gedit - * - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * Copyright (C) 2002 Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/libgnome.h> -#include <libgnomeprint/gnome-print.h> -#include <libgnomeprint/gnome-print-master.h> -#include <libgnomeprintui/gnome-print-dialog.h> -#include <libgnomeprintui/gnome-print-master-preview.h> -#include <eel/eel-string.h> - -#include <string.h> /* For strlen */ - -#include "gedit2.h" -#include "gedit-print.h" -#include "gedit-debug.h" -#include "gedit-document.h" -#include "gedit-prefs-manager.h" - -#define CM(v) ((v) * 72.0 / 2.54) -#define A4_WIDTH (210.0 * 72 / 25.4) -#define A4_HEIGHT (297.0 * 72 / 25.4) - - -static GnomePrintConfig *gedit_print_config = NULL; - -typedef struct _GeditPrintJobInfo GeditPrintJobInfo; - -struct _GeditPrintJobInfo { - - GeditDocument *doc; - - gboolean preview; - - GnomePrintConfig *config; - gint range_type; - - GnomePrintMaster *print_master; - GnomePrintContext *print_ctx; - - gint page_num; - /* Page stuff*/ - gdouble page_width; - gdouble page_height; - gdouble margin_top; - gdouble margin_left; - gdouble margin_right; - gdouble margin_bottom; - gdouble header_height; - gdouble numbers_width; - - /* Fonts */ - GnomeFont *font_body; - GnomeFont *font_header; - GnomeFont *font_numbers; - - gint first_line_to_print; - gint printed_lines; - - gint print_line_numbers; - gboolean print_header; - gint tabs_size; - GtkWrapMode print_wrap_mode; -}; - - -/* FIXME: remove when libgnomeprint well define it -- Paolo */ -GnomeGlyphList *gnome_glyphlist_unref (GnomeGlyphList *gl); - -static GQuark gedit_print_error_quark (void); -#define GEDIT_PRINT_ERROR gedit_print_error_quark () - -static GeditPrintJobInfo* gedit_print_job_info_new (GeditDocument* doc, GError **error); -static void gedit_print_job_info_destroy (GeditPrintJobInfo *pji); - -static void gedit_print_preview_real (GeditPrintJobInfo *pji); -static void gedit_print_real (GeditDocument* doc, gboolean preview, GError **error); -static gboolean gedit_print_run_dialog (GeditPrintJobInfo *pji); - -static void gedit_print_error_dialog (GError *error); - -static const gchar* gedit_print_get_next_line_to_print_delimiter (GeditPrintJobInfo *pji, - const gchar *start, const gchar *end, gboolean first_line_of_par); - -static void gedit_print_line (GeditPrintJobInfo *pji, const gchar *start, - const gchar *end, gdouble y, gboolean first_line_of_par); -static gdouble gedit_print_paragraph (GeditPrintJobInfo *pji, const gchar *start, - const gchar *end, gdouble y); -static void gedit_print_line_number (GeditPrintJobInfo *pji, gdouble y); -static gdouble gedit_print_create_new_page (GeditPrintJobInfo *pji); -static void gedit_print_end_page (GeditPrintJobInfo *pji); - - - -GQuark -gedit_print_error_quark () -{ - static GQuark quark; - if (!quark) - quark = g_quark_from_static_string ("gedit_print_error"); - - return quark; -} - - -static GeditPrintJobInfo* -gedit_print_job_info_new (GeditDocument* doc, GError **error) -{ - GeditPrintJobInfo *pji; - - gchar *print_font_body; - gchar *print_font_header; - gchar *print_font_numbers; - - gedit_debug (DEBUG_PRINT, ""); - - g_return_val_if_fail (doc != NULL, NULL); - - if (gedit_print_config == NULL) - { - gedit_print_config = gnome_print_config_default (); - g_return_val_if_fail (gedit_print_config != NULL, NULL); - - gnome_print_config_set (gedit_print_config, "Settings.Transport.Backend", "lpr"); - gnome_print_config_set (gedit_print_config, "Printer", "GENERIC"); - } - - pji = g_new0 (GeditPrintJobInfo, 1); - - pji->doc = doc; - pji->preview = FALSE; - pji->range_type = GNOME_PRINT_RANGE_ALL; - - pji->page_num = 0; - - pji->page_width = A4_WIDTH; - pji->page_height = A4_HEIGHT; - pji->margin_top = CM (1); - pji->margin_left = CM (1); - pji->margin_right = CM (1); - pji->margin_bottom = CM (1); - pji->header_height = CM (0); - - print_font_body = gedit_prefs_manager_get_print_font_body (); - print_font_header = gedit_prefs_manager_get_print_font_header (); - print_font_numbers = gedit_prefs_manager_get_print_font_numbers (); - - pji->font_body = gnome_font_find_closest_from_full_name (print_font_body); - pji->font_header = gnome_font_find_closest_from_full_name (print_font_header); - pji->font_numbers = gnome_font_find_closest_from_full_name (print_font_numbers); - - g_free (print_font_body); - g_free (print_font_header); - g_free (print_font_numbers); - - if ((pji->font_body == NULL) || - (pji->font_header == NULL) || - (pji->font_numbers == NULL)) - { - g_set_error (error, GEDIT_PRINT_ERROR, 1, - _("gedit is unable to print since it cannot find\n" - "one of the required fonts.")); - - gedit_print_job_info_destroy (pji); - - return NULL; - } - - if (gedit_prefs_manager_get_print_header ()) - pji->header_height = 2.5 * gnome_font_get_size (pji->font_header); - else - pji->header_height = 0; - - pji->numbers_width = CM(0); - - pji->first_line_to_print = 1; - pji->printed_lines = 0; - - pji->print_line_numbers = gedit_prefs_manager_get_print_line_numbers (); - pji->print_header = gedit_prefs_manager_get_print_header (); - pji->tabs_size = gedit_prefs_manager_get_tabs_size (); - pji->print_wrap_mode = gedit_prefs_manager_get_print_wrap_mode (); - - pji->config = gedit_print_config; - gnome_print_config_ref (pji->config); - - return pji; -} - -static void -gedit_print_job_info_destroy (GeditPrintJobInfo *pji) -{ - gedit_debug (DEBUG_PRINT, ""); - - g_return_if_fail (pji != NULL); - - if (pji->config != NULL) - gnome_print_config_unref (pji->config); - - if (pji->print_ctx != NULL) - g_object_unref (pji->print_ctx); - - if (pji->print_master != NULL) - g_object_unref (pji->print_master); - - g_free (pji); -} - -static void -gedit_print_update_page_size_and_margins (GeditPrintJobInfo *pji) -{ - const GnomePrintUnit *unit; - - gedit_debug (DEBUG_PRINT, ""); - - gnome_print_master_get_page_size_from_config (pji->config, - &pji->page_width, &pji->page_height); - - if (gnome_print_config_get_length (pji->config, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, - &pji->margin_left, &unit)) - { - gnome_print_convert_distance (&pji->margin_left, unit, GNOME_PRINT_PS_UNIT); - } - - if (gnome_print_config_get_length (pji->config, GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, - &pji->margin_right, &unit)) - { - gnome_print_convert_distance (&pji->margin_right, unit, GNOME_PRINT_PS_UNIT); - } - - if (gnome_print_config_get_length (pji->config, GNOME_PRINT_KEY_PAGE_MARGIN_TOP, - &pji->margin_top, &unit)) - { - gnome_print_convert_distance (&pji->margin_top, unit, GNOME_PRINT_PS_UNIT); - } - if (gnome_print_config_get_length (pji->config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, - &pji->margin_bottom, &unit)) - { - gnome_print_convert_distance (&pji->margin_bottom, unit, GNOME_PRINT_PS_UNIT); - } - - if (pji->print_line_numbers > 0) - { - gchar* num_str; - - num_str = g_strdup_printf ("%d", gedit_document_get_line_count (pji->doc)); - pji->numbers_width = gnome_font_get_width_utf8 (pji->font_numbers, num_str); - g_free (num_str); - } -} -/** - * gedit_print_run_dialog: - * @pji: - * - * Run the print dialog - * - * Return Value: TRUE if the printing was canceled by the user - **/ -static gboolean -gedit_print_run_dialog (GeditPrintJobInfo *pji) -{ - GtkWidget *dialog; - gint selection_flag; - gint res; - gint lines; - - gedit_debug (DEBUG_PRINT, ""); - - g_return_val_if_fail (pji != NULL, TRUE); - - if (!gedit_document_has_selected_text (pji->doc)) - selection_flag = GNOME_PRINT_RANGE_SELECTION_UNSENSITIVE; - else - selection_flag = GNOME_PRINT_RANGE_SELECTION; - - dialog = g_object_new (GNOME_TYPE_PRINT_DIALOG, "print_config", pji->config, NULL); - - gnome_print_dialog_construct (GNOME_PRINT_DIALOG (dialog), - _("Print"), - GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); - - lines = gedit_document_get_line_count (pji->doc); - - gnome_print_dialog_construct_range_page ( GNOME_PRINT_DIALOG (dialog), - GNOME_PRINT_RANGE_ALL | - /*GNOME_PRINT_RANGE_RANGE |*/ - selection_flag, - 1, lines, "A", _("Lines")); - - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW - (bonobo_mdi_get_active_window - (BONOBO_MDI (gedit_mdi)))); - - res = gtk_dialog_run (GTK_DIALOG (dialog)); - - switch (res) - { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - gedit_debug (DEBUG_PRINT, "Print button pressed."); - break; - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - gedit_debug (DEBUG_PRINT, "Preview button pressed."); - pji->preview = TRUE; - break; - default: - gtk_widget_destroy (dialog); - return TRUE; - } - - pji->range_type = gnome_print_dialog_get_range (GNOME_PRINT_DIALOG (dialog)); - - gtk_widget_destroy (dialog); - - gedit_debug (DEBUG_PRINT, "Print dialog destroyed."); - - return FALSE; -} - -static void -gedit_print_header (GeditPrintJobInfo *pji, gint page_number) -{ - gdouble y, x, len; - gchar* l_text; - gchar* r_text; - gchar* uri; - gchar* uri_to_print; - - gedit_debug (DEBUG_PRINT, ""); - - g_return_if_fail (pji != NULL); - g_return_if_fail (pji->font_header != NULL); - g_return_if_fail (pji->doc != NULL); - - gnome_print_setfont (pji->print_ctx, pji->font_header); - - y = pji->page_height - pji->margin_top - - gnome_font_get_ascender (pji->font_header); - - /* Print left text */ - x = pji->margin_right; - - uri = gedit_document_get_uri (pji->doc); - uri_to_print = eel_str_middle_truncate (uri, 60); - g_free (uri); - - l_text = g_strdup_printf (_("File: %s"), uri_to_print); - g_free (uri_to_print); - - gnome_print_moveto (pji->print_ctx, x, y); - gnome_print_show (pji->print_ctx, l_text); - - /* Print right text */ - r_text = g_strdup_printf (_("Page: %d"), page_number); - len = gnome_font_get_width_utf8 (pji->font_header, r_text); - - x = pji->page_width - pji->margin_right - len; - - gnome_print_moveto (pji->print_ctx, x, y); - gnome_print_show (pji->print_ctx, r_text); - - /* Print line */ - y = pji->page_height - pji->margin_top - - (1.5 * gnome_font_get_size (pji->font_header)); - - gnome_print_setlinewidth (pji->print_ctx, 1.0); - gnome_print_moveto (pji->print_ctx, pji->margin_right, y); - gnome_print_lineto (pji->print_ctx, pji->page_width - pji->margin_right, y); - gnome_print_stroke (pji->print_ctx); - - g_free (l_text); - g_free (r_text); - - gnome_print_setfont (pji->print_ctx, pji->font_body); - -} - -static void -gedit_print_document (GeditPrintJobInfo *pji) -{ - gchar *text_to_print; - gchar *text_end; - const gchar *end; - const gchar *p; - gdouble y; - gint paragraph_delimiter_index; - gint next_paragraph_start; - gdouble fontheight; - gint start; - - gedit_debug (DEBUG_PRINT, ""); - - switch (pji->range_type) - { - case GNOME_PRINT_RANGE_ALL: - text_to_print = gedit_document_get_buffer (pji->doc); - text_end = text_to_print + strlen (text_to_print); - break; - case GNOME_PRINT_RANGE_SELECTION: - text_to_print = gedit_document_get_selected_text (pji->doc, &start, NULL); - text_end = text_to_print + strlen (text_to_print); - - pji->first_line_to_print = - gedit_document_get_line_at_offset (pji->doc, start) + 1; - break; - default: - g_return_if_fail (FALSE); - } - - y = gedit_print_create_new_page (pji); - - gnome_print_setfont (pji->print_ctx, pji->font_body); - - pango_find_paragraph_boundary (text_to_print, -1, - ¶graph_delimiter_index, &next_paragraph_start); - - p = text_to_print; - end = text_to_print + paragraph_delimiter_index; - - fontheight = gnome_font_get_ascender (pji->font_body) + - gnome_font_get_descender (pji->font_body); - - while (p < text_end) - { - gunichar wc = g_utf8_get_char (p); - /* Only one character has type G_UNICODE_PARAGRAPH_SEPARATOR in - * Unicode 3.0; update this if that changes. - */ -#define PARAGRAPH_SEPARATOR 0x2029 - - if ((wc == '\n' || - wc == '\r' || - wc == PARAGRAPH_SEPARATOR)) - { - if (pji->numbers_width > 0.0) - gedit_print_line_number (pji, y); - - y -= 1.2 * gnome_font_get_size (pji->font_body); - - if ((y - pji->margin_bottom) < fontheight) - { - gedit_print_end_page (pji); - - y = gedit_print_create_new_page (pji); - } - } - else - { - y = gedit_print_paragraph (pji, p, end, y); - } - - ++pji->printed_lines; - - p = p + next_paragraph_start; - - if (p < text_end) - { - pango_find_paragraph_boundary (p, -1, - ¶graph_delimiter_index, &next_paragraph_start); - end = p + paragraph_delimiter_index; - } - - } - - gnome_print_showpage (pji->print_ctx); - - g_free (text_to_print); -} - -/** - * gedit_print_preview_real: - * @pji: - * - * Create and show the print preview window - **/ -static void -gedit_print_preview_real (GeditPrintJobInfo *pji) -{ - GtkWidget *gpmp; - gchar *title; - - gedit_debug (DEBUG_PRINT, ""); - - g_return_if_fail (pji != NULL); - g_return_if_fail (pji->print_master != NULL); - - title = g_strdup_printf (_("gedit - Print Preview")); - gpmp = gnome_print_master_preview_new (pji->print_master, title); - g_free (title); - - gtk_widget_show (gpmp); -} - -/** - * gedit_print_real: - * @preview: - * - * The main printing function - **/ -static void -gedit_print_real (GeditDocument* doc, gboolean preview, GError **error) -{ - GeditPrintJobInfo *pji; - gboolean cancel = FALSE; - - gedit_debug (DEBUG_PRINT, ""); - - pji = gedit_print_job_info_new (doc, error); - - if (pji == NULL) - return; - - pji->preview = preview; - - if (!pji->preview) - /* - * Open the print dialog and initialize - * pji->config - */ - cancel = gedit_print_run_dialog (pji); - - /* The canceled button on the dialog was clicked */ - if (cancel) { - gedit_print_job_info_destroy (pji); - return; - } - - g_return_if_fail (pji->config != NULL); - - pji->print_master = gnome_print_master_new_from_config (pji->config); - g_return_if_fail (pji->print_master != NULL); - - pji->print_ctx = gnome_print_master_get_context (pji->print_master); - g_return_if_fail (pji->print_ctx != NULL); - - gedit_print_update_page_size_and_margins (pji); - gedit_print_document (pji); -#if 0 - /* The printing was canceled while in progress */ - if (pji->canceled) { - gedit_print_job_info_destroy (pji); - return; - } -#endif - gnome_print_master_close (pji->print_master); - - if (pji->preview) - gedit_print_preview_real (pji); - else - gnome_print_master_print (pji->print_master); - - gedit_print_job_info_destroy (pji); -} - -static void -gedit_print_error_dialog (GError *error) -{ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new ( - GTK_WINDOW (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi))), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("An error occurred while printing.\n\n%s,"), - error->message); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - gtk_dialog_run (GTK_DIALOG (dialog)); - - gtk_widget_destroy (dialog); -} - - -void -gedit_print (GeditMDIChild* active_child) -{ - GeditDocument *doc; - GError *error = NULL; - - gedit_debug (DEBUG_PRINT, ""); - - g_return_if_fail (active_child != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - gedit_print_real (doc, FALSE, &error); - - if (error) - { - gedit_print_error_dialog (error); - g_error_free (error); - } -} - -void -gedit_print_preview (GeditMDIChild* active_child) -{ - GeditDocument *doc; - GError *error = NULL; - - gedit_debug (DEBUG_PRINT, ""); - - g_return_if_fail (active_child != NULL); - - doc = active_child->document; - g_return_if_fail (doc != NULL); - - gedit_print_real (doc, TRUE, &error); - - if (error) - { - gedit_print_error_dialog (error); - g_error_free (error); - } -} - -static const gchar* -gedit_print_get_next_line_to_print_delimiter (GeditPrintJobInfo *pji, - const gchar *start, const gchar *end, gboolean first_line_of_par) -{ - const gchar* p; - gdouble line_width = 0.0; - gdouble printable_page_width; - ArtPoint space_advance; - gint space; - gint chars_in_this_line = 0; - - gedit_debug (DEBUG_PRINT, ""); - - if (pji->numbers_width > 0.0) - printable_page_width = pji->page_width - - (pji->margin_right + pji->margin_left) - pji->numbers_width - CM(0.5); - else - printable_page_width = pji->page_width - - (pji->margin_right + pji->margin_left); - - p = start; - - /* Find space advance */ - space = gnome_font_lookup_default (pji->font_body, ' '); - gnome_font_get_glyph_stdadvance (pji->font_body, space, &space_advance); - - if (!first_line_of_par) - { - gunichar ch = g_utf8_get_char (p); - - while (ch == ' ' || ch == '\t') - { - p = g_utf8_next_char (p); - ch = g_utf8_get_char (p); - } - } - - while (p < end) - { - gunichar ch; - gint glyph; - - ch = g_utf8_get_char (p); - ++chars_in_this_line; - - if (ch == '\t') - { - /* FIXME: use a tabs array */ - gint num_of_equivalent_spaces; - - num_of_equivalent_spaces = pji->tabs_size - ((chars_in_this_line - 1) % pji->tabs_size); - chars_in_this_line += num_of_equivalent_spaces - 1; - - line_width += (num_of_equivalent_spaces * space_advance.x); - } - else - { - glyph = gnome_font_lookup_default (pji->font_body, ch); - - /* FIXME */ - if (glyph == space) - line_width += space_advance.x; - else - /* - if ((glyph < 0) || (glyph >= 256)) - */ - { - ArtPoint adv; - gnome_font_get_glyph_stdadvance (pji->font_body, glyph, &adv); - if (adv.x > 0) - line_width += adv.x; - else - /* To be as conservative as possible */ - line_width += (2 * space_advance.x); - - } - /* - } - else - line_width += gnome_font_get_glyph_width (pji->font_body, glyph); - */ - } - - if (line_width > printable_page_width) - { - /* FIXME: take care of lines wrapping at word boundaries too */ - return p; - } - - p = g_utf8_next_char (p); - } - - return end; -} - -static void -gedit_print_line_number (GeditPrintJobInfo *pji, gdouble y) -{ - gchar *num_str; - gdouble len; - gdouble x; - - gint line_num = pji->first_line_to_print + pji->printed_lines; - - gedit_debug (DEBUG_PRINT, ""); - - if ((pji->printed_lines + 1) % pji->print_line_numbers != 0) - return; - - num_str = g_strdup_printf ("%d", line_num); - - gnome_print_setfont (pji->print_ctx, pji->font_numbers); - - len = gnome_font_get_width_utf8 (pji->font_numbers, num_str); - - x = pji->margin_left + pji->numbers_width - len; - - gnome_print_moveto (pji->print_ctx, x, y - - gnome_font_get_ascender (pji->font_numbers)); - gnome_print_show (pji->print_ctx, num_str); - - g_free (num_str); - - /* Restore body font */ - gnome_print_setfont (pji->print_ctx, pji->font_body); -} - -static void -gedit_print_line (GeditPrintJobInfo *pji, const gchar *start, const gchar *end, gdouble y, - gboolean first_line_of_par) -{ - GnomeGlyphList * gl; - gdouble x; - const gchar* p; - gint chars_in_this_line = 0; - - gedit_debug (DEBUG_PRINT, ""); - - p = start; - - gl = gnome_glyphlist_from_text_dumb (pji->font_body, 0x000000ff, 0.0, 0.0, ""); - - gnome_glyphlist_advance (gl, TRUE); - - if (pji->numbers_width > 0.0) - { - if (first_line_of_par) - gedit_print_line_number (pji, y); - - x = pji->margin_left + pji->numbers_width + CM(0.5); - } - else - x = pji->margin_left; - - gnome_glyphlist_moveto (gl, x, y - gnome_font_get_ascender (pji->font_body)); - - if (!first_line_of_par) - { - gunichar ch = g_utf8_get_char (p); - - while (ch == ' ' || ch == '\t') - { - p = g_utf8_next_char (p); - ch = g_utf8_get_char (p); - } - } - - while (p < end) - { - gunichar ch; - gint glyph; - - ch = g_utf8_get_char (p); - ++chars_in_this_line; - - if (ch == '\t') - { - /* FIXME: use a tabs array */ - gint i; - gint num_of_equivalent_spaces; - - glyph = gnome_font_lookup_default (pji->font_body, ' '); - - num_of_equivalent_spaces = pji->tabs_size - - ((chars_in_this_line - 1) % pji->tabs_size); - - chars_in_this_line += num_of_equivalent_spaces - 1; - - for (i = 0; i < num_of_equivalent_spaces; ++i) - gnome_glyphlist_glyph (gl, glyph); - - } - else - { - glyph = gnome_font_lookup_default (pji->font_body, ch); - gnome_glyphlist_glyph (gl, glyph); - } - - p = g_utf8_next_char (p); - } - - gnome_print_moveto (pji->print_ctx, 0.0, 0.0); - gnome_print_glyphlist (pji->print_ctx, gl); - gnome_glyphlist_unref (gl); -} - -static gdouble -gedit_print_paragraph (GeditPrintJobInfo *pji, const gchar *start, const gchar *end, gdouble y) -{ - const gchar *p, *s; - gdouble fontheight; - gboolean fl; - - gedit_debug (DEBUG_PRINT, ""); - - p = start; - - fl = TRUE; - - fontheight = gnome_font_get_ascender (pji->font_body) + - gnome_font_get_descender (pji->font_body); - - while (p < end) - { - s = p; - p = gedit_print_get_next_line_to_print_delimiter (pji, s, end, fl); - gedit_print_line (pji, s, p, y, fl); - y -= 1.2 * gnome_font_get_size (pji->font_body); - fl = FALSE; - - if ((y - pji->margin_bottom) < fontheight) - { - gedit_print_end_page (pji); - - y = gedit_print_create_new_page (pji); - } - - /* FIXME: "word wrap" - Paolo */ - if (pji->print_wrap_mode == GTK_WRAP_NONE) - return y; - - } - - return y; -} - -static gdouble -gedit_print_create_new_page (GeditPrintJobInfo *pji) -{ - gchar *pn_str; - - gedit_debug (DEBUG_PRINT, ""); - - ++pji->page_num; - pn_str = g_strdup_printf ("%d", pji->page_num); - gnome_print_beginpage (pji->print_ctx, pn_str); - - g_free (pn_str); - - if (pji->print_header) - { - gedit_print_header (pji, +pji->page_num); - return pji->page_height - pji->margin_top - pji->header_height; - } - else - return pji->page_height - pji->margin_top; -} - -static void -gedit_print_end_page (GeditPrintJobInfo *pji) -{ - gnome_print_showpage (pji->print_ctx); -} - diff --git a/gedit/gedit-print.h b/gedit/gedit-print.h deleted file mode 100644 index c04f3c1ba..000000000 --- a/gedit/gedit-print.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-print.h - * This file is part of gedit - * - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_PRINT_H__ -#define __GEDIT_PRINT_H__ - -#include "gedit-mdi-child.h" - -void gedit_print (GeditMDIChild* active_child); -void gedit_print_preview (GeditMDIChild* active_child); - -#endif /* __GEDIT_PRINT_H__ */ diff --git a/gedit/gedit-recent.c b/gedit/gedit-recent.c deleted file mode 100644 index b7544761c..000000000 --- a/gedit/gedit-recent.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-recent.c - * This file is part of gedit - * - * Copyright (C) 2002 James Willcox - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gedit-recent.h" -#include "gedit-prefs-manager.h" - - -static GnomeRecentModel *model; - - -GnomeRecentModel * -gedit_recent_get_model (void) -{ - return model; -} - -void -gedit_recent_init (void) -{ - model = gnome_recent_model_new ("gedit-2", gedit_prefs_manager_get_max_recents ()); -} diff --git a/gedit/gedit-recent.h b/gedit/gedit-recent.h deleted file mode 100644 index 3b3f0f99a..000000000 --- a/gedit/gedit-recent.h +++ /dev/null @@ -1,12 +0,0 @@ - - -#ifndef __GEDIT_RECENT_H__ -#define __GEDIT_RECENT_H__ - -#include "gnome-recent-model.h" - - -GnomeRecentModel * gedit_recent_get_model (void); -void gedit_recent_init (void); - -#endif diff --git a/gedit/gedit-session.c b/gedit/gedit-session.c deleted file mode 100644 index 982a7dd02..000000000 --- a/gedit/gedit-session.c +++ /dev/null @@ -1,247 +0,0 @@ -/* gedit-session - Basic session management for gedit - * - * Copyright (C) 2002 Ximian, Inc. - * - * Authors Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/gnome-config.h> -#include <libgnomeui/gnome-client.h> -#include "bonobo-mdi-session.h" -#include "gedit2.h" -#include "gedit-mdi-child.h" -#include "gedit-session.h" -#include "gedit-file.h" -#include "gedit-debug.h" -#include "gedit-plugins-engine.h" -#include "gedit-prefs-manager.h" - -/* The master client we use for SM */ -static GnomeClient *master_client = NULL; - -/* argv[0] from main(); used as the command to restart the program */ -static const char *program_argv0 = NULL; - -static void -interaction_function (GnomeClient *client, gint key, GnomeDialogType dialog_type, gpointer shutdown) -{ - const gchar *prefix; - - gedit_debug (DEBUG_SESSION, ""); - - /* Save all unsaved files */ - - if (GPOINTER_TO_INT (shutdown)) - gedit_file_save_all (); - - /* Save session data */ - - prefix = gnome_client_get_config_prefix (client); - - gedit_debug (DEBUG_SESSION, "Prefix: %s", prefix); - - gnome_config_push_prefix (prefix); - - bonobo_mdi_save_state (BONOBO_MDI (gedit_mdi), "Session"); - - gnome_config_pop_prefix (); - gnome_config_sync (); - - gnome_interaction_key_return (key, FALSE); - - gedit_debug (DEBUG_SESSION, "END"); -} - -/* save_yourself handler for the master client */ -static gboolean -client_save_yourself_cb (GnomeClient *client, - gint phase, - GnomeSaveStyle save_style, - gboolean shutdown, - GnomeInteractStyle interact_style, - gboolean fast, - gpointer data) -{ - const gchar *prefix; - - char *argv[] = { "rm", "-r", NULL }; - - gedit_debug (DEBUG_SESSION, ""); - - gnome_client_request_interaction (client, - GNOME_DIALOG_NORMAL, - interaction_function, - GINT_TO_POINTER (shutdown)); - - prefix = gnome_client_get_config_prefix (client); - - gedit_debug (DEBUG_SESSION, "Prefix: %s", prefix); - - /* Tell the session manager how to discard this save */ - - argv[2] = gnome_config_get_real_path (prefix); - gnome_client_set_discard_command (client, 3, argv); - - /* Tell the session manager how to clone or restart this instance */ - - argv[0] = (char *) program_argv0; - argv[1] = NULL; /* "--debug-session"; */ - - gnome_client_set_clone_command (client, 1 /*2*/, argv); - gnome_client_set_restart_command (client, 1 /*2*/, argv); - - gedit_debug (DEBUG_SESSION, "END"); - - return TRUE; -} - -/* die handler for the master client */ -static void -client_die_cb (GnomeClient *client, gpointer data) -{ - gedit_debug (DEBUG_SESSION, ""); - - if (!client->save_yourself_emitted) - gedit_file_close_all (); - - gedit_plugins_engine_save_settings (); - - gedit_prefs_manager_shutdown (); - - /* FIXME: we should enable it, but it crashes here - Paolo */ - /* - g_object_unref (G_OBJECT (gedit_mdi)); - */ - - gtk_main_quit (); -} - -/** - * gedit_session_init: - * - * Initializes session management support. This function should be called near - * the beginning of the program. - **/ -void -gedit_session_init (const char *argv0) -{ - gedit_debug (DEBUG_SESSION, ""); - - if (master_client) - return; - - program_argv0 = argv0; - - master_client = gnome_master_client (); - - g_signal_connect (master_client, "save_yourself", - G_CALLBACK (client_save_yourself_cb), - NULL); - g_signal_connect (master_client, "die", - G_CALLBACK (client_die_cb), - NULL); -} - -/** - * gedit_session_is_restored: - * - * Returns whether this gedit is running from a restarted session. - * - * Return value: TRUE if the session manager restarted us, FALSE otherwise. - * This should be used to determine whether to pay attention to command line - * arguments in case the session was not restored. - **/ -gboolean -gedit_session_is_restored (void) -{ - gboolean restored; - - gedit_debug (DEBUG_SESSION, ""); - - if (!master_client) - return FALSE; - - restored = (gnome_client_get_flags (master_client) & GNOME_CLIENT_RESTORED) != 0; - - gedit_debug (DEBUG_SESSION, restored ? "RESTORED" : "NOT RESTORED"); - - return restored; -} - -/* Callback used from bonobo_mdi_restore_state() */ -static BonoboMDIChild * -mdi_child_create_cb (const gchar *str) -{ - GeditMDIChild *child; - GError *error = NULL; - - gedit_debug (DEBUG_SESSION, ""); - - /* The config string is simply a filename */ - if (str != NULL) - { - gedit_debug (DEBUG_SESSION, "URI: %s", str); - - child = gedit_mdi_child_new_with_uri (str, &error); - } - else - child = gedit_mdi_child_new (); - - if (error != NULL) { - /* FIXME: we are restoring the session; where should we report errors? */ - g_error_free (error); - return NULL; - } - - return BONOBO_MDI_CHILD (child); -} - -/** - * gedit_session_load: - * - * Loads the session by fetching the necessary information from the session - * manager and opening files. - * - * Return value: TRUE if the session was loaded successfully, FALSE otherwise. - **/ -gboolean -gedit_session_load (void) -{ - int retval; - - gedit_debug (DEBUG_SESSION, ""); - - gnome_config_push_prefix (gnome_client_get_config_prefix (master_client)); - - retval = bonobo_mdi_restore_state (BONOBO_MDI (gedit_mdi), "Session", - mdi_child_create_cb); - - gnome_config_pop_prefix (); - return retval; -} diff --git a/gedit/gedit-session.h b/gedit/gedit-session.h deleted file mode 100644 index 1edc8c5dc..000000000 --- a/gedit/gedit-session.h +++ /dev/null @@ -1,36 +0,0 @@ -/* gedit-session - Basic session management for gedit - * - * Copyright (C) 2002 Ximian, Inc. - * - * Author: Federico Mena-Quintero <federico@ximian.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_SESSION_H__ -#define __GEDIT_SESSION_H__ - -void gedit_session_init (const char *argv0); -gboolean gedit_session_is_restored (void); -gboolean gedit_session_load (void); - -#endif diff --git a/gedit/gedit-ui.xml b/gedit/gedit-ui.xml deleted file mode 100644 index 0d5525e0d..000000000 --- a/gedit/gedit-ui.xml +++ /dev/null @@ -1,334 +0,0 @@ -<Root> - -<commands> - <cmd name="FileNew" _label="New" - _tip="Create a new document" pixtype="stock" pixname="gtk-new" accel="*Control*N"/> - - <cmd name="FileOpen" _label="Open" - _tip="Open a file" pixtype="stock" pixname="gtk-open" accel="*Control*O"/> - - <cmd name="FileSave" _label="Save" - _tip="Save the current file" pixtype="stock" pixname="gtk-save" - accel="*Control*S"/> - - <cmd name="FileSaveAll" _label="Save All" - _tip="Save all open files" pixtype="stock" pixname="gtk-save"/> - - <cmd name="FileSaveAs" _label="Save As" - _tip="Save the current file with a different name" - pixtype="stock" pixname="gtk-save-as" - accel="*Shift**Control*S"/> - - <cmd name="FileRevert" _label="Revert" - _tip="Revert to a saved version of the file" - pixtype="stock" pixname="gtk-revert-to-saved"/> - - <cmd name="FileOpenURI" _label="Open Location..." - _tip="Open a file from a specified location" pixtype="stock" pixname="gtk-open"/> - - <cmd name="FilePrint" _label="Print" - _tip="Print the current file" pixtype="stock" pixname="gtk-print" - accel="*Control*P"/> - - <cmd name="FilePrintSetup" _label="Print Setup" - _tip="Setup the page settings for your current printer" - pixtype="stock" pixname="gtk-print"/> - - <cmd name="FilePrintPreview" _label="Print Preview" - _tip="Print preview" pixtype="stock" pixname="gtk-print-preview" - accel="*Shift**Control*P"/> - - <cmd name="FileClose" _label="Close" - _tip="Close the current file" pixtype="stock" pixname="gtk-close" - accel="*Control*W"/> - - <cmd name="FileCloseAll" _label="Close All" - _tip="Close all open files" pixtype="stock" pixname="gtk-close" - accel="*Shift**Control*W"/> - - <cmd name="FileExit" _label="Quit" _tip="Quit the program" - pixtype="stock" pixname="gtk-quit" accel="*Control*Q"/> - - - - <cmd name="EditUndo" _label="Undo" _tip="Undo the last action" - pixtype="stock" pixname="gtk-undo" accel="*Control*Z"/> - - <cmd name="EditRedo" _label="Redo" _tip="Redo the undone action" - pixtype="stock" pixname="gtk-redo" accel="*Shift**Control*Z"/> - - <cmd name="EditCut" _label="Cut" _tip="Cut the selection" - pixtype="stock" pixname="gtk-cut" accel="*Control*X"/> - - <cmd name="EditCopy" _label="Copy" - _tip="Copy the selection" pixtype="stock" pixname="gtk-copy" accel="*Control*c"/> - - <cmd name="EditPaste" _label="Paste" - _tip="Paste the clipboard" pixtype="stock" pixname="gtk-paste" accel="*Control*v"/> - - <cmd name="EditClear" _label="Delete" - _tip="Delete the selected text"/> - - <cmd name="EditSelectAll" _label="Select All" _tip="Select the entire document" - accel="*Control*A"/> - - <cmd name="SearchFind" _label="Find" _tip="Search for a string" - pixtype="stock" pixname="gtk-find" accel="*Control*F"/> - - <cmd name="SearchFindAgain" _label="Find Again" _tip="Search again for the same string" - pixtype="stock" pixname="gtk-find" accel="*Control*G"/> - - <cmd name="SearchReplace" _label="Replace" _tip="Replace a string" - pixtype="stock" pixname="gtk-find-and-replace" accel="*Control*R"/> - - <cmd name="SearchGoToLine" _label="Replace" _tip="Go to a specific line number" - pixtype="stock" pixname="gtk-jump-to" /> - - <cmd name="ViewToolbar" _label="_Toolbar" type="toggle" - _tip="Change the visibility of the toolbar in the current window" state="0"/> - - <cmd name="ViewStatusbar" _label="_Statusbar" type="toggle" - _tip="Change the visibility of the statusbar in the current window" state="0"/> - - <cmd name="ToolbarSystem" id="ToolbarSystem" _label="_Desktop Default" type="radio" - group="buttons" state = "1" _tip="Set toolbar button style according to desktop default"/> - - <cmd name="ToolbarIcon" id="ToolbarIcon" _label="_Icon" type="radio" - group="buttons" _tip="Only show icons in the toolbar"/> - - <cmd name="ToolbarIconText" id="ToolbarIconText" _label="Icon and _Text" type="radio" - group="buttons" _tip ="Show both icons and texts in the toolbar"/> - - <cmd name="SettingsPreferences" _label="Preferences" _tip="Configure the application" - pixtype="stock" pixname="gtk-preferences"/> - - <cmd name="StatusBarCursorPosition" id="StatusBarCursorPosition" - _label="Show _Cursor Position" type="toggle" - _tip="Show cursor position in the statusbar" state="1"/> - - <cmd name="StatusBarOverwriteMode" id="StatusBarOverwriteMode" - _label="Show _Overwrite Mode" type="toggle" - _tip="Show overwrite mode in the statusbar" state="1"/> - - - <cmd name="BonoboCustomize" _label="Customize" _tip="Customize toolbars"/> - - - <cmd name="HelpContents" _label="_Contents" _tip="Open the gedit manual" - accel="F1" pixtype="stock" pixname="gtk-help"/> - - <cmd name="About" _label="_About" _tip="About this application" - pixtype="stock" pixname="About"/> - - - <cmd name="BonoboUIDump" _label="Dump XML" _tip="Dump the UI Xml description" hidden="0"/> - -</commands> - -<menu> - -<submenu name="File" _label="_File"> - - <menuitem name="FileNew" verb="" _label="_New"/> - - <menuitem name="FileOpen" verb="" _label="_Open..."/> - - <menuitem name="FileOpenURI" verb="" _label="Open _Location..."/> - - <submenu name="Recents" _label="Recent _Files"> - - </submenu> - - <separator/> - - <menuitem name="FileSave" verb="" _label="_Save"/> - - <menuitem name="FileSaveAs" verb="" _label="Save _As..."/> - - <menuitem name="FileSaveAll" verb="" _label="Sa_ve All"/> - - <menuitem name="FileRevert" verb="" _label="_Revert"/> - - <separator/> - - <menuitem name="FilePrintPreview" verb="" _label="Print Previe_w"/> - - <menuitem name="FilePrint" verb="" _label="_Print..."/> - - <placeholder name="FileOps_1" /> - - <placeholder name="FileOps_2" delimit="top"/> - - <separator/> - - <menuitem name="FileClose" verb="" _label="_Close"/> - - <menuitem name="FileCloseAll" verb="" _label="Clos_e All"/> - - <menuitem name="FileExit" verb="" _label="_Quit"/> - -</submenu> - -<submenu name="Edit" _label="_Edit"> - - <menuitem name="EditUndo" verb="" _label="_Undo"/> - - <menuitem name="EditRedo" verb="" _label="_Redo"/> - - <separator/> - - <menuitem name="EditCut" verb="" _label="Cu_t"/> - - <menuitem name="EditCopy" verb="" _label="_Copy"/> - - <menuitem name="EditPaste" verb="" _label="_Paste"/> - - <menuitem name="EditClear" verb="" _label="_Delete"/> - - <placeholder name="EditOps_1" /> - - <separator/> - - <placeholder name="EditOps_2" /> - - <menuitem name="EditSelectAll" verb="" _label="Select _All"/> - - <placeholder name="EditOps_3" /> - - <placeholder name="EditOps_4" delimit="top"/> - - <placeholder name="EditOps_5" delimit="top"/> - - <separator/> - - <menuitem name="SettingsPreferences" verb="" _label="Pr_eferences..."/> - -</submenu> - -<submenu name="View" _label="_View" hidden="0"> - - <menuitem name="ViewToolbar" id="ViewToolbar" verb=""/> - - <menuitem name="ViewStatusbar" id="ViewStatusbar" verb=""/> - - <separator/> - - <submenu name="CustomizeToolbar" _label="_Customize Toolbar"> - - <menuitem name="ToolbarSystem" verb=""/> - - <menuitem name="ToolbarIcon" verb=""/> - - <menuitem name="ToolbarIconText" verb=""/> - - </submenu> - - <submenu name="CustomizeStatusbar" _label="C_ustomize Statusbar"> - - <menuitem name="StatusBarCursorPosition" verb=""/> - - <menuitem name="StatusBarOverwriteMode" verb=""/> - - </submenu> - - <placeholder name="ViewOps" delimit="top"/> - -</submenu> - - -<submenu name="Search" _label="_Search"> - - <menuitem name="SearchFind" verb="" _label="_Find"/> - - <menuitem name="SearchFindAgain" verb="" _label="Find Ne_xt"/> - - <menuitem name="SearchReplace" verb="" _label="_Replace"/> - - <placeholder name="SearchOps_1" delimit="top"/> - - <separator/> - - <menuitem name="SearchGoToLine" verb="" _label="Goto _Line"/> - - <placeholder name="SearchOps_2" /> - - <placeholder name="SearchOps_3" delimit="top"/> - - </submenu> - -<submenu name="Tools" _label="_Tools" hidden="1"> - - <placeholder name="ToolsOps_1" /> - - <placeholder name="ToolsOps_2" delimit="top"/> - - <placeholder name="ToolsOps_3" delimit="top"/> - -</submenu> - - -<submenu name="Documents" _label="_Documents"> - - <placeholder name="DocumentsOps_1" delimit="bottom"/> - - <placeholder name="OpenDocuments" /> - - <placeholder name="DocumentsOps_2" delimit="top"/> - -</submenu> - -<submenu name="Help" _label="_Help"> - - <menuitem name="HelpContents" verb=""/> - - <menuitem name="About" verb="" /> - -</submenu> - -<submenu name="Debug" _label="_Debug" hidden="1"> - - <menuitem name="BonoboUIDump" verb=""/> - <menuitem name="BonoboCustomize" label ="Customize" verb=""/> -</submenu> - -</menu> - -<dockitem name="Toolbar" _tip="Main toolbar" config="0" - behavior = "exclusive" in_new_band="1"> - - <toolitem name="FileNew" verb=""/> - <toolitem name="FileOpen" verb=""/> - <toolitem name="FileSave" verb=""/> - <toolitem name="FileClose" verb=""/> - - <separator/> - - <toolitem name="FilePrint" verb=""/> - - <separator/> - - <toolitem name="EditUndo" verb=""/> - <toolitem name="EditRedo" verb=""/> - - <separator/> - - <toolitem name="EditCut" verb=""/> - <toolitem name="EditCopy" verb=""/> - <toolitem name="EditPaste" verb=""/> - - <separator/> - - <toolitem name="SearchFind" verb=""/> - <toolitem name="SearchReplace" verb=""/> - -</dockitem> - -<status resize_grip="1"> - <item name="main" /> - <control name="dummy" hidden="1"/> - <control name="OverwriteMode"/> - <control name="CursorPosition"/> -</status> - -</Root> - diff --git a/gedit/gedit-undo-manager.c b/gedit/gedit-undo-manager.c deleted file mode 100644 index 17eb83ea7..000000000 --- a/gedit/gedit-undo-manager.c +++ /dev/null @@ -1,861 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-undo-manager.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <glib.h> -#include <stdlib.h> -#include <string.h> - -#include "gedit-undo-manager.h" -#include "gedit-debug.h" -#include "gedit-prefs-manager.h" -#include "gedit-marshal.h" - -typedef struct _GeditUndoAction GeditUndoAction; -typedef struct _GeditUndoInsertAction GeditUndoInsertAction; -typedef struct _GeditUndoDeleteAction GeditUndoDeleteAction; - -typedef enum { - GEDIT_UNDO_ACTION_INSERT, - GEDIT_UNDO_ACTION_DELETE -} GeditUndoActionType; - -/* - * We use offsets instead of GtkTextIters because the last ones - * require to much memory in this context without giving us any advantage. - */ - -struct _GeditUndoInsertAction -{ - gint pos; - gchar *text; - gint length; - gint chars; -}; - -struct _GeditUndoDeleteAction -{ - gint start; - gint end; - gchar *text; -}; - -struct _GeditUndoAction -{ - GeditUndoActionType action_type; - - union { - GeditUndoInsertAction insert; - GeditUndoDeleteAction delete; - } action; - - gboolean mergeable; - - gint order_in_group; -}; - -struct _GeditUndoManagerPrivate -{ - GeditDocument* document; - - GList* actions; - gint next_redo; - - gint actions_in_current_group; - - gboolean can_undo; - gboolean can_redo; - - gint running_not_undoable_actions; -}; - -enum { - CAN_UNDO, - CAN_REDO, - LAST_SIGNAL -}; - -static void gedit_undo_manager_class_init (GeditUndoManagerClass *klass); -static void gedit_undo_manager_init (GeditUndoManager *um); -static void gedit_undo_manager_finalize (GObject *object); - -static void gedit_undo_manager_insert_text_handler (GtkTextBuffer *buffer, GtkTextIter *pos, - const gchar *text, gint length, - GeditUndoManager *um); -static void gedit_undo_manager_delete_range_handler (GtkTextBuffer *buffer, GtkTextIter *start, - GtkTextIter *end, GeditUndoManager *um); -static void gedit_undo_manager_begin_user_action_handler (GtkTextBuffer *buffer, GeditUndoManager *um); -static void gedit_undo_manager_end_user_action_handler (GtkTextBuffer *buffer, GeditUndoManager *um); - -static void gedit_undo_manager_free_action_list (GeditUndoManager *um); - -static void gedit_undo_manager_add_action (GeditUndoManager *um, - GeditUndoAction undo_action); -static void gedit_undo_manager_free_first_n_actions (GeditUndoManager *um, gint n); -static void gedit_undo_manager_check_list_size (GeditUndoManager *um); - -static gboolean gedit_undo_manager_merge_action (GeditUndoManager *um, - GeditUndoAction *undo_action); -static gint gedit_undo_manager_get_number_of_groups (GeditUndoManager *um); - -static GObjectClass *parent_class = NULL; -static guint undo_manager_signals [LAST_SIGNAL] = { 0 }; - -GType -gedit_undo_manager_get_type (void) -{ - static GType undo_manager_type = 0; - - if (undo_manager_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GeditDocumentClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gedit_undo_manager_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GeditDocument), - 0, /* n_preallocs */ - (GInstanceInitFunc) gedit_undo_manager_init - }; - - undo_manager_type = g_type_register_static (G_TYPE_OBJECT, - "GeditUndoManager", - &our_info, - 0); - } - - return undo_manager_type; -} - -static void -gedit_undo_manager_class_init (GeditUndoManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_undo_manager_finalize; - - klass->can_undo = NULL; - klass->can_redo = NULL; - - undo_manager_signals[CAN_UNDO] = - g_signal_new ("can_undo", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditUndoManagerClass, can_undo), - NULL, NULL, - gedit_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - - undo_manager_signals[CAN_REDO] = - g_signal_new ("can_redo", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GeditUndoManagerClass, can_redo), - NULL, NULL, - gedit_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - -} - -static void -gedit_undo_manager_init (GeditUndoManager *um) -{ - gedit_debug (DEBUG_UNDO, ""); - - um->priv = g_new0 (GeditUndoManagerPrivate, 1); - - um->priv->actions = NULL; - um->priv->next_redo = 0; - - um->priv->can_undo = FALSE; - um->priv->can_redo = FALSE; - - um->priv->running_not_undoable_actions = 0; -} - -static void -gedit_undo_manager_finalize (GObject *object) -{ - GeditUndoManager *um; - - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (object != NULL); - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (object)); - - um = GEDIT_UNDO_MANAGER (object); - - g_return_if_fail (um->priv != NULL); - - if (um->priv->actions != NULL) - { - gedit_undo_manager_free_action_list (um); - } - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gedit_undo_manager_delete_range_handler), - um); - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gedit_undo_manager_insert_text_handler), - um); - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gedit_undo_manager_begin_user_action_handler), - um); - - g_signal_handlers_disconnect_by_func (G_OBJECT (um->priv->document), - G_CALLBACK (gedit_undo_manager_end_user_action_handler), - um); - - g_free (um->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -GeditUndoManager* -gedit_undo_manager_new (GeditDocument* document) -{ - GeditUndoManager *um; - - gedit_debug (DEBUG_UNDO, ""); - - um = GEDIT_UNDO_MANAGER (g_object_new (GEDIT_TYPE_UNDO_MANAGER, NULL)); - - g_return_val_if_fail (um->priv != NULL, NULL); - um->priv->document = document; - - g_signal_connect (G_OBJECT (document), "insert_text", - G_CALLBACK (gedit_undo_manager_insert_text_handler), - um); - - g_signal_connect (G_OBJECT (document), "delete_range", - G_CALLBACK (gedit_undo_manager_delete_range_handler), - um); - - g_signal_connect (G_OBJECT (document), "begin_user_action", - G_CALLBACK (gedit_undo_manager_begin_user_action_handler), - um); - - g_signal_connect (G_OBJECT (document), "end_user_action", - G_CALLBACK (gedit_undo_manager_end_user_action_handler), - um); - - return um; -} - -void gedit_undo_manager_begin_not_undoable_action (GeditUndoManager *um) -{ - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - ++um->priv->running_not_undoable_actions; -} - -void gedit_undo_manager_end_not_undoable_action (GeditUndoManager *um) -{ - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - if (um->priv->running_not_undoable_actions <= 0) - um->priv->running_not_undoable_actions = 0; - else - --um->priv->running_not_undoable_actions; -} - -gboolean -gedit_undo_manager_can_undo (const GeditUndoManager *um) -{ - gedit_debug (DEBUG_UNDO, ""); - - g_return_val_if_fail (GEDIT_IS_UNDO_MANAGER (um), FALSE); - g_return_val_if_fail (um->priv != NULL, FALSE); - - return um->priv->can_undo; -} - -gboolean -gedit_undo_manager_can_redo (const GeditUndoManager *um) -{ - gedit_debug (DEBUG_UNDO, ""); - - g_return_val_if_fail (GEDIT_IS_UNDO_MANAGER (um), FALSE); - g_return_val_if_fail (um->priv != NULL, FALSE); - - return um->priv->can_redo; -} - -void -gedit_undo_manager_undo (GeditUndoManager *um) -{ - GeditUndoAction *undo_action; - - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - g_return_if_fail (um->priv->can_undo); - - gedit_undo_manager_begin_not_undoable_action (um); - - do - { - ++um->priv->next_redo; - - undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo); - g_return_if_fail (undo_action != NULL); - - switch (undo_action->action_type) - { - case GEDIT_UNDO_ACTION_DELETE: - gedit_document_insert_text ( - um->priv->document, - undo_action->action.delete.start, - undo_action->action.delete.text, - strlen (undo_action->action.delete.text)); - break; - case GEDIT_UNDO_ACTION_INSERT: - gedit_document_delete_text ( - um->priv->document, - undo_action->action.insert.pos, - undo_action->action.insert.pos + - undo_action->action.insert.chars); - break; - - default: - g_warning ("This should not happen."); - return; - } - - } while (undo_action->order_in_group > 1); - - gedit_undo_manager_end_not_undoable_action (um); - - if (!um->priv->can_redo) - { - um->priv->can_redo = TRUE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, TRUE); - } - - if (um->priv->next_redo >= (gint)(g_list_length (um->priv->actions) - 1)) - { - um->priv->can_undo = FALSE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, FALSE); - } -} - -void -gedit_undo_manager_redo (GeditUndoManager *um) -{ - GeditUndoAction *undo_action; - - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - g_return_if_fail (um->priv->can_redo); - - undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo); - g_return_if_fail (undo_action != NULL); - - gedit_undo_manager_begin_not_undoable_action (um); - - do - { - switch (undo_action->action_type) - { - case GEDIT_UNDO_ACTION_DELETE: - gedit_document_delete_text ( - um->priv->document, - undo_action->action.delete.start, - undo_action->action.delete.end); - break; - - case GEDIT_UNDO_ACTION_INSERT: - gedit_document_insert_text ( - um->priv->document, - undo_action->action.insert.pos, - undo_action->action.insert.text, - undo_action->action.insert.length); - - break; - - default: - g_warning ("This should not happen."); - return; - } - - --um->priv->next_redo; - - if (um->priv->next_redo < 0) - undo_action = NULL; - else - undo_action = g_list_nth_data (um->priv->actions, um->priv->next_redo); - - } while ((undo_action != NULL) && (undo_action->order_in_group > 1)); - - gedit_undo_manager_end_not_undoable_action (um); - - if (um->priv->next_redo < 0) - { - um->priv->can_redo = FALSE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE); - } - - if (!um->priv->can_undo) - { - um->priv->can_undo = TRUE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, TRUE); - } - -} - -static void -gedit_undo_manager_free_action_list (GeditUndoManager *um) -{ - gint n, len; - - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - if (um->priv->actions == NULL) - { - return; - } - len = g_list_length (um->priv->actions); - - for (n = 0; n < len; n++) - { - GeditUndoAction *undo_action = - (GeditUndoAction *)(g_list_nth_data (um->priv->actions, n)); - - gedit_debug (DEBUG_UNDO, "Free action (tye %s) %d/%d", - (undo_action->action_type == GEDIT_UNDO_ACTION_INSERT) ? "insert": - "delete", n, len); - - if (undo_action->action_type == GEDIT_UNDO_ACTION_INSERT) - g_free (undo_action->action.insert.text); - else if (undo_action->action_type == GEDIT_UNDO_ACTION_DELETE) - g_free (undo_action->action.delete.text); - else - g_return_if_fail (FALSE); - - g_free (undo_action); - } - - g_list_free (um->priv->actions); - um->priv->actions = NULL; -} - -static void -gedit_undo_manager_insert_text_handler (GtkTextBuffer *buffer, GtkTextIter *pos, - const gchar *text, gint length, GeditUndoManager *um) -{ - GeditUndoAction undo_action; - - gedit_debug (DEBUG_UNDO, ""); - - if (um->priv->running_not_undoable_actions > 0) - return; - - g_return_if_fail (strlen (text) == (guint)length); - - undo_action.action_type = GEDIT_UNDO_ACTION_INSERT; - - undo_action.action.insert.pos = gtk_text_iter_get_offset (pos); - undo_action.action.insert.text = (gchar*) text; - undo_action.action.insert.length = length; - undo_action.action.insert.chars = g_utf8_strlen (text, length); - - if ((undo_action.action.insert.chars > 1) || (g_utf8_get_char (text) == '\n')) - - undo_action.mergeable = FALSE; - else - undo_action.mergeable = TRUE; - - gedit_undo_manager_add_action (um, undo_action); -} - -static void -gedit_undo_manager_delete_range_handler (GtkTextBuffer *buffer, GtkTextIter *start, - GtkTextIter *end, GeditUndoManager *um) -{ - GeditUndoAction undo_action; - - gedit_debug (DEBUG_UNDO, ""); - - if (um->priv->running_not_undoable_actions > 0) - return; - - undo_action.action_type = GEDIT_UNDO_ACTION_DELETE; - - gtk_text_iter_order (start, end); - - undo_action.action.delete.start = gtk_text_iter_get_offset (start); - undo_action.action.delete.end = gtk_text_iter_get_offset (end); - - undo_action.action.delete.text = gedit_document_get_chars ( - GEDIT_DOCUMENT (buffer), - undo_action.action.delete.start, - undo_action.action.delete.end); - - if (((undo_action.action.delete.end - undo_action.action.delete.start) > 1) || - (g_utf8_get_char (undo_action.action.delete.text ) == '\n')) - undo_action.mergeable = FALSE; - else - undo_action.mergeable = TRUE; - - gedit_debug (DEBUG_UNDO, "START: %d", undo_action.action.delete.start); - gedit_debug (DEBUG_UNDO, "END: %d", undo_action.action.delete.end); - gedit_debug (DEBUG_UNDO, "TEXT: %s", undo_action.action.delete.text); - - gedit_undo_manager_add_action (um, undo_action); - - g_free (undo_action.action.delete.text); - - gedit_debug (DEBUG_UNDO, "DONE"); -} - -static void -gedit_undo_manager_begin_user_action_handler (GtkTextBuffer *buffer, GeditUndoManager *um) -{ - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - if (um->priv->running_not_undoable_actions > 0) - return; - - um->priv->actions_in_current_group = 0; -} - -static void -gedit_undo_manager_end_user_action_handler (GtkTextBuffer *buffer, GeditUndoManager *um) -{ - gedit_debug (DEBUG_UNDO, ""); - - if (um->priv->running_not_undoable_actions > 0) - return; - - /* TODO: is it needed ? */ -} - -/* FIXME: change prototype to use GeditUndoAction *undo_action : Paolo */ -static void -gedit_undo_manager_add_action (GeditUndoManager *um, GeditUndoAction undo_action) -{ - GeditUndoAction* action; - - gedit_debug (DEBUG_UNDO, ""); - - if (um->priv->next_redo >= 0) - { - gedit_undo_manager_free_first_n_actions (um, um->priv->next_redo + 1); - } - - um->priv->next_redo = -1; - - if (!gedit_undo_manager_merge_action (um, &undo_action)) - { - action = g_new (GeditUndoAction, 1); - *action = undo_action; - - if (action->action_type == GEDIT_UNDO_ACTION_INSERT) - action->action.insert.text = g_strdup (undo_action.action.insert.text); - else if (action->action_type == GEDIT_UNDO_ACTION_DELETE) - action->action.delete.text = g_strdup (undo_action.action.delete.text); - else - { - g_free (action); - g_return_if_fail (FALSE); - } - - ++um->priv->actions_in_current_group; - action->order_in_group = um->priv->actions_in_current_group; - - um->priv->actions = g_list_prepend (um->priv->actions, action); - } - - gedit_undo_manager_check_list_size (um); - - if (!um->priv->can_undo) - { - um->priv->can_undo = TRUE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_UNDO], 0, TRUE); - } - - if (um->priv->can_redo) - { - um->priv->can_redo = FALSE; - g_signal_emit (G_OBJECT (um), undo_manager_signals [CAN_REDO], 0, FALSE); - } - - gedit_debug (DEBUG_UNDO, "DONE"); -} - -static void -gedit_undo_manager_free_first_n_actions (GeditUndoManager *um, gint n) -{ - gint i; - - gedit_debug (DEBUG_UNDO, ""); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - if (um->priv->actions == NULL) - return; - - for (i = 0; i < n; i++) - { - GeditUndoAction *undo_action = - (GeditUndoAction *)(g_list_first (um->priv->actions)->data); - - if (undo_action->action_type == GEDIT_UNDO_ACTION_INSERT) - g_free (undo_action->action.insert.text); - else if (undo_action->action_type == GEDIT_UNDO_ACTION_DELETE) - g_free (undo_action->action.delete.text); - else - g_return_if_fail (FALSE); - - g_free (undo_action); - - um->priv->actions = g_list_delete_link (um->priv->actions, um->priv->actions); - - if (um->priv->actions == NULL) - return; - } -} - -static void -gedit_undo_manager_check_list_size (GeditUndoManager *um) -{ - gint undo_levels; - - gedit_debug (DEBUG_UNDO, "TODO"); - - g_return_if_fail (GEDIT_IS_UNDO_MANAGER (um)); - g_return_if_fail (um->priv != NULL); - - undo_levels = gedit_prefs_manager_get_undo_actions_limit (); - - if (undo_levels < 1) - return; - - if (gedit_undo_manager_get_number_of_groups (um) > undo_levels) - { - GeditUndoAction *undo_action; - GList* last; - - last = g_list_last (um->priv->actions); - undo_action = (GeditUndoAction*) last->data; - - do - { - if (undo_action->action_type == GEDIT_UNDO_ACTION_INSERT) - g_free (undo_action->action.insert.text); - else if (undo_action->action_type == GEDIT_UNDO_ACTION_DELETE) - g_free (undo_action->action.delete.text); - else - g_return_if_fail (FALSE); - - g_free (undo_action); - - um->priv->actions = g_list_delete_link (um->priv->actions, last); - g_return_if_fail (um->priv->actions != NULL); - - last = g_list_last (um->priv->actions); - undo_action = (GeditUndoAction*) last->data; - - } while ((undo_action->order_in_group > 1) || - (gedit_undo_manager_get_number_of_groups (um) > - undo_levels)); - } -} - -/** - * gedit_undo_manager_merge_action: - * @um: a #GeditUndoManager - * @undo_action: - * - * This function tries to merge the undo action at the top of - * the stack with a new undo action. So when we undo for example - * typing, we can undo the whole word and not each letter by itself - * - * Return Value: TRUE is merge was sucessful, FALSE otherwise - **/ -static gboolean -gedit_undo_manager_merge_action (GeditUndoManager *um, GeditUndoAction *undo_action) -{ - GeditUndoAction *last_action; - - gedit_debug (DEBUG_UNDO, ""); - - g_return_val_if_fail (GEDIT_IS_UNDO_MANAGER (um), FALSE); - g_return_val_if_fail (um->priv != NULL, FALSE); - - if (um->priv->actions == NULL) - return FALSE; - - last_action = (GeditUndoAction*) g_list_nth_data (um->priv->actions, 0); - - if (!last_action->mergeable) - return FALSE; - - if ((!undo_action->mergeable) || - (undo_action->action_type != last_action->action_type)) - { - last_action->mergeable = FALSE; - return FALSE; - } - - if (undo_action->action_type == GEDIT_UNDO_ACTION_DELETE) - { - if ((last_action->action.delete.start != undo_action->action.delete.start) && - (last_action->action.delete.start != undo_action->action.delete.end)) - { - last_action->mergeable = FALSE; - return FALSE; - } - - if (last_action->action.delete.start == undo_action->action.delete.start) - { - gchar *str; - -#define L (last_action->action.delete.end - last_action->action.delete.start - 1) -#define g_utf8_get_char_at(p,i) g_utf8_get_char(g_utf8_offset_to_pointer((p),(i))) - - gedit_debug (DEBUG_UNDO, "L = %d", L); - - /* Deleted with the delete key */ - if ((g_utf8_get_char (undo_action->action.delete.text) != ' ') && - (g_utf8_get_char (undo_action->action.delete.text) != '\t') && - ((g_utf8_get_char_at (last_action->action.delete.text, L) == ' ') || - (g_utf8_get_char_at (last_action->action.delete.text, L) == '\t'))) - { - last_action->mergeable = FALSE; - return FALSE; - } - - str = g_strdup_printf ("%s%s", last_action->action.delete.text, - undo_action->action.delete.text); - - g_free (last_action->action.delete.text); - last_action->action.delete.end += (undo_action->action.delete.end - undo_action->action.delete.start); - last_action->action.delete.text = str; - } - else - { - gchar *str; - - /* Deleted with the backspace key */ - if ((g_utf8_get_char (undo_action->action.delete.text) != ' ') && - (g_utf8_get_char (undo_action->action.delete.text) != '\t') && - ((g_utf8_get_char (last_action->action.delete.text) == ' ') || - (g_utf8_get_char (last_action->action.delete.text) == '\t'))) - { - last_action->mergeable = FALSE; - return FALSE; - } - - str = g_strdup_printf ("%s%s", undo_action->action.delete.text, - last_action->action.delete.text); - - g_free (last_action->action.delete.text); - last_action->action.delete.start = undo_action->action.delete.start; - last_action->action.delete.text = str; - } - } - else if (undo_action->action_type == GEDIT_UNDO_ACTION_INSERT) - { - gchar* str; - -#define I (last_action->action.insert.chars - 1) - - if ((undo_action->action.insert.pos != - (last_action->action.insert.pos + last_action->action.insert.chars)) || - ((g_utf8_get_char (undo_action->action.insert.text) != ' ') && - (g_utf8_get_char (undo_action->action.insert.text) != '\t') && - ((g_utf8_get_char_at (last_action->action.insert.text, I) == ' ') || - (g_utf8_get_char_at (last_action->action.insert.text, I) == '\t'))) - ) - { - last_action->mergeable = FALSE; - return FALSE; - } - - str = g_strdup_printf ("%s%s", last_action->action.insert.text, - undo_action->action.insert.text); - - g_free (last_action->action.insert.text); - last_action->action.insert.length += undo_action->action.insert.length; - last_action->action.insert.text = str; - last_action->action.insert.chars += undo_action->action.insert.chars; - - } - else - g_warning ("Unknown action inside undo merge encountered"); - - return TRUE; -} - -static gint -gedit_undo_manager_get_number_of_groups (GeditUndoManager *um) -{ - GList *list = um->priv->actions; - gint num = 0; - - gedit_debug (DEBUG_UNDO, ""); - - while (list) - { - if (((GeditUndoAction* ) list->data)->order_in_group == 1) - ++num; - list = list->next; - } - - return num; -} - diff --git a/gedit/gedit-undo-manager.h b/gedit/gedit-undo-manager.h deleted file mode 100644 index 7196efbb5..000000000 --- a/gedit/gedit-undo-manager.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-undo-manager.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_UNDO_MANAGER_H__ -#define __GEDIT_UNDO_MANAGER_H__ - -#include "gedit-document.h" - -#define GEDIT_TYPE_UNDO_MANAGER (gedit_undo_manager_get_type ()) -#define GEDIT_UNDO_MANAGER(obj) (GTK_CHECK_CAST ((obj), GEDIT_TYPE_UNDO_MANAGER, GeditUndoManager)) -#define GEDIT_UNDO_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_UNDO_MANAGER, GeditUndoManagerClass)) -#define GEDIT_IS_UNDO_MANAGER(obj) (GTK_CHECK_TYPE ((obj), GEDIT_TYPE_UNDO_MANAGER)) -#define GEDIT_IS_UNDO_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_UNDO_MANAGER)) -#define GEDIT_UNDO_MANAGER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GEDIT_TYPE_UNDO_MANAGER, GeditUndoManagerClass)) - - -typedef struct _GeditUndoManager GeditUndoManager; -typedef struct _GeditUndoManagerClass GeditUndoManagerClass; - -typedef struct _GeditUndoManagerPrivate GeditUndoManagerPrivate; - -struct _GeditUndoManager -{ - GObject base; - - GeditUndoManagerPrivate *priv; -}; - -struct _GeditUndoManagerClass -{ - GObjectClass parent_class; - - /* Signals */ - void (*can_undo)( GeditUndoManager *um, gboolean can_undo); - void (*can_redo)( GeditUndoManager *um, gboolean can_redo); -}; - -GType gedit_undo_manager_get_type (void) G_GNUC_CONST; - -GeditUndoManager* gedit_undo_manager_new (GeditDocument *document); - -gboolean gedit_undo_manager_can_undo (const GeditUndoManager *um); -gboolean gedit_undo_manager_can_redo (const GeditUndoManager *um); - -void gedit_undo_manager_undo (GeditUndoManager *um); -void gedit_undo_manager_redo (GeditUndoManager *um); - -void gedit_undo_manager_begin_not_undoable_action (GeditUndoManager *um); -void gedit_undo_manager_end_not_undoable_action (GeditUndoManager *um); - -#endif /* __GEDIT_UNDO_MANAGER_H__ */ - - diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c deleted file mode 100644 index e2b656793..000000000 --- a/gedit/gedit-utils.c +++ /dev/null @@ -1,1537 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-utils.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <libgnomeui/libgnomeui.h> -#include <glib/gunicode.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomevfs/gnome-vfs.h> -#include <eel/eel-vfs-extensions.h> -#include <eel/eel-string.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include <string.h> - -#include "gedit-utils.h" -#include "gedit2.h" -#include "bonobo-mdi.h" -#include "gedit-document.h" -#include "gedit-debug.h" - -/* =================================================== */ -/* Flash */ - -struct _MessageInfo { - BonoboWindow * win; - guint timeoutid; - guint handlerid; -}; - -typedef struct _MessageInfo MessageInfo; - -MessageInfo *current_mi = NULL; - -static gint remove_message_timeout (MessageInfo * mi); -static void remove_timeout_cb (GtkWidget *win, MessageInfo *mi); -static void bonobo_window_flash (BonoboWindow * win, const gchar * flash); - -static gint -remove_message_timeout (MessageInfo * mi) -{ - BonoboUIComponent *ui_component; - - GDK_THREADS_ENTER (); - - ui_component = bonobo_mdi_get_ui_component_from_window (mi->win); - g_return_val_if_fail (ui_component != NULL, FALSE); - - bonobo_ui_component_set_status (ui_component, " ", NULL); - - g_signal_handler_disconnect (G_OBJECT (mi->win), mi->handlerid); - - g_free (mi); - current_mi = NULL; - - GDK_THREADS_LEAVE (); - - return FALSE; /* removes the timeout */ -} - -/* Called if the win is destroyed before the timeout occurs. */ -static void -remove_timeout_cb (GtkWidget *win, MessageInfo *mi) -{ - gtk_timeout_remove (mi->timeoutid); - g_free (mi); - - if (mi == current_mi) - current_mi = NULL; -} - -static const guint32 flash_length = 3000; /* 3 seconds, I hope */ - -/** - * bonobo_win_flash - * @app: Pointer a Bonobo window object - * @flash: Text of message to be flashed - * - * Description: - * Flash the message in the statusbar for a few moments; if no - * statusbar, do nothing. For trivial little status messages, - * e.g. "Auto saving..." - **/ - -static void -bonobo_window_flash (BonoboWindow * win, const gchar * flash) -{ - BonoboUIComponent *ui_component; - g_return_if_fail (win != NULL); - g_return_if_fail (BONOBO_IS_WINDOW (win)); - g_return_if_fail (flash != NULL); - - ui_component = bonobo_mdi_get_ui_component_from_window (win); - g_return_if_fail (ui_component != NULL); - - if (current_mi != NULL) - { - gtk_timeout_remove (current_mi->timeoutid); - remove_message_timeout (current_mi); - } - - if (bonobo_ui_component_path_exists (ui_component, "/status", NULL)) - { - MessageInfo * mi; - - bonobo_ui_component_set_status (ui_component, flash, NULL); - - mi = g_new(MessageInfo, 1); - - mi->timeoutid = - gtk_timeout_add (flash_length, - (GtkFunction) remove_message_timeout, - mi); - - mi->handlerid = - g_signal_connect (GTK_OBJECT (win), - "destroy", - G_CALLBACK (remove_timeout_cb), - mi); - - mi->win = win; - - current_mi = mi; - } -} - -/* ========================================================== */ - -/** - * gedit_utils_flash: - * @msg: Message to flash on the statusbar - * - * Flash a temporary message on the statusbar of gedit. - **/ -void -gedit_utils_flash (gchar *msg) -{ - g_return_if_fail (msg != NULL); - - bonobo_window_flash (bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi)), msg); - - /* Update UI */ - while (gtk_events_pending ()) - gtk_main_iteration (); -} - -/** - * gedit_utils_flash_va: - * @format: - **/ -void -gedit_utils_flash_va (gchar *format, ...) -{ - va_list args; - gchar *msg; - - g_return_if_fail (format != NULL); - - va_start (args, format); - msg = g_strdup_vprintf (format, args); - va_end (args); - - gedit_utils_flash (msg); - g_free (msg); -} - -gboolean -gedit_utils_uri_has_file_scheme (const gchar *uri) -{ - gchar* canonical_uri = NULL; - gboolean res; - - canonical_uri = eel_make_uri_canonical (uri); - g_return_val_if_fail (canonical_uri != NULL, FALSE); - - res = eel_istr_has_prefix (canonical_uri, "file:"); - - g_free (canonical_uri); - - return res; -} - -gboolean -gedit_utils_is_uri_read_only (const gchar* uri) -{ - gchar* file_uri = NULL; - gchar* canonical_uri = NULL; - - gint res; - - g_return_val_if_fail (uri != NULL, TRUE); - - gedit_debug (DEBUG_FILE, "URI: %s", uri); - - /* FIXME: all remote files are marked as readonly */ - if (!gedit_utils_uri_has_file_scheme (uri)) - return TRUE; - - canonical_uri = eel_make_uri_canonical (uri); - g_return_val_if_fail (canonical_uri != NULL, TRUE); - - gedit_debug (DEBUG_FILE, "CANONICAL URI: %s", canonical_uri); - - file_uri = gnome_vfs_get_local_path_from_uri (canonical_uri); - if (file_uri == NULL) - { - gedit_debug (DEBUG_FILE, "FILE URI: NULL"); - - return TRUE; - } - - res = access (file_uri, W_OK); - - g_free (canonical_uri); - g_free (file_uri); - - return res; -} - -GtkWidget* -gedit_button_new_with_stock_image (const gchar* text, const gchar* stock_id) -{ - GtkWidget *button; - GtkStockItem item; - GtkWidget *label; - GtkWidget *image; - GtkWidget *hbox; - GtkWidget *align; - - button = gtk_button_new (); - - if (GTK_BIN (button)->child) - gtk_container_remove (GTK_CONTAINER (button), - GTK_BIN (button)->child); - - if (gtk_stock_lookup (stock_id, &item)) - { - label = gtk_label_new_with_mnemonic (text); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button)); - - image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON); - hbox = gtk_hbox_new (FALSE, 2); - - align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); - - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (button), align); - gtk_container_add (GTK_CONTAINER (align), hbox); - gtk_widget_show_all (align); - - return button; - } - - label = gtk_label_new_with_mnemonic (text); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (button)); - - gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); - - gtk_widget_show (label); - gtk_container_add (GTK_CONTAINER (button), label); - - return button; -} - -GtkWidget* -gedit_dialog_add_button (GtkDialog *dialog, const gchar* text, const gchar* stock_id, - gint response_id) -{ - GtkWidget *button; - - g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL); - g_return_val_if_fail (text != NULL, NULL); - g_return_val_if_fail (stock_id != NULL, NULL); - - button = gedit_button_new_with_stock_image (text, stock_id); - g_return_val_if_fail (button != NULL, NULL); - - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - - gtk_widget_show (button); - - gtk_dialog_add_action_widget (dialog, button, response_id); - - return button; -} - -/* - * ATTENTION: - * THIS IS AN ATTEMPT TO MAKE A FULLY INTERNATIONALIZED - * CASELESS SEARCH - * IT STILL HAS SOME BUGS - */ - -static gchar *g_utf8_strcasestr(const gchar *haystack, const gchar *needle); - -static gchar * -g_utf8_strcasestr(const gchar *haystack, const gchar *needle) -{ - gsize needle_len; - gsize haystack_len; - gchar *ret = NULL; - gchar *p; - gchar *casefold; - gchar *caseless_haystack; - gchar *caseless_needle; - - g_return_val_if_fail (haystack != NULL, NULL); - g_return_val_if_fail (needle != NULL, NULL); - - casefold = g_utf8_casefold (haystack, -1); - caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL); - g_free (casefold); - - casefold = g_utf8_casefold (needle, -1); - caseless_needle = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL); - g_free (casefold); - - needle_len = g_utf8_strlen (caseless_needle, -1); - haystack_len = g_utf8_strlen (caseless_haystack, -1); - - if (needle_len == 0) - { - ret = (gchar *)haystack; - goto finally_1; - } - - if (haystack_len < needle_len) - { - ret = NULL; - goto finally_1; - } - - p = (gchar*)haystack; - needle_len = strlen (caseless_needle); - - /* Not so efficient */ - while (*p) - { - if ((memcmp (caseless_haystack, caseless_needle, needle_len) == 0)) - { - ret = p; - goto finally_1; - } - - g_free (caseless_haystack); - - p = g_utf8_next_char (p); - - casefold = g_utf8_casefold (p, -1); - caseless_haystack = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL); - g_free (casefold); - } - -finally_1: - - g_free (caseless_needle); - g_free (caseless_haystack); - - return ret; -} - -/* - * n: len of the string in bytes - */ -gboolean -g_utf8_caselessnmatch (const char *s1, const char *s2, gssize n1, gssize n2) -{ - gchar *casefold; - gchar *normalized_s1; - gchar *normalized_s2; - gint len_s1; - gint len_s2; - gboolean ret = FALSE; - - g_return_val_if_fail (s1 != NULL, FALSE); - g_return_val_if_fail (s2 != NULL, FALSE); - g_return_val_if_fail (n1 > 0, FALSE); - g_return_val_if_fail (n2 > 0, FALSE); - - casefold = g_utf8_casefold (s1, n1); - normalized_s1 = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL); - g_free (casefold); - - casefold = g_utf8_casefold (s2, n2); - normalized_s2 = g_utf8_normalize (casefold, -1, G_NORMALIZE_ALL); - g_free (casefold); - - len_s1 = strlen (normalized_s1); - len_s2 = strlen (normalized_s2); - - if (len_s1 != len_s2) - goto finally_2; - - ret = (memcmp (normalized_s1, normalized_s2, len_s1) == 0); - -finally_2: - g_free (normalized_s1); - g_free (normalized_s2); - - return ret; -} - -/********************************************************** - * The following code is a modified version of the gtk one - **********************************************************/ - -/* -gboolean _gtk_text_btree_char_is_invisible (const GtkTextIter *iter); -*/ -#define GTK_TEXT_UNKNOWN_CHAR 0xFFFC - - -static void -forward_chars_with_skipping (GtkTextIter *iter, - gint count, - gboolean skip_invisible, - gboolean skip_nontext) -{ - - gint i; - - g_return_if_fail (count >= 0); - - i = count; - - while (i > 0) - { - gboolean ignored = FALSE; - - if (skip_nontext && - gtk_text_iter_get_char (iter) == GTK_TEXT_UNKNOWN_CHAR) - ignored = TRUE; - - if (!ignored && - skip_invisible && - /* _gtk_text_btree_char_is_invisible (iter)*/ FALSE) - ignored = TRUE; - - gtk_text_iter_forward_char (iter); - - if (!ignored) - --i; - } -} - -static gboolean -lines_match (const GtkTextIter *start, - const gchar **lines, - gboolean visible_only, - gboolean slice, - GtkTextIter *match_start, - GtkTextIter *match_end) -{ - GtkTextIter next; - gchar *line_text; - const gchar *found; - gint offset; - - if (*lines == NULL || **lines == '\0') - { - if (match_start) - *match_start = *start; - - if (match_end) - *match_end = *start; - return TRUE; - } - - next = *start; - gtk_text_iter_forward_line (&next); - - /* No more text in buffer, but *lines is nonempty */ - if (gtk_text_iter_equal (start, &next)) - { - return FALSE; - } - - if (slice) - { - if (visible_only) - line_text = gtk_text_iter_get_visible_slice (start, &next); - else - line_text = gtk_text_iter_get_slice (start, &next); - } - else - { - if (visible_only) - line_text = gtk_text_iter_get_visible_text (start, &next); - else - line_text = gtk_text_iter_get_text (start, &next); - } - - if (match_start) /* if this is the first line we're matching */ - found = g_utf8_strcasestr (line_text, *lines); - else - { - /* If it's not the first line, we have to match from the - * start of the line. - */ - if (g_utf8_caselessnmatch (line_text, *lines, strlen (line_text), strlen (*lines)) == 0) - found = line_text; - else - found = NULL; - } - - if (found == NULL) - { - g_free (line_text); - return FALSE; - } - - /* Get offset to start of search string */ - offset = g_utf8_strlen (line_text, found - line_text); - - next = *start; - - /* If match start needs to be returned, set it to the - * start of the search string. - */ - if (match_start) - { - *match_start = next; - - forward_chars_with_skipping (match_start, offset, - visible_only, !slice); - } - - /* Go to end of search string */ - offset += g_utf8_strlen (*lines, -1); - - forward_chars_with_skipping (&next, offset, - visible_only, !slice); - - g_free (line_text); - - ++lines; - - if (match_end) - *match_end = next; - - /* pass NULL for match_start, since we don't need to find the - * start again. - */ - return lines_match (&next, lines, visible_only, slice, NULL, match_end); -} - -/* strsplit () that retains the delimiter as part of the string. */ -static gchar ** -strbreakup (const char *string, - const char *delimiter, - gint max_tokens) -{ - GSList *string_list = NULL, *slist; - gchar **str_array, *s; - guint i, n = 1; - - g_return_val_if_fail (string != NULL, NULL); - g_return_val_if_fail (delimiter != NULL, NULL); - - if (max_tokens < 1) - max_tokens = G_MAXINT; - - s = strstr (string, delimiter); - if (s) - { - guint delimiter_len = strlen (delimiter); - - do - { - guint len; - gchar *new_string; - - len = s - string + delimiter_len; - new_string = g_new (gchar, len + 1); - strncpy (new_string, string, len); - new_string[len] = 0; - string_list = g_slist_prepend (string_list, new_string); - n++; - string = s + delimiter_len; - s = strstr (string, delimiter); - } - while (--max_tokens && s); - } - if (*string) - { - n++; - string_list = g_slist_prepend (string_list, g_strdup (string)); - } - - str_array = g_new (gchar*, n); - - i = n - 1; - - str_array[i--] = NULL; - for (slist = string_list; slist; slist = slist->next) - str_array[i--] = slist->data; - - g_slist_free (string_list); - - return str_array; -} - -/** - * gedit_text_iter_forward_search: - * @iter: start of search - * @str: a search string - * @flags: flags affecting how the search is done - * @match_start: return location for start of match, or %NULL - * @match_end: return location for end of match, or %NULL - * @limit: bound for the search, or %NULL for the end of the buffer - * - * Searches forward for @str. Any match is returned as the range - * @match_start, @match_end. The search will not continue past - * @limit. Note that a search is a linear or O(n) operation, so you - * may wish to use @limit to avoid locking up your UI on large - * buffers. - * - * If the #GTK_TEXT_SEARCH_VISIBLE_ONLY flag is present, the match may - * have invisible text interspersed in @str. i.e. @str will be a - * possibly-noncontiguous subsequence of the matched range. similarly, - * if you specify #GTK_TEXT_SEARCH_TEXT_ONLY, the match may have - * pixbufs or child widgets mixed inside the matched range. If these - * flags are not given, the match must be exact; the special 0xFFFC - * character in @str will match embedded pixbufs or child widgets. - * - * Return value: whether a match was found - **/ -gboolean -gedit_text_iter_forward_search (const GtkTextIter *iter, - const gchar *str, - GtkTextSearchFlags flags, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit) -{ - gchar **lines = NULL; - GtkTextIter match; - gboolean retval = FALSE; - GtkTextIter search; - gboolean visible_only; - gboolean slice; - - g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (str != NULL, FALSE); - - if ((flags & GTK_TEXT_SEARCH_CASE_INSENSITIVE) == 0) - return gtk_text_iter_forward_search (iter, str, flags, - match_start, match_end, limit); - - if (limit && - gtk_text_iter_compare (iter, limit) >= 0) - return FALSE; - - if (*str == '\0') - { - /* If we can move one char, return the empty string there */ - match = *iter; - - if (gtk_text_iter_forward_char (&match)) - { - if (limit && - gtk_text_iter_equal (&match, limit)) - return FALSE; - - if (match_start) - *match_start = match; - if (match_end) - *match_end = match; - return TRUE; - } - else - return FALSE; - } - - visible_only = (flags & GTK_TEXT_SEARCH_VISIBLE_ONLY) != 0; - slice = (flags & GTK_TEXT_SEARCH_TEXT_ONLY) == 0; - - /* locate all lines */ - - lines = strbreakup (str, "\n", -1); - - search = *iter; - - do - { - /* This loop has an inefficient worst-case, where - * gtk_text_iter_get_text () is called repeatedly on - * a single line. - */ - GtkTextIter end; - - if (limit && - gtk_text_iter_compare (&search, limit) >= 0) - break; - - if (lines_match (&search, (const gchar**)lines, - visible_only, slice, &match, &end)) - { - if (limit == NULL || - (limit && - gtk_text_iter_compare (&end, limit) < 0)) - { - retval = TRUE; - - if (match_start) - *match_start = match; - - if (match_end) - *match_end = end; - - } - - break; - } - } - while (gtk_text_iter_forward_line (&search)); - - g_strfreev ((gchar**)lines); - - return retval; -} - -/************************************************************* - * ERROR REPORTING CODE - ************************************************************/ - -#define MAX_URI_IN_DIALOG_LENGTH 50 - -void -gedit_utils_error_reporting_loading_file ( - const gchar *uri, - GError *error, - GtkWindow *parent) -{ - gchar *scheme_string; - gchar *error_message; - gchar *full_formatted_uri; - gchar *uri_for_display ; - - GnomeVFSURI *vfs_uri; - - GtkWidget *dialog; - - g_return_if_fail (uri != NULL); - g_return_if_fail (error != NULL); - - full_formatted_uri = eel_format_uri_for_display (uri); - - /* Truncate the URI so it doesn't get insanely wide. Note that even - * though the dialog uses wrapped text, if the URI doesn't contain - * white space then the text-wrapping code is too stupid to wrap it. - */ - uri_for_display = eel_str_middle_truncate (full_formatted_uri, - MAX_URI_IN_DIALOG_LENGTH); - g_free (full_formatted_uri); - - switch (error->code) - { - case GNOME_VFS_ERROR_NOT_FOUND: - error_message = g_strdup_printf ( - _("Could not find the file \"%s\".\n\n" - "Please, check that you typed the location correctly and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_CORRUPTED_DATA: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because " - "it contains corrupted data."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_NOT_SUPPORTED: - scheme_string = eel_uri_get_scheme (uri); - - if ((scheme_string != NULL) && g_utf8_validate (scheme_string, -1, NULL)) - { - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because " - "gedit cannot handle %s: locations."), - uri_for_display, scheme_string); - } - else - error_message = g_strdup_printf ( - _("Could not open the file \"%s\""), - uri_for_display); - - if (scheme_string != NULL) - g_free (scheme_string); - - break; - - case GNOME_VFS_ERROR_WRONG_FORMAT: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because " - "it contains data in an invalid format."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_TOO_BIG: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because " - "it is too big."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_INVALID_URI: - error_message = g_strdup_printf ( - _("\"%s\" is not a valid location.\n\n" - "Please, check that you typed the location correctly and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_ACCESS_DENIED: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because " - "access was denied."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_TOO_MANY_OPEN_FILES: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because " - "there are too many open files.\n\n" - "Please, close some open file and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_IS_DIRECTORY: - error_message = g_strdup_printf ( - _("\"%s\" is a directory.\n\n" - "Please, check that you typed the location correctly and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_NO_MEMORY: - error_message = g_strdup_printf ( - _("Not enough available memory to open the file \"%s\". " - "Please, close some running application and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_HOST_NOT_FOUND: - /* This case can be hit for user-typed strings like "foo" due to - * the code that guesses web addresses when there's no initial "/". - * But this case is also hit for legitimate web addresses when - * the proxy is set up wrong. - */ - { - gchar *host_name; - vfs_uri = gnome_vfs_uri_new (uri); - - if (vfs_uri == NULL) - host_name = g_strdup ("XXX"); - else - { - host_name = eel_make_valid_utf8 ( - gnome_vfs_uri_get_host_name (vfs_uri)); - - gnome_vfs_uri_unref (vfs_uri); - } - - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because no host \"%s\" " - "could be found.\n\n" - "Please, check that you typed the location correctly " - "and that your proxy settings are correct and then " - "try again."), - uri_for_display, - host_name); - - g_free (host_name); - } - - break; - - case GNOME_VFS_ERROR_INVALID_HOST_NAME: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because the host name was invalid.\n\n" - "Please, check that you typed the location correctly and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because the host name was empty.\n\n" - "Please, check that your proxy settings are correct and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_LOGIN_FAILED: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because the attempt to " - "log in failed.\n\n" - "Please, check that you typed the location correctly and try again."), - uri_for_display); - break; - - case GEDIT_ERROR_INVALID_UTF8_DATA: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\" because " - "it contains invalid UTF-8 data.\n\n" - "Probably, you are trying to open a binary file."), - uri_for_display); - - break; - - /* - case GNOME_VFS_ERROR_GENERIC: - case GNOME_VFS_ERROR_INTERNAL: - case GNOME_VFS_ERROR_BAD_PARAMETERS: - case GNOME_VFS_ERROR_IO: - case GNOME_VFS_ERROR_BAD_FILE: - case GNOME_VFS_ERROR_NO_SPACE: - case GNOME_VFS_ERROR_READ_ONLY: - case GNOME_VFS_ERROR_NOT_OPEN: - case GNOME_VFS_ERROR_INVALID_OPEN_MODE: - case GNOME_VFS_ERROR_EOF: - case GNOME_VFS_ERROR_NOT_A_DIRECTORY: - case GNOME_VFS_ERROR_IN_PROGRESS: - case GNOME_VFS_ERROR_INTERRUPTED: - case GNOME_VFS_ERROR_FILE_EXISTS: - case GNOME_VFS_ERROR_LOOP: - case GNOME_VFS_ERROR_NOT_PERMITTED: - case GNOME_VFS_ERROR_CANCELLED: - case GNOME_VFS_ERROR_DIRECTORY_BUSY: - case GNOME_VFS_ERROR_DIRECTORY_NOT_EMPTY: - case GNOME_VFS_ERROR_TOO_MANY_LINKS: - case GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM: - case GNOME_VFS_ERROR_NOT_SAME_FILE_SYSTEM: - case GNOME_VFS_ERROR_NAME_TOO_LONG: - case GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE: - case GNOME_VFS_ERROR_SERVICE_OBSOLETE, - case GNOME_VFS_ERROR_PROTOCOL_ERROR, - case GNOME_VFS_NUM_ERRORS: - */ - default: - error_message = g_strdup_printf ( - _("Could not open the file \"%s\"."), - uri_for_display); - - break; - } - - dialog = gtk_message_dialog_new ( - parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - error_message); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (uri_for_display); - g_free (error_message); -} - -void -gedit_utils_error_reporting_saving_file ( - const gchar *uri, - GError *error, - GtkWindow *parent) -{ - gchar *error_message; - gchar *full_formatted_uri; - gchar *uri_for_display ; - - GtkWidget *dialog; - - g_return_if_fail (uri != NULL); - g_return_if_fail (error != NULL); - - full_formatted_uri = eel_format_uri_for_display (uri); - - /* Truncate the URI so it doesn't get insanely wide. Note that even - * though the dialog uses wrapped text, if the URI doesn't contain - * white space then the text-wrapping code is too stupid to wrap it. - */ - uri_for_display = eel_str_middle_truncate (full_formatted_uri, - MAX_URI_IN_DIALOG_LENGTH); - g_free (full_formatted_uri); - - if (strcmp (error->message, " ") == 0) - error_message = g_strdup_printf ( - _("Could not save the file \"%s\"."), - uri_for_display); - else - error_message = g_strdup_printf ( - _("Could not save the file \"%s\".\n\n%s"), - uri_for_display, error->message); - - dialog = gtk_message_dialog_new ( - parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - error_message); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (uri_for_display); - g_free (error_message); -} - -void -gedit_utils_error_reporting_reverting_file ( - const gchar *uri, - GError *error, - GtkWindow *parent) -{ - gchar *scheme_string; - gchar *error_message; - gchar *full_formatted_uri; - gchar *uri_for_display ; - - GnomeVFSURI *vfs_uri; - - GtkWidget *dialog; - - g_return_if_fail (uri != NULL); - g_return_if_fail (error != NULL); - - full_formatted_uri = eel_format_uri_for_display (uri); - - /* Truncate the URI so it doesn't get insanely wide. Note that even - * though the dialog uses wrapped text, if the URI doesn't contain - * white space then the text-wrapping code is too stupid to wrap it. - */ - uri_for_display = eel_str_middle_truncate (full_formatted_uri, - MAX_URI_IN_DIALOG_LENGTH); - g_free (full_formatted_uri); - - switch (error->code) - { - case GNOME_VFS_ERROR_NOT_FOUND: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because gedit cannot find it.\n\n" - "Perhaps, it has recently been deleted."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_CORRUPTED_DATA: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because " - "it contains corrupted data."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_NOT_SUPPORTED: - scheme_string = eel_uri_get_scheme (uri); - - if ((scheme_string != NULL) && g_utf8_validate (scheme_string, -1, NULL)) - { - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because " - "gedit cannot handle %s: locations."), - uri_for_display, scheme_string); - } - else - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\"."), - uri_for_display); - - if (scheme_string != NULL) - g_free (scheme_string); - - break; - - case GNOME_VFS_ERROR_WRONG_FORMAT: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because " - "it contains data in an invalid format."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_TOO_BIG: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because " - "it is too big."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_ACCESS_DENIED: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because " - "access was denied."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_TOO_MANY_OPEN_FILES: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because " - "there are too many open files.\n\n" - "Please, close some open file and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_NO_MEMORY: - error_message = g_strdup_printf ( - _("Not enough available memory to revert the file \"%s\". " - "Please, close some running application and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_HOST_NOT_FOUND: - /* This case can be hit for user-typed strings like "foo" due to - * the code that guesses web addresses when there's no initial "/". - * But this case is also hit for legitimate web addresses when - * the proxy is set up wrong. - */ - { - gchar *host_name; - vfs_uri = gnome_vfs_uri_new (uri); - - if (vfs_uri == NULL) - host_name = g_strdup ("XXX"); - else - { - host_name = eel_make_valid_utf8 ( - gnome_vfs_uri_get_host_name (vfs_uri)); - - gnome_vfs_uri_unref (vfs_uri); - } - - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because no host \"%s\" " - "could be found.\n\n" - "Please, check that your proxy settings are correct and " - "try again."), - uri_for_display, - host_name); - - g_free (host_name); - } - - break; - - case GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because the host name was empty.\n\n" - "Please, check that your proxy settings are correct and try again."), - uri_for_display); - break; - - case GNOME_VFS_ERROR_LOGIN_FAILED: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because the attempt to " - "log in failed."), - uri_for_display); - break; - - case GEDIT_ERROR_INVALID_UTF8_DATA: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\" because " - "it contains invalid UTF-8 data.\n\n" - "Probably, you are trying to revert a binary file."), - uri_for_display); - - break; - - case GEDIT_ERROR_UNTITLED: - error_message = g_strdup_printf ( - _("It is not possible to revert an Untitled document.")); - break; - - /* - case GNOME_VFS_ERROR_INVALID_URI: - case GNOME_VFS_ERROR_INVALID_HOST_NAME: - case GNOME_VFS_ERROR_GENERIC: - case GNOME_VFS_ERROR_INTERNAL: - case GNOME_VFS_ERROR_BAD_PARAMETERS: - case GNOME_VFS_ERROR_IO: - case GNOME_VFS_ERROR_BAD_FILE: - case GNOME_VFS_ERROR_NO_SPACE: - case GNOME_VFS_ERROR_READ_ONLY: - case GNOME_VFS_ERROR_NOT_OPEN: - case GNOME_VFS_ERROR_INVALID_OPEN_MODE: - case GNOME_VFS_ERROR_EOF: - case GNOME_VFS_ERROR_NOT_A_DIRECTORY: - case GNOME_VFS_ERROR_IN_PROGRESS: - case GNOME_VFS_ERROR_INTERRUPTED: - case GNOME_VFS_ERROR_FILE_EXISTS: - case GNOME_VFS_ERROR_LOOP: - case GNOME_VFS_ERROR_NOT_PERMITTED: - case GNOME_VFS_ERROR_CANCELLED: - case GNOME_VFS_ERROR_DIRECTORY_BUSY: - case GNOME_VFS_ERROR_DIRECTORY_NOT_EMPTY: - case GNOME_VFS_ERROR_TOO_MANY_LINKS: - case GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM: - case GNOME_VFS_ERROR_NOT_SAME_FILE_SYSTEM: - case GNOME_VFS_ERROR_NAME_TOO_LONG: - case GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE: - case GNOME_VFS_ERROR_SERVICE_OBSOLETE, - case GNOME_VFS_ERROR_PROTOCOL_ERROR, - case GNOME_VFS_NUM_ERRORS: - case GNOME_VFS_ERROR_IS_DIRECTORY: - - */ - default: - error_message = g_strdup_printf ( - _("Could not revert the file \"%s\"."), - uri_for_display); - - break; - } - - dialog = gtk_message_dialog_new ( - parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - error_message); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (uri_for_display); - g_free (error_message); -} - -void -gedit_utils_error_reporting_creating_file ( - const gchar *uri, - gint error_code, - GtkWindow *parent) -{ - gchar *error_message; - gchar *full_formatted_uri; - gchar *uri_for_display ; - - GtkWidget *dialog; - - g_return_if_fail (uri != NULL); - - full_formatted_uri = eel_format_uri_for_display (uri); - - /* Truncate the URI so it doesn't get insanely wide. Note that even - * though the dialog uses wrapped text, if the URI doesn't contain - * white space then the text-wrapping code is too stupid to wrap it. - */ - uri_for_display = eel_str_middle_truncate (full_formatted_uri, - MAX_URI_IN_DIALOG_LENGTH); - g_free (full_formatted_uri); - - switch (error_code) - { - case EEXIST: - error_message = g_strdup_printf (_("The file \"%s\" already exists."), - uri_for_display); - break; - - case EISDIR: - error_message = g_strdup_printf ( - _("\"%s\" is a directory.\n\n" - "Please, check that you typed the location correctly."), - uri_for_display); - break; - - case EACCES: - case EROFS: - case ETXTBSY: - error_message = g_strdup_printf ( - _("Cannot create the file \"%s\".\n\n" - "Make sure you have the appropriate write permissions."), - uri_for_display); - break; - - case ENAMETOOLONG: - error_message = g_strdup_printf ( - _("Cannot create the file \"%s\".\n\n" - "The file name is too long."), - uri_for_display); - break; - - case ENOENT: - error_message = g_strdup_printf ( - _("Cannot create the file \"%s\".\n\n" - "A directory component in the file name does not exist or " - "is a dangling symbolic link."), - uri_for_display); - break; - - - case ENOSPC: - error_message = g_strdup_printf ( - _("There is not enough disk space to create the file \"%s\".\n\n" - "Please free some disk space and try again."), - uri_for_display); - break; - - default: - error_message = g_strdup_printf (_("Could not create the file \"%s\"."), - uri_for_display); - } - - dialog = gtk_message_dialog_new ( - parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - error_message); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - g_free (uri_for_display); - g_free (error_message); -} - - -/* - * gedit_utils_set_atk_name_description - * @widget : The Gtk widget for which name/description to be set - * @name : Atk name string - * @description : Atk description string - * Description : This function sets up name and description - * for a specified gtk widget. - */ - -void -gedit_utils_set_atk_name_description ( GtkWidget *widget, - const gchar *name, - const gchar *description) -{ - AtkObject *aobj; - - aobj = gtk_widget_get_accessible (widget); - - if (!(GTK_IS_ACCESSIBLE (aobj))) - return; - - if(name) - atk_object_set_name (aobj, name); - - if(description) - atk_object_set_description (aobj, description); -} -/* - * gedit_set_atk__relation - * @obj1,@obj2 : specified widgets. - * @rel_type : the type of relation to set up. - * Description : This function establishes atk relation - * between 2 specified widgets. - */ -void -gedit_utils_set_atk_relation ( GtkWidget *obj1, - GtkWidget *obj2, - AtkRelationType rel_type ) -{ - AtkObject *atk_obj1, *atk_obj2; - AtkRelationSet *relation_set; - AtkObject *targets[1]; - AtkRelation *relation; - - atk_obj1 = gtk_widget_get_accessible (obj1); - atk_obj2 = gtk_widget_get_accessible (obj2); - - if (!(GTK_IS_ACCESSIBLE (atk_obj1)) || !(GTK_IS_ACCESSIBLE (atk_obj2))) - return; - - relation_set = atk_object_ref_relation_set (atk_obj1); - targets[0] = atk_obj2; - - relation = atk_relation_new (targets, 1, rel_type); - atk_relation_set_add (relation_set, relation); - - g_object_unref (G_OBJECT (relation)); -} - -gboolean -gedit_utils_uri_exists (const gchar* text_uri) -{ - GnomeVFSURI *uri; - gboolean res; - - g_return_val_if_fail (text_uri != NULL, FALSE); - - gedit_debug (DEBUG_FILE, "text_uri: %s", text_uri); - - uri = gnome_vfs_uri_new (text_uri); - g_return_val_if_fail (uri != NULL, FALSE); - - res = gnome_vfs_uri_exists (uri); - - gnome_vfs_uri_unref (uri); - - gedit_debug (DEBUG_FILE, res ? "TRUE" : "FALSE"); - - return res; -} - -gchar * -gedit_utils_convert_search_text (const gchar *text) -{ - GString *str; - gint length; - gboolean drop_prev = FALSE; - const gchar *cur; - const gchar *end; - const gchar *prev; - - g_return_val_if_fail (text != NULL, NULL); - - length = strlen (text); - - str = g_string_new (""); - - cur = text; - end = text + length; - prev = NULL; - while (cur != end) { - const gchar *next; - next = g_utf8_next_char (cur); - - if (prev && (*prev == '\\')) { - switch (*cur) { - case 'n': - str = g_string_append (str, "\n"); - break; - case 'r': - str = g_string_append (str, "\r"); - break; - case 't': - str = g_string_append (str, "\t"); - break; - case '\\': - str = g_string_append (str, "\\"); - drop_prev = TRUE; - break; - default: - str = g_string_append (str, "\\"); - str = g_string_append (str, cur); - break; - } - } else if (*cur != '\\') { - str = g_string_append_len (str, cur, next - cur); - } - - if (!drop_prev) - prev = cur; - else { - prev = NULL; - drop_prev = FALSE; - } - - cur = next; - } - - return g_string_free (str, FALSE); -} - -gboolean -gedit_utils_create_empty_file (const gchar *uri) -{ - gchar *canonical_uri; - gchar *filename; - int fd; - - g_return_val_if_fail (uri != NULL, FALSE); - - /* Get filename from uri */ - if (!gedit_utils_uri_has_file_scheme (uri)) - return FALSE; - - canonical_uri = eel_make_uri_canonical (uri); - g_return_val_if_fail (canonical_uri != NULL, FALSE); - - gedit_debug (DEBUG_FILE, "CANONICAL URI: %s", canonical_uri); - - filename = gnome_vfs_get_local_path_from_uri (canonical_uri); - g_free (canonical_uri); - - if (filename == NULL) - { - gedit_debug (DEBUG_FILE, "FILENAME: NULL"); - - return FALSE; - } - - fd = open (filename, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - - g_free (filename); - - if (fd == -1) - return FALSE; - - return (close (fd) == 0); -} diff --git a/gedit/gedit-utils.h b/gedit/gedit-utils.h deleted file mode 100644 index 284968e2c..000000000 --- a/gedit/gedit-utils.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-utils.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_UTILS_H__ -#define __GEDIT_UTILS_H__ - -#include <glib.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtktextiter.h> -#include <atk/atk.h> - -#define GTK_TEXT_SEARCH_CASE_INSENSITIVE (1 << 7) - -void gedit_utils_flash (gchar *msg); -void gedit_utils_flash_va (gchar *format, ...); - -gboolean gedit_utils_is_uri_read_only (const gchar* uri); -gboolean gedit_utils_uri_has_file_scheme (const gchar *uri); - -GtkWidget *gedit_button_new_with_stock_image (const gchar* text, - const gchar* stock_id); - -GtkWidget *gedit_dialog_add_button (GtkDialog *dialog, - const gchar* text, - const gchar* stock_id, - gint response_id); - -gboolean gedit_text_iter_forward_search (const GtkTextIter *iter, - const gchar *str, - GtkTextSearchFlags flags, - GtkTextIter *match_start, - GtkTextIter *match_end, - const GtkTextIter *limit); - -gchar *gedit_utils_str_middle_truncate (const gchar *string, - guint truncate_length); - -void gedit_utils_error_reporting_loading_file (const gchar *uri, - GError *error, - GtkWindow *parent); -void gedit_utils_error_reporting_saving_file (const gchar *uri, - GError *error, - GtkWindow *parent); -void gedit_utils_error_reporting_reverting_file (const gchar *uri, - GError *error, - GtkWindow *parent); -void gedit_utils_error_reporting_creating_file (const gchar *uri, - gint error_code, - GtkWindow *parent); - -gboolean g_utf8_caselessnmatch (const char *s1, const char *s2, gssize n1, gssize n2); - -void gedit_utils_set_atk_name_description (GtkWidget *widget, const gchar *name, - const gchar *description); -void gedit_utils_set_atk_relation (GtkWidget *obj1, GtkWidget *obj2, - AtkRelationType rel_type); - -gboolean gedit_utils_uri_exists (const gchar* text_uri); - -gchar *gedit_utils_convert_search_text (const gchar *text); - -gboolean gedit_utils_create_empty_file (const gchar *uri); - -#endif /* __GEDIT_UTILS_H__ */ - - diff --git a/gedit/gedit-view.c b/gedit/gedit-view.c deleted file mode 100644 index 8d3a171e7..000000000 --- a/gedit/gedit-view.c +++ /dev/null @@ -1,1010 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-view.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnome/gnome-i18n.h> -#include "gedit-view.h" -#include "gedit-debug.h" -#include "gedit-menus.h" -#include "gedit-prefs-manager.h" - -#define MIN_NUMBER_WINDOW_WIDTH 20 - -struct _GeditViewPrivate -{ - GtkTextView *text_view; - - GeditDocument *document; - - gboolean line_numbers_visible; - - GtkWidget *cursor_position_statusbar; - GtkWidget *overwrite_mode_statusbar; - - gboolean overwrite_mode; -}; - - -static void gedit_view_class_init (GeditViewClass *klass); -static void gedit_view_init (GeditView *view); -static void gedit_view_finalize (GObject *object); - -static void gedit_view_update_cursor_position_statusbar - (GtkTextBuffer *buffer, - GeditView* view); -static void gedit_view_cursor_moved (GtkTextBuffer *buffer, - const GtkTextIter *new_location, - GtkTextMark *mark, - gpointer data); -static void gedit_view_update_overwrite_mode_statusbar (GtkTextView* w, GeditView* view); -static void gedit_view_doc_readonly_changed_handler (GeditDocument *document, - gboolean readonly, - GeditView *view); -static gint gedit_view_calculate_real_tab_width (GeditView *view, gint tab_size); - -static void gedit_view_populate_popup (GtkTextView *textview, GtkMenu *menu, gpointer data); -static void gedit_view_undo_activate_callback (GtkWidget *menu_item, GeditDocument *doc); -static void gedit_view_redo_activate_callback (GtkWidget *menu_item, GeditDocument *doc); - -static GtkVBoxClass *parent_class = NULL; - -GType -gedit_view_get_type (void) -{ - static GType view_type = 0; - - if (view_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GeditViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gedit_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GeditView), - 0, /* n_preallocs */ - (GInstanceInitFunc) gedit_view_init - }; - - view_type = g_type_register_static (GTK_TYPE_VBOX, - "GeditView", - &our_info, - 0); - } - - return view_type; -} - -static void -gedit_view_grab_focus (GtkWidget *widget) -{ - GeditView *view; - - gedit_debug (DEBUG_VIEW, ""); - - view = GEDIT_VIEW (widget); - - GTK_TEXT_VIEW (view->priv->text_view)->disable_scroll_on_focus = TRUE; - gtk_widget_grab_focus (GTK_WIDGET (view->priv->text_view)); - GTK_TEXT_VIEW (view->priv->text_view)->disable_scroll_on_focus = FALSE; -} - -static void -gedit_view_doc_readonly_changed_handler (GeditDocument *document, gboolean readonly, - GeditView *view) -{ - gedit_debug (DEBUG_VIEW, ""); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - - gtk_text_view_set_editable (view->priv->text_view, !readonly); -} - - -static void -gedit_view_class_init (GeditViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_view_finalize; - - GTK_WIDGET_CLASS (klass)->grab_focus = gedit_view_grab_focus; -} - -/* This function is taken from gtk+/tests/testtext.c */ -static void -gedit_view_get_lines (GtkTextView *text_view, - gint first_y, - gint last_y, - GArray *buffer_coords, - GArray *numbers, - gint *countp) -{ - GtkTextIter iter; - gint count; - gint size; - gint last_line_num; - - gedit_debug (DEBUG_VIEW, ""); - - g_array_set_size (buffer_coords, 0); - g_array_set_size (numbers, 0); - - /* Get iter at first y */ - gtk_text_view_get_line_at_y (text_view, &iter, first_y, NULL); - - /* For each iter, get its location and add it to the arrays. - * Stop when we pass last_y - */ - count = 0; - size = 0; - - while (!gtk_text_iter_is_end (&iter)) - { - gint y, height; - - gtk_text_view_get_line_yrange (text_view, &iter, &y, &height); - - g_array_append_val (buffer_coords, y); - last_line_num = gtk_text_iter_get_line (&iter); - g_array_append_val (numbers, last_line_num); - - ++count; - - if ((y + height) > last_y) - break; - - gtk_text_iter_forward_line (&iter); - } - - if (gtk_text_iter_is_end (&iter)) - { - gint y, height; - gint line_num; - - gtk_text_view_get_line_yrange (text_view, &iter, &y, &height); - - line_num = gtk_text_iter_get_line (&iter); - - if (line_num != last_line_num) - { - g_array_append_val (buffer_coords, y); - g_array_append_val (numbers, line_num); - ++count; - } - } - - *countp = count; -} - -/* The original version of this function - * is taken from gtk+/tests/testtext.c - */ -static gint -gedit_view_line_numbers_expose (GtkWidget *widget, - GdkEventExpose *event, - GeditDocument *doc) -{ - gint count; - GArray *numbers; - GArray *pixels; - gint first_y; - gint last_y; - gint i; - GdkWindow *left_win; - GdkWindow *right_win; - PangoLayout *layout; - GtkTextView *text_view; - GtkTextWindowType type; - GdkDrawable *target; - gint layout_width; - gchar *str; - - /* It is annoying -- Paolo - * gedit_debug (DEBUG_VIEW, ""); - */ - text_view = GTK_TEXT_VIEW (widget); - - /* See if this expose is on the line numbers window */ - left_win = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_LEFT); - right_win = gtk_text_view_get_window (text_view, - GTK_TEXT_WINDOW_RIGHT); - - if (event->window == left_win) - { - type = GTK_TEXT_WINDOW_LEFT; - target = left_win; - } - else if (event->window == right_win) - { - type = GTK_TEXT_WINDOW_RIGHT; - target = right_win; - } - else - return FALSE; - - first_y = event->area.y; - last_y = first_y + event->area.height; - - gtk_text_view_window_to_buffer_coords (text_view, - type, - 0, - first_y, - NULL, - &first_y); - - gtk_text_view_window_to_buffer_coords (text_view, - type, - 0, - last_y, - NULL, - &last_y); - - numbers = g_array_new (FALSE, FALSE, sizeof (gint)); - pixels = g_array_new (FALSE, FALSE, sizeof (gint)); - - gedit_view_get_lines (text_view, - first_y, - last_y, - pixels, - numbers, - &count); - - layout = gtk_widget_create_pango_layout (widget, ""); - - /* Set size */ - str = g_strdup_printf ("%d", MAX (99, gedit_document_get_line_count (doc))); - pango_layout_set_text (layout, str, -1); - g_free (str); - - pango_layout_get_pixel_size (layout, &layout_width, NULL); - - gtk_text_view_set_border_window_size (GTK_TEXT_VIEW (text_view), - GTK_TEXT_WINDOW_LEFT, - layout_width + 4); - - /* Draw fully internationalized numbers! */ - - i = 0; - while (i < count) - { - gint pos; - - gtk_text_view_buffer_to_window_coords (text_view, - type, - 0, - g_array_index (pixels, gint, i), - NULL, - &pos); - - str = g_strdup_printf ("%d", g_array_index (numbers, gint, i) + 1); - - pango_layout_set_text (layout, str, -1); - - gtk_paint_layout (widget->style, - target, - GTK_WIDGET_STATE (widget), - FALSE, - NULL, - widget, - NULL, - 2, pos, - layout); - - g_free (str); - - ++i; - } - - g_array_free (pixels, TRUE); - g_array_free (numbers, TRUE); - - g_object_unref (G_OBJECT (layout)); - - return TRUE; -} - - -static void -gedit_view_init (GeditView *view) -{ - GtkTextView *text_view; - GtkWidget *sw; /* the scrolled window */ - GdkColor background, text, selection, sel_text; - - gedit_debug (DEBUG_VIEW, ""); - - view->priv = g_new0 (GeditViewPrivate, 1); - - view->priv->document = NULL; - view->priv->line_numbers_visible = FALSE; - - /* Create the scrolled window */ - sw = gtk_scrolled_window_new (NULL, NULL); - g_return_if_fail (sw != NULL); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - text_view = GTK_TEXT_VIEW (gtk_text_view_new ()); - g_return_if_fail (text_view != NULL); - view->priv->text_view = text_view; - - /* - * Set tab, fonts, wrap mode, colors, etc. according - * to preferences - */ - if (!gedit_prefs_manager_get_use_default_font ()) - { - gchar *editor_font = gedit_prefs_manager_get_editor_font (); - - gedit_view_set_font (view, FALSE, editor_font); - - g_free (editor_font); - } - - if (!gedit_prefs_manager_get_use_default_colors ()) - { - background = gedit_prefs_manager_get_background_color (); - text = gedit_prefs_manager_get_text_color (); - selection = gedit_prefs_manager_get_selection_color (); - sel_text = gedit_prefs_manager_get_selected_text_color (); - - gedit_view_set_colors (view, FALSE, - &background, &text, &selection, &sel_text); - } - - gedit_view_set_wrap_mode (view, gedit_prefs_manager_get_wrap_mode ()); - - g_object_set (G_OBJECT (view->priv->text_view), "cursor_visible", TRUE, NULL); - - gtk_box_pack_start (GTK_BOX (view), sw, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (view->priv->text_view)); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_IN); - - gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view->priv->text_view), 2); - gtk_text_view_set_right_margin (GTK_TEXT_VIEW (view->priv->text_view), 2); - - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (view), GTK_CAN_FOCUS); - - g_signal_connect (G_OBJECT (view->priv->text_view), "populate-popup", - G_CALLBACK (gedit_view_populate_popup), view); -} - -static void -gedit_view_finalize (GObject *object) -{ - GeditView *view; - - gedit_debug (DEBUG_VIEW, "%d", object->ref_count); - - g_return_if_fail (object != NULL); - g_return_if_fail (GEDIT_IS_VIEW (object)); - - view = GEDIT_VIEW (object); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - g_return_if_fail (view->priv != NULL); - - g_return_if_fail (view->priv->document != NULL); - g_object_unref (view->priv->document); - view->priv->document = NULL; - - G_OBJECT_CLASS (parent_class)->finalize (object); - - g_free (view->priv); - - gedit_debug (DEBUG_VIEW, "END"); -} - - -/** - * gedit_view_new: - * @doc: a #GeditDocument - * - * Creates a new #GeditView object displaying the @doc document. - * One document can be shared among many views. @doc cannot be NULL. - * The view adds its own reference count to the document; - * it does not take over an existing reference. - * - * Return value: a new #GeditView - **/ -GeditView* -gedit_view_new (GeditDocument *doc) -{ - GeditView *view; - - gedit_debug (DEBUG_VIEW, "START"); - - g_return_val_if_fail (doc != NULL, NULL); - - view = GEDIT_VIEW (g_object_new (GEDIT_TYPE_VIEW, NULL)); - g_return_val_if_fail (view != NULL, NULL); - - gtk_text_view_set_buffer (view->priv->text_view, - GTK_TEXT_BUFFER (doc)); - - view->priv->document = doc; - g_object_ref (view->priv->document); - - gtk_text_view_scroll_to_mark (view->priv->text_view, - gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), "insert"), - 0, TRUE, 0.0, 1.0); - - if (gedit_prefs_manager_get_display_line_numbers ()) - gedit_view_show_line_numbers (view, TRUE); - - gtk_widget_show_all (GTK_WIDGET (view)); - - /* Set tab size: this function must be called after show */ - gedit_view_set_tab_size (view, gedit_prefs_manager_get_tabs_size ()); - - g_signal_connect (GTK_TEXT_BUFFER (doc), - "changed", - G_CALLBACK (gedit_view_update_cursor_position_statusbar), - view); - - g_signal_connect (GTK_TEXT_BUFFER (doc), - "mark_set",/* cursor moved */ - G_CALLBACK (gedit_view_cursor_moved), - view); - - g_signal_connect (GTK_TEXT_VIEW (view->priv->text_view), - "toggle_overwrite",/* cursor moved */ - G_CALLBACK (gedit_view_update_overwrite_mode_statusbar), - view); - - g_signal_connect (doc, - "readonly_changed", - G_CALLBACK (gedit_view_doc_readonly_changed_handler), - view); - - gtk_text_view_set_editable (view->priv->text_view, !gedit_document_is_readonly (doc)); - - - gedit_debug (DEBUG_VIEW, "END: %d", G_OBJECT (view)->ref_count); - - return view; -} - -void -gedit_view_cut_clipboard (GeditView *view) -{ - GtkTextBuffer* buffer = NULL; - - gedit_debug (DEBUG_VIEW, ""); - - buffer = gtk_text_view_get_buffer (view->priv->text_view); - g_return_if_fail (buffer != NULL); - g_return_if_fail (view->priv->document != NULL); - - /* FIXME: what is default editability of a buffer? */ - gtk_text_buffer_cut_clipboard (buffer, - gtk_clipboard_get (GDK_NONE), - !gedit_document_is_readonly (view->priv->document)); - - gtk_text_view_scroll_mark_onscreen (view->priv->text_view, - gtk_text_buffer_get_mark (buffer, - "insert")); -} - -void -gedit_view_copy_clipboard (GeditView *view) -{ - GtkTextBuffer* buffer = NULL; - - gedit_debug (DEBUG_VIEW, ""); - - buffer = gtk_text_view_get_buffer (view->priv->text_view); - g_return_if_fail (buffer != NULL); - - gtk_text_buffer_copy_clipboard (buffer, - gtk_clipboard_get (GDK_NONE)); - - gtk_text_view_scroll_mark_onscreen (view->priv->text_view, - gtk_text_buffer_get_mark (buffer, - "insert")); -} - -void -gedit_view_paste_clipboard (GeditView *view) -{ - GtkTextBuffer* buffer = NULL; - - gedit_debug (DEBUG_VIEW, ""); - - buffer = gtk_text_view_get_buffer (view->priv->text_view); - g_return_if_fail (buffer != NULL); - g_return_if_fail (view->priv->document != NULL); - - /* FIXME: what is default editability of a buffer? */ - gtk_text_buffer_paste_clipboard (buffer, - gtk_clipboard_get (GDK_NONE), - NULL, - !gedit_document_is_readonly (view->priv->document)); - - gtk_text_view_scroll_mark_onscreen (view->priv->text_view, - gtk_text_buffer_get_mark (buffer, - "insert")); -} - -void -gedit_view_delete_selection (GeditView *view) -{ - GtkTextBuffer* buffer = NULL; - - gedit_debug (DEBUG_VIEW, ""); - - buffer = gtk_text_view_get_buffer (view->priv->text_view); - g_return_if_fail (buffer != NULL); - g_return_if_fail (view->priv->document != NULL); - - /* FIXME: what is default editability of a buffer? */ - gtk_text_buffer_delete_selection (buffer, - TRUE, - !gedit_document_is_readonly (view->priv->document)); - - gtk_text_view_scroll_mark_onscreen (view->priv->text_view, - gtk_text_buffer_get_mark (buffer, - "insert")); -} - -void -gedit_view_select_all (GeditView *view) -{ - /* FIXME: it does not select the last char of the buffer */ - GtkTextBuffer* buffer = NULL; - GtkTextIter start_iter, end_iter; - - gedit_debug (DEBUG_VIEW, ""); - - buffer = gtk_text_view_get_buffer (view->priv->text_view); - g_return_if_fail (buffer != NULL); - - gtk_text_buffer_get_start_iter (buffer, &start_iter); - gtk_text_buffer_get_end_iter (buffer, &end_iter); - - gtk_text_buffer_place_cursor (buffer, &end_iter); - - gtk_text_buffer_move_mark (buffer, - gtk_text_buffer_get_mark (buffer, "selection_bound"), - &start_iter); -} - -GeditDocument* -gedit_view_get_document (const GeditView *view) -{ - gedit_debug (DEBUG_VIEW, ""); - - g_return_val_if_fail (GEDIT_IS_VIEW (view), NULL); - g_return_val_if_fail (view->priv != NULL, NULL); - - return view->priv->document; -} - -void -gedit_view_scroll_to_cursor (GeditView *view) -{ - GtkTextBuffer* buffer = NULL; - - gedit_debug (DEBUG_VIEW, ""); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - g_return_if_fail (view->priv != NULL); - - buffer = gtk_text_view_get_buffer (view->priv->text_view); - g_return_if_fail (buffer != NULL); - - gtk_text_view_scroll_mark_onscreen (view->priv->text_view, - gtk_text_buffer_get_mark (buffer, - "insert")); -} - -void -gedit_view_set_colors (GeditView* view, gboolean def, GdkColor* backgroud, GdkColor* text, - GdkColor* selection, GdkColor* sel_text) -{ - gedit_debug (DEBUG_VIEW, ""); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - - if (!def) - { - if (backgroud != NULL) - gtk_widget_modify_base (GTK_WIDGET (view->priv->text_view), - GTK_STATE_NORMAL, backgroud); - - if (text != NULL) - gtk_widget_modify_text (GTK_WIDGET (view->priv->text_view), - GTK_STATE_NORMAL, text); - - if (selection != NULL) - { - gtk_widget_modify_base (GTK_WIDGET (view->priv->text_view), - GTK_STATE_SELECTED, selection); - - gtk_widget_modify_base (GTK_WIDGET (view->priv->text_view), - GTK_STATE_ACTIVE, selection); - } - - if (sel_text != NULL) - { - gtk_widget_modify_text (GTK_WIDGET (view->priv->text_view), - GTK_STATE_SELECTED, sel_text); - - gtk_widget_modify_text (GTK_WIDGET (view->priv->text_view), - GTK_STATE_ACTIVE, sel_text); - } - } - else - { - GtkRcStyle *rc_style; - - rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (view->priv->text_view)); - - rc_style->color_flags [GTK_STATE_NORMAL] = 0; - rc_style->color_flags [GTK_STATE_SELECTED] = 0; - rc_style->color_flags [GTK_STATE_ACTIVE] = 0; - - gtk_widget_modify_style (GTK_WIDGET (view->priv->text_view), rc_style); - } -} - -void -gedit_view_set_font (GeditView* view, gboolean def, const gchar* font_name) -{ - gedit_debug (DEBUG_VIEW, ""); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - - if (!def) - { - PangoFontDescription *font_desc = NULL; - - g_return_if_fail (font_name != NULL); - - font_desc = pango_font_description_from_string (font_name); - g_return_if_fail (font_desc != NULL); - - gtk_widget_modify_font (GTK_WIDGET (view->priv->text_view), font_desc); - - pango_font_description_free (font_desc); - } - else - { - GtkRcStyle *rc_style; - - rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (view->priv->text_view)); - - if (rc_style->font_desc) - pango_font_description_free (rc_style->font_desc); - - rc_style->font_desc = NULL; - - gtk_widget_modify_style (GTK_WIDGET (view->priv->text_view), rc_style); - } -} - -void -gedit_view_set_wrap_mode (GeditView* view, GtkWrapMode wrap_mode) -{ - gedit_debug (DEBUG_VIEW, ""); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view->priv->text_view), wrap_mode); -} - -/* This function is taken from gtksourceview - * - * Copyright (C) 2001 - * Mikael Hermansson<tyan@linux.se> - * Chris Phelps <chicane@reninet.com> - */ - -static gint -gedit_view_calculate_real_tab_width (GeditView *view, gint tab_size) -{ - PangoLayout *layout; - gchar *tab_string; - gint counter = 0; - gint tab_width = 0; - - gedit_debug (DEBUG_VIEW, ""); - - g_return_val_if_fail (GEDIT_IS_VIEW (view), -1); - - if (tab_size == 0) - return -1; - - tab_string = g_malloc (tab_size + 1); - - while (counter < tab_size) { - tab_string [counter] = ' '; - counter++; - } - - tab_string [tab_size] = 0; - - layout = gtk_widget_create_pango_layout ( - GTK_WIDGET (view->priv->text_view), - tab_string); - g_free (tab_string); - - if (layout != NULL) { - pango_layout_get_pixel_size (layout, &tab_width, NULL); - g_object_unref (G_OBJECT (layout)); - } else - tab_width = -1; - - gedit_debug (DEBUG_VIEW, "Tab width: %d", tab_width); - - return tab_width; -} - -void -gedit_view_set_tab_size (GeditView* view, gint tab_size) -{ - PangoTabArray *tab_array; - gint real_tab_width; - - gedit_debug (DEBUG_VIEW, "Tab size: %d", tab_size); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - - real_tab_width = gedit_view_calculate_real_tab_width ( - GEDIT_VIEW (view), - tab_size); - - if (real_tab_width < 0) - { - g_warning ("Impossible to set tab width."); - return; - } - - tab_array = pango_tab_array_new (1, TRUE); - pango_tab_array_set_tab (tab_array, 0, PANGO_TAB_LEFT, real_tab_width); - - gtk_text_view_set_tabs (GTK_TEXT_VIEW (view->priv->text_view), tab_array); - pango_tab_array_free (tab_array); -} - -void -gedit_view_show_line_numbers (GeditView* view, gboolean visible) -{ - gedit_debug (DEBUG_VIEW, ""); - - if (visible) - { - if (!view->priv->line_numbers_visible) - { - gedit_debug (DEBUG_VIEW, "Show line numbers"); - - gtk_text_view_set_border_window_size ( - GTK_TEXT_VIEW (view->priv->text_view), - GTK_TEXT_WINDOW_LEFT, - MIN_NUMBER_WINDOW_WIDTH); - - g_signal_connect ( - G_OBJECT (view->priv->text_view), - "expose_event", - G_CALLBACK (gedit_view_line_numbers_expose), - view->priv->document); - - view->priv->line_numbers_visible = visible; - } - } - else - if (view->priv->line_numbers_visible) - { - gedit_debug (DEBUG_VIEW, "Hide line numbers"); - - gtk_text_view_set_border_window_size ( - GTK_TEXT_VIEW (view->priv->text_view), - GTK_TEXT_WINDOW_LEFT, - 0); - - g_signal_handlers_disconnect_by_func ( - G_OBJECT (view->priv->text_view), - G_CALLBACK (gedit_view_line_numbers_expose), - view->priv->document); - - view->priv->line_numbers_visible = visible; - } -} - -void -gedit_view_set_cursor_position_statusbar (GeditView *view, GtkWidget* status) -{ - gedit_debug (DEBUG_VIEW, ""); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - - view->priv->cursor_position_statusbar = status; - - if ((status != NULL) && (view->priv->document != NULL)) - gedit_view_update_cursor_position_statusbar - (GTK_TEXT_BUFFER (view->priv->document), - view); -} - -void -gedit_view_set_overwrite_mode_statusbar (GeditView *view, GtkWidget* status) -{ - gedit_debug (DEBUG_VIEW, ""); - - g_return_if_fail (GEDIT_IS_VIEW (view)); - - view->priv->overwrite_mode_statusbar = status; - - view->priv->overwrite_mode = !GTK_TEXT_VIEW (view->priv->text_view)->overwrite_mode; - - if (status != NULL) - gedit_view_update_overwrite_mode_statusbar (view->priv->text_view, view); -} - -static void -gedit_view_update_cursor_position_statusbar (GtkTextBuffer *buffer, GeditView* view) -{ - gchar *msg; - gint row, col; - GtkTextIter iter; - - gedit_debug (DEBUG_VIEW, ""); - - if (view->priv->cursor_position_statusbar == NULL) - return; - - /* clear any previous message, underflow is allowed */ - gtk_statusbar_pop (GTK_STATUSBAR (view->priv->cursor_position_statusbar), 0); - - gtk_text_buffer_get_iter_at_mark (buffer, - &iter, - gtk_text_buffer_get_insert (buffer)); - - row = gtk_text_iter_get_line (&iter); - col = gtk_text_iter_get_line_offset (&iter); - msg = g_strdup_printf (_(" Ln %d, Col. %d"), row + 1, col + 1); - - gtk_statusbar_push (GTK_STATUSBAR (view->priv->cursor_position_statusbar), - 0, msg); - - g_free (msg); -} - -static void -gedit_view_cursor_moved (GtkTextBuffer *buffer, - const GtkTextIter *new_location, - GtkTextMark *mark, - gpointer data) -{ - GeditView* view; - - gedit_debug (DEBUG_VIEW, ""); - - view = GEDIT_VIEW (data); - gedit_view_update_cursor_position_statusbar (buffer, view); -} - -static void -gedit_view_update_overwrite_mode_statusbar (GtkTextView* w, GeditView* view) -{ - gchar *msg; - - gedit_debug (DEBUG_VIEW, ""); - - view->priv->overwrite_mode = !view->priv->overwrite_mode; - - if (view->priv->overwrite_mode_statusbar == NULL) - return; - - /* clear any previous message, underflow is allowed */ - gtk_statusbar_pop (GTK_STATUSBAR (view->priv->overwrite_mode_statusbar), 0); - - if (view->priv->overwrite_mode) - msg = g_strdup (_(" OVR")); - else - msg = g_strdup (_(" INS")); - - gtk_statusbar_push (GTK_STATUSBAR (view->priv->overwrite_mode_statusbar), - 0, msg); - - g_free (msg); -} - -static void -gedit_view_undo_activate_callback (GtkWidget *menu_item, GeditDocument *doc) -{ - g_return_if_fail (doc != NULL); - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - - if (gedit_document_can_undo (doc)) - gedit_document_undo (doc); -} - -static void -gedit_view_redo_activate_callback (GtkWidget *menu_item, GeditDocument *doc) -{ - g_return_if_fail (doc != NULL); - g_return_if_fail (GEDIT_IS_DOCUMENT (doc)); - - if (gedit_document_can_redo (doc)) - gedit_document_redo (doc); -} - -static void -gedit_view_populate_popup (GtkTextView *textview, GtkMenu *menu, gpointer data) -{ - GeditView *view; - GeditDocument *doc; - GtkWidget *menu_item; - - g_return_if_fail (menu != NULL); - g_return_if_fail (GTK_IS_MENU_SHELL (menu)); - g_return_if_fail (data != NULL); - g_return_if_fail (GEDIT_IS_VIEW (data)); - - view = GEDIT_VIEW (data); - - doc = gedit_view_get_document (view); - g_return_if_fail (doc != NULL); - - /* Add the separator */ - menu_item = gtk_separator_menu_item_new (); - gtk_widget_show (menu_item); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item); - - /* Add the redo button */ - menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_REDO, NULL); - gtk_widget_set_sensitive (menu_item, gedit_document_can_redo (doc)); - gtk_widget_show (menu_item); - g_signal_connect (G_OBJECT (menu_item), "activate", - G_CALLBACK (gedit_view_redo_activate_callback), doc); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item); - - /* Add the undo button */ - menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_UNDO, NULL); - gtk_widget_set_sensitive (menu_item, gedit_document_can_undo (doc)); - g_signal_connect (G_OBJECT (menu_item), "activate", - G_CALLBACK (gedit_view_undo_activate_callback), doc); - gtk_widget_show (menu_item); - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item); -} - diff --git a/gedit/gedit-view.h b/gedit/gedit-view.h deleted file mode 100644 index f907da6c4..000000000 --- a/gedit/gedit-view.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-view.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence - * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. * * - */ - -/* - * Modified by the gedit Team, 1998-2001. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT_VIEW_H__ -#define __GEDIT_VIEW_H__ - - -#include <gtk/gtk.h> -#include "gedit-document.h" - -#define GEDIT_TYPE_VIEW (gedit_view_get_type ()) -#define GEDIT_VIEW(obj) (GTK_CHECK_CAST ((obj), GEDIT_TYPE_VIEW, GeditView)) -#define GEDIT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_VIEW, GeditViewClass)) -#define GEDIT_IS_VIEW(obj) (GTK_CHECK_TYPE ((obj), GEDIT_TYPE_VIEW)) -#define GEDIT_IS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_VIEW)) -#define GEDIT_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GEDIT_TYPE_VIEW, GeditViewClass)) - - -typedef struct _GeditView GeditView; -typedef struct _GeditViewClass GeditViewClass; - -typedef struct _GeditViewPrivate GeditViewPrivate; - -struct _GeditView -{ - GtkVBox box; - - GeditViewPrivate *priv; -}; - -struct _GeditViewClass -{ - GtkVBoxClass parent_class; -}; - - -GtkType gedit_view_get_type (void) G_GNUC_CONST; - -GeditView* gedit_view_new (GeditDocument *doc); - -void gedit_view_cut_clipboard (GeditView *view); -void gedit_view_copy_clipboard (GeditView *view); -void gedit_view_paste_clipboard (GeditView *view); -void gedit_view_delete_selection (GeditView *view); -void gedit_view_select_all (GeditView *view); - -void gedit_view_scroll_to_cursor (GeditView *view); - -GeditDocument* gedit_view_get_document (const GeditView *view); - -void gedit_view_set_colors (GeditView* view, - gboolean def, - GdkColor* backgroud, GdkColor* text, - GdkColor* selection, GdkColor* sel_text); - -void gedit_view_set_font (GeditView* view, - gboolean def, - const gchar* font_name); - -void gedit_view_set_wrap_mode (GeditView* view, GtkWrapMode wrap_mode); -void gedit_view_set_tab_size (GeditView* view, gint tab_size); - -void gedit_view_show_line_numbers (GeditView* view, gboolean visible); - -void gedit_view_set_cursor_position_statusbar (GeditView *view, GtkWidget* status); -void gedit_view_set_overwrite_mode_statusbar (GeditView *view, GtkWidget* status); - - -#endif /* __GEDIT_VIEW_H__ */ - diff --git a/gedit/gedit-window-server.c b/gedit/gedit-window-server.c deleted file mode 100644 index f3b160d8e..000000000 --- a/gedit/gedit-window-server.c +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit-window-server.c - * This file is part of gedit - * - * Copyright (C) 2002 James Willcox - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-context.h> - -#include "gedit-window-server.h" -#include "gedit-document-server.h" -#include "GNOME_Gedit.h" -#include "gedit-file.h" -#include "gedit-mdi.h" -#include "gedit2.h" - -static void gedit_window_server_class_init (GeditWindowServerClass *klass); -static void gedit_window_server_init (GeditWindowServer *a); -static void gedit_window_server_object_finalize (GObject *object); -static GObjectClass *gedit_window_server_parent_class; - -BonoboObject * -gedit_window_server_new (BonoboWindow *win) -{ - GeditWindowServer *server; - - server = g_object_new (GEDIT_WINDOW_SERVER_TYPE, NULL); - server->win = win; - - return BONOBO_OBJECT (server); -} - -static void -impl_gedit_window_server_openURIList (PortableServer_Servant _servant, - const GNOME_Gedit_URIList * uris, - CORBA_Environment * ev) -{ - GList *list = NULL; - guint i; - - /* convert from CORBA_sequence into GList */ - for (i=0; i < uris->_length; i++) { - list = g_list_append (list, g_strdup (uris->_buffer[i])); - } - - if (list) { - gedit_file_open_uri_list (list, 0, TRUE); - } - - g_list_foreach (list, (GFunc)g_free, NULL); - g_list_free (list); -} - -static GNOME_Gedit_Document -impl_gedit_window_server_newDocument (PortableServer_Servant _servant, - CORBA_Environment * ev) -{ - GeditDocument *doc; - BonoboObject *doc_server; - - gedit_file_new (); - - doc = gedit_get_active_document (); - - doc_server = gedit_document_server_new (doc); - - return BONOBO_OBJREF (doc_server); -} - -static void -impl_gedit_window_server_grabFocus (PortableServer_Servant _servant, - CORBA_Environment * ev) -{ - BonoboWindow *window; - - window = gedit_get_active_window (); - gtk_window_present (GTK_WINDOW (window)); -} - -static void -gedit_window_server_class_init (GeditWindowServerClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - POA_GNOME_Gedit_Window__epv *epv = &klass->epv; - - gedit_window_server_parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = gedit_window_server_object_finalize; - - /* connect implementation callbacks */ - epv->newDocument = impl_gedit_window_server_newDocument; - epv->openURIList = impl_gedit_window_server_openURIList; - epv->grabFocus = impl_gedit_window_server_grabFocus; -} - -static void -gedit_window_server_init (GeditWindowServer *c) -{ -} - -static void -gedit_window_server_object_finalize (GObject *object) -{ - GeditWindowServer *a = GEDIT_WINDOW_SERVER (object); - - gedit_window_server_parent_class->finalize (G_OBJECT (a)); -} - -BONOBO_TYPE_FUNC_FULL ( - GeditWindowServer, - GNOME_Gedit_Window, - BONOBO_TYPE_OBJECT, - gedit_window_server); diff --git a/gedit/gedit-window-server.h b/gedit/gedit-window-server.h deleted file mode 100644 index c6557b84f..000000000 --- a/gedit/gedit-window-server.h +++ /dev/null @@ -1,39 +0,0 @@ - -#ifndef __GEDIT_WINDOW_SERVER_H -#define __GEDIT_WINDOW_SERVER_H - -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-object.h> -#include <bonobo/bonobo-window.h> -#include "GNOME_Gedit.h" - -G_BEGIN_DECLS - -#define GEDIT_WINDOW_SERVER_TYPE (gedit_window_server_get_type ()) -#define GEDIT_WINDOW_SERVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GEDIT_WINDOW_SERVER_TYPE, GeditWindowServer)) -#define GEDIT_WINDOW_SERVER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GEDIT_WINDOW_SERVER_TYPE, GeditWindowServerClass)) -#define GEDIT_WINDOW_SERVER_IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GEDIT_WINDOW_SERVER_TYPE)) -#define GEDIT_WINDOW_SERVER_IS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GEDIT_WINDOW_SERVER_TYPE)) -#define GEDIT_WINDOW_SERVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GEDIT_WINDOW_SERVER_TYPE, GeditWindowServerClass)) - -typedef struct -{ - BonoboObject parent; - - BonoboWindow *win; -} GeditWindowServer; - -typedef struct -{ - BonoboObjectClass parent_class; - - POA_GNOME_Gedit_Window__epv epv; -} GeditWindowServerClass; - -GType gedit_window_server_get_type (void); - -BonoboObject *gedit_window_server_new (BonoboWindow *win); - -G_END_DECLS - -#endif /* __GEDIT_WINDOW_SERVER_H */ diff --git a/gedit/gedit2.c b/gedit/gedit2.c deleted file mode 100644 index befd9b94a..000000000 --- a/gedit/gedit2.c +++ /dev/null @@ -1,432 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit2.c - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence, Jason Leach - * Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#include <config.h> - -#include <libgnome/libgnome.h> -#include <libgnomeui/libgnomeui.h> -#include <libgnomeui/gnome-window-icon.h> -#include <eel/eel-vfs-extensions.h> - -#include "gedit2.h" -#include "gedit-mdi.h" -#include "gedit-prefs-manager.h" -#include "gedit-debug.h" -#include "gedit-file.h" -#include "gedit-utils.h" -#include "gedit-session.h" -#include "gedit-plugins-engine.h" -#include "gedit-application-server.h" - -#ifndef GNOME_ICONDIR -#define GNOME_ICONDIR "" -#endif - -GeditMDI *gedit_mdi = NULL; -gboolean gedit_close_x_button_pressed = FALSE; -gboolean gedit_exit_button_pressed = FALSE; -BonoboObject *gedit_app_server = NULL; - -static gboolean quit_option = FALSE; -static gboolean new_window_option = FALSE; -static gboolean new_document_option = FALSE; - -typedef struct _CommandLineData CommandLineData; - -struct _CommandLineData -{ - GList* file_list; - gint line_pos; -}; - -static void gedit_set_default_icon (); -static void gedit_load_file_list (CommandLineData *data); - -static const struct poptOption options [] = -{ - { "debug-mdi", '\0', POPT_ARG_NONE, &debug_mdi, 0, - N_("Show mdi debugging messages."), NULL }, - - { "debug-commands", '\0', POPT_ARG_NONE, &debug_commands, 0, - N_("Show commands debugging messages."), NULL }, - - { "debug-document", '\0', POPT_ARG_NONE, &debug_document, 0, - N_("Show document debugging messages."), NULL }, - - { "debug-file", '\0', POPT_ARG_NONE, &debug_file, 0, - N_("Show file debugging messages."), NULL }, - - { "debug-plugins", '\0', POPT_ARG_NONE, &debug_plugins, 0, - N_("Show plugin debugging messages."), NULL }, - - { "debug-prefs", '\0', POPT_ARG_NONE, &debug_prefs, 0, - N_("Show prefs debugging messages."), NULL }, - - { "debug-print", '\0', POPT_ARG_NONE, &debug_print, 0, - N_("Show printing debugging messages."), NULL }, - - { "debug-search", '\0', POPT_ARG_NONE, &debug_search, 0, - N_("Show search debugging messages."), NULL }, - - { "debug-undo", '\0', POPT_ARG_NONE, &debug_undo, 0, - N_("Show undo debugging messages."), NULL }, - - { "debug-view", '\0', POPT_ARG_NONE, &debug_view, 0, - N_("Show view debugging messages."), NULL }, - - { "debug-recent", '\0', POPT_ARG_NONE, &debug_recent, 0, - N_("Show recent debugging messages."), NULL }, - - { "debug-session", '\0', POPT_ARG_NONE, &debug_session, 0, - N_("Show session management debugging messages."), NULL }, - - { "debug", '\0', POPT_ARG_NONE, &debug, 0, - N_("Turn on all debugging messages."), NULL }, - - { "quit", '\0', POPT_ARG_NONE, &quit_option, 0, - N_("Quit an existing instance of gedit"), NULL }, - - { "new-window", '\0', POPT_ARG_NONE, &new_window_option, 0, - N_("Create a new toplevel window in an existing instance of gedit"), NULL }, - - { "new-document", '\0', POPT_ARG_NONE, &new_document_option, 0, - N_("Create a new document in an existing instance of gedit"), NULL }, - - {NULL, '\0', 0, NULL, 0} -}; - -static void -gedit_set_default_icon () -{ - if (!g_file_test (GNOME_ICONDIR "/gedit-icon.png", G_FILE_TEST_EXISTS)) - { - g_warning ("Could not find %s", GNOME_ICONDIR "/gedit-icon.png"); - - /* In case we haven't yet been installed */ - gnome_window_icon_set_default_from_file ("../pixmaps/gedit-icon.png"); - } - else - { - gnome_window_icon_set_default_from_file (GNOME_ICONDIR "/gedit-icon.png"); - } -} - -static void -gedit_load_file_list (CommandLineData *data) -{ - gboolean res; - - res = gedit_file_open_from_stdin (NULL); - - if (!data) - { - if (!res) - gedit_file_new (); - return; - } - - /* Update UI */ - while (gtk_events_pending ()) - gtk_main_iteration (); - - /* Load files */ - if (!gedit_file_open_uri_list (data->file_list, data->line_pos, TRUE) && !res) - /* If no file is opened then create a new empty untitled document */ - gedit_file_new (); - - g_list_free (data->file_list); - g_free (data); -} - - -static CommandLineData * -gedit_get_command_line_data (GnomeProgram *program) -{ - GValue value = { 0, }; - poptContext ctx; - char **args; - CommandLineData *data = NULL; - int i; - - g_value_init (&value, G_TYPE_POINTER); - g_object_get_property (G_OBJECT (program), GNOME_PARAM_POPT_CONTEXT, &value); - ctx = g_value_get_pointer (&value); - g_value_unset (&value); - - args = (char**) poptGetArgs(ctx); - - - if (args) - { - data = g_new0 (CommandLineData, 1); - for (i = 0; args[i]; i++) - { - if (*args[i] == '+') - data->line_pos = atoi (args[i] + 1); - else - data->file_list = g_list_append (data->file_list, - eel_make_uri_from_shell_arg (args[i])); - } - } - - return data; -} - - - -static void -gedit_handle_automation_cmdline (GnomeProgram *program) -{ - CORBA_Environment env; - GNOME_Gedit_Application server; - GNOME_Gedit_Window window; - GNOME_Gedit_Document document; - CommandLineData *data; - GNOME_Gedit_URIList *uri_list; - GList *list; - int i; - - CORBA_exception_init (&env); - - server = bonobo_activation_activate_from_id ("OAFIID:GNOME_Gedit_Application", - 0, NULL, &env); - g_return_if_fail (server != NULL); - - if (quit_option) - GNOME_Gedit_Application_quit (server, &env); - - - if (new_window_option) - GNOME_Gedit_Application_newWindow (server, &env); - - if (new_document_option) - { - window = GNOME_Gedit_Application_getActiveWindow (server, &env); - GNOME_Gedit_Window_newDocument (window, &env); - } - - data = gedit_get_command_line_data (program); - - if (data) - { - window = GNOME_Gedit_Application_getActiveWindow (server, &env); - - /* convert the GList of files into a CORBA sequence */ - - uri_list = GNOME_Gedit_URIList__alloc (); - uri_list->_maximum = g_list_length (data->file_list); - uri_list->_length = uri_list->_maximum; - uri_list->_buffer = CORBA_sequence_GNOME_Gedit_URI_allocbuf (uri_list->_length); - - list = data->file_list; - i=0; - while (list != NULL) - { - uri_list->_buffer[i] = CORBA_string_dup ((gchar*)list->data); - list = list->next; - i++; - } - - CORBA_sequence_set_release (uri_list, CORBA_TRUE); - GNOME_Gedit_Window_openURIList (window, uri_list, &env); - - document = GNOME_Gedit_Application_getActiveDocument (server, &env); - - GNOME_Gedit_Document_setLinePosition (document, data->line_pos, &env); - - g_list_foreach (data->file_list, (GFunc)g_free, NULL); - g_list_free (data->file_list); - g_free (data); - } - - if (!quit_option) - { - window = GNOME_Gedit_Application_getActiveWindow (server, &env); - - /* at the very least, we focus the active window */ - GNOME_Gedit_Window_grabFocus (window, &env); - } - - bonobo_object_release_unref (server, &env); - CORBA_exception_free (&env); -} - -int -main (int argc, char **argv) -{ - GnomeProgram *program; - gboolean restored = FALSE; - CORBA_Object factory; - - bindtextdomain (GETTEXT_PACKAGE, GEDIT_LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - /* Initialize gnome program */ - program = gnome_program_init ("gedit", VERSION, - LIBGNOMEUI_MODULE, argc, argv, - GNOME_PARAM_POPT_TABLE, options, - GNOME_PARAM_HUMAN_READABLE_NAME, - _("Text Editor"), - GNOME_PARAM_APP_DATADIR, DATADIR, - NULL); - - /* check whether we are running already */ - factory = bonobo_activation_activate_from_id - ("OAFIID:GNOME_Gedit_Factory", - Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, - NULL, NULL); - - if (factory != NULL) - { - /* there is an instance already running, so send - * commands to it if needed - */ - gedit_handle_automation_cmdline (program); - - /* and we're done */ - exit (0); - } - - /* Set default icon */ - gedit_set_default_icon (); - - /* Load user preferences */ - gedit_prefs_manager_init (); - gedit_recent_init (); - - /* Init plugins engine */ - gedit_plugins_engine_init (); - - /* Initialize session management */ - gedit_session_init (argv[0]); - - /* Create our MDI object */ - gedit_mdi = gedit_mdi_new (); - - if (gedit_session_is_restored ()) - restored = gedit_session_load (); - - if (!restored) - { - CommandLineData *data; - - data = gedit_get_command_line_data (program); - - gtk_init_add ((GtkFunction)gedit_load_file_list, (gpointer)data); - - /* Open the first top level window */ - bonobo_mdi_open_toplevel (BONOBO_MDI (gedit_mdi), NULL); - } - - gedit_app_server = gedit_application_server_new (); - - gtk_main(); - - return 0; -} - - -BonoboWindow* -gedit_get_active_window (void) -{ - g_return_val_if_fail (gedit_mdi != NULL, NULL); - - return bonobo_mdi_get_active_window (BONOBO_MDI (gedit_mdi)); -} - -GeditDocument* -gedit_get_active_document (void) -{ - BonoboMDIChild *active_child; - - g_return_val_if_fail (gedit_mdi != NULL, NULL); - - active_child = bonobo_mdi_get_active_child (BONOBO_MDI (gedit_mdi)); - - if (active_child == NULL) - return NULL; - - return GEDIT_MDI_CHILD (active_child)->document; -} - -GeditView* -gedit_get_active_view (void) -{ - GtkWidget *active_view; - - g_return_val_if_fail (gedit_mdi != NULL, NULL); - - active_view = bonobo_mdi_get_active_view (BONOBO_MDI (gedit_mdi)); - - if (active_view == NULL) - return NULL; - - return GEDIT_VIEW (active_view); -} - -GList* -gedit_get_top_windows (void) -{ - g_return_val_if_fail (gedit_mdi != NULL, NULL); - - return bonobo_mdi_get_windows (BONOBO_MDI (gedit_mdi)); -} - -BonoboUIComponent* -gedit_get_ui_component_from_window (BonoboWindow* win) -{ - g_return_val_if_fail (win != NULL, NULL); - - return bonobo_mdi_get_ui_component_from_window (win); -} - -/* Return a newly allocated list */ -GList* -gedit_get_open_documents (void) -{ - GList* children; - GList* docs = NULL; - g_return_val_if_fail (gedit_mdi != NULL, NULL); - - children = bonobo_mdi_get_children (BONOBO_MDI (gedit_mdi)); - - while (children != NULL) - { - GeditMDIChild *child; - - child = GEDIT_MDI_CHILD (children->data); - - docs = g_list_append (docs, child->document); - children = g_list_next (children); - } - - return docs; -} diff --git a/gedit/gedit2.h b/gedit/gedit2.h deleted file mode 100644 index bb8c3f591..000000000 --- a/gedit/gedit2.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gedit2.h - * This file is part of gedit - * - * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence, Jason Leach - * Copyright (C) 2000, 2002 Chema Celorio, Paolo Maggi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * Modified by the gedit Team, 1998-2002. See the AUTHORS file for a - * list of people on the gedit Team. - * See the ChangeLog files for a list of changes. - */ - -#ifndef __GEDIT2_H__ -#define __GEDIT2_H__ - -#include <gmodule.h> -#include <glib/glist.h> -#include <bonobo/bonobo-object.h> -#include <bonobo/bonobo-window.h> - -#include "gedit-mdi.h" -#include "gedit-document.h" -#include "gedit-view.h" - -extern GeditMDI* gedit_mdi; -extern gboolean gedit_close_x_button_pressed; -extern gboolean gedit_exit_button_pressed; -extern BonoboObject *gedit_app_server; - -BonoboWindow* gedit_get_active_window (void); -GeditDocument* gedit_get_active_document (void); -GeditView* gedit_get_active_view (void); -GList* gedit_get_top_windows (void); -BonoboUIComponent* gedit_get_ui_component_from_window (BonoboWindow* win); -GList* gedit_get_open_documents (void); - - -#endif /* __GEDIT2_H__ */ - - - diff --git a/gedit/gnome-recent-marshal.list b/gedit/gnome-recent-marshal.list deleted file mode 100644 index 1e99a95aa..000000000 --- a/gedit/gnome-recent-marshal.list +++ /dev/null @@ -1 +0,0 @@ -BOOL:STRING diff --git a/gedit/gnome-recent-model.c b/gedit/gnome-recent-model.c deleted file mode 100644 index 5e5ff5a18..000000000 --- a/gedit/gnome-recent-model.c +++ /dev/null @@ -1,874 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/** - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - * - * Authors: - * James Willcox <jwillcox@cs.indiana.edu> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <gtk/gtk.h> -#include <gconf/gconf-client.h> -#include <libbonoboui.h> -#include <libgnomevfs/gnome-vfs.h> -#include "gnome-recent-model.h" -#include "gnome-recent-view.h" -#include <eel/eel-vfs-extensions.h> - -#define GNOME_RECENT_MODEL_BASE_KEY "/desktop/gnome/recent_files" -#define GNOME_RECENT_MODEL_GLOBAL_LIMIT_KEY "global_limit" -#define GNOME_RECENT_MODEL_GLOBAL_LIMIT_ENV "GNOME_RECENT_MODEL_GLOBAL_LIMIT" -#define GNOME_RECENT_MODEL_GLOBAL_LIST "gnome-recent-global" - -static void gnome_recent_model_class_init (GnomeRecentModelClass * klass); -static void gnome_recent_model_init (GnomeRecentModel * recent); -static gchar *gnome_recent_model_gconf_key (GnomeRecentModel * recent); -static void gnome_recent_model_notify_cb (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - gpointer user_data); -static GSList * gnome_recent_model_delete_from_list (GnomeRecentModel *recent, - GSList *list, - const gchar *uri); -static GSList * gnome_recent_model_gconf_to_list (GConfValue* value); -static void gnome_recent_model_g_slist_deep_free (GSList *list); -static void gnome_recent_model_set_appname (GnomeRecentModel *recent, gchar *appname); - -struct _GnomeRecentModel { - GObject parent_instance; /* We emit signals */ - - gchar *appname; /* the app that owns this object */ - GConfClient *gconf_client; /* we use GConf to store stuff */ - unsigned int limit; /* maximum number of items to store */ - - GnomeRecentModel *global; /* Another GnomeRecentModel object, - * representing the global - * recent uri list - */ - - GHashTable *monitors; /* A hash table holding - * GnomeVfsMonitorHandle objects. - */ -}; - -struct _GnomeRecentModelClass { - GObjectClass parent_class; - - void (*changed) (GnomeRecentModel *recent, const GSList *list); -}; - -struct _GnomeRecentModelMenuData { - GnomeRecentModel *recent; - gchar *uri; -}; - -typedef struct _GnomeRecentModelMenuData GnomeRecentModelMenuData; - -enum { - CHANGED, - LAST_SIGNAL -}; - -/* GObject properties */ -enum { - PROP_BOGUS, - PROP_APPNAME, - PROP_LIMIT -}; - -static GType model_signals[LAST_SIGNAL] = { 0 }; -static GObjectClass *parent_class = NULL; - - -#if 0 -static void -print_list (GSList *list) -{ - while (list) { - g_print ("%s, ", (char *)list->data); - - list = list->next; - } - g_print ("\n\n"); -} -#endif - -/** - * gnome_recent_model_get_type: - * @: - * - * This returns a GType representing a GnomeRecentModel object. - * - * Returns: a GType - */ -GType -gnome_recent_model_get_type (void) -{ - static GType gnome_recent_model_type = 0; - - if(!gnome_recent_model_type) { - static const GTypeInfo gnome_recent_model_info = { - sizeof (GnomeRecentModelClass), - NULL, /* base init */ - NULL, /* base finalize */ - (GClassInitFunc)gnome_recent_model_class_init, /* class init */ - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (GnomeRecentModel), - 0, - (GInstanceInitFunc) gnome_recent_model_init - }; - - gnome_recent_model_type = g_type_register_static (G_TYPE_OBJECT, - "GnomeRecentModel", - &gnome_recent_model_info, 0); - } - - return gnome_recent_model_type; -} - -static void -gnome_recent_model_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GnomeRecentModel *recent = GNOME_RECENT_MODEL (object); - gchar *appname; - - switch (prop_id) - { - case PROP_APPNAME: - appname = g_strdup (g_value_get_string (value)); - gnome_recent_model_set_appname (recent, appname); - break; - case PROP_LIMIT: - gnome_recent_model_set_limit (GNOME_RECENT_MODEL (recent), - g_value_get_int (value)); - break; - default: - break; - } -} - -static void -gnome_recent_model_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GnomeRecentModel *recent = GNOME_RECENT_MODEL (object); - - switch (prop_id) - { - case PROP_APPNAME: - g_value_set_string (value, recent->appname); - break; - case PROP_LIMIT: - g_value_set_int (value, recent->limit); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -gnome_recent_model_class_init (GnomeRecentModelClass * klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->set_property = gnome_recent_model_set_property; - object_class->get_property = gnome_recent_model_get_property; - - model_signals[CHANGED] = g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GnomeRecentModelClass, changed), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - - g_object_class_install_property (object_class, - PROP_APPNAME, - g_param_spec_string ("appname", - "Application Name", - "The name of the application using this object.", - "gnome-app", - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_LIMIT, - g_param_spec_int ("limit", - "Limit", - "The maximum number of items to be allowed in the list.", - 1, - 1000, - 10, - G_PARAM_READWRITE)); - - klass->changed = NULL; -} - - -static void -gnome_recent_model_init (GnomeRecentModel * recent) -{ - int argc=0; - char **argv=NULL; - - if (!gconf_init (argc, argv, NULL)) - { - g_warning ("GConf Initialization failed."); - return; - } - - if (!gnome_vfs_init ()) { - g_warning ("gnome-vfs initialization failed."); - return; - } - - recent->gconf_client = gconf_client_get_default (); - recent->monitors = g_hash_table_new (g_str_hash, g_str_equal); -} - -static gint -gnome_recent_model_get_global_limit (GnomeRecentModel *model) -{ - char *key; - gint limit; - - key = g_strdup_printf ("%s/%s", GNOME_RECENT_MODEL_BASE_KEY, - GNOME_RECENT_MODEL_GLOBAL_LIMIT_KEY); - - - limit = gconf_client_get_int (model->gconf_client, - key, NULL); - - if (limit <= 0) { - /* ok, gconf schemas are not functioning, so assign a sane value */ - limit = 10; - } - - g_free (key); - - return limit; -} - - -/** - * gnome_recent_model_new: - * @appname: The name of your application. - * @limit: The maximum number of items allowed. - * - * This creates a new GnomeRecentModel object. - * - * Returns: a GnomeRecentModel object - */ -GnomeRecentModel * -gnome_recent_model_new (const gchar *appname, gint limit) -{ - GnomeRecentModel *model; - - g_return_val_if_fail (appname, NULL); - g_return_val_if_fail (limit > 0, NULL); - - model = GNOME_RECENT_MODEL (g_object_new (gnome_recent_model_get_type (), - "appname", - appname, - "limit", - limit, NULL)); - - g_return_val_if_fail (model, NULL); - - return model; -} - -/** - * gnome_recent_model_new_global: - * @ - * - * This creates a new GnomeRecentModel object, with the global history list. - * - * Returns: a GnomeRecentModel object - */ -GnomeRecentModel * -gnome_recent_model_new_global (void) -{ - GnomeRecentModel *model; - gint limit; - - model = GNOME_RECENT_MODEL (g_object_new(gnome_recent_model_get_type (), - "appname", - GNOME_RECENT_MODEL_GLOBAL_LIST, - NULL)); - - g_return_val_if_fail (model, NULL); - - limit = gnome_recent_model_get_global_limit (model); - gnome_recent_model_set_limit (model, limit); - - return model; -} - - - -static void -gnome_recent_model_monitor_cb (GnomeVFSMonitorHandle *handle, - const gchar *monitor_uri, - const gchar *info_uri, - GnomeVFSMonitorEventType event_type, - gpointer data) -{ - GnomeRecentModel *recent= GNOME_RECENT_MODEL (data); - - g_return_if_fail (recent); - - /* if a file was deleted, we just remove it from our list */ - switch (event_type) { - case GNOME_VFS_MONITOR_EVENT_DELETED: - gnome_recent_model_delete (recent, monitor_uri); - g_hash_table_remove (recent->monitors, monitor_uri); - break; - default: - break; - } - -} - -static void -gnome_recent_model_monitor_uri (GnomeRecentModel *recent, const gchar *uri) -{ - GnomeVFSMonitorHandle *handle=NULL; - GnomeVFSResult result; - - g_return_if_fail (recent); - g_return_if_fail (GNOME_IS_RECENT_MODEL (recent)); - g_return_if_fail (uri); - - handle = g_hash_table_lookup (recent->monitors, uri); - if (handle == NULL) { - - /* this is a new uri, so we need to monitor it */ - result = gnome_vfs_monitor_add (&handle, - uri, - GNOME_VFS_MONITOR_FILE, - gnome_recent_model_monitor_cb, - recent); - if (result == GNOME_VFS_OK) { - g_hash_table_insert (recent->monitors, - g_strdup (uri), - handle); - } - } -} - -static void -gnome_recent_model_monitor_uri_list (GnomeRecentModel *recent, - GSList *list) -{ - GSList *p; - const gchar *uri; - - p = list; - while (p != NULL) { - uri = (const gchar *)p->data; - - gnome_recent_model_monitor_uri (recent, uri); - - p = p->next; - } -} - -#if 0 -static void -gnome_recent_model_monitor_cancel (GnomeRecentModel *recent, const gchar *uri) -{ - g_return_if_fail (recent); - g_return_if_fail (GNOME_IS_RECENT_MODEL (recent)); - g_return_if_fail (uri); - - g_hash_table_remove (recent->monitors, uri); -} -#endif - -/** - * gnome_recent_model_add: - * @recent: A GnomeRecentModel object. - * @uri: The URI you want to add to the list. - * - * This function adds a URI to the list of recently used URIs. - * - * Returns: a gboolean - */ -gboolean -gnome_recent_model_add (GnomeRecentModel * recent, const gchar * uri) -{ - GSList *uri_lst; - gchar *gconf_key; - gchar *utf8_uri; - gchar *canonical_uri; - - g_return_val_if_fail (recent, FALSE); - g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), FALSE); - g_return_val_if_fail (recent->gconf_client, FALSE); - g_return_val_if_fail (uri, FALSE); - - canonical_uri = eel_make_uri_canonical (uri); - g_return_val_if_fail (canonical_uri != NULL, FALSE); - - utf8_uri = g_filename_to_utf8 (canonical_uri, -1, NULL, NULL, NULL); - g_free (canonical_uri); - - if (utf8_uri == NULL) { - g_warning ("Couldn't add %s to recent file list", uri); - return FALSE; - } - - gconf_key = gnome_recent_model_gconf_key (recent); - - - uri_lst = gconf_client_get_list (recent->gconf_client, - gconf_key, - GCONF_VALUE_STRING, NULL); - - /* if this is already in our list, remove it */ - uri_lst = gnome_recent_model_delete_from_list (recent, uri_lst, - utf8_uri); - - /* prepend the new one */ - uri_lst = g_slist_prepend (uri_lst, g_strdup (utf8_uri)); - - /* if we're over the limit, delete from the end */ - while (g_slist_length (uri_lst) > recent->limit) - { - gchar *tmp_uri; - tmp_uri = g_slist_nth_data (uri_lst, g_slist_length (uri_lst)-1); - uri_lst = g_slist_remove (uri_lst, tmp_uri); - g_free (tmp_uri); - } - - gconf_client_set_list (recent->gconf_client, - gconf_key, - GCONF_VALUE_STRING, - uri_lst, NULL); - - gconf_client_suggest_sync (recent->gconf_client, NULL); - - /* add to the global list */ - if (recent->global) - gnome_recent_model_add (GNOME_RECENT_MODEL (recent->global), uri); - - g_free (gconf_key); - gnome_recent_model_g_slist_deep_free (uri_lst); - - g_free (utf8_uri); - - return TRUE; -} - - -/** - * gnome_recent_model_delete: - * @recent: A GnomeRecentModel object. - * @uri: The URI you want to delete from the list. - * - * This function deletes a URI from the list of recently used URIs. - * - * Returns: a gboolean - */ -gboolean -gnome_recent_model_delete (GnomeRecentModel * recent, const gchar * uri) -{ - GSList *uri_lst; - GSList *new_uri_lst; - gboolean ret = FALSE; - gchar *gconf_key; - gchar *utf8_uri; - gchar *canonical_uri; - - g_return_val_if_fail (recent, FALSE); - g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), FALSE); - g_return_val_if_fail (recent->gconf_client, FALSE); - g_return_val_if_fail (uri, FALSE); - - canonical_uri = eel_make_uri_canonical (uri); - g_return_val_if_fail (canonical_uri != NULL, FALSE); - - utf8_uri = g_filename_to_utf8 (canonical_uri, -1, NULL, NULL, NULL); - if (utf8_uri == NULL) { - g_warning ("Couldn't remove %s from recent file list", uri); - return FALSE; - } - - gconf_key = gnome_recent_model_gconf_key (recent); - uri_lst = gconf_client_get_list (recent->gconf_client, - gconf_key, - GCONF_VALUE_STRING, NULL); - - new_uri_lst = gnome_recent_model_delete_from_list (recent, uri_lst, - utf8_uri); - - /* if it wasn't deleted, no need to cause unneeded updates */ - /* - if (new_uri_lst == uri_lst) { - return FALSE; - } - else - uri_lst = new_uri_lst; - */ - - /* delete it from gconf */ - gconf_client_set_list (recent->gconf_client, - gconf_key, - GCONF_VALUE_STRING, - new_uri_lst, - NULL); - gconf_client_suggest_sync (recent->gconf_client, NULL); - - /* delete from the global list */ - if (recent->global) - gnome_recent_model_delete (GNOME_RECENT_MODEL (recent->global), uri); - - - g_free (gconf_key); - gnome_recent_model_g_slist_deep_free (new_uri_lst); - - g_free (utf8_uri); - - return ret; -} - -#if 0 -static GSList * -gnome_recent_model_unescape_list (GnomeRecentModel *model, GSList *list) -{ - GSList *newlist=NULL; - GSList *tmp; - gchar *uri; - gchar *unescaped_uri; - gchar *ascii_uri; - GError *error = NULL; - - tmp = list; - - while (tmp) { - uri = (gchar *)tmp->data; - - ascii_uri = g_filename_from_utf8 (uri, -1, - NULL, NULL, &error); - - if (error) - { - g_warning ("Couldn't convert: %s", error->message); - g_error_free (error); - error = NULL; - - } - else - { - unescaped_uri = gnome_vfs_unescape_string_for_display (ascii_uri); - newlist = g_slist_prepend (newlist, unescaped_uri); - g_free (unescaped_uri); - g_free (ascii_uri); - - } - } - - newlist = g_slist_reverse (newlist); - - gnome_recent_model_g_slist_deep_free (list); - - return newlist; -} -#endif - -/** - * gnome_recent_model_get_list: - * @recent: A GnomeRecentModel object. - * - * This returns a linked list of strings (URIs) currently held - * by this object (in UTF8). - * - * Returns: A GSList * - */ -GSList * -gnome_recent_model_get_list (GnomeRecentModel * recent) -{ - GSList *uri_utf8_lst; - GSList *uri_lst = NULL; - GSList *iter; - - gchar *gconf_key = gnome_recent_model_gconf_key (recent); - - g_return_val_if_fail (recent, NULL); - g_return_val_if_fail (recent->gconf_client, NULL); - g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), NULL); - - uri_utf8_lst = gconf_client_get_list (recent->gconf_client, - gconf_key, - GCONF_VALUE_STRING, NULL); - g_free (gconf_key); - - iter = uri_utf8_lst; - - while (iter != NULL) - { - gchar *uri; - const gchar *uri_utf8 = (const gchar*) iter->data; - - uri = g_filename_from_utf8 (uri_utf8, -1, NULL, NULL, NULL); - if (uri != NULL) - uri_lst = g_slist_prepend (uri_lst, uri); - - iter = g_slist_next(iter); - } - - uri_lst = g_slist_reverse (uri_lst); - - /* FIXME: This sucks. */ - gnome_recent_model_monitor_uri_list (recent, uri_lst); - - gnome_recent_model_g_slist_deep_free (uri_utf8_lst); - - return uri_lst; -} - - - -/** - * gnome_recent_model_set_limit: - * @recent: A GnomeRecentModel object. - * @limit: The maximum number of items allowed in the list. - * - * Use this function to constrain the number of items allowed in the list. - * The default is %GNOME_RECENT_MODEL_DEFAULT_LIMIT. - * - */ -void -gnome_recent_model_set_limit (GnomeRecentModel *recent, gint limit) -{ - GSList *list; - int len; - unsigned int i; - - g_return_if_fail (recent); - g_return_if_fail (GNOME_IS_RECENT_MODEL (recent)); - g_return_if_fail (limit > 0); - recent->limit = limit; - - list = gnome_recent_model_get_list (recent); - len = g_slist_length (list); - - if (len <= limit) return; - - /* if we're over the limit, delete from the end */ - i=g_slist_length (list); - while (i > recent->limit) - { - gchar *uri = g_slist_nth_data (list, i-1); - gnome_recent_model_delete (recent, uri); - - i--; - } - - gnome_recent_model_g_slist_deep_free (list); -} - - -/** - * gnome_recent_model_get_limit: - * @recent: A GnomeRecentModel object. - * - */ -gint -gnome_recent_model_get_limit (GnomeRecentModel *recent) -{ - g_return_val_if_fail (recent, -1); - g_return_val_if_fail (GNOME_IS_RECENT_MODEL (recent), -1); - - return recent->limit; -} - - -/** - * gnome_recent_model_clear: - * @recent: A GnomeRecentModel object. - * - * This function clears the list of recently used URIs. - * - */ -void -gnome_recent_model_clear (GnomeRecentModel *recent) -{ - gchar *key; - - g_return_if_fail (recent); - g_return_if_fail (recent->gconf_client); - g_return_if_fail (GNOME_IS_RECENT_MODEL (recent)); - - key = gnome_recent_model_gconf_key (recent); - - gconf_client_unset (recent->gconf_client, key, NULL); -} - -static void -gnome_recent_model_set_appname (GnomeRecentModel *recent, gchar *appname) -{ - gchar *key; - gint notify_id; - - g_return_if_fail (recent); - g_return_if_fail (appname); - - recent->appname = appname; - - /* if this isn't the global list embed a global one */ - if (strcmp (appname, GNOME_RECENT_MODEL_GLOBAL_LIST)) { - recent->global = gnome_recent_model_new_global (); - } - - /* Set up the gconf notification stuff */ - key = gnome_recent_model_gconf_key (recent); - gconf_client_add_dir (recent->gconf_client, - GNOME_RECENT_MODEL_BASE_KEY, GCONF_CLIENT_PRELOAD_NONE, NULL); - notify_id = gconf_client_notify_add (recent->gconf_client, - key, - gnome_recent_model_notify_cb, - recent, NULL, NULL); - - - - g_free (key); -} - -static GSList * -gnome_recent_model_delete_from_list (GnomeRecentModel *recent, GSList *list, - const gchar *uri) -{ - unsigned int i; - gchar *text; - - for (i = 0; i < g_slist_length (list); i++) { - text = g_slist_nth_data (list, i); - - if (!strcmp (text, uri)) { - list = g_slist_remove (list, text); - g_free (text); - } - } - - return list; -} - -/* this takes a list of GConfValues, and returns a list of strings */ -static GSList * -gnome_recent_model_gconf_to_list (GConfValue* value) -{ - GSList* iter; - GSList *list = NULL; - - g_return_val_if_fail (value, NULL); - - iter = gconf_value_get_list (value); - - while (iter != NULL) - { - gchar *uri; - GConfValue* element = iter->data; - const gchar *uri_utf8 = gconf_value_get_string (element); - - uri = g_filename_from_utf8 (uri_utf8, -1, NULL, NULL, NULL); - if (uri != NULL) - list = g_slist_prepend (list, uri); - - iter = g_slist_next(iter); - } - - list = g_slist_reverse (list); - - return list; -} - -static void -gnome_recent_model_g_slist_deep_free (GSList *list) -{ - GSList *lst; - - if (list == NULL) - return; - - lst = list; - while (lst) { - g_free (lst->data); - lst->data = NULL; - lst = lst->next; - } - - g_slist_free (list); -} - -static gchar * -gnome_recent_model_gconf_key (GnomeRecentModel * model) -{ - gchar *key; - - g_return_val_if_fail (model, NULL); - - key = g_strdup_printf ("%s/%s", GNOME_RECENT_MODEL_BASE_KEY, model->appname); - return key; -} - -/* this is the gconf notification callback. */ -static void -gnome_recent_model_notify_cb (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - GSList *list=NULL; - GnomeRecentModel *recent = user_data; - - if (entry->value == NULL) { - g_signal_emit (G_OBJECT(recent), model_signals[CHANGED], 0, NULL); - return; - } - - list = gnome_recent_model_gconf_to_list (entry->value); - - gnome_recent_model_monitor_uri_list (recent, list); - - /* - list = gnome_recent_model_unescape_list (recent, list); - */ - - g_signal_emit (G_OBJECT(recent), model_signals[CHANGED], 0, list); - - gnome_recent_model_g_slist_deep_free (list); -} - - -gchar * -gnome_recent_model_get_appname (GnomeRecentModel *model) -{ - return g_strdup (model->appname); -} diff --git a/gedit/gnome-recent-model.h b/gedit/gnome-recent-model.h deleted file mode 100644 index 1ccc67dd2..000000000 --- a/gedit/gnome-recent-model.h +++ /dev/null @@ -1,40 +0,0 @@ -/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef __GNOME_RECENT_MODEL_H__ -#define __GNOME_RECENT_MODEL_H__ - -#include <libbonoboui.h> - -G_BEGIN_DECLS - -#define GNOME_RECENT_MODEL(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gnome_recent_model_get_type (), GnomeRecentModel) -#define GNOME_RECENT_MODEL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gnome_recent_model_get_type (), GnomeRecentModelClass) -#define GNOME_IS_RECENT_MODEL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gnome_recent_model_get_type ()) - -typedef struct _GnomeRecentModel GnomeRecentModel; - -typedef struct _GnomeRecentModelClass GnomeRecentModelClass; - -GType gnome_recent_model_get_type (void); - -/* constructors */ -GnomeRecentModel * gnome_recent_model_new (const gchar *appname, - gint limit); -GnomeRecentModel * gnome_recent_model_new_global (void); - - - -/* public methods */ -gboolean gnome_recent_model_add (GnomeRecentModel *recent, - const gchar *uri); -gboolean gnome_recent_model_delete (GnomeRecentModel *recent, - const gchar *uri); -void gnome_recent_model_clear (GnomeRecentModel *recent); -GSList * gnome_recent_model_get_list (GnomeRecentModel *recent); -void gnome_recent_model_set_limit (GnomeRecentModel *recent, - gint limit); -gint gnome_recent_model_get_limit (GnomeRecentModel *recent); -gchar *gnome_recent_model_get_appname (GnomeRecentModel *recent); - -G_END_DECLS - -#endif /* __GNOME_RECENT_MODEL_H__ */ diff --git a/gedit/gnome-recent-util.c b/gedit/gnome-recent-util.c deleted file mode 100644 index c8988767b..000000000 --- a/gedit/gnome-recent-util.c +++ /dev/null @@ -1,43 +0,0 @@ -#include <stdio.h> -#include <gtk/gtk.h> -#include <string.h> -#include "gnome-recent-util.h" - -/* ripped out of gedit2 */ -gchar* -gnome_recent_util_escape_underlines (const gchar* text) -{ - GString *str; - gint length; - const gchar *p; - const gchar *end; - - g_return_val_if_fail (text != NULL, NULL); - - length = strlen (text); - - str = g_string_new (""); - - p = text; - end = text + length; - - while (p != end) - { - const gchar *next; - next = g_utf8_next_char (p); - - switch (*p) - { - case '_': - g_string_append (str, "__"); - break; - default: - g_string_append_len (str, p, next - p); - break; - } - - p = next; - } - - return g_string_free (str, FALSE); -} diff --git a/gedit/gnome-recent-util.h b/gedit/gnome-recent-util.h deleted file mode 100644 index 989c8306b..000000000 --- a/gedit/gnome-recent-util.h +++ /dev/null @@ -1,9 +0,0 @@ - -G_BEGIN_DECLS - - -gchar *gnome_recent_util_escape_underlines (const gchar *uri); - - - -G_END_DECLS diff --git a/gedit/gnome-recent-view-bonobo.c b/gedit/gnome-recent-view-bonobo.c deleted file mode 100644 index 13e3c76a5..000000000 --- a/gedit/gnome-recent-view-bonobo.c +++ /dev/null @@ -1,550 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/** - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of 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 of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - * - * Authors: - * James Willcox <jwillcox@cs.indiana.edu> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <gtk/gtk.h> -#include <gconf/gconf-client.h> -#include <libbonoboui.h> -#include <libgnomevfs/gnome-vfs.h> -#include "gnome-recent-model.h" -#include "gnome-recent-view.h" -#include "gnome-recent-view-bonobo.h" -#include "gnome-recent-util.h" -#include "gnome-recent-marshal.h" -#include <eel/eel-vfs-extensions.h> - -#define GNOME_RECENT_VERB_NAME "-uri-" - -struct _GnomeRecentViewBonobo { - GObject parent_instance; /* We emit signals */ - - BonoboUIComponent *uic; - gchar *path; /* The menu path where our stuff - * will go - */ - - gulong changed_cb_id; - - GnomeRecentModel *model; -}; - -struct _GnomeRecentViewBonoboClass { - GObjectClass parent_class; - - void (*activate) (GnomeRecentViewBonobo *view, const gchar *uri); -}; - -struct _GnomeRecentViewBonoboMenuData { - GnomeRecentViewBonobo *view; - gchar *uri; -}; - -typedef struct _GnomeRecentViewBonoboMenuData GnomeRecentViewBonoboMenuData; - -enum { - ACTIVATE, - LAST_SIGNAL -}; - -/* GObject properties */ -enum { - PROP_BOGUS, - PROP_UI_COMPONENT, - PROP_MENU_PATH -}; - -static guint gnome_recent_view_bonobo_signals[LAST_SIGNAL] = { 0 }; - -static void -gnome_recent_view_bonobo_clear (GnomeRecentView *view_parent) -{ - gint i=1; - gboolean done=FALSE; - gchar *appname; - GnomeRecentModel *model; - GnomeRecentViewBonobo *view; - - g_return_if_fail (view_parent); - view = GNOME_RECENT_VIEW_BONOBO (view_parent); - g_return_if_fail (view->uic); - - model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (view)); - appname = gnome_recent_model_get_appname (model); - - while (!done) - { - gchar *verb_name = g_strdup_printf ("%s%s%d", appname,GNOME_RECENT_VERB_NAME, i); - gchar *item_path = g_strconcat (view->path, "/", verb_name, NULL); - if (bonobo_ui_component_path_exists (view->uic, item_path, NULL)) - bonobo_ui_component_rm (view->uic, item_path, NULL); - else - done=TRUE; - - g_free (item_path); - g_free (verb_name); - - i++; - } - - g_free (appname); -} - -static void -gnome_recent_view_bonobo_menu_cb (BonoboUIComponent *uic, gpointer data, const char *cname) -{ - gboolean ret; - GnomeRecentViewBonoboMenuData *md = (GnomeRecentViewBonoboMenuData *) data; - GnomeRecentModel *model; - - g_return_if_fail (md); - g_return_if_fail (md->uri); - g_return_if_fail (md->view); - g_return_if_fail (GNOME_IS_RECENT_VIEW_BONOBO (md->view)); - - ret = FALSE; - g_signal_emit (G_OBJECT(md->view), - gnome_recent_view_bonobo_signals[ACTIVATE], 0, - md->uri, &ret); - - if (!ret) { - model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (md->view)); - gnome_recent_model_delete (model, md->uri); - } -} - -static void -gnome_recent_view_bonobo_menu_data_destroy_cb (gpointer data, GClosure *closure) -{ - GnomeRecentViewBonoboMenuData *md = data; - - g_free (md->uri); - g_free (md); -} - - -static void -gnome_recent_view_bonobo_set_list (GnomeRecentViewBonobo *view, GSList *list) -{ - BonoboUIComponent* ui_component; - guint i; - guint num; - gchar *label = NULL; - gchar *verb_name = NULL; - gchar *tip = NULL; - gchar *escaped_name = NULL; - gchar *item_path = NULL; - gchar *uri; - gchar *utf8_uri; - gchar *escaped_uri; - gchar *cmd; - gchar *appname; - GnomeRecentViewBonoboMenuData *md; - GnomeRecentModel *model; - GClosure *closure; - - g_return_if_fail (view); - - ui_component = view->uic; - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); - - model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (view)); - appname = gnome_recent_model_get_appname (model); - - gnome_recent_view_bonobo_clear (GNOME_RECENT_VIEW (view)); - - bonobo_ui_component_freeze (ui_component, NULL); - - num = 1; - - for (i = 1; i <= g_slist_length (list); ++i) - { - gchar *temp; - gchar *uri_for_display; - gchar *escaped_uri_for_display; - - uri = g_path_get_basename (g_slist_nth_data (list, i - 1)); - temp = gnome_vfs_unescape_string_for_display (uri); - - utf8_uri = g_filename_to_utf8 (temp, -1, NULL, NULL, NULL); - g_free (temp); - - if (utf8_uri == NULL) { - g_warning ("Could not display: %s", uri); - g_free (uri); - continue; - } - - uri_for_display = eel_format_uri_for_display (g_slist_nth_data (list, i - 1)); - g_return_if_fail (uri_for_display != NULL); - - escaped_uri_for_display = g_markup_escape_text (uri_for_display, strlen (uri_for_display)); - g_return_if_fail (escaped_uri_for_display != NULL); - - g_free (uri_for_display); - - /* this is what gets passed to our private "activate" callback */ - md = (GnomeRecentViewBonoboMenuData *)g_malloc (sizeof (GnomeRecentViewBonoboMenuData)); - md->view = view; - md->uri = g_strdup (g_slist_nth_data (list, i-1)); - - escaped_uri = g_markup_escape_text (utf8_uri, strlen (utf8_uri)); - g_return_if_fail (escaped_uri != NULL); - escaped_name = gnome_recent_util_escape_underlines (escaped_uri); - g_return_if_fail (escaped_name != NULL); - - tip = g_strdup_printf (_("Open %s"), escaped_uri_for_display); - - verb_name = g_strdup_printf ("%s%s%d", appname, GNOME_RECENT_VERB_NAME, i); - cmd = g_strdup_printf ("<cmd name = \"%s\" /> ", verb_name); - bonobo_ui_component_set_translate (ui_component, "/commands/", cmd, NULL); - - closure = g_cclosure_new (G_CALLBACK (gnome_recent_view_bonobo_menu_cb), - md, gnome_recent_view_bonobo_menu_data_destroy_cb); - - bonobo_ui_component_add_verb_full (ui_component, verb_name, - closure); - - if (num < 10) - label = g_strdup_printf ("_%d. %s", num, escaped_name); - else - label = g_strdup_printf ("%d. %s", num, escaped_name); - - - - item_path = g_strconcat (view->path, "/", verb_name, NULL); - - if (bonobo_ui_component_path_exists (ui_component, item_path, NULL)) - { - bonobo_ui_component_set_prop (ui_component, item_path, - "label", label, NULL); - - bonobo_ui_component_set_prop (ui_component, item_path, - "tip", tip, NULL); - } - else - { - gchar *xml; - - xml = g_strdup_printf ("<menuitem name=\"%s\" " - "verb=\"%s\"" - " _label=\"%s\" _tip=\"%s\" " - "hidden=\"0\" />", - verb_name, verb_name, label, - tip); - - bonobo_ui_component_set_translate (ui_component, view->path, xml, NULL); - - g_free (xml); - } - - g_free (label); - g_free (verb_name); - g_free (tip); - g_free (escaped_name); - g_free (item_path); - g_free (uri); - g_free (utf8_uri); - g_free (escaped_uri); - g_free (escaped_uri_for_display); - g_free (cmd); - - ++num; - } - - g_free (appname); - - bonobo_ui_component_thaw (ui_component, NULL); -} - -static void -model_changed_cb (GnomeRecentModel *model, GSList *list, GnomeRecentViewBonobo *view) -{ - gnome_recent_view_bonobo_set_list (view, list); -} - - - -static void -gnome_recent_view_bonobo_populate (GnomeRecentViewBonobo *view) -{ - GnomeRecentModel *model; - GSList *list; - - model = gnome_recent_view_get_model (GNOME_RECENT_VIEW (view)); - list = gnome_recent_model_get_list (model); - - gnome_recent_view_bonobo_set_list (view, list); -} - -static GnomeRecentModel * -gnome_recent_view_bonobo_get_model (GnomeRecentView *view_parent) -{ - GnomeRecentViewBonobo *view; - - g_return_val_if_fail (view_parent, NULL); - view = GNOME_RECENT_VIEW_BONOBO (view_parent); - - return view->model; -} - -static void -gnome_recent_view_bonobo_set_model (GnomeRecentView *view_parent, GnomeRecentModel *model) -{ - GnomeRecentViewBonobo *view; - - g_return_if_fail (view_parent); - view = GNOME_RECENT_VIEW_BONOBO (view_parent); - - if (view->model) - g_signal_handler_disconnect (G_OBJECT (view->model), - view->changed_cb_id); - - view->model = model; - view->changed_cb_id = g_signal_connect (G_OBJECT (model), "changed", - G_CALLBACK (model_changed_cb), view); - - gnome_recent_view_bonobo_populate (view); -} - -static void -gnome_recent_view_bonobo_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GnomeRecentViewBonobo *view = GNOME_RECENT_VIEW_BONOBO (object); - - switch (prop_id) - { - case PROP_UI_COMPONENT: - gnome_recent_view_bonobo_set_ui_component (GNOME_RECENT_VIEW_BONOBO (view), - BONOBO_UI_COMPONENT (g_value_get_object (value))); - break; - case PROP_MENU_PATH: - view->path = g_strdup (g_value_get_string (value)); - break; - default: - break; - } -} - -static void -gnome_recent_view_bonobo_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GnomeRecentViewBonobo *view = GNOME_RECENT_VIEW_BONOBO (object); - - switch (prop_id) - { - case PROP_UI_COMPONENT: - g_value_set_pointer (value, view->uic); - break; - case PROP_MENU_PATH: - g_value_set_string (value, g_strdup (view->path)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - - -static void -gnome_recent_view_bonobo_finalize (GObject *object) -{ - GnomeRecentViewBonobo *view = GNOME_RECENT_VIEW_BONOBO (object); - - if (view->path) - g_free (view->path); - - if (view->model) - g_signal_handler_disconnect (G_OBJECT (view->model), - view->changed_cb_id); -} - -static void -gnome_recent_view_bonobo_class_init (GnomeRecentViewBonoboClass * klass) -{ - GObjectClass *object_class; - - - object_class = G_OBJECT_CLASS (klass); - - object_class->set_property = gnome_recent_view_bonobo_set_property; - object_class->get_property = gnome_recent_view_bonobo_get_property; - object_class->finalize = gnome_recent_view_bonobo_finalize; - - gnome_recent_view_bonobo_signals[ACTIVATE] = g_signal_new ("activate", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GnomeRecentViewBonoboClass, activate), - NULL, NULL, - gnome_recent_BOOLEAN__STRING, - G_TYPE_BOOLEAN, 1, - G_TYPE_STRING); - - g_object_class_install_property (object_class, - PROP_UI_COMPONENT, - g_param_spec_object ("ui-component", - "UI Component", - "BonoboUIComponent for menus.", - bonobo_ui_component_get_type(), - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_MENU_PATH, - g_param_spec_string ("ui-path", - "Path", - "The path to put the menu items.", - "/menus/File/GnomeRecentDocuments", - G_PARAM_READWRITE)); - - - klass->activate = NULL; -} - -static void -gnome_recent_view_init (GnomeRecentViewClass *iface) -{ - iface->do_clear = gnome_recent_view_bonobo_clear; - iface->do_get_model = gnome_recent_view_bonobo_get_model; - iface->do_set_model = gnome_recent_view_bonobo_set_model; -} - - -static void -gnome_recent_view_bonobo_init (GnomeRecentViewBonobo * recent) -{ - /* maybe should remove this */ -} - -void -gnome_recent_view_bonobo_set_ui_component (GnomeRecentViewBonobo *view, BonoboUIComponent *uic) -{ - g_return_if_fail (view); - g_return_if_fail (uic); - - view->uic = uic; -} - -void -gnome_recent_view_bonobo_set_ui_path (GnomeRecentViewBonobo *view, const gchar *path) -{ - g_return_if_fail (view); - g_return_if_fail (path); - - view->path = g_strdup (path); -} - -BonoboUIComponent * -gnome_recent_view_bonobo_get_ui_component (GnomeRecentViewBonobo *view) -{ - g_return_val_if_fail (view, NULL); - - return view->uic; -} - -gchar * -gnome_recent_view_bonobo_get_ui_path (GnomeRecentViewBonobo *view) -{ - g_return_val_if_fail (view, NULL); - - return g_strdup (view->path); -} - -/** - * gnome_recent_view_bonobo_new: - * @appname: The name of your application. - * @limit: The maximum number of items allowed. - * - * This creates a new GnomeRecentViewBonobo object. - * - * Returns: a GnomeRecentViewBonobo object - */ -GnomeRecentViewBonobo * -gnome_recent_view_bonobo_new (BonoboUIComponent *uic, const gchar *path) -{ - GnomeRecentViewBonobo *view; - - g_return_val_if_fail (uic, NULL); - g_return_val_if_fail (path, NULL); - - view = GNOME_RECENT_VIEW_BONOBO (g_object_new (gnome_recent_view_bonobo_get_type (), - "ui-path", - path, - "ui-component", - uic, NULL)); - - g_return_val_if_fail (view, NULL); - - return view; -} - -/** - * gnome_recent_view_bonobo_get_type: - * @: - * - * This returns a GType representing a GnomeRecentViewBonobo object. - * - * Returns: a GType - */ -GType -gnome_recent_view_bonobo_get_type (void) -{ - static GType gnome_recent_view_bonobo_type = 0; - - if(!gnome_recent_view_bonobo_type) { - static const GTypeInfo gnome_recent_view_bonobo_info = { - sizeof (GnomeRecentViewBonoboClass), - NULL, /* base init */ - NULL, /* base finalize */ - (GClassInitFunc)gnome_recent_view_bonobo_class_init, /* class init */ - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (GnomeRecentViewBonobo), - 0, - (GInstanceInitFunc) gnome_recent_view_bonobo_init - }; - - static const GInterfaceInfo view_info = - { - (GInterfaceInitFunc) gnome_recent_view_init, - NULL, - NULL - }; - - gnome_recent_view_bonobo_type = g_type_register_static (G_TYPE_OBJECT, - "GnomeRecentViewBonobo", - &gnome_recent_view_bonobo_info, 0); - g_type_add_interface_static (gnome_recent_view_bonobo_type, - GNOME_TYPE_RECENT_VIEW, - &view_info); - } - - return gnome_recent_view_bonobo_type; -} - diff --git a/gedit/gnome-recent-view-bonobo.h b/gedit/gnome-recent-view-bonobo.h deleted file mode 100644 index 92d63f10d..000000000 --- a/gedit/gnome-recent-view-bonobo.h +++ /dev/null @@ -1,34 +0,0 @@ -/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef __GNOME_RECENT_VIEW_BONOBO_H__ -#define __GNOME_RECENT_VIEW_BONOBO_H__ - -#include <libbonoboui.h> - -G_BEGIN_DECLS - -#define GNOME_RECENT_VIEW_BONOBO(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gnome_recent_view_bonobo_get_type (), GnomeRecentViewBonobo) -#define GNOME_RECENT_VIEW_BONOBO_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gnome_recent_view_bonobo_get_type (), GnomeRecentViewBonoboClass) -#define GNOME_IS_RECENT_VIEW_BONOBO(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gnome_recent_view_bonobo_get_type ()) - -typedef struct _GnomeRecentViewBonobo GnomeRecentViewBonobo; - -typedef struct _GnomeRecentViewBonoboClass GnomeRecentViewBonoboClass; - -GType gnome_recent_view_bonobo_get_type (void); - -GnomeRecentViewBonobo * gnome_recent_view_bonobo_new (BonoboUIComponent *uic, - const gchar *path); - - -void gnome_recent_view_bonobo_set_ui_component (GnomeRecentViewBonobo *view, - BonoboUIComponent *uic); - -void gnome_recent_view_bonobo_set_ui_path (GnomeRecentViewBonobo *view, - const gchar *path); - -gchar * gnome_recent_view_bonobo_get_ui_path (GnomeRecentViewBonobo *view); -BonoboUIComponent *gnome_recent_view_bonobo_get_ui_component (GnomeRecentViewBonobo *view); - -G_END_DECLS - -#endif /* __GNOME_RECENT_VIEW_BONOBO_H__ */ diff --git a/gedit/gnome-recent-view.c b/gedit/gnome-recent-view.c deleted file mode 100644 index edb145c97..000000000 --- a/gedit/gnome-recent-view.c +++ /dev/null @@ -1,51 +0,0 @@ -#include <string.h> -#include <gtk/gtk.h> -#include "gnome-recent-view.h" - - -GtkType -gnome_recent_view_get_type (void) -{ - static GtkType view_type = 0; - - if (!view_type) - { - static const GTypeInfo view_info = - { - sizeof (GnomeRecentViewClass), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ - }; - - view_type = g_type_register_static (G_TYPE_INTERFACE, - "GnomeRecentView", - &view_info, 0); - } - - return view_type; -} - -void -gnome_recent_view_clear (GnomeRecentView *view) -{ - g_return_if_fail (GNOME_IS_RECENT_VIEW (view)); - - GNOME_RECENT_VIEW_GET_CLASS (view)->do_clear (view); -} - -GnomeRecentModel * -gnome_recent_view_get_model (GnomeRecentView *view) -{ - g_return_val_if_fail (view, NULL); - - return GNOME_RECENT_VIEW_GET_CLASS (view)->do_get_model (view); -} - -void -gnome_recent_view_set_model (GnomeRecentView *view, GnomeRecentModel *model) -{ - g_return_if_fail (view); - g_return_if_fail (model); - - GNOME_RECENT_VIEW_GET_CLASS (view)->do_set_model (view, model); -} diff --git a/gedit/gnome-recent-view.h b/gedit/gnome-recent-view.h deleted file mode 100644 index aedf67ccc..000000000 --- a/gedit/gnome-recent-view.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef __GNOME_RECENT_VIEW_H__ -#define __GNOME_RECENT_VIEW_H__ - - -#include <gdk/gdk.h> -#include <gtk/gtkwidget.h> -#include "gnome-recent-model.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GNOME_TYPE_RECENT_VIEW (gnome_recent_view_get_type ()) -#define GNOME_RECENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_RECENT_VIEW, GnomeRecentView)) -#define GNOME_RECENT_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GNOME_TYPE_RECENT_VIEW, GnomeRecentViewClass)) -#define GNOME_IS_RECENT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_RECENT_VIEW)) -#define GNOME_IS_RECENT_VIEW_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GNOME_TYPE_RECENT_VIEW)) -#define GNOME_RECENT_VIEW_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GNOME_TYPE_RECENT_VIEW, GnomeRecentViewClass)) - -typedef struct _GnomeRecentView GnomeRecentView; /* Dummy typedef */ -typedef struct _GnomeRecentViewClass GnomeRecentViewClass; - -struct _GnomeRecentViewClass -{ - GTypeInterface base_iface; - - /* vtable, not signals */ - void (* do_clear) (GnomeRecentView *view); - void (* do_set_model) (GnomeRecentView *view, - GnomeRecentModel *model); - GnomeRecentModel * (* do_get_model) (GnomeRecentView *view); -}; - -GtkType gnome_recent_view_get_type (void) G_GNUC_CONST; -void gnome_recent_view_set_list (GnomeRecentView *view, - GSList *list); -void gnome_recent_view_clear (GnomeRecentView *view); -GnomeRecentModel *gnome_recent_view_get_model (GnomeRecentView *view); -void gnome_recent_view_set_model (GnomeRecentView *view, - GnomeRecentModel *model); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GNOME_RECENT_VIEW_H__ */ |