#include "gtk/gtkcheckmenuitem.h"
#include "gtk/gtktearoffmenuitem.h"
#include "gtk/gtkaccellabel.h"
-#include "gdk/gdkprivate.h" /* for gdk_progname */
#include "gdk/gdkkeysyms.h"
#include <string.h>
#include <sys/stat.h>
if (!item_factory_type)
{
- GtkTypeInfo item_factory_info =
+ static const GtkTypeInfo item_factory_info =
{
"GtkItemFactory",
sizeof (GtkItemFactory),
GTK_ACCEL_VISIBLE);
else
{
- GSList *slist;
+ GSList *work;
- slist = gtk_accel_group_entries_from_object (GTK_OBJECT (widget));
- while (slist)
+ work = gtk_accel_group_entries_from_object (GTK_OBJECT (widget));
+ while (work)
{
GtkAccelEntry *ac_entry;
- ac_entry = slist->data;
- slist = slist->next;
+ ac_entry = work->data;
+ work = work->next;
if (ac_entry->accel_flags & GTK_ACCEL_VISIBLE &&
ac_entry->accel_group == ifactory->accel_group &&
ac_entry->signal_id == signal_id)
/* keep a per-action list of the widgets on the factory
*/
- if (callback_action)
+ if (callback)
{
GtkIFActionLink *link;
fname[i + 1] = 0;
item = g_hash_table_lookup (class->item_ht, fname);
+
+ g_free (fname);
+
if (item && item->widgets)
return gtk_item_factory_from_widget (item->widgets->data);
}
static void
-gtk_item_factory_destroy (GtkObject *object)
+gtk_item_factory_destroy (GtkObject *object)
{
GtkItemFactory *ifactory;
GSList *slist;
if (ifactory->widget)
{
- GtkObject *object;
+ GtkObject *dobj;
- object = GTK_OBJECT (ifactory->widget);
+ dobj = GTK_OBJECT (ifactory->widget);
- gtk_object_ref (object);
- gtk_object_sink (object);
- gtk_object_destroy (object);
- gtk_object_unref (object);
+ gtk_object_ref (dobj);
+ gtk_object_sink (dobj);
+ gtk_object_destroy (dobj);
+ gtk_object_unref (dobj);
ifactory->widget = NULL;
}
g_free (ifactory->path);
g_assert (ifactory->widget == NULL);
+ if (ifactory->translate_data && ifactory->translate_notify)
+ ifactory->translate_notify (ifactory->translate_data);
+
parent_class->finalize (object);
}
return;
fputs ("; ", f_out);
- if (gdk_progname)
- fputs (gdk_progname, f_out);
+ if (g_get_prgname ())
+ fputs (g_get_prgname (), f_out);
fputs (" GtkItemFactory rc-file -*- scheme -*-\n", f_out);
fputs ("; this file is an automated menu-path dump\n", f_out);
fputs (";\n", f_out);
}
static gboolean
-gtk_item_factory_parse_path (gchar *str,
- gchar **path,
- gchar **parent_path,
- gchar **item)
+gtk_item_factory_parse_path (GtkItemFactory *ifactory,
+ gchar *str,
+ gchar **path,
+ gchar **parent_path,
+ gchar **item)
{
+ gchar *translation;
gchar *p, *q;
*path = g_strdup (str);
}
*p = 0;
- p = strrchr (str, '/');
+ if (ifactory->translate_func)
+ translation = ifactory->translate_func (str, ifactory->translate_data);
+ else
+ translation = str;
+
+ p = strrchr (translation, '/');
p++;
*item = g_strdup (p);
}
}
- if (!gtk_item_factory_parse_path (entry->path,
+ if (!gtk_item_factory_parse_path (ifactory, entry->path,
&path, &parent_path, &name))
return;
-
+
parent = gtk_item_factory_get_widget (ifactory, parent_path);
if (!parent)
{
{
GtkAccelGroup *menu_group;
+ if (entry->callback)
+ g_warning ("gtk_item_factory_create_item(): Can't specify a callback on a branch: \"%s\"",
+ entry->path);
+
menu_group = gtk_accel_group_new ();
if (type_id == quark_type_last_branch)
gtk_item_factory_add_item (ifactory,
path, entry->accelerator,
- entry->callback, entry->callback_action, callback_data,
+ (type_id == quark_type_branch ||
+ type_id == quark_type_last_branch) ?
+ (GtkItemFactoryCallback) NULL : entry->callback,
+ entry->callback_action, callback_data,
callback_type,
item_type_path,
widget);
+
+ g_free (path);
}
void
parser_func = scanner->value.v_symbol;
- /* check whether this is a GtkItemFactory symbol...
+ /* check whether this is a GtkItemFactory symbol.
*/
if (parser_func == gtk_item_factory_parse_menu_path)
expected_token = parser_func (scanner, class);
close (fd);
}
+
+void
+gtk_item_factory_set_translate_func (GtkItemFactory *ifactory,
+ GtkTranslateFunc func,
+ gpointer data,
+ GtkDestroyNotify notify)
+{
+ g_return_if_fail (ifactory != NULL);
+
+ if (ifactory->translate_data && ifactory->translate_notify)
+ ifactory->translate_notify (ifactory->translate_data);
+
+ ifactory->translate_func = func;
+ ifactory->translate_data = data;
+ ifactory->translate_notify = notify;
+}