~blackskad/gnomeradio/dev-vol-button

« back to all changes in this revision

Viewing changes to src/prefs.c

  • Committer: mfcn
  • Date: 2008-09-13 20:00:09 UTC
  • Revision ID: svn-v3-trunk0:ba97a3d1-ec25-0410-b1c6-e06ad936ea6c:trunk:208
        * src/gui.c (main):
        * src/prefs.c (add_button_clicked_cb), (del_button_clicked_cb),
        (name_cell_edited_cb):
        Don't update menus while main-view and tray-icon are not visible yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
extern int mom_ps;
31
31
extern gnomeradio_settings settings;
32
32
 
 
33
extern gboolean main_visible;
 
34
 
33
35
static GtkWidget *device_entry;
34
36
static GtkWidget *mixer_combo;
35
37
static GtkWidget *mute_on_exit_cb;
310
312
        v_scb = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(list_view));
311
313
        gtk_adjustment_set_value(v_scb, v_scb->upper);
312
314
        
313
 
        gtk_combo_box_append_text(GTK_COMBO_BOX(preset_combo), ps->title);
314
 
        mom_ps = g_list_length(settings.presets) - 1;
315
 
        preset_combo_set_item(mom_ps);
 
315
        if (main_visible) {
 
316
                gtk_combo_box_append_text(GTK_COMBO_BOX(preset_combo), ps->title);
 
317
                mom_ps = g_list_length(settings.presets) - 1;
 
318
                preset_combo_set_item(mom_ps);
316
319
 
317
 
        menuitems = GTK_MENU_SHELL(tray_menu)->children;
318
 
        menuitem = gtk_menu_item_new_with_label(ps->title); 
319
 
                
320
 
        gtk_menu_shell_insert(GTK_MENU_SHELL(tray_menu), menuitem, mom_ps);             
321
 
        g_signal_connect(G_OBJECT(menuitem), "activate", (GCallback)preset_menuitem_activate_cb, (gpointer)mom_ps);
322
 
        gtk_widget_show(menuitem);
 
320
                menuitems = GTK_MENU_SHELL(tray_menu)->children;
 
321
                menuitem = gtk_menu_item_new_with_label(ps->title); 
 
322
                        
 
323
                gtk_menu_shell_insert(GTK_MENU_SHELL(tray_menu), menuitem, mom_ps);             
 
324
                g_signal_connect(G_OBJECT(menuitem), "activate", (GCallback)preset_menuitem_activate_cb, (gpointer)mom_ps);
 
325
                gtk_widget_show(menuitem);
 
326
        }
323
327
 
324
328
        buffer = g_strdup_printf("%d", g_list_length(settings.presets) - 1);
325
329
        path = gtk_tree_path_new_from_string(buffer);
356
360
        gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path);
357
361
        gtk_list_store_remove(list_store, &iter);
358
362
 
359
 
        gtk_combo_box_remove_text(GTK_COMBO_BOX(preset_combo), *row + 1);
360
 
        if (--mom_ps < 0) mom_ps = 0;
361
 
        if (!g_list_length(settings.presets)) mom_ps = -1;
362
 
        preset_combo_set_item(mom_ps);
 
363
        if (main_visible) {
 
364
                gtk_combo_box_remove_text(GTK_COMBO_BOX(preset_combo), *row + 1);
 
365
                if (--mom_ps < 0) mom_ps = 0;
 
366
                if (!g_list_length(settings.presets)) mom_ps = -1;
 
367
                preset_combo_set_item(mom_ps);
363
368
 
364
 
        menuitems = GTK_MENU_SHELL(tray_menu)->children;
365
 
        g_assert(*row < g_list_length(menuitems));
366
 
        menuitem = g_list_nth_data(menuitems, *row);
367
 
        gtk_widget_destroy(menuitem);
 
369
                menuitems = GTK_MENU_SHELL(tray_menu)->children;
 
370
                g_assert(*row < g_list_length(menuitems));
 
371
                menuitem = g_list_nth_data(menuitems, *row);
 
372
                gtk_widget_destroy(menuitem);
 
373
        }
368
374
        
369
375
        gtk_tree_path_prev(path);
370
376
        gtk_tree_view_set_cursor(GTK_TREE_VIEW(list_view), path, NULL, FALSE);
420
426
        if (ps->title) g_free(ps->title);
421
427
        ps->title = g_strdup(new_val);
422
428
 
423
 
        gtk_combo_box_remove_text(GTK_COMBO_BOX(preset_combo), *row + 1);
424
 
        gtk_combo_box_insert_text(GTK_COMBO_BOX(preset_combo), *row + 1, ps->title);
425
 
        mom_ps = *row;
426
 
        preset_combo_set_item(mom_ps);
427
 
        
428
 
        menuitems = GTK_MENU_SHELL(tray_menu)->children;
429
 
        g_assert(mom_ps < g_list_length(menuitems));
430
 
        menuitem = g_list_nth_data(menuitems, mom_ps);
431
 
        gtk_widget_destroy(menuitem);
432
 
        menuitem = gtk_menu_item_new_with_label(ps->title); 
433
 
                
434
 
        gtk_menu_shell_insert(GTK_MENU_SHELL(tray_menu), menuitem, *row);               
435
 
        g_signal_connect(G_OBJECT(menuitem), "activate", (GCallback)preset_menuitem_activate_cb, (gpointer)mom_ps);
436
 
        gtk_widget_show(menuitem);
 
429
        if (main_visible) {
 
430
                gtk_combo_box_remove_text(GTK_COMBO_BOX(preset_combo), *row + 1);
 
431
                gtk_combo_box_insert_text(GTK_COMBO_BOX(preset_combo), *row + 1, ps->title);
 
432
                mom_ps = *row;
 
433
                preset_combo_set_item(mom_ps);
 
434
 
 
435
                menuitems = GTK_MENU_SHELL(tray_menu)->children;
 
436
                g_assert(mom_ps < g_list_length(menuitems));
 
437
                menuitem = g_list_nth_data(menuitems, mom_ps);
 
438
                gtk_widget_destroy(menuitem);
 
439
                menuitem = gtk_menu_item_new_with_label(ps->title); 
 
440
                        
 
441
                gtk_menu_shell_insert(GTK_MENU_SHELL(tray_menu), menuitem, *row);               
 
442
                g_signal_connect(G_OBJECT(menuitem), "activate", (GCallback)preset_menuitem_activate_cb, (gpointer)mom_ps);
 
443
                gtk_widget_show(menuitem);
 
444
        }
437
445
        
438
446
        gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path);
439
447
        gtk_list_store_set(GTK_LIST_STORE(list_store), &iter, 0, new_val, -1);