/**
 * rb_removable_media_manager_scan:
 * @manager: the #RBRemovableMediaManager
 *
 * Initiates a new scan of all attached media.  Newly activated plugins that use
 * the create-source-volume or create-source-mount signals should call this if
 * the 'scanned' property is %TRUE.  Otherwise, the first scan will catch any
 * existing volumes or mounts that the plugin is interested in.
 */
void
rb_removable_media_manager_scan (RBRemovableMediaManager *manager)
{
	RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (manager);
	GHashTableIter iter;
	GList *list, *it;
	gpointer hkey, hvalue;

	priv->scanned = TRUE;

	/* check volumes first */
	list = g_volume_monitor_get_volumes (priv->volume_monitor);

	/* - check for volumes that have disappeared */
	g_hash_table_iter_init (&iter, priv->volume_mapping);
	while (g_hash_table_iter_next (&iter, &hkey, &hvalue)) {
		GVolume *volume = G_VOLUME (hkey);

		if (g_list_index (list, volume) == -1) {
			/* volume has vanished */
			rb_removable_media_manager_remove_volume (manager, volume);
		}
	}

	/* - check for newly added volumes */
	for (it = list; it != NULL; it = g_list_next (it)) {
		GVolume *volume = G_VOLUME (it->data);
		rb_removable_media_manager_add_volume (manager, volume);
		g_object_unref (volume);
	}
	g_list_free (list);

	/* check mounts */
	list = g_volume_monitor_get_mounts (priv->volume_monitor);

	/* - check for mounts that have disappeared */
	g_hash_table_iter_init (&iter, priv->mount_mapping);
	while (g_hash_table_iter_next (&iter, &hkey, &hvalue)) {
		GMount *mount = G_MOUNT (hkey);

		if (g_list_index (list, mount) == -1) {
			rb_removable_media_manager_remove_mount (manager, mount);
		}
	}

	/* - check for newly added mounts */
	for (it = list; it != NULL; it = g_list_next (it)) {
		GMount *mount = G_MOUNT (it->data);
		rb_removable_media_manager_add_mount (manager, mount);
		g_object_unref (mount);
	}
	g_list_free (list);

	/* - check devices */
#if defined(HAVE_GUDEV)
	list = g_udev_client_query_by_subsystem (priv->gudev_client, "usb");
	for (it = list; it != NULL; it = g_list_next (it)) {
		/* pretend the device was just added */
		uevent_cb (priv->gudev_client, "add", G_UDEV_DEVICE (it->data), manager);
	}
	g_list_free (list);
#endif
}
示例#2
0
static void update(dt_lib_module_t *user_data, gboolean early_bark_out)
{
//   early_bark_out = FALSE; // FIXME: when barking out early we don't update on ctrl-a/ctrl-shift-a. but otherwise it's impossible to edit text
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
  dt_lib_metadata_t *d  = (dt_lib_metadata_t *)self->data;
  int imgsel = dt_control_get_mouse_over_id();
  if(early_bark_out && imgsel == d->imgsel)
    return;

  d->imgsel = imgsel;

  sqlite3_stmt *stmt;

  GList *title       = NULL;
  uint32_t title_count       = 0;
  GList *description = NULL;
  uint32_t description_count = 0;
  GList *creator     = NULL;
  uint32_t creator_count     = 0;
  GList *publisher   = NULL;
  uint32_t publisher_count   = 0;
  GList *rights      = NULL;
  uint32_t rights_count     = 0;

  // using dt_metadata_get() is not possible here. we want to do all this in a single pass, everything else takes ages.
  if(imgsel < 0)  // selected images
  {
    DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), "select key, value from meta_data where id in (select imgid from selected_images) group by key, value order by value", -1, &stmt, NULL);
  }
  else     // single image under mouse cursor
  {
    char query[1024];
    snprintf(query, sizeof(query), "select key, value from meta_data where id = %d group by key, value order by value", imgsel);
    DT_DEBUG_SQLITE3_PREPARE_V2(dt_database_get(darktable.db), query, -1, &stmt, NULL);
  }
  while(sqlite3_step(stmt) == SQLITE_ROW)
  {
    char *value = g_strdup((char *)sqlite3_column_text(stmt, 1));
    if(sqlite3_column_bytes(stmt,1))
    {
      switch(sqlite3_column_int(stmt, 0))
      {
        case DT_METADATA_XMP_DC_CREATOR:
          creator_count++;
          creator = g_list_append(creator, value);
          break;
        case DT_METADATA_XMP_DC_PUBLISHER:
          publisher_count++;
          publisher = g_list_append(publisher, value);
          break;
        case DT_METADATA_XMP_DC_TITLE:
          title_count++;
          title = g_list_append(title, value);
          break;
        case DT_METADATA_XMP_DC_DESCRIPTION:
          description_count++;
          description = g_list_append(description, value);
          break;
        case DT_METADATA_XMP_DC_RIGHTS:
          rights_count++;
          rights = g_list_append(rights, value);
          break;
      }
    }
  }
  sqlite3_finalize(stmt);

  fill_combo_box_entry(&(d->title), title_count, &title, &(d->multi_title));
  fill_combo_box_entry(&(d->description), description_count, &description, &(d->multi_description));
  fill_combo_box_entry(&(d->rights), rights_count, &rights, &(d->multi_rights));
  fill_combo_box_entry(&(d->creator), creator_count, &creator, &(d->multi_creator));
  fill_combo_box_entry(&(d->publisher), publisher_count, &publisher, &(d->multi_publisher));

  g_list_free(g_list_first(title));
  g_list_free(g_list_first(description));
  g_list_free(g_list_first(creator));
  g_list_free(g_list_first(publisher));
  g_list_free(g_list_first(rights));
}
示例#3
0
/* Fills the mail alarm data with the values from the widgets */
static void
malarm_widgets_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm)
{
    char *str;
    ECalComponentText description;
    GSList *attendee_list = NULL;
    GtkTextBuffer *text_buffer;
    GtkTextIter text_iter_start, text_iter_end;
    ENameSelectorModel *name_selector_model;
    EDestinationStore *destination_store;
    GList *destinations;
    icalcomponent *icalcomp;
    icalproperty *icalprop;
    GList *l;

    /* Attendees */
    name_selector_model = e_name_selector_peek_model (dialog->name_selector);
    e_name_selector_model_peek_section (name_selector_model, section_name, NULL, &destination_store);
    destinations = e_destination_store_list_destinations (destination_store);

    for (l = destinations; l; l = g_list_next (l)) {
        EDestination *dest;
        ECalComponentAttendee *a;

        dest = l->data;

        a = g_new0 (ECalComponentAttendee, 1);
        a->value = e_destination_get_email (dest);
        a->cn = e_destination_get_name (dest);

        attendee_list = g_slist_append (attendee_list, a);
    }

    e_cal_component_alarm_set_attendee_list (alarm, attendee_list);

    e_cal_component_free_attendee_list (attendee_list);
    g_list_free (destinations);

    if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->malarm_message)))
        return;

    /* Description */
    text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->malarm_description));
    gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start);
    gtk_text_buffer_get_end_iter   (text_buffer, &text_iter_end);
    str = gtk_text_buffer_get_text (text_buffer, &text_iter_start, &text_iter_end, FALSE);

    description.value = str;
    description.altrep = NULL;

    e_cal_component_alarm_set_description (alarm, &description);
    g_free (str);

    /* remove the X-EVOLUTION-NEEDS-DESCRIPTION property, so that
     * we don't re-set the alarm's description */
    icalcomp = e_cal_component_alarm_get_icalcomponent (alarm);
    icalprop = icalcomponent_get_first_property(icalcomp, ICAL_X_PROPERTY);
    while (icalprop) {
        const char *x_name;

        x_name = icalproperty_get_x_name (icalprop);
        if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) {
            icalcomponent_remove_property (icalcomp, icalprop);
            break;
        }

        icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
    }
}
示例#4
0
static void
setup_options (void)
{
	MatePanelAppletsManager *manager;
	GList               *applet_list, *l;
	int                  i;
	int                  j;
	char                *prefs_path = NULL;
	char                *unique_key = NULL;
	gboolean             unique_key_found = FALSE;
	gchar              **dconf_paths;
	GtkListStore        *model;
	GtkTreeIter          iter;
	GtkCellRenderer     *renderer;

	model = gtk_list_store_new (NUMBER_COLUMNS,
				    G_TYPE_STRING,
				    G_TYPE_STRING);

	gtk_combo_box_set_model (GTK_COMBO_BOX (applet_combo),
				 GTK_TREE_MODEL (model));

	manager = g_object_new (PANEL_TYPE_APPLETS_MANAGER_DBUS, NULL);
	applet_list = MATE_PANEL_APPLETS_MANAGER_GET_CLASS (manager)->get_applets (manager);
	for (l = applet_list, i = 1; l; l = g_list_next (l), i++) {
		MatePanelAppletInfo *info = (MatePanelAppletInfo *)l->data;

		gtk_list_store_append (model, &iter);
		gtk_list_store_set (model, &iter,
				    COLUMN_TEXT, g_strdup (mate_panel_applet_info_get_name (info)),
				    COLUMN_ITEM, g_strdup (mate_panel_applet_info_get_iid (info)),
				    -1);
	}
	g_list_free (applet_list);
	g_object_unref (manager);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (applet_combo),
				    renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (applet_combo),
					renderer, "text", COLUMN_TEXT, NULL);

	gtk_combo_box_set_active (GTK_COMBO_BOX (applet_combo), 0);

	setup_combo (size_combo, size_items, "Size",
		     G_N_ELEMENTS (size_items));
	setup_combo (orient_combo, orient_items, "Orientation",
		     G_N_ELEMENTS (orient_items));

	for (i = 0; !unique_key_found; i++)
	{
		unique_key = g_strdup_printf ("mate-panel-test-applet-%d", i);
		unique_key_found = TRUE;
		dconf_paths = mate_dconf_list_subdirs ("/tmp/", TRUE);
		for (j = 0; dconf_paths[j] != NULL; j++)
		{
			if (g_strcmp0(unique_key, dconf_paths[j]) == 0) {
				unique_key_found = FALSE;
				break;
			}
		}
		if (dconf_paths)
			g_strfreev (dconf_paths);
	}
	
	prefs_path = g_strdup_printf ("/tmp/%s/", unique_key);
	if (unique_key)
		g_free (unique_key);
	gtk_entry_set_text (GTK_ENTRY (prefs_path_entry), prefs_path);
	g_free (prefs_path);
}
示例#5
0
/*
 * save config
 */
