예제 #1
0
파일: main.c 프로젝트: jubalh/pnmixer
/**
 * Opens the specified mixer application which can be triggered either
 * by clicking the 'Volume Control' GtkImageMenuItem in the context
 * menu, the GtkButton 'Mixer' in the left-click popup_window or
 * by middle-click if the Middle Click Action in the preferences
 * is set to 'Volume Control'.
 */
void on_mixer(void) {
  gchar* cmd = get_vol_command();
  if (cmd) {
    run_command(cmd);
    g_free(cmd);
  }
  else
    report_error(_("\nNo mixer application was found on your system.\n\nPlease open preferences and set the command you want to run for volume control."));
}
예제 #2
0
파일: prefs.c 프로젝트: Cw1X/pnmixer
GtkWidget* create_prefs_window (void) {
  GtkBuilder *builder;
  GError     *error = NULL;

  GdkColor   vol_meter_color_button_color;
  gint       *vol_meter_clrs;
  gchar      *vol_cmd,*uifile,*custcmd;

  PrefsData  *prefs_data;

  uifile = get_ui_file("prefs.xml");
  if (!uifile) {
    report_error(_("Can't find preferences user interface file.  Please insure PNMixer is installed correctly.\n"));
    return NULL;
  }

  builder = gtk_builder_new();
  if (!gtk_builder_add_from_file( builder, uifile, &error)) {
    g_warning("%s",error->message);
    report_error(error->message);
    g_error_free(error);
    g_free(uifile);
    g_object_unref (G_OBJECT (builder));
    return NULL;
  }
  
  g_free(uifile);

  prefs_data = g_slice_new(PrefsData);
#define GO(name) prefs_data->name = GTK_WIDGET(gtk_builder_get_object(builder,#name))
  GO(prefs_window);
  GO(card_combo);
  GO(chan_combo);
  GO(vol_pos_label);
  GO(vol_pos_combo);
  GO(vol_meter_pos_label);
  GO(vol_meter_pos_spin);
  GO(vol_meter_color_label);
  GO(vol_meter_color_button);
  GO(custom_label);
  GO(custom_entry);
  GO(vol_text_check);
  GO(draw_vol_check);
  GO(icon_theme_combo);
  GO(vol_control_entry);
  GO(scroll_step_spin);
  GO(middle_click_combo);
  GO(enable_hotkeys_check);
  GO(hotkey_spin);
  GO(hotkey_dialog);
  GO(hotkey_key_label);
  GO(mute_hotkey_label);
  GO(up_hotkey_label);
  GO(down_hotkey_label);
#ifdef HAVE_LIBN
  GO(enable_noti_check);
  GO(hotkey_noti_check);
  GO(mouse_noti_check);
  GO(popup_noti_check);
  GO(external_noti_check);
#endif
#undef GO

  // vol text display
  gtk_toggle_button_set_active
    (GTK_TOGGLE_BUTTON(prefs_data->vol_text_check),
     g_key_file_get_boolean_with_default(keyFile,"PNMixer","DisplayTextVolume",FALSE));
  gtk_combo_box_set_active
    (GTK_COMBO_BOX (prefs_data->vol_pos_combo),
     g_key_file_get_integer_with_default(keyFile,"PNMixer","TextVolumePosition",0));

  // volume meter
  gtk_toggle_button_set_active
    (GTK_TOGGLE_BUTTON(prefs_data->draw_vol_check),
     g_key_file_get_boolean_with_default(keyFile,"PNMixer","DrawVolMeter",FALSE));
  gtk_adjustment_set_upper
    (GTK_ADJUSTMENT(gtk_builder_get_object(builder,"vol_meter_pos_adjustment")),
     tray_icon_size()-10);
  gtk_spin_button_set_value
    (GTK_SPIN_BUTTON(prefs_data->vol_meter_pos_spin),
     g_key_file_get_integer_with_default(keyFile,"PNMixer","VolMeterPos",0));

  // load available icon themes into icon theme combo box.  also sets active
  load_icon_themes(prefs_data->icon_theme_combo,
		   GTK_LIST_STORE(gtk_builder_get_object(builder,"icon_theme_liststore")));


  // set color button color
  vol_meter_clrs = get_vol_meter_colors();
  vol_meter_color_button_color.red = vol_meter_clrs[0];
  vol_meter_color_button_color.green = vol_meter_clrs[1];
  vol_meter_color_button_color.blue = vol_meter_clrs[2];
  gtk_color_button_set_color(GTK_COLOR_BUTTON(prefs_data->vol_meter_color_button),
			     &vol_meter_color_button_color);
  g_free(vol_meter_clrs);

  // fill in card/channel combo boxes
  fill_card_combo(prefs_data->card_combo,prefs_data->chan_combo);


  // volume command
  vol_cmd = get_vol_command();
  if (vol_cmd) {
    gtk_entry_set_text(GTK_ENTRY(prefs_data->vol_control_entry), vol_cmd);
    g_free(vol_cmd);
  }

  // mouse scroll step
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(prefs_data->scroll_step_spin),
			    g_key_file_get_integer_with_default(keyFile,"PNMixer","MouseScrollStep",1));

  //  middle click
  gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_data->middle_click_combo),
			   g_key_file_get_integer_with_default(keyFile,"PNMixer","MiddleClickAction",0));

  // custom command
  gtk_entry_set_invisible_char(GTK_ENTRY(prefs_data->custom_entry), 8226);

  custcmd =  g_key_file_get_string(keyFile,"PNMixer","CustomCommand",NULL);
  if (custcmd) {
    gtk_entry_set_text(GTK_ENTRY(prefs_data->custom_entry),custcmd);
    g_free(custcmd);
  }

  on_vol_text_toggle(GTK_TOGGLE_BUTTON(prefs_data->vol_text_check),
		     prefs_data);
  on_draw_vol_toggle(GTK_TOGGLE_BUTTON(prefs_data->draw_vol_check),
		     prefs_data);
  on_middle_changed(GTK_COMBO_BOX(prefs_data->middle_click_combo),
		    prefs_data);

  // hotkeys
  gtk_toggle_button_set_active
    (GTK_TOGGLE_BUTTON(prefs_data->enable_hotkeys_check),
     g_key_file_get_boolean_with_default(keyFile,"PNMixer","EnableHotKeys",FALSE));
  
  // hotkey step
  gtk_spin_button_set_value(GTK_SPIN_BUTTON(prefs_data->hotkey_spin),
			    g_key_file_get_integer_with_default(keyFile,"PNMixer","HotkeyVolumeStep",1));


  if (g_key_file_has_key(keyFile,"PNMixer","VolMuteKey",NULL)) 
    set_label_for_keycode(prefs_data->mute_hotkey_label,
			  g_key_file_get_integer(keyFile,"PNMixer", "VolMuteKey", NULL),
			  g_key_file_get_integer_with_default(keyFile,"PNMixer", "VolMuteMods", 0));

  if (g_key_file_has_key(keyFile,"PNMixer","VolUpKey",NULL)) 
    set_label_for_keycode(prefs_data->up_hotkey_label,
			  g_key_file_get_integer(keyFile,"PNMixer", "VolUpKey", NULL),
			  g_key_file_get_integer_with_default(keyFile,"PNMixer", "VolUpMods", 0));
  if (g_key_file_has_key(keyFile,"PNMixer","VolDownKey",NULL)) 
    set_label_for_keycode(prefs_data->down_hotkey_label,
			  g_key_file_get_integer(keyFile,"PNMixer", "VolDownKey", NULL),
			  g_key_file_get_integer_with_default(keyFile,"PNMixer", "VolDownMods", 0));


  gtk_notebook_append_page(GTK_NOTEBOOK(gtk_builder_get_object(builder,"notebook1")),
#ifdef HAVE_LIBN
			   GTK_WIDGET(gtk_builder_get_object(builder,"notification_vbox")),			   
#else
			   GTK_WIDGET(gtk_builder_get_object(builder,"no_notification_label")),
#endif
			   gtk_label_new("Notifications"));

#ifdef HAVE_LIBN
  // notification checkboxes
  set_notifications_booleans();
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_data->enable_noti_check),enable_noti);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_data->hotkey_noti_check),hotkey_noti);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_data->mouse_noti_check),mouse_noti);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_data->popup_noti_check),popup_noti);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_data->external_noti_check),external_noti);
  on_notification_toggle(GTK_TOGGLE_BUTTON(prefs_data->enable_noti_check),prefs_data);
#endif

  gtk_builder_connect_signals(builder, prefs_data);
  g_object_unref (G_OBJECT (builder));

  return prefs_data->prefs_window;
}