Esempio n. 1
0
static void update_playlist(GmpvMpv *mpv)
{
	/* The length of "playlist//filename" including null-terminator (19)
	 * plus the number of digits in the maximum value of 64 bit int (19).
	 */
	const gsize filename_prop_str_size = 38;
	GtkListStore *store = gmpv_playlist_get_store(mpv->playlist);
	gchar *filename_prop_str = g_malloc(filename_prop_str_size);
	gboolean iter_end = FALSE;
	GtkTreeIter iter;
	mpv_node mpv_playlist;
	gint playlist_count;
	gint i;

	mpv_check_error(mpv_get_property(	mpv->mpv_ctx,
						"playlist",
						MPV_FORMAT_NODE,
						&mpv_playlist ));
	playlist_count = mpv_playlist.u.list->num;

	gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);

	for(i = 0; i < playlist_count; i++)
	{
		mpv_node_list *prop_list = mpv_playlist.u.list->values[i].u.list;
		gchar *uri = NULL;
		gchar *title = NULL;
		gchar *name = NULL;

		for(gint j = 0; j < prop_list->num; j++)
		{
			const gchar *key = prop_list->keys[j];
			const mpv_node value = prop_list->values[j];

			if(g_strcmp0(key, "filename") == 0)
			{
				g_assert(value.format == MPV_FORMAT_STRING);
				uri = value.u.string;
			}
			else if(g_strcmp0(key, "title") == 0)
			{
				g_assert(value.format == MPV_FORMAT_STRING);
				title = value.u.string;
			}
		}

		name = title?g_strdup(title):get_name_from_path(uri);

		/* Overwrite current entry if it doesn't match the new value */
		if(!iter_end)
		{
			gchar *old_name = NULL;
			gchar *old_uri = NULL;
			gboolean name_update;
			gboolean uri_update;

			gtk_tree_model_get
				(	GTK_TREE_MODEL(store), &iter,
					PLAYLIST_NAME_COLUMN, &old_name,
					PLAYLIST_URI_COLUMN, &old_uri, -1 );

			name_update = (g_strcmp0(name, old_name) != 0);
			uri_update = (g_strcmp0(uri, old_uri) != 0);

			/* Only set the name if either the title can be
			 * retrieved or the name is unset. This preserves the
			 * correct title if it becomes unavailable later such as
			 * when restarting mpv.
			 */
			if(name_update && (!old_name || title || uri_update))
			{
				gtk_list_store_set
					(	store, &iter,
						PLAYLIST_NAME_COLUMN, name, -1 );
			}

			if(uri_update)
			{
				gtk_list_store_set
					(	store, &iter,
						PLAYLIST_URI_COLUMN, uri, -1 );
			}

			iter_end = !gtk_tree_model_iter_next
					(GTK_TREE_MODEL(store), &iter);

			g_free(old_name);
			g_free(old_uri);
		}
		/* Append entries to the playlist if there are fewer entries in
		 * the playlist widget than mpv's playlist.
		 */
		else
		{
			gmpv_playlist_append(mpv->playlist, name, uri);
		}

		g_free(name);
	}

	/* If there are more entries in the playlist widget than mpv's playlist,
	 * remove the excess entries from the playlist widget.
	 */
	if(!iter_end)
	{
		while(gtk_list_store_remove(store, &iter));
	}

	g_free(filename_prop_str);
	mpv_free_node_contents(&mpv_playlist);
}
Esempio n. 2
0
/*
 * Update the tree by adding/removing entries
 * Does not change other nodes
 */
static void update_tree(struct menu *src, GtkTreeIter * dst)
{
	struct menu *child1;
	GtkTreeIter iter, tmp;
	GtkTreeIter *child2 = &iter;
	gboolean valid;
	GtkTreeIter *sibling;
	struct symbol *sym;
	struct property *prop;
	struct menu *menu1, *menu2;

	if (src == &rootmenu)
		indent = 1;

	valid = gtk_tree_model_iter_children(model2, child2, dst);
	for (child1 = src->list; child1; child1 = child1->next) {

		prop = child1->prompt;
		sym = child1->sym;

	      reparse:
		menu1 = child1;
		if (valid)
			gtk_tree_model_get(model2, child2, COL_MENU,
					   &menu2, -1);
		else
			menu2 = NULL;	// force adding of a first child

#ifdef DEBUG
		printf("%*c%s | %s\n", indent, ' ',
		       menu1 ? menu_get_prompt(menu1) : "nil",
		       menu2 ? menu_get_prompt(menu2) : "nil");
#endif

		if (!menu_is_visible(child1) && !show_all) {	// remove node
			if (gtktree_iter_find_node(dst, menu1) != NULL) {
				memcpy(&tmp, child2, sizeof(GtkTreeIter));
				valid = gtk_tree_model_iter_next(model2,
								 child2);
				gtk_tree_store_remove(tree2, &tmp);
				if (!valid)
					return;	// next parent
				else
					goto reparse;	// next child
			} else
				continue;
		}

		if (menu1 != menu2) {
			if (gtktree_iter_find_node(dst, menu1) == NULL) {	// add node
				if (!valid && !menu2)
					sibling = NULL;
				else
					sibling = child2;
				gtk_tree_store_insert_before(tree2,
							     child2,
							     dst, sibling);
				set_node(child2, menu1, fill_row(menu1));
				if (menu2 == NULL)
					valid = TRUE;
			} else {	// remove node
				memcpy(&tmp, child2, sizeof(GtkTreeIter));
				valid = gtk_tree_model_iter_next(model2,
								 child2);
				gtk_tree_store_remove(tree2, &tmp);
				if (!valid)
					return;	// next parent
				else
					goto reparse;	// next child
			}
		} else if (sym && (sym->flags & SYMBOL_CHANGED)) {
			set_node(child2, menu1, fill_row(menu1));
		}

		indent++;
		update_tree(child1, child2);
		indent--;

		valid = gtk_tree_model_iter_next(model2, child2);
	}
}
Esempio n. 3
0
/*
 * Set a column in the map provider table to a new value and mirror the changes
 * in the key file.  If value is NULL, restore the default value.
 */
void
ph_config_set_map_provider(GtkTreeIter *iter,
                           guint row,
                           gint column,
                           const GValue *value)
{
    gchar *name;
    gchar *group;
    const gchar *key;

    g_return_if_fail(ph_config != NULL);
    g_return_if_fail(iter != NULL);
    g_return_if_fail(column >= 0 && column < PH_MAP_PROVIDER_COLUMN_COUNT);

    if (ph_config->map_providers == NULL)
        (void) ph_config_get_map_providers();

    g_return_if_fail(ph_config->map_providers != NULL);

    gtk_tree_model_get(GTK_TREE_MODEL(ph_config->map_providers), iter,
            PH_MAP_PROVIDER_COLUMN_NAME, &name, -1);
    group = ph_config_get_map_provider_group(name);
    key = ph_config_get_map_provider_key(column);

    if (value == NULL && row < G_N_ELEMENTS(ph_config_default_map_providers)) {
        /* restore default value for built-in provider */
        ph_map_provider_to_list_single(&ph_config_default_map_providers[row],
                ph_config->map_providers, iter, column);
        (void) g_key_file_remove_key(ph_config->key_file, group, key, NULL);
    }
    else {
        GValue target = { 0 };
        GType target_type;

        target_type = gtk_tree_model_get_column_type(
                GTK_TREE_MODEL(ph_config->map_providers), column);
        g_value_init(&target, target_type);

        if (value == NULL) {
            /* restore default value for another provider */
            switch (column) {
            case PH_MAP_PROVIDER_COLUMN_URL:
                g_value_set_static_string(&target, "");
                break;
            case PH_MAP_PROVIDER_COLUMN_TILE_SIZE:
                g_value_set_uint(&target, 256);
                break;
            case PH_MAP_PROVIDER_COLUMN_ZOOM_MIN:
                g_value_set_uint(&target, 0);
                break;
            case PH_MAP_PROVIDER_COLUMN_ZOOM_MAX:
                g_value_set_uint(&target, 18);
                break;
            case PH_MAP_PROVIDER_COLUMN_ZOOM_DETAIL:
                g_value_set_uint(&target, 14);
                break;
            default:
                g_warn_if_reached();
            }
        }
        else
            /* actually set to a new value */
            g_value_transform(value, &target);

        gtk_list_store_set_value(ph_config->map_providers, iter,
                column, &target);
        ph_config_set_value(group, key, &target);
        g_value_unset(&target);
    }

    g_free(name);
    g_free(group);
}
Esempio n. 4
0
static gint
gtk_app_chooser_sort_func (GtkTreeModel *model,
                           GtkTreeIter  *a,
                           GtkTreeIter  *b,
                           gpointer      user_data)
{
  gboolean a_recommended, b_recommended;
  gboolean a_fallback, b_fallback;
  gboolean a_heading, b_heading;
  gboolean a_default, b_default;
  gchar *a_name, *b_name, *a_casefold, *b_casefold;
  gint retval = 0;

  /* this returns:
   * - <0 if a should show before b
   * - =0 if a is the same as b
   * - >0 if a should show after b
   */

  gtk_tree_model_get (model, a,
                      COLUMN_NAME, &a_name,
                      COLUMN_RECOMMENDED, &a_recommended,
                      COLUMN_FALLBACK, &a_fallback,
                      COLUMN_HEADING, &a_heading,
                      COLUMN_DEFAULT, &a_default,
                      -1);

  gtk_tree_model_get (model, b,
                      COLUMN_NAME, &b_name,
                      COLUMN_RECOMMENDED, &b_recommended,
                      COLUMN_FALLBACK, &b_fallback,
                      COLUMN_HEADING, &b_heading,
                      COLUMN_DEFAULT, &b_default,
                      -1);

  /* the default one always wins */
  if (a_default && !b_default)
    {
      retval = -1;
      goto out;
    }

  if (b_default && !a_default)
    {
      retval = 1;
      goto out;
    }
  
  /* the recommended one always wins */
  if (a_recommended && !b_recommended)
    {
      retval = -1;
      goto out;
    }

  if (b_recommended && !a_recommended)
    {
      retval = 1;
      goto out;
    }

  /* the recommended one always wins */
  if (a_fallback && !b_fallback)
    {
      retval = -1;
      goto out;
    }

  if (b_fallback && !a_fallback)
    {
      retval = 1;
      goto out;
    }

  /* they're both recommended/falback or not, so if one is a heading, wins */
  if (a_heading)
    {
      retval = -1;
      goto out;
    }

  if (b_heading)
    {
      retval = 1;
      goto out;
    }

  /* don't order by name recommended applications, but use GLib's ordering */
  if (!a_recommended)
    {
      a_casefold = a_name != NULL ?
        g_utf8_casefold (a_name, -1) : NULL;
      b_casefold = b_name != NULL ?
        g_utf8_casefold (b_name, -1) : NULL;

      retval = g_strcmp0 (a_casefold, b_casefold);

      g_free (a_casefold);
      g_free (b_casefold);
    }

 out:
  g_free (a_name);
  g_free (b_name);

  return retval;
}
Esempio n. 5
0
extern void popup_all_block(GtkTreeModel *model, GtkTreeIter *iter, int id)
{
	char *name = NULL;
	char title[100];
	ListIterator itr = NULL;
	popup_info_t *popup_win = NULL;
	GError *error = NULL;
	int i=0;

	gtk_tree_model_get(model, iter, SORTID_BLOCK, &name, -1);

	switch(id) {
	case JOB_PAGE:
		snprintf(title, 100, "Jobs(s) in block %s", name);
		break;
	case PART_PAGE:
		snprintf(title, 100, "Partition(s) containing block %s", name);
		break;
	case RESV_PAGE:
		snprintf(title, 100, "Reservations(s) containing block %s",
			 name);
		break;
	case NODE_PAGE:
		snprintf(title, 100, "Midplane(s) in block %s", name);
		break;
	case SUBMIT_PAGE:
		snprintf(title, 100, "Submit job on %s", name);
		break;
	case INFO_PAGE:
		snprintf(title, 100, "Full info for block %s", name);
		break;
	default:
		g_print("Block got %d\n", id);
	}

	itr = list_iterator_create(popup_list);
	while ((popup_win = list_next(itr))) {
		if (popup_win->spec_info)
			if (!xstrcmp(popup_win->spec_info->title, title)) {
				break;
			}
	}
	list_iterator_destroy(itr);

	if (!popup_win) {
		if (id == INFO_PAGE)
			popup_win = create_popup_info(id, BLOCK_PAGE, title);
		else
			popup_win = create_popup_info(BLOCK_PAGE, id, title);
	} else {
		g_free(name);
		gtk_window_present(GTK_WINDOW(popup_win->popup));
		return;
	}

	/* Pass the model and the structs from the iter so we can always get
	   the current node_inx.
	*/
	popup_win->model = model;
	popup_win->iter = *iter;
	popup_win->node_inx_id = SORTID_NODE_INX;

	switch(id) {
	case JOB_PAGE:
		popup_win->spec_info->search_info->gchar_data = name;
		break;
	case PART_PAGE:
		g_free(name);
		gtk_tree_model_get(model, iter, SORTID_PARTITION, &name, -1);
		popup_win->spec_info->search_info->gchar_data = name;
		break;
	case RESV_PAGE:
	case NODE_PAGE:
		g_free(name);
		gtk_tree_model_get(model, iter, SORTID_NODELIST, &name, -1);
		gtk_tree_model_get(model, iter, SORTID_SMALL_BLOCK, &i, -1);
		if (i) {
			i=0;
			/* strip off the ionodes part */
			while (name[i]) {
				if (name[i] == '[') {
					name[i] = '\0';
					break;
				}
				i++;
			}
		}
		popup_win->spec_info->search_info->gchar_data = name;
		break;
	case INFO_PAGE:
		popup_win->spec_info->search_info->gchar_data = name;
		break;
	default:
		g_print("block got %d\n", id);
	}


	if (!sview_thread_new((gpointer)popup_thr, popup_win, FALSE, &error)) {
		g_printerr ("Failed to create part popup thread: %s\n",
			    error->message);
		return;
	}
}
Esempio n. 6
0
/**
 * Build data storage by querying the X server for all input devices.
 * Can be called multiple times, in which case it'll clean out and re-fill
 * update the tree store.
 */