void on_save_config(GtkButton *button, gpointer user_data)
{
	/* open config file */
	FILE *config = fopen(current_path, "w");
	
	/* get target */
	const gchar *target = gtk_entry_get_text(GTK_ENTRY(targetname));
	fprintf(config, "%s\n", target);
	
	/* debugger type */
	gchar *debugger = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cmb_debugger));
	fprintf(config, "%s\n", debugger);
	
	/* get command line arguments */
	GtkTextIter start, end;
	GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
	
	gtk_text_buffer_get_start_iter(buffer, &start);
	gtk_text_buffer_get_end_iter(buffer, &end);
	
	gchar *args = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
	gchar** lines = g_strsplit(args, "\n", 0);
	g_free(args);
	args = g_strjoinv(" ", lines);
	g_strfreev(lines);
	fprintf(config, "%s\n", args);
	g_free(args);

	/* environment */
	GtkTreeIter iter;
	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(envtree));
	gtk_tree_model_get_iter_first(model, &iter);
	do
	{
		gchar *name, *value;
		gtk_tree_model_get (
			model,
			&iter,
			NAME, &name,
			VALUE, &value,
		   -1);
		 if (strlen(name))
		 {
			fprintf(config, "%s\n", ENVIRONMENT_MARKER);
			fprintf(config, "%s\n%s\n", name, value);
		 }
		 
		 g_free(name);
		 g_free(value);
	}
	while (gtk_tree_model_iter_next(model, &iter));

	/* breakpoints */
	breaks_iterate(collect_breaks);
	GList *biter = breaks;
	while (biter)
	{
		breakpoint *bp = (breakpoint*)biter->data;
		
		fprintf(config, "%s\n", BREAKPOINTS_MARKER);
		fprintf(config, "%s\n%i\n%i\n%s\n%i\n",
			bp->file, bp->line, bp->hitscount, bp->condition, bp->enabled);
				
		biter = biter->next;
	}
	g_list_free(breaks);
	breaks = NULL;
	
	/* watches */
	GList *watches = wtree_get_watches();
	biter = watches;
	while (biter)
	{
		gchar *watch = (gchar*)biter->data;
		
		fprintf(config, "%s\n", WATCH_MARKER);
		fprintf(config, "%s\n", watch);
				
		biter = biter->next;
	}
	g_list_foreach(watches, (GFunc)g_free, NULL);
	g_list_free(watches);
	watches = NULL;
	

	fclose(config);

	dialogs_show_msgbox(GTK_MESSAGE_INFO, _("Config saved successfully"));
}
示例#6
0
static void
list_drives (GList *drives,
	     int indent)
{
  GList *volumes, *l;
  int c, i;
  GDrive *drive;
  char *name;
  char **ids;
  GIcon *icon;
  char *type_name;
  
  for (c = 0, l = drives; l != NULL; l = l->next, c++)
    {
      drive = (GDrive *) l->data;
      name = g_drive_get_name (drive);
      
      g_print ("%*sDrive(%d): %s\n", indent, "", c, name);
      g_free (name);

      type_name = get_type_name (drive);
      g_print ("%*sType: %s\n", indent+2, "", type_name);
      g_free (type_name);
      
      if (extra_detail)
	{
	  ids = g_drive_enumerate_identifiers (drive);
	  if (ids && ids[0] != NULL)
	    {
	      g_print ("%*sids:\n", indent+2, "");
	      for (i = 0; ids[i] != NULL; i++)
		{
		  char *id = g_drive_get_identifier (drive,
						     ids[i]);
		  g_print ("%*s %s: '%s'\n", indent+2, "", ids[i], id);
		  g_free (id);
		}
	    }
	  g_strfreev (ids);

          icon = g_drive_get_icon (drive);
          if (icon)
          {
                  if (G_IS_THEMED_ICON (icon))
                          show_themed_icon_names (G_THEMED_ICON (icon), indent + 2);
                  g_object_unref (icon);
          }

	  g_print ("%*sis_media_removable=%d\n", indent + 2, "", g_drive_is_media_removable (drive));
	  g_print ("%*shas_media=%d\n", indent + 2, "", g_drive_has_media (drive));
	  g_print ("%*sis_media_check_automatic=%d\n", indent + 2, "", g_drive_is_media_check_automatic (drive));
	  g_print ("%*scan_poll_for_media=%d\n", indent + 2, "", g_drive_can_poll_for_media (drive));
	  g_print ("%*scan_eject=%d\n", indent + 2, "", g_drive_can_eject (drive));
	}
      
      volumes = g_drive_get_volumes (drive);
      list_volumes (volumes, indent + 2, FALSE);
      g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
      g_list_free (volumes);
    }
}
示例#7
0
BotCTransPath * 
bot_ctrans_get_new_path(BotCTrans * ctrans,
        const char * from_frame_id,
        const char * to_frame_id)
{
    dbg("%s (%s, %s)\n", __FUNCTION__,
            from_frame_id, to_frame_id);

    BotCTransFrame *from_frame = _get_frame_or_warn(ctrans, from_frame_id);
    BotCTransFrame *to_frame = _get_frame_or_warn(ctrans, to_frame_id);
    if(!from_frame || !to_frame) 
        return NULL;
    // do a djikstra shortest path search
 
    GHashTable *Q = g_hash_table_new(g_direct_hash, g_direct_equal);
    GPtrArray *all_ndata = g_ptr_array_new();

    GList *frames_list = bot_g_hash_table_get_vals(ctrans->frames);
    for(GList *fiter=frames_list; fiter; fiter=fiter->next) {
        BotCTransFrame *frame = fiter->data;
        SPNodeData *ndata = _spnode_data_new(frame);
        if(frame == from_frame) 
            ndata->distance = 0;
        else
            ndata->distance = -1;
        g_hash_table_insert(Q, frame, ndata);
        g_ptr_array_add(all_ndata, ndata);
    }

    int first_iter = 1;
    while(g_hash_table_size(Q) > 0) {
        dbg("===\n");

        // find the node with the shortest distance
        SPNodeData *u = NULL;
        if(first_iter) {
            u = g_hash_table_lookup(Q, from_frame);
            first_iter = 0;
        } else {
            for(GList *fiter=frames_list; fiter; fiter=fiter->next) {
                BotCTransFrame *frame = fiter->data;

                SPNodeData *ndata = g_hash_table_lookup(Q, frame);
                if(!ndata)
                    continue;

                dbg("   %s: %d\n", frame->id, ndata->distance);

                if(!u || u->distance < 0 ||
                   (ndata->distance >= 0 && ndata->distance < u->distance)) {
                    u = ndata;
                }
            }
        }

        dbg("u: %s (%d)\n", u->frame->id, u->distance);

        if(u->distance < 0 || u->frame == to_frame) {
            break;
        }

        g_hash_table_remove(Q, u->frame);
        
        // check each neighbor of u
        for(int lind=0; lind<u->frame->links->len; lind++) {
            BotCTransLink *link = g_ptr_array_index(u->frame->links, lind);

            const BotCTransFrame *nbr_frame = NULL;
            int invert_transformation = 0;
            if(link->frame_from == u->frame) {
                nbr_frame = link->frame_to;
                invert_transformation = 0;
            } else {
                nbr_frame = link->frame_from;
                invert_transformation = 1;
            }

            dbg("  nbr: %s\n", nbr_frame->id);

            SPNodeData *nbr_ndata = g_hash_table_lookup(Q, nbr_frame);
            if(!nbr_ndata)
                continue;

            int alt_dist = u->distance + 1;
            if(nbr_ndata->distance < 0 ||
               alt_dist < nbr_ndata->distance) {
                nbr_ndata->distance = alt_dist;
                nbr_ndata->previous = u;
                nbr_ndata->previous_link = link;
                nbr_ndata->invert_transformation = invert_transformation;

                dbg("  set: %s (%d)\n", nbr_ndata->frame->id, 
                        nbr_ndata->distance);
            }
        }
    }

    SPNodeData *to_node = g_hash_table_lookup(Q, to_frame);
    if(!to_node || to_node->distance < 0) {
        g_hash_table_destroy(Q);
        bot_g_ptr_array_free_with_func(all_ndata, 
                (GDestroyNotify)_spnode_data_destroy);
        g_list_free(frames_list);

        return NULL;
    }

    // how long is the path?
    int nlinks = 0;
    SPNodeData *node = to_node;
    while(node && node->frame != from_frame) {
        node = node->previous;
        nlinks++;
    }

    BotCTransPath *path = _path_new(nlinks);
    node = to_node;
    int nind = nlinks - 1;
    while(node && node->frame != from_frame) {
        path->links[nind] = node->previous_link;
        assert(node->previous_link);
        path->invert[nind] = node->invert_transformation;
        node = node->previous;
        nind--;
    }
    assert(nind == -1);

    g_hash_table_destroy(Q);
    bot_g_ptr_array_free_with_func(all_ndata, 
            (GDestroyNotify)_spnode_data_destroy);
    g_list_free(frames_list);

    return path;
}
void
ags_recall_lv2_run_run_init_pre(AgsRecall *recall)
{
  AgsRecallLv2 *recall_lv2;
  AgsRecallChannelRun *recall_channel_run;
  AgsRecallRecycling *recall_recycling;
  AgsRecallLv2Run *recall_lv2_run;
  AgsAudioSignal *audio_signal;

  AgsLv2Plugin *lv2_plugin;
  
  AgsConfig *config;

  LV2_Handle *lv2_handle;
  
  float *output, *input;
  
  guint output_lines, input_lines;
  guint samplerate;
  guint buffer_size;
  guint port_count;
  guint i, i_stop;
  
  void (*parent_class_run_init_pre)(AgsRecall *recall);

  void (*connect_port)(LV2_Handle instance,
		       uint32_t port,
		       void *data_location);
  void (*activate)(LV2_Handle instance);
  
  pthread_mutex_t *recall_lv2_mutex;

  /* get recall mutex */
  pthread_mutex_lock(ags_recall_get_class_mutex());

  parent_class_run_init_pre = AGS_RECALL_CLASS(ags_recall_lv2_run_parent_class)->run_init_pre;
  
  pthread_mutex_unlock(ags_recall_get_class_mutex());

  /* call parent */
  parent_class_run_init_pre(recall);

  recall_lv2_run = AGS_RECALL_LV2_RUN(recall);

  g_object_get(recall,
	       "parent", &recall_recycling,
	       NULL);

  g_object_get(recall_recycling,
	       "parent", &recall_channel_run,
	       NULL);

  g_object_get(recall_channel_run,
	       "recall-channel", &recall_lv2,
	       NULL);

  /* set up buffer */
  g_object_get(recall_lv2_run,
	       "source", &audio_signal,
	       NULL);

  g_object_get(audio_signal,
	       "samplerate", &samplerate,
	       "buffer-size", &buffer_size,
	       NULL);
  
  /* get recall lv2 mutex */
  pthread_mutex_lock(ags_recall_get_class_mutex());
  
  recall_lv2_mutex = AGS_RECALL(recall_lv2)->obj_mutex;
  
  pthread_mutex_unlock(ags_recall_get_class_mutex());

  /* get some fields */
  pthread_mutex_lock(recall_lv2_mutex);

  lv2_plugin = recall_lv2->plugin;

  output_lines = recall_lv2->output_lines;
  input_lines = recall_lv2->input_lines;

  connect_port = recall_lv2->plugin_descriptor->connect_port;
  activate = recall_lv2->plugin_descriptor->activate;
  
  pthread_mutex_unlock(recall_lv2_mutex);
  
  /* set up buffer */
  input = NULL;
  output = NULL;
  
  if(input_lines > 0){
    input = (float *) malloc(input_lines *
			     buffer_size *
			     sizeof(float));
  }

  output = (float *) malloc(output_lines *
			    buffer_size *
			    sizeof(float));

  recall_lv2_run->output = output;
  recall_lv2_run->input = input;
  
  /* instantiate lv2 */  
  lv2_handle = (LV2_Handle *) ags_base_plugin_instantiate((AgsBasePlugin *) lv2_plugin,
							  samplerate, buffer_size);

  recall_lv2_run->lv2_handle = lv2_handle;
  
#ifdef AGS_DEBUG
  g_message("instantiate LV2 handle");
#endif

  ags_recall_lv2_run_load_ports(recall_lv2_run);

  /* can't be done in ags_recall_lv2_run_run_init_inter since possebility of overlapping buffers */
  pthread_mutex_lock(recall_lv2_mutex);

  /* connect audio port */
  for(i = 0; i < input_lines; i++){
#ifdef AGS_DEBUG
    g_message("connect in port: %d", recall_lv2->input_port[i]);
#endif
    
    connect_port(recall_lv2_run->lv2_handle[0],
		 recall_lv2->input_port[i],
		 recall_lv2_run->input);
  }

  for(i = 0; i < output_lines; i++){
#ifdef AGS_DEBUG
    g_message("connect out port: %d", recall_lv2->output_port[i]);
#endif
    
    connect_port(recall_lv2_run->lv2_handle[0],
		 recall_lv2->output_port[i],
		 recall_lv2_run->output);
  }

  /* connect event port */
  if(ags_recall_lv2_test_flags(recall_lv2, AGS_RECALL_LV2_HAS_EVENT_PORT)){
    recall_lv2_run->event_port = ags_lv2_plugin_alloc_event_buffer(AGS_RECALL_LV2_DEFAULT_MIDI_LENGHT);
    
    connect_port(recall_lv2_run->lv2_handle[0],
		 recall_lv2->event_port,
		 recall_lv2_run->event_port);
  }
  
  /* connect atom port */
  if(ags_recall_lv2_test_flags(recall_lv2, AGS_RECALL_LV2_HAS_ATOM_PORT)){
    recall_lv2_run->atom_port = ags_lv2_plugin_alloc_atom_sequence(AGS_RECALL_LV2_DEFAULT_MIDI_LENGHT);
    
    connect_port(recall_lv2_run->lv2_handle[0],
		 recall_lv2->atom_port,
		 recall_lv2_run->atom_port);   
  }
  
  /* activate */
  if(activate != NULL){
    activate(recall_lv2_run->lv2_handle[0]);
  }

  pthread_mutex_unlock(recall_lv2_mutex);

  /* set program */
  if(ags_lv2_plugin_test_flags(lv2_plugin, AGS_LV2_PLUGIN_HAS_PROGRAM_INTERFACE)){
    AgsPort *current_port;

    GList *plugin_port_start, *plugin_port;
    GList *port;
    GList *list;
    
    gchar *specifier, *current_specifier;

    float *port_data;

    guint bank, program;
    guint port_count;

    pthread_mutex_t *base_plugin_mutex;
    
    pthread_mutex_lock(recall_lv2_mutex);

    port = g_list_copy(AGS_RECALL(recall_lv2)->port);

    bank = recall_lv2->bank;
    program = recall_lv2->program;
    
    pthread_mutex_unlock(recall_lv2_mutex);

    /* get base plugin mutex */
    pthread_mutex_lock(ags_base_plugin_get_class_mutex());
  
    base_plugin_mutex = AGS_BASE_PLUGIN(lv2_plugin)->obj_mutex;
  
    pthread_mutex_unlock(ags_base_plugin_get_class_mutex());
    
    /* get plugin port */
    pthread_mutex_lock(base_plugin_mutex);

    plugin_port_start = g_list_copy(AGS_BASE_PLUGIN(lv2_plugin)->plugin_port);

    pthread_mutex_unlock(base_plugin_mutex);

    /* create port data */
    port_count = g_list_length(plugin_port_start);
    
    port_data = (float *) malloc(port_count * sizeof(float));

    plugin_port = plugin_port_start;
    
    for(i = 0; i < port_count && plugin_port != NULL; ){
      AgsPluginPort *current_plugin_port;

      pthread_mutex_t *plugin_port_mutex;

      current_plugin_port = AGS_PLUGIN_PORT(plugin_port->data);

      /* get plugin port mutex */
      pthread_mutex_lock(ags_plugin_port_get_class_mutex());
      
      plugin_port_mutex = current_plugin_port->obj_mutex;

      pthread_mutex_unlock(ags_plugin_port_get_class_mutex());

      /* get specifier */
      pthread_mutex_lock(plugin_port_mutex);

      specifier = g_strdup(current_plugin_port->port_name);
 	
      pthread_mutex_unlock(plugin_port_mutex);

      list = ags_port_find_specifier(port, specifier);

      if(list != NULL){
	GValue value = {0,};
	
	current_port = list->data;

	g_value_init(&value,
		     G_TYPE_FLOAT);

	ags_port_safe_read(current_port,
			   &value);
	port_data[i] = g_value_get_float(&value);

	g_value_unset(&value);
      }else{
	port_data[i] = 0.0;
      }

      g_free(specifier);

      /* iterate plugin port */
      plugin_port = plugin_port->next;
    }

    ags_lv2_plugin_change_program(lv2_plugin,
				  recall_lv2_run->lv2_handle[0],
				  bank,
				  program);

    /* reset port data */    
    plugin_port = plugin_port_start;

    for(i = 0; i < port_count && plugin_port != NULL;){
      AgsPluginPort *current_plugin_port;

      pthread_mutex_t *plugin_port_mutex;

      current_plugin_port = AGS_PLUGIN_PORT(plugin_port->data);

      /* get plugin port mutex */
      pthread_mutex_lock(ags_plugin_port_get_class_mutex());
      
      plugin_port_mutex = current_plugin_port->obj_mutex;

      pthread_mutex_unlock(ags_plugin_port_get_class_mutex());

      /* get specifier */
      pthread_mutex_lock(plugin_port_mutex);

      specifier = g_strdup(current_plugin_port->port_name);
 	
      pthread_mutex_unlock(plugin_port_mutex);

      list = ags_port_find_specifier(port, specifier);

      if(list != NULL){
	GValue value = {0,};
	
	current_port = list->data;

	g_value_init(&value,
		     G_TYPE_FLOAT);
	g_value_set_float(&value, port_data[i]);
	
	ags_port_safe_write_raw(current_port,
				&value);

	g_value_unset(&value);
      }
      
      /* iterate plugin port */
      plugin_port = plugin_port->next;
    }
    
    g_free(port_data);

    g_list_free(port);
    g_list_free(plugin_port_start);
  }

  g_object_unref(recall_recycling);

  g_object_unref(recall_channel_run);

  g_object_unref(recall_lv2);

  g_object_unref(audio_signal);
}
void
ags_recall_lv2_run_run_pre(AgsRecall *recall)
{
  AgsRecallLv2 *recall_lv2;
  AgsRecallChannelRun *recall_channel_run;
  AgsRecallRecycling *recall_recycling;
  AgsRecallLv2Run *recall_lv2_run;
  AgsAudioSignal *audio_signal;
  AgsPort *current_port;
  AgsRecallID *recall_id;
  AgsRecyclingContext *parent_recycling_context, *recycling_context;

  AgsCountBeatsAudioRun *count_beats_audio_run;
  AgsRouteLv2AudioRun *route_lv2_audio_run;

  GList *list_start, *list;
  GList *port;
  
  GList *note_start, *note;
  
  guint output_lines, input_lines;
  guint notation_counter;
  guint x0, x1;
  guint port_count;

  guint copy_mode_in, copy_mode_out;
  guint buffer_size;
  guint i;

  void (*parent_class_run_pre)(AgsRecall *recall);

  void (*run)(LV2_Handle instance,
	      uint32_t sample_count);
  void (*deactivate)(LV2_Handle instance);
  void (*cleanup)(LV2_Handle instance);
  
  pthread_mutex_t *recall_lv2_mutex;
  pthread_mutex_t *port_mutex;
  
  /* get parent class */
  pthread_mutex_lock(ags_recall_get_class_mutex());

  parent_class_run_pre = AGS_RECALL_CLASS(ags_recall_lv2_run_parent_class)->run_pre;
  
  pthread_mutex_unlock(ags_recall_get_class_mutex());

  /* call parent */
  parent_class_run_pre(recall);

  g_object_get(recall,
	       "recall-id", &recall_id,
	       "source", &audio_signal,
	       NULL);

  g_object_get(recall_id,
	       "recycling-context", &recycling_context,
	       NULL);

  g_object_get(recycling_context,
	       "parent", &parent_recycling_context,
	       NULL);

  g_object_get(audio_signal,
	       "note", &note_start,
	       NULL);

  if(ags_recall_global_get_rt_safe() &&
     parent_recycling_context != NULL &&
     note_start == NULL){
    g_object_unref(recall_id);

    g_object_unref(audio_signal);

    g_object_unref(recycling_context);

    g_object_unref(parent_recycling_context);

    return;
  }

  g_list_free_full(note_start,
		   g_object_unref);

  g_object_get(recall,
	       "parent", &recall_recycling,
	       NULL);

  g_object_get(recall_recycling,
	       "parent", &recall_channel_run,
	       NULL);

  g_object_get(recall_channel_run,
	       "recall-channel", &recall_lv2,
	       NULL);

  recall_lv2_run = AGS_RECALL_LV2_RUN(recall);

  g_object_get(recall_lv2_run,
	       "route-lv2-audio-run", &route_lv2_audio_run,
	       NULL);
  
  if(route_lv2_audio_run == NULL){
    g_object_unref(recall_id);

    g_object_unref(audio_signal);

    g_object_unref(recycling_context);

    if(parent_recycling_context != NULL){
      g_object_unref(parent_recycling_context);
    }
    
    g_object_unref(recall_recycling);
    
    g_object_unref(recall_channel_run);

    g_object_unref(recall_lv2);

    return;
  }

  /* get recall lv2 mutex */
  pthread_mutex_lock(ags_recall_get_class_mutex());
  
  recall_lv2_mutex = AGS_RECALL(recall_lv2)->obj_mutex;
  
  pthread_mutex_unlock(ags_recall_get_class_mutex());

  g_object_get(route_lv2_audio_run,
	       "count-beats-audio-run", &count_beats_audio_run,
	       NULL);

  g_object_get(audio_signal,
	       "buffer-size", &buffer_size,
	       NULL);

  /* get some fields */
  pthread_mutex_lock(recall_lv2_mutex);

  output_lines = recall_lv2->output_lines;
  input_lines = recall_lv2->input_lines;

  pthread_mutex_unlock(recall_lv2_mutex);

  g_object_get(count_beats_audio_run,
	       "notation-counter", &notation_counter,
	       NULL);
  
  g_object_get(recall_lv2_run,
	       "note", &note_start,
	       NULL);

  if(ags_recall_global_get_rt_safe()){
    note = note_start;

    while(note != NULL){
      g_object_get(note->data,
		   "x0", &x0,
		   "x1", &x1,
		   NULL);
       	
      if((x1 + 1 <= notation_counter &&
	  !ags_note_test_flags(note->data, AGS_NOTE_FEED)) ||
	 x0 > notation_counter){
	recall_lv2_run->note = g_list_remove(recall_lv2_run->note,
					     note->data);
	g_object_unref(note->data);
      }
    
      note = note->next;
    }

    g_list_free(note_start);
  }else{
    g_object_get(note_start->data,
		 "x0", &x0,
		 "x1", &x1,
		 NULL);
    
    if(audio_signal->stream_current == NULL ||
       (x1 + 1 <= notation_counter &&
	!ags_note_test_flags(note_start->data, AGS_NOTE_FEED)) ||
       x0 > notation_counter){
      //    g_message("done");
      pthread_mutex_lock(recall_lv2_mutex);

      deactivate = recall_lv2->plugin_descriptor->deactivate;
      cleanup = recall_lv2->plugin_descriptor->cleanup;
      
      pthread_mutex_unlock(recall_lv2_mutex);

      /* deactivate */
      if(deactivate != NULL){
	deactivate(recall_lv2_run->lv2_handle[0]);
      }

      /* cleanup */
      if(cleanup != NULL){
	cleanup(recall_lv2_run->lv2_handle[0]);
      }

      ags_recall_done(recall);
      g_list_free(note_start);
      
      goto ags_recall_lv2_run_run_pre_END;
    }
  }

  /* get copy mode and clear buffer */
  copy_mode_in = ags_audio_buffer_util_get_copy_mode(AGS_AUDIO_BUFFER_UTIL_FLOAT,
						     ags_audio_buffer_util_format_from_soundcard(audio_signal->format));

  copy_mode_out = ags_audio_buffer_util_get_copy_mode(ags_audio_buffer_util_format_from_soundcard(audio_signal->format),
						      AGS_AUDIO_BUFFER_UTIL_FLOAT);
  
  if(recall_lv2_run->output != NULL){
    ags_audio_buffer_util_clear_float(recall_lv2_run->output, 1,
				      output_lines * buffer_size);
  }

  if(recall_lv2_run->input != NULL){
    ags_audio_buffer_util_clear_float(recall_lv2_run->input, 1,
				      input_lines * buffer_size);
  }

  /* copy data  */
  if(recall_lv2_run->input != NULL){
    ags_audio_buffer_util_copy_buffer_to_buffer(recall_lv2_run->input, 1, 0,
						audio_signal->stream_current->data, 1, 0,
						(guint) buffer_size, copy_mode_in);
  }
  
  /* process data */
  pthread_mutex_lock(recall_lv2_mutex);

  run = recall_lv2->plugin_descriptor->run;
    
  pthread_mutex_unlock(recall_lv2_mutex);
  
  g_object_get(recall_lv2_run,
	       "note", &note_start,
	       NULL);
  
  note = note_start;

  while(note != NULL){
    run(recall_lv2_run->lv2_handle[0],
	(uint32_t) buffer_size);

    note = note->next;
  }

  g_list_free(note_start);

  /* copy data */
  if(recall_lv2_run->output != NULL){
    ags_audio_buffer_util_clear_buffer(audio_signal->stream_current->data, 1,
				       buffer_size, ags_audio_buffer_util_format_from_soundcard(audio_signal->format));
    
    ags_audio_buffer_util_copy_buffer_to_buffer(audio_signal->stream_current->data, 1, 0,
						recall_lv2_run->output, 1, 0,
						(guint) buffer_size, copy_mode_out);
  }

ags_recall_lv2_run_run_pre_END:
  
  g_object_unref(recall_id);

  g_object_unref(recycling_context);

  if(parent_recycling_context != NULL){
    g_object_unref(parent_recycling_context);
  }
  
  g_object_unref(recall_recycling);
    
  g_object_unref(recall_channel_run);

  g_object_unref(recall_lv2);

  g_object_unref(count_beats_audio_run);
}
示例#10
0
static void _g_list_free__qtable_entry_unref0_ (GList* self) {
	g_list_foreach (self, (GFunc) _qtable_entry_unref0_, NULL);
	g_list_free (self);
}
示例#11
0
/**
 * ags_recall_lv2_run_load_ports:
 * @recall_lv2_run: the #AgsRecallLv2Run
 *
 * Set up LV2 ports.
 *
 * Since: 2.0.0
 */
