示例#1
1
int
main (int argc, char **argv)
{
  GtkStatusIcon *icon;

  gtk_init (&argc, &argv);

  icon = gtk_status_icon_new ();

  g_signal_connect (icon, "size-changed", G_CALLBACK (size_changed_cb), NULL);
  g_signal_connect (icon, "notify::embedded", G_CALLBACK (embedded_changed_cb), NULL);
  g_signal_connect (icon, "notify::orientation", G_CALLBACK (orientation_changed_cb), NULL);
  g_signal_connect (icon, "notify::screen", G_CALLBACK (screen_changed_cb), NULL);
  g_print ("icon size %d\n", gtk_status_icon_get_size (icon));

  g_signal_connect (icon, "activate",
                    G_CALLBACK (icon_activated), NULL);

  g_signal_connect (icon, "popup-menu",
                    G_CALLBACK (popup_menu), NULL);

  icons = g_slist_append (icons, icon);

  update_icon ();

  timeout = gdk_threads_add_timeout (2000, timeout_handler, icon);

  gtk_main ();

  return 0;
}
示例#2
0
void gui_animate_play(void)
{
gint t;
struct model_pak *model;

model = tree_model_get();
if (model)
  {
  model->animating = TRUE;

/* increase alpha to make the drop sharper moving to higher resolutions */
#define SCALE_ALPHA 0.08
#define DELAY_MIN 5
#define DELAY_MAX 100

/* NB: phonon resolution range: [1,100] */
/*
x = SCALE_ALPHA * (sysenv.render.phonon_resolution-1.0);
x = DELAY_MAX * pow(10.0, -x);
t = CLAMP(x, DELAY_MIN, DELAY_MAX);
*/

/* CURRENT - use desired FPS to get timeout value (ms) */
t = 1000 / gui_animate_fps;

//printf("anim : %f -> %d\n", sysenv.render.phonon_resolution, t);

  if (animate_phonons)
    {
    model->pulse_count = 0;
    model->pulse_direction = 1;
/* hide eigenvectors while animating */
    spatial_destroy_by_label("phonons", model);

/* HACK - quick fix to better align phonon animation with resulting movie */
/* FIXME - work it out properly */
t *= 4.0 / sysenv.render.phonon_resolution;

#if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 12
    gdk_threads_add_timeout(t, (GSourceFunc) &gui_phonon_loop, NULL);
#else
    g_timeout_add(t, (GSourceFunc) &gui_phonon_loop, NULL);
#endif
    }
  else
    {
#if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 12
    gdk_threads_add_timeout(t, (GSourceFunc) &gui_frame_loop, NULL);
#else
    g_timeout_add(t, (GSourceFunc) &gui_frame_loop, NULL);
#endif
    }
  }
}
示例#3
0
/**
 * fm_file_ops_job_run_with_progress
 * @parent: parent window to show dialog over it
 * @job: (transfer full): job descriptor to run
 *
 * Runs the file operation job with a progress dialog.
 * The returned data structure will be freed in idle handler automatically
 * when it's not needed anymore.
 *
 * NOTE: INCONSISTENCY: it takes a reference from job
 *
 * Before 0.1.15 this call had different arguments.
 *
 * Return value: (transfer none): progress data; not usable; caller should not free it either.
 *
 * Since: 0.1.0
 */
