MOO_ASSIGN_STRING, MOO_OBJECT_REF_SINK

master
Yevgen Muntyan 2007-12-19 14:02:42 -06:00
parent a797478846
commit 70d5fbc914
24 changed files with 45 additions and 105 deletions

View File

@ -1294,14 +1294,9 @@ moo_command_data_set (MooCommandData *data,
guint index,
const char *value)
{
char *tmp;
g_return_if_fail (data != NULL);
g_return_if_fail (index < data->len);
tmp = data->data[index];
data->data[index] = g_strdup (value);
g_free (tmp);
MOO_ASSIGN_STRING (data->data[index], value);
}
@ -1319,13 +1314,8 @@ static void
moo_command_data_take_code (MooCommandData *data,
char *code)
{
char *tmp;
g_return_if_fail (data != NULL);
tmp = data->code;
data->code = code;
g_free (tmp);
MOO_ASSIGN_STRING (data->code, code);
}

View File

@ -13,7 +13,7 @@
#define MOOEDIT_COMPILATION
#include "mooedit/moocommanddisplay.h"
#include "mooedit/moocommand-private.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include <string.h>

View File

@ -22,7 +22,6 @@
#include "mooedit/mooeditfiltersettings.h"
#include "mooedit/mooeditor-private.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooglade.h"
#include "mooutils/mooi18n.h"
#include "mooutils/mooutils-misc.h"
@ -694,9 +693,7 @@ _moo_edit_set_encoding (MooEdit *edit,
if (!_moo_str_equal (encoding, edit->priv->encoding))
{
char *tmp = edit->priv->encoding;
edit->priv->encoding = g_strdup (encoding);
g_free (tmp);
MOO_ASSIGN_STRING (edit->priv->encoding, encoding);
g_object_notify (G_OBJECT (edit), "encoding");
}
}

View File

@ -698,16 +698,9 @@ void
moo_editor_set_app_name (MooEditor *editor,
const char *name)
{
char *tmp;
g_return_if_fail (MOO_IS_EDITOR (editor));
tmp = editor->priv->app_name;
editor->priv->app_name = g_strdup (name);
MOO_ASSIGN_STRING (editor->priv->app_name, name);
_moo_edit_window_update_title ();
g_free (tmp);
}
const char *

View File