void
ags_recall_lv2_run_load_ports(AgsRecallLv2Run *recall_lv2_run)
{
  AgsRecallLv2 *recall_lv2;
  AgsRecallChannelRun *recall_channel_run;
  AgsRecallRecycling *recall_recycling;
  AgsPort *current_port;

  AgsLv2Plugin *lv2_plugin;
  
  GList *plugin_port_start, *plugin_port;
  GList *port;
  GList *list;

  gchar *filename, *effect;
  gchar *specifier, *current_specifier;
  
  guint port_count;
  guint i, j;

  void (*connect_port)(LV2_Handle instance,
		       uint32_t port,
		       void *data_location);

  pthread_mutex_t *recall_mutex;
  pthread_mutex_t *recall_lv2_mutex;
  pthread_mutex_t *port_mutex;

  if(!AGS_IS_RECALL_LV2_RUN(recall_lv2_run)){
    return;
  }
  
  /* get recall mutex */
  pthread_mutex_lock(ags_recall_get_class_mutex());

  recall_mutex = AGS_RECALL(recall_lv2_run)->obj_mutex;
  
  pthread_mutex_unlock(ags_recall_get_class_mutex());

  g_object_get(recall_lv2_run,
	       "parent", &recall_recycling,
	       NULL);

  g_object_get(recall_recycling,
	       "parent", &recall_channel_run,
	       NULL);

  g_object_get(recall_channel_run,
	       "recall-channel", &recall_lv2,
	       NULL);
  
  /* get recall lv2 mutex */
  pthread_mutex_lock(ags_recall_get_class_mutex());
  
  recall_lv2_mutex = AGS_RECALL(recall_lv2)->obj_mutex;
  
  pthread_mutex_unlock(ags_recall_get_class_mutex());

  /* get some fields */
  pthread_mutex_lock(recall_mutex);

  filename = g_strdup(AGS_RECALL(recall_lv2)->filename);
  effect = g_strdup(AGS_RECALL(recall_lv2)->effect);

  port = g_list_copy(AGS_RECALL(recall_lv2)->port);

  connect_port = recall_lv2->plugin_descriptor->connect_port;
  
  pthread_mutex_unlock(recall_mutex);
  
  lv2_plugin = ags_lv2_manager_find_lv2_plugin(ags_lv2_manager_get_instance(),
					       filename, effect);

  g_free(filename);
  g_free(effect);

  g_object_get(lv2_plugin,
	       "plugin-port", &plugin_port_start,
	       NULL);
  
  if(plugin_port_start != NULL){
    plugin_port = plugin_port_start;

    for(i = 0; plugin_port != NULL; i++){
      AgsPluginPort *current_plugin_port;
      
      pthread_mutex_t *plugin_port_mutex;
      
      current_plugin_port = AGS_PLUGIN_PORT(plugin_port->data);

      /* get plugin port mutex */
      pthread_mutex_lock(ags_plugin_port_get_class_mutex());
      
      plugin_port_mutex = current_plugin_port->obj_mutex;

      pthread_mutex_unlock(ags_plugin_port_get_class_mutex());

      if(ags_plugin_port_test_flags(current_plugin_port,
				    AGS_PLUGIN_PORT_CONTROL)){
	pthread_mutex_lock(plugin_port_mutex);
	  
	specifier = g_strdup(current_plugin_port->port_name);
	
	pthread_mutex_unlock(plugin_port_mutex);

	list = ags_port_find_specifier(port, specifier);
	g_free(specifier);

	if(list != NULL){
	  float *port_pointer;
	  
	  guint port_index;
	  
	  current_port = list->data;
	  
	  /* get port mutex */
	  pthread_mutex_lock(ags_port_get_class_mutex());

	  port_mutex = current_port->obj_mutex;
      
	  pthread_mutex_unlock(ags_port_get_class_mutex());

	  /* get port pointer */
	  pthread_mutex_lock(port_mutex);
	    
	  port_pointer = (float *) &(current_port->port_value.ags_port_float);

	  pthread_mutex_unlock(port_mutex);

	  g_object_get(current_plugin_port,
		       "port-index", &port_index,
		       NULL);
	  
	  connect_port(recall_lv2_run->lv2_handle[0],
		       (uint32_t) port_index,
		       (float *) port_pointer);

#ifdef AGS_DEBUG
	g_message("connect port: %d", port_index);
#endif
	}
      }

      /* iterate plugin port */
      plugin_port = plugin_port->next;
    }
  }

  g_list_free(port);

  g_list_free_full(plugin_port_start,
		   g_object_unref);

  g_object_unref(recall_recycling);

  g_object_unref(recall_channel_run);

  g_object_unref(recall_lv2);
}
/***************************
 *                         *
 * Encodings dialog window *
 *                         *
 **************************/
