Commit 8c92ecec authored by John Sullivan's avatar John Sullivan

Added nautilus_gtk_signal_connect_free_data, and deployed it.

parent 3e6324f1
2000-01-11 John Sullivan <sullivan@eazel.com>
* libnautilus/nautilus-gtk-extensions.h:
* libnautilus/nautilus-gtk-extensions.c:
(nautilus_gtk_signal_connect_free_data): New function,
convenience wrapper for gtk_signal_connect_full where
the destroy-function is g_free() and the other extra
values are the defaults.
* src/ntl-window-msgs.c: (nautilus_window_load_content_view_menu):
Use nautilus_gtk_signal_connect_free_data to avoid leaking the menu item's
signal's copy of the iid string.
2000-01-11 John Sullivan <sullivan@eazel.com>
Content view menu now works (can switch between List and Icon views).
......
......@@ -28,6 +28,32 @@
#include <gnome.h>
/**
* nautilus_gtk_signal_connect_free_data:
*
* Attach a function pointer and user data to a signal, and free
* the user data when the signal is disconnected.
* @object: the object which emits the signal. For example, a button in the button press signal.
* @name: the name of the signal.
* @func: function pointer to attach to the signal.
* @data: the user data associated with the function. g_free() will be called on
* this user data when the signal is disconnected.
**/
guint nautilus_gtk_signal_connect_free_data (GtkObject *object,
const gchar *name,
GtkSignalFunc func,
gpointer data)
{
return gtk_signal_connect_full (object,
name,
func,
NULL, /* marshal */
data,
(GtkDestroyNotify)g_free,
FALSE, /* is this an object signal? */
FALSE); /* invoke func after signal? */
}
/**
* nautilus_gtk_window_hide_retain_geometry:
*
......
......@@ -29,6 +29,12 @@
#include <gtk/gtkwindow.h>
guint nautilus_gtk_signal_connect_free_data (GtkObject *object,
const gchar *name,
GtkSignalFunc func,
gpointer data);
void nautilus_gtk_window_present (GtkWindow *window);
#endif /* NAUTILUS_GTK_EXTENSIONS_H */
......@@ -28,6 +28,32 @@
#include <gnome.h>
/**
* nautilus_gtk_signal_connect_free_data:
*
* Attach a function pointer and user data to a signal, and free
* the user data when the signal is disconnected.
* @object: the object which emits the signal. For example, a button in the button press signal.
* @name: the name of the signal.
* @func: function pointer to attach to the signal.
* @data: the user data associated with the function. g_free() will be called on
* this user data when the signal is disconnected.
**/
guint nautilus_gtk_signal_connect_free_data (GtkObject *object,
const gchar *name,
GtkSignalFunc func,
gpointer data)
{
return gtk_signal_connect_full (object,
name,
func,
NULL, /* marshal */
data,
(GtkDestroyNotify)g_free,
FALSE, /* is this an object signal? */
FALSE); /* invoke func after signal? */
}
/**
* nautilus_gtk_window_hide_retain_geometry:
*
......
......@@ -29,6 +29,12 @@
#include <gtk/gtkwindow.h>
guint nautilus_gtk_signal_connect_free_data (GtkObject *object,
const gchar *name,
GtkSignalFunc func,
gpointer data);
void nautilus_gtk_window_present (GtkWindow *window);
#endif /* NAUTILUS_GTK_EXTENSIONS_H */
......@@ -28,6 +28,32 @@
#include <gnome.h>
/**
* nautilus_gtk_signal_connect_free_data:
*
* Attach a function pointer and user data to a signal, and free
* the user data when the signal is disconnected.
* @object: the object which emits the signal. For example, a button in the button press signal.
* @name: the name of the signal.
* @func: function pointer to attach to the signal.
* @data: the user data associated with the function. g_free() will be called on
* this user data when the signal is disconnected.
**/
guint nautilus_gtk_signal_connect_free_data (GtkObject *object,
const gchar *name,
GtkSignalFunc func,
gpointer data)
{
return gtk_signal_connect_full (object,
name,
func,
NULL, /* marshal */
data,
(GtkDestroyNotify)g_free,
FALSE, /* is this an object signal? */
FALSE); /* invoke func after signal? */
}
/**
* nautilus_gtk_window_hide_retain_geometry:
*
......
......@@ -29,6 +29,12 @@
#include <gtk/gtkwindow.h>
guint nautilus_gtk_signal_connect_free_data (GtkObject *object,
const gchar *name,
GtkSignalFunc func,
gpointer data);
void nautilus_gtk_window_present (GtkWindow *window);
#endif /* NAUTILUS_GTK_EXTENSIONS_H */
......@@ -28,6 +28,7 @@
#include "ntl-window-private.h"
#include "ntl-index-panel.h"
#include "explorer-location-bar.h"
#include <libnautilus/nautilus-gtk-extensions.h>
struct _NautilusWindowLoadInfo {
/* These are the three states of loading in process.
......@@ -274,11 +275,14 @@ nautilus_window_load_content_view_menu (NautilusWindow *window, NautilusNavigati
{
default_view_index = index;
}
/* FIXME: copy of identifier->iid doesn't get freed */
gtk_signal_connect (GTK_OBJECT (menu_item),
"activate",
GTK_SIGNAL_FUNC (view_menu_switch_views_cb),
g_strdup (identifier->iid));
/* Free copy of string when signal disconnected. */
nautilus_gtk_signal_connect_free_data (
GTK_OBJECT (menu_item),
"activate",
GTK_SIGNAL_FUNC (view_menu_switch_views_cb),
g_strdup (identifier->iid));
/* Store reference to window in item; no need to free this. */
gtk_object_set_user_data (GTK_OBJECT (menu_item), window);
gtk_menu_append (GTK_MENU (new_menu), menu_item);
gtk_widget_show (menu_item);
......
......@@ -28,6 +28,7 @@
#include "ntl-window-private.h"
#include "ntl-index-panel.h"
#include "explorer-location-bar.h"
#include <libnautilus/nautilus-gtk-extensions.h>
struct _NautilusWindowLoadInfo {
/* These are the three states of loading in process.
......@@ -274,11 +275,14 @@ nautilus_window_load_content_view_menu (NautilusWindow *window, NautilusNavigati
{
default_view_index = index;
}
/* FIXME: copy of identifier->iid doesn't get freed */
gtk_signal_connect (GTK_OBJECT (menu_item),
"activate",
GTK_SIGNAL_FUNC (view_menu_switch_views_cb),
g_strdup (identifier->iid));
/* Free copy of string when signal disconnected. */
nautilus_gtk_signal_connect_free_data (
GTK_OBJECT (menu_item),
"activate",
GTK_SIGNAL_FUNC (view_menu_switch_views_cb),
g_strdup (identifier->iid));
/* Store reference to window in item; no need to free this. */
gtk_object_set_user_data (GTK_OBJECT (menu_item), window);
gtk_menu_append (GTK_MENU (new_menu), menu_item);
gtk_widget_show (menu_item);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment