diff --git a/moo/mooedit/Makefile.incl b/moo/mooedit/Makefile.incl index 007c7f68..e046c9d5 100644 --- a/moo/mooedit/Makefile.incl +++ b/moo/mooedit/Makefile.incl @@ -16,6 +16,8 @@ moo_sources += \ mooedit/mooedit-fileops.h \ mooedit/mooeditfiltersettings.c \ mooedit/mooeditfiltersettings.h \ + mooedit/mooedithistoryitem.c \ + mooedit/mooedithistoryitem.h \ mooedit/mooedit-impl.h \ mooedit/mooeditor.c \ mooedit/mooeditor.h \ diff --git a/moo/mooedit/mooedit-impl.h b/moo/mooedit/mooedit-impl.h index a1cde744..3d77e51c 100644 --- a/moo/mooedit/mooedit-impl.h +++ b/moo/mooedit/mooedit-impl.h @@ -19,7 +19,7 @@ #include "mooedit/moolinemark.h" #include "mooedit/mooeditor.h" #include "mooedit/mootextview.h" -#include "mooutils/mdhistorymgr.h" +#include "mooutils/moohistorymgr.h" #include G_BEGIN_DECLS @@ -48,14 +48,6 @@ gboolean _moo_edit_line_mark_clicked (MooTextView *view, int line); void _moo_edit_update_bookmarks_style(MooEdit *edit); -void _moo_edit_history_item_set_encoding (MdHistoryItem *item, - const char *encoding); -void _moo_edit_history_item_set_line (MdHistoryItem *item, - int line); -const char *_moo_edit_history_item_get_encoding (MdHistoryItem *item); -int _moo_edit_history_item_get_line (MdHistoryItem *item); - - /***********************************************************************/ /* Preferences */ diff --git a/moo/mooedit/mooedit.c b/moo/mooedit/mooedit.c index e0068306..2774733c 100644 --- a/moo/mooedit/mooedit.c +++ b/moo/mooedit/mooedit.c @@ -714,52 +714,6 @@ moo_edit_get_editor (MooEdit *doc) } -void -_moo_edit_history_item_set_encoding (MdHistoryItem *item, - const char *encoding) -{ - g_return_if_fail (item != NULL); - md_history_item_set (item, KEY_ENCODING, encoding); -} - -void -_moo_edit_history_item_set_line (MdHistoryItem *item, - int line) -{ - char *value = NULL; - - g_return_if_fail (item != NULL); - - if (line >= 0) - value = g_strdup_printf ("%d", line + 1); - - md_history_item_set (item, KEY_LINE, value); - g_free (value); -} - -const char * -_moo_edit_history_item_get_encoding (MdHistoryItem *item) -{ - g_return_val_if_fail (item != NULL, NULL); - return md_history_item_get (item, KEY_ENCODING); -} - -int -_moo_edit_history_item_get_line (MdHistoryItem *item) -{ - const char *strval; - - g_return_val_if_fail (item != NULL, -1); - - strval = md_history_item_get (item, KEY_LINE); - - if (strval && strval[0]) - return strtol (strval, NULL, 10) - 1; - else - return -1; -} - - typedef void (*SetVarFunc) (MooEdit *edit, const char *name, char *val); diff --git a/moo/mooedit/mooedithistoryitem.c b/moo/mooedit/mooedithistoryitem.c index e9151664..289b2010 100644 --- a/moo/mooedit/mooedithistoryitem.c +++ b/moo/mooedit/mooedithistoryitem.c @@ -5,16 +5,16 @@ #define KEY_LINE "line" void -_moo_edit_history_item_set_encoding (MdHistoryItem *item, - const char *encoding) +_moo_edit_history_item_set_encoding (MooHistoryItem *item, + const char *encoding) { g_return_if_fail (item != NULL); - md_history_item_set (item, KEY_ENCODING, encoding); + moo_history_item_set (item, KEY_ENCODING, encoding); } void -_moo_edit_history_item_set_line (MdHistoryItem *item, - int line) +_moo_edit_history_item_set_line (MooHistoryItem *item, + int line) { char *value = NULL; @@ -23,25 +23,25 @@ _moo_edit_history_item_set_line (MdHistoryItem *item, if (line >= 0) value = g_strdup_printf ("%d", line + 1); - md_history_item_set (item, KEY_LINE, value); + moo_history_item_set (item, KEY_LINE, value); g_free (value); } const char * -_moo_edit_history_item_get_encoding (MdHistoryItem *item) +_moo_edit_history_item_get_encoding (MooHistoryItem *item) { g_return_val_if_fail (item != NULL, NULL); - return md_history_item_get (item, KEY_ENCODING); + return moo_history_item_get (item, KEY_ENCODING); } int -_moo_edit_history_item_get_line (MdHistoryItem *item) +_moo_edit_history_item_get_line (MooHistoryItem *item) { const char *strval; g_return_val_if_fail (item != NULL, -1); - strval = md_history_item_get (item, KEY_LINE); + strval = moo_history_item_get (item, KEY_LINE); if (strval && strval[0]) return strtol (strval, NULL, 10) - 1; diff --git a/moo/mooedit/mooedithistoryitem.h b/moo/mooedit/mooedithistoryitem.h index 1ccba570..9aa2159a 100644 --- a/moo/mooedit/mooedithistoryitem.h +++ b/moo/mooedit/mooedithistoryitem.h @@ -1,16 +1,16 @@ #ifndef MOO_EDIT_HISTORY_ITEM_H #define MOO_EDIT_HISTORY_ITEM_H -#include +#include G_BEGIN_DECLS -void _moo_edit_history_item_set_encoding (MdHistoryItem *item, +void _moo_edit_history_item_set_encoding (MooHistoryItem *item, const char *encoding); -void _moo_edit_history_item_set_line (MdHistoryItem *item, +void _moo_edit_history_item_set_line (MooHistoryItem *item, int line); -const char *_moo_edit_history_item_get_encoding (MdHistoryItem *item); -int _moo_edit_history_item_get_line (MdHistoryItem *item); +const char *_moo_edit_history_item_get_encoding (MooHistoryItem *item); +int _moo_edit_history_item_get_line (MooHistoryItem *item); G_END_DECLS diff --git a/moo/mooedit/mooeditor-impl.h b/moo/mooedit/mooeditor-impl.h index cd3f371a..1f09309b 100644 --- a/moo/mooedit/mooeditor-impl.h +++ b/moo/mooedit/mooeditor-impl.h @@ -6,12 +6,12 @@ #endif #include "mooedit/mooeditor.h" -#include "mooutils/mdhistorymgr.h" +#include "mooutils/moohistorymgr.h" #include "mooutils/moofilewatch.h" G_BEGIN_DECLS -MdHistoryMgr *_moo_editor_get_history_mgr (MooEditor *editor); +MooHistoryMgr *_moo_editor_get_history_mgr (MooEditor *editor); void _moo_editor_set_focused_doc (MooEditor *editor, MooEdit *doc); diff --git a/moo/mooedit/mooeditor-private.h b/moo/mooedit/mooeditor-private.h index 6e98690a..e104bde5 100644 --- a/moo/mooedit/mooeditor-private.h +++ b/moo/mooedit/mooeditor-private.h @@ -35,7 +35,7 @@ struct MooEditorPrivate { MooEditWindowArray *windows; MooUiXml *doc_ui_xml; MooUiXml *ui_xml; - MdHistoryMgr *history; + MooHistoryMgr *history; MooFileWatch *file_watch; MooEditorOptions opts; diff --git a/moo/mooedit/mooeditor-tests.c b/moo/mooedit/mooeditor-tests.c index 7a9907e3..f00d3ffe 100644 --- a/moo/mooedit/mooeditor-tests.c +++ b/moo/mooedit/mooeditor-tests.c @@ -2,7 +2,7 @@ #include "mooedit/mooeditor-tests.h" #include "mooedit/mooeditor-impl.h" #include "mooutils/mooutils-fs.h" -#include "mooutils/mdhistorymgr.h" +#include "mooutils/moohistorymgr.h" static struct { char *working_dir; @@ -235,7 +235,7 @@ test_suite_cleanup (G_GNUC_UNUSED gpointer data) editor = moo_editor_instance (); // moo_editor_close_all (editor, FALSE, FALSE); - recent_file = _md_history_mgr_get_filename (_moo_editor_get_history_mgr (editor)); + recent_file = _moo_history_mgr_get_filename (_moo_editor_get_history_mgr (editor)); if (!g_file_test (recent_file, G_FILE_TEST_EXISTS)) g_critical ("recent file %s does not exist", recent_file); diff --git a/moo/mooedit/mooeditor.c b/moo/mooedit/mooeditor.c index d655aa32..acd80472 100644 --- a/moo/mooedit/mooeditor.c +++ b/moo/mooedit/mooeditor.c @@ -24,6 +24,7 @@ #include "mooedit/mooedit-accels.h" #include "mooedit/mooeditfiltersettings.h" #include "mooedit/moofileenc.h" +#include "mooedit/mooedithistoryitem.h" #include "mooedit-ui.h" #include "medit-ui.h" #include "mooutils/moomenuaction.h" @@ -234,9 +235,10 @@ moo_editor_constructor (GType type, editor->priv->history = NULL; if (!is_embedded (editor)) - editor->priv->history = MD_HISTORY_MGR (g_object_new (MD_TYPE_HISTORY_MGR, - "name", "Editor", - (const char*) NULL)); + editor->priv->history = MOO_HISTORY_MGR ( + g_object_new (MOO_TYPE_HISTORY_MGR, + "name", "Editor", + (const char*) NULL)); moo_prefs_new_key_string (moo_edit_setting (MOO_EDIT_PREFS_DEFAULT_LANG), MOO_LANG_NONE); @@ -585,7 +587,7 @@ moo_editor_set_ui_xml (MooEditor *editor, } -MdHistoryMgr * +MooHistoryMgr * _moo_editor_get_history_mgr (MooEditor *editor) { g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL); @@ -597,7 +599,7 @@ add_recent_uri (MooEditor *editor, const char *uri) { if (!is_embedded (editor)) - md_history_mgr_add_uri (editor->priv->history, uri); + moo_history_mgr_add_uri (editor->priv->history, uri); } static void @@ -615,15 +617,15 @@ recent_item_activated (GSList *items, const char *encoding; const char *uri; char *filename; - MdHistoryItem *item = items->data; + MooHistoryItem *item = items->data; - uri = md_history_item_get_uri (item); + uri = moo_history_item_get_uri (item); filename = g_filename_from_uri (uri, NULL, NULL); g_return_if_fail (filename != NULL); encoding = _moo_edit_history_item_get_encoding (item); if (!moo_editor_open_uri (editor, window, GTK_WIDGET (window), uri, encoding)) - md_history_mgr_remove_uri (editor->priv->history, uri); + moo_history_mgr_remove_uri (editor->priv->history, uri); g_free (filename); @@ -643,7 +645,7 @@ create_recent_menu (GtkAction *action) g_return_val_if_fail (MOO_IS_EDIT_WINDOW (window), NULL); editor = moo_editor_instance (); - menu = md_history_mgr_create_menu (editor->priv->history, + menu = moo_history_mgr_create_menu (editor->priv->history, recent_item_activated, window, NULL); moo_bind_bool_property (action, @@ -685,7 +687,7 @@ action_recent_dialog (MooEditWindow *window) editor = moo_editor_instance (); g_return_if_fail (MOO_IS_EDITOR (editor)); - dialog = md_history_mgr_create_dialog (editor->priv->history, + dialog = moo_history_mgr_create_dialog (editor->priv->history, recent_item_activated, window, NULL); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); @@ -869,7 +871,7 @@ update_history_item_for_doc (MooEditor *editor, gboolean add) { char *uri; - MdHistoryItem *item; + MooHistoryItem *item; int line; const char *enc; @@ -879,7 +881,7 @@ update_history_item_for_doc (MooEditor *editor, if (!(uri = moo_edit_get_uri (doc))) return; - item = md_history_item_new (uri, NULL); + item = moo_history_item_new (uri, NULL); line = moo_text_view_get_cursor_line (MOO_TEXT_VIEW (doc)); if (line != 0) @@ -890,11 +892,11 @@ update_history_item_for_doc (MooEditor *editor, _moo_edit_history_item_set_encoding (item, enc); if (add) - md_history_mgr_add_file (editor->priv->history, item); + moo_history_mgr_add_file (editor->priv->history, item); else - md_history_mgr_update_file (editor->priv->history, item); + moo_history_mgr_update_file (editor->priv->history, item); - md_history_item_free (item); + moo_history_item_free (item); g_free (uri); } @@ -948,7 +950,7 @@ moo_editor_load_file (MooEditor *editor, if (!fenc->encoding) { - MdHistoryItem *hist_item = md_history_mgr_find_uri (editor->priv->history, uri); + MooHistoryItem *hist_item = moo_history_mgr_find_uri (editor->priv->history, uri); if (hist_item) recent_encoding = _moo_edit_history_item_get_encoding (hist_item); } @@ -969,11 +971,11 @@ moo_editor_load_file (MooEditor *editor, } else { - MdHistoryItem *hist_item; + MooHistoryItem *hist_item; if (line < 0) { - hist_item = md_history_mgr_find_uri (editor->priv->history, uri); + hist_item = moo_history_mgr_find_uri (editor->priv->history, uri); if (hist_item) line = _moo_edit_history_item_get_line (hist_item); } diff --git a/moo/mooutils/Makefile.incl b/moo/mooutils/Makefile.incl index a797ac62..776a6edb 100644 --- a/moo/mooutils/Makefile.incl +++ b/moo/mooutils/Makefile.incl @@ -2,8 +2,8 @@ moo_sources += \ mooutils/mooarray.h \ mooutils/mooutils-thread.c \ mooutils/mooutils-thread.h \ - mooutils/mdhistorymgr.c \ - mooutils/mdhistorymgr.h \ + mooutils/moohistorymgr.c \ + mooutils/moohistorymgr.h \ mooutils/moo-environ.h \ mooutils/mooaccel.c \ mooutils/mooaccel.h \ diff --git a/moo/mooutils/mdhistorymgr.h b/moo/mooutils/mdhistorymgr.h deleted file mode 100644 index ff3a0257..00000000 --- a/moo/mooutils/mdhistorymgr.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * mdhistorymgr.h - * - * Copyright (C) 2004-2010 by Yevgen Muntyan - * - * This file is part of medit. medit is free software; you can - * redistribute it and/or modify it under the terms of the - * GNU Lesser General Public License as published by the - * Free Software Foundation; either version 2.1 of the License, - * or (at your option) any later version. - * - * You should have received a copy of the GNU Lesser General Public - * License along with medit. If not, see . - */ - -#ifndef MD_HISTORY_MGR_H -#define MD_HISTORY_MGR_H - -#include - -G_BEGIN_DECLS - -#define MD_HISTORY_MGR_PARSE_ERROR (md_history_mgr_parse_error_quark ()) - -enum { - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT -}; - -#define MD_TYPE_HISTORY_MGR (md_history_mgr_get_type ()) -#define MD_HISTORY_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MD_TYPE_HISTORY_MGR, MdHistoryMgr)) -#define MD_HISTORY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MD_TYPE_HISTORY_MGR, MdHistoryMgrClass)) -#define MD_IS_HISTORY_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MD_TYPE_HISTORY_MGR)) -#define MD_IS_HISTORY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MD_TYPE_HISTORY_MGR)) -#define MD_HISTORY_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MD_TYPE_HISTORY_MGR, MdHistoryMgrClass)) - -typedef struct MdHistoryItem MdHistoryItem; -typedef struct MdHistoryMgr MdHistoryMgr; -typedef struct MdHistoryMgrClass MdHistoryMgrClass; -typedef struct MdHistoryMgrPrivate MdHistoryMgrPrivate; - -struct MdHistoryMgr { - GObject base; - MdHistoryMgrPrivate *priv; -}; - -struct MdHistoryMgrClass { - GObjectClass base_class; -}; - -typedef void (*MdHistoryCallback) (GSList *items, - gpointer data); - -GQuark md_history_mgr_parse_error_quark (void) G_GNUC_CONST; -GType md_history_mgr_get_type (void) G_GNUC_CONST; - -void md_history_mgr_add_file (MdHistoryMgr *mgr, - MdHistoryItem *item); -void md_history_mgr_update_file (MdHistoryMgr *mgr, - MdHistoryItem *item); -void md_history_mgr_add_uri (MdHistoryMgr *mgr, - const char *uri); -void md_history_mgr_remove_uri (MdHistoryMgr *mgr, - const char *uri); -MdHistoryItem *md_history_mgr_find_uri (MdHistoryMgr *mgr, - const char *uri); - -void md_history_mgr_shutdown (MdHistoryMgr *mgr); - -guint md_history_mgr_get_n_items (MdHistoryMgr *mgr); - -GtkWidget *md_history_mgr_create_menu (MdHistoryMgr *mgr, - MdHistoryCallback callback, - gpointer data, - GDestroyNotify notify); -GtkWidget *md_history_mgr_create_dialog (MdHistoryMgr *mgr, - MdHistoryCallback callback, - gpointer data, - GDestroyNotify notify); - -MdHistoryItem *md_history_item_new (const char *uri, - const char *first_key, - ...); -MdHistoryItem *md_history_item_copy (MdHistoryItem *item); -void md_history_item_free (MdHistoryItem *item); -void md_history_item_set (MdHistoryItem *item, - const char *key, - const char *value); -const char *md_history_item_get (MdHistoryItem *item, - const char *key); -const char *md_history_item_get_uri (MdHistoryItem *item); -void md_history_item_foreach (MdHistoryItem *item, - GDataForeachFunc func, - gpointer user_data); - -char *_md_history_mgr_get_filename (MdHistoryMgr *mgr); - -G_END_DECLS - -#endif /* MD_HISTORY_MGR_H */ diff --git a/moo/mooutils/moohistorycombo.c b/moo/mooutils/moohistorycombo.c index 3c3e2cfd..5e161600 100644 --- a/moo/mooutils/moohistorycombo.c +++ b/moo/mooutils/moohistorycombo.c @@ -346,7 +346,7 @@ default_sort_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b) { - MooHistoryItem *e1 = NULL, *e2 = NULL; + MooHistoryListItem *e1 = NULL, *e2 = NULL; int result; /* XXX 0 is not good */ @@ -364,8 +364,8 @@ default_sort_func (GtkTreeModel *model, else result = strcmp (e1->data, e2->data); - moo_history_item_free (e1); - moo_history_item_free (e2); + moo_history_list_item_free (e1); + moo_history_list_item_free (e2); return result; } @@ -454,7 +454,7 @@ default_filter_func (const char *entry_text, G_GNUC_UNUSED gpointer data) { gboolean visible; - MooHistoryItem *e = NULL; + MooHistoryListItem *e = NULL; gtk_tree_model_get (model, iter, 0, &e, -1); @@ -470,7 +470,7 @@ default_filter_func (const char *entry_text, visible = TRUE; } - moo_history_item_free (e); + moo_history_list_item_free (e); return visible ? TRUE : FALSE; } @@ -507,7 +507,7 @@ moo_history_combo_commit (MooHistoryCombo *combo) { GtkTreeIter iter; const char *text; - MooHistoryItem *freeme = NULL; + MooHistoryListItem *freeme = NULL; g_return_if_fail (MOO_IS_HISTORY_COMBO (combo)); @@ -525,7 +525,7 @@ moo_history_combo_commit (MooHistoryCombo *combo) moo_history_combo_add_text (combo, text); if (freeme) - moo_history_item_free (freeme); + moo_history_list_item_free (freeme); } @@ -580,14 +580,14 @@ cell_data_func (G_GNUC_UNUSED GtkCellLayout *cell_layout, GtkTreeModel *model, GtkTreeIter *iter) { - MooHistoryItem *e = NULL; + MooHistoryListItem *e = NULL; gtk_tree_model_get (model, iter, 0, &e, -1); if (e) { g_object_set (cell, "text", e->display, NULL); - moo_history_item_free (e); + moo_history_list_item_free (e); } } @@ -598,10 +598,10 @@ row_separator_func (GtkTreeModel *model, G_GNUC_UNUSED gpointer data) { gboolean separator; - MooHistoryItem *item = NULL; + MooHistoryListItem *item = NULL; gtk_tree_model_get (model, iter, 0, &item, -1); separator = item == NULL; - moo_history_item_free (item); + moo_history_list_item_free (item); return separator; } @@ -611,7 +611,7 @@ get_text_func (GtkTreeModel *model, GtkTreeIter *iter, G_GNUC_UNUSED gpointer data) { - MooHistoryItem *e = NULL; + MooHistoryListItem *e = NULL; char *text; gtk_tree_model_get (model, iter, 0, &e, -1); @@ -620,6 +620,6 @@ get_text_func (GtkTreeModel *model, g_return_val_if_fail (g_utf8_validate (e->data, -1, NULL), NULL); text = g_strdup (e->data); - moo_history_item_free (e); + moo_history_list_item_free (e); return text; } diff --git a/moo/mooutils/moohistorylist.c b/moo/mooutils/moohistorylist.c index 4c496a83..bb9f94fc 100644 --- a/moo/mooutils/moohistorylist.c +++ b/moo/mooutils/moohistorylist.c @@ -22,7 +22,7 @@ #define MAX_NUM_HISTORY_ITEMS 10 -typedef MooHistoryItem Item; +typedef MooHistoryListItem Item; struct _MooHistoryListPrivate { GtkTreeModel *model; @@ -47,7 +47,7 @@ struct _MooHistoryListPrivate { gboolean allow_empty; }; -MOO_DEFINE_BOXED_TYPE_C (MooHistoryItem, moo_history_item) +MOO_DEFINE_BOXED_TYPE_C (MooHistoryListItem, moo_history_list_item) static GHashTable *named_lists; @@ -81,7 +81,7 @@ static void _list_delete_last (MooHistoryList *list); static void list_save_recent (MooHistoryList *list); static void menu_item_activated (MooHistoryList *list, - MooHistoryItem *entry, + MooHistoryListItem *entry, gpointer menu_data); @@ -239,11 +239,11 @@ moo_history_list_finalize (GObject *object) } -MooHistoryItem * +MooHistoryListItem * moo_history_list_get_item (MooHistoryList *list, GtkTreeIter *iter) { - MooHistoryItem *item = NULL; + MooHistoryListItem *item = NULL; gtk_tree_model_get (list->priv->model, iter, 0, &item, -1); return item; } @@ -266,11 +266,11 @@ moo_history_list_find (MooHistoryList *list, if (entry && list->priv->compare_func (text, entry, list->priv->compare_data)) { - moo_history_item_free (entry); + moo_history_list_item_free (entry); return TRUE; } - moo_history_item_free (entry); + moo_history_list_item_free (entry); } while (gtk_tree_model_iter_next (list->priv->model, iter)); } @@ -291,9 +291,9 @@ default_compare_func (const char *text, Item* -moo_history_item_new (const char *data, - const char *display, - gboolean builtin) +moo_history_list_item_new (const char *data, + const char *display, + gboolean builtin) { Item *item; @@ -311,17 +311,17 @@ moo_history_item_new (const char *data, Item* -moo_history_item_copy (const Item *item) +moo_history_list_item_copy (const Item *item) { g_return_val_if_fail (item != NULL, NULL); - return moo_history_item_new (item->data, - item->display, - item->builtin); + return moo_history_list_item_new (item->data, + item->display, + item->builtin); } void -moo_history_item_free (Item *item) +moo_history_list_item_free (Item *item) { if (item) { @@ -373,7 +373,7 @@ moo_history_list_add_builtin (MooHistoryList *list, g_return_if_fail (MOO_IS_HISTORY_LIST (list)); - new_item = moo_history_item_new (item, display_item, TRUE); + new_item = moo_history_list_item_new (item, display_item, TRUE); g_return_if_fail (new_item != NULL); if (moo_history_list_find (list, item, &iter)) @@ -381,7 +381,7 @@ moo_history_list_add_builtin (MooHistoryList *list, Item *old = moo_history_list_get_item (list, &iter); if (!old->builtin) _list_remove (list, &iter); - moo_history_item_free (old); + moo_history_list_item_free (old); } _list_insert (list, list->priv->num_builtin++, new_item); @@ -471,11 +471,11 @@ moo_history_list_add_full (MooHistoryList *list, g_signal_emit (list, signals[CHANGED], 0); } - moo_history_item_free (old); + moo_history_list_item_free (old); return; } - new_entry = moo_history_item_new (entry, display_entry, FALSE); + new_entry = moo_history_list_item_new (entry, display_entry, FALSE); g_return_if_fail (new_entry != NULL); if (list->priv->num_builtin && @@ -503,7 +503,7 @@ moo_history_list_add_full (MooHistoryList *list, if (was_empty) g_object_notify (G_OBJECT (list), "empty"); - moo_history_item_free (new_entry); + moo_history_list_item_free (new_entry); } @@ -528,7 +528,7 @@ moo_history_list_get_last_item (MooHistoryList *list) data = item->data; item->data = NULL; - moo_history_item_free (item); + moo_history_list_item_free (item); return data; } @@ -570,7 +570,7 @@ moo_history_list_remove (MooHistoryList *list, if (moo_history_list_is_empty (list)) g_object_notify (G_OBJECT (list), "empty"); - moo_history_item_free (item); + moo_history_list_item_free (item); return; } @@ -744,9 +744,9 @@ moo_history_list_get_model (MooHistoryList *list) */ static void -menu_item_activated (MooHistoryList *list, - MooHistoryItem *entry, - gpointer menu_data) +menu_item_activated (MooHistoryList *list, + MooHistoryListItem *entry, + gpointer menu_data) { g_signal_emit (list, signals[ACTIVATE_ITEM], 0, entry, menu_data); } @@ -794,8 +794,8 @@ _list_insert (MooHistoryList *list, moo_menu_mgr_insert (list->priv->mgr, NULL, index, NULL, entry->display, tip, MOO_MENU_ITEM_ACTIVATABLE, - moo_history_item_copy (entry), - (GDestroyNotify) moo_history_item_free); + moo_history_list_item_copy (entry), + (GDestroyNotify) moo_history_list_item_free); } else { @@ -833,15 +833,15 @@ _list_move_on_top (MooHistoryList *list, moo_menu_mgr_insert (list->priv->mgr, NULL, new_index, NULL, entry->display, tip, MOO_MENU_ITEM_ACTIVATABLE, - moo_history_item_copy (entry), - (GDestroyNotify) moo_history_item_free); + moo_history_list_item_copy (entry), + (GDestroyNotify) moo_history_list_item_free); else moo_menu_mgr_insert_separator (list->priv->mgr, NULL, new_index); gtk_list_store_remove (list->priv->store, iter); gtk_list_store_insert (list->priv->store, iter, new_index); gtk_list_store_set (list->priv->store, iter, 0, entry, -1); - moo_history_item_free (entry); + moo_history_list_item_free (entry); g_free (tip); } @@ -939,7 +939,7 @@ save_one (GtkTreeModel *model, if (!item->builtin) moo_markup_create_text_element (root, ELEMENT_ITEM, item->data); - moo_history_item_free (item); + moo_history_list_item_free (item); return FALSE; } diff --git a/moo/mooutils/moohistorylist.h b/moo/mooutils/moohistorylist.h index 69fc88b6..bb5b148e 100644 --- a/moo/mooutils/moohistorylist.h +++ b/moo/mooutils/moohistorylist.h @@ -22,7 +22,7 @@ G_BEGIN_DECLS -#define MOO_TYPE_HISTORY_ITEM (moo_history_item_get_type ()) +#define MOO_TYPE_HISTORY_ITEM (moo_history_list_item_get_type ()) #define MOO_TYPE_HISTORY_LIST (moo_history_list_get_type ()) #define MOO_HISTORY_LIST(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_HISTORY_LIST, MooHistoryList)) #define MOO_HISTORY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_HISTORY_LIST, MooHistoryListClass)) @@ -30,18 +30,18 @@ G_BEGIN_DECLS #define MOO_IS_HISTORY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_HISTORY_LIST)) #define MOO_HISTORY_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_HISTORY_LIST, MooHistoryListClass)) -typedef struct _MooHistoryItem MooHistoryItem; +typedef struct _MooHistoryListItem MooHistoryListItem; typedef struct _MooHistoryList MooHistoryList; typedef struct _MooHistoryListPrivate MooHistoryListPrivate; typedef struct _MooHistoryListClass MooHistoryListClass; -typedef char *(*MooHistoryDisplayFunc) (const char *item, - gpointer data); -typedef gboolean (*MooHistoryCompareFunc) (const char *text, - MooHistoryItem *item, - gpointer data); +typedef char *(*MooHistoryDisplayFunc) (const char *item, + gpointer data); +typedef gboolean (*MooHistoryCompareFunc) (const char *text, + MooHistoryListItem *item, + gpointer data); -struct _MooHistoryItem +struct _MooHistoryListItem { char *data; char *display; @@ -59,16 +59,16 @@ struct _MooHistoryListClass { GObjectClass parent_class; - void (*activate_item) (MooHistoryList *list, - MooHistoryItem *item, - gpointer menu_data); + void (*activate_item) (MooHistoryList *list, + MooHistoryListItem *item, + gpointer menu_data); void (*changed) (MooHistoryList *list); }; GType moo_history_list_get_type (void) G_GNUC_CONST; -GType moo_history_item_get_type (void) G_GNUC_CONST; +GType moo_history_list_item_get_type (void) G_GNUC_CONST; MooHistoryList *moo_history_list_new (const char *user_id); MooHistoryList *moo_history_list_get (const char *user_id); @@ -103,7 +103,7 @@ char *moo_history_list_display_filename (const char *entry, gpointer data); /* must free the result */ -MooHistoryItem *moo_history_list_get_item (MooHistoryList *list, +MooHistoryListItem *moo_history_list_get_item (MooHistoryList *list, GtkTreeIter *iter); gboolean moo_history_list_find (MooHistoryList *list, const char *text, @@ -123,11 +123,11 @@ void moo_history_list_add_builtin (MooHistoryList *list, MooMenuMgr *moo_history_list_get_menu_mgr (MooHistoryList *list); -MooHistoryItem *moo_history_item_new (const char *data, +MooHistoryListItem *moo_history_list_item_new (const char *data, const char *display, gboolean builtin); -MooHistoryItem *moo_history_item_copy (const MooHistoryItem *item); -void moo_history_item_free (MooHistoryItem *item); +MooHistoryListItem *moo_history_list_item_copy (const MooHistoryListItem *item); +void moo_history_list_item_free (MooHistoryListItem *item); G_END_DECLS diff --git a/moo/mooutils/mdhistorymgr.c b/moo/mooutils/moohistorymgr.c similarity index 71% rename from moo/mooutils/mdhistorymgr.c rename to moo/mooutils/moohistorymgr.c index da38eac1..b116507c 100644 --- a/moo/mooutils/mdhistorymgr.c +++ b/moo/mooutils/moohistorymgr.c @@ -1,5 +1,5 @@ /* - * mdhistorymgr.h + * moohistorymgr.h * * Copyright (C) 2004-2010 by Yevgen Muntyan * @@ -13,7 +13,7 @@ * License along with medit. If not, see . */ -#include "mooutils/mdhistorymgr.h" +#include "mooutils/moohistorymgr.h" #include "mooutils/moofileicon.h" #include "mooutils/mooapp-ipc.h" #include "mooutils/moofilewatch.h" @@ -33,13 +33,13 @@ #define N_MENU_ITEMS 10 #define MAX_ITEM_NUMBER 5000 -#define IPC_ID "MdHistoryMgr" +#define IPC_ID "MooHistoryMgr" -MOO_DEFINE_DLIST(WidgetList, widget_list, GtkWidget) -MOO_DEFINE_QUEUE(MdHistoryItem, md_history_item) -MOO_DEFINE_QUARK(md-history-mgr-parse-error, md_history_mgr_parse_error_quark) +MOO_DEFINE_DLIST (WidgetList, widget_list, GtkWidget) +MOO_DEFINE_QUEUE (MooHistoryItem, moo_history_item) +MOO_DEFINE_QUARK (moo-history-mgr-parse-error, moo_history_mgr_parse_error_quark) -struct MdHistoryMgrPrivate { +struct _MooHistoryMgrPrivate { char *filename; char *basename; char *name; @@ -50,18 +50,18 @@ struct MdHistoryMgrPrivate { guint update_widgets_idle; WidgetList *widgets; - MdHistoryItemQueue *files; + MooHistoryItemQueue *files; GHashTable *hash; guint loaded : 1; }; typedef struct { - MdHistoryCallback callback; + MooHistoryCallback callback; gpointer data; GDestroyNotify notify; } CallbackData; -struct MdHistoryItem { +struct _MooHistoryItem { char *uri; GData *data; MooFileIcon *icon; @@ -73,49 +73,49 @@ typedef enum { UPDATE_ITEM_ADD } UpdateType; -static GObject *md_history_mgr_constructor (GType type, +static GObject *moo_history_mgr_constructor (GType type, guint n_props, GObjectConstructParam *props); -static void md_history_mgr_dispose (GObject *object); -static void md_history_mgr_set_property (GObject *object, +static void moo_history_mgr_dispose (GObject *object); +static void moo_history_mgr_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); -static void md_history_mgr_get_property (GObject *object, +static void moo_history_mgr_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static const char *get_filename (MdHistoryMgr *mgr); -static const char *get_basename (MdHistoryMgr *mgr); +static const char *get_filename (MooHistoryMgr *mgr); +static const char *get_basename (MooHistoryMgr *mgr); -static void ensure_files (MdHistoryMgr *mgr); -static void schedule_save (MdHistoryMgr *mgr); -static void md_history_mgr_save (MdHistoryMgr *mgr); +static void ensure_files (MooHistoryMgr *mgr); +static void schedule_save (MooHistoryMgr *mgr); +static void moo_history_mgr_save (MooHistoryMgr *mgr); -static void populate_menu (MdHistoryMgr *mgr, +static void populate_menu (MooHistoryMgr *mgr, GtkWidget *menu); -static void schedule_update_widgets (MdHistoryMgr *mgr); +static void schedule_update_widgets (MooHistoryMgr *mgr); -static void md_history_item_format (MdHistoryItem *item, +static void moo_history_item_format (MooHistoryItem *item, GString *buffer); -static gboolean md_history_item_equal (MdHistoryItem *item1, - MdHistoryItem *item2); -static MooFileIcon *md_history_item_get_icon (MdHistoryItem *item); +static gboolean moo_history_item_equal (MooHistoryItem *item1, + MooHistoryItem *item2); +static MooFileIcon *moo_history_item_get_icon (MooHistoryItem *item); static char *uri_get_basename (const char *uri); static char *uri_get_display_name (const char *uri); static void ipc_callback (GObject *obj, const char *data, gsize len); -static void ipc_notify_add_file (MdHistoryMgr *mgr, - MdHistoryItem *item); -static void ipc_notify_update_file (MdHistoryMgr *mgr, - MdHistoryItem *item); -static void ipc_notify_remove_file (MdHistoryMgr *mgr, - MdHistoryItem *item); +static void ipc_notify_add_file (MooHistoryMgr *mgr, + MooHistoryItem *item); +static void ipc_notify_update_file (MooHistoryMgr *mgr, + MooHistoryItem *item); +static void ipc_notify_remove_file (MooHistoryMgr *mgr, + MooHistoryItem *item); -G_DEFINE_TYPE (MdHistoryMgr, md_history_mgr, G_TYPE_OBJECT) +G_DEFINE_TYPE (MooHistoryMgr, moo_history_mgr, G_TYPE_OBJECT) enum { PROP_0, @@ -131,16 +131,16 @@ enum { static guint signals[N_SIGNALS]; static void -md_history_mgr_class_init (MdHistoryMgrClass *klass) +moo_history_mgr_class_init (MooHistoryMgrClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (MdHistoryMgrPrivate)); + g_type_class_add_private (klass, sizeof (MooHistoryMgrPrivate)); - object_class->constructor = md_history_mgr_constructor; - object_class->set_property = md_history_mgr_set_property; - object_class->get_property = md_history_mgr_get_property; - object_class->dispose = md_history_mgr_dispose; + object_class->constructor = moo_history_mgr_constructor; + object_class->set_property = moo_history_mgr_set_property; + object_class->get_property = moo_history_mgr_get_property; + object_class->dispose = moo_history_mgr_dispose; g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string ("name", "name", "name", @@ -152,7 +152,7 @@ md_history_mgr_class_init (MdHistoryMgrClass *klass) signals[CHANGED] = _moo_signal_new_cb ("changed", - MD_TYPE_HISTORY_MGR, + MOO_TYPE_HISTORY_MGR, G_SIGNAL_RUN_LAST, G_CALLBACK (schedule_update_widgets), NULL, NULL, @@ -161,28 +161,28 @@ md_history_mgr_class_init (MdHistoryMgrClass *klass) } static void -md_history_mgr_init (MdHistoryMgr *mgr) +moo_history_mgr_init (MooHistoryMgr *mgr) { - mgr->priv = G_TYPE_INSTANCE_GET_PRIVATE (mgr, MD_TYPE_HISTORY_MGR, MdHistoryMgrPrivate); + mgr->priv = G_TYPE_INSTANCE_GET_PRIVATE (mgr, MOO_TYPE_HISTORY_MGR, MooHistoryMgrPrivate); mgr->priv->filename = NULL; mgr->priv->basename = NULL; - mgr->priv->files = md_history_item_queue_new (); + mgr->priv->files = moo_history_item_queue_new (); mgr->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); mgr->priv->loaded = FALSE; } static GObject * -md_history_mgr_constructor (GType type, - guint n_props, - GObjectConstructParam *props) +moo_history_mgr_constructor (GType type, + guint n_props, + GObjectConstructParam *props) { GObject *object; - MdHistoryMgr *mgr; + MooHistoryMgr *mgr; - object = G_OBJECT_CLASS (md_history_mgr_parent_class)-> + object = G_OBJECT_CLASS (moo_history_mgr_parent_class)-> constructor (type, n_props, props); - mgr = MD_HISTORY_MGR (object); + mgr = MOO_HISTORY_MGR (object); if (mgr->priv->name) { @@ -194,18 +194,18 @@ md_history_mgr_constructor (GType type, } static void -md_history_mgr_dispose (GObject *object) +moo_history_mgr_dispose (GObject *object) { - MdHistoryMgr *mgr = MD_HISTORY_MGR (object); + MooHistoryMgr *mgr = MOO_HISTORY_MGR (object); if (mgr->priv) { - md_history_mgr_shutdown (mgr); + moo_history_mgr_shutdown (mgr); if (mgr->priv->files) { - md_history_item_queue_foreach (mgr->priv->files, (MdHistoryItemListFunc) md_history_item_free, NULL); - md_history_item_queue_free_links (mgr->priv->files); + moo_history_item_queue_foreach (mgr->priv->files, (MooHistoryItemListFunc) moo_history_item_free, NULL); + moo_history_item_queue_free_links (mgr->priv->files); g_hash_table_destroy (mgr->priv->hash); } @@ -216,13 +216,13 @@ md_history_mgr_dispose (GObject *object) mgr->priv = NULL; } - G_OBJECT_CLASS (md_history_mgr_parent_class)->dispose (object); + G_OBJECT_CLASS (moo_history_mgr_parent_class)->dispose (object); } void -md_history_mgr_shutdown (MdHistoryMgr *mgr) +moo_history_mgr_shutdown (MooHistoryMgr *mgr) { - g_return_if_fail (MD_IS_HISTORY_MGR (mgr)); + g_return_if_fail (MOO_IS_HISTORY_MGR (mgr)); if (!mgr->priv) return; @@ -238,7 +238,7 @@ md_history_mgr_shutdown (MdHistoryMgr *mgr) { g_source_remove (mgr->priv->save_idle); mgr->priv->save_idle = 0; - md_history_mgr_save (mgr); + moo_history_mgr_save (mgr); } if (mgr->priv->update_widgets_idle) @@ -252,12 +252,12 @@ md_history_mgr_shutdown (MdHistoryMgr *mgr) } static void -md_history_mgr_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +moo_history_mgr_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - MdHistoryMgr *mgr = MD_HISTORY_MGR (object); + MooHistoryMgr *mgr = MOO_HISTORY_MGR (object); switch (prop_id) { @@ -272,12 +272,12 @@ md_history_mgr_set_property (GObject *object, } static void -md_history_mgr_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +moo_history_mgr_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - MdHistoryMgr *mgr = MD_HISTORY_MGR (object); + MooHistoryMgr *mgr = MOO_HISTORY_MGR (object); switch (prop_id) { @@ -286,7 +286,7 @@ md_history_mgr_get_property (GObject *object, break; case PROP_EMPTY: - g_value_set_boolean (value, md_history_mgr_get_n_items (mgr) == 0); + g_value_set_boolean (value, moo_history_mgr_get_n_items (mgr) == 0); break; default: @@ -297,7 +297,7 @@ md_history_mgr_get_property (GObject *object, static const char * -get_basename (MdHistoryMgr *mgr) +get_basename (MooHistoryMgr *mgr) { if (!mgr->priv->basename) { @@ -317,7 +317,7 @@ get_basename (MdHistoryMgr *mgr) } static const char * -get_filename (MdHistoryMgr *mgr) +get_filename (MooHistoryMgr *mgr) { if (!mgr->priv->filename) mgr->priv->filename = moo_get_user_cache_file (get_basename (mgr)); @@ -325,9 +325,9 @@ get_filename (MdHistoryMgr *mgr) } char * -_md_history_mgr_get_filename (MdHistoryMgr *mgr) +_moo_history_mgr_get_filename (MooHistoryMgr *mgr) { - g_return_val_if_fail (MD_IS_HISTORY_MGR (mgr), NULL); + g_return_val_if_fail (MOO_IS_HISTORY_MGR (mgr), NULL); return g_strdup (get_filename (mgr)); } @@ -350,21 +350,21 @@ _md_history_mgr_get_filename (MdHistoryMgr *mgr) #define ELM_RECENT_ITEMS "recent-items" static void -add_file (MdHistoryMgr *mgr, - MdHistoryItem *item) +add_file (MooHistoryMgr *mgr, + MooHistoryItem *item) { const char *uri; - uri = md_history_item_get_uri (item); + uri = moo_history_item_get_uri (item); if (g_hash_table_lookup (mgr->priv->hash, uri) != NULL) { g_critical ("%s: duplicated uri '%s'", G_STRLOC, uri); - md_history_item_free (item); + moo_history_item_free (item); return; } - md_history_item_queue_push_tail (mgr->priv->files, item); + moo_history_item_queue_push_tail (mgr->priv->files, item); g_hash_table_insert (mgr->priv->hash, g_strdup (uri), mgr->priv->files->tail); } @@ -372,10 +372,10 @@ add_file (MdHistoryMgr *mgr, static gboolean parse_element (const char *filename, MooMarkupNode *elm, - MdHistoryItem **item_p) + MooHistoryItem **item_p) { const char *uri; - MdHistoryItem *item; + MooHistoryItem *item; MooMarkupNode *child; if (strcmp (elm->name, ELM_ITEM) != 0) @@ -392,7 +392,7 @@ parse_element (const char *filename, return FALSE; } - item = md_history_item_new (uri, NULL); + item = moo_history_item_new (uri, NULL); g_return_val_if_fail (item != NULL, FALSE); for (child = elm->children; child != NULL; child = child->next) @@ -425,7 +425,7 @@ parse_element (const char *filename, continue; } - md_history_item_set (item, key, value); + moo_history_item_set (item, key, value); } *item_p = item; @@ -433,7 +433,7 @@ parse_element (const char *filename, } static void -load_legacy (MdHistoryMgr *mgr) +load_legacy (MooHistoryMgr *mgr) { MooMarkupDoc *xml; MooMarkupNode *root, *node; @@ -455,7 +455,7 @@ load_legacy (MdHistoryMgr *mgr) for (node = root->children; node != NULL; node = node->next) { char *uri = NULL; - MdHistoryItem *item = NULL; + MooHistoryItem *item = NULL; if (!MOO_MARKUP_IS_ELEMENT (node)) continue; @@ -467,7 +467,7 @@ load_legacy (MdHistoryMgr *mgr) } if (uri) - item = md_history_item_new (uri, NULL); + item = moo_history_item_new (uri, NULL); if (item) add_file (mgr, item); @@ -488,8 +488,8 @@ typedef enum { typedef struct { gboolean seen_root; Element element; - MdHistoryItem *item; - MdHistoryMgr *mgr; + MooHistoryItem *item; + MooHistoryMgr *mgr; } ParserData; static void @@ -504,16 +504,16 @@ start_element_root (const gchar *element_name, if (data->seen_root) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid element '%s'", element_name); return; } if (strcmp (element_name, ELM_ROOT) != 0) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid element '%s'", element_name); return; } @@ -522,16 +522,16 @@ start_element_root (const gchar *element_name, { if (seen_version || strcmp (*p, PROP_VERSION) != 0) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid attribute '%s'", *p); return; } if (strcmp (*v, PROP_VERSION_VALUE) != 0) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid version value '%s'", *v); return; } @@ -541,8 +541,8 @@ start_element_root (const gchar *element_name, if (!seen_version) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "version attribute missing"); return; } @@ -558,13 +558,13 @@ start_element_item (const gchar *element_name, ParserData *data, GError **error) { - MdHistoryItem *item = NULL; + MooHistoryItem *item = NULL; const char **p, **v; if (strcmp (element_name, ELM_ITEM) != 0) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid element '%s'", element_name); return; @@ -576,28 +576,28 @@ start_element_item (const gchar *element_name, { if (strcmp (*p, PROP_URI) != 0) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid attribute '%s'", *v); return; } if (item != NULL) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "duplicate attribute '%s'", *v); return; } - item = md_history_item_new (*v, NULL); + item = moo_history_item_new (*v, NULL); g_return_if_fail (item != NULL); } if (!item) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "missing attribute '%s'", PROP_URI); return; } @@ -620,8 +620,8 @@ start_element_data (const gchar *element_name, if (strcmp (element_name, ELM_DATA) != 0) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid element '%s'", element_name); return; @@ -641,8 +641,8 @@ start_element_data (const gchar *element_name, } else { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid attribute '%s'", *v); return; } @@ -650,21 +650,21 @@ start_element_data (const gchar *element_name, if (!key || !key[0]) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "missing attribute '%s'", PROP_KEY); return; } if (!value) { - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "missing attribute '%s'", PROP_VALUE); return; } - md_history_item_set (data->item, key, value); + moo_history_item_set (data->item, key, value); } static void @@ -690,8 +690,8 @@ parser_start_element (G_GNUC_UNUSED GMarkupParseContext *context, attribute_values, data, error); break; case ELEMENT_DATA: - g_set_error (error, MD_HISTORY_MGR_PARSE_ERROR, - MD_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, + g_set_error (error, MOO_HISTORY_MGR_PARSE_ERROR, + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT, "invalid element '%s'", element_name); break; } @@ -726,7 +726,7 @@ parser_end_element (G_GNUC_UNUSED GMarkupParseContext *context, } static void -load_file (MdHistoryMgr *mgr) +load_file (MooHistoryMgr *mgr) { const char *filename; GMarkupParser parser = {0}; @@ -761,12 +761,12 @@ load_file (MdHistoryMgr *mgr) } if (data.item) - md_history_item_free (data.item); + moo_history_item_free (data.item); } static gboolean parse_update_item (MooMarkupDoc *xml, - MdHistoryItem **item, + MooHistoryItem **item, UpdateType *type) { const char *version; @@ -816,7 +816,7 @@ parse_update_item (MooMarkupDoc *xml, } static void -ensure_files (MdHistoryMgr *mgr) +ensure_files (MooHistoryMgr *mgr) { if (!mgr->priv->loaded) load_file (mgr); @@ -824,28 +824,28 @@ ensure_files (MdHistoryMgr *mgr) static gboolean -save_in_idle (MdHistoryMgr *mgr) +save_in_idle (MooHistoryMgr *mgr) { mgr->priv->save_idle = 0; - md_history_mgr_save (mgr); + moo_history_mgr_save (mgr); return FALSE; } static void -schedule_save (MdHistoryMgr *mgr) +schedule_save (MooHistoryMgr *mgr) { if (!mgr->priv->save_idle) mgr->priv->save_idle = g_idle_add ((GSourceFunc) save_in_idle, mgr); } static void -md_history_mgr_save (MdHistoryMgr *mgr) +moo_history_mgr_save (MooHistoryMgr *mgr) { const char *filename; GError *error = NULL; MooFileWriter *writer; - g_return_if_fail (MD_IS_HISTORY_MGR (mgr)); + g_return_if_fail (MOO_IS_HISTORY_MGR (mgr)); if (!mgr->priv->files) return; @@ -861,7 +861,7 @@ md_history_mgr_save (MdHistoryMgr *mgr) if ((writer = moo_config_writer_new (filename, FALSE, &error))) { GString *string; - MdHistoryItemList *l; + MooHistoryItemList *l; moo_file_writer_write (writer, "\n", -1); moo_file_writer_write (writer, "<" ELM_ROOT " " PROP_VERSION "=\"" PROP_VERSION_VALUE "\">\n", -1); @@ -870,9 +870,9 @@ md_history_mgr_save (MdHistoryMgr *mgr) for (l = mgr->priv->files->head; l != NULL; l = l->next) { - MdHistoryItem *item = l->data; + MooHistoryItem *item = l->data; g_string_truncate (string, 0); - md_history_item_format (item, string); + moo_history_item_format (item, string); if (!moo_file_writer_write (writer, string->str, -1)) break; } @@ -894,7 +894,7 @@ md_history_mgr_save (MdHistoryMgr *mgr) static char * -format_for_update (MdHistoryItem *item, +format_for_update (MooHistoryItem *item, UpdateType type) { GString *buffer; @@ -907,7 +907,7 @@ format_for_update (MdHistoryItem *item, ELM_UPDATE, PROP_VERSION, PROP_VERSION_VALUE, PROP_TYPE, update_types[type]); - md_history_item_format (item, buffer); + moo_history_item_format (item, buffer); g_string_append (buffer, "\n"); @@ -916,71 +916,71 @@ format_for_update (MdHistoryItem *item, guint -md_history_mgr_get_n_items (MdHistoryMgr *mgr) +moo_history_mgr_get_n_items (MooHistoryMgr *mgr) { - g_return_val_if_fail (MD_IS_HISTORY_MGR (mgr), 0); + g_return_val_if_fail (MOO_IS_HISTORY_MGR (mgr), 0); ensure_files (mgr); return mgr->priv->files->length; } void -md_history_mgr_add_uri (MdHistoryMgr *mgr, +moo_history_mgr_add_uri (MooHistoryMgr *mgr, const char *uri) { - MdHistoryItem *freeme = NULL; - MdHistoryItem *item; + MooHistoryItem *freeme = NULL; + MooHistoryItem *item; - g_return_if_fail (MD_IS_HISTORY_MGR (mgr)); + g_return_if_fail (MOO_IS_HISTORY_MGR (mgr)); g_return_if_fail (uri && uri[0]); - if (!(item = md_history_mgr_find_uri (mgr, uri))) + if (!(item = moo_history_mgr_find_uri (mgr, uri))) { - freeme = md_history_item_new (uri, NULL); + freeme = moo_history_item_new (uri, NULL); item = freeme; } - md_history_mgr_add_file (mgr, item); + moo_history_mgr_add_file (mgr, item); - md_history_item_free (freeme); + moo_history_item_free (freeme); } static void -md_history_mgr_add_file_real (MdHistoryMgr *mgr, - MdHistoryItem *item, +moo_history_mgr_add_file_real (MooHistoryMgr *mgr, + MooHistoryItem *item, gboolean notify) { const char *uri; - MdHistoryItemList *link; - MdHistoryItem *new_item = NULL; + MooHistoryItemList *link; + MooHistoryItem *new_item = NULL; - g_return_if_fail (MD_IS_HISTORY_MGR (mgr)); + g_return_if_fail (MOO_IS_HISTORY_MGR (mgr)); g_return_if_fail (item != NULL); ensure_files (mgr); - uri = md_history_item_get_uri (item); - link = (MdHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); + uri = moo_history_item_get_uri (item); + link = (MooHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); if (!link) { - MdHistoryItem *copy = md_history_item_copy (item); - md_history_item_queue_push_head (mgr->priv->files, copy); + MooHistoryItem *copy = moo_history_item_copy (item); + moo_history_item_queue_push_head (mgr->priv->files, copy); new_item = copy; g_hash_table_insert (mgr->priv->hash, g_strdup (uri), mgr->priv->files->head); } else if (link != mgr->priv->files->head || - !md_history_item_equal (item, link->data)) + !moo_history_item_equal (item, link->data)) { - MdHistoryItem *tmp = link->data; + MooHistoryItem *tmp = link->data; - md_history_item_queue_unlink (mgr->priv->files, link); - md_history_item_queue_push_head_link (mgr->priv->files, link); + moo_history_item_queue_unlink (mgr->priv->files, link); + moo_history_item_queue_push_head_link (mgr->priv->files, link); - new_item = link->data = md_history_item_copy (item); + new_item = link->data = moo_history_item_copy (item); - md_history_item_free (tmp); + moo_history_item_free (tmp); } if (new_item) @@ -998,42 +998,42 @@ md_history_mgr_add_file_real (MdHistoryMgr *mgr, } if (mgr->priv->files->length > MAX_ITEM_NUMBER) - md_history_mgr_remove_uri (mgr, - md_history_item_get_uri (mgr->priv->files->tail->data)); + moo_history_mgr_remove_uri (mgr, + moo_history_item_get_uri (mgr->priv->files->tail->data)); } void -md_history_mgr_add_file (MdHistoryMgr *mgr, - MdHistoryItem *item) +moo_history_mgr_add_file (MooHistoryMgr *mgr, + MooHistoryItem *item) { - md_history_mgr_add_file_real (mgr, item, TRUE); + moo_history_mgr_add_file_real (mgr, item, TRUE); } static void -md_history_mgr_update_file_real (MdHistoryMgr *mgr, - MdHistoryItem *file, +moo_history_mgr_update_file_real (MooHistoryMgr *mgr, + MooHistoryItem *file, gboolean notify) { const char *uri; - MdHistoryItemList *link; + MooHistoryItemList *link; - g_return_if_fail (MD_IS_HISTORY_MGR (mgr)); + g_return_if_fail (MOO_IS_HISTORY_MGR (mgr)); g_return_if_fail (file != NULL); ensure_files (mgr); - uri = md_history_item_get_uri (file); - link = (MdHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); + uri = moo_history_item_get_uri (file); + link = (MooHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); if (!link) { - md_history_mgr_add_file (mgr, file); + moo_history_mgr_add_file (mgr, file); } - else if (!md_history_item_equal (link->data, file)) + else if (!moo_history_item_equal (link->data, file)) { - MdHistoryItem *tmp = link->data; - link->data = md_history_item_copy (file); - md_history_item_free (tmp); + MooHistoryItem *tmp = link->data; + link->data = moo_history_item_copy (file); + moo_history_item_free (tmp); g_signal_emit (mgr, signals[CHANGED], 0); if (notify) @@ -1045,42 +1045,42 @@ md_history_mgr_update_file_real (MdHistoryMgr *mgr, } void -md_history_mgr_update_file (MdHistoryMgr *mgr, - MdHistoryItem *file) +moo_history_mgr_update_file (MooHistoryMgr *mgr, + MooHistoryItem *file) { - md_history_mgr_update_file_real (mgr, file, TRUE); + moo_history_mgr_update_file_real (mgr, file, TRUE); } -MdHistoryItem * -md_history_mgr_find_uri (MdHistoryMgr *mgr, +MooHistoryItem * +moo_history_mgr_find_uri (MooHistoryMgr *mgr, const char *uri) { - MdHistoryItemList *link; + MooHistoryItemList *link; - g_return_val_if_fail (MD_IS_HISTORY_MGR (mgr), NULL); + g_return_val_if_fail (MOO_IS_HISTORY_MGR (mgr), NULL); g_return_val_if_fail (uri != NULL, NULL); ensure_files (mgr); - link = (MdHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); + link = (MooHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); return link ? link->data : NULL; } static void -md_history_mgr_remove_uri_real (MdHistoryMgr *mgr, +moo_history_mgr_remove_uri_real (MooHistoryMgr *mgr, const char *uri, gboolean notify) { - MdHistoryItemList *link; - MdHistoryItem *item; + MooHistoryItemList *link; + MooHistoryItem *item; - g_return_if_fail (MD_IS_HISTORY_MGR (mgr)); + g_return_if_fail (MOO_IS_HISTORY_MGR (mgr)); g_return_if_fail (uri != NULL); ensure_files (mgr); - link = (MdHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); + link = (MooHistoryItemList*) g_hash_table_lookup (mgr->priv->hash, uri); if (!link) return; @@ -1088,7 +1088,7 @@ md_history_mgr_remove_uri_real (MdHistoryMgr *mgr, item = link->data; g_hash_table_remove (mgr->priv->hash, uri); - md_history_item_queue_delete_link (mgr->priv->files, link); + moo_history_item_queue_delete_link (mgr->priv->files, link); g_signal_emit (mgr, signals[CHANGED], 0); @@ -1101,14 +1101,14 @@ md_history_mgr_remove_uri_real (MdHistoryMgr *mgr, if (mgr->priv->files->length == 0) g_object_notify (G_OBJECT (mgr), "empty"); - md_history_item_free (item); + moo_history_item_free (item); } void -md_history_mgr_remove_uri (MdHistoryMgr *mgr, +moo_history_mgr_remove_uri (MooHistoryMgr *mgr, const char *uri) { - md_history_mgr_remove_uri_real (mgr, uri, TRUE); + moo_history_mgr_remove_uri_real (mgr, uri, TRUE); } @@ -1117,15 +1117,15 @@ ipc_callback (GObject *obj, const char *data, gsize len) { - MdHistoryMgr *mgr; + MooHistoryMgr *mgr; MooMarkupDoc *xml; GError *error = NULL; - MdHistoryItem *item; + MooHistoryItem *item; UpdateType type; - g_return_if_fail (MD_IS_HISTORY_MGR (obj)); + g_return_if_fail (MOO_IS_HISTORY_MGR (obj)); - mgr = MD_HISTORY_MGR (obj); + mgr = MOO_HISTORY_MGR (obj); ensure_files (mgr); xml = moo_markup_parse_memory (data, len, &error); @@ -1145,25 +1145,25 @@ ipc_callback (GObject *obj, switch (type) { case UPDATE_ITEM_UPDATE: - md_history_mgr_update_file_real (mgr, item, FALSE); + moo_history_mgr_update_file_real (mgr, item, FALSE); break; case UPDATE_ITEM_ADD: - md_history_mgr_add_file_real (mgr, item, FALSE); + moo_history_mgr_add_file_real (mgr, item, FALSE); break; case UPDATE_ITEM_REMOVE: - md_history_mgr_remove_uri_real (mgr, md_history_item_get_uri (item), FALSE); + moo_history_mgr_remove_uri_real (mgr, moo_history_item_get_uri (item), FALSE); break; } - md_history_item_free (item); + moo_history_item_free (item); } moo_markup_doc_unref (xml); } static void -ipc_notify (MdHistoryMgr *mgr, - MdHistoryItem *item, +ipc_notify (MooHistoryMgr *mgr, + MooHistoryItem *item, UpdateType type) { if (mgr->priv->ipc_id) @@ -1175,22 +1175,22 @@ ipc_notify (MdHistoryMgr *mgr, } static void -ipc_notify_add_file (MdHistoryMgr *mgr, - MdHistoryItem *item) +ipc_notify_add_file (MooHistoryMgr *mgr, + MooHistoryItem *item) { ipc_notify (mgr, item, UPDATE_ITEM_ADD); } static void -ipc_notify_update_file (MdHistoryMgr *mgr, - MdHistoryItem *item) +ipc_notify_update_file (MooHistoryMgr *mgr, + MooHistoryItem *item) { ipc_notify (mgr, item, UPDATE_ITEM_UPDATE); } static void -ipc_notify_remove_file (MdHistoryMgr *mgr, - MdHistoryItem *item) +ipc_notify_remove_file (MooHistoryMgr *mgr, + MooHistoryItem *item) { ipc_notify (mgr, item, UPDATE_ITEM_REMOVE); } @@ -1213,14 +1213,14 @@ callback_data_free (CallbackData *data) static void view_destroyed (GtkWidget *widget, - MdHistoryMgr *mgr) + MooHistoryMgr *mgr) { - g_object_set_data (G_OBJECT (widget), "md-history-mgr-callback-data", NULL); + g_object_set_data (G_OBJECT (widget), "moo-history-mgr-callback-data", NULL); mgr->priv->widgets = widget_list_remove (mgr->priv->widgets, widget); } static void -update_menu (MdHistoryMgr *mgr, +update_menu (MooHistoryMgr *mgr, GtkWidget *menu) { WidgetList *children; @@ -1231,7 +1231,7 @@ update_menu (MdHistoryMgr *mgr, { GtkWidget *item = children->data; - if (g_object_get_data (G_OBJECT (item), "md-history-menu-item-file")) + if (g_object_get_data (G_OBJECT (item), "moo-history-menu-item-file")) gtk_widget_destroy (item); children = widget_list_delete_link (children, children); @@ -1241,15 +1241,15 @@ update_menu (MdHistoryMgr *mgr, } GtkWidget * -md_history_mgr_create_menu (MdHistoryMgr *mgr, - MdHistoryCallback callback, +moo_history_mgr_create_menu (MooHistoryMgr *mgr, + MooHistoryCallback callback, gpointer data, GDestroyNotify notify) { GtkWidget *menu; CallbackData *cb_data; - g_return_val_if_fail (MD_IS_HISTORY_MGR (mgr), NULL); + g_return_val_if_fail (MOO_IS_HISTORY_MGR (mgr), NULL); g_return_val_if_fail (callback != NULL, NULL); menu = gtk_menu_new (); @@ -1260,7 +1260,7 @@ md_history_mgr_create_menu (MdHistoryMgr *mgr, cb_data->callback = callback; cb_data->data = data; cb_data->notify = notify; - g_object_set_data_full (G_OBJECT (menu), "md-history-mgr-callback-data", + g_object_set_data_full (G_OBJECT (menu), "moo-history-mgr-callback-data", cb_data, (GDestroyNotify) callback_data_free); populate_menu (mgr, menu); @@ -1274,27 +1274,27 @@ menu_item_activated (GtkWidget *menu_item) { GtkWidget *parent = menu_item->parent; CallbackData *data; - MdHistoryItem *item; + MooHistoryItem *item; GSList *list; g_return_if_fail (parent != NULL); - data = (CallbackData*) g_object_get_data (G_OBJECT (parent), "md-history-mgr-callback-data"); - item = (MdHistoryItem*) g_object_get_data (G_OBJECT (menu_item), "md-history-menu-item-file"); + data = (CallbackData*) g_object_get_data (G_OBJECT (parent), "moo-history-mgr-callback-data"); + item = (MooHistoryItem*) g_object_get_data (G_OBJECT (menu_item), "moo-history-menu-item-file"); g_return_if_fail (data && item); - list = g_slist_prepend (NULL, md_history_item_copy (item)); + list = g_slist_prepend (NULL, moo_history_item_copy (item)); data->callback (list, data->data); - md_history_item_free ((MdHistoryItem*) list->data); + moo_history_item_free ((MooHistoryItem*) list->data); g_slist_free (list); } static void -populate_menu (MdHistoryMgr *mgr, +populate_menu (MooHistoryMgr *mgr, GtkWidget *menu) { guint n_items, i; - MdHistoryItemList *l; + MooHistoryItemList *l; ensure_files (mgr); @@ -1303,7 +1303,7 @@ populate_menu (MdHistoryMgr *mgr, for (i = 0, l = mgr->priv->files->head; i < n_items; i++, l = l->next) { GtkWidget *item, *image; - MdHistoryItem *hist_item = l->data; + MooHistoryItem *hist_item = l->data; char *display_name, *display_basename; GdkPixbuf *pixbuf; @@ -1316,15 +1316,15 @@ populate_menu (MdHistoryMgr *mgr, gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, i); /* XXX */ - pixbuf = moo_file_icon_get_pixbuf (md_history_item_get_icon (hist_item), + pixbuf = moo_file_icon_get_pixbuf (moo_history_item_get_icon (hist_item), GTK_WIDGET (item), GTK_ICON_SIZE_MENU); image = gtk_image_new_from_pixbuf (pixbuf); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - g_object_set_data_full (G_OBJECT (item), "md-history-menu-item-file", - md_history_item_copy (hist_item), - (GDestroyNotify) md_history_item_free); + g_object_set_data_full (G_OBJECT (item), "moo-history-menu-item-file", + moo_history_item_copy (hist_item), + (GDestroyNotify) moo_history_item_free); g_signal_connect (item, "activate", G_CALLBACK (menu_item_activated), NULL); g_free (display_basename); @@ -1348,14 +1348,14 @@ open_selected (GtkTreeView *tree_view) GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *selection; - MdHistoryMgr *mgr; + MooHistoryMgr *mgr; GList *selected; GSList *items; - mgr = (MdHistoryMgr*) g_object_get_data (G_OBJECT (tree_view), "md-history-mgr"); - g_return_if_fail (MD_IS_HISTORY_MGR (mgr)); + mgr = (MooHistoryMgr*) g_object_get_data (G_OBJECT (tree_view), "moo-history-mgr"); + g_return_if_fail (MOO_IS_HISTORY_MGR (mgr)); - data = (CallbackData*) g_object_get_data (G_OBJECT (tree_view), "md-history-mgr-callback-data"); + data = (CallbackData*) g_object_get_data (G_OBJECT (tree_view), "moo-history-mgr-callback-data"); g_return_if_fail (data != NULL); selection = gtk_tree_view_get_selection (tree_view); @@ -1364,15 +1364,15 @@ open_selected (GtkTreeView *tree_view) for (items = NULL; selected != NULL; ) { char *uri = NULL; - MdHistoryItem *item; + MooHistoryItem *item; GtkTreePath *path = (GtkTreePath*) selected->data; gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, COLUMN_URI, &uri, -1); - item = md_history_mgr_find_uri (mgr, uri); + item = moo_history_mgr_find_uri (mgr, uri); if (item) - items = g_slist_prepend (items, md_history_item_copy (item)); + items = g_slist_prepend (items, moo_history_item_copy (item)); g_free (uri); gtk_tree_path_free (path); @@ -1384,7 +1384,7 @@ open_selected (GtkTreeView *tree_view) if (items) data->callback (items, data->data); - g_slist_foreach (items, (GFunc) md_history_item_free, NULL); + g_slist_foreach (items, (GFunc) moo_history_item_free, NULL); g_slist_free (items); } @@ -1428,7 +1428,7 @@ create_tree_view (void) #define LOADING_PRIORITY G_PRIORITY_DEFAULT_IDLE typedef struct { - MdHistoryItemList *items; + MooHistoryItemList *items; guint idle; GtkWidget *tree_view; GtkListStore *store; @@ -1438,7 +1438,7 @@ static void cancel_idle_loading (GtkWidget *tree_view) { g_object_set_data (G_OBJECT (tree_view), - "md-history-mgr-idle-loader", + "moo-history-mgr-idle-loader", NULL); } @@ -1447,13 +1447,13 @@ idle_loader_free (IdleLoader *data) { if (data->idle) g_source_remove (data->idle); - md_history_item_list_foreach (data->items, (MdHistoryItemListFunc) md_history_item_free, NULL); - md_history_item_list_free_links (data->items); + moo_history_item_list_foreach (data->items, (MooHistoryItemListFunc) moo_history_item_free, NULL); + moo_history_item_list_free_links (data->items); g_free (data); } static void -add_entry (MdHistoryItem *item, +add_entry (MooHistoryItem *item, GtkListStore *store, GtkWidget *tree_view) { @@ -1463,7 +1463,7 @@ add_entry (MdHistoryItem *item, display_basename = uri_get_basename (item->uri); display_name = uri_get_display_name (item->uri); - pixbuf = moo_file_icon_get_pixbuf (md_history_item_get_icon (item), + pixbuf = moo_file_icon_get_pixbuf (moo_history_item_get_icon (item), tree_view, GTK_ICON_SIZE_MENU); gtk_list_store_append (store, &iter); @@ -1471,7 +1471,7 @@ add_entry (MdHistoryItem *item, COLUMN_PIXBUF, pixbuf, COLUMN_NAME, display_basename, COLUMN_TOOLTIP, display_name, - COLUMN_URI, md_history_item_get_uri (item), + COLUMN_URI, moo_history_item_get_uri (item), -1); g_free (display_basename); @@ -1486,15 +1486,15 @@ idle_loader (IdleLoader *data) for (count = 0; data->items != NULL && count < CHUNK_SIZE; count++) { add_entry (data->items->data, data->store, data->tree_view); - md_history_item_free (data->items->data); - data->items = md_history_item_list_delete_link (data->items, data->items); + moo_history_item_free (data->items->data); + data->items = moo_history_item_list_delete_link (data->items, data->items); } if (!data->items) { data->idle = 0; g_object_set_data (G_OBJECT (data->tree_view), - "md-history-mgr-idle-loader", + "moo-history-mgr-idle-loader", NULL); return FALSE; } @@ -1505,12 +1505,12 @@ idle_loader (IdleLoader *data) } static void -populate_tree_view (MdHistoryMgr *mgr, +populate_tree_view (MooHistoryMgr *mgr, GtkWidget *tree_view) { GtkListStore *store; GtkTreeModel *model; - MdHistoryItemList *l; + MooHistoryItemList *l; int count; ensure_files (mgr); @@ -1533,11 +1533,11 @@ populate_tree_view (MdHistoryMgr *mgr, while (l != NULL) { - data->items = md_history_item_list_prepend (data->items, md_history_item_copy (l->data)); + data->items = moo_history_item_list_prepend (data->items, moo_history_item_copy (l->data)); l = l->next; } - data->items = md_history_item_list_reverse (data->items); + data->items = moo_history_item_list_reverse (data->items); data->idle = g_timeout_add_full (LOADING_PRIORITY, LOADING_TIMEOUT, (GSourceFunc) idle_loader, @@ -1546,13 +1546,13 @@ populate_tree_view (MdHistoryMgr *mgr, data->store = store; g_object_set_data_full (G_OBJECT (tree_view), - "md-history-mgr-idle-loader", data, + "moo-history-mgr-idle-loader", data, (GDestroyNotify) idle_loader_free); } } static void -update_tree_view (MdHistoryMgr *mgr, +update_tree_view (MooHistoryMgr *mgr, GtkWidget *tree_view) { GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); @@ -1561,15 +1561,15 @@ update_tree_view (MdHistoryMgr *mgr, } static GtkWidget * -md_history_mgr_create_tree_view (MdHistoryMgr *mgr, - MdHistoryCallback callback, - gpointer data, - GDestroyNotify notify) +moo_history_mgr_create_tree_view (MooHistoryMgr *mgr, + MooHistoryCallback callback, + gpointer data, + GDestroyNotify notify) { GtkWidget *tree_view; CallbackData *cb_data; - g_return_val_if_fail (MD_IS_HISTORY_MGR (mgr), NULL); + g_return_val_if_fail (MOO_IS_HISTORY_MGR (mgr), NULL); g_return_val_if_fail (callback != NULL, NULL); tree_view = create_tree_view (); @@ -1580,9 +1580,9 @@ md_history_mgr_create_tree_view (MdHistoryMgr *mgr, cb_data->callback = callback; cb_data->data = data; cb_data->notify = notify; - g_object_set_data_full (G_OBJECT (tree_view), "md-history-mgr-callback-data", + g_object_set_data_full (G_OBJECT (tree_view), "moo-history-mgr-callback-data", cb_data, (GDestroyNotify) callback_data_free); - g_object_set_data (G_OBJECT (tree_view), "md-history-mgr", mgr); + g_object_set_data (G_OBJECT (tree_view), "moo-history-mgr", mgr); populate_tree_view (mgr, tree_view); if (mgr->priv->files->head) @@ -1607,14 +1607,14 @@ row_activated (GtkDialog *dialog) } GtkWidget * -md_history_mgr_create_dialog (MdHistoryMgr *mgr, - MdHistoryCallback callback, - gpointer data, - GDestroyNotify notify) +moo_history_mgr_create_dialog (MooHistoryMgr *mgr, + MooHistoryCallback callback, + gpointer data, + GDestroyNotify notify) { GtkWidget *dialog, *swin, *tree_view; - g_return_val_if_fail (MD_IS_HISTORY_MGR (mgr), NULL); + g_return_val_if_fail (MOO_IS_HISTORY_MGR (mgr), NULL); g_return_val_if_fail (callback != NULL, NULL); dialog = gtk_dialog_new_with_buttons ("", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, @@ -1629,7 +1629,7 @@ md_history_mgr_create_dialog (MdHistoryMgr *mgr, swin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - tree_view = md_history_mgr_create_tree_view (mgr, callback, data, notify); + tree_view = moo_history_mgr_create_tree_view (mgr, callback, data, notify); gtk_container_add (GTK_CONTAINER (swin), tree_view); gtk_widget_show_all (swin); @@ -1645,7 +1645,7 @@ md_history_mgr_create_dialog (MdHistoryMgr *mgr, static gboolean -do_update_widgets (MdHistoryMgr *mgr) +do_update_widgets (MooHistoryMgr *mgr) { WidgetList *l; @@ -1667,7 +1667,7 @@ do_update_widgets (MdHistoryMgr *mgr) } static void -schedule_update_widgets (MdHistoryMgr *mgr) +schedule_update_widgets (MooHistoryMgr *mgr) { if (!mgr->priv->update_widgets_idle && mgr->priv->widgets) mgr->priv->update_widgets_idle = @@ -1676,59 +1676,59 @@ schedule_update_widgets (MdHistoryMgr *mgr) void -md_history_item_free (MdHistoryItem *item) +moo_history_item_free (MooHistoryItem *item) { if (item) { g_free (item->uri); g_datalist_clear (&item->data); moo_file_icon_free (item->icon); - moo_free (MdHistoryItem, item); + moo_free (MooHistoryItem, item); } } -static MdHistoryItem * -md_history_item_new_uri (const char *uri) +static MooHistoryItem * +moo_history_item_new_uri (const char *uri) { - MdHistoryItem *item = moo_new (MdHistoryItem); + MooHistoryItem *item = moo_new (MooHistoryItem); item->uri = g_strdup (uri); item->data = NULL; item->icon = NULL; return item; } -static MdHistoryItem * -md_history_item_newv (const char *uri, - const char *first_key, - va_list args) +static MooHistoryItem * +moo_history_item_newv (const char *uri, + const char *first_key, + va_list args) { const char *key; - MdHistoryItem *item; + MooHistoryItem *item; - item = md_history_item_new_uri (uri); + item = moo_history_item_new_uri (uri); for (key = first_key; key != NULL; ) { const char *value = va_arg (args, const char *); - md_history_item_set (item, key, value); + moo_history_item_set (item, key, value); key = va_arg (args, const char *); } return item; } -MdHistoryItem * -md_history_item_new (const char *uri, - const char *first_key, - ...) +MooHistoryItem * +moo_history_item_new (const char *uri, + const char *first_key, + ...) { va_list args; - MdHistoryItem *item; + MooHistoryItem *item; g_return_val_if_fail (uri != NULL, NULL); va_start (args, first_key); - item = md_history_item_newv (uri, first_key, args); + item = moo_history_item_newv (uri, first_key, args); va_end (args); return item; @@ -1737,20 +1737,20 @@ md_history_item_new (const char *uri, static void copy_data (GQuark key, const char *value, - MdHistoryItem *dest) + MooHistoryItem *dest) { g_datalist_id_set_data_full (&dest->data, key, g_strdup (value), g_free); } -MdHistoryItem * -md_history_item_copy (MdHistoryItem *item) +MooHistoryItem * +moo_history_item_copy (MooHistoryItem *item) { - MdHistoryItem *copy; + MooHistoryItem *copy; if (!item) return NULL; - copy = md_history_item_new_uri (item->uri); + copy = moo_history_item_new_uri (item->uri); g_datalist_foreach (&item->data, (GDataForeachFunc) copy_data, copy); copy->icon = moo_file_icon_copy (item->icon); @@ -1758,7 +1758,7 @@ md_history_item_copy (MdHistoryItem *item) } typedef struct { - MdHistoryItem *item; + MooHistoryItem *item; gboolean equal; } CmpData; @@ -1778,8 +1778,8 @@ cmp_data (GQuark key, } static gboolean -md_history_item_equal (MdHistoryItem *item1, - MdHistoryItem *item2) +moo_history_item_equal (MooHistoryItem *item1, + MooHistoryItem *item2) { CmpData data; @@ -1806,9 +1806,9 @@ md_history_item_equal (MdHistoryItem *item1, } void -md_history_item_set (MdHistoryItem *item, - const char *key, - const char *value) +moo_history_item_set (MooHistoryItem *item, + const char *key, + const char *value) { g_return_if_fail (item != NULL); g_return_if_fail (key != NULL); @@ -1820,8 +1820,8 @@ md_history_item_set (MdHistoryItem *item, } const char * -md_history_item_get (MdHistoryItem *item, - const char *key) +moo_history_item_get (MooHistoryItem *item, + const char *key) { g_return_val_if_fail (item != NULL, NULL); g_return_val_if_fail (key != NULL, NULL); @@ -1829,14 +1829,14 @@ md_history_item_get (MdHistoryItem *item, } const char * -md_history_item_get_uri (MdHistoryItem *item) +moo_history_item_get_uri (MooHistoryItem *item) { g_return_val_if_fail (item != NULL, NULL); return item->uri; } static MooFileIcon * -md_history_item_get_icon (MdHistoryItem *item) +moo_history_item_get_icon (MooHistoryItem *item) { g_return_val_if_fail (item != NULL, NULL); @@ -1871,8 +1871,8 @@ format_data (GQuark key_id, } static void -md_history_item_format (MdHistoryItem *item, - GString *dest) +moo_history_item_format (MooHistoryItem *item, + GString *dest) { char *uri_escaped; @@ -1896,9 +1896,9 @@ md_history_item_format (MdHistoryItem *item, } void -md_history_item_foreach (MdHistoryItem *item, - GDataForeachFunc func, - gpointer user_data) +moo_history_item_foreach (MooHistoryItem *item, + GDataForeachFunc func, + gpointer user_data) { g_return_if_fail (item != NULL); g_return_if_fail (func != NULL); diff --git a/moo/mooutils/moohistorymgr.h b/moo/mooutils/moohistorymgr.h new file mode 100644 index 00000000..56f6341a --- /dev/null +++ b/moo/mooutils/moohistorymgr.h @@ -0,0 +1,99 @@ +/* + * moohistorymgr.h + * + * Copyright (C) 2004-2010 by Yevgen Muntyan + * + * This file is part of medit. medit is free software; you can + * redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public + * License along with medit. If not, see . + */ + +#ifndef MOO_HISTORY_MGR_H +#define MOO_HISTORY_MGR_H + +#include + +G_BEGIN_DECLS + +#define MOO_HISTORY_MGR_PARSE_ERROR (moo_history_mgr_parse_error_quark ()) + +enum { + MOO_HISTORY_MGR_PARSE_ERROR_INVALID_CONTENT +}; + +#define MOO_TYPE_HISTORY_MGR (moo_history_mgr_get_type ()) +#define MOO_HISTORY_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOO_TYPE_HISTORY_MGR, MooHistoryMgr)) +#define MOO_HISTORY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_HISTORY_MGR, MooHistoryMgrClass)) +#define MOO_IS_HISTORY_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOO_TYPE_HISTORY_MGR)) +#define MOO_IS_HISTORY_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_HISTORY_MGR)) +#define MOO_HISTORY_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_HISTORY_MGR, MooHistoryMgrClass)) + +typedef struct _MooHistoryItem MooHistoryItem; +typedef struct _MooHistoryMgr MooHistoryMgr; +typedef struct _MooHistoryMgrClass MooHistoryMgrClass; +typedef struct _MooHistoryMgrPrivate MooHistoryMgrPrivate; + +struct _MooHistoryMgr { + GObject base; + MooHistoryMgrPrivate *priv; +}; + +struct _MooHistoryMgrClass { + GObjectClass base_class; +}; + +typedef void (*MooHistoryCallback) (GSList *items, + gpointer data); + +GQuark moo_history_mgr_parse_error_quark (void) G_GNUC_CONST; +GType moo_history_mgr_get_type (void) G_GNUC_CONST; + +void moo_history_mgr_add_file (MooHistoryMgr *mgr, + MooHistoryItem *item); +void moo_history_mgr_update_file (MooHistoryMgr *mgr, + MooHistoryItem *item); +void moo_history_mgr_add_uri (MooHistoryMgr *mgr, + const char *uri); +void moo_history_mgr_remove_uri (MooHistoryMgr *mgr, + const char *uri); +MooHistoryItem *moo_history_mgr_find_uri (MooHistoryMgr *mgr, + const char *uri); + +void moo_history_mgr_shutdown (MooHistoryMgr *mgr); + +guint moo_history_mgr_get_n_items (MooHistoryMgr *mgr); + +GtkWidget *moo_history_mgr_create_menu (MooHistoryMgr *mgr, + MooHistoryCallback callback, + gpointer data, + GDestroyNotify notify); +GtkWidget *moo_history_mgr_create_dialog (MooHistoryMgr *mgr, + MooHistoryCallback callback, + gpointer data, + GDestroyNotify notify); + +MooHistoryItem *moo_history_item_new (const char *uri, + const char *first_key, + ...); +MooHistoryItem *moo_history_item_copy (MooHistoryItem *item); +void moo_history_item_free (MooHistoryItem *item); +void moo_history_item_set (MooHistoryItem *item, + const char *key, + const char *value); +const char *moo_history_item_get (MooHistoryItem *item, + const char *key); +const char *moo_history_item_get_uri (MooHistoryItem *item); +void moo_history_item_foreach (MooHistoryItem *item, + GDataForeachFunc func, + gpointer user_data); + +char *_moo_history_mgr_get_filename (MooHistoryMgr *mgr); + +G_END_DECLS + +#endif /* MOO_HISTORY_MGR_H */