Ejemplo n.º 1
0
static gint 
_gail_combo_button_release (gpointer data)
{
  GtkCombo *combo;
  GtkWidget *action_widget;
  GdkEvent tmp_event;

  GDK_THREADS_ENTER ();

  combo = GTK_COMBO (data);
  if (combo->current_button == 0)
    {
      GDK_THREADS_LEAVE ();
      return FALSE;
    }

  tmp_event.button.type = GDK_BUTTON_RELEASE; 
  tmp_event.button.button = 1; 
  tmp_event.button.window = combo->list->window;
  tmp_event.button.time = GDK_CURRENT_TIME;
  gdk_window_set_user_data (combo->list->window, combo->button);
  action_widget = combo->list;

  gtk_widget_event (action_widget, &tmp_event);

  GDK_THREADS_LEAVE ();

  return FALSE;
}
Ejemplo n.º 2
0
static gboolean
idle_do_action (gpointer data)
{
  GtkWidget *widget;
  GailExpander *gail_expander;

  GDK_THREADS_ENTER ();

  gail_expander = GAIL_EXPANDER (data);
  gail_expander->action_idle_handler = 0;

  widget = GTK_ACCESSIBLE (gail_expander)->widget;
  if (widget == NULL /* State is defunct */ ||
      !GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
    {
      GDK_THREADS_LEAVE ();
      return FALSE;
    }

  gtk_widget_activate (widget);

  GDK_THREADS_LEAVE ();

  return FALSE; 
}
/* Scroll function taken/adapted from gtktreeview.c */
static gint
scroll_row_timeout (gpointer data)
{
	GtkTreeView *tree_view = data;
	GdkRectangle visible_rect;
	gint y, x;
	gint offset;
	gfloat value;
	GtkAdjustment* vadj;
	RbTreeDndData *priv_data;

	GDK_THREADS_ENTER ();

	priv_data = g_object_get_data (G_OBJECT (tree_view), RB_TREE_DND_STRING);
	g_return_val_if_fail(priv_data != NULL, TRUE);

	gdk_window_get_pointer (gtk_tree_view_get_bin_window (tree_view), &x, &y, NULL);
	gtk_tree_view_convert_widget_to_bin_window_coords (tree_view, x, y, &x, &y);
	gtk_tree_view_convert_bin_window_to_tree_coords (tree_view, x, y, &x, &y);

	gtk_tree_view_get_visible_rect (tree_view, &visible_rect);

	/* see if we are near the edge. */
	if (x < visible_rect.x && x > visible_rect.x + visible_rect.width)
	{
		GDK_THREADS_LEAVE ();
		priv_data->scroll_timeout = 0;
		return FALSE;
	}

	offset = y - (visible_rect.y + 2 * SCROLL_EDGE_SIZE);
	if (offset > 0)
	{
		offset = y - (visible_rect.y + visible_rect.height - 2 * SCROLL_EDGE_SIZE);
		if (offset < 0) 
		{
			GDK_THREADS_LEAVE ();
			priv_data->scroll_timeout = 0;
			return FALSE;
		}
	}

	vadj = gtk_tree_view_get_vadjustment (tree_view);
	value = CLAMP (vadj->value + offset, vadj->lower, vadj->upper - vadj->page_size);
	gtk_adjustment_set_value (vadj, value);

	/* don't remove it if we're on the edge and not scrolling */
	if (ABS (vadj->value - value) > 0.0001)
		remove_select_on_drag_timeout(tree_view);

	GDK_THREADS_LEAVE ();

	return TRUE;
}
Ejemplo n.º 4
0
gboolean populate_files (gpointer data)     //TODO:: show an spinner while loading
{
  FilebrowserBackend *filebackend= FILEBROWSER_BACKEND(data);
  FilebrowserBackendDetails *directory = FILEBROWSER_BACKEND_GET_PRIVATE(filebackend);
  GDK_THREADS_ENTER();
  if (g_cancellable_is_cancelled (directory->cancellable)){
  GDK_THREADS_LEAVE();
  return FALSE; /* remove source */
  }
  GError *error=NULL;
  GFileInfo *info = g_file_enumerator_next_file (directory->enumerator, directory->cancellable, &error);
  if (info){
	  const gchar *mime= g_file_info_get_content_type (info);
	  if (!g_file_info_get_is_hidden (info)  && !g_file_info_get_is_backup (info)){
	    if (MIME_ISDIR(mime)){
		//if has dot in name pos 0 don't process
		const gchar *folder=g_file_info_get_display_name(info);
		if(folder[0]!='.'){
		  FOLDERFILE *current;
		  current=new_folderfile();
		  current->mime=g_strdup(mime);
      GIcon *icon =g_file_info_get_icon(info); 
      current->icon= g_icon_to_string (icon);
		  current->display_name=g_strdup(folder);
		  /* add to list */
		 directory->filesinfolder = g_slist_append(directory->filesinfolder, current);
		  }
	  } else {
	    if (IS_TEXT(mime) && !IS_APPLICATION(mime)){
	      //files
	      FOLDERFILE *current;
	      current=new_folderfile();
	      current->mime=g_strdup(mime);
	      GIcon *icon =g_file_info_get_icon(info); 
	      current->icon= g_icon_to_string (icon);
	      current->display_name=g_strdup(g_file_info_get_display_name(info));
	      /* add to list */
	      directory->filesinfolder = g_slist_append(directory->filesinfolder, current);
	      }
	    }
	  }	
	g_object_unref(info);
   } else {
   	if (error){
   		g_print(_("Error::%s"),error->message);
   		g_error_free (error);
   	}
	GDK_THREADS_LEAVE();
	return FALSE; /* remove source */
   }
    GDK_THREADS_LEAVE();
    return TRUE;
}
Ejemplo n.º 5
0
guint
bst_choice_modal (GtkWidget *choice,
		  guint      mouse_button,
		  guint32    time)
{
  gpointer data = GUINT_TO_POINTER (0);
  
  if (GTK_IS_MENU (choice))
    {
      GtkMenu *menu = GTK_MENU (choice);
      
      gtk_object_set_data (GTK_OBJECT (menu), "BstChoice", data);
      
      if (bst_choice_selectable (choice))
	{
	  modal_loop_quit_on_menu_item_activate = TRUE;
	  modal_loop_running = TRUE;
	  current_popup_menu = GTK_WIDGET (menu);
	  gtk_menu_popup (menu, NULL, NULL, NULL, NULL, mouse_button, time);
	  while (modal_loop_running)
	    {
	      GDK_THREADS_LEAVE ();
	      g_main_iteration (TRUE);
	      GDK_THREADS_ENTER ();
	    }
	  current_popup_menu = NULL;
	  modal_loop_quit_on_menu_item_activate = FALSE;
	}
      
      data = gtk_object_get_data (GTK_OBJECT (menu), "BstChoice");
    }
  else if (GXK_IS_DIALOG (choice))
    {
      gtk_object_set_data (GTK_OBJECT (choice), "BstChoice", data);
      
      if (bst_choice_selectable (choice))
	{
	  gtk_widget_show (choice);
          
          while (GTK_WIDGET_VISIBLE (choice))
	    {
	      GDK_THREADS_LEAVE ();
	      g_main_iteration (TRUE);
	      GDK_THREADS_ENTER ();
	    }
	}
      
      data = gtk_object_get_data (GTK_OBJECT (choice), "BstChoice");
    }
  
  return GPOINTER_TO_UINT (data);
}
Ejemplo n.º 6
0
int interface_gtk_start(Playlist *playlist, int argc, char **argv)
{
	char path[256];
	char *home;

	the_coreplayer = playlist->GetCorePlayer();

	g_thread_init(NULL);
	if (!g_thread_supported()) {
		alsaplayer_error("Sorry - this interface requires working threads.\n");
		return 1;
	}

	// Scope functions
	scopes = new AlsaSubscriber();
	scopes->Subscribe(the_coreplayer->GetNode(), POS_END);
	scopes->EnterStream(scope_feeder_func, the_coreplayer);

	gtk_set_locale();
	gtk_init(&argc, &argv);
	gdk_rgb_init();

	home = getenv("HOME");
	if (home) {
		snprintf(path, 255, "%s/.gtkrc", home);
		gtk_rc_parse(path);
	}

	if (playlist->Length())
		playlist->UnPause();
	// Scope addons
	gdk_flush();
	GDK_THREADS_ENTER();
	init_main_window(playlist);
	load_scope_addons();
	gdk_flush();
	gtk_main();
	gdk_flush();
	GDK_THREADS_LEAVE();
	unload_scope_addons();
	destroy_scopes_window();
	GDK_THREADS_ENTER();
	gdk_flush();
	GDK_THREADS_LEAVE();

	playlist->Pause();

	dl_close_scopes();
	return 0;
}
Ejemplo n.º 7
0
static void the_fftscope(void)
{
	guchar *loc;
	guchar bits [256 * 129];
	int i, h;

	running = 1;

	while (running) {
		guint val;
		gint j;
		gint k;

		memset(bits, 0, 256 * 128);

		for (i=0; i < BARS; i++) { 
			val = 0;
			for (j = xranges[i]; j < xranges[i + 1]; j++) {
				/* k = (guint)(sqrt(fftout[j]) * fftmult); */
				k = (fft_buf[j] + fft_buf[256+j]) / 256;
				val += k;
			}
			if(val > 127) val = 127;
			if (val > (guint)maxbar[ i ]) 
				maxbar[ i ] = val;
			else {
				k = maxbar[ i ] - (4 + (8 / (128 - maxbar[ i ])));
				val = k > 0 ? k : 0;
				maxbar[ i ] = val;
			}
			loc = bits + 256 * 128;
			for (h = val; h > 0; h--) {
				for (j = (256 / BARS) * i + 0; j < (256 / BARS) * i + ((256 / BARS) - 1); j++) {
					*(loc + j) = val-h;
				}
				loc -=256;
			}
		}
		GDK_THREADS_ENTER();
		gdk_draw_indexed_image(area->window, area->style->white_gc,
				0,0,256,128, GDK_RGB_DITHER_NONE, bits, 256, color_map);
		gdk_flush();
		GDK_THREADS_LEAVE();
		dosleep(SCOPE_SLEEP);
	}	
	GDK_THREADS_ENTER();
	fftscope_hide();
	GDK_THREADS_LEAVE();
}
Ejemplo n.º 8
0
static gboolean
xt_event_check (GSource*  source_data)
{
  GDK_THREADS_ENTER ();

  if (xt_event_poll_fd.revents & G_IO_IN) {
    int mask;
    mask = XPending(xtdisplay);
    GDK_THREADS_LEAVE ();
    return (gboolean)mask;
  }

  GDK_THREADS_LEAVE ();
  return FALSE;
}   
Ejemplo n.º 9
0
static gint draw_func(gpointer data)
{
	gint i;
	
	if(!window)
	{
		timeout_tag = 0;
		return FALSE;
	}
	
	GDK_THREADS_ENTER();
	gdk_draw_rectangle(draw_pixmap,gc,TRUE,0,0,WIDTH,HEIGHT);

	
	for(i = 0; i < NUM_BANDS; i++)
	{
		/*if(bar_heights[i] > 4)
			bar_heights[i] -= 4;
		else
			bar_heights[i] = 0;*/
		gdk_draw_pixmap(draw_pixmap,gc,bar, 0,HEIGHT - 1 - bar_heights[i], i * (WIDTH / NUM_BANDS), HEIGHT - 1 - bar_heights[i], (WIDTH / NUM_BANDS) - 1, bar_heights[i]);
		
	}
	gdk_window_clear(area->window);
	GDK_THREADS_LEAVE();
	
	return TRUE;
}
Ejemplo n.º 10
0
static gboolean
select_on_drag_timeout (gpointer data)
{
	GtkTreeView *tree_view = data;
	GtkTreeSelection *selection;
	RbTreeDndData *priv_data;

	GDK_THREADS_ENTER ();

	priv_data = g_object_get_data (G_OBJECT (tree_view), RB_TREE_DND_STRING);
	g_return_val_if_fail(priv_data != NULL, FALSE);
	g_return_val_if_fail(priv_data->previous_dest_path != NULL, FALSE);

	selection = gtk_tree_view_get_selection(tree_view);
	if (!gtk_tree_selection_path_is_selected(selection,priv_data->previous_dest_path)) {
		rb_debug("Changing selection because of drag timeout");
		gtk_tree_view_set_cursor(tree_view,priv_data->previous_dest_path,NULL,FALSE);
	}

	priv_data->select_on_drag_timeout = 0;
	gtk_tree_path_free(priv_data->previous_dest_path);
	priv_data->previous_dest_path = NULL;

	GDK_THREADS_LEAVE ();
	return FALSE;
}
Ejemplo n.º 11
0
static gboolean vfs_mime_type_reload( gpointer user_data )
{
    GList* l;
    /* FIXME: process mime database reloading properly. */
    /* Remove all items in the hash table */
    GDK_THREADS_ENTER();

    g_static_rw_lock_writer_lock( &mime_hash_lock );
    g_hash_table_foreach_remove ( mime_hash, ( GHRFunc ) gtk_true, NULL );
    g_static_rw_lock_writer_unlock( &mime_hash_lock );

    g_source_remove( reload_callback_id );
    reload_callback_id = 0;

    /* g_debug( "reload mime-types" ); */

    /* call all registered callbacks */
    for( l = reload_cb; l; l = l->next )
    {
        VFSMimeReloadCbEnt* ent = (VFSMimeReloadCbEnt*)l->data;
        ent->cb( ent->user_data );
    }
    GDK_THREADS_LEAVE();
    return FALSE;
}
Ejemplo n.º 12
0
void show_selection_ascii(struct selectRange *srange)
{
	g_usleep(1);
	GDK_THREADS_ENTER();
	int start, end;
	start = srange->start;
	end = srange->end;

	GtkTextView *textview3 =
	    (GtkTextView *) gtk_builder_get_object(builder, "textview3");

	GtkTextBuffer *buffer3 =
	    gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview3));
	int line1, line2;
	line1 = start / 16;
	start = start - 16 * line1;

	line2 = end / 16;
	end = end - 16 * line2;

	GtkTextIter iter1, iter2;

	gtk_text_buffer_get_iter_at_line_offset(buffer3, &iter1, line1, start);
	gtk_text_buffer_get_iter_at_line_offset(buffer3, &iter2, line2, end);
	gtk_text_buffer_select_range(buffer3, &iter1, &iter2);

	GDK_THREADS_LEAVE();
}
Ejemplo n.º 13
0
static gint clock_timer_callback(gpointer data){
	Clock *clock = (Clock *)data;
	GDK_THREADS_ENTER ();
	clock_gen_str(clock);
	GDK_THREADS_LEAVE ();
	return TRUE;
}
Ejemplo n.º 14
0
static gboolean
on_pad_buffer (GstPad *pad, 
               GstBuffer *buf)
{
    gint64 timestamp;

    GDK_THREADS_ENTER ();

    timestamp = GST_BUFFER_TIMESTAMP (buf);

    if (buffer) 
        gst_buffer_unref (buffer);

    buffer = buf;
    gst_buffer_ref (buf);
    GDK_THREADS_LEAVE ();

    if (start_time == 0)
        start_time = get_time ();
    else {
        gint64 time_left = (timestamp / 1000) - (get_time () - start_time);
        time_left -= 1000000 / 25;
        if (time_left > 2000)
            usleep (time_left);

    }

    return TRUE;
}
Ejemplo n.º 15
0
static void
thunar_uca_provider_child_watch (GPid     pid,
                                 gint     status,
                                 gpointer user_data)
{
  ThunarUcaProvider *uca_provider = THUNAR_UCA_PROVIDER (user_data);
  ThunarVfsMonitor  *monitor;
  ThunarVfsPath     *path;

  GDK_THREADS_ENTER ();

  /* verify that we still have a valid child_watch_path */
  if (G_LIKELY (uca_provider->child_watch_path != NULL))
    {
      /* determine the corresponding ThunarVfsPath */
      path = thunar_vfs_path_new (uca_provider->child_watch_path, NULL);
      if (G_LIKELY (path != NULL))
        {
          /* schedule a changed notification on the path */
          monitor = thunar_vfs_monitor_get_default ();
          thunar_vfs_monitor_feed (monitor, THUNAR_VFS_MONITOR_EVENT_CHANGED, path);
          g_object_unref (G_OBJECT (monitor));

          /* release the ThunarVfsPath */
          thunar_vfs_path_unref (path);
        }
    }

  /* need to cleanup */
  g_spawn_close_pid (pid);

  GDK_THREADS_LEAVE ();
}
Ejemplo n.º 16
0
static gboolean
xt_event_dispatch (GSource*  source_data,
                    GSourceFunc call_back,
                    gpointer  user_data)
{
  XEvent event;
  XtAppContext ac;
  int i = 0;

  ac = XtDisplayToApplicationContext(xtdisplay);

  GDK_THREADS_ENTER ();

  /* Process only real X traffic here.  We only look for data on the
   * pipe, limit it to XTBIN_MAX_EVENTS and only call
   * XtAppProcessEvent so that it will look for X events.  There's no
   * timer processing here since we already have a timer callback that
   * does it.  */
  for (i=0; i < XTBIN_MAX_EVENTS && XPending(xtdisplay); i++) {
    XtAppProcessEvent(ac, XtIMXEvent);
  }

  GDK_THREADS_LEAVE ();

  return TRUE;  
}
Ejemplo n.º 17
0
gboolean on_thumbnail_idle( VFSThumbnailLoader* loader )
{
    VFSFileInfo* file;
    /* g_debug( "ENTER ON_THUMBNAIL_IDLE" ); */
    vfs_async_task_lock( loader->task );

    while( ( file = (VFSFileInfo*)g_queue_pop_head(loader->update_queue) )  )
    {
        GDK_THREADS_ENTER();
        vfs_dir_emit_thumbnail_loaded( loader->dir, file );
        vfs_file_info_unref( file );
        GDK_THREADS_LEAVE();
    }

    loader->idle_handler = 0;

    vfs_async_task_unlock( loader->task );

    if( vfs_async_task_is_finished( loader->task ) )
    {
        /* g_debug( "FREE LOADER IN IDLE HANDLER" ); */
        loader->dir->thumbnail_loader = NULL;
        vfs_thumbnail_loader_free(loader);
    }
    /* g_debug( "LEAVE ON_THUMBNAIL_IDLE" ); */

    return FALSE;
}
Ejemplo n.º 18
0
static gboolean
idle_move_item (gpointer data)
{
  BstCanvasSource *self = data;
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (self);

  GDK_THREADS_ENTER ();
  if (self->source && item->canvas)
    {
      SfiReal x, y;
      bse_proxy_get (self->source,
                     "pos-x", &x,
                     "pos-y", &y,
                     NULL);
      x *= BST_CANVAS_SOURCE_PIXEL_SCALE;
      y *= -BST_CANVAS_SOURCE_PIXEL_SCALE;
      gnome_canvas_item_w2i (item, &x, &y);
      g_object_freeze_notify (G_OBJECT (self));
      gnome_canvas_item_move (item, x, y);
      /* canvas notification bug workaround */
      g_object_notify (self, "x");
      g_object_notify (self, "y");
      g_object_thaw_notify (G_OBJECT (self));
    }
  self->idle_reposition = FALSE;
  g_object_unref (self);
  GDK_THREADS_LEAVE ();
  return FALSE;
}
Ejemplo n.º 19
0
static void
import_complete_cb (RhythmDBImportJob *job, int total, RBGenericPlayerSource *source)
{
	RBGenericPlayerSourceClass *klass = RB_GENERIC_PLAYER_SOURCE_GET_CLASS (source);
	RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source);
	RBShell *shell;

	GDK_THREADS_ENTER ();

	g_object_get (source, "shell", &shell, NULL);
	rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (priv->import_errors), RB_DISPLAY_PAGE (source));
	g_object_unref (shell);

	if (klass->impl_load_playlists)
		klass->impl_load_playlists (source);

	g_object_unref (priv->import_job);
	priv->import_job = NULL;

	rb_display_page_notify_status_changed (RB_DISPLAY_PAGE (source));
	g_object_set (source, "load-status", RB_SOURCE_LOAD_STATUS_LOADED, NULL);

	rb_transfer_target_transfer (RB_TRANSFER_TARGET (source), NULL, FALSE);

	GDK_THREADS_LEAVE ();
}
Ejemplo n.º 20
0
/* This callback is called every 3 seconds */
static int update_timout(batt *b) {
    GDK_THREADS_ENTER();
    ++b->state_elapsed_time;
    ++b->info_elapsed_time;

    /* check the existance of batteries every 3 seconds */
    check_batteries( b );

    /* check the existance of AC adapter every 3 seconds,
     * and update charging state of batteries if needed. */
    check_ac_adapter( b );

    /* check state of batteries every 30 seconds */
    if( b->state_elapsed_time == 30/3 )  /* 30 sec */
    {
        /* update state of batteries */
        g_list_foreach( b->batteries, (GFunc)get_batt_state, &b->use_sysfs );
        b->state_elapsed_time = 0;
    }
    /* check the capacity of batteries every 1 hour */
    if( b->info_elapsed_time == 3600/3 )  /* 1 hour */
    {
        /* update info of batteries */
        g_list_foreach( b->batteries, (GFunc)get_batt_info, &b->use_sysfs );
        b->info_elapsed_time = 0;
    }

    update_display( b, TRUE );

    GDK_THREADS_LEAVE();
    return TRUE;
}
Ejemplo n.º 21
0
/* This is a one-shot idle callback called from the main loop to call
   notify_file_changed() for a thumbnail. It frees the uri afterwards.
   We do this in an idle callback as I don't think nautilus_file_changed() is
   thread-safe. */
