Ejemplo n.º 1
0
/**
 * Compares two times and acts on match (deadline)
 */
static void check_for_deadline(Time* current_time_struct, Time* target_time_struct)
{
    if ((current_time_struct->hours == target_time_struct->hours) 
            && (current_time_struct->minutes == target_time_struct->minutes)
            && (current_time_struct->seconds == target_time_struct->seconds)) {

        debug_printf (DEBUG_INFO, "* Alarm has been activated, decide what action to take!");

        /* Decide what action to take from the selected item in the combo */
        switch (cfg_get_single_value_as_int_with_default (config, "alarm-plugin", "action-id", 0)) {
            case 0:
                debug_printf (DEBUG_INFO, "* Attempting to play/pause");
                play_song ();
                break;
            case 1:
                debug_printf (DEBUG_INFO, "* Attempting to stop");
                stop_song ();
                break;
            case 2:
                debug_printf (DEBUG_INFO, "* Stopping and closing gmpc");
                stop_song ();
                main_quit ();
                break;
            case 3:
                debug_printf (DEBUG_INFO, "* Closing gmpc only");
                /* Friendly way of closing gmpc */
                main_quit ();
                break;
            case 4:
                debug_printf (DEBUG_INFO, "* Shutting down system");
                /* TODO: Nice way of halting a system */
                break;
            case 5:
                debug_printf (DEBUG_INFO, "* Toggling random");
                random_toggle ();
                break;
        }

        /* Disable timer, and thus the ticking timeout */
        alarm_stop();
    }
}
Ejemplo n.º 2
0
/* @brief Called when a file, document or url is to be closed by the application
 *
 * Application (callee) should close the file and may destroy its window and free 
 * other resources. System Daemon removes the task from the Task Manager of Popupmenu.
 */
static void on_file_close ( eripc_context_t          *context,
                            const eripc_event_info_t *info,
                            void                     *user_data )
{
    LOGPRINTF("entry");
    
    // return result to caller
    eripc_reply_bool(context, info->message_id, TRUE);
    
    main_quit();
}
Ejemplo n.º 3
0
void MainWindow::createTrayActions() {
	minimizeAction = new QAction(tr("Mi&nimize"), this);
	connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide()));
	connect(minimizeAction, SIGNAL(triggered()), stats_, SLOT(hide()));

	restoreAction = new QAction(tr("&Restore"), this);
	connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
//	connect(restoreAction, SIGNAL(triggered()), stats_, SLOT(show()));

	quitAction = new QAction(tr("&Quit"), this);
	connect(quitAction, SIGNAL(triggered()), this, SLOT(main_quit()));
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: hsgg/quark
void
signal_handler (int signal)
{
    g_static_mutex_lock (&main_signal_mutex);

    switch (signal) {
    case SIGTERM:
    case SIGINT:
    case SIGHUP:
        main_quit ();
        break;
    }

    g_static_mutex_unlock (&main_signal_mutex);
}
Ejemplo n.º 5
0
/* @brief Called just after unmounting the volume
 *
 * Typically an application should have responded to a prior sysPrepareUnmount 
 * signal, but when a device with volumes was removed unexpectedly it may need 
 * to act on this signal.
 */  