FmProgressDisplay* fm_file_ops_job_run_with_progress(GtkWindow* parent, FmFileOpsJob* job)
{
    FmProgressDisplay* data;

    g_return_val_if_fail(job != NULL, NULL);

    data = g_slice_new0(FmProgressDisplay);
    data->job = job;
    if(parent)
        data->parent = g_object_ref(parent);
    data->delay_timeout = gdk_threads_add_timeout(SHOW_DLG_DELAY, on_show_dlg, data);

    g_signal_connect(job, "ask", G_CALLBACK(on_ask), data);
    g_signal_connect(job, "ask-rename", G_CALLBACK(on_ask_rename), data);
    g_signal_connect(job, "error", G_CALLBACK(on_error), data);
    g_signal_connect(job, "prepared", G_CALLBACK(on_prepared), data);
    g_signal_connect(job, "cur-file", G_CALLBACK(on_cur_file), data);
    g_signal_connect(job, "percent", G_CALLBACK(on_percent), data);
    g_signal_connect(job, "finished", G_CALLBACK(on_finished), data);
    g_signal_connect(job, "cancelled", G_CALLBACK(on_cancelled), data);

    if (!fm_job_run_async(FM_JOB(job)))
    {
        fm_progress_display_destroy(data);
        return NULL;
    }

    return data;
}
示例#4
0
static void
update_play_button (GthMediaViewerPage *self,
		    GstState            new_state)
{
	if (! self->priv->playing && (new_state == GST_STATE_PLAYING)) {
		self->priv->playing = TRUE;
		gtk_image_set_from_stock (GTK_IMAGE (GET_WIDGET ("button_play_image")), GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_LARGE_TOOLBAR);
		gtk_widget_set_tooltip_text (GET_WIDGET ("button_play_image"), _("Pause"));

		if (self->priv->update_progress_id == 0)
			self->priv->update_progress_id = gdk_threads_add_timeout (PROGRESS_DELAY, update_progress_cb, self);
	}
	else if (self->priv->playing && (new_state != GST_STATE_PLAYING)) {
		self->priv->playing = FALSE;
		gtk_image_set_from_stock (GTK_IMAGE (GET_WIDGET ("button_play_image")), GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_LARGE_TOOLBAR);
		gtk_widget_set_tooltip_text (GET_WIDGET ("button_play_image"), _("Play"));

		if (self->priv->update_progress_id != 0) {
			 g_source_remove (self->priv->update_progress_id);
			 self->priv->update_progress_id = 0;
		}
	}

	gth_viewer_page_update_sensitivity (GTH_VIEWER_PAGE (self));
}
示例#5
0
static void
gtk_gesture_long_press_begin (GtkGesture       *gesture,
                              GdkEventSequence *sequence)
{
  GtkGestureLongPressPrivate *priv;
  const GdkEvent *event;
  GtkWidget *widget;
  gint delay;

  priv = gtk_gesture_long_press_get_instance_private (GTK_GESTURE_LONG_PRESS (gesture));
  sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
  event = gtk_gesture_get_last_event (gesture, sequence);

  if (!event ||
      (event->type != GDK_BUTTON_PRESS &&
       event->type != GDK_TOUCH_BEGIN))
    return;

  widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
  g_object_get (gtk_widget_get_settings (widget),
                "gtk-long-press-time", &delay,
                NULL);

  delay = (gint)(priv->delay_factor * delay);

  gtk_gesture_get_point (gesture, sequence,
                         &priv->initial_x, &priv->initial_y);
  priv->timeout_id =
    gdk_threads_add_timeout (delay,
                             _gtk_gesture_long_press_timeout,
                             gesture);
}
示例#6
0
static gboolean
gd_notification_visibility_notify_event (GtkWidget          *widget,
                                          GdkEventVisibility  *event)
{
  GdNotification *notification = GD_NOTIFICATION (widget);
  GdNotificationPrivate *priv = notification->priv;

  if (!gtk_widget_get_visible (widget))
    return FALSE;

  if (priv->waiting_for_viewable)
    {
      start_animation (notification);
      priv->waiting_for_viewable = FALSE;
    }

  if (notification->priv->timeout_source_id == 0 &&
      notification->priv->timeout != -1)
    notification->priv->timeout_source_id =
      gdk_threads_add_timeout (notification->priv->timeout * 1000,
                               gd_notification_timeout_cb,
                               widget);

  return FALSE;
}
static gboolean
cb_button_press (GtkWidget      *widget,
		 GdkEventButton *event,
		 gpointer        user_data)
{
  GtkScaleButton *button;
  GtkScaleButtonPrivate *priv;
  GtkAdjustment *adj;

  button = GTK_SCALE_BUTTON (user_data);
  priv = button->priv;
  adj = priv->adjustment;

  if (priv->click_id != 0)
    g_source_remove (priv->click_id);

  if (widget == button->plus_button)
    priv->direction = fabs (adj->page_increment);
  else
    priv->direction = - fabs (adj->page_increment);

  priv->click_id = gdk_threads_add_timeout (priv->click_timeout,
                                            cb_button_timeout,
                                            button);
  cb_button_timeout (button);

  return TRUE;
}
示例#8
0
文件: callbacks.c 项目: linuxmint/pix
static gboolean
gth_file_list_drag_motion (GtkWidget      *file_view,
			   GdkDragContext *context,
			   gint            x,
			   gint            y,
			   guint           time,
			   gpointer        extra_data)
{
	GthBrowser  *browser = extra_data;
	BrowserData *data;
	GthFileData *location_data;

	data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
	data->drop_pos = -1;

	if ((gtk_drag_get_source_widget (context) == file_view) && ! gth_file_source_is_reorderable (gth_browser_get_location_source (browser))) {
		gdk_drag_status (context, 0, time);
		return FALSE;
	}

	location_data = gth_browser_get_location_data (browser);
	if (! g_file_info_get_attribute_boolean (location_data->info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
		gdk_drag_status (context, 0, time);
		return FALSE;
	}

	if (gth_file_source_is_reorderable (gth_browser_get_location_source (browser))) {
		GtkAllocation allocation;

		if (gtk_drag_get_source_widget (context) == file_view)
			gdk_drag_status (context, GDK_ACTION_MOVE, time);
		else
			gdk_drag_status (context, GDK_ACTION_COPY, time);
		gth_file_view_set_drag_dest_pos (GTH_FILE_VIEW (file_view), context, x, y, time, &data->drop_pos);

		gtk_widget_get_allocation (file_view, &allocation);

		if (y < 10)
			data->scroll_diff = - (10 - y);
		else if (y > allocation.height - 10)
			data->scroll_diff = (10 - (allocation.height - y));
		else
			data->scroll_diff = 0;

		if (data->scroll_diff != 0) {
			if (data->scroll_event == 0)
				data->scroll_event = gdk_threads_add_timeout (SCROLL_TIMEOUT, drag_motion_autoscroll_cb, browser);
		}
		else if (data->scroll_event != 0) {
			g_source_remove (data->scroll_event);
			data->scroll_event = 0;
		}
	}
	else if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_ASK)
		gdk_drag_status (context, GDK_ACTION_ASK, time);
	else
		gdk_drag_status (context, GDK_ACTION_COPY, time);

	return TRUE;
}
示例#9
0
/* show a scan finger dialog */
void run_scan_finger_dialog(GtkWidget *dialog)
{
	guint id;
	gtk_widget_show_all(dialog);
	id = gdk_threads_add_timeout(100, scan_finger_pulse_progress, dialog);
	g_object_set_data(G_OBJECT(dialog), "pulsesource", GUINT_TO_POINTER(id));
}
示例#10
0
static void
on_animate (void)
{
  n_animations += 20;
 
  timer = gdk_threads_add_timeout (1000, (GSourceFunc) animation_timer, NULL);
}
示例#11
0
static void
task_progress_cb (GthTask    *task,
		  const char *description,
		  const char *details,
		  gboolean    pulse,
		  double      fraction,
		  gpointer    user_data)
{
	GthTaskProgress *self = user_data;

	if (description != NULL)
		gtk_label_set_text (GTK_LABEL (self->description_label), description);
	if (details != NULL)
		gtk_label_set_text (GTK_LABEL (self->details_label), details);
	if (pulse) {
		gtk_progress_bar_pulse (GTK_PROGRESS_BAR (self->fraction_progressbar));
		if (self->pulse_event == 0)
			self->pulse_event = gdk_threads_add_timeout (PULSE_INTERVAL, task_pulse_cb, self);
	}
	else {
		if (self->pulse_event != 0) {
			g_source_remove (self->pulse_event);
			self->pulse_event = 0;
		}
		gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->fraction_progressbar), fraction);
	}
}
static void
check_hover_timer (NautilusTreeViewDragDest *dest,
                   const char               *uri)
{
    GtkSettings *settings;
    guint timeout;

    if (g_strcmp0 (uri, dest->details->target_uri) == 0) {
        return;
    }
    remove_hover_timer (dest);

    settings = gtk_widget_get_settings (GTK_WIDGET (dest->details->tree_view));
    g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);

    g_free (dest->details->target_uri);
    dest->details->target_uri = NULL;

    if (uri != NULL) {
        dest->details->target_uri = g_strdup (uri);
        dest->details->hover_id =
            gdk_threads_add_timeout (timeout,
                                     hover_timer,
                                     dest);
    }
}
示例#13
0
/*!
 \brief start_tickler() starts up a GTK+ timeout function based on the
 enum passed to it.
 \param type (TicklerType enum) is an enum passed which is used to know 
 which timeout to fire up.
 \see signal_read_rtvars_thread signal_read_rtvars
 */
