Made moo_edit_get_filename() return duplicated string
This commit is contained in:
parent
c9336fe3bd
commit
2902ce6aed
4
moo.mprj
4
moo.mprj
@ -13,8 +13,8 @@
|
|||||||
<configure>
|
<configure>
|
||||||
<args>--enable-debug=full --enable-all-warnings --enable-project</args>
|
<args>--enable-debug=full --enable-all-warnings --enable-project</args>
|
||||||
<vars>
|
<vars>
|
||||||
<var name="CFLAGS">-g</var>
|
|
||||||
<var name="OBJCFLAGS">-g</var>
|
<var name="OBJCFLAGS">-g</var>
|
||||||
|
<var name="CFLAGS">-g</var>
|
||||||
</vars>
|
</vars>
|
||||||
</configure>
|
</configure>
|
||||||
</debug>
|
</debug>
|
||||||
@ -37,8 +37,8 @@
|
|||||||
<build_dir>build/optimized</build_dir>
|
<build_dir>build/optimized</build_dir>
|
||||||
<configure>
|
<configure>
|
||||||
<vars>
|
<vars>
|
||||||
<var name="CFLAGS">-O2 -g</var>
|
|
||||||
<var name="OBJCFLAGS">-O2 -g</var>
|
<var name="OBJCFLAGS">-O2 -g</var>
|
||||||
|
<var name="CFLAGS">-O2 -g</var>
|
||||||
</vars>
|
</vars>
|
||||||
</configure>
|
</configure>
|
||||||
</optimized>
|
</optimized>
|
||||||
|
@ -241,8 +241,9 @@ run_in_pane (MooCommandExe *cmd,
|
|||||||
|
|
||||||
if (filter)
|
if (filter)
|
||||||
{
|
{
|
||||||
const char *fn = MOO_IS_EDIT (doc) ? moo_edit_get_filename (MOO_EDIT (doc)) : NULL;
|
char *fn = MOO_IS_EDIT (doc) ? moo_edit_get_filename (MOO_EDIT (doc)) : NULL;
|
||||||
moo_output_filter_set_active_file (filter, fn);
|
moo_output_filter_set_active_file (filter, fn);
|
||||||
|
g_free (fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
moo_cmd_view_set_filter (MOO_CMD_VIEW (output), filter);
|
moo_cmd_view_set_filter (MOO_CMD_VIEW (output), filter);
|
||||||
@ -351,12 +352,15 @@ create_environment (MooCommandContext *ctx,
|
|||||||
*envp = NULL;
|
*envp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*working_dir = NULL;
|
||||||
doc = moo_command_context_get_doc (ctx);
|
doc = moo_command_context_get_doc (ctx);
|
||||||
|
|
||||||
if (doc && moo_edit_get_filename (doc))
|
if (doc && !moo_edit_is_untitled (doc))
|
||||||
*working_dir = g_path_get_dirname (moo_edit_get_filename (doc));
|
{
|
||||||
else
|
char *filename = moo_edit_get_filename (doc);
|
||||||
*working_dir = NULL;
|
*working_dir = g_path_get_dirname (filename);
|
||||||
|
g_free (filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ moo_command_check_sensitive_real (MooCommand *cmd,
|
|||||||
if ((cmd->options & MOO_COMMAND_NEED_DOC) && !doc)
|
if ((cmd->options & MOO_COMMAND_NEED_DOC) && !doc)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((cmd->options & MOO_COMMAND_NEED_FILE) && (!MOO_IS_EDIT (doc) || !moo_edit_get_filename (doc)))
|
if ((cmd->options & MOO_COMMAND_NEED_FILE) && (!MOO_IS_EDIT (doc) || moo_edit_is_untitled (doc)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -411,7 +411,7 @@ check_context (MooCommandOptions options,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((options & MOO_COMMAND_NEED_FILE) &&
|
if ((options & MOO_COMMAND_NEED_FILE) &&
|
||||||
!(MOO_IS_EDIT (doc) && moo_edit_get_filename (doc) != NULL))
|
!(MOO_IS_EDIT (doc) && !moo_edit_is_untitled (doc)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((options & MOO_COMMAND_NEED_SAVE) && !MOO_IS_EDIT (doc))
|
if ((options & MOO_COMMAND_NEED_SAVE) && !MOO_IS_EDIT (doc))
|
||||||
@ -442,9 +442,7 @@ moo_command_run (MooCommand *cmd,
|
|||||||
}
|
}
|
||||||
else if (cmd->options & MOO_COMMAND_NEED_SAVE)
|
else if (cmd->options & MOO_COMMAND_NEED_SAVE)
|
||||||
{
|
{
|
||||||
if (!save_one (doc))
|
if (!save_one (doc) || moo_edit_is_untitled (doc))
|
||||||
return;
|
|
||||||
if (!moo_edit_get_filename (doc))
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,16 @@ void _moo_edit_create_progress_dialog (MooEdit *edit);
|
|||||||
void _moo_edit_set_progress_text (MooEdit *edit,
|
void _moo_edit_set_progress_text (MooEdit *edit,
|
||||||
const char *text);
|
const char *text);
|
||||||
|
|
||||||
|
GdkPixbuf *_moo_edit_get_icon (MooEdit *edit,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GtkIconSize size);
|
||||||
|
|
||||||
|
#define MOO_EDIT_IS_UNTITLED(edit) (!(edit)->priv->filename)
|
||||||
|
|
||||||
|
struct _MooEditFileInfo {
|
||||||
|
char *filename;
|
||||||
|
char *encoding;
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MOO_EDIT_LINE_END_NONE,
|
MOO_EDIT_LINE_END_NONE,
|
||||||
@ -117,7 +127,6 @@ struct _MooEditPrivate {
|
|||||||
/* Document
|
/* Document
|
||||||
*/
|
*/
|
||||||
char *filename;
|
char *filename;
|
||||||
char *basename;
|
|
||||||
char *display_filename;
|
char *display_filename;
|
||||||
char *display_basename;
|
char *display_basename;
|
||||||
|
|
||||||
|
@ -151,18 +151,23 @@ moo_edit_script_context_set_doc (MooEditScriptContext *ctx,
|
|||||||
|
|
||||||
if (MOO_IS_EDIT (doc))
|
if (MOO_IS_EDIT (doc))
|
||||||
{
|
{
|
||||||
|
char *filename = NULL, *basename = NULL;
|
||||||
char *dirname = NULL, *base = NULL, *ext = NULL;
|
char *dirname = NULL, *base = NULL, *ext = NULL;
|
||||||
|
|
||||||
if (moo_edit_get_basename (MOO_EDIT (doc)))
|
filename = moo_edit_get_filename (MOO_EDIT (doc));
|
||||||
get_extension (moo_edit_get_basename (MOO_EDIT (doc)), &base, &ext);
|
|
||||||
|
|
||||||
if (moo_edit_get_filename (MOO_EDIT (doc)))
|
if (filename)
|
||||||
dirname = g_path_get_dirname (moo_edit_get_filename (MOO_EDIT (doc)));
|
{
|
||||||
|
basename = g_path_get_basename (filename);
|
||||||
|
|
||||||
ms_value_dict_set_string (val, MS_VAR_FILE,
|
if (basename)
|
||||||
moo_edit_get_filename (MOO_EDIT (doc)));
|
get_extension (basename, &base, &ext);
|
||||||
ms_value_dict_set_string (val, MS_VAR_NAME,
|
|
||||||
moo_edit_get_basename (MOO_EDIT (doc)));
|
dirname = g_path_get_dirname (filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
ms_value_dict_set_string (val, MS_VAR_FILE, filename);
|
||||||
|
ms_value_dict_set_string (val, MS_VAR_NAME, basename);
|
||||||
ms_value_dict_set_string (val, MS_VAR_BASE, base);
|
ms_value_dict_set_string (val, MS_VAR_BASE, base);
|
||||||
ms_value_dict_set_string (val, MS_VAR_DIR, dirname);
|
ms_value_dict_set_string (val, MS_VAR_DIR, dirname);
|
||||||
ms_value_dict_set_string (val, MS_VAR_EXT, ext);
|
ms_value_dict_set_string (val, MS_VAR_EXT, ext);
|
||||||
@ -170,6 +175,8 @@ moo_edit_script_context_set_doc (MooEditScriptContext *ctx,
|
|||||||
g_free (base);
|
g_free (base);
|
||||||
g_free (ext);
|
g_free (ext);
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
|
g_free (basename);
|
||||||
|
g_free (filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -298,7 +298,6 @@ moo_edit_finalize (GObject *object)
|
|||||||
MooEdit *edit = MOO_EDIT (object);
|
MooEdit *edit = MOO_EDIT (object);
|
||||||
|
|
||||||
g_free (edit->priv->filename);
|
g_free (edit->priv->filename);
|
||||||
g_free (edit->priv->basename);
|
|
||||||
g_free (edit->priv->display_filename);
|
g_free (edit->priv->display_filename);
|
||||||
g_free (edit->priv->display_basename);
|
g_free (edit->priv->display_basename);
|
||||||
g_free (edit->priv->encoding);
|
g_free (edit->priv->encoding);
|
||||||
@ -502,7 +501,7 @@ moo_edit_is_empty (MooEdit *edit)
|
|||||||
|
|
||||||
g_return_val_if_fail (MOO_IS_EDIT (edit), FALSE);
|
g_return_val_if_fail (MOO_IS_EDIT (edit), FALSE);
|
||||||
|
|
||||||
if (MOO_EDIT_IS_BUSY (edit) || MOO_EDIT_IS_MODIFIED (edit) || edit->priv->filename)
|
if (MOO_EDIT_IS_BUSY (edit) || MOO_EDIT_IS_MODIFIED (edit) || !MOO_EDIT_IS_UNTITLED (edit))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
gtk_text_buffer_get_bounds (get_buffer (edit), &start, &end);
|
gtk_text_buffer_get_bounds (get_buffer (edit), &start, &end);
|
||||||
@ -510,6 +509,13 @@ moo_edit_is_empty (MooEdit *edit)
|
|||||||
return !gtk_text_iter_compare (&start, &end);
|
return !gtk_text_iter_compare (&start, &end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
moo_edit_is_untitled (MooEdit *edit)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MOO_IS_EDIT (edit), FALSE);
|
||||||
|
return MOO_EDIT_IS_UNTITLED (edit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MooEditStatus
|
MooEditStatus
|
||||||
moo_edit_get_status (MooEdit *edit)
|
moo_edit_get_status (MooEdit *edit)
|
||||||
@ -617,22 +623,15 @@ moo_edit_file_info_get_type (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
char *
|
||||||
moo_edit_get_filename (MooEdit *edit)
|
moo_edit_get_filename (MooEdit *edit)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
||||||
return edit->priv->filename;
|
return g_strdup (edit->priv->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
moo_edit_get_basename (MooEdit *edit)
|
moo_edit_get_display_name (MooEdit *edit)
|
||||||
{
|
|
||||||
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
|
||||||
return edit->priv->basename;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
moo_edit_get_display_filename (MooEdit *edit)
|
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
||||||
return edit->priv->display_filename;
|
return edit->priv->display_filename;
|
||||||
@ -645,14 +644,6 @@ moo_edit_get_display_basename (MooEdit *edit)
|
|||||||
return edit->priv->display_basename;
|
return edit->priv->display_basename;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
|
||||||
moo_edit_get_encoding (MooEdit *edit)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
|
||||||
return edit->priv->encoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
moo_edit_get_uri (MooEdit *edit)
|
moo_edit_get_uri (MooEdit *edit)
|
||||||
{
|
{
|
||||||
@ -664,6 +655,13 @@ moo_edit_get_uri (MooEdit *edit)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
moo_edit_get_encoding (MooEdit *edit)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MOO_IS_EDIT (edit), NULL);
|
||||||
|
return edit->priv->encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static GtkTextBuffer *
|
static GtkTextBuffer *
|
||||||
get_buffer (MooEdit *edit)
|
get_buffer (MooEdit *edit)
|
||||||
|
@ -58,11 +58,6 @@ typedef struct _MooEditPrivate MooEditPrivate;
|
|||||||
typedef struct _MooEditClass MooEditClass;
|
typedef struct _MooEditClass MooEditClass;
|
||||||
|
|
||||||
|
|
||||||
struct _MooEditFileInfo {
|
|
||||||
char *filename;
|
|
||||||
char *encoding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _MooEdit
|
struct _MooEdit
|
||||||
{
|
{
|
||||||
MooTextView parent;
|
MooTextView parent;
|
||||||
@ -92,19 +87,19 @@ struct _MooEditClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GType moo_edit_get_type (void) G_GNUC_CONST;
|
GType moo_edit_get_type (void) G_GNUC_CONST;
|
||||||
GType moo_edit_file_info_get_type (void) G_GNUC_CONST;
|
GType moo_edit_file_info_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
const char *moo_edit_get_filename (MooEdit *edit);
|
char *moo_edit_get_uri (MooEdit *edit);
|
||||||
const char *moo_edit_get_basename (MooEdit *edit);
|
char *moo_edit_get_filename (MooEdit *edit);
|
||||||
const char *moo_edit_get_display_filename (MooEdit *edit);
|
char *moo_edit_get_basename (MooEdit *edit);
|
||||||
|
const char *moo_edit_get_display_name (MooEdit *edit);
|
||||||
const char *moo_edit_get_display_basename (MooEdit *edit);
|
const char *moo_edit_get_display_basename (MooEdit *edit);
|
||||||
|
|
||||||
const char *moo_edit_get_encoding (MooEdit *edit);
|
const char *moo_edit_get_encoding (MooEdit *edit);
|
||||||
|
|
||||||
char *moo_edit_get_uri (MooEdit *edit);
|
|
||||||
|
|
||||||
gboolean moo_edit_is_empty (MooEdit *edit);
|
gboolean moo_edit_is_empty (MooEdit *edit);
|
||||||
|
gboolean moo_edit_is_untitled (MooEdit *edit);
|
||||||
void moo_edit_set_modified (MooEdit *edit,
|
void moo_edit_set_modified (MooEdit *edit,
|
||||||
gboolean modified);
|
gboolean modified);
|
||||||
gboolean moo_edit_get_clean (MooEdit *edit);
|
gboolean moo_edit_get_clean (MooEdit *edit);
|
||||||
|
@ -136,7 +136,7 @@ _moo_edit_save_changes_dialog (MooEdit *edit)
|
|||||||
{
|
{
|
||||||
GtkDialog *dialog = NULL;
|
GtkDialog *dialog = NULL;
|
||||||
int response;
|
int response;
|
||||||
const char *name = moo_edit_get_display_basename (edit);
|
const char *name;
|
||||||
|
|
||||||
g_return_val_if_fail (MOO_IS_EDIT (edit), MOO_EDIT_RESPONSE_CANCEL);
|
g_return_val_if_fail (MOO_IS_EDIT (edit), MOO_EDIT_RESPONSE_CANCEL);
|
||||||
name = moo_edit_get_display_basename (edit);
|
name = moo_edit_get_display_basename (edit);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "mooedit/mooeditdialogs.h"
|
#include "mooedit/mooeditdialogs.h"
|
||||||
#include "mooedit/mootextbuffer.h"
|
#include "mooedit/mootextbuffer.h"
|
||||||
#include "mooedit/mooeditprefs.h"
|
#include "mooedit/mooeditprefs.h"
|
||||||
|
#include "moofileview/moofile.h"
|
||||||
#include "mooutils/moofilewatch.h"
|
#include "mooutils/moofilewatch.h"
|
||||||
#include "mooutils/mooencodings.h"
|
#include "mooutils/mooencodings.h"
|
||||||
#include "mooutils/mooi18n.h"
|
#include "mooutils/mooi18n.h"
|
||||||
@ -1203,10 +1204,9 @@ _moo_edit_set_filename (MooEdit *edit,
|
|||||||
const char *file,
|
const char *file,
|
||||||
const char *encoding)
|
const char *encoding)
|
||||||
{
|
{
|
||||||
char *tmp1, *tmp2, *tmp3, *tmp4, *tmp5;
|
char *tmp1, *tmp3, *tmp4, *tmp5;
|
||||||
|
|
||||||
tmp1 = edit->priv->filename;
|
tmp1 = edit->priv->filename;
|
||||||
tmp2 = edit->priv->basename;
|
|
||||||
tmp3 = edit->priv->display_filename;
|
tmp3 = edit->priv->display_filename;
|
||||||
tmp4 = edit->priv->display_basename;
|
tmp4 = edit->priv->display_basename;
|
||||||
tmp5 = edit->priv->encoding;
|
tmp5 = edit->priv->encoding;
|
||||||
@ -1219,7 +1219,6 @@ _moo_edit_set_filename (MooEdit *edit,
|
|||||||
int n = add_untitled (edit);
|
int n = add_untitled (edit);
|
||||||
|
|
||||||
edit->priv->filename = NULL;
|
edit->priv->filename = NULL;
|
||||||
edit->priv->basename = NULL;
|
|
||||||
|
|
||||||
if (n == 1)
|
if (n == 1)
|
||||||
edit->priv->display_filename = g_strdup (_("Untitled"));
|
edit->priv->display_filename = g_strdup (_("Untitled"));
|
||||||
@ -1230,15 +1229,17 @@ _moo_edit_set_filename (MooEdit *edit,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
char *basename;
|
||||||
|
|
||||||
remove_untitled (NULL, edit);
|
remove_untitled (NULL, edit);
|
||||||
|
|
||||||
edit->priv->filename = g_strdup (file);
|
edit->priv->filename = g_strdup (file);
|
||||||
edit->priv->basename = g_path_get_basename (file);
|
edit->priv->display_filename = _moo_edit_filename_to_utf8 (file);
|
||||||
|
|
||||||
edit->priv->display_filename =
|
basename = g_path_get_basename (file);
|
||||||
_moo_edit_filename_to_utf8 (file);
|
edit->priv->display_basename = _moo_edit_filename_to_utf8 (basename);
|
||||||
edit->priv->display_basename =
|
|
||||||
_moo_edit_filename_to_utf8 (edit->priv->basename);
|
g_free (basename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!encoding)
|
if (!encoding)
|
||||||
@ -1249,7 +1250,6 @@ _moo_edit_set_filename (MooEdit *edit,
|
|||||||
moo_edit_status_changed (edit);
|
moo_edit_status_changed (edit);
|
||||||
|
|
||||||
g_free (tmp1);
|
g_free (tmp1);
|
||||||
g_free (tmp2);
|
|
||||||
g_free (tmp3);
|
g_free (tmp3);
|
||||||
g_free (tmp4);
|
g_free (tmp4);
|
||||||
g_free (tmp5);
|
g_free (tmp5);
|
||||||
@ -1282,3 +1282,12 @@ _moo_edit_filename_to_utf8 (const char *filename)
|
|||||||
|
|
||||||
return utf_filename;
|
return utf_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GdkPixbuf *
|
||||||
|
_moo_edit_get_icon (MooEdit *doc,
|
||||||
|
GtkWidget *widget,
|
||||||
|
GtkIconSize size)
|
||||||
|
{
|
||||||
|
return _moo_get_icon_for_path (doc->priv->filename, widget, size);
|
||||||
|
}
|
||||||
|
@ -802,11 +802,18 @@ window_info_remove (WindowInfo *win,
|
|||||||
static int
|
static int
|
||||||
edit_and_file_cmp (MooEdit *edit, const char *filename)
|
edit_and_file_cmp (MooEdit *edit, const char *filename)
|
||||||
{
|
{
|
||||||
const char *edit_filename;
|
char *edit_filename;
|
||||||
|
|
||||||
g_return_val_if_fail (MOO_IS_EDIT (edit) && filename != NULL, TRUE);
|
g_return_val_if_fail (MOO_IS_EDIT (edit) && filename != NULL, TRUE);
|
||||||
|
|
||||||
edit_filename = moo_edit_get_filename (edit);
|
edit_filename = moo_edit_get_filename (edit);
|
||||||
|
|
||||||
if (edit_filename)
|
if (edit_filename)
|
||||||
return strcmp (edit_filename, filename);
|
{
|
||||||
|
int result = strcmp (edit_filename, filename);
|
||||||
|
g_free (edit_filename);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1023,9 +1030,9 @@ moo_editor_add_doc (MooEditor *editor,
|
|||||||
|
|
||||||
window_info_add (info, doc);
|
window_info_add (info, doc);
|
||||||
|
|
||||||
if (!moo_edit_get_filename (doc) &&
|
if (moo_edit_is_untitled (doc) &&
|
||||||
!moo_edit_config_get_string (doc->config, "lang") &&
|
!moo_edit_config_get_string (doc->config, "lang") &&
|
||||||
editor->priv->default_lang)
|
editor->priv->default_lang)
|
||||||
{
|
{
|
||||||
moo_edit_config_set (doc->config, MOO_EDIT_CONFIG_SOURCE_FILENAME,
|
moo_edit_config_set (doc->config, MOO_EDIT_CONFIG_SOURCE_FILENAME,
|
||||||
"lang", editor->priv->default_lang, NULL);
|
"lang", editor->priv->default_lang, NULL);
|
||||||
@ -1811,7 +1818,7 @@ static MooMarkupNode *
|
|||||||
save_doc_session (MooEdit *doc,
|
save_doc_session (MooEdit *doc,
|
||||||
MooMarkupNode *elm)
|
MooMarkupNode *elm)
|
||||||
{
|
{
|
||||||
const char *filename;
|
char *filename;
|
||||||
const char *encoding;
|
const char *encoding;
|
||||||
MooMarkupNode *node;
|
MooMarkupNode *node;
|
||||||
|
|
||||||
@ -1838,6 +1845,7 @@ save_doc_session (MooEdit *doc,
|
|||||||
node = moo_markup_create_element (elm, "document");
|
node = moo_markup_create_element (elm, "document");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (filename);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2178,7 +2186,7 @@ _moo_editor_reload (MooEditor *editor,
|
|||||||
g_return_if_fail (info != NULL);
|
g_return_if_fail (info != NULL);
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
g_return_if_fail (moo_edit_get_filename (doc) != NULL);
|
g_return_if_fail (!moo_edit_is_untitled (doc));
|
||||||
|
|
||||||
if (!editor->priv->silent &&
|
if (!editor->priv->silent &&
|
||||||
!MOO_EDIT_IS_CLEAN (doc) &&
|
!MOO_EDIT_IS_CLEAN (doc) &&
|
||||||
@ -2262,10 +2270,10 @@ _moo_editor_save (MooEditor *editor,
|
|||||||
info = window_list_find_doc (editor, doc);
|
info = window_list_find_doc (editor, doc);
|
||||||
g_return_val_if_fail (info != NULL, FALSE);
|
g_return_val_if_fail (info != NULL, FALSE);
|
||||||
|
|
||||||
if (!moo_edit_get_filename (doc))
|
if (moo_edit_is_untitled (doc))
|
||||||
return _moo_editor_save_as (editor, doc, NULL, NULL, error);
|
return _moo_editor_save_as (editor, doc, NULL, NULL, error);
|
||||||
|
|
||||||
filename = g_strdup (moo_edit_get_filename (doc));
|
filename = moo_edit_get_filename (doc);
|
||||||
encoding = g_strdup (moo_edit_get_encoding (doc));
|
encoding = g_strdup (moo_edit_get_encoding (doc));
|
||||||
|
|
||||||
if (!editor->priv->silent &&
|
if (!editor->priv->silent &&
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "mooutils/mooi18n.h"
|
#include "mooutils/mooi18n.h"
|
||||||
#include "mooutils/mooaction-private.h"
|
#include "mooutils/mooaction-private.h"
|
||||||
#include "mooutils/moofiledialog.h"
|
#include "mooutils/moofiledialog.h"
|
||||||
#include "moofileview/moofile.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -973,7 +972,7 @@ static void moo_edit_window_get_property(GObject *object,
|
|||||||
|
|
||||||
case PROP_CAN_RELOAD:
|
case PROP_CAN_RELOAD:
|
||||||
doc = ACTIVE_DOC (window);
|
doc = ACTIVE_DOC (window);
|
||||||
g_value_set_boolean (value, doc && moo_edit_get_filename (doc));
|
g_value_set_boolean (value, doc && !moo_edit_is_untitled (doc));
|
||||||
break;
|
break;
|
||||||
case PROP_HAS_OPEN_DOCUMENT:
|
case PROP_HAS_OPEN_DOCUMENT:
|
||||||
g_value_set_boolean (value, ACTIVE_DOC (window) != NULL);
|
g_value_set_boolean (value, ACTIVE_DOC (window) != NULL);
|
||||||
@ -1095,7 +1094,7 @@ update_window_title (MooEditWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (window->priv->use_full_name)
|
if (window->priv->use_full_name)
|
||||||
name = moo_edit_get_display_filename (edit);
|
name = moo_edit_get_display_name (edit);
|
||||||
else
|
else
|
||||||
name = moo_edit_get_display_basename (edit);
|
name = moo_edit_get_display_basename (edit);
|
||||||
|
|
||||||
@ -1144,6 +1143,7 @@ update_window_title (MooEditWindow *window)
|
|||||||
g_string_append_printf (title, doc_title_format, name);
|
g_string_append_printf (title, doc_title_format, name);
|
||||||
|
|
||||||
gtk_window_set_title (GTK_WINDOW (window), title->str);
|
gtk_window_set_title (GTK_WINDOW (window), title->str);
|
||||||
|
|
||||||
g_string_free (title, TRUE);
|
g_string_free (title, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2584,9 +2584,7 @@ update_tab_label (MooEditWindow *window,
|
|||||||
moo_edit_get_display_basename (doc));
|
moo_edit_get_display_basename (doc));
|
||||||
gtk_label_set_text (GTK_LABEL (label), label_text);
|
gtk_label_set_text (GTK_LABEL (label), label_text);
|
||||||
|
|
||||||
/* XXX */
|
pixbuf = _moo_edit_get_icon (doc, icon, GTK_ICON_SIZE_MENU);
|
||||||
pixbuf = _moo_get_icon_for_path (moo_edit_get_filename (doc),
|
|
||||||
icon, GTK_ICON_SIZE_MENU);
|
|
||||||
set_tab_icon (icon, evbox, pixbuf);
|
set_tab_icon (icon, evbox, pixbuf);
|
||||||
|
|
||||||
g_free (label_text);
|
g_free (label_text);
|
||||||
@ -3736,11 +3734,16 @@ compare_doc_list_actions (gpointer a1,
|
|||||||
gpointer a2)
|
gpointer a2)
|
||||||
{
|
{
|
||||||
MooEdit *d1, *d2;
|
MooEdit *d1, *d2;
|
||||||
|
int result;
|
||||||
|
|
||||||
d1 = g_object_get_data (a1, "moo-edit");
|
d1 = g_object_get_data (a1, "moo-edit");
|
||||||
d2 = g_object_get_data (a2, "moo-edit");
|
d2 = g_object_get_data (a2, "moo-edit");
|
||||||
g_return_val_if_fail (d1 && d2, -1);
|
g_return_val_if_fail (d1 && d2, -1);
|
||||||
return strcmp (moo_edit_get_display_basename (d1),
|
|
||||||
moo_edit_get_display_basename (d2));
|
result = strcmp (moo_edit_get_display_basename (d1),
|
||||||
|
moo_edit_get_display_basename (d2));
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3796,7 +3799,7 @@ do_update_doc_list (MooEditWindow *window)
|
|||||||
{
|
{
|
||||||
g_object_set (action,
|
g_object_set (action,
|
||||||
"label", moo_edit_get_display_basename (doc),
|
"label", moo_edit_get_display_basename (doc),
|
||||||
"tooltip", moo_edit_get_display_filename (doc),
|
"tooltip", moo_edit_get_display_name (doc),
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3806,7 +3809,7 @@ do_update_doc_list (MooEditWindow *window)
|
|||||||
action = g_object_new (MOO_TYPE_RADIO_ACTION ,
|
action = g_object_new (MOO_TYPE_RADIO_ACTION ,
|
||||||
"name", name,
|
"name", name,
|
||||||
"label", moo_edit_get_display_basename (doc),
|
"label", moo_edit_get_display_basename (doc),
|
||||||
"tooltip", moo_edit_get_display_filename (doc),
|
"tooltip", moo_edit_get_display_name (doc),
|
||||||
"use-underline", FALSE,
|
"use-underline", FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
g_object_set_data_full (doc, "moo-doc-list-action", action, g_object_unref);
|
g_object_set_data_full (doc, "moo-doc-list-action", action, g_object_unref);
|
||||||
|
@ -1622,9 +1622,12 @@ do_print_operation (GtkTextView *view,
|
|||||||
op->priv->parent = GTK_WINDOW (parent);
|
op->priv->parent = GTK_WINDOW (parent);
|
||||||
|
|
||||||
if (MOO_IS_EDIT (view))
|
if (MOO_IS_EDIT (view))
|
||||||
moo_print_operation_set_filename (op,
|
{
|
||||||
moo_edit_get_display_filename (MOO_EDIT (view)),
|
const char *filename, *basename;
|
||||||
moo_edit_get_display_basename (MOO_EDIT (view)));
|
filename = moo_edit_get_display_name (MOO_EDIT (view));
|
||||||
|
basename = moo_edit_get_display_basename (MOO_EDIT (view));
|
||||||
|
moo_print_operation_set_filename (op, filename, basename);
|
||||||
|
}
|
||||||
|
|
||||||
res = gtk_print_operation_run (GTK_PRINT_OPERATION (op),
|
res = gtk_print_operation_run (GTK_PRINT_OPERATION (op),
|
||||||
action, op->priv->parent, &error);
|
action, op->priv->parent, &error);
|
||||||
|
@ -1129,13 +1129,13 @@ create_command_context (gpointer window,
|
|||||||
|
|
||||||
ctx = moo_command_context_new (doc, window);
|
ctx = moo_command_context_new (doc, window);
|
||||||
|
|
||||||
if (MOO_IS_EDIT (doc) && moo_edit_get_filename (doc))
|
if (MOO_IS_EDIT (doc) && !moo_edit_is_untitled (doc))
|
||||||
{
|
{
|
||||||
const char *filename, *basename;
|
char *filename, *basename;
|
||||||
char *dirname, *base = NULL, *extension = NULL;
|
char *dirname, *base = NULL, *extension = NULL;
|
||||||
|
|
||||||
filename = moo_edit_get_filename (doc);
|
filename = moo_edit_get_filename (doc);
|
||||||
basename = moo_edit_get_basename (doc);
|
basename = filename ? g_path_get_basename (filename) : NULL;
|
||||||
dirname = g_path_get_dirname (filename);
|
dirname = g_path_get_dirname (filename);
|
||||||
get_extension (basename, &base, &extension);
|
get_extension (basename, &base, &extension);
|
||||||
|
|
||||||
@ -1147,6 +1147,8 @@ create_command_context (gpointer window,
|
|||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
g_free (base);
|
g_free (base);
|
||||||
g_free (extension);
|
g_free (extension);
|
||||||
|
g_free (basename);
|
||||||
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MOO_IS_EDIT (doc))
|
if (MOO_IS_EDIT (doc))
|
||||||
|
@ -337,7 +337,7 @@ static void
|
|||||||
goto_current_doc_dir (MooFileSelector *filesel)
|
goto_current_doc_dir (MooFileSelector *filesel)
|
||||||
{
|
{
|
||||||
MooEdit *doc;
|
MooEdit *doc;
|
||||||
const char *filename;
|
char *filename;
|
||||||
|
|
||||||
doc = moo_edit_window_get_active_doc (filesel->window);
|
doc = moo_edit_window_get_active_doc (filesel->window);
|
||||||
filename = doc ? moo_edit_get_filename (doc) : NULL;
|
filename = doc ? moo_edit_get_filename (doc) : NULL;
|
||||||
@ -349,6 +349,8 @@ goto_current_doc_dir (MooFileSelector *filesel)
|
|||||||
moo_file_selector_select_file (filesel, filename, dirname);
|
moo_file_selector_select_file (filesel, filename, dirname);
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1092,7 +1094,9 @@ doc_move (MooFileSelector *filesel,
|
|||||||
{
|
{
|
||||||
char *filename, *old_filename;
|
char *filename, *old_filename;
|
||||||
|
|
||||||
old_filename = g_strdup (moo_edit_get_filename (doc));
|
old_filename = moo_edit_get_filename (doc);
|
||||||
|
/* XXX non-local */
|
||||||
|
g_return_if_fail (old_filename != NULL);
|
||||||
|
|
||||||
filename = save_as_dialog (GTK_WIDGET (filesel), destdir,
|
filename = save_as_dialog (GTK_WIDGET (filesel), destdir,
|
||||||
moo_edit_get_display_basename (doc),
|
moo_edit_get_display_basename (doc),
|
||||||
@ -1304,7 +1308,6 @@ moo_file_selector_drop_doc (MooFileSelector *filesel,
|
|||||||
int y,
|
int y,
|
||||||
guint time)
|
guint time)
|
||||||
{
|
{
|
||||||
const char *filename;
|
|
||||||
GdkModifierType mods;
|
GdkModifierType mods;
|
||||||
DropDocAction action;
|
DropDocAction action;
|
||||||
|
|
||||||
@ -1312,9 +1315,7 @@ moo_file_selector_drop_doc (MooFileSelector *filesel,
|
|||||||
g_return_if_fail (destdir != NULL);
|
g_return_if_fail (destdir != NULL);
|
||||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
|
|
||||||
filename = moo_edit_get_filename (doc);
|
if (moo_edit_is_untitled (doc))
|
||||||
|
|
||||||
if (!filename)
|
|
||||||
{
|
{
|
||||||
gboolean result = drop_untitled (filesel, doc, destdir,
|
gboolean result = drop_untitled (filesel, doc, destdir,
|
||||||
widget, context, x, y, time);
|
widget, context, x, y, time);
|
||||||
|
@ -415,12 +415,15 @@ init_dir_entry (MooHistoryCombo *hist_combo,
|
|||||||
if (!gtk_entry_get_text(GTK_ENTRY (entry))[0])
|
if (!gtk_entry_get_text(GTK_ENTRY (entry))[0])
|
||||||
{
|
{
|
||||||
MooFileEntryCompletion *completion;
|
MooFileEntryCompletion *completion;
|
||||||
|
char *filename;
|
||||||
|
|
||||||
completion = g_object_get_data (G_OBJECT (entry), "find-plugin-file-completion");
|
completion = g_object_get_data (G_OBJECT (entry), "find-plugin-file-completion");
|
||||||
|
|
||||||
if (doc && moo_edit_get_filename (doc))
|
filename = doc ? moo_edit_get_filename (doc) : NULL;
|
||||||
|
|
||||||
|
if (filename)
|
||||||
{
|
{
|
||||||
char *dir = g_path_get_dirname (moo_edit_get_filename (doc));
|
char *dir = g_path_get_dirname (filename);
|
||||||
_moo_file_entry_completion_set_path (completion, dir);
|
_moo_file_entry_completion_set_path (completion, dir);
|
||||||
g_free (dir);
|
g_free (dir);
|
||||||
}
|
}
|
||||||
@ -428,6 +431,8 @@ init_dir_entry (MooHistoryCombo *hist_combo,
|
|||||||
{
|
{
|
||||||
_moo_file_entry_completion_set_path (completion, g_get_home_dir ());
|
_moo_file_entry_completion_set_path (completion, g_get_home_dir ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -229,18 +229,12 @@
|
|||||||
(define-method get_filename
|
(define-method get_filename
|
||||||
(of-object "MooEdit")
|
(of-object "MooEdit")
|
||||||
(c-name "moo_edit_get_filename")
|
(c-name "moo_edit_get_filename")
|
||||||
(return-type "const-char*")
|
(return-type "char*")
|
||||||
)
|
)
|
||||||
|
|
||||||
(define-method get_basename
|
(define-method get_display_name
|
||||||
(of-object "MooEdit")
|
(of-object "MooEdit")
|
||||||
(c-name "moo_edit_get_basename")
|
(c-name "moo_edit_get_display_name")
|
||||||
(return-type "const-char*")
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-method get_display_filename
|
|
||||||
(of-object "MooEdit")
|
|
||||||
(c-name "moo_edit_get_display_filename")
|
|
||||||
(return-type "const-char*")
|
(return-type "const-char*")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user