Commit a495ac48 authored by Chema Celorio's avatar Chema Celorio Committed by Jose Maria Celorio

dont' crash if there isn't a document open.

2000-11-20  Chema Celorio  <chema@celorio.com>

	* shell_output/shell_output.c: dont' crash if there isn't
	a document open.

2000-11-20  Chema Celorio  <chema@celorio.com>

	* configure.in (ALL_LINGUAS): check for gnome-print 0.25
	bump version to 0.94

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
parent 2187295d
2000-11-20 Chema Celorio <chema@celorio.com>
* configure.in (ALL_LINGUAS): check for gnome-print 0.25
bump version to 0.94
2000-11-14 Stanislav Visnovsky <visnovsky@nenya.ms.mff.cuni.cz>
* gedit.desktop: Added Slovak translation.
......
......@@ -18,7 +18,7 @@
no Maximized, so
[X] Fix the undo bug when replacing text and a pair of delte/inser gets
divided in 2.
[ ] The Plugins sensitivity is not beeing modified when all the docs are
[X] The Plugins sensitivity is not beeing modified when all the docs are
closed. Rewrite the set sensitivity code.
[ ] Reactivate multiple views
......
AC_INIT(src/gedit.c)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(gedit, 0.9.3)
AM_INIT_AUTOMAKE(gedit, 0.9.4)
AM_MAINTAINER_MODE
AM_ACLOCAL_INCLUDE(macros)
......@@ -62,14 +62,14 @@ AM_PATH_GTK(1.2.7,,
dnl ******************************
dnl GnomePrint checking
dnl ******************************
AC_MSG_CHECKING(for GnomePrint libraries >= 0.24)
AC_MSG_CHECKING(for GnomePrint libraries >= 0.25)
if gnome-config --libs print > /dev/null 2>&1; then
vers=`gnome-config --modversion print | sed -e "s/gnome-print-//" | \
awk 'BEGIN { FS = "."; } { print $1 * 1000 + $2;}'`
if test "$vers" -ge 24; then
if test "$vers" -ge 25; then
AC_MSG_RESULT(found)
else
AC_MSG_ERROR(You need at least GNOME print 0.24 for this version of gedit)
AC_MSG_ERROR(You need at least GNOME print 0.25 for this version of gedit)
fi
else
AC_MSG_ERROR(Did not find GnomePrint installed)
......
......@@ -22,6 +22,8 @@
<copyright>(C) 1998, 1999, 2000 Alex Roberts and Evan Lawrence</copyright>
<authors>Chema Celorio &lt;chema@celorio.com&gt;
Jason Leach &lt;leach@wam.umd.edu&gt;
Paolo Maggi &lt;maggi@athena.polito.it&gt;
Roberto Majadas &lt;phoenix@nova.es&gt;
Based in gedit 0.6.1 by :
Alex Roberts &lt;bse@error.fsnet.co.uk&gt;
......
......@@ -21,6 +21,7 @@
#include <config.h>
#include <glib.h>
#include <string.h> /* For strlen and strcmp */
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
......@@ -491,9 +492,12 @@ gedit_plugin_manager_clicked (GtkWidget *widget, gpointer button)
for (n = 0; n < g_list_length (mdi->windows); n++)
{
nth_app = g_list_nth_data (mdi->windows, n);
gedit_plugins_menu_add (nth_app);
gedit_plugins_menu_add (nth_app);
}
if(gedit_document_current () == NULL)
gedit_window_set_plugins_menu_sensitivity (FALSE);
return;
}
......
......@@ -30,6 +30,7 @@
#include <libgnomeui/gnome-color-picker.h>
#include <libgnomeui/gnome-propertybox.h>
#include <glade/glade.h>
#include <string.h> /* For strcmp */
#include "prefs.h"
#include "view.h"
......
......@@ -35,6 +35,7 @@
#include <libgnomeui/gnome-messagebox.h>
#include <libgnomeui/gnome-stock.h>
#include <glade/glade-xml.h>
#include <string.h> /* For strlen */
#include "window.h"
#include "search.h"
......@@ -368,8 +369,12 @@ dialog_display_messages (GeditReplaceDialog *dialog)
g_free (msg);
}
if (dialog->replacements == -1) {
#if 0 /* warning: too many arguments for format */
msg = g_strdup_printf (_("Could not allocate the memory for the Replace all request."),
dialog->replacements);
#endif
msg = g_strdup_printf (_("Could not allocate the memory for the Replace all request."));
gnome_dialog_run_and_close ((GnomeDialog *)
gnome_message_box_new (msg,
GNOME_MESSAGE_BOX_INFO,
......
......@@ -225,7 +225,7 @@ gedit_file_open (GeditDocument *doc, const gchar *fname)
gedit_flash_va ("%s %s", _(MSGBAR_FILE_OPENED), fname);
gedit_recent_add (fname);
gedit_recent_update (gedit_window_active_app());
gedit_recent_update_all_windows (mdi);
return 0;
}
......@@ -833,7 +833,7 @@ gedit_file_save_as_ok_sel (GtkWidget *w, gpointer cbdata)
/* Add the saved as file to the recent files ( history ) menu */
gedit_recent_add (file_name);
gedit_recent_update (gedit_window_active_app());
gedit_recent_update_all_windows (mdi);
gedit_flash_va ("%s %s", _(MSGBAR_FILE_SAVED), file_name);
......
......@@ -52,8 +52,11 @@ struct _PluginData
work, and there aren't any open documents.
set sentivity off in the plugins menu */
gint needs_a_document;
#if 0 /* It is not needed*/
GtkWidget * menu_item;
#endif
/* filled in by plugin */
void *private_data;
......
......@@ -111,28 +111,6 @@ gedit_prefs_save_settings (void)
gedit_debug (DEBUG_PREFS, "end");
}
/* Determine we use fonts or fontsets. If a fontset is supplied for
* text widgets, we use fontsets for drawing texts. Otherwise we use
* normal fonts instead.
*/
static gboolean
gedit_prefs_determine_use_fontset (void)
{
GtkWidget *dummy_widget;
gboolean retval;
dummy_widget = gtk_text_new (NULL, NULL);
gtk_widget_ensure_style (dummy_widget);
if (dummy_widget->style->font->type == GDK_FONT_FONTSET)
retval = TRUE;
else
retval = FALSE;
gtk_widget_unref (dummy_widget);
return retval;
}
void
gedit_prefs_load_settings (void)
{
......@@ -191,7 +169,7 @@ gedit_prefs_load_settings (void)
}
#endif
settings->use_fontset = gedit_prefs_determine_use_fontset ();
settings->use_fontset = FALSE;
settings->font = gnome_config_get_string ("font");
if (settings->font == NULL)
settings->font = g_strdup (DEFAULT_FONT);
......
......@@ -32,6 +32,10 @@
#ifndef MAX_RECENT
#define MAX_RECENT 4
#endif
#ifndef DATA_ITEMS_TO_REMOVE
#define DATA_ITEMS_TO_REMOVE "items_to_remove"
#endif
void gedit_recent_update (GnomeApp *app);
......@@ -221,19 +225,29 @@ gedit_recent_add_menu_item (GnomeApp *app, const gchar *file_name, const gchar *
**/
static void
gedit_recent_update_menus (GnomeApp *app, GList *recent_files)
{
{
static gint items_in_menu = 0;
const gchar *file_name;
gchar *path;
int i;
gint* items_to_remove = NULL;
gedit_debug (DEBUG_RECENT, "");
g_return_if_fail (app != NULL);
items_to_remove = gtk_object_get_data (GTK_OBJECT(app), DATA_ITEMS_TO_REMOVE);
if(items_to_remove != NULL) {
/* xgettext translators : Use the name of the stock
* Menu item for "File" if it is not the same, we are going to
* fail to insert the recent menu items.*/
gnome_app_remove_menu_range (app, _("_File/"), 7, *items_to_remove);
/* xgettext translators : Use the name of the stock Menu item for "File"
if it is not the same, we are going to fail to insert the recent menu items.*/
gnome_app_remove_menu_range (app, _("_File/"), 7, items_in_menu);
gtk_object_remove_data(GTK_OBJECT(app), DATA_ITEMS_TO_REMOVE);
}
items_in_menu = g_list_length (recent_files);
/* xgettext translators : Use the name of the stock Menu item for "File"
......@@ -245,6 +259,9 @@ gedit_recent_update_menus (GnomeApp *app, GList *recent_files)
}
g_free (path);
items_to_remove = g_new0 (gint, 1);
*items_to_remove = items_in_menu;
gtk_object_set_data_full (GTK_OBJECT(app), DATA_ITEMS_TO_REMOVE,items_to_remove, g_free);
}
/* Callback for a click on a file in the recently used menu */
......@@ -259,7 +276,8 @@ recent_cb (GtkWidget *widget, gpointer data)
{
gedit_flash_va (_("Unable to open recent file : %s"), (gchar *) data);
gedit_recent_remove ((gchar *) data);
gedit_recent_update_menus (gedit_window_active_app (), gedit_recent_history_list);
gedit_recent_history_write_config ();
gedit_recent_update_all_windows (mdi);
}
}
......@@ -268,8 +286,8 @@ recent_cb (GtkWidget *widget, gpointer data)
* @app:
*
* Grabs the list of recently used documents, then updates the menus by
* calling recent_update_menus(). Should be called after each addition
* to the recent documents list.
* calling recent_update_menus(). Should be called when a new
* window is created. It updates the menu of a single window.
**/
void
gedit_recent_update (GnomeApp *app)
......@@ -283,6 +301,30 @@ gedit_recent_update (GnomeApp *app)
gedit_recent_update_menus (app, filelist);
}
/**
* recent_update_all_windows:
* @app:
*
* Updates the recent files menus in all open windows.
* Should be called after each addition to the recent documents list.
**/
void
gedit_recent_update_all_windows (GnomeMDI *mdi)
{
gint i;
gedit_debug (DEBUG_RECENT, "");
g_assert(mdi != NULL);
g_assert(mdi->windows != NULL);
for (i = 0; i < g_list_length (mdi->windows); i++)
{
gedit_recent_update (GNOME_APP (g_list_nth_data (mdi->windows, i)));
}
}
/**
* recent_add:
* @filename: Filename of document to add to the recently accessed list
......@@ -324,7 +366,7 @@ gedit_recent_remove (char *file_name)
if (strcmp (nth_list_item, file_name) == 0)
{
gedit_recent_history_list = g_list_remove (gedit_recent_history_list, nth_list_item);
g_free (nth_list_item);
g_free (nth_list_item);
return;
}
}
......
......@@ -23,6 +23,8 @@
#define __RECENT_H__
void gedit_recent_update (GnomeApp *app);
void gedit_recent_update_all_windows (GnomeMDI *mdi);
void gedit_recent_add (const char *filename);
void gedit_recent_history_write_config (void);
......
......@@ -20,6 +20,7 @@
*/
#include <config.h>
#include <string.h> /* For strlen */
#include "window.h"
#include "undo.h"
......
......@@ -20,9 +20,7 @@
*/
#include <config.h>
#if 0
#include <gnome.h>
#endif
#include <libgnome/gnome-defs.h>
#include <libgnomeui/gnome-preferences.h>
......@@ -399,9 +397,7 @@ gedit_window_set_widgets_sensitivity (gint sensitive)
GnomeUIInfo *ui_info;
GnomeUIInfo *sub_ui_info;
GtkWidget *widget;
#if 0 /* See below */
PluginData *pd;
#endif
gint count = 0, sub_count = 0;
gedit_debug (DEBUG_WINDOW, "");
......@@ -493,28 +489,59 @@ gedit_window_set_widgets_sensitivity (gint sensitive)
if (sensitive)
gedit_window_set_view_menu_sensitivity (app);
#if 0
/* This is broken, since the widget pointer is stored in pd->menu_item.
It is broken because with multiple windows, there are more than one
widgets that need updating */
g_print ("Setting plugins sensitivity ...\n");
/* plugin menus */
gedit_window_set_plugins_menu_sensitivity (sensitive);
return;
}
/**
* gedit_window_set_plugins_menu_sensitivity:
* @sensitive:
*
* Set plugins menu sensitivity
**/
void
gedit_window_set_plugins_menu_sensitivity (gint sensitive)
{
GnomeApp *app;
PluginData *pd;
GnomeDockItem *dock_item;
GtkWidget *menu_bar, *widget;
gint count;
GList* children;
gchar* path;
gint menu_pos;
app = GNOME_APP (g_list_nth_data (mdi->windows, 0));
g_return_if_fail (GNOME_IS_APP (app));
dock_item = gnome_app_get_dock_item_by_name (app, GNOME_APP_MENUBAR_NAME);
g_return_if_fail (GNOME_IS_DOCK_ITEM (dock_item));
menu_bar = gnome_dock_item_get_child (dock_item);
for (count = 0; count < g_list_length (plugins_list); count++)
{
g_print ("count %i\n", count);
pd = g_list_nth_data (plugins_list, count);
if (!pd->needs_a_document) {
g_print ("This plugin does not need a document\n");
continue;
if (pd->installed && pd->needs_a_document)
{
path = g_strdup_printf ("%s/%s", _("_Plugins"), pd->name);
children = gtk_container_children (GTK_CONTAINER (
gnome_app_find_menu_pos (menu_bar, path, &menu_pos)));
widget = GTK_WIDGET (g_list_nth_data (children, menu_pos - 1));
if (GTK_IS_WIDGET (widget))
gtk_widget_set_sensitive (widget, sensitive);
g_free (path);
}
widget = pd->menu_item;
if (widget)
gtk_widget_set_sensitive (widget, sensitive);
else
g_print ("The widget is not laoded\n" );
}
#endif
return;
}
......@@ -47,6 +47,7 @@ void gedit_window_refresh_all (gint mdi_mode_changed);
void gedit_window_set_view_menu_sensitivity (GnomeApp *app);
void gedit_window_set_toolbar_labels (GnomeApp *app);
void gedit_window_set_widgets_sensitivity (gint unsensitive);
void gedit_window_set_plugins_menu_sensitivity (gint sensitive);
#endif /* __WINDOW_H__ */
......
2000-11-20 Chema Celorio <chema@celorio.com>
* shell_output/shell_output.c: dont' crash if there isn't
a document open.
2000-10-10 Chema Celorio <chema@celorio.com>
* all plugins .c files : Rename to GeditDocument & GeditView
......
......@@ -140,8 +140,10 @@ shell_output (void){
GtkWidget *ok;
GtkWidget *cancel;
gchar *text;
if (gedit_document_current () == NULL)
return;
gui = glade_xml_new (GEDIT_GLADEDIR "/shell_output.glade",NULL);
if (!gui)
......@@ -184,7 +186,7 @@ init_plugin (PluginData *pd)
{
gchar *current_directory;
/* initialise */
/* initialize */
pd->destroy_plugin = destroy_plugin;
pd->name = _("Shell Output");
pd->desc = _("Insert the shell output in the document");
......
......@@ -22,6 +22,8 @@
<copyright>(C) 1998, 1999, 2000 Alex Roberts and Evan Lawrence</copyright>
<authors>Chema Celorio &lt;chema@celorio.com&gt;
Jason Leach &lt;leach@wam.umd.edu&gt;
Paolo Maggi &lt;maggi@athena.polito.it&gt;
Roberto Majadas &lt;phoenix@nova.es&gt;
Based in gedit 0.6.1 by :
Alex Roberts &lt;bse@error.fsnet.co.uk&gt;
......
......@@ -21,6 +21,7 @@
#include <config.h>
#include <glib.h>
#include <string.h> /* For strlen and strcmp */
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
......@@ -491,9 +492,12 @@ gedit_plugin_manager_clicked (GtkWidget *widget, gpointer button)
for (n = 0; n < g_list_length (mdi->windows); n++)
{
nth_app = g_list_nth_data (mdi->windows, n);
gedit_plugins_menu_add (nth_app);
gedit_plugins_menu_add (nth_app);
}
if(gedit_document_current () == NULL)
gedit_window_set_plugins_menu_sensitivity (FALSE);
return;
}
......
......@@ -30,6 +30,7 @@
#include <libgnomeui/gnome-color-picker.h>
#include <libgnomeui/gnome-propertybox.h>
#include <glade/glade.h>
#include <string.h> /* For strcmp */
#include "prefs.h"
#include "view.h"
......
......@@ -35,6 +35,7 @@
#include <libgnomeui/gnome-messagebox.h>
#include <libgnomeui/gnome-stock.h>
#include <glade/glade-xml.h>
#include <string.h> /* For strlen */
#include "window.h"
#include "search.h"
......@@ -368,8 +369,12 @@ dialog_display_messages (GeditReplaceDialog *dialog)
g_free (msg);
}
if (dialog->replacements == -1) {
#if 0 /* warning: too many arguments for format */
msg = g_strdup_printf (_("Could not allocate the memory for the Replace all request."),
dialog->replacements);
#endif
msg = g_strdup_printf (_("Could not allocate the memory for the Replace all request."));
gnome_dialog_run_and_close ((GnomeDialog *)
gnome_message_box_new (msg,
GNOME_MESSAGE_BOX_INFO,
......
......@@ -225,7 +225,7 @@ gedit_file_open (GeditDocument *doc, const gchar *fname)
gedit_flash_va ("%s %s", _(MSGBAR_FILE_OPENED), fname);
gedit_recent_add (fname);
gedit_recent_update (gedit_window_active_app());
gedit_recent_update_all_windows (mdi);
return 0;
}
......@@ -833,7 +833,7 @@ gedit_file_save_as_ok_sel (GtkWidget *w, gpointer cbdata)
/* Add the saved as file to the recent files ( history ) menu */
gedit_recent_add (file_name);
gedit_recent_update (gedit_window_active_app());
gedit_recent_update_all_windows (mdi);
gedit_flash_va ("%s %s", _(MSGBAR_FILE_SAVED), file_name);
......
......@@ -52,8 +52,11 @@ struct _PluginData
work, and there aren't any open documents.
set sentivity off in the plugins menu */
gint needs_a_document;
#if 0 /* It is not needed*/
GtkWidget * menu_item;
#endif
/* filled in by plugin */
void *private_data;
......
......@@ -111,28 +111,6 @@ gedit_prefs_save_settings (void)
gedit_debug (DEBUG_PREFS, "end");
}
/* Determine we use fonts or fontsets. If a fontset is supplied for
* text widgets, we use fontsets for drawing texts. Otherwise we use
* normal fonts instead.
*/
static gboolean
gedit_prefs_determine_use_fontset (void)
{
GtkWidget *dummy_widget;
gboolean retval;
dummy_widget = gtk_text_new (NULL, NULL);
gtk_widget_ensure_style (dummy_widget);
if (dummy_widget->style->font->type == GDK_FONT_FONTSET)
retval = TRUE;
else
retval = FALSE;
gtk_widget_unref (dummy_widget);
return retval;
}
void
gedit_prefs_load_settings (void)
{
......@@ -191,7 +169,7 @@ gedit_prefs_load_settings (void)
}
#endif
settings->use_fontset = gedit_prefs_determine_use_fontset ();
settings->use_fontset = FALSE;
settings->font = gnome_config_get_string ("font");
if (settings->font == NULL)
settings->font = g_strdup (DEFAULT_FONT);
......
......@@ -32,6 +32,10 @@
#ifndef MAX_RECENT
#define MAX_RECENT 4
#endif
#ifndef DATA_ITEMS_TO_REMOVE
#define DATA_ITEMS_TO_REMOVE "items_to_remove"
#endif
void gedit_recent_update (GnomeApp *app);
......@@ -221,19 +225,29 @@ gedit_recent_add_menu_item (GnomeApp *app, const gchar *file_name, const gchar *
**/
static void
gedit_recent_update_menus (GnomeApp *app, GList *recent_files)
{
{
static gint items_in_menu = 0;
const gchar *file_name;
gchar *path;
int i;
gint* items_to_remove = NULL;
gedit_debug (DEBUG_RECENT, "");
g_return_if_fail (app != NULL);
items_to_remove = gtk_object_get_data (GTK_OBJECT(app), DATA_ITEMS_TO_REMOVE);
if(items_to_remove != NULL) {
/* xgettext translators : Use the name of the stock
* Menu item for "File" if it is not the same, we are going to
* fail to insert the recent menu items.*/
gnome_app_remove_menu_range (app, _("_File/"), 7, *items_to_remove);
/* xgettext translators : Use the name of the stock Menu item for "File"
if it is not the same, we are going to fail to insert the recent menu items.*/
gnome_app_remove_menu_range (app, _("_File/"), 7, items_in_menu);
gtk_object_remove_data(GTK_OBJECT(app), DATA_ITEMS_TO_REMOVE);
}
items_in_menu = g_list_length (recent_files);
/* xgettext translators : Use the name of the stock Menu item for "File"
......@@ -245,6 +259,9 @@ gedit_recent_update_menus (GnomeApp *app, GList *recent_files)
}
g_free (path);
items_to_remove = g_new0 (gint, 1);
*items_to_remove = items_in_menu;
gtk_object_set_data_full (GTK_OBJECT(app), DATA_ITEMS_TO_REMOVE,items_to_remove, g_free);
}
/* Callback for a click on a file in the recently used menu */
......@@ -259,7 +276,8 @@ recent_cb (GtkWidget *widget, gpointer data)
{
gedit_flash_va (_("Unable to open recent file : %s"), (gchar *) data);
gedit_recent_remove ((gchar *) data);
gedit_recent_update_menus (gedit_window_active_app (), gedit_recent_history_list);
gedit_recent_history_write_config ();
gedit_recent_update_all_windows (mdi);
}
}
......@@ -268,8 +286,8 @@ recent_cb (GtkWidget *widget, gpointer data)
* @app:
*
* Grabs the list of recently used documents, then updates the menus by
* calling recent_update_menus(). Should be called after each addition
* to the recent documents list.
* calling recent_update_menus(). Should be called when a new
* window is created. It updates the menu of a single window.
**/
void
gedit_recent_update (GnomeApp *app)
......@@ -283,6 +301,30 @@ gedit_recent_update (GnomeApp *app)
gedit_recent_update_menus (app, filelist);
}
/**
* recent_update_all_windows:
* @app:
*
* Updates the recent files menus in all open windows.