Beispiel #1
0
static gboolean
mex_suggest_timeout_cb (MexSearchPlugin *self)
{
  gchar *uri;
  const gchar *text;
  MexDownloadQueue *dq;

  MexSearchPluginPrivate *priv = self->priv;

  priv->suggest_timeout = 0;

  text = mx_entry_get_text (MX_ENTRY (priv->search_entry));

  dq = mex_download_queue_get_default ();

  if (priv->suggest_id)
    mex_download_queue_cancel (dq, priv->suggest_id);

  uri =
    g_strdup_printf ("http://google.com/complete/search?output=toolbar&q=%s",
                     text);
  priv->suggest_id =
    mex_download_queue_enqueue (dq, uri, mex_suggest_complete_cb, self);

  return FALSE;
}
Beispiel #2
0
/**
 * mpl_entry_get_text:
 * @self: #MplEntry
 *
 * Retrieves the text of the entry.
 *
 * Return value: pointer to string holding the text; the string is owned by
 * the entry and must not be freed.
 */
const gchar *
mpl_entry_get_text (MplEntry *self)
{
  g_return_val_if_fail (MPL_IS_ENTRY (self), NULL);

  return mx_entry_get_text (MX_ENTRY (self->priv->entry));
}
Beispiel #3
0
static void
mex_search_text_changed_cb (MxEntry         *entry,
                            GParamSpec      *pspec,
                            MexSearchPlugin *self)
{
  MexSearchPluginPrivate *priv = self->priv;

  if (priv->suggest_timeout)
    {
      g_source_remove (priv->suggest_timeout);
      priv->suggest_timeout = 0;
    }

  /* Don't start suggestions unless we have at least 3 characters */
  if (g_utf8_strlen (mx_entry_get_text (entry), -1) < 3)
    {
      /* ensure the spinner is not visible */
      mx_spinner_set_animating (MX_SPINNER (priv->spinner), FALSE);
      clutter_actor_hide (priv->spinner);

      return;
    }

  /* show spinner */
  mx_spinner_set_animating (MX_SPINNER (priv->spinner), TRUE);
  clutter_actor_show (priv->spinner);

  priv->suggest_timeout =
    g_timeout_add_seconds (1, (GSourceFunc)mex_suggest_timeout_cb, self);
}
static gboolean
start_search (MnpWorldClock *area)
{
    MnpWorldClockPrivate *priv = GET_PRIVATE (area);

    priv->completion_timeout = 0;

    if (!priv->completion_inited) {
        priv->completion_inited = TRUE;
        construct_completion (area);
    }
    priv->search_text = mx_entry_get_text (priv->search_location);

    if (!priv->search_text || (strlen(priv->search_text) < 3))
        clutter_actor_hide(priv->completion);

    if (priv->search_text && (strlen(priv->search_text) > 2))
        g_signal_emit_by_name (priv->zones_model, "filter-changed");
    if (priv->search_text && (strlen(priv->search_text) > 2) && (clutter_model_get_n_rows(priv->zones_model) > 0)) {
        clutter_actor_show(priv->completion);
        clutter_actor_raise_top (priv->completion);
    } else {
        clutter_actor_hide(priv->completion);
    }


    return FALSE;
}
static void
_yes_clicked_cb (MxButton *button, DawatiBtRequest *request)
{
  DawatiBtRequestPrivate *priv = GET_PRIVATE (request);
  const char *response = NULL;

  if (priv->request == DAWATI_BT_REQUEST_TYPE_PIN)
    response = mx_entry_get_text (MX_ENTRY (priv->request_entry));

  g_signal_emit (request, signals[SIGNAL_RESPONSE], 0,
                 DAWATI_BT_REQUEST_RESPONSE_YES, response);
}
Beispiel #6
0
static void
_update_clicked (MxButton         *button,
                 ObjectStoreTest  *app)
{
  char const *input;

  input = mx_entry_get_text (app->entry);
  if (input == NULL ||
      input[0] == '\0')
  {
    g_warning ("Please enter text");
    return;

  } else if (input[0] == '-') {

    /* Remove item */
    int index = g_ascii_isdigit (input[1]) ?
                  atoi (&input[1]) :
                  -1;
    if (index < 0)
    {
      g_warning ("Invalid number, can not remove");
      return;
    }

    clutter_model_remove (app->store, index);

  } else if (g_ascii_isdigit (input[0])) {

    /* Update item */
    unsigned index = atoi (input);
    char **tokens = g_strsplit (input, ":", 2);
    char const *text = tokens[1];
    FooTestObject *object = store_get_object (app->store, index);

    if (object == NULL)
    {
      g_warning ("Failed to find object");
      return;
    }

    foo_test_object_set_text (FOO_TEST_OBJECT (object), text);
    g_object_unref (object);

  } else {

    /* Add item */
    store_add_object (app->store, input);
  }

  mx_entry_set_text (app->entry, "");
}
Beispiel #7
0
static void
search_entry_text_changed_cb (MxEntry        *entry,
                              GParamSpec     *pspec,
                              MnbPeoplePanel *self)
{
  MnbPeoplePanelPrivate *priv = GET_PRIVATE (self);
  const gchar *text = mx_entry_get_text (entry);

  if (text != NULL && text[0] == '\0')
    text = NULL;

  anerley_feed_model_set_filter_text (priv->model, text);
}
static void
add_location_clicked_cb (ClutterActor *button, MnpWorldClock *world_clock)
{
    MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock);

    mx_list_view_set_model (MX_LIST_VIEW (priv->zones_list), NULL);

    priv->search_text = NULL;
    g_signal_emit_by_name (priv->zones_model, "filter-changed");

    add_location_tile (world_clock, mx_entry_get_text (priv->search_location), FALSE);

    mx_list_view_set_model (MX_LIST_VIEW (priv->zones_list), priv->zones_model);
}
static void
mex_search_plugin_search_cb (MexSearchPlugin *self)
{
  MexSearchPluginPrivate *priv = self->priv;

  const gchar *search = mx_entry_get_text (MX_ENTRY (priv->search_entry));

  /* don't run a search if the search entry was empty */
  if (!search || search[0] == '\0')
    return;

  /* Stop the suggestions search */
  if (priv->suggest_timeout)
    {
      g_source_remove (priv->suggest_timeout);
      priv->suggest_timeout = 0;
    }

  /* Start a new search */
  mex_search_plugin_search (self, search);

  /* Update the history list */
  mex_search_plugin_update_history (self, search);

  /* Present the search model */
  mex_model_provider_present_model (MEX_MODEL_PROVIDER (self),
                                    priv->search_model);

  /* Hide the search page, if it was visible */
  if (CLUTTER_ACTOR_IS_VISIBLE (priv->search_page))
    mex_tool_provider_remove_actor (MEX_TOOL_PROVIDER (self),
                                    priv->search_page);

  /* TODO: Maybe use weak references to stop the search if the application
   *       didn't use it?
   */
}
Beispiel #10
0
static void
mex_search_plugin_search_cb (MexSearchPlugin *self)
{
  MexModelInfo *info;
  MexSearchPluginPrivate *priv = self->priv;

  const gchar *search = mx_entry_get_text (MX_ENTRY (priv->search_entry));

  /* Stop the suggestions search */
  if (priv->suggest_timeout)
    {
      g_source_remove (priv->suggest_timeout);
      priv->suggest_timeout = 0;
    }

  /* Start a new search */
  mex_search_plugin_search (self, search);

  /* Update the history list */
  mex_search_plugin_update_history (self, search);

  /* Present the search model */
  info = mex_model_info_new_with_sort_funcs (priv->search_model,
                                             "search-results", 0);
  mex_model_provider_present_model (MEX_MODEL_PROVIDER (self), info);
  mex_model_info_free (info);

  /* Hide the search page, if it was visible */
  if (CLUTTER_ACTOR_IS_VISIBLE (priv->search_page))
    mex_tool_provider_remove_actor (MEX_TOOL_PROVIDER (self),
                                    priv->search_page);

  /* TODO: Maybe use weak references to stop the search if the application
   *       didn't use it?
   */
}
Beispiel #11
0
static void
text_changed_cb (MxEntry *entry, GParamSpec *pspec, void *user_data)
{
  printf ("Text: %s\n", mx_entry_get_text (entry));
}