void
gxi_edit_encodings_clicked_cb (GtkButton *button, GncXmlImportData *data)
{
    GtkBuilder *builder;
    GtkWidget *dialog;
    GtkListStore *list_store;
    GtkTreeStore *tree_store;
    GtkTreeIter iter, parent, *parent_ptr;
    GList *encodings_bak, *enc_iter;
    const gchar *encoding;
    system_encoding_type *system_enc;
    gpointer enc_ptr;
    gint i, j;

    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "assistant-xml-encoding.glade", "encodings_dialog");
    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "encodings_dialog"));
    data->encodings_dialog = dialog;


    // Set the style context for this assistant so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncAssistXmlEncoding");

    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, data);

    gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->assistant));

    data->available_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "available_encs_view"));

    data->custom_enc_entry = GTK_WIDGET(gtk_builder_get_object (builder, "custom_enc_entry"));

    /* set up selected encodings list */
    data->selected_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "selected_encs_view"));
    list_store = gtk_list_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
    for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next)
    {
        encoding = g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data));
        gtk_list_store_append (list_store, &iter);
        gtk_list_store_set (list_store, &iter, ENC_COL_STRING, encoding,
                            ENC_COL_QUARK, enc_iter->data, -1);
    }
    gtk_tree_view_insert_column_with_attributes (
        data->selected_encs_view, -1, NULL,
        gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
    gtk_tree_view_set_model (data->selected_encs_view,
                             GTK_TREE_MODEL (list_store));
    g_object_unref (list_store);

    /* set up system encodings list */
    data->available_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "available_encs_view"));
    tree_store = gtk_tree_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER);
    for (i = 0, system_enc = system_encodings;
            i < n_system_encodings;
            i++, system_enc++)
    {
        if (i == 0)
        {
            /* first system encoding */
            parent_ptr = NULL;
        }
        else
        {
            parent_ptr = &iter;
            for (j = 0; j < system_enc->parent; j++)
                if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (tree_store),
                                                &parent, &iter))
                {
                    /* go up one level */
                    iter = parent;
                }
                else
                {
                    /* no parent to toplevel element */
                    parent_ptr = NULL;
                }
        }
        if (system_enc->encoding)
            enc_ptr = GUINT_TO_POINTER (g_quark_from_string (system_enc->encoding));
        else
            enc_ptr = NULL;

        gtk_tree_store_append (tree_store, &iter, parent_ptr);
        gtk_tree_store_set (tree_store, &iter, ENC_COL_STRING,
                            gettext (system_enc->text), ENC_COL_QUARK, enc_ptr, -1);
    }
    gtk_tree_view_insert_column_with_attributes (
        data->available_encs_view, -1, NULL,
        gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL);
    gtk_tree_view_set_model (data->available_encs_view,
                             GTK_TREE_MODEL (tree_store));
    g_object_unref (tree_store);

    /* run the dialog */
    encodings_bak = g_list_copy (data->encodings);
    if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
    {
        g_list_free (encodings_bak);
        if (!g_list_find (data->encodings,
                          GUINT_TO_POINTER (data->default_encoding)))
        {
            /* choose top level encoding then */
            data->default_encoding = GPOINTER_TO_UINT (data->encodings->data);
        }

        /* update whole page */
        gxi_check_file (data);
        gxi_update_default_enc_combo (data);
        gxi_update_string_box (data);
        gxi_update_conversion_forward (data);
    }
    else
    {
        g_list_free (data->encodings);
        data->encodings = encodings_bak;
    }
    g_object_unref(G_OBJECT(builder));

    gtk_widget_destroy (dialog);
    data->encodings_dialog = NULL;
}
// Create a new bus from the current selection
static void create_bus_button_clicked (GtkWidget *widget, gpointer data)
  {
  int row_type = -1 ;
  bus_layout_D *dialog = (bus_layout_D *)data ;
  GList *llTreeRefs = NULL, *llItr = NULL ;
  GtkTreeStore *ts = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tview))) ;
  GtkTreeIter itrBus, itr, itrSrc, itrSrcParent ;
  GtkTreeRowReference *refBus = NULL, *refSrcParent = NULL ;
  GtkTreePath *tp = NULL, *tpSrcParent = NULL ;

  llTreeRefs = get_selected_refs (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview))) ;

  if (NULL == llTreeRefs) return ;

  gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), &itr,
    tp = gtk_tree_row_reference_get_path (llTreeRefs->data)) ;

  gtk_tree_model_get (GTK_TREE_MODEL (ts), &itr, BUS_LAYOUT_MODEL_COLUMN_TYPE, &row_type, -1) ;

  gtk_tree_path_free (tp) ;

  gtk_tree_store_prepend (ts, &itrBus, NULL) ;
  gtk_tree_store_set (ts, &itrBus,
    BUS_LAYOUT_MODEL_COLUMN_ICON, (row_type & ROW_TYPE_INPUT) ? QCAD_STOCK_BUS_INPUT : QCAD_STOCK_BUS_OUTPUT,
    BUS_LAYOUT_MODEL_COLUMN_NAME, _("Untitled Bus"),
    BUS_LAYOUT_MODEL_COLUMN_TYPE, (row_type & ROW_TYPE_INPUT) ? ROW_TYPE_BUS_INPUT : ROW_TYPE_BUS_OUTPUT,
    BUS_LAYOUT_MODEL_COLUMN_INDEX, -1, -1) ;

  refBus = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), tp = gtk_tree_model_get_path (GTK_TREE_MODEL (ts), &itrBus)) ;
  gtk_tree_path_free (tp) ;

  for (llItr = g_list_last (llTreeRefs) ; llItr != NULL ; llItr = llItr->prev)
    {
    gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), &itrBus, tp = gtk_tree_row_reference_get_path (refBus)) ;
    gtk_tree_path_free (tp) ;

    gtk_tree_store_append (ts, &itr, &itrBus) ;

    gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), &itrSrc,
      tp = gtk_tree_row_reference_get_path (llItr->data)) ;
    gtk_tree_path_free (tp) ;

    swap_model_iters_contents (GTK_TREE_MODEL (ts), &itrSrc, &itr) ;

    gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), &itrSrc,
      tp = gtk_tree_row_reference_get_path (llItr->data)) ;

    if (gtk_tree_path_get_depth (tp) > 1)
      {
      gtk_tree_path_up (tpSrcParent = gtk_tree_path_copy (tp)) ;

      refSrcParent = (1 == gtk_tree_model_path_n_children (GTK_TREE_MODEL (ts), tpSrcParent)) ?
        gtk_tree_row_reference_new (GTK_TREE_MODEL (ts), tpSrcParent) : NULL ;

      gtk_tree_path_free (tpSrcParent) ;
      }

    gtk_tree_path_free (tp) ;

    gtk_tree_row_reference_free (llItr->data) ;

    // Remove cell from old location
    gtk_tree_store_remove (ts, &itrSrc) ;

    // The bus that owned the row we just moved has become empty - delete it
    if (NULL != refSrcParent)
      {
      tpSrcParent = gtk_tree_row_reference_get_path (refSrcParent) ;

      gtk_tree_model_get_iter (GTK_TREE_MODEL (ts), &itrSrcParent, tpSrcParent) ;

      gtk_tree_store_remove (ts, &itrSrcParent) ;

      gtk_tree_path_free (tpSrcParent) ;
      gtk_tree_row_reference_free (refSrcParent) ;
      refSrcParent = NULL ;
      }
    }

  gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview)), tp = gtk_tree_row_reference_get_path (refBus)) ;

  gtk_tree_path_free (tp) ;
  gtk_tree_row_reference_free (refBus) ;
  g_list_free (llTreeRefs) ;
  }
