Removed some unneeded functions to avoid duplicate code.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@629 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
ee196b6782
commit
902379738b
@ -3,6 +3,12 @@
|
|||||||
* src/encodings.c, src/document.c, src/keyfile.c, src/main.c:
|
* src/encodings.c, src/document.c, src/keyfile.c, src/main.c:
|
||||||
Save default encoding for new files as charset string.
|
Save default encoding for new files as charset string.
|
||||||
* src/filetypes.c: Reordered the filetypes (just a cosmetic change).
|
* 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@uvena.de>
|
2006-07-24 Enrico Tröger <enrico.troeger@uvena.de>
|
||||||
|
@ -848,7 +848,9 @@ on_file_open_dialog_response (GtkDialog *dialog,
|
|||||||
}
|
}
|
||||||
else
|
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);
|
g_slist_foreach(flist, (GFunc)g_free, NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,7 @@
|
|||||||
#include "win32.h"
|
#include "win32.h"
|
||||||
#include "sciwrappers.h"
|
#include "sciwrappers.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
//#include "interface.h"
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "prefs.h"
|
|
||||||
#include "keybindings.h"
|
#include "keybindings.h"
|
||||||
|
|
||||||
|
|
||||||
@ -148,7 +146,9 @@ void dialogs_show_open_file ()
|
|||||||
}
|
}
|
||||||
else
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,53 +212,6 @@ void dialogs_show_save_as ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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, ...)
|
void dialogs_show_info(const gchar *text, ...)
|
||||||
{
|
{
|
||||||
#ifndef GEANY_WIN32
|
#ifndef GEANY_WIN32
|
||||||
@ -272,11 +225,11 @@ void dialogs_show_info(const gchar *text, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
#ifdef GEANY_WIN32
|
#ifdef GEANY_WIN32
|
||||||
win32_message_dialog(GTK_MESSAGE_INFO, _("Information"), string);
|
win32_message_dialog(GTK_MESSAGE_INFO, string);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
|
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_dialog_run (GTK_DIALOG (dialog));
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
#endif
|
#endif
|
||||||
@ -297,10 +250,10 @@ void dialogs_show_error(const gchar *text, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
#ifdef GEANY_WIN32
|
#ifdef GEANY_WIN32
|
||||||
win32_message_dialog(GTK_MESSAGE_ERROR, _("Error"), string);
|
win32_message_dialog(GTK_MESSAGE_ERROR, string);
|
||||||
#else
|
#else
|
||||||
dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
|
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_dialog_run(GTK_DIALOG(dialog));
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
#endif
|
#endif
|
||||||
@ -329,10 +282,10 @@ gboolean dialogs_show_unsaved_file(gint idx)
|
|||||||
msg = g_strdup(_("The file is not saved.\nDo you want to save it before closing?"));
|
msg = g_strdup(_("The file is not saved.\nDo you want to save it before closing?"));
|
||||||
}
|
}
|
||||||
#ifdef GEANY_WIN32
|
#ifdef GEANY_WIN32
|
||||||
ret = win32_message_dialog_unsaved(_("Error"), msg);
|
ret = win32_message_dialog_unsaved(msg);
|
||||||
#else
|
#else
|
||||||
dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
|
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);
|
gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
|
||||||
|
|
||||||
@ -1378,30 +1331,6 @@ GtkWidget *dialogs_add_file_open_extra_widget(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// 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)
|
void dialogs_show_file_properties(gint idx)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog, *label, *table, *hbox, *image, *perm_table, *check;
|
GtkWidget *dialog, *label, *table, *hbox, *image, *perm_table, *check;
|
||||||
@ -1779,10 +1708,10 @@ gboolean dialogs_show_question(const gchar *text, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
#ifdef GEANY_WIN32
|
#ifdef GEANY_WIN32
|
||||||
ret = win32_message_dialog(GTK_MESSAGE_QUESTION, _("Question"), string);
|
ret = win32_message_dialog(GTK_MESSAGE_QUESTION, string);
|
||||||
#else
|
#else
|
||||||
dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
|
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)
|
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES)
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* 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$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
@ -30,10 +30,6 @@ void dialogs_show_open_file(void);
|
|||||||
/* This shows the file selection dialog to save a file. */
|
/* This shows the file selection dialog to save a file. */
|
||||||
void dialogs_show_save_as();
|
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_info(const gchar *text, ...);
|
||||||
|
|
||||||
void dialogs_show_error(const gchar *text, ...);
|
void dialogs_show_error(const gchar *text, ...);
|
||||||
@ -69,8 +65,6 @@ void dialogs_create_recent_menu(void);
|
|||||||
|
|
||||||
GtkWidget *dialogs_add_file_open_extra_widget(void);
|
GtkWidget *dialogs_add_file_open_extra_widget(void);
|
||||||
|
|
||||||
gboolean dialogs_show_mkcfgdir_error(gint error_nr);
|
|
||||||
|
|
||||||
void dialogs_show_file_properties(gint idx);
|
void dialogs_show_file_properties(gint idx);
|
||||||
|
|
||||||
gboolean dialogs_show_question(const gchar *text, ...);
|
gboolean dialogs_show_question(const gchar *text, ...);
|
||||||
|
@ -348,7 +348,9 @@ void document_new_file(filetype *ft)
|
|||||||
|
|
||||||
if (idx == -1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +379,9 @@ void document_new_file(filetype *ft)
|
|||||||
}
|
}
|
||||||
else
|
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 @@ void document_save_file(gint idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#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 */
|
/* 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)
|
void document_find_next(gint idx, const gchar *text, gint flags, gboolean find_button, gboolean inc)
|
||||||
{
|
{
|
||||||
@ -823,7 +829,7 @@ void document_find_next(gint idx, const gchar *text, gint flags, gboolean find_b
|
|||||||
{
|
{
|
||||||
if (find_button)
|
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);
|
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
|
||||||
document_find_next(idx, text, flags, TRUE, inc);
|
document_find_next(idx, text, flags, TRUE, inc);
|
||||||
@ -872,7 +878,7 @@ gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search
|
|||||||
}
|
}
|
||||||
else
|
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);
|
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);
|
return document_find_text(idx, text, flags, search_backwards);
|
||||||
|
12
src/main.c
12
src/main.c
@ -491,11 +491,17 @@ gint main(gint argc, gchar **argv)
|
|||||||
else config_dir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, NULL);
|
else config_dir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, NULL);
|
||||||
|
|
||||||
mkdir_result = utils_make_settings_dir(config_dir);
|
mkdir_result = utils_make_settings_dir(config_dir);
|
||||||
if (mkdir_result != 0 && ! dialogs_show_mkcfgdir_error(mkdir_result))
|
if (mkdir_result != 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);
|
g_free(config_dir);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_FIFO
|
#ifdef HAVE_FIFO
|
||||||
if (! ignore_fifo) ioc = create_fifo(argc, argv, config_dir);
|
if (! ignore_fifo) ioc = create_fifo(argc, argv, config_dir);
|
||||||
@ -573,7 +579,9 @@ gint main(gint argc, gchar **argv)
|
|||||||
}
|
}
|
||||||
else
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user