SF.net SVN: geany: [629] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Tue Jul 25 12:46:21 UTC 2006


Revision: 629
Author:   eht16
Date:     2006-07-25 05:46:08 -0700 (Tue, 25 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=629&view=rev

Log Message:
-----------
Removed some unneeded functions to avoid duplicate code.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/dialogs.c
    trunk/src/dialogs.h
    trunk/src/document.c
    trunk/src/main.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-07-25 12:44:42 UTC (rev 628)
+++ trunk/ChangeLog	2006-07-25 12:46:08 UTC (rev 629)
@@ -3,6 +3,12 @@
  * src/encodings.c, src/document.c, src/keyfile.c, src/main.c:
    Save default encoding for new files as charset string.
  * src/filetypes.c: Reordered the filetypes (just a cosmetic change).
+ * src/win32.c, src/utils.c:
+   Removed title argument from win32_message_dialog because it is
+   defined by the dialog type.
+   Added simple wrapper function win32_open_browser().
+ * src/dialogs.c, src/main.c, src/document.c, src/callbacks.c:
+   Removed some unneeded functions to avoid duplicate code.
 
 
 2006-07-24  Enrico Tröger  <enrico.troeger at uvena.de>

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-07-25 12:44:42 UTC (rev 628)
+++ trunk/src/callbacks.c	2006-07-25 12:46:08 UTC (rev 629)
@@ -848,7 +848,9 @@
 			}
 			else
 			{
-				dialogs_show_file_open_error();
+				dialogs_show_error(
+		_("You have opened too many files. There is a limit of %d concurrent open files."),
+		GEANY_MAX_OPEN_FILES);
 				g_slist_foreach(flist, (GFunc)g_free, NULL);
 				break;
 			}

Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c	2006-07-25 12:44:42 UTC (rev 628)
+++ trunk/src/dialogs.c	2006-07-25 12:46:08 UTC (rev 629)
@@ -42,9 +42,7 @@
 #include "win32.h"
 #include "sciwrappers.h"
 #include "support.h"
-//#include "interface.h"
 #include "utils.h"
-#include "prefs.h"
 #include "keybindings.h"
 
 
@@ -148,7 +146,9 @@
 	}
 	else
 	{
-		dialogs_show_file_open_error();
+		dialogs_show_error(
+		_("You have opened too many files. There is a limit of %d concurrent open files."),
+		GEANY_MAX_OPEN_FILES);
 	}
 }
 
@@ -157,7 +157,7 @@
 void dialogs_show_save_as ()
 {
 #ifdef GEANY_WIN32
-		win32_show_file_dialog(FALSE);
+	win32_show_file_dialog(FALSE);
 #else
 	gint idx = document_get_cur_idx();
 
@@ -212,53 +212,6 @@
 }
 
 
-
-void dialogs_show_file_open_error(void)
-{
-	/// TODO rewrite the messages
-	gchar *pri = g_strdup_printf(_("There is a limit of %d concurrent open tabs."), GEANY_MAX_OPEN_FILES);
-	gchar *sec = _("error: too many open files");
-#ifdef GEANY_WIN32
-	win32_message_dialog(GTK_MESSAGE_INFO, sec, pri);	
-#else
-	GtkWidget *dialog;
-
-	dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, sec);
-	gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), pri);
-	gtk_dialog_run (GTK_DIALOG (dialog));
-	gtk_widget_destroy (dialog);
-#endif
-	g_free(pri);
-}
-
-
-/// TODO replace by dialogs_show_question
-gboolean dialogs_show_not_found(const gchar *text)
-{
-	GtkWidget *dialog;
-	gchar *string;
-	gint ret;
-
-	string = g_strdup_printf(_("The match \"%s\" was not found. Wrap search around the document?"), text);
-#ifdef GEANY_WIN32
-	dialog = NULL;
-	ret = MessageBox(NULL, string, _("Question"), MB_YESNO | MB_ICONWARNING);
-	g_free(string);
-	if (ret == IDYES) return TRUE;
-	else return FALSE;
-#else
-	dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", string);
-	g_free(string);
-	ret = gtk_dialog_run(GTK_DIALOG (dialog));
-	gtk_widget_destroy(dialog);
-	if (ret == GTK_RESPONSE_YES) return TRUE;
-	else return FALSE;
-#endif
-}
-
-
 void dialogs_show_info(const gchar *text, ...)
 {
 #ifndef GEANY_WIN32
@@ -272,11 +225,11 @@
 	va_end(args);
 
 #ifdef GEANY_WIN32
-	win32_message_dialog(GTK_MESSAGE_INFO,  _("Information"), string);	
+	win32_message_dialog(GTK_MESSAGE_INFO,  string);
 #else
 
 	dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_INFO, GTK_BUTTONS_OK, string);
+                                  GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", string);
 	gtk_dialog_run (GTK_DIALOG (dialog));
 	gtk_widget_destroy (dialog);
 #endif
@@ -297,10 +250,10 @@
 	va_end(args);
 
 #ifdef GEANY_WIN32
-	win32_message_dialog(GTK_MESSAGE_ERROR, _("Error"), string);
+	win32_message_dialog(GTK_MESSAGE_ERROR, string);
 #else
 	dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, string);
+                                  GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", string);
 	gtk_dialog_run(GTK_DIALOG(dialog));
 	gtk_widget_destroy(dialog);
 #endif
@@ -329,10 +282,10 @@
 		msg  = g_strdup(_("The file is not saved.\nDo you want to save it before closing?"));
 	}
 #ifdef GEANY_WIN32
-	ret = win32_message_dialog_unsaved(_("Error"), msg);
+	ret = win32_message_dialog_unsaved(msg);
 #else
 	dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, msg);