void PopupMenuGtk::show(const IntRect& rect, FrameView* view, int index)
{
    ASSERT(client());

    if (!m_popup) {
        m_popup = GTK_MENU(gtk_menu_new());
        g_signal_connect(m_popup.get(), "unmap", G_CALLBACK(menuUnmapped), this);
    } else
        gtk_container_foreach(GTK_CONTAINER(m_popup.get()), reinterpret_cast<GtkCallback>(menuRemoveItem), this);

    int x, y;
    gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(view->hostWindow()->platformPageClient())), &x, &y);
    m_menuPosition = view->contentsToWindow(rect.location());
    m_menuPosition = IntPoint(m_menuPosition.x() + x, m_menuPosition.y() + y + rect.height());
    m_indexMap.clear();

    const int size = client()->listSize();
    for (int i = 0; i < size; ++i) {
        GtkWidget* item;
        if (client()->itemIsSeparator(i))
            item = gtk_separator_menu_item_new();
        else
            item = gtk_menu_item_new_with_label(client()->itemText(i).utf8().data());

        m_indexMap.add(item, i);
        g_signal_connect(item, "activate", G_CALLBACK(menuItemActivated), this);

        // FIXME: Apply the PopupMenuStyle from client()->itemStyle(i)
        gtk_widget_set_sensitive(item, client()->itemIsEnabled(i));
        gtk_menu_shell_append(GTK_MENU_SHELL(m_popup.get()), item);
        gtk_widget_show(item);
    }

    gtk_menu_set_active(m_popup.get(), index);


    // The size calls are directly copied from gtkcombobox.c which is LGPL
    GtkRequisition requisition;
    gtk_widget_set_size_request(GTK_WIDGET(m_popup.get()), -1, -1);
    gtk_widget_size_request(GTK_WIDGET(m_popup.get()), &requisition);
    gtk_widget_set_size_request(GTK_WIDGET(m_popup.get()), std::max(rect.width(), requisition.width), -1);

    GList* children = gtk_container_get_children(GTK_CONTAINER(m_popup.get()));
    GList* p = children;
    if (size)
        for (int i = 0; i < size; i++) {
            if (i > index)
              break;

            GtkWidget* item = reinterpret_cast<GtkWidget*>(p->data);
            GtkRequisition itemRequisition;
            gtk_widget_get_child_requisition(item, &itemRequisition);
            m_menuPosition.setY(m_menuPosition.y() - itemRequisition.height);

            p = g_list_next(p);
        } else
            // Center vertically the empty popup in the combo box area
            m_menuPosition.setY(m_menuPosition.y() - rect.height() / 2);

    g_list_free(children);
    gtk_menu_popup(m_popup.get(), 0, 0, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 0, gtk_get_current_event_time());
}
示例#15
0
文件: main.c 项目: barak/xsystrace
int
main (int argc, char *argv[])
{
	struct pollfd pfd;
	char line[4096], *p;
	char *name, *id, *polname, *filters;
	int nfilters, res;
	time_t curtime;
	GList *items = NULL;

	GtkWidget *systracewin;
	GtkWidget *processname;
	GtkWidget *policyname;
	GtkWidget *processid;
	GtkWidget *syscallinfo;
	GtkWidget *statusline;
	GtkWidget *timeline;
	GtkWidget *reviewbutton;
	GtkWidget *detachlabel;
	GtkWidget *filterentry;

	GtkStyle *default_style, *red_style;

	/* Set up required parameters */
	parameters();

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

	add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps");
	add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");

	/*
	 * The following code was added by Glade to create one of each component
	 * (except popup menus), just so that you see something after building
	 * the project. Delete any components that you don't want shown initially.
	 */
	systracewin = create_systracewin ();
	filterreview = create_filterreview();
	wizard = create_wizard();

	processname = lookup_widget(GTK_WIDGET(systracewin), "processname");
	processid = lookup_widget(GTK_WIDGET(systracewin), "processid");
	policyname = lookup_widget(GTK_WIDGET(systracewin), "policyname");
	syscallinfo = lookup_widget(GTK_WIDGET(systracewin), "syscallinfo");
	statusline = lookup_widget(GTK_WIDGET(systracewin), "statusline");
	timeline = lookup_widget(GTK_WIDGET(systracewin), "timeline");
	reviewbutton = lookup_widget(GTK_WIDGET(systracewin), "reviewbutton");
	wizardbutton = lookup_widget(GTK_WIDGET(systracewin), "wizardbutton");
	detachlabel = lookup_widget(GTK_WIDGET(systracewin), "detachlabel");
	filterentry = lookup_widget(GTK_WIDGET(systracewin), "filterentry");
	default_style = gtk_widget_get_style(processname);
	red_style = make_color(default_style, 0xd000, 0x1000, 0);
	red_style->private_font = gdk_font_load("-*-helvetica-bold-r-normal--*-140-*-*-*-*-iso8859-1");
	gtk_widget_set_style(processname, red_style);
	gtk_widget_set_style(processid, red_style);
	gtk_widget_set_style(policyname, red_style);
	gtk_widget_set_style(syscallinfo, red_style);

	/* Return key is not supposed to pop it up */
	gtk_combo_disable_activate(GTK_COMBO(filterentry));

	/* Connect to cradle server if requested */
	if (argc == 2 && strcmp(argv[1], "-C") == 0) {
		struct sockaddr_un sun;
		int s;
		char path[MAXPATHLEN];

		snprintf(path, sizeof(path), "/tmp/systrace-%d/%s",
		    getuid(), CRADLE_UI);

		if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
			err(1, "socket()");

		memset(&sun, 0, sizeof (sun));
		sun.sun_family = AF_UNIX;

		if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
		    sizeof(sun.sun_path))
			errx(1, "Path too long: %s", path);

		if (connect(s, (struct sockaddr *)&sun, sizeof(sun)) == -1)
			err(1, "connect()");

		if (dup2(s, fileno(stdin)) == -1)
			err(1, "dup2");
		if (dup2(s, fileno(stdout)) == -1)
			err(1, "dup2");
	}

	/* Make IO line buffered */
	setvbuf(stdin, NULL, _IONBF, 0);
	setvbuf(stdout, NULL, _IONBF, 0);
	while (1) {
		/* See if we can read from the file descriptor */
		memset(&pfd, 0, sizeof(pfd));
		pfd.fd = fileno(stdin);
		pfd.events = POLLIN;
		res = poll(&pfd, 1, 1000);
		if (res == -1) {
			if (errno == EINTR || errno == EAGAIN)
				break;
		} else if (res == 0) {
			while (gtk_events_pending())
				gtk_main_iteration();
			continue;
		}

		if (freadline(line, sizeof(line), stdin) == NULL)
			break;
		p = line;
		name = strsep(&p, ",");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		p++;
		strsep(&p, " ");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		id = strsep(&p, "(");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		strsep(&p, ":");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		p++;
		polname = strsep(&p, ",");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		strsep(&p, ":");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		p++;
		filters = strsep(&p, ",");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		nfilters = atoi(filters);
		strsep(&p, ":");
		if (p == NULL || *p == '\0')
			errx(1, "Bad input line");
		p++;

		gtk_label_set_text(GTK_LABEL(processname), name);
		gtk_label_set_text(GTK_LABEL(processid), id);
		gtk_label_set_text(GTK_LABEL(policyname), polname);
		gtk_label_set_text(GTK_LABEL(syscallinfo), p);
		gtk_label_set_text(GTK_LABEL(statusline), "");

		items = make_policy_suggestion(p);

		curtime = time(NULL);
		snprintf(line, sizeof(line), "%.25s", ctime(&curtime));
		gtk_label_set_text(GTK_LABEL(timeline), line);

		if (nfilters) {
			gtk_widget_set_sensitive(wizardbutton, 0);
			gtk_widget_set_sensitive(reviewbutton, 1);
			gtk_label_set_text(GTK_LABEL(detachlabel), "Automatic");
		} else {
			gtk_widget_set_sensitive(wizardbutton, 1);
			gtk_widget_set_sensitive(reviewbutton, 0);
			gtk_label_set_text(GTK_LABEL(detachlabel), "Detach");
		}

		gtk_widget_show (systracewin);

		gtk_combo_set_popdown_strings (GTK_COMBO(filterentry), items);
		g_list_foreach(items, free_list, NULL);
		g_list_free(items);

		do {
			gtk_main ();
			while (freadline(line, sizeof(line), stdin)) {
				if (!strcmp(line, "OKAY"))
					goto done;
				if (!strcmp(line, "WRONG"))
					break;
				gtk_label_set_text(GTK_LABEL(statusline), line);
			}
		} while (1);

	done:
		gtk_widget_hide (systracewin);

		while (gtk_events_pending())
			gtk_main_iteration();
	}
	return 0;
}
gboolean working_area_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
	// Local variables
	gint				box_height;					// Height of the bounding box
	gint				box_width;					// Width of the bounding box
	GList				*collision_list = NULL;
	guint				count_int;
	gint				finish_x;					// X position at the layer objects finish time
	gint				finish_y;					// Y position at the layer objects finish time
	GList				*layer_pointer;
	GString				*message;					// Used to construct message strings
	guint				num_collisions;
	gint				onscreen_bottom;			// Y coordinate of bounding box bottom
	gint				onscreen_left;				// X coordinate of bounding box left
	gint				onscreen_right;				// X coordinate of bounding box right
	gint				onscreen_top;				// Y coordinate of bounding box top
	gint				pixmap_height;				// Height of the front store
	gint				pixmap_width;				// Width of the front store
	gfloat				scaled_height_ratio;		// Used to calculate a vertical scaling ratio
	gfloat				scaled_width_ratio;			// Used to calculate a horizontal scaling ratio
	gint				selected_row;				// Holds the number of the row that is selected
	gint				start_x;					// X position at the layer objects start time
	gint				start_y;					// Y position at the layer objects start time
	layer 				*this_layer_data;			// Pointer to the data for the selected layer
	slide				*this_slide_data;			// Alias to make things easier
	guint				tmp_int;					// Temporary integer


	// Only do this function if we have a front store available and a project loaded
	if ((NULL == get_front_store()) || (FALSE == get_project_active()))
	{
		return TRUE;
	}

	// Set the delete key focus to be layers
	set_delete_focus(FOCUS_LAYER);

	// Change the focus of the window to be this widget
	gtk_widget_grab_focus(GTK_WIDGET(widget));

	// Initialise some things
	this_slide_data = get_current_slide_data();
	gdk_drawable_get_size(GDK_PIXMAP(get_front_store()), &pixmap_width, &pixmap_height);

	// Check for primary mouse button click
	if (1 != event->button)
	{
		// Not a primary mouse click, so return
		return TRUE;
	}

	// Reset the mouse drag toggle
	set_mouse_dragging(FALSE);

	// Check if this was a double mouse click.  If it was, open an edit dialog
	if (GDK_2BUTTON_PRESS == event->type)
	{
		// Open an edit dialog
		layer_edit();

		return TRUE;
	}

	// Check if this was a triple mouse click.  If it was, ignore it
	if (GDK_3BUTTON_PRESS == event->type)
	{
		return TRUE;
	}

	// If we're presently creating a new highlight layer, store the mouse coordinates
	if (TYPE_HIGHLIGHT == get_new_layer_selected())
	{
		// Save the mouse coordinates
		set_stored_x(event->x);
		set_stored_y(event->y);

		// Reset the invalidation area
		set_invalidation_end_x(event->x);
		set_invalidation_end_y(event->y);
		set_invalidation_start_x(event->x - 1);
		set_invalidation_start_y(event->y - 1);

		return TRUE;
	}

	// If the user has clicked on the start or end points for the selected layer, we
	// don't want to do the collision detection below that changes layers
	if (END_POINTS_INACTIVE == get_end_point_status())
	{
		// * Check if the user is clicking on the layer start or end points *

		// Calculate the height and width scaling values for the main drawing area at its present size
		scaled_height_ratio = (gfloat) get_project_height() / (gfloat) pixmap_height;
		scaled_width_ratio = (gfloat) get_project_width() / (gfloat) pixmap_width;

		// Determine which row is selected in the time line
		selected_row = time_line_get_selected_layer_num(this_slide_data->timeline_widget);
		layer_pointer = g_list_first(this_slide_data->layers);
		this_layer_data = g_list_nth_data(layer_pointer, selected_row);

		// If the layer data isn't accessible, then don't run this function
		if (NULL == this_layer_data)
		{
			return TRUE;
		}

		// Calculate start and end points
		finish_x = (this_layer_data->x_offset_finish / scaled_width_ratio) + END_POINT_HORIZONTAL_OFFSET;
		finish_y = (this_layer_data->y_offset_finish / scaled_height_ratio) + END_POINT_VERTICAL_OFFSET;
		start_x = (this_layer_data->x_offset_start / scaled_width_ratio) + END_POINT_HORIZONTAL_OFFSET;
		start_y = (this_layer_data->y_offset_start / scaled_height_ratio) + END_POINT_VERTICAL_OFFSET;

		// Is the user clicking on an end point?
		if (((event->x >= start_x)							// Start point
			&& (event->x <= start_x + END_POINT_WIDTH)
			&& (event->y >= start_y)
			&& (event->y <= start_y + END_POINT_HEIGHT)) ||
			((event->x >= finish_x)							// End point
			&& (event->x <= finish_x + END_POINT_WIDTH)
			&& (event->y >= finish_y)
			&& (event->y <= finish_y + END_POINT_HEIGHT)))
		{
			// Retrieve the layer size information
			switch (this_layer_data->object_type)
			{
				case TYPE_EMPTY:
					// We can't drag an empty layer, so reset things and return
					set_mouse_dragging(FALSE);
					set_end_point_status(END_POINTS_INACTIVE);
					set_stored_x(-1);
					set_stored_y(-1);
					return TRUE;

				case TYPE_HIGHLIGHT:
					box_width = ((layer_highlight *) this_layer_data->object_data)->width;
					box_height = ((layer_highlight *) this_layer_data->object_data)->height;
					break;

				case TYPE_GDK_PIXBUF:
					// If this is the background layer, then we ignore it
					if (TRUE == this_layer_data->background)
					{
						set_mouse_dragging(FALSE);
						set_end_point_status(END_POINTS_INACTIVE);
						set_stored_x(-1);
						set_stored_y(-1);
						return TRUE;
					}

					// No it's not, so process it
					box_width = ((layer_image *) this_layer_data->object_data)->width;
					box_height = ((layer_image *) this_layer_data->object_data)->height;
					break;

				case TYPE_MOUSE_CURSOR:
					box_width = ((layer_mouse *) this_layer_data->object_data)->width;
					box_height = ((layer_mouse *) this_layer_data->object_data)->height;
					break;

				case TYPE_TEXT:
					box_width = ((layer_text *) this_layer_data->object_data)->rendered_width;
					box_height = ((layer_text *) this_layer_data->object_data)->rendered_height;
					break;

				default:
					message = g_string_new(NULL);
					g_string_printf(message, "%s ED377: %s", _("Error"), _("Unknown layer type."));
					display_warning(message->str);
					g_string_free(message, TRUE);

					return TRUE;  // Unknown layer type, so no idea how to extract the needed data for the next code
			}

			// Work out the bounding box boundaries (scaled)
			if ((event->x >= start_x)							// Left
				&& (event->x <= start_x + END_POINT_WIDTH)		// Right
				&& (event->y >= start_y)						// Top
				&& (event->y <= start_y + END_POINT_HEIGHT))	// Bottom
			{
				// Start point clicked
				onscreen_left = this_layer_data->x_offset_start / scaled_width_ratio;
				onscreen_top = this_layer_data->y_offset_start / scaled_width_ratio;;
				onscreen_right = (this_layer_data->x_offset_start + box_width) / scaled_height_ratio;
				onscreen_bottom = (this_layer_data->y_offset_start + box_height) / scaled_height_ratio;
			} else
			{
				// End point clicked
				onscreen_left = this_layer_data->x_offset_finish / scaled_width_ratio;
				onscreen_top = this_layer_data->y_offset_finish / scaled_width_ratio;;
				onscreen_right = (this_layer_data->x_offset_finish + box_width) / scaled_height_ratio;
				onscreen_bottom = (this_layer_data->y_offset_finish + box_height) / scaled_height_ratio;
			}

			// Ensure the bounding box doesn't go out of bounds
			onscreen_left = CLAMP(onscreen_left, 2, pixmap_width - 2);
			onscreen_top = CLAMP(onscreen_top, 2, pixmap_height - 2);
			onscreen_right = CLAMP(onscreen_right, 2, pixmap_width - 2);
			onscreen_bottom = CLAMP(onscreen_bottom, 2, pixmap_height - 2);

			// Draw a bounding box onscreen
			draw_bounding_box(onscreen_left, onscreen_top, onscreen_right, onscreen_bottom);

			// End point clicked, so we return in order to avoid the collision detection
			return TRUE;
		}
	}

	// * Do collision detection here to determine if the user has clicked on a layer's object *

	this_slide_data = get_current_slide_data();
	calculate_object_boundaries();
	collision_list = detect_collisions(collision_list, event->x, event->y);
	if (NULL == collision_list)
	{
		// If there was no collision, then select the background layer
		time_line_set_selected_layer_num(this_slide_data->timeline_widget, this_slide_data->num_layers - 1);  // *Needs* the -1, don't remove

		// Clear any existing handle box
		gdk_draw_drawable(GDK_DRAWABLE(get_main_drawing_area()->window), GDK_GC(get_main_drawing_area()->style->fg_gc[GTK_WIDGET_STATE(get_main_drawing_area())]),
				GDK_PIXMAP(get_front_store()), 0, 0, 0, 0, -1, -1);

		// Reset the stored mouse coordinates
		set_stored_x(-1);
		set_stored_y(-1);

		// Free the memory allocated during the collision detection
		g_list_free(collision_list);
		collision_list = NULL;

		return TRUE;
	}

	// * To get here there must have been at least one collision *

	// Save the mouse coordinates
	set_stored_x(event->x);
	set_stored_y(event->y);

	// Determine which layer the user has selected in the timeline
	selected_row = time_line_get_selected_layer_num(this_slide_data->timeline_widget);

	// Is the presently selected layer in the collision list?
	collision_list = g_list_first(collision_list);
	num_collisions = g_list_length(collision_list);
	for (count_int = 0; count_int < num_collisions; count_int++)
	{
		collision_list = g_list_first(collision_list);
		collision_list = g_list_nth(collision_list, count_int);
		layer_pointer = g_list_first(this_slide_data->layers);
		tmp_int = g_list_position(layer_pointer, ((boundary_box *) collision_list->data)->layer_ptr);
		if (tmp_int == selected_row)
		{
			// Return if the presently selected row is in the collision list, as we don't want to change our selected layer
			return TRUE;
		}
	}

	// * To get here, the presently selected layer wasn't in the collision list *

	// The presently selected row is not in the collision list, so move the selection row to the first collision
	collision_list = g_list_first(collision_list);
	selected_row = g_list_position(this_slide_data->layers, ((boundary_box *) collision_list->data)->layer_ptr);
	time_line_set_selected_layer_num(this_slide_data->timeline_widget, selected_row);

	// Draw a handle box around the new selected object
	draw_handle_box();

	// Free the memory allocated during the collision detection
	g_list_free(collision_list);
	collision_list = NULL;

	return TRUE;
}
示例#17
0
static void
list_volumes (GList *volumes,
	      int indent,
	      gboolean only_with_no_drive)
{
  GList *l, *mounts;
  int c, i;
  GMount *mount;
  GVolume *volume;
  GDrive *drive;
  char *name;
  char *uuid;
  GFile *activation_root;
  char **ids;
  GIcon *icon;
  char *type_name;
  
  for (c = 0, l = volumes; l != NULL; l = l->next, c++)
    {
      volume = (GVolume *) l->data;
      
      if (only_with_no_drive)
	{
	  drive = g_volume_get_drive (volume);
	  if (drive != NULL)
	    {
	      g_object_unref (drive);
	      continue;
	    }
	}
      
      name = g_volume_get_name (volume);
      
      g_print ("%*sVolume(%d): %s\n", indent, "", c, name);
      g_free (name);

      type_name = get_type_name (volume);
      g_print ("%*sType: %s\n", indent+2, "", type_name);
      g_free (type_name);

      if (extra_detail)
	{
	  ids = g_volume_enumerate_identifiers (volume);
	  if (ids && ids[0] != NULL)
	    {
	      g_print ("%*sids:\n", indent+2, "");
	      for (i = 0; ids[i] != NULL; i++)
		{
		  char *id = g_volume_get_identifier (volume,
						      ids[i]);
		  g_print ("%*s %s: '%s'\n", indent+2, "", ids[i], id);
		  g_free (id);
		}
	    }
	  g_strfreev (ids);
	  
	  uuid = g_volume_get_uuid (volume);
	  if (uuid)
	    g_print ("%*suuid=%s\n", indent + 2, "", uuid);
	  activation_root = g_volume_get_activation_root (volume);
	  if (activation_root)
            {
              char *uri;
              uri = g_file_get_uri (activation_root);
              g_print ("%*sactivation_root=%s\n", indent + 2, "", uri);
              g_free (uri);
              g_object_unref (activation_root);
            }
      icon = g_volume_get_icon (volume);
      if (icon)
        {
          if (G_IS_THEMED_ICON (icon))
            show_themed_icon_names (G_THEMED_ICON (icon), indent + 2);

          g_object_unref (icon);
        }

	  g_print ("%*scan_mount=%d\n", indent + 2, "", g_volume_can_mount (volume));
	  g_print ("%*scan_eject=%d\n", indent + 2, "", g_volume_can_eject (volume));
	  g_free (uuid);
	}
      
      mount = g_volume_get_mount (volume);
      if (mount)
	{
	  mounts = g_list_prepend (NULL, mount);
	  list_mounts (mounts, indent + 2, FALSE);
	  g_list_free (mounts);
	  g_object_unref (mount);
	}
    }  
}
示例#18
0
void FontSupport::drawText(const WFont& font, const WRectF& rect,
			   WFlags<AlignmentFlag> flags, const WString& text)
{
  PANGO_LOCK;

  std::string utf8 = text.toUTF8();

  std::vector<PangoGlyphString *> glyphs;
  int width;

  GList *items = layoutText(font, utf8, glyphs, width);

  AlignmentFlag hAlign = flags & AlignHorizontalMask;
  AlignmentFlag vAlign = flags & AlignVerticalMask;

  /* FIXME handle bidi ! */

  double x;
  switch (hAlign) {
  case AlignLeft:
    x = rect.left();
    break;
  case AlignRight:
    x = rect.right() - pangoUnitsToDouble(width);
    break;
  case AlignCenter:
    x = rect.center().x() - pangoUnitsToDouble(width/2);
    break;
  default:
    x = 0;
  }

  unsigned i = 0;
  for (GList *elem = items; elem; elem = elem->next) {
    PangoItem *item = (PangoItem *)elem->data;
    PangoAnalysis *analysis = &item->analysis;

    PangoGlyphString *gl = glyphs[i++];

    currentFont_ = analysis->font;

    /*
     * Note, we are actually ignoring the selected glyphs here, which
     * is a pitty and possibly wrong if the device does not make the
     * same selection !
     */
    WString s = WString::fromUTF8(utf8.substr(item->offset,
					      item->length));

    device_->drawText(WRectF(x, rect.y(),
			     1000, rect.height()),
		      AlignLeft | vAlign, TextSingleLine,
		      s);

    WTextItem textItem = device_->measureText(s, -1, false);

    x += textItem.width();

    pango_item_free(item);
    pango_glyph_string_free(gl);
  }

  g_list_free(items);

  currentFont_ = 0;
}
示例#19
0
static EmployeeWindow *
gnc_employee_new_window (QofBook *bookp,
                         GncEmployee *employee)
{
    EmployeeWindow *ew;
    GtkBuilder *builder;
    GtkWidget *hbox, *edit;
    gnc_commodity *currency;
    GNCPrintAmountInfo print_info;
    GList *acct_types;
    Account *ccard_acct;

    /*
     * Find an existing window for this employee.  If found, bring it to
     * the front.
     */
    if (employee)
    {
        GncGUID employee_guid;

        employee_guid = *gncEmployeeGetGUID (employee);
        ew = gnc_find_first_gui_component (DIALOG_EDIT_EMPLOYEE_CM_CLASS,
                                           find_handler, &employee_guid);
        if (ew)
        {
            gtk_window_present (GTK_WINDOW(ew->dialog));
            return(ew);
        }
    }

    /* Find the default currency */
    if (employee)
        currency = gncEmployeeGetCurrency (employee);
    else
        currency = gnc_default_currency ();

    /*
     * No existing employee window found.  Build a new one.
     */
    ew = g_new0 (EmployeeWindow, 1);

    ew->book = bookp;

    /* Find the dialog */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-employee.glade", "Employee Dialog");
    ew->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Employee Dialog"));

    g_object_set_data (G_OBJECT (ew->dialog), "dialog_info", ew);

    /* Get entry points */
    ew->id_entry = GTK_WIDGET(gtk_builder_get_object (builder, "id_entry"));
    ew->username_entry = GTK_WIDGET(gtk_builder_get_object (builder, "username_entry"));

    ew->name_entry = GTK_WIDGET(gtk_builder_get_object (builder, "name_entry"));
    ew->addr1_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr1_entry"));
    ew->addr2_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr2_entry"));
    ew->addr3_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr3_entry"));
    ew->addr4_entry = GTK_WIDGET(gtk_builder_get_object (builder, "addr4_entry"));
    ew->phone_entry = GTK_WIDGET(gtk_builder_get_object (builder, "phone_entry"));
    ew->fax_entry = GTK_WIDGET(gtk_builder_get_object (builder, "fax_entry"));
    ew->email_entry = GTK_WIDGET(gtk_builder_get_object (builder, "email_entry"));

    ew->language_entry = GTK_WIDGET(gtk_builder_get_object (builder, "language_entry"));
    ew->active_check = GTK_WIDGET(gtk_builder_get_object (builder, "active_check"));

    /* Currency */
    edit = gnc_currency_edit_new();
    gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(edit), currency);
    ew->currency_edit = edit;

    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "currency_box"));
    gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);

    /* WORKDAY: Value */
    edit = gnc_amount_edit_new();
    gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
    print_info = gnc_integral_print_info ();
    print_info.max_decimal_places = 5;
    gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
    gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 100000);
    ew->workday_amount = edit;
    gtk_widget_show (edit);

    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "hours_hbox"));
    gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);

    /* RATE: Monetary Value */
    edit = gnc_amount_edit_new();
    print_info = gnc_commodity_print_info (currency, FALSE);
    gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
    gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
    gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit),
                                  gnc_commodity_get_fraction (currency));
    ew->rate_amount = edit;
    gtk_widget_show (edit);

    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "rate_hbox"));
    gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);

    /* CCard Account Selection */
    ew->ccard_acct_check = GTK_WIDGET(gtk_builder_get_object (builder, "ccard_check"));

    edit = gnc_account_sel_new();
    acct_types = g_list_prepend(NULL, (gpointer)ACCT_TYPE_CREDIT);
    gnc_account_sel_set_acct_filters (GNC_ACCOUNT_SEL(edit), acct_types, NULL);
    g_list_free (acct_types);

    ew->ccard_acct_sel = edit;
    gtk_widget_show (edit);

    hbox = GTK_WIDGET(gtk_builder_get_object (builder, "ccard_acct_hbox"));
    gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);

    /* Setup signals */
    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ew);

    /* Setup initial values */
    if (employee != NULL)
    {
        GncAddress *addr;

        ew->dialog_type = EDIT_EMPLOYEE;
        ew->employee_guid = *gncEmployeeGetGUID (employee);

        addr = gncEmployeeGetAddr (employee);

        gtk_entry_set_text (GTK_ENTRY (ew->id_entry), gncEmployeeGetID (employee));
        gtk_entry_set_text (GTK_ENTRY (ew->username_entry), gncEmployeeGetUsername (employee));

        /* Setup Address */
        gtk_entry_set_text (GTK_ENTRY (ew->name_entry), gncAddressGetName (addr));
        gtk_entry_set_text (GTK_ENTRY (ew->addr1_entry), gncAddressGetAddr1 (addr));
        gtk_entry_set_text (GTK_ENTRY (ew->addr2_entry), gncAddressGetAddr2 (addr));
        gtk_entry_set_text (GTK_ENTRY (ew->addr3_entry), gncAddressGetAddr3 (addr));
        gtk_entry_set_text (GTK_ENTRY (ew->addr4_entry), gncAddressGetAddr4 (addr));
        gtk_entry_set_text (GTK_ENTRY (ew->phone_entry), gncAddressGetPhone (addr));
        gtk_entry_set_text (GTK_ENTRY (ew->fax_entry), gncAddressGetFax (addr));
        gtk_entry_set_text (GTK_ENTRY (ew->email_entry), gncAddressGetEmail (addr));

        gtk_entry_set_text (GTK_ENTRY (ew->language_entry),
                            gncEmployeeGetLanguage (employee));

        /* Set toggle buttons */
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->active_check),
                                      gncEmployeeGetActive (employee));

        ew->component_id =
            gnc_register_gui_component (DIALOG_EDIT_EMPLOYEE_CM_CLASS,
                                        gnc_employee_window_refresh_handler,
                                        gnc_employee_window_close_handler,
                                        ew);
    }
    else
    {
        employee = gncEmployeeCreate (bookp);
        ew->employee_guid = *gncEmployeeGetGUID (employee);

        ew->dialog_type = NEW_EMPLOYEE;
        ew->component_id =
            gnc_register_gui_component (DIALOG_NEW_EMPLOYEE_CM_CLASS,
                                        gnc_employee_window_refresh_handler,
                                        gnc_employee_window_close_handler,
                                        ew);
    }


    /* I know that employee exists here -- either passed in or just created */
    /* Set the workday and rate values */
    gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (ew->workday_amount),
                                gncEmployeeGetWorkday (employee));
    gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (ew->rate_amount),
                                gncEmployeeGetRate (employee));


    ccard_acct = gncEmployeeGetCCard (employee);
    if (ccard_acct == NULL)
    {
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->ccard_acct_check), FALSE);
        gtk_widget_set_sensitive (ew->ccard_acct_sel, FALSE);
    }
    else
    {
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->ccard_acct_check), TRUE);
        gnc_account_sel_set_account (GNC_ACCOUNT_SEL (ew->ccard_acct_sel), ccard_acct, FALSE);
    }

    /* XXX: Set the ACL */

    gnc_gui_component_watch_entity_type (ew->component_id,
                                         GNC_EMPLOYEE_MODULE_NAME,
                                         QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);

    gtk_widget_show_all (ew->dialog);

    if (ccard_acct == NULL)
        gtk_widget_hide (ew->ccard_acct_sel);

    g_object_unref(G_OBJECT(builder));

    return ew;
}
示例#20
0
WTextItem FontSupport::measureText(const WFont& font, const WString& text,
				   double maxWidth, bool wordWrap)
{
  PANGO_LOCK;

  /*
   * Note: accurate measuring on a bitmap requires that the transformation
   * is applied, because hinting may push chars to boundaries e.g. when
   * rotated (or scaled too?)
   */
  std::string utf8 = text.toUTF8();
  const char *s = utf8.c_str();

  if (wordWrap) {
    int utflen = g_utf8_strlen(s, -1);
    PangoLogAttr *attrs = new PangoLogAttr[utflen + 1];
    PangoLanguage *language = pango_language_from_string("en-US");

    pango_get_log_attrs(s, utf8.length(), -1, language, attrs, utflen + 1);

    double w = 0, nextW = -1;

    int current = 0;
    int measured = 0;
    int end = 0;

    bool maxWidthReached = false;

    for (int i = 0; i < utflen + 1; ++i) {
      if (i == utflen || attrs[i].is_line_break) {
	int cend = g_utf8_offset_to_pointer(s, end) - s;

	WTextItem ti
	  = measureText(font, WString::fromUTF8(utf8.substr(measured,
							    cend - measured)),
			-1, false);

	if (w + ti.width() > maxWidth) {
	  nextW = ti.width();
	  maxWidthReached = true;
	  break;
	} else {
	  measured = cend;
	  current = g_utf8_offset_to_pointer(s, i) - s;
	  w += ti.width();

	  if (i == utflen)
	    w += measureText(font, WString::fromUTF8(utf8.substr(measured)),
			     -1, false).width();
	}
      }

      if (!attrs[i].is_white)
	end = i + 1;
    }

    delete[] attrs;

    if (maxWidthReached) {
      return WTextItem(WString::fromUTF8(utf8.substr(0, current)), w, nextW);
    } else {
      return WTextItem(text, w);
    }
  } else {
    std::vector<PangoGlyphString *> glyphs;
    int width;

    GList *items = layoutText(font, utf8, glyphs, width);

    double w = pangoUnitsToDouble(width);

    for (unsigned i = 0; i < glyphs.size(); ++i)
      pango_glyph_string_free(glyphs[i]);

    g_list_foreach(items, (GFunc) pango_item_free, 0);
    g_list_free(items);

    return WTextItem(text, w);
  }
}
示例#21
0
/*
 * change the visualization method 
 */