static GtkTreeStore* query_devices(GDeviceSetup* gds)
{
    GtkTreeStore *treestore;
    GtkTreeModel *model;
    GtkTreeIter iter, child;
    XIDeviceInfo *devices, *dev;
    int ndevices;
    int i, j;
    int icontype;
    GdkPixbuf *icon;
    int valid, child_valid;
    int id, masterid;

    if (!gds->treeview)
    {
        treestore = gtk_tree_store_new(NUM_COLS,
                                       G_TYPE_UINT, /* deviceid*/
                                       G_TYPE_STRING, /* name */
                                       G_TYPE_UINT,
                                       GDK_TYPE_PIXBUF,
                                       G_TYPE_UINT
                                       );
        model = GTK_TREE_MODEL(treestore);
    } else
    {
        model = gtk_tree_view_get_model(gds->treeview);
        treestore = GTK_TREE_STORE(model);
    }

    gds->generation++;
    devices = XIQueryDevice(gds->dpy, XIAllDevices, &ndevices);

    /* First, run through all master device and append them to the tree store
     */
    for (i = 0; i < ndevices; i++)
    {
        dev = &devices[i];

        if (dev->use != XIMasterPointer && dev->use != XIMasterKeyboard)
            continue;

        valid = gtk_tree_model_get_iter_first(model, &iter);
        g_debug("MD %d: %s", dev->deviceid,  dev->name);

        while(valid) {
            gtk_tree_model_get(model, &iter, COL_ID, &id, -1);
            if (id == dev->deviceid)
            {
                gtk_tree_store_set(treestore, &iter,
                                   COL_GENERATION, gds->generation, -1);
                valid = 0xFF;
                break;
            }
            valid = gtk_tree_model_iter_next(model, &iter);
        }

        if (valid != 0xFF) /* new MD */
        {
            icontype = (dev->use == XIMasterPointer) ? ICON_MOUSE : ICON_KEYBOARD;
            icon = load_icon(icontype);

            gtk_tree_store_append(treestore, &iter, NULL);
            gtk_tree_store_set(treestore, &iter,
                               COL_ID, dev->deviceid,
                               COL_NAME, dev->name,
                               COL_USE, dev->use,
                               COL_ICON, icon,
                               COL_GENERATION, gds->generation,
                               -1);
            g_object_unref(icon);
        }
    }

    /* search for Floating fake master device */
    valid = gtk_tree_model_get_iter_first(model, &iter);
    while(valid)
    {
        gtk_tree_model_get(model, &iter, COL_ID, &id, -1);
        if (id == ID_FLOATING)
            break;

        valid = gtk_tree_model_iter_next(model, &iter);
    }

    if (!valid)
    {
        /* Attach a fake master device for "Floating" */
        icon = load_icon(ICON_FLOATING);
        gtk_tree_store_append(treestore, &iter, NULL);
        gtk_tree_store_set(treestore, &iter,
                COL_ID, ID_FLOATING,
                COL_NAME, "Floating",
                COL_USE, ID_FLOATING,
                COL_ICON, icon,
                COL_GENERATION, gds->generation,
                -1);
        g_object_unref(icon);
    } else {
        GtkTreeIter prev;
        GtkTreeIter pos = iter; /* current position of Floating */

        /* always move Floating fake device to end of list */
        while(valid)
        {
            prev = iter;
            valid = gtk_tree_model_iter_next(model, &iter);
        }

        gtk_tree_store_move_after(treestore, &pos, &prev);

        /* update generation too */
        gtk_tree_store_set(treestore, &pos,
                           COL_GENERATION, gds->generation, -1);
    }


    /* now that we added all MDs, run through again and add SDs to the
     * respective MD */
    for (i = 0; i < ndevices; i++)
    {
        dev = &devices[i];

        if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard)
   	  continue;

        g_debug("SD %d: %s", dev->deviceid, dev->name);

	valid = gtk_tree_model_get_iter_first(model, &iter);
	while(valid) {
	  gtk_tree_model_get(model, &iter, COL_ID, &masterid, -1);
	  if(dev->attachment == masterid || (dev->use == XIFloatingSlave && masterid == ID_FLOATING))
	    {
	      /* found master, check if we're already attached to it in
	       * the tree model */
	      child_valid = gtk_tree_model_iter_children(model, &child, &iter);
	      while (child_valid)
		{
		  gtk_tree_model_get(model, &child, COL_ID, &id);

		  if (id == dev->deviceid)
		    {
		      gtk_tree_store_set(treestore, &child,
					 COL_GENERATION, gds->generation, -1);
		      child_valid = 0xFF;
		      break;
		    }

		  child_valid = gtk_tree_model_iter_next(model, &child);
		}

	      /* new slave device, attach */
	      if (child_valid != 0xFF)
		{
		  gtk_tree_store_append(treestore, &child, &iter);
		  gtk_tree_store_set(treestore, &child,
				     COL_ID, dev->deviceid,
				     COL_NAME, dev->name,
				     COL_USE, dev->use,
				     COL_GENERATION, gds->generation,
				     -1);
		}
	      break;
	    }

	  valid = gtk_tree_model_iter_next(model, &iter);
	}
    }

    XIFreeDeviceInfo(devices);

    /* clean tree store of anything that doesn't have the current
       server generation */

    valid = gtk_tree_model_get_iter_first(model, &iter);
    while(valid)
    {
        int gen;

        child_valid = gtk_tree_model_iter_children(model, &child, &iter);
        while(child_valid)
        {
            gtk_tree_model_get(model, &child, COL_GENERATION, &gen, -1);
            if (gen < gds->generation)
                child_valid = gtk_tree_store_remove(treestore, &child);
            else
                child_valid = gtk_tree_model_iter_next(model, &child);
        }

        gtk_tree_model_get(model, &iter, COL_GENERATION, &gen, -1);
        if (gen < gds->generation)
            valid = gtk_tree_store_remove(treestore, &iter);
        else
            valid = gtk_tree_model_iter_next(model, &iter);
    }

    return treestore;
}
Esempio n. 7
0
void
on_open_export_dialog_activate (GtkButton *button, gpointer user_data)
{
	GSQL_TRACE_FUNC;
	
	GladeXML* gxml;
	GtkDialog *dialog;
	GtkWidget *combo;
	GtkWidget *combo_exptype;
	GtkWidget *choosebutton;
	GtkAlignment *alig;
	GtkAlignment *alig_exptype;
	GtkRadioButton *rbutton;
	GtkWidget *target;
	GtkWidget *headers;
	GtkWidget *progressbar, *config_vbox, *save_button;
	GSList *rgroup;
	GSQLContent *content = NULL;
	GSQLSession *session = NULL;
	GSQLWorkspace *workspace = NULL;
	gchar *encoding = NULL;
	static gchar *filename = NULL;
	static gboolean include_headers = TRUE;
	static gboolean only_fetched = FALSE;
	static gint exptype = 0;
	GtkTreeIter iter;
	GtkTreeModel *model;
	gint ret;
	
	gxml = glade_xml_new (GSQLP_EXPORTER_GLADE_DIALOG, "export_dialog", NULL);
	g_return_if_fail(gxml);
	
	dialog = (GtkDialog *) glade_xml_get_widget (gxml, "export_dialog");
	
	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gsql_window));
	
	alig = (GtkAlignment *) glade_xml_get_widget (gxml, "alignment_enc");
	alig_exptype = (GtkAlignment *) glade_xml_get_widget (gxml, "alignment_exptype");
	
	combo = (GtkWidget *) gsql_enconding_list ();
	combo_exptype = (GtkWidget *) get_export_types_combo ();
	
	target = (GtkWidget *) glade_xml_get_widget (gxml, "target");
	
	choosebutton = (GtkWidget *) glade_xml_get_widget (gxml, "choosebutton");
	
	headers = (GtkWidget *) glade_xml_get_widget (gxml, "headers");
	progressbar = (GtkWidget *) glade_xml_get_widget (gxml, "progressbar");
	config_vbox = (GtkWidget *) glade_xml_get_widget (gxml, "config_vbox");
	save_button = (GtkWidget *) glade_xml_get_widget (gxml, "save_button");
	
	g_signal_connect ((gpointer) choosebutton, "clicked",
						G_CALLBACK (on_choosebutton_activate),
						(gpointer) target);
	
	if (filename)
		gtk_entry_set_text (GTK_ENTRY (target), filename);
	
	if (exptype)
		gtk_combo_box_set_active (GTK_COMBO_BOX (combo_exptype), exptype);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (headers), include_headers);
	gtk_container_add (GTK_CONTAINER (alig), combo);
	gtk_container_add (GTK_CONTAINER (alig_exptype), combo_exptype);
	
	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gsql_window));
	
	// 2 - cancel, 3 - export complete (via gtk_dialog_response)
	while ((ret != 2) && (ret !=3))
	{
		ret = gtk_dialog_run (dialog);
		GSQL_DEBUG ("Export result dialog: [ret=%d]", ret);
	
		if (ret == 1) // Save action selected
		{
			GSQL_DEBUG ("Start exporting...");
			rbutton = (GtkRadioButton *) glade_xml_get_widget (gxml, "radiobutton1");
			rgroup = gtk_radio_button_get_group (rbutton);
		
			if (filename)
				g_free (filename);
		
			filename = g_strdup (gtk_entry_get_text (GTK_ENTRY (target)));

			GSQL_DEBUG ("GSList length: %d", g_slist_length (rgroup));
		
			if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_exptype), &iter))
			{
				model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_exptype));
				gtk_tree_model_get (model, &iter,
							0, &exptype, -1);
			}
		
			session = gsql_session_get_active ();
			workspace = gsql_session_get_workspace (session);
			content = gsql_workspace_get_current_content (workspace);
		
			gtk_widget_show (progressbar);
			gtk_widget_hide (config_vbox);
			gtk_widget_hide (save_button);
		
			g_object_set_data (G_OBJECT (content), "dialog", dialog);
			g_object_set_data (G_OBJECT (content), "progress", progressbar);
		
			g_return_if_fail (GSQL_IS_CONTENT (content));
		
			if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
			{
				model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
				gtk_tree_model_get (model, &iter,
							1, &encoding, -1);
				GSQL_DEBUG ("Exporter: encoding selected. [%s]", encoding);
			}
		
			include_headers = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (headers));

			GSQL_DEBUG ("Exporter: [filename=%s]", filename);
			switch (exptype)
			{
				case 0: // CSV
					GSQL_DEBUG ("Export type: CSV");
					exporter_export_to_csv (content, filename, 
											encoding, include_headers);
					break;
				case 1: // HTML
					GSQL_DEBUG ("Export type: HTML");
					exporter_export_to_html (content, filename, 
											 encoding, include_headers);
					break;
				case 2: // XML
					GSQL_DEBUG ("Export type: XML");
					exporter_export_to_xml (content, filename, 
											 encoding, include_headers);
					break;
				case 3: // Plain text
					GSQL_DEBUG ("Export type: Plain text");
					exporter_export_to_plain_text (content, filename, 
											 encoding, include_headers);
					break;
			}
		}
	
	}
	
	

	if (encoding)
		g_free (encoding);
	
	gtk_widget_destroy ((GtkWidget *) dialog);
	g_object_unref(G_OBJECT(gxml));
	
}
Esempio n. 8
0
static gboolean confirm_overwrite()
{
    GtkTreeIter iter;
    gboolean valid;
    gboolean exist = FALSE;
    gboolean settings_different = TRUE;

    Settings * user_settings;

    user_settings = settings_get_from_gui();
    if (settings_on_execute)
    {
        settings_different = !settings_equal(user_settings,
            settings_on_execute);
    }

    valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter);

    while (valid)
    {
        gchar *output_file;
        gchar *status;
        gboolean done;

        gtk_tree_model_get (GTK_TREE_MODEL(list_store), &iter,
            COL_OUTPUT_FILE, &output_file,
            COL_STATUS, &status, -1);

        done = strcmp("Done", status) == 0;

        if ((settings_different || !done) &&
            g_file_test(output_file, G_FILE_TEST_EXISTS))
            exist = TRUE;

        g_free(output_file);
        g_free(status);

        if (exist)
            break;

        valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter);
    }

    settings_delete(user_settings);

    if (exist)
    {
        GtkWidget * dialog_confirm_overwrite;
        gint result;

        dialog_confirm_overwrite =
            get_widget_checked("dialog_confirm_overwrite");

        result = gtk_dialog_run( GTK_DIALOG(dialog_confirm_overwrite) );
        gtk_widget_hide( dialog_confirm_overwrite );

        switch (result)
        {
        default:
            return FALSE;

        case GTK_RESPONSE_OK:
            return TRUE;
        }
    }
    else
    {
        /* no need to confirm -- no overwrites */
        return TRUE;
    }
}
Esempio n. 9
0
static void
process_item(GtkTreeIter *iter, Settings *user_settings, gboolean skip_done,
             int is_first)
{
    gchar *in_file, *out_full, *ancillary_file, *meta_file,
      *status, *polsarpro_aux_info, *interferogram_file,
      *coherence_file, *slave_metadata_file, *baseline_file,
      *uavsar_type;
    int pid, isPolSARPro = FALSE;

    pid = getpid();

    gtk_tree_model_get(GTK_TREE_MODEL(list_store), iter,
		       COL_INPUT_FILE, &in_file,
		       COL_ANCILLARY_FILE, &ancillary_file,
		       COL_METADATA_FILE, &meta_file,
		       COL_OUTPUT_FILE, &out_full,
		       COL_STATUS, &status,
		       COL_POLSARPRO_INFO, &polsarpro_aux_info,
		       COL_INTERFEROGRAM, &interferogram_file,
		       COL_COHERENCE, &coherence_file,
		       COL_SLAVE_METADATA, &slave_metadata_file,
		       COL_BASELINE, &baseline_file,
           COL_UAVSAR_TYPE, &uavsar_type,
		       -1);

    int image_data_type = extract_image_data_type(polsarpro_aux_info);
    if (image_data_type >= 0 && image_data_type < 3)
      isPolSARPro = TRUE;

    if (strcmp(status, "Done") != 0 || !skip_done)
    {
        //char *in_basename = stripExt(in_file);
        char *out_basename = stripExt(out_full);
        char *out_nameonly = get_basename(out_full);
        char *output_dir = getPath(out_full);
        char *config_file, *cmd_output, *tmp_dir, *intermediates_file;
        gchar *err_string;

        /* Ensure we have access to the output directory */
        if (!have_access_to_dir(output_dir, &err_string))
        {
            /* We don't -- issue a message in the "Status" column. */
            gtk_list_store_set(list_store, iter, COL_STATUS, err_string, -1);

            g_free(err_string);
            //free(in_basename);
            free(out_basename);
            free(output_dir);

            return;
        }

        tmp_dir = MALLOC(sizeof(char)*
            (strlen(output_dir)+strlen(out_nameonly)+32));
        if (strlen(output_dir) > 0) {
          sprintf(tmp_dir, "%s%c%s-%s", output_dir, DIR_SEPARATOR,
                  out_nameonly, time_stamp_dir());
        }
        else {
          sprintf(tmp_dir, "%s-%s", out_nameonly, time_stamp_dir());
        }

        create_clean_dir(tmp_dir);
        set_asf_tmp_dir(tmp_dir);

        config_file =
            settings_to_config_file(user_settings,
                                    in_file, ancillary_file, meta_file,
                                    out_full, output_dir,
                                    tmp_dir, polsarpro_aux_info,
				    interferogram_file, coherence_file,
				    slave_metadata_file, baseline_file, uavsar_type);
        if (!config_file) {
            err_string = "Error creating configuration file.";
            gtk_list_store_set(list_store, iter, COL_STATUS, err_string, -1);

            free(out_basename);
            free(output_dir);
            free(tmp_dir);
            return;
        }

        cmd_output = do_convert(pid, iter, config_file, TRUE,
            user_settings->keep_files, &intermediates_file);
        err_string = check_for_error(cmd_output);
        if (err_string) {
            // unsuccessful
            gtk_list_store_set(list_store, iter, COL_STATUS, err_string,
                COL_LOG, cmd_output, -1);
            FREE(err_string);
        }
        else {
            // successful -- move to "completed" list
            GtkTreeIter completed_iter;
            move_to_completed_files_list(iter, &completed_iter, cmd_output,
                                         intermediates_file);
            set_thumbnail(&completed_iter, tmp_dir, out_full, isPolSARPro);
            input_data_formats_changed();
            refresh_file_names();
        }

        // for subsequent runs, save the imported dem & mask
        settings_update_dem(user_settings, output_dir);
        settings_update_mask(user_settings, output_dir);

        free(config_file);
        free(out_basename);
        free(output_dir);
        free(out_nameonly);
        free(intermediates_file);
        g_free(cmd_output);

        if (!user_settings->keep_files)
            remove_dir(tmp_dir);

        free(tmp_dir);
    }

    g_free(status);
    g_free(out_full);
    g_free(ancillary_file);
    g_free(meta_file);
    g_free(in_file);
    g_free(polsarpro_aux_info);
}
Esempio n. 10
0
static void
network_model_update_property (const gchar *property,
                               GValue      *value,
                               gpointer     user_data)
{
  CarrickNetworkModel        *self = user_data;
  CarrickNetworkModelPrivate *priv = self->priv;
  GtkListStore               *store = GTK_LIST_STORE (self);
  GList                      *new_services = NULL;
  GList                      *old_services = NULL;
  GList                      *list_iter = NULL;
  GList                      *tmp = NULL;
  GtkTreeIter                 iter;
  gchar                      *path = NULL;
  DBusGProxy                 *service;
  guint                       index = 0;

  if (g_str_equal (property, "Services"))
    {
      old_services = priv->services;

      dbus_g_type_collection_value_iterate (value,
                                            network_model_iterate_services,
                                            &new_services);

      priv->services = new_services;

      for (list_iter = new_services;
           list_iter != NULL;
           list_iter = list_iter->next)
        {
          path = list_iter->data;

          /* Remove from old list, if present.
           * We only want stale services in old list
           */
          tmp = g_list_find_custom (old_services,
                                    path,
                                    (GCompareFunc) g_strcmp0);
          if (tmp)
            {
              old_services = g_list_delete_link (old_services, tmp);
            }

          /* if we don't have the service in the model, add it*/
          if (network_model_have_service_by_path (store, &iter, path) == FALSE)
            {
              service = dbus_g_proxy_new_for_name (priv->connection,
                                                   CONNMAN_SERVICE, path,
                                                   CONNMAN_SERVICE_INTERFACE);

              gtk_list_store_insert_with_values (store, &iter, -1,
                                                 CARRICK_COLUMN_PROXY, service,
                                                 CARRICK_COLUMN_INDEX, index,
                                                 -1);

              dbus_g_proxy_add_signal (service,
                                       "PropertyChanged",
                                       G_TYPE_STRING,
                                       G_TYPE_VALUE,
                                       G_TYPE_INVALID);

              dbus_g_proxy_connect_signal (service,
                                           "PropertyChanged",
                                           G_CALLBACK
                                           (network_model_service_changed_cb),
                                           self,
                                           NULL);

              net_connman_Service_get_properties_async
                (service,
                 network_model_service_get_properties_cb,
                 self);

              g_object_unref (service);
            }
          /* else update it */
          else
            {
              guint current_index;
              gtk_tree_model_get (GTK_TREE_MODEL (self), &iter,
                                  CARRICK_COLUMN_INDEX, &current_index,
                                  -1);
              if (current_index != index)
                gtk_list_store_set (store, &iter,
                                    CARRICK_COLUMN_INDEX, index,
                                    -1);
            }


          index++;
        }

      /* Old list only contains items not in new list.
       * Remove stale services */
      for (list_iter = old_services;
           list_iter != NULL;
           list_iter = list_iter->next)
        {
          path = list_iter->data;

          if (network_model_have_service_by_path (store, &iter, path) == TRUE)
            gtk_list_store_remove (store, &iter);

          g_free (path);
        }

      if (old_services)
        {
          g_list_free (old_services);
          old_services = NULL;
        }
    }
}
Esempio n. 11
0
void validate_menu(GtkTreeIter * iter)
{
	struct validate *validate;
	GtkWidget *scrolled_window;
	GtkWidget *text_view;
	GtkTextBuffer *text_buffer;

	gboolean updated = FALSE; 
	gdouble scroll_hvalue = 0;
	gdouble scroll_vvalue = 0;

	gtk_tree_model_get(GTK_TREE_MODEL(debr.ui_menu.model), iter, MENU_VALIDATE_POINTER, &validate, -1);
	if (validate != NULL) {
		updated = TRUE;
		validate->menu_iter = *iter;
		scroll_hvalue = gtk_adjustment_get_value(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(validate->widget)));
		scroll_vvalue = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(validate->widget)));
		gtk_text_buffer_set_text(validate->text_buffer, "", 0);
		goto out;
	}

	scrolled_window = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC,
				       GTK_POLICY_AUTOMATIC);
	gtk_box_pack_end(GTK_BOX(debr.ui_validate.text_view_vbox), scrolled_window, TRUE, TRUE, 0);
	text_buffer = gtk_text_buffer_new(NULL);
	text_view = gtk_text_view_new_with_buffer(text_buffer);
	gtk_widget_show(text_view);
	gtk_container_add(GTK_CONTAINER(scrolled_window), text_view);
	g_object_set(G_OBJECT(text_view), "editable", FALSE, "cursor-visible", FALSE, NULL);

	PangoFontDescription *font = pango_font_description_new();
	pango_font_description_set_family(font, "monospace");
	gtk_widget_modify_font(text_view, font);
	pango_font_description_free(font);

	GebrGeoXmlValidateOperations operations;
	operations.append_text = (void(*)(gpointer,const gchar*,...))validate_append_text;
	operations.append_text_emph = (void(*)(gpointer,const gchar*,...))validate_append_text_emph;
	operations.append_text_error = NULL;
	operations.append_text_error_with_paths = (void(*)(gpointer, gint, const gchar *, const gchar *, GebrValidateCaseName, const gchar *,
							   ...))validate_append_text_error;
	GebrGeoXmlValidateOptions options;
	options.all = TRUE;
	options.ehelp = -1;
	validate = g_new(struct validate, 1);
	validate->widget = scrolled_window;
	validate->text_view = text_view;
	validate->text_buffer = text_buffer;
	validate->menu_iter = *iter;
	validate->geoxml_validate = gebr_geoxml_validate_new(validate, operations, options);
	gtk_list_store_append(debr.ui_validate.list_store, &validate->iter);