static gboolean
thumbnail_thread_notify_file_changed (gpointer image_uri)
{
	NautilusFile *file;

	GDK_THREADS_ENTER ();

	file = nautilus_file_get_by_uri ((char *) image_uri);
#ifdef DEBUG_THUMBNAILS
	g_message ("(Thumbnail Thread) Notifying file changed file:%p uri: %s\n", file, (char*) image_uri);
#endif

	if (file != NULL) {
		nautilus_file_set_is_thumbnailing (file, FALSE);
		nautilus_file_invalidate_attributes (file,
						     NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL |
						     NAUTILUS_FILE_ATTRIBUTE_INFO);
		nautilus_file_unref (file);
	}
	g_free (image_uri);

	GDK_THREADS_LEAVE ();

	return FALSE;
}
Ejemplo n.º 22
0
int
main (int argc, char **argv)
{
	GtkWidget *main_window;
	GtkTreeModel *main_model;
	GtkTreeIter iter;
	RBEntryView *view;
	RhythmDB *db;
	RhythmDBEntry *entry;

	gtk_init (&argc, &argv);
	gdk_threads_init ();
	rb_thread_helpers_init ();
	rb_file_helpers_init (TRUE);
	rb_stock_icons_init ();
	rb_debug_init (TRUE);

	GDK_THREADS_ENTER ();

	db = rhythmdb_tree_new ("test");

	rhythmdb_write_lock (db);

	entry = create_entry (db, "file:///sin.mp3",
			      "Sin", "Pretty Hate Machine", "Nine Inch Nails", "Rock");
	
	rhythmdb_write_unlock (db);

	rhythmdb_read_lock (db);

	main_model = GTK_TREE_MODEL (rhythmdb_query_model_new_empty (db));
	rhythmdb_do_full_query (db, main_model,
				RHYTHMDB_QUERY_PROP_EQUALS,
				RHYTHMDB_PROP_TYPE, RHYTHMDB_ENTRY_TYPE_IGNORE,
				RHYTHMDB_QUERY_END);

	wait_for_model_completion (RHYTHMDB_QUERY_MODEL (main_model));
	g_assert (gtk_tree_model_get_iter_first (main_model, &iter));

	main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

	view = rb_entry_view_new (db, rb_file ("rb-entry-view-library.xml"));

	rb_entry_view_set_query_model (view, RHYTHMDB_QUERY_MODEL (main_model));

	gtk_container_add (GTK_CONTAINER (main_window), GTK_WIDGET (view));

	g_signal_connect (G_OBJECT (main_window), "destroy",
			  G_CALLBACK (gtk_main_quit), NULL);

	gtk_widget_show_all (GTK_WIDGET (main_window));

	gtk_main ();
	
	rhythmdb_shutdown (db);
	g_object_unref (G_OBJECT (db));
	GDK_THREADS_LEAVE ();
	
	exit (0);
}
Ejemplo n.º 23
0
static void
thunar_uca_provider_child_watch (ThunarUcaProvider *uca_provider,
                                 gint               exit_status)