+                                  GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, "%s", msg);
 
 	gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
 
@@ -1378,30 +1331,6 @@
 }
 
 
-/// TODO remove this function and use dialogs_show_question instead
-gboolean dialogs_show_mkcfgdir_error(gint error_nr)
-{
-#ifndef GEANY_WIN32
-	GtkWidget *dialog;
-#endif
-	gchar string[255];
-	gint ret;
-
-	snprintf(string, 255, _("Configuration directory could not be created (%s).\nThere could be some problems using %s without a configuration directory.\nStart %s anyway?"),
-									g_strerror(error_nr), PACKAGE, PACKAGE);
-#ifdef GEANY_WIN32
-	ret = win32_message_dialog(GTK_MESSAGE_ERROR, _("Error"), string);
-#else
-	dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, string);
-	ret = gtk_dialog_run(GTK_DIALOG(dialog));
-	gtk_widget_destroy(dialog);
-	if (ret == GTK_RESPONSE_YES) return TRUE;
-	else return FALSE;
-#endif
-}
-
-
 void dialogs_show_file_properties(gint idx)
 {
 	GtkWidget *dialog, *label, *table, *hbox, *image, *perm_table, *check;
@@ -1779,10 +1708,10 @@
 	va_end(args);
 
 #ifdef GEANY_WIN32
-	ret = win32_message_dialog(GTK_MESSAGE_QUESTION, _("Question"), string);
+	ret = win32_message_dialog(GTK_MESSAGE_QUESTION, string);
 #else
 	dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
-                                  GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, string);
+                                  GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", string);
 	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES)
 		ret = TRUE;
 	gtk_widget_destroy(dialog);

Modified: trunk/src/dialogs.h
===================================================================
--- trunk/src/dialogs.h	2006-07-25 12:44:42 UTC (rev 628)
+++ trunk/src/dialogs.h	2006-07-25 12:46:08 UTC (rev 629)
@@ -15,7 +15,7 @@
  *
  *      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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * $Id$
  */
@@ -30,10 +30,6 @@
 /* This shows the file selection dialog to save a file. */
 void dialogs_show_save_as();
 
-void dialogs_show_file_open_error(void);
-
-gboolean dialogs_show_not_found(const gchar *text);
-
 void dialogs_show_info(const gchar *text, ...);
 
 void dialogs_show_error(const gchar *text, ...);
@@ -69,8 +65,6 @@
 
 GtkWidget *dialogs_add_file_open_extra_widget(void);
 
-gboolean dialogs_show_mkcfgdir_error(gint error_nr);
-
 void dialogs_show_file_properties(gint idx);
 
 gboolean dialogs_show_question(const gchar *text, ...);

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-07-25 12:44:42 UTC (rev 628)
+++ trunk/src/document.c	2006-07-25 12:46:08 UTC (rev 629)
@@ -348,7 +348,9 @@
 
 		if (idx == -1)
 		{
-			dialogs_show_file_open_error();
+			dialogs_show_error(
+			_("You have opened too many files. There is a limit of %d concurrent open files."),
+			GEANY_MAX_OPEN_FILES);
 			return;
 		}
 
@@ -377,7 +379,9 @@
 	}
 	else
 	{
-		dialogs_show_file_open_error();
+		dialogs_show_error(
+		_("You have opened too many files. There is a limit of %d concurrent open files."),
+		GEANY_MAX_OPEN_FILES);
 	}
 }
 
@@ -799,6 +803,8 @@
 }
 
 
+#define SEARCH_NOT_FOUND_TXT _("The match \"%s\" was not found. Wrap search around the document?")
+
 /* special search function, used from the find entry in the toolbar */
 void document_find_next(gint idx, const gchar *text, gint flags, gboolean find_button, gboolean inc)
 {
@@ -823,7 +829,7 @@
 	{
 		if (find_button)
 		{
-			if (dialogs_show_not_found(text))
+			if (dialogs_show_question(SEARCH_NOT_FOUND_TXT, text))
 			{
 				sci_goto_pos(doc_list[idx].sci, 0, FALSE);
 				document_find_next(idx, text, flags, TRUE, inc);
@@ -872,7 +878,7 @@
 	}
 	else
 	{
-		if (dialogs_show_not_found(text))
+		if (dialogs_show_question(SEARCH_NOT_FOUND_TXT, text))
 		{
 			sci_goto_pos(doc_list[idx].sci, (search_backwards) ? sci_get_length(doc_list[idx].sci) : 0, TRUE);
 			return document_find_text(idx, text, flags, search_backwards);

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2006-07-25 12:44:42 UTC (rev 628)
+++ trunk/src/main.c	2006-07-25 12:46:08 UTC (rev 629)
@@ -491,10 +491,16 @@
 	else config_dir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, NULL);
 
 	mkdir_result = utils_make_settings_dir(config_dir);
-	if (mkdir_result != 0 && ! dialogs_show_mkcfgdir_error(mkdir_result))
+	if (mkdir_result != 0)
 	{
-		g_free(config_dir);
-		return (0);
+		if (! dialogs_show_question(
+			_("Configuration directory could not be created (%s).\nThere could be some problems "
+			  "using %s without a configuration directory.\nStart %s anyway?"),
+			  g_strerror(mkdir_result), PACKAGE, PACKAGE))
+		{
+			g_free(config_dir);
+			return (0);
+		}
 	}
 
 #ifdef HAVE_FIFO
@@ -573,7 +579,9 @@
 				}
 				else
 				{
-					dialogs_show_file_open_error();
+					dialogs_show_error(
+			_("You have opened too many files. There is a limit of %d concurrent open files."),
+			GEANY_MAX_OPEN_FILES);
 					break;
 				}
 			}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Commits mailing list