out:
	gtk_tree_store_set(debr.ui_menu.model, iter, MENU_VALIDATE_NEED_UPDATE, FALSE,
			   MENU_VALIDATE_POINTER, validate, -1);

	GebrGeoXmlFlow * menu = menu_get_xml_pointer(iter);
	gint error_count = gebr_geoxml_validate_report_menu(validate->geoxml_validate, menu);
	gtk_list_store_set(debr.ui_validate.list_store, &validate->iter,
			   VALIDATE_ICON, !error_count ? debr.pixmaps.stock_apply : debr.pixmaps.stock_warning,
			   VALIDATE_FILENAME, gebr_geoxml_document_get_filename(GEBR_GEOXML_DOCUMENT(menu)),
			   VALIDATE_POINTER, validate, -1);
	validate_set_selected(&validate->iter);

	if (updated) {
		gtk_adjustment_set_value(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(validate->widget)), scroll_hvalue);
		gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(validate->widget)), scroll_vvalue);
	}
}
Esempio n. 12
0
static void
network_model_service_changed_cb (DBusGProxy  *service,
                                  const gchar *property,
                                  GValue      *value,
                                  gpointer     user_data)
{
  CarrickNetworkModel *self = user_data;
  GtkListStore        *store = GTK_LIST_STORE (self);
  GtkTreeIter          iter;
  GHashTable          *dict;

  if (property == NULL || value == NULL)
    return;

  if (network_model_have_service_by_proxy (store, &iter, service) == FALSE)
    return;

  if (g_str_equal (property, "State"))
    {
      const char *type, *state;
      DBusGProxy *service_proxy;

      /* HACK: connman (0.61) vpn handling is not consistent, so we
       * remove the provider on idle (otherwise it'll just hang there).
       * But: set the state first, so notifications etc happen. */

      state = g_value_get_string (value);
      gtk_list_store_set (store, &iter,
                          CARRICK_COLUMN_STATE, state,
                          -1);

      gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
                          CARRICK_COLUMN_TYPE, &type,
                          CARRICK_COLUMN_PROXY, &service_proxy,
                          -1);
      if (g_strcmp0 (type, "vpn") == 0 &&
          (g_strcmp0 (state, "idle") == 0 ||
           g_strcmp0 (state, "failure") == 0))
        net_connman_Manager_remove_provider_async (self->priv->manager,
                                                   dbus_g_proxy_get_path (service),
                                                   remove_provider_cb,
                                                   self);
    }
  else if (g_str_equal (property, "Favorite"))
    {
      gtk_list_store_set (store, &iter,
                          CARRICK_COLUMN_FAVORITE, g_value_get_boolean (value),
                          -1);
    }
  else if (g_str_equal (property, "Strength"))
    {
      guint current_strength;
      /* This is the most common change, and fairly unimportant...
       * Round to nearest ten, and avoid change notification */
      guint strength = 10 * ((g_value_get_uchar (value) + 5) / 10);

      gtk_tree_model_get (GTK_TREE_MODEL (self), &iter,
                          CARRICK_COLUMN_STRENGTH, &current_strength,
                          -1);
      if (current_strength != strength)
        gtk_list_store_set (store, &iter,
                            CARRICK_COLUMN_STRENGTH, strength,
                            -1);
    }
  else if (g_str_equal (property, "Name"))
    {
      gtk_list_store_set (store, &iter,
                          CARRICK_COLUMN_NAME, g_value_get_string (value),
                          -1);
    }
  else if (g_str_equal (property, "PassphraseRequired") ||
	  g_str_equal (property, "SetupRequired"))
    {
      /* Rather than store this property we're just going to trigger
       * GetProperties to pull the up-to-date passphrase
       */
      net_connman_Service_get_properties_async
        (service,
         network_model_service_get_properties_cb,
         self);
    }
  else if (g_str_equal (property, "IPv4"))
    {
      dict = g_value_get_boxed (value);
      if (dict)
        {
          const char *method, *address, *netmask, *gateway;

          method = get_string (dict, "Method");
          address = get_string (dict, "Address");
          netmask = get_string (dict, "Netmask");
          gateway = get_string (dict, "Gateway");
          gtk_list_store_set (store, &iter,
                              CARRICK_COLUMN_METHOD, method,
                              CARRICK_COLUMN_ADDRESS, address,
                              CARRICK_COLUMN_NETMASK, netmask,
                              CARRICK_COLUMN_GATEWAY, gateway,
                              -1);
        }
    }
  else if (g_str_equal (property, "IPv4.Configuration"))
    {
      dict = g_value_get_boxed (value);
      if (dict)
        {
          const char *method, *address, *netmask, *gateway;

          method = get_string (dict, "Method");
          address = get_string (dict, "Address");
          netmask = get_string (dict, "Netmask");
          gateway = get_string (dict, "Gateway");
          gtk_list_store_set (store, &iter,
                              CARRICK_COLUMN_CONFIGURED_METHOD, method,
                              CARRICK_COLUMN_CONFIGURED_ADDRESS, address,
                              CARRICK_COLUMN_CONFIGURED_NETMASK, netmask,
                              CARRICK_COLUMN_CONFIGURED_GATEWAY, gateway,
                              -1);
        }
    }
  else if (g_str_equal (property, "IPv6"))
    {
      dict = g_value_get_boxed (value);
      if (dict)
        {
          const char *method, *address, *gateway;
          guint prefix;

          method = get_string (dict, "Method");
          address = get_string (dict, "Address");
          prefix = get_uint (dict, "PrefixLength");
          gateway = get_string (dict, "Gateway");
          gtk_list_store_set (store, &iter,
                              CARRICK_COLUMN_IPV6_METHOD, method,
                              CARRICK_COLUMN_IPV6_ADDRESS, address,
                              CARRICK_COLUMN_IPV6_PREFIX_LENGTH, prefix,
                              CARRICK_COLUMN_IPV6_GATEWAY, gateway,
                              -1);
        }
    }
  else if (g_str_equal (property, "IPv6.Configuration"))
    {
      dict = g_value_get_boxed (value);
      if (dict)
        {
          const char *method, *address, *gateway;
          guint prefix;

          method = get_string (dict, "Method");
          address = get_string (dict, "Address");
          prefix = get_uint (dict, "PrefixLength");
          gateway = get_string (dict, "Gateway");
          gtk_list_store_set (store, &iter,
                              CARRICK_COLUMN_CONFIGURED_IPV6_METHOD, method,
                              CARRICK_COLUMN_CONFIGURED_IPV6_ADDRESS, address,
                              CARRICK_COLUMN_CONFIGURED_IPV6_PREFIX_LENGTH, prefix,
                              CARRICK_COLUMN_CONFIGURED_IPV6_GATEWAY, gateway,
                              -1);
        }
    }
  else if (g_str_equal (property, "Nameservers"))
    {
      gtk_list_store_set (store, &iter,
                          CARRICK_COLUMN_NAMESERVERS,
                          g_value_get_boxed (value),
                          -1);
    }
  else if (g_str_equal (property, "Nameservers.Configuration"))
    {
      gtk_list_store_set (store, &iter,
                          CARRICK_COLUMN_CONFIGURED_NAMESERVERS,
                          g_value_get_boxed (value),
                          -1);
    }
  else if (g_str_equal (property, "Immutable"))
    {
      gtk_list_store_set (store, &iter,
                          CARRICK_COLUMN_IMMUTABLE, g_value_get_boolean (value),
                          -1);
    }
  else if (g_str_equal (property, "LoginRequired"))
    {
      gtk_list_store_set (store, &iter,
                          CARRICK_COLUMN_LOGIN_REQUIRED, g_value_get_boolean (value),
                          -1);
    }
  else if (g_str_equal (property, "Ethernet"))
    {
      dict = g_value_get_boxed (value);
      if (dict)
        {
          const char *mac_address;
          mac_address = get_string (dict, "Address");
          gtk_list_store_set (store, &iter,
                              CARRICK_COLUMN_ETHERNET_MAC_ADDRESS, mac_address,
                              -1);
        }
    }
  else if (g_str_equal (property, "Proxy"))
    {
      dict = g_value_get_boxed (value);
      if (dict)
        {
          const char  *proxy_method, *proxy_url;
          const char **servers, **excludes;

          proxy_method = get_string (dict, "Method");
          proxy_url = get_string (dict, "URL");
          servers = get_boxed (dict, "Servers");
          excludes = get_boxed (dict, "Excludes");

          gtk_list_store_set (store, &iter,
                              CARRICK_COLUMN_PROXY_METHOD, proxy_method,
                              CARRICK_COLUMN_PROXY_URL, proxy_url,
                              CARRICK_COLUMN_PROXY_SERVERS, servers,
                              CARRICK_COLUMN_PROXY_EXCLUDES, excludes,
                              -1);
        }
    }
  else if (g_str_equal (property, "Proxy.Configuration"))
    {
      dict = g_value_get_boxed (value);
      if (dict)
        {
          const char  *proxy_method, *proxy_url;
          const char **servers, **excludes;

          proxy_method = get_string (dict, "Method");
          proxy_url = get_string (dict, "URL");
          servers = get_boxed (dict, "Servers");
          excludes = get_boxed (dict, "Excludes");

          gtk_list_store_set (store, &iter,
                              CARRICK_COLUMN_PROXY_METHOD, proxy_method,
                              CARRICK_COLUMN_PROXY_URL, proxy_url,
                              CARRICK_COLUMN_PROXY_SERVERS, servers,
                              CARRICK_COLUMN_PROXY_EXCLUDES, excludes,
                              -1);
        }
    }
}
Esempio n. 13
0
/*
 * Note that this is called every time the user clicks on an item,
 * whether it is already selected or not.
 */
