Beispiel #1
0
/* If this file is a torrent, add it to our list */
static void
core_watchdir_monitor_file (TrCore * core, GFile * file)
{
  char * filename = g_file_get_path (file);
  const gboolean is_torrent = g_str_has_suffix (filename, ".torrent");

  if (is_torrent)
    {
      GSList * l;
      struct TrCorePrivate * p = core->priv;

      /* if we're not already watching this file, start watching it now */
      for (l=p->monitor_files; l!=NULL; l=l->next)
        if (g_file_equal (file, l->data))
          break;

      if (l == NULL)
        {
          g_object_ref (file);
          p->monitor_files = g_slist_prepend (p->monitor_files, file);
          if (p->monitor_idle_tag == 0)
            p->monitor_idle_tag = gdk_threads_add_timeout_seconds (1, core_watchdir_idle, core);
        }
    }

  g_free (filename);
}
Beispiel #2
0
guint
gtr_timeout_add_seconds( guint seconds, GSourceFunc function, gpointer data )
{
#if GTK_CHECK_VERSION( 2,14,0 )
    return gdk_threads_add_timeout_seconds( seconds, function, data );
#elif GTK_CHECK_VERSION( 2,12,0 )
    return gdk_threads_add_timeout( seconds*1000, function, data );
#else
    return g_timeout_add_full( G_PRIORITY_DEFAULT,
                               seconds * 1000,
                               gtr_thread_func,
                               gtr_func_data_new( function, data ),
                               gtr_func_data_free );
#endif
}
Beispiel #3
0
static void
spun_cb (GtkSpinButton * w, gpointer core, gboolean isDouble)
{
    /* user may be spinning through many values, so let's hold off
       for a moment to keep from flooding the core with changes */
    GObject * o = G_OBJECT (w);
    struct spin_idle_data * data = g_object_get_data (o, IDLE_DATA);

    if (data == NULL)
    {
        data = g_new (struct spin_idle_data, 1);
        data->core = core;
        data->last_change = g_timer_new ();
        data->isDouble = isDouble;
        g_object_set_data_full (o, IDLE_DATA, data, spin_idle_data_free);
        g_object_ref (G_OBJECT (o));
        gdk_threads_add_timeout_seconds (1, spun_cb_idle, w);
    }
static void
onResponse( GtkDialog * dialog, int response, gpointer unused UNUSED )
{
    if( response == GTK_RESPONSE_APPLY )
    {
        GtkWidget * w;
        GObject * d = G_OBJECT( dialog );
        struct relocate_dialog_data * data = g_object_get_data( d, DATA_KEY );
        GtkFileChooser * chooser = g_object_get_data( d, "chooser" );
        GtkToggleButton * move_tb = g_object_get_data( d, "move_rb" );
        char * location = gtk_file_chooser_get_filename( chooser );

        data->do_move = gtk_toggle_button_get_active( move_tb );

        /* pop up a dialog saying that the work is in progress */
        w = gtk_message_dialog_new( GTK_WINDOW( dialog ),
                                    GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
                                    GTK_MESSAGE_INFO,
                                    GTK_BUTTONS_CLOSE,
                                    NULL );
        gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( w ), _( "This may take a moment..." ) );
        gtk_dialog_set_response_sensitive( GTK_DIALOG( w ), GTK_RESPONSE_CLOSE, FALSE );
        gtk_widget_show( w );

        /* remember this location so that it can be the default next time */
        g_free( previousLocation );
        previousLocation = location;

        /* start the move and periodically check its status */
        data->message_dialog = w;
        data->done = TR_LOC_DONE;
        onTimer( data );
        gdk_threads_add_timeout_seconds( 1, onTimer, data );
    }
    else
    {
        gtk_widget_destroy( GTK_WIDGET( dialog ) );
    }
}
static void permission_checker (GtkButton *button12, gpointer data) {
    cleanup_window();

    gtk_image_set_from_stock(GTK_IMAGE(permission_status_icon), GTK_STOCK_EXECUTE, GTK_ICON_SIZE_SMALL_TOOLBAR);
    gtk_label_set_label(GTK_LABEL(permission_status_label), _("Checking..."));

    //This will make the communication thread check the permission
    //and set the current status on the perm_result enum
    permission_check_requested = TRUE;

    //This is only to accelerate the check.
    //If scrobbles are being made, they are stopped for the request to be done sooner.
    scrobbling_enabled = FALSE;

    //Wake up the communication thread in case it's waiting for track plays
    pthread_mutex_lock(&communication_mutex);
    pthread_cond_signal(&communication_signal);
    pthread_mutex_unlock(&communication_mutex);

    //The button is clicked. Wait for the permission check to be done.
    gdk_threads_add_timeout_seconds(1, permission_checker_thread, data);
}