示例#1
0
文件: volume.c 项目: TKr/lxde-lxpanel
static void on_mouse_scroll (GtkWidget* widget, GdkEventScroll* evt, volume_t *vol)
{
	if ( ! vol->dlg ) {

		vol->dlg = create_volume_window();
		g_signal_connect( vol->dlg, "delete-event",
				G_CALLBACK(on_volume_focus), widget );

	}
	else {
		if (! vol_spin) return;
		GtkAdjustment *vol_adjustment =
			gtk_spin_button_get_adjustment (vol_spin);
		if (! vol_adjustment) return;

		curr_volume = gtk_adjustment_get_value (vol_adjustment);

		if (evt->direction == GDK_SCROLL_UP) {
			curr_volume += 2;
		}
		else /*if (evt->direction == GDK_SCROLL_DOWN)*/ {
			curr_volume -= 2;
		}
		update_icon(widget, vol);
		gtk_adjustment_set_value (vol_adjustment, curr_volume);
		gtk_spin_button_set_adjustment(vol_spin, vol_adjustment);
		skip_botton1_event = TRUE;
	}
}
示例#2
0
void
vol_create_gui(volume_t * vol) {

	GtkWidget * label;
	GtkWidget * vbox;
	GtkWidget * hbox;

	++vol_slot_count;

	if (vol_window == NULL) {
		create_volume_window();
	}

	vbox = gtk_bin_get_child(GTK_BIN(vol_window));

	vol->slot = gtk_table_new(4, 3, FALSE);
        gtk_box_pack_start(GTK_BOX(vbox), vol->slot, FALSE, FALSE, 0);

	gtk_table_attach(GTK_TABLE(vol->slot), gtk_hseparator_new(), 0, 3, 0, 1,
			 GTK_FILL, GTK_FILL, 5, 5);

        hbox = gtk_hbox_new(FALSE, 0);
	label = gtk_label_new(_("File:"));
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_table_attach(GTK_TABLE(vol->slot), hbox, 0, 1, 1, 2,
			 GTK_FILL, GTK_FILL, 5, 5);

        vol->file_entry = gtk_entry_new();
        gtk_editable_set_editable(GTK_EDITABLE(vol->file_entry), FALSE);
	gtk_table_attach(GTK_TABLE(vol->slot), vol->file_entry, 1, 2, 1, 2,
			 GTK_EXPAND | GTK_FILL, GTK_FILL, 5, 5);

	vol->pause_button = gtk_button_new_with_label(_("Pause"));
	g_signal_connect(vol->pause_button, "clicked", G_CALLBACK(vol_pause_event), vol);
	gtk_table_attach(GTK_TABLE(vol->slot), vol->pause_button, 2, 3, 1, 2,
			 GTK_FILL, GTK_FILL, 5, 5);

        hbox = gtk_hbox_new(FALSE, 0);
	label = gtk_label_new(_("Progress:"));
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_table_attach(GTK_TABLE(vol->slot), hbox, 0, 1, 2, 3,
			 GTK_FILL, GTK_FILL, 5, 5);

	vol->progress = gtk_progress_bar_new();
	gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(vol->progress), 0.0f);
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(vol->progress), "0.0%");
	gtk_table_attach(GTK_TABLE(vol->slot), vol->progress, 1, 2, 2, 3,
			 GTK_EXPAND | GTK_FILL, GTK_FILL, 5, 5);

	vol->cancel_button = gui_stock_label_button (_("Abort"), GTK_STOCK_CANCEL); 
	g_signal_connect(vol->cancel_button, "clicked", G_CALLBACK(vol_cancel_event), vol);
	gtk_table_attach(GTK_TABLE(vol->slot), vol->cancel_button, 2, 3, 2, 3,
			 GTK_FILL, GTK_FILL, 5, 5);

	gtk_table_attach(GTK_TABLE(vol->slot), gtk_hseparator_new(), 0, 3, 3, 4,
			 GTK_FILL, GTK_FILL, 5, 5);

	gtk_widget_show_all(vol->slot);
}
示例#3
0
static GtkWidget *volume_constructor(LXPanel *panel, config_setting_t *settings)
{
    volume_t *vol;
    GtkWidget *p;
    GtkAdjustment *vol_adjustment;

    vol_before_mute = 1;
    curr_volume = 0;
    curr_image = NULL;
    skip_botton1_event = FALSE;

    ENTER;
    /* check if OSS mixer device could be open */
    mixer_fd = open ("/dev/mixer", O_RDWR, 0);
    if (mixer_fd < 0) {
        RET(NULL);
    }
    /* try to obtain current volume */
    p = create_volume_window(); /* use pointer */
    if (! vol_spin)
        goto _error;
    vol_adjustment = gtk_spin_button_get_adjustment (vol_spin);
    if (! vol_adjustment)
    {
_error:
        gtk_widget_destroy(p);
        RET(NULL);
    }
    curr_volume = gtk_adjustment_get_value (vol_adjustment);

    vol = g_new0(volume_t, 1);
    vol->dlg = p; /* it was reused */

    p = gtk_event_box_new();
    lxpanel_plugin_set_data(p, vol, volume_destructor);
    vol->panel = panel;

    gtk_widget_add_events(p, GDK_BUTTON_PRESS_MASK);
    g_signal_connect(p, "scroll-event", G_CALLBACK(on_mouse_scroll), vol);
    gtk_widget_set_size_request(p, panel_get_icon_size(panel), panel_get_icon_size(panel));

    update_icon(p, vol);
    gtk_widget_destroy( vol->dlg );
    vol->dlg = NULL;

    /* FIXME: display current level in tooltip. ex: "Volume Control: 80%"  */
    gtk_widget_set_tooltip_text(p, _("Volume control"));

    RET(p);
}
示例#4
0
文件: menu.c 项目: spippolatore/abuse
void menu_handler(event &ev, input_manager *inm)
{
  switch (ev.type)
  {
    case EV_MESSAGE :
    {
      switch (ev.message.id)
      {
				case ID_LIGHT_OFF :
				if (!volume_window)
				{
                                  screen->clear();
				  eh->flush_screen(); 
				  gamma_correct(pal,1);
				  fade_in(cash.img(title_screen),8);
                                  inm->redraw();
				  eh->flush_screen(); 
				} break;
				case ID_RETURN :
				if (!volume_window)
				{
				  the_game->set_state(RUN_STATE);
				} break;
				case ID_START_GAME :
				if (!volume_window)
				{        
				  the_game->load_level(level_file);
				  the_game->set_state(RUN_STATE);
				  view *v;
				  for (v=player_list;v;v=v->next)
				    if (v->focus)
				      v->reset_player();
				   
				} break;

   
        case ID_LOAD_PLAYER_GAME :
				if (!volume_window)
				{
				  int got_level=load_game(0,symbol_str("LOAD"));
				  the_game->reset_keymap();
				  if (got_level)
				  {
				    char name[50];
				    sprintf(name,"save%04d.spe",got_level);
				    the_game->load_level(name);
				    the_game->set_state(RUN_STATE);	    
				  }
				} break;
			
			
				case ID_VOLUME : 
				if (!volume_window)
				{ create_volume_window(); } break;
			
				case ID_MEDIUM :
				{
				  set_symbol_value(l_difficulty,l_medium);
				  save_difficulty();
				} break;
				case ID_HARD :
				{
				  set_symbol_value(l_difficulty,l_hard);
				  save_difficulty();
				} break;
				case ID_EXTREME :
				{
				  set_symbol_value(l_difficulty,l_extreme);
				  save_difficulty();
				} break;
				case ID_EASY :
				{
				  set_symbol_value(l_difficulty,l_easy);
				  save_difficulty();
				} break;
			
				case ID_NETWORKING :
				{
				  if (!volume_window)
				  {
				    net_configuration *cfg=new net_configuration;
				    if (cfg->input())
				    {
				      if (main_net_cfg) delete main_net_cfg;
				      main_net_cfg=cfg;
				    } else delete cfg;
				    the_game->draw(0);
				    inm->redraw();
				  }
				} break;
					      
				case ID_SHOW_SELL :
				if (!volume_window)
				{ 
				  show_sell(1); 
				  screen->clear();
				  if (title_screen>=0)
				  {
				    image *tit=cash.img(title_screen);
				      tit->put_image(screen,screen->width()/2-tit->width()/2,
								      screen->height()/2-tit->height()/2);
				  }
				  inm->redraw();
				  fade_in(NULL,8);
				  eh->flush_screen(); 
			
				} break;
					      
				case ID_MACKEYS :
                                  do_key_config(eh);

                                  /*
					fade_out(8);
					RestoreMac();
					MacKeyConfigMenu();

					UnRestoreMac(); */

                                    fade_in(cash.img(title_screen),8);
                                    inm->redraw();
                                    eh->flush_screen(); 
					break;

				case ID_MACCONF :
                                  do_monitor_config(eh);

				  fade_in(cash.img(title_screen),8);
                                  inm->redraw();
                                  eh->flush_screen(); 
                                  break;
      } break;
    } break;
    case EV_CLOSE_WINDOW :
    {
      if (ev.window==volume_window)
      { eh->close_window(volume_window); volume_window=NULL; }
    } break;
  }
}
示例#5
0
文件: volume.c 项目: TKr/lxde-lxpanel
static gboolean on_button_press (GtkWidget* widget, GdkEventButton* evt, LXPanel* p)
{
	volume_t *vol = lxpanel_plugin_get_data(widget);

	/* for scroll correction */
	if (skip_botton1_event) {
		gtk_widget_destroy(vol->dlg);
		vol->dlg = NULL;
		skip_botton1_event = FALSE;
	}

	switch ( evt->button ) {
	case 1: {	/*  Left click */
		if ( ! vol->dlg ) {
			vol->dlg = create_volume_window();

			/* setting background to default */
			gtk_widget_set_style(vol->dlg, panel_get_defstyle(p));

			g_signal_connect( vol->dlg, "focus-out-event",
					G_CALLBACK(on_volume_focus), widget );

			gtk_window_present( GTK_WINDOW(vol->dlg) );
		}
		else {
			/* update icon */
			if (! vol_spin) return FALSE;
			GtkAdjustment *vol_adjustment =
				gtk_spin_button_get_adjustment (vol_spin);
			if (! vol_adjustment) return FALSE;
			curr_volume = gtk_adjustment_get_value (vol_adjustment);
			update_icon(widget, vol);

			gtk_widget_destroy(vol->dlg);
			vol->dlg = NULL;
		}
		break;
	}

	case 2:	{	/* middle mouse button */
		if ( ! vol->dlg ) {
			vol->dlg = create_volume_window();
		}

		if (! vol_spin) return FALSE;
		GtkAdjustment *vol_adjustment =
			gtk_spin_button_get_adjustment (vol_spin);
		if (! vol_adjustment) return FALSE;

		curr_volume = gtk_adjustment_get_value (vol_adjustment);

		if (curr_volume > 0) {
			/* turning to mute */
			vol_before_mute = curr_volume;
			curr_volume = 0;
		}
		else {
			curr_volume = vol_before_mute;
		}

		gtk_adjustment_set_value (vol_adjustment, curr_volume);
		gtk_spin_button_set_adjustment(vol_spin, vol_adjustment);

		update_icon(widget, vol);

		gtk_widget_destroy( vol->dlg );
		vol->dlg = NULL;
		break;
	}
	default:	/* never here */
		break;
	}
	return FALSE;
}
示例#6
0
void menu_handler(event &ev, jwindow *ico_win)
{
  switch (ev.type)
  {
    case EV_MESSAGE :
    {
      switch (ev.message.id)
      {
	case ID_LIGHT_OFF :
	{
	  gamma_correct(pal,1);
	} break;
	case ID_START_GAME :
	{        
	  the_game->load_level(level_file);
	  the_game->set_state(RUN_STATE);
	} break;

	case ID_VOLUME : 
	{ create_volume_window(); } break;
      	case ID_SFX_UP :
	{ if (volume_window) 
	  {
	    sfx_volume+=16;
	    if (sfx_volume>127) sfx_volume=127;
	    draw_sfx_vol();
	  }
	} break;
      	case ID_SFX_DOWN :
	{ if (volume_window) 
	  {
	    sfx_volume-=16;
	    if (sfx_volume<0) sfx_volume=0;
	    draw_sfx_vol();
	  }
	} break;

      	case ID_MUSIC_UP :
	{ if (volume_window) 
	  {
	    music_volume+=16;
	    if (music_volume>127) music_volume=127;
	    draw_music_vol();
	  }
	} break;
      	case ID_MUSIC_DOWN :
	{ if (volume_window) 
	  {
	    music_volume-=16;
	    if (music_volume<0) music_volume=0;
	    draw_music_vol();
	  }
	} break;
	case ID_MEDIUM :
	{
	  set_symbol_value(l_difficulty,l_medium);
	  save_difficulty();
	} break;
	case ID_HARD :
	{
	  set_symbol_value(l_difficulty,l_hard);
	  save_difficulty();
	} break;
	case ID_EXTREME :
	{
	  set_symbol_value(l_difficulty,l_extreme);
	  save_difficulty();
	} break;
	case ID_EASY :
	{
	  set_symbol_value(l_difficulty,l_easy);
	  save_difficulty();
	} break;
		      
			 
      } break;
    } break;
    case EV_CLOSE_WINDOW :
    {
      if (ev.window==volume_window)
      { eh->close_window(volume_window); volume_window=NULL; }
    } break;
  }
}