/* completionproposal.h
 *
 * Copyright (C) 2009, 2010, 2011 Krzesimir Nowak
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/interface.h>
#include <glibmm/ustring.h>
#include <gdkmm/pixbuf.h>
#include <gtksourceview/gtksourcecompletionproposal.h>

_DEFS(gtksourceviewmm,gtksourceview)
_PINCLUDE(glibmm/private/interface_p.h)

namespace Gsv
{

/** Completion proposal object.
 *
 * The proposal interface represents a completion item in the completion window.
 * It provides information on how to display the completion item and what action
 * should be taken when the completion item is activated.
 *
 * @newin{2,10}
 */
class CompletionProposal : public Glib::Interface
{
  _CLASS_INTERFACE(CompletionProposal, GtkSourceCompletionProposal, GTK_SOURCE_COMPLETION_PROPOSAL, GtkSourceCompletionProposalIface)

public:
  /** Gets the label of a proposal.
   *
   * The label is shown in the list of proposals as plain text. If you need any
   * markup (such as bold or italic text), you have to implement get_markup().
   *
   * @return The label of a proposal.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(Glib::ustring get_label() const, gtk_source_completion_proposal_get_label)

  /** Gets the label of a proposal with markup. The label is shown in the list
   * of proposals and may contain markup. This will be used instead of
   * get_label() if implemented.
   *
   * @return The label of a proposal with markup.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(Glib::ustring get_markup() const, gtk_source_completion_proposal_get_markup)

  /** Gets the text of a proposal.
   *
   * The text that is inserted into the text buffer when the proposal is
   * activated by the default activation. You are free to implement a custom
   * activation handler in the provider and not implement this function.
   *
   * @return The text of a proposal.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(Glib::ustring get_text() const, gtk_source_completion_proposal_get_text)

  /** Gets the icon of a proposal.
   *
   * @return The icon of a proposal.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_icon(), gtk_source_completion_proposal_get_icon, refreturn)

  /** Gets the icon of a proposal.
   *
   * @return The icon of a proposal.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> get_icon() const, gtk_source_completion_proposal_get_icon, constversion, refreturn)

  /** Gets extra information associated to the proposal.
   *
   * This information will be used to present the user with extra, detailed
   * information about the selected proposal.
   *
   * @return The extra information of a proposal or empty string if no extra
   * information is associated to a proposal.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(Glib::ustring get_info() const, gtk_source_completion_proposal_get_info)

  /** Emits the "changed" signal on a proposal.
   *
   * This should be called by implementations whenever the name, icon or info of
   * the proposal has changed.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(void changed(), gtk_source_completion_proposal_changed)

  /** Get the hash value of a proposal.
   *
   * This is used to (together with equal()) to match proposals in the
   * completion model. By default, it uses a direct hash.
   *
   * @return The hash value of a proposal.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(guint hash() const, gtk_source_completion_proposal_hash)

  /** Get whether two proposal objects are the same.
   *
   * This is used to (together with hash()) to match proposals in the
   * completion model. By default, it uses direct equality.
   *
   * @param other A CompletionProposal.
   * @return @c true if a proposal and @a other are the same proposal.
   *
   * @newin{2,10}
   */
  _WRAP_METHOD(bool equal(const Glib::RefPtr<const CompletionProposal>& other) const, gtk_source_completion_proposal_equal)

  /** Emitted when the proposal has changed.
   *
   * The completion popup will react to this by updating the shown information.
   *
   * @newin{2,10}
   */
  _WRAP_SIGNAL(void changed(), "changed")

private:

  _WRAP_VFUNC(Glib::ustring get_label() const, get_label)

  _WRAP_VFUNC(Glib::ustring get_markup() const, get_markup)

  _WRAP_VFUNC(Glib::ustring get_text() const, get_text)

  _WRAP_VFUNC(Glib::RefPtr<Gdk::Pixbuf> get_icon() const, get_icon, refreturn)

  _WRAP_VFUNC(Glib::ustring get_info() const, get_info)

  _WRAP_VFUNC(guint hash() const, hash)

#m4 _CONVERSION(`GtkSourceCompletionProposal*', `const Glib::RefPtr<const CompletionProposal>&', `Glib::wrap($3, true)')
  _WRAP_VFUNC(bool equal(const Glib::RefPtr<const CompletionProposal>& other) const, equal)
#m4 _CONVERSION(`GtkSourceCompletionProposal*', `const Glib::RefPtr<const CompletionProposal>&', `Glib::wrap($3)')
};

} // namespace Gsv