@ -14,6 +14,7 @@
#include "mooedit/mootext-private.h"
#include "mooedit/mootextbuffer.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-misc.h"
struct _MooLineMarkPrivate {
@ -367,16 +368,12 @@ void
moo_line_mark_set_markup (MooLineMark *mark,
const char *markup)
{
char *tmp;
g_return_if_fail (MOO_IS_LINE_MARK (mark));
if (!markup || !markup[0])
markup = NULL;
tmp = mark->priv->markup;
mark->priv->markup = g_strdup (markup);
g_free (tmp);
MOO_ASSIGN_STRING (mark->priv->markup, markup);
}

View File

@ -14,6 +14,7 @@
#include "mooedit/mooeditor.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-debug.h"
#include "mooutils/mooutils-misc.h"
#include <string.h>
@ -220,14 +221,8 @@ void
moo_output_filter_cmd_start (MooOutputFilter *filter,
const char *active_dir)
{
char *tmp;
g_return_if_fail (MOO_IS_OUTPUT_FILTER (filter));
tmp = filter->priv->active_dir;
filter->priv->active_dir = g_strdup (active_dir);
g_free (tmp);
MOO_ASSIGN_STRING (filter->priv->active_dir, active_dir);
g_signal_emit (filter, signals[CMD_START], 0);
}
@ -314,13 +309,8 @@ void
moo_output_filter_set_active_file (MooOutputFilter *filter,
const char *filename)
{
char *tmp;
g_return_if_fail (MOO_IS_OUTPUT_FILTER (filter));
tmp = filter->priv->active_file;
filter->priv->active_file = g_strdup (filename);
g_free (tmp);
MOO_ASSIGN_STRING (filter->priv->active_file, filename);
}

View File

@ -1580,17 +1580,9 @@ moo_print_operation_set_filename (MooPrintOperation *op,
const char *filename,
const char *basename)
{
char *tmp;
g_return_if_fail (MOO_IS_PRINT_OPERATION (op));
tmp = op->priv->filename;
op->priv->filename = g_strdup (filename);
g_free (tmp);
tmp = op->priv->basename;
op->priv->basename = g_strdup (basename);
g_free (tmp);
MOO_ASSIGN_STRING (op->priv->filename, filename);
MOO_ASSIGN_STRING (op->priv->basename, basename);
}

View File

@ -21,7 +21,6 @@
#include "mooedit/mooeditprefs.h"
#include "mooedit/mootextbox.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooundo.h"
#include "mooutils/mooentry.h"
@ -1612,14 +1611,10 @@ moo_text_view_set_color (MooTextView *view,
const char *color,
const char *propname)
{
char *tmp;
g_return_if_fail (MOO_IS_TEXT_VIEW (view));
g_return_if_fail (color_num < MOO_TEXT_VIEW_N_COLORS);
tmp = view->priv->colors[color_num];
view->priv->colors[color_num] = g_strdup (color);
g_free (tmp);
MOO_ASSIGN_STRING (view->priv->colors[color_num], color);
invalidate_gcs (view);

View File

@ -22,7 +22,6 @@
#include "mooutils/mooprefs.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooactionfactory.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/moostock.h"
#include <string.h>

View File

@ -18,7 +18,6 @@
#include "mooterm/mootermbuffer-private.h"
#include "mooterm/mooterm-text.h"
#include "mooutils/moomarshals.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-debug.h"
#include <string.h>

View File

@ -12,6 +12,7 @@
#include "mooutils/mooactiongroup.h"
#include "mooutils/mooactionbase.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/moowindow.h"
#include <string.h>
@ -74,14 +75,11 @@ moo_action_collection_set_property (GObject *object,
GParamSpec *pspec)
{
MooActionCollection *coll = MOO_ACTION_COLLECTION (object);
char *tmp;
switch (property_id)
{
case PROP_NAME:
tmp = coll->priv->name;
coll->priv->name = g_strdup (g_value_get_string (value));
g_free (tmp);
MOO_ASSIGN_STRING (coll->priv->name, g_value_get_string (value));
break;
case PROP_DISPLAY_NAME:
moo_action_collection_set_display_name (coll, g_value_get_string (value));

View File

@ -11,6 +11,7 @@
*/
#include "mooutils/mooactiongroup.h"
#include "mooutils/mooutils-misc.h"
G_DEFINE_TYPE (MooActionGroup, _moo_action_group, GTK_TYPE_ACTION_GROUP)
@ -39,13 +40,8 @@ void
_moo_action_group_set_display_name (MooActionGroup *group,
const char *display_name)
{
char *tmp;
g_return_if_fail (MOO_IS_ACTION_GROUP (group));
tmp = group->display_name;
group->display_name = g_strdup (display_name);
g_free (tmp);
MOO_ASSIGN_STRING (group->display_name, display_name);
}

View File

@ -18,7 +18,7 @@
#include "moomarshals.h"
#ifdef MOO_COMPILATION
#include "mooutils-gobject.h"
#include "mooutils-misc.h"
#else
#if GLIB_CHECK_VERSION(2,10,0)
#define MOO_OBJECT_REF_SINK(obj) g_object_ref_sink (obj)

View File

@ -108,16 +108,12 @@ moo_file_dialog_set_property (GObject *object,
break;
case PROP_DIR:
tmp = dialog->priv->dir;
dialog->priv->dir = g_value_dup_string (value);
g_free (tmp);
MOO_ASSIGN_STRING (dialog->priv->dir, g_value_get_string (value));
g_object_notify (object, "dir");
break;
case PROP_NAME:
tmp = dialog->priv->name;
dialog->priv->name = g_value_dup_string (value);
g_free (tmp);
MOO_ASSIGN_STRING (dialog->priv->name, g_value_get_string (value));
g_object_notify (object, "name");
break;
@ -518,9 +514,7 @@ static void
set_encoding (MooFileDialog *dialog,
const char *encoding)
{
char *tmp = dialog->priv->encoding;
dialog->priv->encoding = g_strdup (encoding);
g_free (tmp);
MOO_ASSIGN_STRING (dialog->priv->encoding, encoding);
}
void

View File

@ -12,7 +12,6 @@
#include "mooutils/moofiltermgr.h"
#include "mooutils/mooprefs.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include <string.h>
#include <gtk/gtk.h>

View File

@ -319,13 +319,8 @@ static void
moo_markup_doc_set_name (MooMarkupDoc *doc,
const char *name)
{
char *tmp;
g_return_if_fail (MOO_MARKUP_IS_DOC (doc));
tmp = doc->name;
doc->name = g_strdup (name ? name : "");
g_free (tmp);
MOO_ASSIGN_STRING (doc->name, name ? name : "");
}

View File

@ -11,7 +11,7 @@
*/
#include "mooutils/moomenutoolbutton.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include <gtk/gtk.h>

View File

@ -16,7 +16,6 @@
#include "mooutils/moomarshals.h"
#include "mooutils/moonotebook.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/mooutils-misc.h"
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

View File

@ -23,7 +23,7 @@
#ifdef MOO_COMPILATION
# include "mooutils-gobject.h"
# include "mooutils-misc.h"
#else
# if GLIB_CHECK_VERSION(2,10,0)
# define MOO_OBJECT_REF_SINK(obj) g_object_ref_sink (obj)

View File

@ -15,6 +15,7 @@
#include "mooutils/moostock.h"
#include "mooutils/mooprefs.h"
#include "mooutils/mooprefsdialogpage.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/moofontsel.h"
#include "mooutils/mooi18n.h"

View File

@ -27,13 +27,6 @@
G_BEGIN_DECLS
#if GLIB_CHECK_VERSION(2,10,0)
#define MOO_OBJECT_REF_SINK(obj) g_object_ref_sink (obj)
#else
#define MOO_OBJECT_REF_SINK(obj) gtk_object_sink (g_object_ref (obj))
#endif
/*****************************************************************************/
/* GType type
*/

View File

@ -124,6 +124,17 @@ _moo_str_equal_inline (const char *s1,
#define _moo_str_equal(s1, s2) (_moo_str_equal_inline ((s1), (s2)))
static inline void
moo_assign_string (char **where,
const char *value)
{
char *tmp = *where;
*where = g_strdup (value);
g_free (tmp);
}
#define MOO_ASSIGN_STRING(where, value) moo_assign_string (&(where), (value))
const char *_moo_get_pid_string (void);
const char *_moo_intern_string (const char *string);
@ -169,6 +180,12 @@ gboolean _moo_regex_escape (const char *string,
#define _moo_free(type,mem) g_free (mem)
#endif
#if GLIB_CHECK_VERSION(2,10,0)
#define MOO_OBJECT_REF_SINK(obj) g_object_ref_sink (obj)
#else
#define MOO_OBJECT_REF_SINK(obj) gtk_object_sink (g_object_ref (obj))
#endif
G_END_DECLS

View File

@ -11,6 +11,7 @@
*/
#include "mooutils/mooutils-treeview.h"
#include "mooutils/mooutils-misc.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/moomarshals.h"
#include <string.h>

View File

@ -499,25 +499,20 @@ moo_window_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
char *tmp;
const char *name = NULL;
MooWindow *window = MOO_WINDOW (object);
switch (prop_id)
{
case PROP_TOOLBAR_UI_NAME:
tmp = window->priv->toolbar_ui_name;
name = g_value_get_string (value);
window->priv->toolbar_ui_name = name ? g_strdup (name) : g_strdup ("");
g_free (tmp);
MOO_ASSIGN_STRING (window->priv->toolbar_ui_name, name ? name : "");
g_object_notify (object, "toolbar-ui-name");
break;
case PROP_MENUBAR_UI_NAME:
tmp = window->priv->menubar_ui_name;
name = g_value_get_string (value);
window->priv->menubar_ui_name = name ? g_strdup (name) : g_strdup ("");
g_free (tmp);
MOO_ASSIGN_STRING (window->priv->menubar_ui_name, name ? name : "");
g_object_notify (object, "menubar-ui-name");
break;