~ubuntu-branches/ubuntu/vivid/indicator-appmenu/vivid-proposed

« back to all changes in this revision

Viewing changes to src/window-menu-model.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Charles Kerr, Sebastien Bacher, Lars Uebernickel, Ubuntu daily release
  • Date: 2013-11-25 03:55:37 UTC
  • mfrom: (1.1.47)
  • Revision ID: package-import@ubuntu.com-20131125035537-rm8pa89m9ii3zs49
Tags: 13.01.0+14.04.20131125-0ubuntu1
[ Charles Kerr ]
* If we can't get the bus, exit instead of stacking g_bus_own_name()
  calls on top of each other, leaking GSources. (LP: #1244250)

[ Sebastien Bacher ]
* Build with -Wno-error=deprecated-declarations.

[ Lars Uebernickel ]
* Call gtk_widget_destroy() to break potential ref cycles Calling
  g_object_unref() is not enough for many of gtk's widgets.
* window-menu-model: disconnect entry signal handlers by func instead
  of id entry_object_free disconnected signal handlers by id. This
  throws warnings when entry_object_free is called when disposing an
  object, because signals are already disconnected at that point. This
  patch uses g_signal_handlers_disconnect_by_func(), which works both
  when the entry is alive and being disposed.
* WindowMenuModel: insert action groups on the toplevel menus
  Inserting them on the menu items was a workaround for the long-fixed
  cloaking-bug in libindicator. It's not supported in gtk 3.10
  anymore, because the menu tracker in gtk doesn't allow action groups
  on menu items. That's for good reasons: it's more efficient and
  consumers of that api should not modify the created menu hierarchy.

[ Ubuntu daily release ]
* Automatic snapshot from revision 251

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
        }
133
133
 
134
134
        g_clear_object(&menu->priv->win_menu_model);
135
 
        g_clear_object(&menu->priv->win_menu);
 
135
 
 
136
        if (menu->priv->win_menu) {
 
137
                gtk_widget_destroy (GTK_WIDGET (menu->priv->win_menu));
 
138
                g_object_unref (menu->priv->win_menu);
 
139
                menu->priv->win_menu = NULL;
 
140
        }
136
141
 
137
142
        g_clear_object(&menu->priv->unity_actions);
138
143
        g_clear_object(&menu->priv->win_actions);
258
263
        IndicatorObjectEntry entry;
259
264
 
260
265
        GtkMenuItem * gmi;
261
 
 
262
 
        gulong label_sig;
263
 
        gulong sensitive_sig;
264
 
        gulong visible_sig;
265
266
};
266
267
 
267
 
/* Destroy and unref the items of the object entry */
268
 
static void
269
 
entry_object_free (gpointer inentry)
270
 
{
271
 
        WindowMenuEntry * entry = (WindowMenuEntry *)inentry;
272
 
 
273
 
        if (entry->label_sig != 0) {
274
 
                g_signal_handler_disconnect(entry->gmi, entry->label_sig);
275
 
        }
276
 
 
277
 
        if (entry->sensitive_sig != 0) {
278
 
                g_signal_handler_disconnect(entry->gmi, entry->sensitive_sig);
279
 
        }
280
 
 
281
 
        if (entry->visible_sig != 0) {
282
 
                g_signal_handler_disconnect(entry->gmi, entry->visible_sig);
283
 
        }
284
 
 
285
 
        g_clear_object(&entry->entry.label);
286
 
        g_clear_object(&entry->entry.image);
287
 
        g_clear_object(&entry->entry.menu);
288
 
 
289
 
        g_free(entry);
290
 
        return;
291
 
}
292
 
 
293
268
/* Sync the menu label changing to the label object */
294
269
static void
295
270
entry_label_notify (GObject * obj, GParamSpec * pspec, gpointer user_data)
349
324
        return;
350
325
}
351
326
 
 
327
/* Destroy and unref the items of the object entry */
 
328
static void
 
329
entry_object_free (gpointer inentry)
 
