Commit ea63204f authored by Tristan Van Berkom's avatar Tristan Van Berkom

removed glade_util_str_replace_char(), glade_util_replace() already


	* src/glade-utils.[ch]: removed glade_util_str_replace_char(),
	  glade_util_replace() already exists.

	* src/glade-project-window.c: Added clause to save recent files after opening and
	  saving projects and when clearing recent queue (i.e. save it when it changes, not
	  at quit time).
	  also fixed cosmetic bug: changed "Recents" to "Recent" in "Recent projects".

	* src/glade-app.c, src/glade-project-window.c: Dont allow more than one project
	  with the same name to be opened simultainiously (where the project name is
	  the basename of the project_path).
parent f3a0238e
2005-06-24 Tristan Van Berkom <tvb@gnome.org>
* src/glade-utils.[ch]: removed glade_util_str_replace_char(),
glade_util_replace() already exists.
* src/glade-project-window.c: Added clause to save recent files after opening and
saving projects and when clearing recent queue (i.e. save it when it changes, not
at quit time).
also fixed cosmetic bug: changed "Recents" to "Recent" in "Recent projects".
* src/glade-app.c, src/glade-project-window.c: Dont allow more than one project
with the same name to be opened simultainiously (where the project name is
the basename of the project_path).
2005-06-24 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* src/glade-app.[ch]: Added GKeyfile handleing
......
......@@ -483,22 +483,39 @@ on_project_selection_changed_cb (GladeProject *project, GladeApp *app)
}
}
gboolean glade_app_is_project_loaded (GladeApp *app, const gchar *project_path)
gboolean
glade_app_is_project_loaded (GladeApp *app, const gchar *project_path)
{
GList *list;
GList *list;
gchar *project_base;
gboolean loaded = FALSE;
if (project_path == NULL) return FALSE;
/* Only one project with the same basename can be loaded simultainiously */
project_base = g_path_get_basename (project_path);
for (list = app->priv->projects; list; list = list->next)
{
GladeProject *cur_project = GLADE_PROJECT (list->data);
gchar *this_base;
if (cur_project->path)
{
this_base = g_path_get_basename (cur_project->path);
if (!strcmp (this_base, project_base))
loaded = TRUE;
if (cur_project->path)
if (!strcmp (cur_project->path, project_path))
return TRUE;
g_free (this_base);
if (loaded)
break;
}
}
return FALSE;
g_free (project_base);
return loaded;
}
void
......
......@@ -196,7 +196,7 @@ gpw_recent_project_add (GladeProjectWindow *gpw, const gchar *project_path)
action_name = g_strdup_printf ("open[%s]", project_path);
/* We don't want '/'s in the menu path */
glade_util_str_replace_char (action_name, '/', ' ');
glade_util_replace (action_name, '/', ' ');
/* Add action */
action = gtk_action_new (action_name, label, NULL, NULL);
......@@ -324,8 +324,11 @@ gpw_recent_project_clear_cb (GtkAction *action, GladeProjectWindow *gpw)
gtk_widget_set_sensitive (gtk_ui_manager_get_widget
(gpw->priv->ui, "/MenuBar/FileMenu/Recents"),
FALSE);
/* Save it */
gpw_recent_project_config_save (gpw);
glade_app_config_save (GLADE_APP (gpw));
}
gtk_widget_destroy (dialog);
}
......@@ -342,6 +345,9 @@ gpw_save (GladeProjectWindow *gpw, GladeProject *project, const gchar *path)
}
gpw_recent_project_add (gpw, path);
gpw_recent_project_config_save (gpw);
glade_app_config_save (GLADE_APP (gpw));
gpw_refresh_project_entry (gpw, project);
gpw_refresh_title (gpw);
glade_util_flash_message (gpw->priv->statusbar,
......@@ -558,11 +564,6 @@ gpw_quit_cb (GtkAction *action, GladeProjectWindow *gpw)
do_close (gpw, project);
}
gpw_recent_project_config_save (gpw);
/* Save the configuration file */
glade_app_config_save (GLADE_APP (gpw));
gtk_main_quit ();
}
......@@ -1100,9 +1101,9 @@ static GtkActionEntry entries[] = {
{ "Open", GTK_STOCK_OPEN, "_Open","<control>O",
"Open a project file", G_CALLBACK (gpw_open_cb) },
{ "Recents", NULL, "Recents Projects", NULL, NULL },
{ "Recents", NULL, "Recent Projects", NULL, NULL },
{ "ClearRecents", GTK_STOCK_CLEAR, "Clear Recents Projects", NULL,
{ "ClearRecents", GTK_STOCK_CLEAR, "Clear Recent Projects", NULL,
NULL, G_CALLBACK (gpw_recent_project_clear_cb) },
{ "Save", GTK_STOCK_SAVE, "_Save","<control>S",
......@@ -1466,8 +1467,20 @@ glade_project_window_open_project (GladeProjectWindow *gpw, const gchar *path)
g_return_if_fail (path != NULL);
/* dont allow more than one project with the same name to be
* opened simultainiously.
*/
if (glade_app_is_project_loaded (GLADE_APP (gpw), (gchar*)path))
{
gchar *base_path = g_path_get_basename (path);
gchar *message = g_strdup_printf (_("A project named %s is already open"), base_path);
glade_util_ui_warn (gpw->priv->window, message);
g_free (message);
g_free (base_path);
return;
}
project = glade_project_open (path);
if (!project)
......@@ -1477,6 +1490,8 @@ glade_project_window_open_project (GladeProjectWindow *gpw, const gchar *path)
}
gpw_recent_project_add (gpw, path);
gpw_recent_project_config_save (gpw);
glade_app_config_save (GLADE_APP (gpw));
glade_project_window_add_project (gpw, project);
}
......
......@@ -457,13 +457,13 @@ glade_util_file_dialog_new (const gchar *title, GtkWindow *parent,
/**
* glade_util_replace:
* @str: a string
* @a: a #char
* @b: a #char
* @a: a #gchar
* @b: a #gchar
*
* Replaces each occurance of the character @a in @str to @b.
*/
void
glade_util_replace (char *str, char a, char b)
glade_util_replace (gchar *str, gchar a, gchar b)
{
g_return_if_fail (str != NULL);
......@@ -1269,20 +1269,4 @@ glade_util_find_iter_by_widget (GtkTreeModel *model,
return NULL;
}
/**
* glade_util_str_replace_char
* @str the string to replace
* @dest the character to replace
* @src the character to replace with
*/
void
glade_util_str_replace_char (gchar *str, gchar dest, gchar src)
{
gchar *tmp = str;
while (*tmp != '\0')
{
if (*tmp == src) *tmp = dest;
tmp++;
}
}
......@@ -71,8 +71,6 @@ LIBGLADEUI_API GtkTreeIter *glade_util_find_iter_by_widget (GtkTreeModel *m
GladeWidget *findme,
gint column);
LIBGLADEUI_API void glade_util_str_replace_char (gchar *str, gchar dest, gchar src);
G_END_DECLS
#endif /* __GLADE_UTILS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment