~charlesk/appmenu-gtk/lp-788640

« back to all changes in this revision

Viewing changes to src/bridge.c

  • Committer: Cody Russell
  • Date: 2010-05-24 19:26:53 UTC
  • Revision ID: crussell@canonical.com-20100524192653-hn5psdivokqe1vvd
Various cleanups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
210
210
 
211
211
static void
212
212
app_menu_bridge_insert (GtkMenuProxy *proxy,
213
 
                        GtkWidget    *shell,
 
213
                        GtkWidget    *parent,
214
214
                        GtkWidget    *child,
215
215
                        guint         position)
216
216
{
217
217
  AppMenuBridge    *bridge;
218
218
  DbusmenuMenuitem *item;
219
 
  GtkWidget        *parent;
220
219
  GtkWidget        *submenu;
221
220
  DbusmenuMenuitem *parent_item = NULL;
222
221
 
226
225
  if (!gtk_widget_get_visible (child))
227
226
    return;
228
227
 
229
 
  //if (!is_in_menubar (child))
230
 
  //  return;
231
228
 
232
229
  bridge = APP_MENU_BRIDGE (proxy);
233
230
 
234
 
  if (GTK_IS_MENU_BAR (shell))
235
 
    {
236
 
      if (!g_hash_table_lookup (bridge->priv->items, shell))
237
 
        {
238
 
          g_print ("inserting shell %p %s\n", shell, G_OBJECT_TYPE_NAME (shell));
239
 
          g_hash_table_insert (bridge->priv->items, shell, bridge->priv->root);
240
 
        }
241
 
 
242
 
      g_print ("   ** child is a %s\n", G_OBJECT_TYPE_NAME (child));
 
231
  if (GTK_IS_MENU_BAR (parent))
 
232
    {
 
233
      if (!g_hash_table_lookup (bridge->priv->items, parent))
 
234
        {
 
235
          g_hash_table_insert (bridge->priv->items, parent, bridge->priv->root);
 
236
        }
 
237
 
 
238
      parent_item = bridge->priv->root;
 
239
    }
 
240
  else if (GTK_IS_MENU (parent))
 
241
    {
 
242
      GtkWidget *attached_to;
 
243
 
 
244
      g_object_get (parent,
 
245
                    "attach-widget", &attached_to,
 
246
                    NULL);
 
247
 
 
248
      if (attached_to)
 
249
        {
 
250
          parent_item = g_hash_table_lookup (bridge->priv->items, attached_to);
 
251
        }
243
252
    }
244
253
 
245
254
  if (GTK_IS_MENU_ITEM (child))
246
255
    {
247
 
      parent = shell;
248
 
 
249
256
      item = dbusmenu_menuitem_new ();
250
257
      g_hash_table_insert (bridge->priv->items, child, item); // move to end?
251
258
 
281
288
          g_hash_table_insert (bridge->priv->items, submenu, item);
282
289
        }
283
290
 
284
 
      //g_print ("parent %p %s\n", parent, parent != NULL ? G_OBJECT_TYPE_NAME (parent) : "NULL");
285
 
 
286
 
      g_print ("child %p %s\n", child, G_OBJECT_TYPE_NAME (child));
287
 
 
288
291
      if (parent == NULL)
289
292
        {
290
293
          parent_item = bridge->priv->root;
291
294
        }
292
295
 
 
296
      /*
293
297
      if (GTK_IS_MENU_BAR (parent))
294
298
        {
295
 
          g_print ("%s, visibility %d\n",
296
 
                   get_menu_label_text (child),
297
 
                   gtk_widget_get_visible (child));
298
 
 
299
299
          parent_item = bridge->priv->root;
300
300
        }
301
301
      else if (GTK_IS_MENU (parent))
309
309
          if (attached_to)
310
310
            {
311
311
              parent_item = g_hash_table_lookup (bridge->priv->items, attached_to);
312
 
 
313
 
              g_print ("%s -> %s   (parent_item == %p\n",
314
 
                       get_menu_label_text (attached_to),
315
 
                       get_menu_label_text (child),
316
 
                       parent_item);
317
312
            }
318
313
        }
 
314
      */
319
315
 
320
316
      if (parent_item)
321
317
        {
322
 
          g_print ("child append\n");
323
 
          if (GTK_IS_MENU_BAR (shell))
 
318
          /* XXX - not sure about this. :)   */
 
319
          if (GTK_IS_MENU_BAR (parent))
324
320
            dbusmenu_menuitem_child_append (parent_item, item);
325
321
          else
326
322
            dbusmenu_menuitem_child_prepend (parent_item, item);
327
323
        }
328
 
 
329
 
      /*
330
 
      if (parent_item)
331
 
        {
332
 
          dbusmenu_menuitem_child_append (parent_item, item);
333
 
        }
334
 
      else
335
 
        {
336
 
          if (GTK_IS_MENU (parent))
337
 
            {
338
 
              GtkWidget *foo;
339
 
 
340
 
              g_object_get (GTK_MENU (parent),
341
 
                            "attach-widget", &foo,
342
 
                            NULL);
343
 
 
344
 
              g_print ("Parent not found, belongs to %s (%s at %p)\n",
345
 
                       foo ? get_menu_label_text (foo) : "(null)",
346
 
                       foo ? G_OBJECT_TYPE_NAME (foo) : "(null)",
347
 
                       foo);
348
 
 
349
 
              parent_item = g_hash_table_lookup (bridge->priv->items,
350
 
                                                 foo);
351
 
              dbusmenu_menuitem_child_append (parent_item, item);
352
 
            }
353
 
          else
354
 
            {
355
 
              g_print ("Parent not found: %s at %p\n",
356
 
                       G_OBJECT_TYPE_NAME (parent),
357
 
                       parent);
358
 
            }
359
 
        }
360
 
      */
361
324
    }
362
325
}
363
326