{
  GFileMonitor *monitor;
  GFile        *file;

  g_return_if_fail (THUNAR_UCA_IS_PROVIDER (uca_provider));

  GDK_THREADS_ENTER ();

  /* verify that we still have a valid child_watch_path */
  if (G_LIKELY (uca_provider->child_watch_path != NULL))
    {
      /* determine the corresponding file */
      file = g_file_new_for_path (uca_provider->child_watch_path);

      /* schedule a changed notification on the path */
      monitor = g_file_monitor (file, G_FILE_MONITOR_NONE, NULL, NULL);

      if (monitor != NULL)
        {
          g_file_monitor_emit_event (monitor, file, file, G_FILE_MONITOR_EVENT_CHANGED);
          g_object_unref (monitor);
        }

      /* release the file */
      g_object_unref (file);
    }

  thunar_uca_provider_child_watch_destroy (uca_provider, NULL);

  GDK_THREADS_LEAVE ();
}
Ejemplo n.º 24
0
static int timeout_func(gpointer data)
{
	int pos;
	gboolean playing;
	static char *previous_file = NULL;
	static gboolean cmd_after_already_run = FALSE;
	char *current_file;

	GDK_THREADS_ENTER();

	playing = xmms_remote_is_playing(sc_gp.xmms_session);
	pos = xmms_remote_get_playlist_pos(sc_gp.xmms_session);
	current_file = xmms_remote_get_playlist_file(sc_gp.xmms_session, pos);
	
	if ((pos != previous_song ||
	     (!previous_file && current_file) ||
	     (previous_file && !current_file) ||
	     (previous_file && current_file &&
	      strcmp(previous_file, current_file))) &&
	    xmms_remote_get_output_time(sc_gp.xmms_session) > 0)
	{
		do_command(cmd_line, current_file, pos);
		g_free(previous_file);
		previous_file = g_strdup(current_file);
		previous_song = pos;
		cmd_after_already_run = FALSE;
	}
	if (!cmd_after_already_run &&
	    ((xmms_remote_get_playlist_time(sc_gp.xmms_session,pos) -
	      xmms_remote_get_output_time(sc_gp.xmms_session)) < 100))
	{
		do_command(cmd_line_after, current_file, pos);
		cmd_after_already_run = TRUE;
	}

	if (playing)
	{
		int playlist_length = xmms_remote_get_playlist_length(sc_gp.xmms_session);
		if (pos + 1 == playlist_length)
			possible_pl_end = TRUE;
		else
			possible_pl_end = FALSE;
	}
	else if (possible_pl_end)
	{
		if (pos == 0)
			do_command(cmd_line_end, current_file, pos);
		possible_pl_end = FALSE;
		g_free(previous_file);
		previous_file = NULL;
	}

	g_free(current_file);
	current_file = NULL;

	GDK_THREADS_LEAVE();

	return TRUE;
}
Ejemplo n.º 25
0
static gpointer find_thread_entry( gpointer arg ) {
    find_context_t* fc = ( find_context_t* )arg;
    find_result_t result;
    pdf_tab_t* pdf_tab;

    pdf_tab = document_storage_get_tab_by_doc( fc->doc );

    if ( pdf_tab == NULL ) {
        return NULL;
    }

    while ( fc->running ) {
        g_mutex_lock( &fc->find_lock );

        if ( !fc->pending_request ) {
            g_cond_wait( &fc->find_cond, &fc->find_lock );
        }

        fc->pending_request = 0;

        g_mutex_unlock( &fc->find_lock );

        if ( !fc->running ) {
            break;
        }

        result = find_next( fc );

        if ( !fc->running ) {
            break;
        }

        GDK_THREADS_ENTER();

        if ( result == FIND_NONE ) {
            doctab_set_search_status( pdf_tab, SEARCH_STATUS_NONE );
        } else {
            if ( result == FIND_OK ) {
                doctab_set_search_status( pdf_tab, SEARCH_STATUS_CLEAR );
            }

            if ( result == FIND_OK_WRAPPED ) {
                doctab_set_search_status( pdf_tab, SEARCH_STATUS_WRAPPED );
            }

            gtk_pdfview_set_highlight(
                pdf_tab->pdf_view,
                fc->page_index,
                ( PopplerRectangle* )fc->match->data
            );
        }

        GDK_THREADS_LEAVE();
    }

    find_context_destroy( fc );

    return NULL;
}
Ejemplo n.º 26
0
static gboolean close_fftscope_window(GtkWidget *widget, GdkEvent *event, gpointer data)
{
	GDK_THREADS_LEAVE();
	stop_fftscope();
	GDK_THREADS_ENTER();

	return TRUE;
}
Ejemplo n.º 27
0
static gboolean
xfce_panel_image_load (gpointer data)
{
  XfcePanelImagePrivate *priv = XFCE_PANEL_IMAGE (data)->priv;
  GdkPixbuf             *pixbuf;
  GdkScreen             *screen;
  GtkIconTheme          *icon_theme = NULL;
  gint                   dest_w, dest_h;

  GDK_THREADS_ENTER ();

  dest_w = priv->width;
  dest_h = priv->height;

  if (G_UNLIKELY (priv->force_icon_sizes
      && dest_w < 32
      && dest_w == dest_h))
    {
      /* we use some hardcoded values here for convienence,
       * above 32 pixels svg icons will kick in */
      if (dest_w > 16 && dest_w < 22)
        dest_w = 16;
      else if (dest_w > 22 && dest_w < 24)
        dest_w = 22;
      else if (dest_w > 24 && dest_w < 32)
        dest_w = 24;

      dest_h = dest_w;
    }

  if (priv->pixbuf != NULL)
    {
      /* use the pixbuf set by the user */
      pixbuf = g_object_ref (G_OBJECT (priv->pixbuf));

      if (G_LIKELY (pixbuf != NULL))
        {
          /* scale the icon to the correct size */
          priv->cache = xfce_panel_image_scale_pixbuf (pixbuf, dest_w, dest_h);
          g_object_unref (G_OBJECT (pixbuf));
        }
    }
  else
    {
      screen = gtk_widget_get_screen (GTK_WIDGET (data));
      if (G_LIKELY (screen != NULL))
        icon_theme = gtk_icon_theme_get_for_screen (screen);

      priv->cache = xfce_panel_pixbuf_from_source_at_size (priv->source, icon_theme, dest_w, dest_h);
    }

  if (G_LIKELY (priv->cache != NULL))
    gtk_widget_queue_draw (GTK_WIDGET (data));

  GDK_THREADS_LEAVE ();

  return FALSE;
}
Ejemplo n.º 28
0
static void
canvas_source_set_position (BstCanvasSource *self)
{
  gboolean idle_reposition = self->idle_reposition;
  GDK_THREADS_LEAVE ();
  idle_move_item (g_object_ref (self));
  GDK_THREADS_ENTER ();
  self->idle_reposition = idle_reposition;
}
Ejemplo n.º 29
0
static void 
nsp_app_feeds_search(void* user_data)
{
	NspApp *app = nsp_app_get();
	NspFeed *feed = nsp_feed_new();
	GtkTreeIter iter;
	GRegex *regex;
	char *new_feed_title = "Search results";
	char *search_exp;
	char *tmp;
	
	feed->title = malloc(sizeof(char)*(strlen(new_feed_title) + 1));
	memcpy(feed->title, new_feed_title, sizeof(char)*(strlen(new_feed_title)+1));
	
	/* Build search term and load results */
	regex = g_regex_new ("(%|_)", 0, 0, NULL);
	tmp = g_regex_replace(regex, (char*)user_data, -1, 0, "\\\\\\0", 0, NULL);
	g_regex_unref(regex);
	
	regex = g_regex_new ("[ \t]+", 0, 0, NULL);
	search_exp = g_regex_replace(regex, tmp, -1, 0, "%", 0, NULL);
	g_regex_unref(regex);
	g_free(tmp);
	
	feed->items = nsp_feed_items_search(search_exp);
	
	/* Update front-end */
	GDK_THREADS_ENTER();
	nsp_feed_update_model(feed);
	gtk_tree_view_set_model(GTK_TREE_VIEW(app->window->feed_item_list), nsp_feed_get_items_model(feed));
	GDK_THREADS_LEAVE();
	
	
	GDK_THREADS_ENTER();
	iter = nsp_feed_list_add(app->window->feed_list, feed, true);
	gtk_tree_store_set (GTK_TREE_STORE(app->window->feed_list->list_model), &iter,
					LIST_COL_ICON, app->window->feed_list->icon_search,
					-1);
	
	app->feeds = g_list_append(app->feeds, feed);
	
	gtk_tree_view_set_cursor(GTK_TREE_VIEW(app->window->feed_list->list_view), gtk_tree_model_get_path(app->window->feed_list->list_model, &iter), NULL, FALSE);
	GDK_THREADS_LEAVE();
}
Ejemplo n.º 30
0
static void on_stop_search( GtkWidget* btn, FindFile* data )
{
    if( data->task && ! vfs_async_task_is_finished( data->task ) )
    {
        // see note in vfs-async-task.c: vfs_async_task_real_cancel()
        GDK_THREADS_LEAVE(); 
        vfs_async_task_cancel( data->task );
        GDK_THREADS_ENTER();
    }
}