void gtkui_vis_method(void)
{
   GtkWidget *dialog, *button, *prev, *vbox;
   GSList *curr = NULL;
   gint active = 0, response = 0;

   GList *lang_list = NULL;
   GtkWidget *hbox, *lang_combo, *label;
   char encoding[50], *local_lang, def_lang[75];


   DEBUG_MSG("gtk_vis_method");

   dialog = gtk_dialog_new_with_buttons("Visualization method...", GTK_WINDOW (window), 
               GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
               GTK_STOCK_OK, GTK_RESPONSE_OK, 
               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
   gtk_container_set_border_width(GTK_CONTAINER(dialog), 10);

   vbox = GTK_DIALOG (dialog)->vbox;

   button = gtk_radio_button_new_with_label(NULL, 
               "hex     Print the packets in hex format.");
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, FALSE, 0);
   if(strcmp(vmethod, "hex") == 0)
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
   prev = button;

   button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (prev),
               "ascii   Print only \"printable\" characters, the others are displayed as dots '.'");
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, FALSE, 0);
   if(strcmp(vmethod, "ascii") == 0)
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
   prev = button;

   button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (prev),
               "text    Print only the \"printable\" characters and skip the others.");
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, FALSE, 0);
   if(strcmp(vmethod, "text") == 0)
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
   prev = button;

   button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (prev),
               "ebcdic  Convert an EBCDIC text to ASCII.");
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, FALSE, 0);
   if(strcmp(vmethod, "ebcdic") == 0)
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
   prev = button;

   button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (prev),
               "html    Strip all the html tags from the text. A tag is every string between < and >.");
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, FALSE, 0);
   if(strcmp(vmethod, "html") == 0)
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
   prev = button;

