Exemple #1
0
/**
 * Handles button-release-event' signal on the tray_icon, currently
 * only used for middle-click.
 *
 * @param status_icon the object which received the signal
 * @param event the GdkEventButton which triggered this signal
 * @param user_data user data set when the signal handler was
 * connected
 */
void tray_icon_button(GtkStatusIcon *status_icon,
		GdkEventButton *event,
		gpointer user_data) {
  if (event->button == 2) {
    gint act = 0;
    if (g_key_file_has_key(keyFile,"PNMixer","MiddleClickAction",NULL))
      act = g_key_file_get_integer(keyFile,"PNMixer","MiddleClickAction",NULL);
    switch (act) {
    case 0: // mute/unmute
      setmute(mouse_noti);
      get_mute_state(TRUE);
      break;
    case 1:
      do_prefs();
      break;
    case 2: {
      on_mixer();
      break;
    }
    case 3:
      if (g_key_file_has_key(keyFile,"PNMixer","CustomCommand",NULL)) {
	gchar* cmd = g_key_file_get_string(keyFile,"PNMixer","CustomCommand",NULL);
	if (cmd) {
	  run_command(cmd);
	  g_free(cmd);
	}  else // This shouldn't ever happen, so let's just write to console
	  g_warning("KeyFile has CustomCommand key, but get_string returned NULL");
      }
      else
	report_error(_("You have not specified a custom command to run, please specify one in preferences."));
      break;
    default: {} // nothing
    }
  }
}
Exemple #2
0
/**
 * Handles button-release-event' signal on the tray_icon, currently
 * only used for middle-click.
 *
 * @param status_icon the object which received the signal
 * @param event the GdkEventButton which triggered this signal
 * @param user_data user data set when the signal handler was
 * connected
 */
void
tray_icon_button(G_GNUC_UNUSED GtkStatusIcon *status_icon,
		 GdkEventButton *event, G_GNUC_UNUSED gpointer user_data)
{
	gint action;

	if (event->button != 2)
		return;
	
	action = prefs_get_integer("MiddleClickAction", 0);

	switch (action) {
	case 0:	// mute/unmute
		setmute(mouse_noti);
		on_volume_has_changed();
		break;
	case 1:
		do_prefs();
		break;
	case 2:
		on_mixer();
		break;
	case 3: {
		gchar *cmd;

		cmd = prefs_get_string("CustomCommand", NULL);

		if (cmd) {
			run_command(cmd);
			g_free(cmd);
		} else
			report_error(_("You have not specified a custom command to run, "
			               "please specify one in preferences."));
		break;
	}
	default: {
	}	// nothing
	}
}
Exemple #3
0
void
handle_splash_event (saver_info *si, XEvent *event)
{
  splash_dialog_data *sp = si->sp_data;
  saver_screen_info *ssi = sp->prompt_screen;
  int which = 0;
  if (!sp) return;

  switch (event->xany.type)
    {
    case Expose:
      draw_splash_window (si);
      break;

    case ButtonPress: case ButtonRelease:

      if (event->xbutton.x >= sp->demo_button_x &&
	  event->xbutton.x < sp->demo_button_x + sp->button_width &&
	  event->xbutton.y >= sp->demo_button_y &&
	  event->xbutton.y < sp->demo_button_y + sp->button_height)
	which = 1;

#ifdef PREFS_BUTTON
      else if (event->xbutton.x >= sp->prefs_button_x &&
	       event->xbutton.x < sp->prefs_button_x + sp->button_width &&
	       event->xbutton.y >= sp->prefs_button_y &&
	       event->xbutton.y < sp->prefs_button_y + sp->button_height)
	which = 2;
#endif /* PREFS_BUTTON */

      else if (event->xbutton.x >= sp->help_button_x &&
	       event->xbutton.x < sp->help_button_x + sp->button_width &&
	       event->xbutton.y >= sp->help_button_y &&
	       event->xbutton.y < sp->help_button_y + sp->button_height)
	which = 3;

      if (event->xany.type == ButtonPress)
	{
	  sp->pressed = which;
	  update_splash_window (si);
	  if (which == 0)
	    XBell (si->dpy, False);
	}
      else if (event->xany.type == ButtonRelease)
	{
	  if (which && sp->pressed == which)
	    {
	      destroy_splash_window (si);
              sp = si->sp_data;
	      switch (which)
		{
		case 1: do_demo (ssi); break;
#ifdef PREFS_BUTTON
		case 2: do_prefs (ssi); break;
#endif /* PREFS_BUTTON */
		case 3: do_help (ssi); break;
		default: abort();
		}
	    }
          else if (which == 0 && sp->pressed == 0)
            {
              /* click and release on the window but not in a button:
                 treat that as "dismiss the splash dialog." */
	      destroy_splash_window (si);
              sp = si->sp_data;
            }
	  if (sp) sp->pressed = 0;
	  update_splash_window (si);
	}
      break;

    default:
      break;
    }
}