G_MODULE_EXPORT void start_tickler(TicklerType type)
{
	gint id = 0;
	GThread *realtime_id = NULL;
	switch (type)
	{
		case RTV_TICKLER:
			if (DATA_GET(global_data,"offline"))
				break;
			if (!DATA_GET(global_data,"rtvars_loaded"))
				break;
			if (DATA_GET(global_data,"restart_realtime"))
			{
				update_logbar("comms_view",NULL,_("TTM is active, Realtime Reader suspended\n"),FALSE,FALSE,FALSE);
				break;
			}
			if (!DATA_GET(global_data,"realtime_id"))
			{
				flush_rt_arrays();

				realtime_id = g_thread_create(signal_read_rtvars_thread,
						NULL, /* Thread args */
						TRUE, /* Joinable */
						NULL); /*GError Pointer */
				DATA_SET(global_data,"realtime_id",realtime_id);
				update_logbar("comms_view",NULL,_("Realtime Reader started\n"),FALSE,FALSE,FALSE);
			}
			else
				update_logbar("comms_view","warning",_("Realtime Reader ALREADY started\n"),FALSE,FALSE,FALSE);
			break;
		case LV_PLAYBACK_TICKLER:
			if (!DATA_GET(global_data,"playback_id"))
			{
				id = gdk_threads_add_timeout((GINT)DATA_GET(global_data,"lv_scroll_delay"),(GSourceFunc)pb_update_logview_traces,GINT_TO_POINTER(FALSE));
				DATA_SET(global_data,"playback_id",GINT_TO_POINTER(id));
			}
			else
				dbg_func(CRITICAL,g_strdup(__FILE__": start_tickler()\n\tPlayback already running \n"));
			break;
		case SCOUNTS_TICKLER:
			if (DATA_GET(global_data,"offline"))
				break;
			if (!((DATA_GET(global_data,"connected")) && 
						(DATA_GET(global_data,"interrogated"))))
				break;
			if (!DATA_GET(global_data,"statuscounts_id"))
			{
				id = g_timeout_add(100,(GSourceFunc)update_errcounts,NULL);
				DATA_SET(global_data,"statuscounts_id",GINT_TO_POINTER(id));
			}
			else
				dbg_func(CRITICAL,g_strdup(__FILE__": start_tickler()\n\tStatuscounts tickler already active \n"));
			break;
		default:
			/* Search for registered handlers from plugins */
			break;

	}
}
示例#14
0
G_MODULE_EXPORT gboolean check_for_first_time(void)
{
	if (DATA_GET(global_data,"first_time"))
		printf("should run first_time_wizard\n");
        gdk_threads_add_timeout(100,(GSourceFunc)personality_choice,NULL);
	return FALSE;

}
示例#15
0
void LayerObject::show(gdouble x, gdouble y, bool delay) {
	if(delay)
		timerID = gdk_threads_add_timeout(500, lo_timer_proc, this);
	else {
		visible = true;
		invalidate();
	}
}
示例#16
0
/* [user thread] */
void _al_append_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog)
{
   if (textlog->tl_have_pending)
      return;
   textlog->tl_have_pending = true;

   gdk_threads_add_timeout(100, do_append_native_text_log, textlog);
}
示例#17
0
static void on_percent(FmFileOpsJob* job, guint percent, FmProgressDisplay* data)
{
    data->data_transferred_size = job->finished;
    data->data_total_size = job->total;
    data->percent = percent;
    if(data->dlg && data->update_timeout == 0)
        data->update_timeout = gdk_threads_add_timeout(500, on_update_dlg, data);
}
示例#18
0
/* [user thread] */
void _al_close_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog)
{
   gdk_threads_add_timeout(0, do_close_native_text_log, textlog);

   while (g_async_queue_pop(textlog->async_queue) != ACK_CLOSED)
      ;
   g_async_queue_unref(textlog->async_queue);
   textlog->async_queue = NULL;
}
示例#19
0
static void
img_cell_renderer_anim_render( GtkCellRenderer      *cell,
							   GdkDrawable          *window,
							   GtkWidget            *widget,
							   GdkRectangle         *background_a,
							   GdkRectangle         *cell_a,
							   GdkRectangle         *expose_a,
							   GtkCellRendererState  state )
{
	ImgCellRendererAnimPrivate *priv;
	GdkPixbufAnimationIter     *iter;
	GdkPixbuf                  *pixbuf;
	cairo_t                    *cr;
	GdkRectangle                rect,
								draw_rect;

	priv = IMG_CELL_RENDERER_ANIM_GET_PRIVATE ( cell );

	/* Get image size */
	img_cell_renderer_anim_get_size( cell, widget, cell_a, &rect.x,
									 &rect.y, &rect.width, &rect.height );
	rect.x += cell_a->x + cell->xpad;
	rect.y += cell_a->y + cell->ypad;
	rect.width  -= 2 * cell->xpad;
	rect.height -= 2 * cell->ypad;

	/* Check for overlaping */
	if( ! gdk_rectangle_intersect( cell_a, &rect, &draw_rect ) ||
		! gdk_rectangle_intersect( expose_a, &draw_rect, &draw_rect ) )
		return;

	/* Draw indicators */
	cr = gdk_cairo_create( window );

	/* Draw the current frame of the GdkPixbufAnimation */
	iter = g_object_get_data( G_OBJECT( priv->anim ), "iter" );
	if( ! iter )
	{
		gint delay;

		/* Initialiize iter */
		iter = gdk_pixbuf_animation_get_iter( priv->anim, NULL );
		g_object_set_data_full( G_OBJECT( priv->anim ), "iter", iter,
								(GDestroyNotify)g_object_unref );

		/* Install timeout */
		delay = gdk_pixbuf_animation_iter_get_delay_time( iter );
		gdk_threads_add_timeout( delay, (GSourceFunc)cb_timeout, iter );
	}
	g_object_set_data( G_OBJECT( iter ), "widget", widget );
	pixbuf = gdk_pixbuf_animation_iter_get_pixbuf( iter );
	gdk_cairo_set_source_pixbuf( cr, pixbuf, rect.x, rect.y );
	gdk_cairo_rectangle( cr, &draw_rect );
	cairo_fill( cr );

	cairo_destroy( cr );
}
示例#20
0
G_MODULE_EXPORT void on_cellrenderertoggle_loaded_toggled(GtkCellRendererToggle *cell,
                                                          gchar *path_str,
                                                          worddic *worddic){
  GtkTreeView *treeview = (GtkTreeView*)gtk_builder_get_object(worddic->definitions, 
                                                               "treeview_dic");
  GtkListStore *model = (GtkListStore*)gtk_builder_get_object(worddic->definitions, 
                                                              "liststore_dic");
  GtkTreeIter  iter;
  GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
  gboolean loaded;

  //get the loaded variable from the tree model
  gtk_tree_model_get_iter (GTK_TREE_MODEL(model), &iter, path);
  gtk_tree_model_get (GTK_TREE_MODEL(model), &iter, COL_LOADED, &loaded, -1);

  //get the dicfile index from UI
  gint index = gtk_tree_path_get_indices(path)[0];
  gtk_tree_path_free (path);

  //get the dicfile from index
  GSList *selected_element = g_slist_nth(worddic->conf->dicfile_list, index);
  WorddicDicfile *dicfile = selected_element->data;

  //load in memory the entries 
  if(!loaded){
    //set the cell state activatable to false to avoid double clicks
    //and inconsistent to true to display current state
    g_object_set(cell, "activatable", FALSE, "inconsistent", TRUE, NULL);
  
    //load all dictionarie entries in a thread
    GError *error = NULL;

    GtkTreeView *treeview = (GtkTreeView*)gtk_builder_get_object(worddic->definitions, 
                                                                 "treeview_dic");
    //Create new thread
    worddic->thread_load_dic = g_thread_new ("Load dicfile",
                                             (GThreadFunc)proxy_worddic_dicfile_parse_all,
                                             dicfile);

    //update the UI every N MiliSeconds
    dic_state_ui *ui = g_new0(dic_state_ui, 1);
    ui->cell = cell;
    ui->treeview = treeview;
    gdk_threads_add_timeout( 500, (GSourceFunc)cb_load_dic_timeout, ui);
  }
  else{
    worddic_dicfile_free_entries(dicfile);
  }

  //reverse the loaded state
  loaded ^= 1;
  //save the new loaded state in the dicfile, list_store and conf
  gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_LOADED, loaded, -1);
  dicfile->is_loaded = loaded;
  worddic_conf_save(worddic->settings, worddic->conf);

}
static gboolean
hildon_time_picker_arrow_press                  (GtkWidget *widget, 
                                                 GdkEvent *event,
                                                 HildonTimePicker *picker)
{
    HildonTimePickerPrivate *priv = HILDON_TIME_PICKER_GET_PRIVATE (picker);
    gint i, button;
    gint newval = 0;
    gint key_repeat = 0;

    /* Make sure we don't add repeat timer twice. Normally it shouldn't
       happen but WM can cause button release to be lost. */
    if (priv->button_press )
        return FALSE;

    priv->start_key_repeat = priv->button_press = TRUE;

    /* Find the widget which was clicked */
    priv->mul = 0;
    for (i = 0; i < WIDGET_GROUP_COUNT; i++)
    {
        for (button = 0; button < BUTTON_COUNT; button++)
        {
            if (priv->widgets[i].buttons[button] == widget)
            {
                /* Update multiplier and move the focus to the clicked field */
                priv->mul = button_multipliers[i][button];
                gtk_widget_grab_focus (priv->widgets[i].eventbox);
                break;
            }
        }
    }
    g_assert (priv->mul != 0);

    /* Change the time now, wrapping if needed. */
    newval = priv->minutes + priv->mul;
    if( newval < 0 )
        newval += MINS_IN_24H;

    hildon_time_picker_change_time (picker, newval);

    /* Get button press repeater timeout from settings (in milliseconds) */
    g_object_get (gtk_widget_get_settings (widget), 
                    "gtk-timeout-repeat", &key_repeat, NULL);

    key_repeat *= 8;

    /* Keep changing the time as long as button is being pressed.
       The first repeat takes 3 times longer to start than the rest. */
    
    priv->timer_id = gdk_threads_add_timeout (key_repeat * 3,
            hildon_time_picker_key_repeat_timeout,
            picker);

    return FALSE;
}
示例#22
0
static void on_cur_file(FmFileOpsJob* job, const char* cur_file, FmProgressDisplay* data)
{
    g_free(data->cur_file);
    data->cur_file = g_strdup(cur_file);
    /* NOTE: Displaying currently processed file will slow down the
     * operation and waste CPU source due to showing the text with pango.
     * Consider showing current file every 0.5 second. */
    if(data->dlg && data->update_timeout == 0)
        data->update_timeout = gdk_threads_add_timeout(500, on_update_dlg, data);
}
示例#23
0
static void 
hildon_banner_ensure_timeout                    (HildonBanner *self)
{
    HildonBannerPrivate *priv = HILDON_BANNER_GET_PRIVATE (self);
    g_assert (priv);

    if (priv->timeout_id == 0 && priv->is_timed && priv->timeout > 0)
        priv->timeout_id = gdk_threads_add_timeout (priv->timeout,
                hildon_banner_timeout, self);
}
示例#24
0
static void
row_deleted_cb (GtkTreeModel *tree_model,
		GtkTreePath  *path,
		gpointer      user_data)
{
	GthMetadataChooser *self = user_data;

	if (self->priv->changed_id != 0)
		g_source_remove (self->priv->changed_id);
	self->priv->changed_id = gdk_threads_add_timeout (ORDER_CHANGED_DELAY, order_changed, self);
}
示例#25
0
int
main (int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *vbox;
    GtkWidget *scrolled_window;
    GtkWidget *tree_view;
    GtkWidget *hbox;
    GtkWidget *button;
    GtkTreePath *path;

    gtk_init (&argc, &argv);

    path = gtk_tree_path_new_from_string ("80");
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title (GTK_WINDOW (window), "Reflow test");
    g_signal_connect (window, "destroy", gtk_main_quit, NULL);
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
    gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Incremental Reflow Test"), FALSE, FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    scrolled_window = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                                    GTK_POLICY_AUTOMATIC,
                                    GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);

    initialize_model ();
    tree_view = gtk_tree_view_new_with_model (model);
    gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view), path, NULL, TRUE, 0.5, 0.0);
    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
    gtk_tree_selection_select_path (selection, path);
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
    gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
            -1,
            NULL,
            gtk_cell_renderer_text_new (),
            "text", TEXT_COLUMN,
            NULL);
    gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    button = gtk_button_new_with_mnemonic ("<b>_Futz!!</b>");
    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
    gtk_label_set_use_markup (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), TRUE);
    g_signal_connect (button, "clicked", G_CALLBACK (futz), NULL);
    g_signal_connect (button, "realize", G_CALLBACK (gtk_widget_grab_focus), NULL);
    gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
    gtk_widget_show_all (window);
    gdk_threads_add_timeout (1000, (GSourceFunc) futz, NULL);
    gtk_main ();
    return 0;
}
示例#26
0
文件: testdnd.c 项目: BYC/gtk
gboolean
popsite_motion	   (GtkWidget	       *widget,
		    GdkDragContext     *context,
		    gint                x,
		    gint                y,
		    guint               time)
{
  if (!popup_timer)
    popup_timer = gdk_threads_add_timeout (500, popup_cb, NULL);

  return TRUE;
}
示例#27
0
static void
gtk_expander_start_animation (GtkExpander *expander)
{
  GtkExpanderPrivate *priv = expander->priv;

  if (priv->animation_timeout)
    g_source_remove (priv->animation_timeout);

  priv->animation_timeout =
		gdk_threads_add_timeout (50,
			       (GSourceFunc) gtk_expander_animation_timeout,
			       expander);
}
示例#28
0
static void
timeout_toggle_toggled (GtkToggleButton *toggle)
{
  if (timeout)
    {
      g_source_remove (timeout);
      timeout = 0;
    }
  else
    {
      timeout = gdk_threads_add_timeout (2000, timeout_handler, NULL);
    }
}
示例#29
0
文件: testdnd.c 项目: BYC/gtk
gboolean
popup_cb (gpointer data)
{
  if (!popped_up)
    {
      if (!popup_window)
	{
	  GtkWidget *button;
	  GtkWidget *table;
	  int i, j;
	  
	  popup_window = gtk_window_new (GTK_WINDOW_POPUP);
	  gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_MOUSE);

	  table = gtk_table_new (3,3, FALSE);

	  for (i=0; i<3; i++)
	    for (j=0; j<3; j++)
	      {
		char buffer[128];
		g_snprintf(buffer, sizeof(buffer), "%d,%d", i, j);
		button = gtk_button_new_with_label (buffer);
		gtk_table_attach (GTK_TABLE (table), button, i, i+1, j, j+1,
				  GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
				  0, 0);

		gtk_drag_dest_set (button,
				   GTK_DEST_DEFAULT_ALL,
				   target_table, n_targets - 1, /* no rootwin */
				   GDK_ACTION_COPY | GDK_ACTION_MOVE);
		g_signal_connect (button, "drag_motion",
				  G_CALLBACK (popup_motion), NULL);
		g_signal_connect (button, "drag_leave",
				  G_CALLBACK (popup_leave), NULL);
	      }

	  gtk_widget_show_all (table);
	  gtk_container_add (GTK_CONTAINER (popup_window), table);

	}
      gtk_widget_show (popup_window);
      popped_up = TRUE;
    }

  popdown_timer = gdk_threads_add_timeout (500, popdown_cb, NULL);
  g_print ("added popdown\n");

  popup_timer = FALSE;

  return FALSE;
}
示例#30
0
文件: images.c 项目: Rjdunwoody91/gtk
static void
start_progressive_loading (GtkWidget *image)
{
  /* This is obviously totally contrived (we slow down loading
   * on purpose to show how incremental loading works).
   * The real purpose of incremental loading is the case where
   * you are reading data from a slow source such as the network.
   * The timeout simply simulates a slow data source by inserting
   * pauses in the reading process.
   */
  load_timeout = gdk_threads_add_timeout (150,
                                progressive_timeout,
                                image);
}