static void on_unmounted ( eripc_context_t          *context,
                           const eripc_event_info_t *info,
                           void                     *user_data )
{
    LOGPRINTF("entry");
    const eripc_arg_t *arg_array  = info->args;

    if (arg_array[0].type == ERIPC_TYPE_STRING)
    {
        const char  *mountpoint = arg_array[0].value.s;
        if (mountpoint)
        {
            main_quit();
        }
    }
}
Ejemplo n.º 6
0
Archivo: fifo.c Proyecto: hsgg/quark
static gboolean
fifo_read (GIOChannel *chan, GIOCondition cond, gpointer data)
{
    char *command;
    gsize term;
    GError *err;
    gboolean ret;

    g_static_mutex_lock (&main_fifo_mutex);

    err = NULL;

    if (cond & G_IO_IN) {
        while (g_io_channel_read_line (chan, &command, NULL, &term, &err) ==
                G_IO_STATUS_NORMAL) {
            command[term] = '\0';
            fifo_execute (command);
            g_free (command);
        }
        if (err) {
            g_warning ("error reading fifo: %s", err->message);
            g_error_free (err);
        }
    }

    if (cond & G_IO_HUP || cond & G_IO_ERR) {
        fifo_close ();
        if (!fifo_open ()) {
            g_critical ("failed to reopen fifo");
            main_quit ();
        }
        ret = FALSE; /* remove me from the watch */
    } else
        ret = TRUE;

    g_static_mutex_unlock (&main_fifo_mutex);

    return ret;
}
Ejemplo n.º 7
0
void MainWindow::createLocalActions() {
	QAction *runtools = new QAction(tr("&Tools"), this);
	connect(runtools, SIGNAL(triggered()), this, SLOT(runTools()));
	addAction(runtools);

	QAction *qminimize = new QAction(tr("&Minimize"), this);
	connect(qminimize, SIGNAL(triggered()), this, SLOT(hide()));
	connect(qminimize, SIGNAL(triggered()), stats_, SLOT(hide()));
	addAction(qminimize);

	QAction *separator1 = new QAction(this);
	separator1->setSeparator(true);
	addAction(separator1);

	qrun_ = new QAction(tr("&Run"), this);
	connect(qrun_, SIGNAL(triggered()), this, SLOT(run()));
	addAction(qrun_);

	qedit_ = new QAction(tr("&Edit"), this);
	connect(qedit_, SIGNAL(triggered()), this, SLOT(edit()));
	addAction(qedit_);

	qdelete_ = new QAction(tr("&Delete"), this);
	connect(qdelete_, SIGNAL(triggered()), this, SLOT(remove()));
	addAction(qdelete_);

	qhelp_ = new QAction(tr("&Help"), this);
	connect(qhelp_, SIGNAL(triggered()), this, SLOT(help()));
	addAction(qhelp_);

	QAction *separator2 = new QAction(this);
	separator2->setSeparator(true);
	addAction(separator2);

	QAction *qquit = new QAction(tr("&Quit"), this);
	//	qa->setShortcut(tr("Ctrl+Q"));
	connect(qquit, SIGNAL(triggered()), this, SLOT(main_quit()));
	addAction(qquit);
}
Ejemplo n.º 8
0
/* wrapper function to abort exit process if cancel button is pressed */
static gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer gdata)
{
	return !main_quit();
}
Ejemplo n.º 9
0
void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	main_quit();
}
Ejemplo n.º 10
0
Archivo: fifo.c Proyecto: hsgg/quark
static void
fifo_execute (const char *command)
{
    if (!g_ascii_strncasecmp (command, "quit", 4))
        main_quit ();
    else if (!g_ascii_strncasecmp (command, "play", 4))
        music_play ();
    else if (!g_ascii_strncasecmp (command, "pause", 5))
        if (music_playing)
            music_pause ();
        else
            music_play ();
    else if (!g_ascii_strncasecmp (command, "stop", 4))
        music_stop ();
    else if (!g_ascii_strncasecmp (command, "next", 4)) {
        playlist_advance (1, TRUE);
    }
    else if (!g_ascii_strncasecmp (command, "prev", 4)) {
        playlist_advance (-1, TRUE);
    }
    else if (!g_ascii_strncasecmp (command, "append", 6)) {
        if (strlen (command) > 7) {
            gchar *u;
            const gchar *path;

            path = (command + 7);
            if (!(u = g_filename_to_utf8 (path, -1, NULL, NULL, NULL))) {
                g_warning (_("Skipping '%s'. Could not convert to UTF-8. "
                             "See the README for a possible solution."), path);
            } else {
                playlist_append_single (u);
                g_free (u);
            }
        }
    }
    else if (!g_ascii_strncasecmp (command, "track", 5)) {
        if (strlen (command) > 6) {
            int i = atoi (command + 6);
            playlist_seek (i - 1); /* first track is '1' */
        }
    }
    else if (!g_ascii_strncasecmp (command, "remove", 6)) {
        if (strlen (command) > 7) {
            int i = atoi (command + 7);
            playlist_remove (i - 1); /* first track is '1' */
        }
    }
    else if (!g_ascii_strncasecmp (command, "clear", 5)) {
        playlist_clear ();
    }
    else if (!g_ascii_strncasecmp (command, "move", 4)) {
        if (strlen (command) > 5) {
            char *p;
            int i = strtol (command + 5, &p, 10);
            if (strlen (command) > (unsigned)(p - command)) {
                int before = atoi (p);
                playlist_move (i - 1, before - 1); /* first track is '1' */
            }
        }
    }
    else if (!g_ascii_strncasecmp (command, "loop", 4)) {
        main_set_loop_at_end(!main_loop_at_end);
    }
    else if (!g_ascii_strncasecmp (command, "random", 6)) {
        main_set_random_order(!main_random_order);
    }
    else if (!g_ascii_strncasecmp (command, "dump", 4)) {
        playlist_dump ();
    }
    else if (!g_ascii_strncasecmp (command, "connect", 7)) {
        if (strlen (command) > 8) {
            fifo_add_notify (command + 8);
        }
    }

}
Ejemplo n.º 11
0
/**
 * keyevents for paint windows thet is show by dataprojector
 **/