330
{
 
331
        WindowMenuEntry * entry = (WindowMenuEntry *)inentry;
 
332
 
 
333
        g_signal_handlers_disconnect_by_func (entry->gmi, entry_label_notify, entry);
 
334
        g_signal_handlers_disconnect_by_func (entry->gmi, entry_sensitive_notify, entry);
 
335
        g_signal_handlers_disconnect_by_func (entry->gmi, entry_visible_notify, entry);
 
336
 
 
337
        g_clear_object(&entry->entry.label);
 
338
        g_clear_object(&entry->entry.image);
 
339
        g_clear_object(&entry->entry.menu);
 
340
 
 
341
        g_free(entry);
 
342
        return;
 
343
}
 
344
 
352
345
/* Put an entry on a menu item */
353
346
static void
354
347
entry_on_menuitem (WindowMenuModel * menu, GtkMenuItem * gmi)
355
348
{
356
349
        WindowMenuEntry * entry = g_new0(WindowMenuEntry, 1);
357
350
 
358
 
        if (menu->priv->app_actions) {
359
 
                gtk_widget_insert_action_group(GTK_WIDGET(gmi), ACTION_MUX_PREFIX_APP, menu->priv->app_actions);
360
 
        }
361
 
        if (menu->priv->win_actions) {
362
 
                gtk_widget_insert_action_group(GTK_WIDGET(gmi), ACTION_MUX_PREFIX_WIN, menu->priv->win_actions);
363
 
        }
364
 
        if (menu->priv->unity_actions) {
365
 
                gtk_widget_insert_action_group(GTK_WIDGET(gmi), ACTION_MUX_PREFIX_UNITY, menu->priv->unity_actions);
366
 
        }
367
 
 
368
351
        entry->gmi = gmi;
369
352
 
370
353
        entry->entry.label = mi_find_label(GTK_WIDGET(gmi));
380
363
 
381
364
                entry->entry.label = GTK_LABEL(gtk_label_new(label));
382
365
                gtk_widget_show(GTK_WIDGET(entry->entry.label));
383
 
                entry->label_sig = g_signal_connect(G_OBJECT(gmi), "notify::label", G_CALLBACK(entry_label_notify), entry->entry.label);
 
366
                g_signal_connect(G_OBJECT(gmi), "notify::label", G_CALLBACK(entry_label_notify), entry);
384
367
        }
385
368
 
386
369
        if (entry->entry.label != NULL) {
395
378
                g_object_ref_sink(entry->entry.menu);
396
379
        }
397
380
 
398
 
        entry->sensitive_sig = g_signal_connect(G_OBJECT(gmi), "notify::sensitive", G_CALLBACK(entry_sensitive_notify), entry);
399
 
        entry->visible_sig = g_signal_connect(G_OBJECT(gmi), "notify::visible", G_CALLBACK(entry_visible_notify), entry);
 
381
        g_signal_connect(G_OBJECT(gmi), "notify::sensitive", G_CALLBACK(entry_sensitive_notify), entry);
 
382
        g_signal_connect(G_OBJECT(gmi), "notify::visible", G_CALLBACK(entry_visible_notify), entry);
400
383
 
401
384
        g_object_set_data_full(G_OBJECT(gmi), ENTRY_DATA, entry, entry_object_free);
402
385
 
440
423
        g_assert(menu->priv->win_menu != NULL);
441
424
        g_object_ref_sink(menu->priv->win_menu);
442
425
 
 
426
        if (menu->priv->app_actions)
 
427
                gtk_widget_insert_action_group(GTK_WIDGET(menu->priv->win_menu), ACTION_MUX_PREFIX_APP, menu->priv->app_actions);
 
428
        if (menu->priv->win_actions)
 
429
                gtk_widget_insert_action_group(GTK_WIDGET(menu->priv->win_menu), ACTION_MUX_PREFIX_WIN, menu->priv->win_actions);
 
430
        if (menu->priv->unity_actions)
 
431
                gtk_widget_insert_action_group(GTK_WIDGET(menu->priv->win_menu), ACTION_MUX_PREFIX_UNITY, menu->priv->unity_actions);
 
432
 
443
433
        menu->priv->win_menu_insert = g_signal_connect(G_OBJECT (menu->priv->win_menu),
444
434
                "insert",
445
435
                G_CALLBACK (item_inserted_cb),