/* start UTF8 */
   button = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON (prev),
               "utf8    Convert the data from the encoding specified below to UTF8 before displaying it.");
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), button, FALSE, FALSE, 0);
   if(strcmp(vmethod, "utf8") == 0)
      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (button), TRUE);
   prev = button;

   hbox = gtk_hbox_new (FALSE, 6);
   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);

   label = gtk_label_new ("Character encoding : ");
   gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

   /* get the system's default encoding, and if it's not UTF8, add it to the list */
   if(!g_get_charset(&local_lang)) {
      snprintf(def_lang, 75, "%s (System Default)", local_lang);
      lang_list = g_list_append(lang_list, def_lang);
   }

   /* some other common encodings */
   lang_list = g_list_append(lang_list, "UTF-8");
   lang_list = g_list_append(lang_list, "EBCDIC-US (IBM)");
   lang_list = g_list_append(lang_list, "ISO-8859-15 (Western Europe)");
   lang_list = g_list_append(lang_list, "ISO-8859-2 (Central Europe)");
   lang_list = g_list_append(lang_list, "ISO-8859-7 (Greek)");
   lang_list = g_list_append(lang_list, "ISO-8859-8 (Hebrew)");
   lang_list = g_list_append(lang_list, "ISO-8859-9 (Turkish)");
   lang_list = g_list_append(lang_list, "ISO-2022-JP (Japanese)");
   lang_list = g_list_append(lang_list, "SJIS (Japanese)");
   lang_list = g_list_append(lang_list, "CP949 (Korean)");
   lang_list = g_list_append(lang_list, "CP1251 (Cyrillic)");
   lang_list = g_list_append(lang_list, "CP1256 (Arabic)");
   lang_list = g_list_append(lang_list, "GB18030 (Chinese)");

   /* make a drop down box and assign the list to it */
   lang_combo = gtk_combo_new();
   gtk_combo_set_popdown_strings (GTK_COMBO (lang_combo), lang_list);
   gtk_box_pack_start (GTK_BOX (hbox), lang_combo, TRUE, TRUE, 0);

   /* list is stored in the widget, can safely free this copy */
   g_list_free(lang_list);
/* end UTF8 */
      
   gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);

   response = gtk_dialog_run(GTK_DIALOG (dialog));
   if(response == GTK_RESPONSE_OK) {
      gtk_widget_hide(dialog);

      /* see which button was clicked */
      active = 0;
      for(curr = gtk_radio_button_get_group(GTK_RADIO_BUTTON (button)); curr; curr = curr->next) {
         active++;
         if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (curr->data)))
            break;
      }

      /* set vmethod string */
      switch(active) {
         case 6: strcpy(vmethod, "hex"); break;
         case 5: strcpy(vmethod, "ascii"); break; 
         case 4: strcpy(vmethod, "text"); break;
         case 3: strcpy(vmethod, "ebcdic"); break;
         case 2: strcpy(vmethod, "html"); break;
         case 1: /* utf8 */
            /* copy first word from encoding choice */
            sscanf(gtk_entry_get_text(GTK_ENTRY (GTK_COMBO (lang_combo)->entry)),
                   "%[^ ]", encoding);
            if(strlen(encoding) > 0) {
               strcpy(vmethod, "utf8");
               set_utf8_encoding(encoding);
               break;
            }
         default: strcpy(vmethod, "ascii");
      }

      set_format(vmethod);
   }

   gtk_widget_destroy(dialog);
}
示例#22
0
void FontSupport::drawText(const WFont& font, const WRectF& rect,
			   const WTransform& transform, Bitmap& bitmap,
			   WFlags<AlignmentFlag> flags,
			   const WString& text)
{
  PANGO_LOCK;

  PangoMatrix matrix;
  matrix.xx = transform.m11();
  matrix.xy = transform.m21();
  matrix.yx = transform.m12();
  matrix.yy = transform.m22();
  matrix.x0 = transform.dx();
  matrix.y0 = transform.dy();

  std::string utf8 = text.toUTF8();

  std::vector<PangoGlyphString *> glyphs;
  int width;

  pango_context_set_matrix(context_, &matrix);

  /*
   * Oh my god, somebody explain me why we need to do this...
   */
  WFont f = font;
  f.setSize(font.sizeLength().toPixels()
	    / pango_matrix_get_font_scale_factor(&matrix));

  GList *items = layoutText(f, utf8, glyphs, width);
  pango_context_set_matrix(context_, 0);

  AlignmentFlag hAlign = flags & AlignHorizontalMask;

  /* FIXME handle bidi ! */

  double x;
  switch (hAlign) {
  case AlignLeft:
    x = rect.left();
    break;
  case AlignRight:
    x = rect.right() - pangoUnitsToDouble(width);
    break;
  case AlignCenter:
    x = rect.center().x() - pangoUnitsToDouble(width/2);
    break;
  default:
    x = 0;
  }

  AlignmentFlag vAlign = flags & AlignVerticalMask;

  PangoFont *pangoFont = matchFont(font).pangoFont();
  PangoFontMetrics *metrics = pango_font_get_metrics(pangoFont, NULL);

  double ascent
    = pangoUnitsToDouble(pango_font_metrics_get_ascent(metrics));
  double descent 
    = pangoUnitsToDouble(pango_font_metrics_get_descent(metrics));

  pango_font_metrics_unref(metrics);

  double baseline = ascent;
  double height = ascent + descent;

  double y;
  switch (vAlign) {
  case AlignTop:
    y = rect.top() + baseline;
    break;
  case AlignMiddle:
    y = rect.center().y() - height / 2 + baseline;
    break;
  case AlignBottom:
    y = rect.bottom() - height + baseline;
    break;
  default:
    y = 0;
  }

  FT_Bitmap bmp;
  bmp.buffer = bitmap.buffer();
  bmp.width = bitmap.width();
  bmp.rows = bitmap.height();
  bmp.pitch = bitmap.pitch();
  bmp.pixel_mode = FT_PIXEL_MODE_GRAY;
  bmp.num_grays = 16; // ???

  GList *elem;
  unsigned i = 0;

  for (elem = items; elem; elem = elem->next) {
    PangoItem *item = (PangoItem *)elem->data;
    PangoAnalysis *analysis = &item->analysis;

    PangoGlyphString *gl = glyphs[i++];

    pango_ft2_render_transformed(&bmp, &matrix,
				 analysis->font, gl,
				 pangoUnitsFromDouble(x),
				 pangoUnitsFromDouble(y));

    x += pangoUnitsToDouble(pango_glyph_string_get_width(gl));

    pango_glyph_string_free(gl);
    pango_item_free(item);
  }

  g_list_free(items);
}
示例#23
0
/*
 * delete selected rows from env variables page 
 */
void delete_selected_rows()
{
	/* path to select after deleting finishes */
	GtkTreeRowReference *reference_to_select = NULL;

	/* empty row path */
	GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row);

	/* get selected rows */
	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(envtree));
	GList *rows = gtk_tree_selection_get_selected_rows(selection, &model);

	/* check whether only empty row was selected */
	if (1 != gtk_tree_selection_count_selected_rows(selection) ||
	    gtk_tree_path_compare((GtkTreePath*)rows->data, empty_path))
	{
		/* get references to the selected rows and find out what to
		select after deletion */
		GList *references = NULL;
		GList *iter = rows;
		while (iter)
		{
			GtkTreePath *path = (GtkTreePath*)iter->data;
			if (!reference_to_select)
			{
				/* select upper sibling of the upper
				selected row that has unselected upper sibling */
				GtkTreePath *sibling = gtk_tree_path_copy(path);
				if(gtk_tree_path_prev(sibling))
				{
					if (!gtk_tree_selection_path_is_selected(selection, sibling))
						reference_to_select = gtk_tree_row_reference_new(gtk_tree_view_get_model(GTK_TREE_VIEW(envtree)), sibling);
				}
				else if (gtk_tree_path_next(sibling), gtk_tree_path_compare(path, sibling))
					reference_to_select = gtk_tree_row_reference_new(gtk_tree_view_get_model(GTK_TREE_VIEW(envtree)), sibling);
			}
			
			if (gtk_tree_path_compare(path, empty_path))
				references = g_list_append(references, gtk_tree_row_reference_new(model, path));
			
			iter = iter->next;
		}
		
		/* if all (with or without empty row) was selected - set empty row
		as a path to be selected after deleting */
		if (!reference_to_select)
			reference_to_select = gtk_tree_row_reference_copy (empty_row);

		iter = references;
		while (iter)
		{
			GtkTreeRowReference *reference = (GtkTreeRowReference*)iter->data;
			GtkTreePath *path = gtk_tree_row_reference_get_path(reference);

			GtkTreeIter titer;
			gtk_tree_model_get_iter(model, &titer, path);
			gtk_list_store_remove(store, &titer);

			iter = iter->next;
		}

		/* set selection */
		gtk_tree_selection_unselect_all(selection);
		GtkTreePath *path = gtk_tree_row_reference_get_path(reference_to_select);
		gtk_tree_selection_select_path(selection, path);
		gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(envtree), path, NULL, TRUE, 0.5, 0.5);

		/* free references list */
		g_list_foreach (references, (GFunc)gtk_tree_row_reference_free, NULL);
		g_list_free (references);
	}
	
	/* free selection reference */
	gtk_tree_row_reference_free(reference_to_select);

	/* free rows list */
	g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
	g_list_free (rows);
}
示例#24
0
static void
mex_library_plugin_init (MexLibraryPlugin *self)
{
    GrlMediaPlugin *plugin;
    GrlPluginRegistry *registry;

    MexLibraryPluginPrivate *priv = self->priv =
                                        LIBRARY_PLUGIN_PRIVATE (self);

    registry = grl_plugin_registry_get_default ();

    plugin = grl_plugin_registry_lookup_source (registry, "grl-filesystem");
    if (plugin)
    {
        GList *query_keys;
        MexFeed *feed;
        GrlMedia *box;
        const gchar *path;
        MexModelInfo *video_info, *photo_info, *music_info;

        query_keys = grl_metadata_key_list_new (GRL_METADATA_KEY_ID,
                                                GRL_METADATA_KEY_TITLE,
                                                GRL_METADATA_KEY_MIME,
                                                GRL_METADATA_KEY_URL,
                                                GRL_METADATA_KEY_DATE,
                                                NULL);

        /* Add the videos model */
        path = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
        box = mex_library_plugin_get_box_for_path (GRL_MEDIA_SOURCE (plugin),
                query_keys, path);

        if (box)
        {
            GList *metadata_keys =
                grl_metadata_key_list_new (GRL_METADATA_KEY_ID,
                                           GRL_METADATA_KEY_DESCRIPTION,
                                           GRL_METADATA_KEY_DURATION,
                                           GRL_METADATA_KEY_THUMBNAIL,
                                           GRL_METADATA_KEY_WIDTH,
                                           GRL_METADATA_KEY_HEIGHT,
                                           NULL);

            feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (plugin),
                                       query_keys, metadata_keys, box);
            g_object_set (feed, "icon-name", "icon-library",
                          "placeholder-text", "No videos found", NULL);


            mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, G_MAXINT);

            video_info = mex_model_info_new_with_sort_funcs (MEX_MODEL (feed),
                         "videos", 0);
            priv->models = g_list_append (priv->models, video_info);
            g_object_unref (feed);
            g_list_free (metadata_keys);
        }

        /* Add the photos model */
        path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
        box = mex_library_plugin_get_box_for_path (GRL_MEDIA_SOURCE (plugin),
                query_keys, path);

        if (box)
        {
            GList *metadata_keys =
                grl_metadata_key_list_new (GRL_METADATA_KEY_ID,
                                           GRL_METADATA_KEY_DESCRIPTION,
                                           GRL_METADATA_KEY_THUMBNAIL,
                                           GRL_METADATA_KEY_WIDTH,
                                           GRL_METADATA_KEY_HEIGHT,
                                           NULL);

            feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (plugin),
                                       query_keys, metadata_keys, box);
            g_object_set (feed, "icon-name", "icon-library",
                          "placeholder-text", "No pictures found", NULL);

            mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, G_MAXINT);

            photo_info = mex_model_info_new_with_sort_funcs (MEX_MODEL (feed),
                         "pictures", 0);
            priv->models = g_list_append (priv->models, photo_info);
            g_object_unref (feed);
            g_list_free (metadata_keys);
        }

        /* Add the music model */
        path = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
        box = mex_library_plugin_get_box_for_path (GRL_MEDIA_SOURCE (plugin),
                query_keys, path);

        if (box)
        {
            GList *metadata_keys =
                grl_metadata_key_list_new (GRL_METADATA_KEY_ID,
                                           GRL_METADATA_KEY_DESCRIPTION,
                                           GRL_METADATA_KEY_THUMBNAIL,
                                           GRL_METADATA_KEY_WIDTH,
                                           GRL_METADATA_KEY_HEIGHT,
                                           GRL_METADATA_KEY_ARTIST,
                                           GRL_METADATA_KEY_ALBUM,
                                           NULL);

            feed = mex_grilo_feed_new (GRL_MEDIA_SOURCE (plugin),
                                       query_keys, metadata_keys, box);
            g_object_set (feed, "icon-name", "icon-library",
                          "placeholder-text", "No music found", NULL);

            mex_grilo_feed_browse (MEX_GRILO_FEED (feed), 0, G_MAXINT);

            music_info = mex_model_info_new_with_sort_funcs (MEX_MODEL (feed),
                         "music", 0);
            priv->models = g_list_append (priv->models, music_info);
            g_object_unref (feed);
            g_list_free (metadata_keys);
        }

        g_list_free (query_keys);
    }
    else
        g_warning ("Filesystem plugin not found");
}
示例#25
0
/*
 * create target page
 */