static gboolean
event_keypress (GtkWidget     *widget,
				GdkEventKey *event )
{
	unsigned int r,g,b;
	printf("debug color %d %c\n", event->keyval, event->keyval);
	switch(event->keyval){
	// key set color for brush
	case 65438:
	case '0':
		sscanf(color_key[0],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65436:
	case '1':
		sscanf(color_key[1],"%2X%2X%2X",&r,&g,&b);
        //printf("%s\n", color_key[1]);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65433:
	case '2':
		sscanf(color_key[2],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g =  g/255.0;
		break;
	case 65435:
	case '3':
		sscanf(color_key[3],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65430:
	case '4':
		sscanf(color_key[4],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65437:
	case '5':
		sscanf(color_key[5],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65432:
	case '6':
		sscanf(color_key[6],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65429:
	case '7':
		sscanf(color_key[7],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65431:
	case '8':
		sscanf(color_key[8],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;
	case 65434:
	case '9':
		sscanf(color_key[9],"%2X%2X%2X",&r,&g,&b);
		color.b = b/255.0; color.r = r/255.0; color.g = g/255.0;
		break;

	case 65455:
	case '/':
		brush_type = 0;
		break;
    case 65451:
        brush_type = 3;
        printf("type 3\n");
        break;
	case 65450:
	case '+':
		brush_type = 1;
		break;
	case '*':
	case 65453:
	case 'a':
		brush_type = 2;
		break;
	case 65535:
		SavePaint();
		CleanPaint();
		break;

	case 'r':
		{

        if (record_video == false){
           printf("start record");
//            writter_v = cvCreateVideoWriter(buffer_v, CV_FOURCC('M', 'J', 'P', 'G') , 20, cvSize(640,480),  1);
            writter_v = cvCreateVideoWriter(buffer_v, CV_FOURCC('T','H','E','O') , 20, cvSize(640,480),  1);
            record_video = true;
        } else {
            cvReleaseVideoWriter( &writter_v );
            record_video = false;
        }
		
		}
		break;

	// vymazání plochy
	case 'c':
		{
			SavePaint();
			CleanPaint();
		}
		break;
	// spuštění režimu ve fullsreenmodu
	case 'f':
		isFullSreen = !isFullSreen;
		if(isFullSreen){
			gdk_window_fullscreen(widget->window);
		}
		else {
			gdk_window_unfullscreen(widget->window);
			window_w = DEFAULT_WIDTH;
			window_h = DEFAULT_HEIGHT;
		}
		break;
	/* spuštění programu */
	case 's':
		start = true;
	break;
	/* nastavení treshold pro upravu obrázku */
	case 'm':
		if(treshold<255) treshold++; break;
	/* nastavení treshold pro upravu obrázku */
	case 'n':
		if(treshold>0) treshold--; break;

	//escape
	case 65307:
	case 'q':
		main_quit ();
		break;
	}

	return true;
}