static void
field_select_row_cb(GtkTreeSelection *sel, gpointer tree)
{
    GtkWidget *window                  = (GtkWidget *)gtk_widget_get_toplevel((GtkWidget *)tree);
    GtkWidget *relation_list           = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                               E_DFILTER_EXPR_RELATION_LIST_KEY);
    GtkWidget *range_label             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_RANGE_LABEL_KEY);
    GtkWidget *range_entry             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_RANGE_ENTRY_KEY);
    GtkWidget *value_label             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LABEL_KEY);
    GtkWidget *value_entry             = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_ENTRY_KEY);
    GtkWidget *value_list_label        = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LIST_LABEL_KEY);
    GtkWidget *value_list              = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LIST_KEY);
    GtkWidget *value_list_scrolled_win = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_VALUE_LIST_SW_KEY);
    GtkWidget *ok_bt                   = (GtkWidget *)g_object_get_data(G_OBJECT(window),
                                             E_DFILTER_EXPR_OK_BT_KEY);
    header_field_info *hfinfo, *cur_hfinfo;
    const char *value_type;
    char value_label_string[1024+1];   /* XXX - should be large enough */
    GtkTreeModel *model;
    GtkTreeIter   iter;

    if (!gtk_tree_selection_get_selected(sel, &model, &iter))
        return;
    gtk_tree_model_get(model, &iter, 0, &hfinfo, -1);

    /*
     * What was the item that was last selected?
     */
    cur_hfinfo = (header_field_info *)g_object_get_data(G_OBJECT(window), E_DFILTER_EXPR_CURRENT_VAR_KEY);
    if (cur_hfinfo == hfinfo) {
        /*
         * It's still selected; no need to change anything.
         */
        return;
    }

    /*
     * Mark it as currently selected.
     */
    g_object_set_data(G_OBJECT(window), E_DFILTER_EXPR_CURRENT_VAR_KEY, hfinfo);

    show_relations(relation_list, hfinfo->type);

    /*
     * Set the label for the value to indicate what type of value
     * it is.
     */
    value_type = ftype_pretty_name(hfinfo->type);
    if (value_type != NULL) {
        /*
         * Indicate what type of value it is.
         */
        g_snprintf(value_label_string, sizeof value_label_string,
                 "Value (%s)", value_type);
        gtk_label_set_text(GTK_LABEL(value_label), value_label_string);
    }

    /*
     * Clear the entry widget for the value, as whatever
     * was there before doesn't apply.
     */
    gtk_entry_set_text(GTK_ENTRY(value_entry), "");

    switch (hfinfo->type) {

    case FT_BOOLEAN:
        /*
         * The list of values should be the strings for "true"
         * and "false"; show them in the value list.
         */
        build_boolean_values(value_list_scrolled_win, value_list,
                             (const true_false_string *)hfinfo->strings);
        break;

    case FT_UINT8:
    case FT_UINT16:
    case FT_UINT24:
    case FT_UINT32:
    case FT_INT8:
    case FT_INT16:
    case FT_INT24:
    case FT_INT32:
        /*
         * If this has a value_string table (not a range_string table) associated with it,
         * fill up the list of values, otherwise clear the list of values.
         */
	/* XXX: ToDo: Implement "range-string" filter ?   */
        if ((hfinfo->strings != NULL) &&
            ! (hfinfo->display & BASE_RANGE_STRING) &&
            ! (hfinfo->display & BASE_VAL64_STRING) &&
            ! ((hfinfo->display & FIELD_DISPLAY_E_MASK) == BASE_CUSTOM)) {
            const value_string *vals = (const value_string *)hfinfo->strings;
            if (hfinfo->display & BASE_EXT_STRING)
                vals = VALUE_STRING_EXT_VS_P((value_string_ext *)vals);
            build_enum_values(value_list_scrolled_win, value_list, vals);
        } else
            gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(value_list))));
        break;

    default:
        /*
         * Clear the list of values.
         */
        gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(value_list))));
        break;
    }

    /*
     * Display various items for the value, as appropriate.
     * The relation we start out with is never a comparison.
     */
    display_value_fields(hfinfo, FALSE, value_label, value_entry,
                         value_list_label, value_list, value_list_scrolled_win, range_label, range_entry);

    /*
     * XXX - in browse mode, there always has to be something
     * selected, so this should always be sensitive.
     */
    gtk_widget_set_sensitive(ok_bt, TRUE);
}
Esempio n. 14
0
void
cal_print_get_events (gchar *buffer, guint32 julian, GUI *appGUI)
{
	GtkTreePath *path;
	GtkTreeIter iter;
	GtkTreeModel *model;
	GSList *lnode;
	struct note *a;
	gint i;

	gchar *wbuf1, *wbuf2;
	gchar buf1[BUFFER_SIZE], buf2[BUFFER_SIZE];
	GDate *date, *sdate;
	gint age, syear;
	guint32 tsk_julian;
	gint time;
	gint max_event_length;
	GRegex *reg;

	buffer[0] = '\0';
	max_event_length = (config.cal_print_event_length + 2 > BUFFER_SIZE) ? BUFFER_SIZE : config.cal_print_event_length + 2;


#ifdef TASKS_ENABLED

	/* tasks */
	if (config.cal_print_tasks) {

		model = GTK_TREE_MODEL (appGUI->tsk->tasks_list_store);
		g_return_if_fail (model != NULL);

		path = gtk_tree_path_new_first ();

		while (gtk_tree_model_get_iter (model, &iter, path) == TRUE) {
			gtk_tree_model_get (model, &iter, TA_COLUMN_DUE_DATE_JULIAN, &tsk_julian, TA_COLUMN_CATEGORY, &wbuf1, -1);

			if (tsk_julian == julian && tasks_category_get_state (wbuf1, STATE_CALENDAR, appGUI) == TRUE) {
				gtk_tree_model_get (model, &iter, TA_COLUMN_DUE_TIME, &time, TA_COLUMN_SUMMARY, &wbuf2, -1);

				if (time >= 0) {
					g_snprintf (buf1, max_event_length, "\n[%02d:%02d] %s", time / 3600, time / 60 % 60, wbuf2);
				} else {
					g_snprintf (buf1, max_event_length, "\n%s", wbuf2);
				}

				g_strlcat (buffer, buf1, BUFFER_SIZE);
				g_free (wbuf2);
			}

			g_free (wbuf1);
			gtk_tree_path_next (path);
		}

		gtk_tree_path_free (path);

	}

#endif  /* TASKS_ENABLED */

#ifdef CONTACTS_ENABLED

	/* birthdays */
	if (config.cal_print_birthdays) {

		model = GTK_TREE_MODEL (appGUI->cnt->contacts_list_store);
		g_return_if_fail (model != NULL);

		date = g_date_new ();
		g_return_if_fail (date != NULL);

		sdate = g_date_new_julian (julian);
		g_return_if_fail (sdate != NULL);

		syear = g_date_get_year (sdate);
		path = gtk_tree_path_new_first ();

		while (gtk_tree_model_get_iter (model, &iter, path) == TRUE) {
			gtk_tree_model_get (model, &iter, COLUMN_BIRTH_DAY_DATE, &tsk_julian, -1);

			if (g_date_valid_julian (tsk_julian)) {
				g_date_set_julian (date, tsk_julian);
				age = syear - g_date_get_year (date);

				if (age >= 0) {

					if (g_date_valid_dmy (g_date_get_day (date), g_date_get_month (date), syear) == FALSE) {
						g_date_subtract_days (date, 1);
					}
					g_date_set_year (date, syear);

					if (g_date_compare (date, sdate) == 0) {

						gtk_tree_model_get (model, &iter, COLUMN_FIRST_NAME, &wbuf1, COLUMN_LAST_NAME, &wbuf2, -1);
						utl_name_strcat (wbuf1, wbuf2, buf2);

						g_snprintf (buf1, max_event_length, "\n%s (%d)", buf2, age);
						g_strlcat (buffer, buf1, BUFFER_SIZE);
					}
				}
			}
			gtk_tree_path_next (path);
		}

		gtk_tree_path_free (path);
		g_date_free (sdate);
		g_date_free (date);

	}

	/* name days */
	if (config.cal_print_namedays) {

		model = GTK_TREE_MODEL (appGUI->cnt->contacts_list_store);
		g_return_if_fail (model != NULL);

		date = NULL;
		date = g_date_new ();
		g_return_if_fail (date != NULL);

		sdate = NULL;
		sdate = g_date_new_julian (julian);
		g_return_if_fail (sdate != NULL);

		syear = g_date_get_year (sdate);
		path = gtk_tree_path_new_first ();

		while (gtk_tree_model_get_iter (model, &iter, path) == TRUE) {
			gtk_tree_model_get (model, &iter, COLUMN_NAME_DAY_DATE, &tsk_julian, -1);

			if (g_date_valid_julian (tsk_julian)) {
				g_date_set_julian (date, tsk_julian);

				if (g_date_valid_dmy (g_date_get_day (date), g_date_get_month (date), syear) == TRUE) {
					g_date_set_year (date, syear);

					if (g_date_compare (date, sdate) == 0) {

						gtk_tree_model_get (model, &iter, COLUMN_FIRST_NAME, &wbuf1, COLUMN_LAST_NAME, &wbuf2, -1);
						utl_name_strcat (wbuf1, wbuf2, buf1);

						g_snprintf (buf2, max_event_length, "\n%s (%s)", buf1, _("Name day"));
						g_strlcat (buffer, buf2, BUFFER_SIZE);
					}
				}
			}
			gtk_tree_path_next (path);
		}

		gtk_tree_path_free (path);
		g_date_free (sdate);
		g_date_free (date);

	}

#endif  /* CONTACTS_ENABLED */

	/* day note */
	if (config.cal_print_day_notes) {

		if (appGUI->cal->notes_list != NULL) {

			wbuf1 = NULL;
			reg = g_regex_new ("\n", 0, 0, NULL);

			for (i = 0, lnode = appGUI->cal->notes_list; lnode != NULL; lnode = lnode->next, i++) {
				a = g_slist_nth_data (appGUI->cal->notes_list, i);

				if (a->date == julian) {
					wbuf1 = g_regex_replace_literal (reg, a->note, -1, 0, " ", 0, NULL);
					break;
				}
			}

			g_regex_unref (reg);
		}

		if (wbuf1 != NULL) {
			g_strstrip (wbuf1);
			g_snprintf (buf1, max_event_length, "\n%s", wbuf1);
			g_strlcat (buffer, buf1, BUFFER_SIZE);
			g_free (wbuf1);
		}

	}

#ifdef HAVE_LIBICAL

	/* ical */
	if (config.cal_print_ical) {


	}

#endif  /* HAVE_LIBICAL */

	g_strstrip (buffer);

}
Esempio n. 15
0
/* "Add domain"-button was pressed */
static void _nojs_preferences_on_add_domain_clicked(NoJSPreferences *self,
														gpointer *inUserData)
{
	NoJSPreferencesPrivate	*priv=self->priv;
	gchar					*domain;
	const gchar				*domainStart, *domainEnd;
	gchar					*realDomain;
	GtkTreeIter				policyIter;

	g_return_if_fail(priv->database);

	/* Get domain name entered */
	domain=g_hostname_to_ascii(gtk_entry_get_text(GTK_ENTRY(priv->addDomainEntry)));

	/* Trim whitespaces from start and end of entered domain name */
	domainStart=domain;
	while(*domainStart && g_ascii_isspace(*domainStart)) domainStart++;

	domainEnd=domain+strlen(domain)-1;
	while(*domainEnd && g_ascii_isspace(*domainEnd)) domainEnd--;
	if(domainEnd<=domainStart) return;

	/* Seperate domain name from whitespaces */
	realDomain=g_strndup(domain, domainEnd-domainStart+1);
	if(!realDomain) return;

	/* Get policy from combo box */
	if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->addDomainPolicyCombo), &policyIter))
	{
		gchar	*sql;
		gchar	*error=NULL;
		gint	success;
		gint	policy;
		gchar	*policyName;

		/* Get policy value to set for domain */
		gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(priv->addDomainPolicyCombo)),
													&policyIter,
													0, &policy,
													1, &policyName,
													-1);

		/* Add domain name and the selected policy to database */
		sql=sqlite3_mprintf("INSERT OR REPLACE INTO policies (site, value) VALUES ('%q', %d);",
								realDomain,
								policy);
		success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);

		/* Show error message if any */
		if(success==SQLITE_OK)
		{
			gtk_list_store_append(priv->listStore, &policyIter);
			gtk_list_store_set(priv->listStore,
								&policyIter,
								DOMAIN_COLUMN, realDomain,
								POLICY_COLUMN, policyName,
								-1);
		}
			else g_warning(_("SQL fails: %s"), error);


		if(error) sqlite3_free(error);

		/* Free allocated resources */
		sqlite3_free(sql);
	}

	/* Free allocated resources */
	g_free(realDomain);
	g_free(domain);
}
Esempio n. 16
0
static void
import_dialog_response_cb (GtkDialog *dialog,
			   int        response_id,
			   gpointer   user_data)
{
	DialogData *data = user_data;

	switch (response_id) {
	case GTK_RESPONSE_DELETE_EVENT:
	case GTK_RESPONSE_CANCEL:
		gth_file_list_cancel (GTH_FILE_LIST (data->file_list), (DataFunc) gtk_widget_destroy, data->dialog);
		break;

	case GTK_RESPONSE_OK:
		{
			GtkTreeIter    iter;
			FacebookAlbum *album;
			GList         *file_list;

			if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("album_combobox")), &iter)) {
				gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, FALSE);
				return;
			}

			gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("album_liststore")), &iter,
					    ALBUM_DATA_COLUMN, &album,
					    -1);

			file_list = get_files_to_download (data);
			if (file_list != NULL) {
				GSettings           *settings;
				GFile               *destination;
				gboolean             single_subfolder;
				GthSubfolderType     subfolder_type;
				GthSubfolderFormat   subfolder_format;
				char                *custom_format;
				GthTask             *task;

				settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA);
				destination = gth_import_preferences_get_destination ();
				subfolder_type = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_TYPE);
				subfolder_format = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_FORMAT);
				single_subfolder = g_settings_get_boolean (settings, PREF_IMPORTER_SUBFOLDER_SINGLE);
				custom_format = g_settings_get_string (settings, PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT);

				task = gth_import_task_new (data->browser,
							    file_list,
							    destination,
							    subfolder_type,
							    subfolder_format,
							    single_subfolder,
							    custom_format,
							    (album->name != NULL ? album->name : ""),
							    NULL,
							    FALSE,
							    FALSE,
							    FALSE);
				gth_browser_exec_task (data->browser, task, GTH_TASK_FLAGS_DEFAULT);
				gtk_widget_destroy (data->dialog);

				g_object_unref (task);
				_g_object_unref (destination);
				g_object_unref (settings);
			}

			_g_object_list_unref (file_list);
			g_object_unref (album);
		}
		break;

	default:
		break;
	}
}
Esempio n. 17
0
/**
 * Drag-and-drop received.
 */