void tpage_init()
{
	page = gtk_hbox_new(FALSE, 0);
	
	GtkWidget *lbox =		gtk_vbox_new(FALSE, SPACING);
	GtkWidget *mbox =		gtk_vbox_new(FALSE, SPACING);
	GtkWidget *rbox =		gtk_vbox_new(FALSE, SPACING);
	GtkWidget* separator =	gtk_vseparator_new();
	
	/* right box with Load/Save buttons */
	gtk_container_set_border_width(GTK_CONTAINER(rbox), SPACING);

	loadbtn = gtk_button_new_from_stock(GTK_STOCK_OPEN);
	g_signal_connect(G_OBJECT(loadbtn), "clicked", G_CALLBACK (on_load_config), (gpointer)TRUE);

	savebtn = gtk_button_new_from_stock(GTK_STOCK_SAVE);
	g_signal_connect(G_OBJECT(savebtn), "clicked", G_CALLBACK (on_save_config), NULL);
	
	clearbtn = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
	g_signal_connect(G_OBJECT(clearbtn), "clicked", G_CALLBACK (on_clear), NULL);

	gtk_box_pack_start(GTK_BOX(rbox), loadbtn, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(rbox), savebtn, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(rbox), clearbtn, FALSE, TRUE, 0);
	

	GtkWidget *hombox =	gtk_hbox_new(TRUE, 0);

	/* left box */
	gtk_container_set_border_width(GTK_CONTAINER(lbox), SPACING);

	/* Target frame */
	GtkWidget *frame = gtk_frame_new(_("Target"));
	GtkWidget *vbox = gtk_vbox_new(FALSE, 0);

	/* filename hbox */
	GtkWidget *hbox = gtk_hbox_new(FALSE, SPACING);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), SPACING);

	targetname = gtk_entry_new ();
	button_browse = gtk_button_new_with_label(_("Browse"));
	g_signal_connect(G_OBJECT(button_browse), "clicked", G_CALLBACK (on_target_browse_clicked), NULL);
	
	gtk_box_pack_start(GTK_BOX(hbox), targetname, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), button_browse, FALSE, TRUE, 0);

	/* pack in the vertical box */
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
	
	/* debugger type hbox */
	hbox = gtk_hbox_new(FALSE, SPACING);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), SPACING);
	GtkWidget *label = gtk_label_new(_("Debugger:")); 
	cmb_debugger = gtk_combo_box_new_text();

	GList *modules = debug_get_modules();
	GList *iter = modules;
	while (iter)
	{
		gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_debugger), (gchar*)iter->data);
		iter = iter->next;
	}
	g_list_free(modules);
	gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_debugger), 0);

	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(hbox), cmb_debugger, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	gtk_container_add(GTK_CONTAINER(frame), vbox);

	gtk_box_pack_start(GTK_BOX(lbox), frame, FALSE, FALSE, 0);

	/* Arguments frame */
	frame = gtk_frame_new(_("Arguments"));
	hbox = gtk_vbox_new(FALSE, SPACING);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), SPACING);
	
	textview = gtk_text_view_new ();
	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), GTK_WRAP_CHAR);
	
	gtk_box_pack_start(GTK_BOX(hbox), textview, TRUE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(frame), hbox);

	gtk_box_pack_start(GTK_BOX(lbox), frame, TRUE, TRUE, 0);
	

	/* Environment */
	gtk_container_set_border_width(GTK_CONTAINER(mbox), SPACING);
	frame = gtk_frame_new(_("Environment variables"));
	hbox = gtk_hbox_new(FALSE, SPACING);
	gtk_container_set_border_width(GTK_CONTAINER(hbox), SPACING);

	store = gtk_list_store_new (
		N_COLUMNS,
		G_TYPE_STRING,
		G_TYPE_STRING);
	model = GTK_TREE_MODEL(store);
	envtree = gtk_tree_view_new_with_model (model);
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(envtree), TRUE);
	gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(envtree), GTK_TREE_VIEW_GRID_LINES_VERTICAL);
	g_object_set(envtree, "rules-hint", TRUE, NULL);
	g_signal_connect(G_OBJECT(envtree), "key-press-event", G_CALLBACK (on_envtree_keypressed), NULL);

	gchar *header;
	int	char_width = get_char_width(envtree);

	header = _("Name");
	renderer_name = gtk_cell_renderer_text_new ();
	g_object_set (renderer_name, "editable", TRUE, NULL);
	g_signal_connect (G_OBJECT (renderer_name), "edited", G_CALLBACK (on_name_changed), NULL);
	column_name = create_column(header, renderer_name, FALSE,
		get_header_string_width(header, MW_NAME, char_width),
		"text", NAME);
	gtk_tree_view_append_column (GTK_TREE_VIEW (envtree), column_name);

	header = _("Value");
	renderer_value = gtk_cell_renderer_text_new ();
	column_value = create_column(header, renderer_value, TRUE,
		get_header_string_width(header, MW_VALUE, char_width),
		"text", VALUE);
	g_signal_connect (G_OBJECT (renderer_value), "edited", G_CALLBACK (on_value_changed), NULL);
	g_signal_connect (G_OBJECT (renderer_value), "editing-started", G_CALLBACK (on_value_editing_started), NULL);
	g_signal_connect (G_OBJECT (renderer_value), "editing-canceled", G_CALLBACK (on_value_editing_cancelled), NULL);
	gtk_tree_view_column_set_cell_data_func(column_value, renderer_value, on_render_value, NULL, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (envtree), column_value);

	/* add empty row */
	add_empty_row();

	/* set multiple selection */
	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(envtree));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);

	gtk_box_pack_start(GTK_BOX(hbox), envtree, TRUE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(frame), hbox);
	gtk_box_pack_start(GTK_BOX(mbox), frame, TRUE, TRUE, 0);


	gtk_box_pack_start(GTK_BOX(hombox), lbox, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(hombox), mbox, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(page), hombox, TRUE, TRUE, 0);

	gtk_box_pack_start(GTK_BOX(page), separator, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(page), rbox, FALSE, TRUE, 0);

	/* update Load/Save config button */
	tpage_on_document_activate(document_get_current());
}
示例#26
0
文件: mymem.c 项目: majenkotech/pcb
static void
g_list_free_full (GList *list, GDestroyNotify free_func) {
    g_list_foreach (list, (GFunc) free_func, NULL);
    g_list_free (list);
}
示例#27
0
gboolean
alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm)
{
    Dialog dialog;
    int response_id;
    GList *icon_list;
    char *gladefile;

    g_return_val_if_fail (alarm != NULL, FALSE);

    dialog.alarm = alarm;
    dialog.ecal = ecal;

    gladefile = g_build_filename (EVOLUTION_GLADEDIR,
                                  "alarm-dialog.glade",
                                  NULL);
    dialog.xml = glade_xml_new (gladefile, NULL, NULL);
    g_free (gladefile);
    if (!dialog.xml) {
        g_message (G_STRLOC ": Could not load the Glade XML file!");
        return FALSE;
    }

    if (!get_widgets (&dialog)) {
        g_object_unref(dialog.xml);
        return FALSE;
    }

    if (!setup_select_names (&dialog)) {
        g_object_unref (dialog.xml);
        return FALSE;
    }

    init_widgets (&dialog);

    alarm_to_dialog (&dialog);

    gtk_widget_ensure_style (dialog.toplevel);
    gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->vbox), 0);
    gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog.toplevel)->action_area), 12);

    icon_list = e_icon_factory_get_icon_list ("stock_calendar");
    if (icon_list) {
        gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list);
        g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
        g_list_free (icon_list);
    }

    gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel),
                                  GTK_WINDOW (parent));

    response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel));

    if (response_id == GTK_RESPONSE_OK)
        dialog_to_alarm (&dialog);

    gtk_widget_destroy (dialog.toplevel);
    g_object_unref (dialog.xml);

    return response_id == GTK_RESPONSE_OK ? TRUE : FALSE;
}
示例#28
0
/*
 * _gtk_recent_chooser_get_items:
 * @chooser: a #GtkRecentChooser
 * @filter: a #GtkRecentFilter
 * @sort_func: (allow-none): sorting function, or %NULL
 * @sort_data: (allow-none): sorting function data, or %NULL
 *
 * Default implementation for getting the filtered, sorted and
 * clamped list of recently used resources from a #GtkRecentChooser.
 * This function should be used by implementations of the
 * #GtkRecentChooser interface inside the GtkRecentChooser::get_items
 * vfunc.
 *
 * Returns: a list of #GtkRecentInfo objects
 */
GList *
_gtk_recent_chooser_get_items (GtkRecentChooser  *chooser,
                               GtkRecentFilter   *filter,
                               GtkRecentSortFunc  sort_func,
                               gpointer           sort_data)
{
    GtkRecentManager *manager;
    gint limit;
    GtkRecentSortType sort_type;
    GList *items;
    GCompareDataFunc compare_func;
    gint length;

    g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);

    manager = _gtk_recent_chooser_get_recent_manager (chooser);
    if (!manager)
        return NULL;

    items = gtk_recent_manager_get_items (manager);
    if (!items)
        return NULL;

    limit = gtk_recent_chooser_get_limit (chooser);
    if (limit == 0)
        return NULL;

    if (filter)
    {
        GList *filter_items, *l;
        gboolean local_only = FALSE;
        gboolean show_private = FALSE;
        gboolean show_not_found = FALSE;

        g_object_get (G_OBJECT (chooser),
                      "local-only", &local_only,
                      "show-private", &show_private,
                      "show-not-found", &show_not_found,
                      NULL);

        filter_items = NULL;
        for (l = items; l != NULL; l = l->next)
        {
            GtkRecentInfo *info = l->data;
            gboolean remove_item = FALSE;

            if (get_is_recent_filtered (filter, info))
                remove_item = TRUE;

            if (local_only && !gtk_recent_info_is_local (info))
                remove_item = TRUE;

            if (!show_private && gtk_recent_info_get_private_hint (info))
                remove_item = TRUE;

            if (!show_not_found && !gtk_recent_info_exists (info))
                remove_item = TRUE;

            if (!remove_item)
                filter_items = g_list_prepend (filter_items, info);
            else
                gtk_recent_info_unref (info);
        }

        g_list_free (items);
        items = filter_items;
    }

    if (!items)
        return NULL;

    sort_type = gtk_recent_chooser_get_sort_type (chooser);
    switch (sort_type)
    {
    case GTK_RECENT_SORT_NONE:
        compare_func = NULL;
        break;
    case GTK_RECENT_SORT_MRU:
        compare_func = (GCompareDataFunc) sort_recent_items_mru;
        break;
    case GTK_RECENT_SORT_LRU:
        compare_func = (GCompareDataFunc) sort_recent_items_lru;
        break;
    case GTK_RECENT_SORT_CUSTOM:
        compare_func = (GCompareDataFunc) sort_recent_items_proxy;
        break;
    default:
        g_assert_not_reached ();
        break;
    }

    if (compare_func)
    {
        SortRecentData sort_recent;

        sort_recent.func = sort_func;
        sort_recent.data = sort_data;

        items = g_list_sort_with_data (items, compare_func, &sort_recent);
    }

    length = g_list_length (items);
    if ((limit != -1) && (length > limit))
    {
        GList *clamp, *l;

        clamp = g_list_nth (items, limit - 1);
        if (!clamp)
            return items;

        l = clamp->next;
        clamp->next = NULL;

        g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref);
    }

    return items;
}
示例#29
0
/**
 * gst_aggregator_iterate_sinkpads:
 * @self: The #GstAggregator
 * @func: The function to call.
 * @user_data: The data to pass to @func.
 *
 * Iterate the sinkpads of aggregator to call a function on them.
 *
 * This method guarantees that @func will be called only once for each
 * sink pad.
 */
gboolean
gst_aggregator_iterate_sinkpads (GstAggregator * self,
    GstAggregatorPadForeachFunc func, gpointer user_data)
{
  gboolean result = FALSE;
  GstIterator *iter;
  gboolean done = FALSE;
  GValue item = { 0, };
  GList *seen_pads = NULL;

  iter = gst_element_iterate_sink_pads (GST_ELEMENT (self));

  if (!iter)
    goto no_iter;

  while (!done) {
    switch (gst_iterator_next (iter, &item)) {
      case GST_ITERATOR_OK:
      {
        GstPad *pad;

        pad = g_value_get_object (&item);

        /* if already pushed, skip. FIXME, find something faster to tag pads */
        if (pad == NULL || g_list_find (seen_pads, pad)) {
          g_value_reset (&item);
          break;
        }

        GST_LOG_OBJECT (self, "calling function on pad %s:%s",
            GST_DEBUG_PAD_NAME (pad));
        result = func (self, pad, user_data);

        done = !result;

        seen_pads = g_list_prepend (seen_pads, pad);

        g_value_reset (&item);
        break;
      }
      case GST_ITERATOR_RESYNC:
        gst_iterator_resync (iter);
        break;
      case GST_ITERATOR_ERROR:
        GST_ERROR_OBJECT (self,
            "Could not iterate over internally linked pads");
        done = TRUE;
        break;
      case GST_ITERATOR_DONE:
        done = TRUE;
        break;
    }
  }
  g_value_unset (&item);
  gst_iterator_free (iter);

  if (seen_pads == NULL) {
    GST_DEBUG_OBJECT (self, "No pad seen");
    return FALSE;
  }

  g_list_free (seen_pads);

no_iter:
  return result;
}
static gpointer
book_view_thread (gpointer data)
{
    EBookBackendScalix *bs;
    gboolean stopped;
    const char *query;
    EDataBookView *book_view;
    EBookBackendScalixPrivate *priv;
    ScalixBackendSearchClosure *closure;
    GList *iter;
    ScanContext context;
    gboolean res;

    book_view = data;
    closure = closure_get (book_view);
    bs = closure->bs;
    priv = E_BOOK_BACKEND_SCALIX_GET_PRIVATE (bs);
    stopped = FALSE;

    bonobo_object_ref (book_view);

    if (priv->container == NULL) {
        e_data_book_view_notify_complete (book_view,
                                          GNOME_Evolution_Addressbook_AuthenticationRequired);

        bonobo_object_unref (book_view);
        return NULL;
    }

    query = e_data_book_view_get_card_query (book_view);
    context.sexp = e_book_backend_sexp_new (query);
    context.backend = E_BOOK_BACKEND (bs);
    context.obj_list = NULL;
    context.return_objects = TRUE;

    if (!(context.search_needed = query_is_search (query))) {
        e_data_book_view_notify_status_message (book_view, _("Loading..."));
    } else {
        e_data_book_view_notify_status_message (book_view, _("Searching..."));
    }

    g_mutex_lock (closure->mutex);
    g_cond_signal (closure->cond);
    g_mutex_unlock (closure->mutex);

    res = scalix_container_foreach (priv->container, scan_objects, &context);

    if (res == FALSE) {
        e_data_book_view_notify_complete (book_view,
                                          GNOME_Evolution_Addressbook_OtherError);
        bonobo_object_unref (book_view);
        return NULL;
    }

    for (iter = context.obj_list; iter; iter = iter->next) {

        g_mutex_lock (closure->mutex);
        stopped = closure->stopped;
        g_mutex_unlock (closure->mutex);

        if (stopped) {
            break;
        }

        e_data_book_view_notify_update (book_view, iter->data);
        g_object_unref (iter->data);
    }

    /*FIXME: we leek objects if stopped */
    g_list_free (context.obj_list);

    if (!stopped) {
        e_data_book_view_notify_complete (book_view,
                                          GNOME_Evolution_Addressbook_Success);
    }

    bonobo_object_unref (book_view);

    return NULL;
}