static void signal_dnd_recv(GtkTreeView *tv,
                            GdkDragContext *context,
                            int x, int y,
                            GtkSelectionData *selection,
                            guint info, guint time,
                            gpointer data)
{
    GDeviceSetup *gds;
    GtkTreeModel *model;
    GtkTreeSelection *sel;
    GtkTreeIter sel_iter, dest_iter, parent, ins_iter,
                *final_parent, *final_sib;
    GtkTreePath *path;
    GtkTreeViewDropPosition pos;
    int id, md_id;
    int use, md_use;
    gboolean status = False;

    gds = (GDeviceSetup*)data;
    model = gtk_tree_view_get_model(tv);
    sel = gtk_tree_view_get_selection(tv);
    if (!gtk_tree_selection_get_selected(sel, NULL, &sel_iter))
        return;

    gtk_tree_model_get(model, &sel_iter,
                       COL_ID, &id,
                       COL_USE, &use,
                       -1);

    /* MD selected? */
    if (use == XIMasterPointer || use == XIMasterKeyboard)
        return;

    if (!gtk_tree_view_get_dest_row_at_pos(tv, x, y, &path, &pos))
        return;

    gtk_tree_model_get_iter(model, &dest_iter, path);

    /* check for parent, set final_parent to parent and final_sib to the
     * sibling we're dropping onto. */
    if (!gtk_tree_model_iter_parent(model, &parent, &dest_iter))
    {
        final_parent = &dest_iter;
        final_sib = NULL;
    } else
    {
        final_parent = &parent;
        final_sib = &dest_iter;
    }

    gtk_tree_model_get(GTK_TREE_MODEL(model), final_parent,
		       COL_ID, &md_id, COL_USE, &md_use, -1);

    g_debug("Trying to attach %d to %d\n", id, md_id);
    
    /* try */
    if(md_id == ID_FLOATING)
      status = float_device(gds, id);
    else
      status = change_attachment(gds, id, md_id);

    if(status)
      toggle_undo_button(gds, TRUE); 
}
Esempio n. 18
0
/* Function to setup popup windows for Burst Buffer */
extern void popup_all_bb(GtkTreeModel *model, GtkTreeIter *iter, int id)
{
	char *name = NULL;
	char title[100];
	ListIterator itr = NULL;
	popup_info_t *popup_win = NULL;
	GError *error = NULL;

	gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1);

	switch(id) {
	case INFO_PAGE:
		snprintf(title, 100, "Full info for Burst Buffer %s", name);
		break;
	default:
		g_print("Burst Buffer got %d\n", id);
	}

	itr = list_iterator_create(popup_list);
	while ((popup_win = list_next(itr))) {
		if (popup_win->spec_info)
			if (!xstrcmp(popup_win->spec_info->title, title)) {
				break;
			}
	}
	list_iterator_destroy(itr);

	if (!popup_win) {
		if (id == INFO_PAGE) {
			popup_win = create_popup_info(id, BB_PAGE, title);
		} else {
			popup_win = create_popup_info(BB_PAGE, id, title);
		}
	} else {
		g_free(name);
		gtk_window_present(GTK_WINDOW(popup_win->popup));
		return;
	}

	/* Pass the model and the structs from the iter so we can always get
	   the current node_inx.
	*/
	popup_win->model = model;
	popup_win->iter = *iter;

	/* Sets up right click information */
	switch(id) {
	case JOB_PAGE:
	case INFO_PAGE:
		popup_win->spec_info->search_info->gchar_data = name;
		specific_info_bb(popup_win);
		break;
	case BLOCK_PAGE:
	case NODE_PAGE:
	case PART_PAGE:
	case SUBMIT_PAGE:
		break;
	default:
		g_print("Burst Buffer got unknown type %d\n", id);
	}
	if (!sview_thread_new((gpointer)popup_thr, popup_win, false, &error)) {
		g_printerr ("Failed to create burst buffer popup thread: %s\n",
			    error->message);
		return;
	}
}
Esempio n. 19
0
static gboolean
category_filter_model_update( GtkTreeStore * store )
{
    int i, n;
    int low = 0;
    int all = 0;
    int high = 0;
    int public = 0;
    int normal = 0;
    int private = 0;
    int store_pos;
    GtkTreeIter top;
    GtkTreeIter iter;
    GtkTreeModel * model = GTK_TREE_MODEL( store );
    GPtrArray * hosts = g_ptr_array_new( );
    GHashTable * hosts_hash = g_hash_table_new_full( g_str_hash, g_str_equal,
                                                     g_free, g_free );
    GObject * o = G_OBJECT( store );
    GtkTreeModel * tmodel = GTK_TREE_MODEL(
                                    g_object_get_data( o, TORRENT_MODEL_KEY ) );

    g_object_steal_data( o, DIRTY_KEY );

    /* Walk through all the torrents, tallying how many matches there are
     * for the various categories. Also make a sorted list of all tracker
     * hosts s.t. we can merge it with the existing list */
    if( gtk_tree_model_get_iter_first( tmodel, &iter )) do
    {
        tr_torrent * tor;
        const tr_info * inf;
        int keyCount;
        char ** keys;

        gtk_tree_model_get( tmodel, &iter, MC_TORRENT_RAW, &tor, -1 );
        inf = tr_torrentInfo( tor );
        keyCount = 0;
        keys = g_new( char*, inf->trackerCount );

        for( i=0, n=inf->trackerCount; i<n; ++i )
        {
            int k;
            char * key = gtr_get_host_from_url( inf->trackers[i].announce );
            int * count = g_hash_table_lookup( hosts_hash, key );
            if( count == NULL )
            {
                count = tr_new0( int, 1 );
                g_hash_table_insert( hosts_hash, g_strdup( key ), count );
                g_ptr_array_add( hosts, g_strdup( key ) );
            }

            for( k=0; k<keyCount; ++k )
                if( !strcmp( keys[k], key ) )
                    break;
            if( k==keyCount )
                keys[keyCount++] = key;
            else
                g_free( key );
        }

        for( i=0; i<keyCount; ++i )
        {
            int * incrementme = g_hash_table_lookup( hosts_hash, keys[i] );
            ++*incrementme;
            g_free( keys[i] );
        }
        g_free( keys );

        ++all;

        if( inf->isPrivate )
            ++private;
        else
            ++public;
Esempio n. 20
0
static gboolean ui_authenticate(dt_storage_facebook_gui_data_t *ui)
{
  if(ui->facebook_api == NULL)
  {
    ui->facebook_api = fb_api_init();
  }

  FBContext *ctx = ui->facebook_api;
  gboolean mustsaveaccount = FALSE;

  gchar *uiselectedaccounttoken = NULL;
  GtkTreeIter iter;
  gtk_combo_box_get_active_iter(ui->comboBox_username, &iter);
  GtkTreeModel *accountModel = gtk_combo_box_get_model(ui->comboBox_username);
  gtk_tree_model_get(accountModel, &iter, 1, &uiselectedaccounttoken, -1);

  g_free(ctx->token);
  ctx->token = g_strdup(uiselectedaccounttoken);
  // check selected token if we already have one
  if(ctx->token != NULL && !fb_test_auth_token(ctx))
  {
    g_free(ctx->token);
    ctx->token = NULL;
  }

  if(ctx->token == NULL)
  {
    mustsaveaccount = TRUE;
    ctx->token = facebook_get_user_auth_token(ui); // ask user to log in
  }

  if(ctx->token == NULL) return FALSE;

  if(mustsaveaccount)
  {
    FBAccountInfo *accountinfo = fb_get_account_info(ui->facebook_api);
    g_return_val_if_fail(accountinfo != NULL, FALSE);
    save_account_info(ui, accountinfo);

    // add account to user list and select it
    GtkListStore *model = GTK_LIST_STORE(gtk_combo_box_get_model(ui->comboBox_username));
    GtkTreeIter iter;
    gboolean r;
    gchar *uid;

    gboolean updated = FALSE;

    for(r = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter); r == TRUE;
        r = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter))
    {
      gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, COMBO_USER_MODEL_ID_COL, &uid, -1);

      if(g_strcmp0(uid, accountinfo->id) == 0)
      {
        gtk_list_store_set(model, &iter, COMBO_USER_MODEL_NAME_COL, accountinfo->username,
                           COMBO_USER_MODEL_TOKEN_COL, accountinfo->token, -1);
        updated = TRUE;
        break;
      }
    }

    if(!updated)
    {
      gtk_list_store_append(model, &iter);
      gtk_list_store_set(model, &iter, COMBO_USER_MODEL_NAME_COL, accountinfo->username,
                         COMBO_USER_MODEL_TOKEN_COL, accountinfo->token, COMBO_USER_MODEL_ID_COL,
                         accountinfo->id, -1);
    }
    gtk_combo_box_set_active_iter(ui->comboBox_username, &iter);
    // we have to re-set the current token here since ui_combo_username_changed is called
    // on gtk_combo_box_set_active_iter (and thus is resetting the active token)
    ctx->token = g_strdup(accountinfo->token);
    fb_account_info_destroy(accountinfo);
  }
  return TRUE;
}
Esempio n. 21
0
static gboolean
gtk_app_chooser_search_equal_func (GtkTreeModel *model,
                                   gint          column,
                                   const gchar  *key,
                                   GtkTreeIter  *iter,
                                   gpointer      user_data)
{
  gchar *normalized_key;
  gchar *name, *normalized_name;
  gchar *path, *normalized_path;
  gchar *basename, *normalized_basename;
  gboolean ret;

  if (key != NULL)
    {
      normalized_key = g_utf8_casefold (key, -1);
      g_assert (normalized_key != NULL);

      ret = TRUE;

      gtk_tree_model_get (model, iter,
                          COLUMN_NAME, &name,
                          COLUMN_EXEC, &path,
                          -1);

      if (name != NULL)
        {
          normalized_name = g_utf8_casefold (name, -1);
          g_assert (normalized_name != NULL);

          if (strncmp (normalized_name, normalized_key, strlen (normalized_key)) == 0)
            ret = FALSE;

          g_free (normalized_name);
        }

      if (ret && path != NULL)
        {
          normalized_path = g_utf8_casefold (path, -1);
          g_assert (normalized_path != NULL);

          basename = g_path_get_basename (path);
          g_assert (basename != NULL);

          normalized_basename = g_utf8_casefold (basename, -1);
          g_assert (normalized_basename != NULL);

          if (strncmp (normalized_path, normalized_key, strlen (normalized_key)) == 0 ||
              strncmp (normalized_basename, normalized_key, strlen (normalized_key)) == 0)
            ret = FALSE;

          g_free (basename);
          g_free (normalized_basename);
          g_free (normalized_path);
        }

      g_free (name);
      g_free (path);
      g_free (normalized_key);

      return ret;
    }
  else
    {
      return TRUE;
    }
}
Esempio n. 22
0
void add_ethernet_service(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data)
{
	GtkWidget *vbox;
	GtkWidget *table;
	GtkWidget *label;
	//GtkWidget *combo;

	GtkWidget *entry;
	GtkWidget *button;

	struct ipv4_config ipv4_config = {
		.method  = NULL,
		.address = NULL,
		.netmask = NULL,
		.gateway = NULL,
	};

	gtk_tree_model_get(data->model, iter,
			CONNMAN_COLUMN_METHOD, &ipv4_config.method,
			CONNMAN_COLUMN_ADDRESS, &ipv4_config.address,
			CONNMAN_COLUMN_NETMASK, &ipv4_config.netmask,
			CONNMAN_COLUMN_GATEWAY, &ipv4_config.gateway,
			-1);

	vbox = gtk_vbox_new(TRUE, 0);

	gtk_container_set_border_width(GTK_CONTAINER(vbox), 24);
	gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0);

	table = gtk_table_new(5, 5, TRUE);
	gtk_table_set_row_spacings(GTK_TABLE(table), 10);
	gtk_table_set_col_spacings(GTK_TABLE(table), 10);
	gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);

	label = gtk_label_new(_("Configuration:"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);

	//combo = gtk_combo_box_new_text();
	//gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "DHCP");
	//gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "MANUAL");
	//gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(combo),
	//				separator_function, NULL, NULL);
	//gtk_table_attach_defaults(GTK_TABLE(table), combo, 2, 4, 0, 1);
	//data->policy.config = combo;

	label = gtk_label_new(_("IP address:"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
	data->ipv4.label[0] = label;

	entry = gtk_entry_new();
	gtk_entry_set_max_length (GTK_ENTRY (entry), 15);
	if (ipv4_config.address)
		gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.address);
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 1, 2);
	data->ipv4.entry[0] = entry;

	label = gtk_label_new(_("Netmask:"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3);
	data->ipv4.label[1] = label;

	entry = gtk_entry_new();
	gtk_entry_set_max_length (GTK_ENTRY (entry), 15);
	if (ipv4_config.netmask)
		gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.netmask);
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 2, 3);
	data->ipv4.entry[1] = entry;

	label = gtk_label_new(_("Gateway:"));
	gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4);
	data->ipv4.label[2] = label;

	entry = gtk_entry_new();
	gtk_entry_set_max_length (GTK_ENTRY (entry), 15);
	if (ipv4_config.gateway)
		gtk_entry_set_text(GTK_ENTRY(entry), ipv4_config.gateway);
	gtk_table_attach_defaults(GTK_TABLE(table), entry, 2, 4, 3, 4);
	data->ipv4.entry[2] = entry;

	data->ipv4_config = ipv4_config;

	button = gtk_button_new_with_label(_("Apply"));
	gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 4, 4, 5);
	g_signal_connect(G_OBJECT(button), "clicked",
			G_CALLBACK(apply_callback), data);

	data->button = button;

	if (g_str_equal(ipv4_config.method, "dhcp") == TRUE)
		update_ethernet_ipv4(data, CONNMAN_POLICY_DHCP);
	else
		update_ethernet_ipv4(data, CONNMAN_POLICY_MANUAL);

	/* g_signal_connect(G_OBJECT(combo), "changed", */
	/* 		G_CALLBACK(changed_callback), data); */
}
Esempio n. 23
0
void prov_usl_vibor(GtkTreeSelection *selection,class prov_usl_data *data)
{
//printf("prov_usl_vibor\n");
GtkTreeModel *model;
GtkTreeIter  iter;


if(gtk_tree_selection_get_selected(selection,&model,&iter) != TRUE)
 return;

gchar *shet_d;
gchar *shet_k;
gchar *datap;
gchar *debet;
gchar *kredit;
gchar *koment;
gchar *kontr;
gint ktoz;
glong vrem;
gint val;
gint nomer;
gchar *kekv;

gtk_tree_model_get(model,&iter,
COL_SHET,&shet_d,
COL_SHET_KOR,&shet_k,
COL_DATA,&datap,
COL_DEBET,&debet,
COL_KREDIT,&kredit,
COL_KONTR,&kontr,
COL_KOMENT,&koment,
COL_KTOZ,&ktoz,
COL_VREM,&vrem,
COL_VAL,&val,
COL_KEKV,&kekv,
NUM_COLUMNS,&nomer,-1);


data->shet_v.new_plus(iceb_u_fromutf(shet_d));
data->shet_kor_v.new_plus(iceb_u_fromutf(shet_k));
data->kontr_v.new_plus(iceb_u_fromutf(kontr));
data->datap_v.new_plus(iceb_u_fromutf(datap));
data->koment_v.new_plus(iceb_u_fromutf(koment));
data->debet_v=atof(debet);
data->kredit_v=atof(kredit);
data->ktoz_v=ktoz;
data->vrem_v=vrem;
data->val_v=val;
data->snanomer=nomer;
data->kekv=atoi(kekv);

g_free(shet_d);
g_free(shet_k);
g_free(datap);
g_free(debet);
g_free(kredit);
g_free(kontr);
g_free(koment);
g_free(kekv);
/*
printf("%s %s %s %s %.2f %.2f %s %d\n",
data->datap_v.ravno(),
data->shet_v.ravno(),
data->shet_kor_v.ravno(),
data->kontr_v.ravno(),
data->debet_v,
data->kredit_v,
data->koment_v.ravno(),
data->snanomer);
*/
}
Esempio n. 24
0
static gboolean
panel_run_dialog_find_command_idle (PanelRunDialog *dialog)
{
	GtkTreeIter   iter;
	GtkTreeModel *model;
	GtkTreePath  *path;
	char         *text;
	GIcon        *found_icon;
	char         *found_name;
	gboolean      fuzzy;

	model = GTK_TREE_MODEL (dialog->program_list_store);
	path = gtk_tree_path_new_first ();

	if (!path || !gtk_tree_model_get_iter (model, &iter, path)) {
		if (path)
			gtk_tree_path_free (path);

		panel_run_dialog_set_icon (dialog, NULL, FALSE);

		dialog->find_command_idle_id = 0;
		return FALSE;
	}

	text = g_strdup (panel_run_dialog_get_combo_text (dialog));
	found_icon = NULL;
	found_name = NULL;
	fuzzy = FALSE;

	do {
		char *exec = NULL;
		GIcon *icon = NULL;
		char *name = NULL;
		char *comment = NULL;

		gtk_tree_model_get (model, &iter,
				    COLUMN_EXEC,      &exec,
				    COLUMN_GICON,     &icon,
				    COLUMN_NAME,      &name,
				    COLUMN_COMMENT,   &comment,
				    -1);

		if (!fuzzy && exec && icon &&
		    fuzzy_command_match (text, exec, &fuzzy)) {
			g_clear_object (&found_icon);
			g_free (found_name);

			found_icon = g_object_ref (icon);
			found_name = g_strdup (name);

			gtk_list_store_set (dialog->program_list_store,
					    &iter,
					    COLUMN_VISIBLE, TRUE,
					    -1);
		} else if (panel_g_utf8_strstrcase (exec, text) != NULL ||
			   panel_g_utf8_strstrcase (name, text) != NULL ||
			   panel_g_utf8_strstrcase (comment, text) != NULL) {
			gtk_list_store_set (dialog->program_list_store,
					    &iter,
					    COLUMN_VISIBLE, TRUE,
					    -1);
		} else {
			gtk_list_store_set (dialog->program_list_store,
					    &iter,
					    COLUMN_VISIBLE, FALSE,
					    -1);
		}

		g_free (exec);
		g_object_unref (icon);
		g_free (name);
		g_free (comment);

        } while (gtk_tree_model_iter_next (model, &iter));

	if (gtk_tree_model_get_iter (gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->program_list)),
				     &iter, path))
		gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (dialog->program_list),
					      path, NULL, FALSE, 0, 0);

	gtk_tree_path_free (path);

	panel_run_dialog_set_icon (dialog, found_icon, FALSE);
	//FIXME update dialog->program_label

	g_clear_object (&found_icon);
	g_free (text);

	g_free (dialog->item_name);
	dialog->item_name = found_name;

	dialog->find_command_idle_id = 0;
	return FALSE;
}
void
IRC_Client_GUI_MessageHandler::remove (const std::string& nick_in)
{
  RPG_TRACE (ACE_TEXT ("IRC_Client_GUI_MessageHandler::remove"));

  // sanity check(s)
  ACE_ASSERT (CBData_.GTKState);

  ACE_Guard<ACE_Thread_Mutex> aGuard (CBData_.GTKState->lock);

  Common_UI_GTKBuildersIterator_t iterator =
      CBData_.GTKState->builders.find (builderLabel_);
  // sanity check(s)
  ACE_ASSERT (iterator != CBData_.GTKState->builders.end ());

  // retrieve channel liststore handle
  GtkListStore* list_store_p =
      GTK_LIST_STORE (gtk_builder_get_object ((*iterator).second.second,
                                              ACE_TEXT_ALWAYS_CHAR ("channel_liststore")));
  ACE_ASSERT (list_store_p);

  // step1: convert text
  gchar* converted_nick_string = Common_UI_Tools::Locale2UTF8 (nick_in);
  if (!converted_nick_string)
  {
    ACE_DEBUG ((LM_ERROR,
                ACE_TEXT ("failed to convert nickname: \"%s\", returning\n")));
    return;
  } // end IF

  // step2: find matching entry
  GtkTreeIter current_iter;
//   GValue current_value;
  gchar* current_value_string = NULL;
  if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store_p),
                                      &current_iter))
  {
    ACE_DEBUG ((LM_ERROR,
                ACE_TEXT ("failed to gtk_tree_model_get_iter_first(%@), returning\n"),
                list_store_p));

    // clean up
    g_free (converted_nick_string);

    return;
  } // end IF
  bool found_row = false;
  do
  {
    current_value_string = NULL;

    // retrieve value
//     gtk_tree_model_get_value(GTK_TREE_MODEL(list_store_p),
//                              current_iter,
//                              0, &current_value);
    gtk_tree_model_get (GTK_TREE_MODEL (list_store_p),
                        &current_iter,
                        0, &current_value_string,
                        -1);
    if (g_str_equal (current_value_string,
                     converted_nick_string) ||
        (g_str_has_suffix (current_value_string,
                           converted_nick_string) &&
         ((current_value_string[0] == '@'))))
      found_row = true;

    // clean up
    g_free (current_value_string);

    if (found_row)
      break; // found value
  } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store_p),
                                     &current_iter));

  // clean up
  g_free (converted_nick_string);

  if (found_row)
    gtk_list_store_remove (list_store_p,
                           &current_iter);
  else
    ACE_DEBUG ((LM_ERROR,
                ACE_TEXT ("failed to remove nick (was: \"%s\"), aborting\n"),
                ACE_TEXT (nick_in.c_str ())));
}
Esempio n. 26
0
static void
program_list_selection_changed (GtkTreeSelection *selection,
				PanelRunDialog   *dialog)
{
	GtkTreeModel *filter_model;
	GtkTreeModel *child_model;
	GtkTreeIter   iter;
	GtkTreeIter   filter_iter;
	char         *temp;
	char         *path, *stripped;
	gboolean      terminal;
	GKeyFile     *key_file;
	GtkWidget    *entry;

	if (!gtk_tree_selection_get_selected (selection, &filter_model,
					      &filter_iter))
		return;

	gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (filter_model),
							  &iter, &filter_iter);

	path = NULL;
	child_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
	gtk_tree_model_get (child_model, &iter,
			    COLUMN_PATH, &path,
			    -1);

	if (!path)
		return;

	key_file = g_key_file_new ();

	if (!g_key_file_load_from_file (key_file, path,
					G_KEY_FILE_NONE, NULL)) {
		g_key_file_free (key_file);
		g_free (path);
		return;
	}

	dialog->use_program_list = TRUE;
	if (dialog->desktop_path)
		g_free (dialog->desktop_path);
	dialog->desktop_path = g_strdup (path);
	if (dialog->item_name)
		g_free (dialog->item_name);
	dialog->item_name = NULL;

	/* Order is important here. We have to set the text first so that the
	 * drag source is enabled, otherwise the drag icon can't be set by
	 * panel_run_dialog_set_icon.
	 */
	entry = gtk_bin_get_child (GTK_BIN (dialog->combobox));
	temp = panel_key_file_get_string (key_file, "Exec");
	if (temp) {
		stripped = remove_parameters (temp);
		gtk_entry_set_text (GTK_ENTRY (entry), stripped);
		g_free (stripped);
	} else {
		temp = panel_key_file_get_string (key_file, "URL");
		gtk_entry_set_text (GTK_ENTRY (entry), sure_string (temp));
	}
	g_free (temp);

	temp = panel_key_file_get_locale_string (key_file, "Icon");
	GIcon *icon = panel_gicon_from_icon_name (temp);
	panel_run_dialog_set_icon (dialog, icon, FALSE);
	g_object_unref (icon);
	g_free (temp);

	temp = panel_key_file_get_locale_string (key_file, "Comment");
	//FIXME: if sure_string () == "", we should display "Will run..." as in entry_changed()
	gtk_label_set_text (GTK_LABEL (dialog->program_label),
			    sure_string (temp));
	g_free (temp);

	terminal = panel_key_file_get_boolean (key_file, "Terminal", FALSE);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox),
				      terminal);

	g_key_file_free (key_file);

	g_free (path);
}
Esempio n. 27
0
static void
import_dialog_response_cb (GtkDialog *dialog,
			   int        response_id,
			   gpointer   user_data)
{
	DialogData *data = user_data;

	switch (response_id) {
	case GTK_RESPONSE_DELETE_EVENT:
	case GTK_RESPONSE_CANCEL:
		gth_file_list_cancel (GTH_FILE_LIST (data->file_list), (DataFunc) gtk_widget_destroy, data->dialog);
		break;

	case GTK_RESPONSE_OK:
		{
			GtkTreeIter     iter;
			PicasaWebAlbum *album;
			GList          *file_list;

			if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("album_combobox")), &iter)) {
				gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog),
								   GTK_RESPONSE_OK,
								   FALSE);
				return;
			}

			gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("album_liststore")), &iter,
					    ALBUM_DATA_COLUMN, &album,
					    -1);

			file_list = get_files_to_download (data);
			if (file_list != NULL) {
				GFile               *destination;
				GError              *error = NULL;
				GSettings           *settings;
				gboolean             single_subfolder;
				GthSubfolderType     subfolder_type;
				GthSubfolderFormat   subfolder_format;
				char                *custom_format;
				char               **tags;
				int                  i;
				GthTask             *task;

				destination = gth_import_preferences_get_destination ();

				if (! gth_import_task_check_free_space (destination, file_list, &error)) {
					_gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->dialog),
									    _("Could not import the files"),
									    error);
					g_clear_error (&error);
					_g_object_unref (destination);
					_g_object_list_unref (file_list);
					g_object_unref (album);
					return;
				}

				settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA);
				subfolder_type = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_TYPE);
				subfolder_format = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_FORMAT);
				single_subfolder = g_settings_get_boolean (settings, PREF_IMPORTER_SUBFOLDER_SINGLE);
				custom_format = g_settings_get_string (settings, PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT);

				tags = g_strsplit ((album->keywords != NULL ? album->keywords : ""), ",", -1);
				for (i = 0; tags[i] != NULL; i++)
					tags[i] = g_strstrip (tags[i]);

				task = gth_import_task_new (data->browser,
							    file_list,
							    destination,
							    subfolder_type,
							    subfolder_format,
							    single_subfolder,
							    custom_format,
							    (album->title != NULL ? album->title : ""),
							    tags,
							    FALSE,
							    FALSE,
							    FALSE);
				gth_browser_exec_task (data->browser, task, GTH_TASK_FLAGS_DEFAULT);
				gtk_widget_destroy (data->dialog);

				g_object_unref (task);
				g_strfreev (tags);
				g_object_unref (settings);
				_g_object_unref (destination);
			}

			_g_object_list_unref (file_list);
			g_object_unref (album);
		}
		break;

	default:
		break;
	}
}
Esempio n. 28
0
static void _nojs_preferences_on_policy_edited(NoJSPreferences *self,
												gchar *path,
												gchar *newText,
												gpointer *inUserData)
{
	NoJSPreferencesPrivate	*priv=self->priv;
	gchar											*domain;
	GtkTreeIter										iter;
	GtkTreeIter										policyIter;

	g_return_if_fail(priv->database);

	if (priv->editingCombo == NULL) return;

	gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(priv->listStore), &iter, path);

	gtk_tree_model_get(GTK_TREE_MODEL(priv->listStore),
						&iter,
						DOMAIN_COLUMN, &domain,
						-1);

	/* Get policy from combo box */
	if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(priv->editingCombo), &policyIter))
	{
		gchar	*sql;
		gchar	*error=NULL;
		gint	success;
		gint	policy;
		gchar	*policyName;

		/* Get policy value to set for domain */
		gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(priv->editingCombo)),
													&policyIter,
													0, &policy,
													1, &policyName,
													-1);

		g_return_if_fail(g_strcmp0(policyName, newText)==0);

		/* Add domain name and the selected policy to database */
		sql=sqlite3_mprintf("UPDATE policies SET value = %d WHERE site = '%q';",
								policy,
								domain);
		success=sqlite3_exec(priv->database, sql, NULL, NULL, &error);

		/* Show error message if any */
		if(success==SQLITE_OK)
		{
			gtk_list_store_set(priv->listStore,
								&iter,
								POLICY_COLUMN, newText,
								-1);
		}
			else g_warning(_("SQL fails: %s"), error);


		if(error) sqlite3_free(error);

		/* Free allocated resources */
		sqlite3_free(sql);
	}

	priv->editingCombo=NULL;
}
Esempio n. 29
0
static void changed_cb(GtkTreeSelection * selection, gpointer conv)
{

    g_return_if_fail(selection != NULL);
    g_return_if_fail(conv != NULL);

    GaimConversation *c = (GaimConversation *) conv;
    GaymBuddy *cm;
    struct gaym_conn *gaym = c->account->gc->proto_data;

    GtkTreeIter iter;
    GtkTreeModel *model;
    gchar *name;

    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
        return;

    gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1);

    /* Remove the current icon stuff */
    GaymChatIcon *icon_data = g_hash_table_lookup(icons, c);
    if (icon_data->event != NULL)
        gtk_widget_destroy(icon_data->event);
    icon_data->event = NULL;


    char *dir = g_build_filename(gaim_user_dir(), "icons", "gaym", NULL);
    char *filename = g_strdup_printf("%s.jpg", name);
    char *path = NULL;
    FILE *file;
    struct stat st;
    struct fetch_thumbnail_data *data =
        g_new0(struct fetch_thumbnail_data, 1);
    path = g_build_filename(dir, filename, NULL);
    if (path && !g_stat(path, &st)) {
        if (file = g_fopen(path, "rb")) {
            data->pic_data = g_malloc(st.st_size);
            data->who = name;
            data->pic_data_len = st.st_size;
            data->from_file = TRUE;
            fread(data->pic_data, 1, st.st_size, file);
            fclose(file);
        }
        g_free(dir);
        g_free(filename);
        g_free(path);

        gaym_gtkconv_update_thumbnail(c, data);
        fetch_thumbnail_cb(data, data->pic_data, data->pic_data_len);
        return;
    }
    // Get GaymBuddy struct for the thumbnail URL.
    cm = g_hash_table_lookup(gaym->channel_members, name);
    if (!cm)
        return;


    // Fetch thumbnail.

    char *hashurl = g_hash_table_lookup(gaym->confighash,
                                        "mini-profile-panel.thumbnail-prefix");

    data = g_new0(struct fetch_thumbnail_data, 1);
    data->who = name;
    data->from_file = FALSE;
    char *url = g_strdup_printf("%s%s", hashurl, cm->thumbnail);
    gaim_url_fetch(url, FALSE, "Mozilla/4.0", FALSE,
                   fetch_thumbnail_cb, data);

    // Add entry to hash table for tracking.
    g_hash_table_replace(pending_updates, c, name);

}
Esempio n. 30
0
void gmpv_mpv_load(	GmpvMpv *mpv,
			const gchar *uri,
			gboolean append,
			gboolean update )
{
	const gchar *load_cmd[] = {"loadfile", NULL, NULL, NULL};
	GtkListStore *playlist_store = gmpv_playlist_get_store(mpv->playlist);
	GtkTreeIter iter;
	gboolean empty;

	g_info(	"Loading file (append=%s, update=%s): %s",
		append?"TRUE":"FALSE",
		update?"TRUE":"FALSE",
		uri?:"<PLAYLIST_ITEMS>" );

	empty = !gtk_tree_model_get_iter_first
			(GTK_TREE_MODEL(playlist_store), &iter);

	load_cmd[2] = (append && !empty)?"append":"replace";

	if(!append && uri && update)
	{
		gmpv_playlist_clear(mpv->playlist);

		mpv->state.new_file = TRUE;
		mpv->state.loaded = FALSE;
	}

	if(!uri)
	{
		gboolean append = FALSE;
		gboolean rc;

		if(!mpv->state.init_load)
		{
			gmpv_mpv_set_property_flag(mpv, "pause", FALSE);
		}

		rc = gtk_tree_model_get_iter_first
			(GTK_TREE_MODEL(playlist_store), &iter);

		while(rc)
		{
			gchar *uri;

			gtk_tree_model_get(	GTK_TREE_MODEL(playlist_store),
						&iter,
						PLAYLIST_URI_COLUMN,
						&uri,
						-1 );

			/* append = FALSE only on first iteration */
			gmpv_mpv_load(mpv, uri, append, FALSE);

			append = TRUE;

			rc = gtk_tree_model_iter_next
				(GTK_TREE_MODEL(playlist_store), &iter);

			g_free(uri);
		}
	}

	if(uri && playlist_store)
	{
		gchar *path = get_path_from_uri(uri);

		load_cmd[1] = path;

		if(!append)
		{
			mpv->state.loaded = FALSE;

			if(!mpv->state.init_load)
			{
				gmpv_mpv_set_property_flag
					(mpv, "pause", FALSE);
			}
		}

		if(update)
		{
			gchar *name = get_name_from_path(path);

			gmpv_playlist_append(mpv->playlist, name, uri);

			g_free(name);
		}

		g_assert(mpv->mpv_ctx);

		mpv_check_error(mpv_request_event(	mpv->mpv_ctx,
							MPV_EVENT_END_FILE,
							0 ));

		mpv_check_error(mpv_command(mpv->mpv_ctx, load_cmd));

		mpv_check_error(mpv_request_event(	mpv->mpv_ctx,
							MPV_EVENT_END_FILE,
							1 ));

		g_free(path);
	}
}