Ejemplo n.º 1
0
static void
add_float_prop_base (ClutterActor *table,
                     const char *name,
                     FloatProp *prop,
                     float value)
{
  int table_y = mx_table_get_row_count (MX_TABLE (table));
  ClutterActor *label;
  ClutterActor *slider;

  label = mx_label_new_with_text (name);
  mx_table_add_actor (MX_TABLE (table), label, table_y, 0);

  slider = mx_slider_new ();
  mx_table_add_actor (MX_TABLE (table), slider, table_y, 1);

  prop->label = mx_label_new ();
  mx_table_add_actor (MX_TABLE (table), prop->label, table_y, 2);

  mx_slider_set_value (MX_SLIDER (slider),
                       (value - prop->min) / (prop->max - prop->min));

  update_float_prop_label (prop, value);

  g_signal_connect_data (slider, "notify::value",
                         G_CALLBACK (float_prop_value_cb),
                         prop,
                         (GClosureNotify) float_prop_free,
                         0);
}
Ejemplo n.º 2
0
static void
add_color_prop_base (ClutterActor *table,
                     const char *name,
                     ColorProp *prop,
                     const ClutterColor *value)
{
  int table_y = mx_table_get_row_count (MX_TABLE (table));
  ClutterActor *label;
  static const char *color_names[] = { "red", "green", "blue" };
  int i;

  label = mx_label_new_with_text (name);
  mx_table_add_actor (MX_TABLE (table), label, table_y, 0);
  prop->rect = clutter_rectangle_new ();
  clutter_rectangle_set_color (CLUTTER_RECTANGLE (prop->rect), value);
  clutter_actor_set_size (prop->rect, 20, 0);
  mx_table_add_actor (MX_TABLE (table), prop->rect, table_y++, 1);

  for (i = 0; i < G_N_ELEMENTS (color_names); i++)
    {
      ClutterActor *slider;
      char *label_name = g_strconcat (name, " ", color_names[i], NULL);
      ColorPropComp *prop_comp = g_slice_new (ColorPropComp);

      label = mx_label_new_with_text (label_name);
      mx_table_add_actor (MX_TABLE (table), label, table_y, 0);
      g_free (label_name);

      slider = mx_slider_new ();
      mx_table_add_actor (MX_TABLE (table), slider, table_y, 1);

      mx_slider_set_value (MX_SLIDER (slider),
                           ((guint8 *) value)[i] / 255.0f);

      prop_comp->comp_num = i;
      prop_comp->prop = prop;

      prop_comp->label = mx_label_new ();
      mx_table_add_actor (MX_TABLE (table), prop_comp->label, table_y, 2);
      update_prop_comp_label (prop_comp, ((guint8 *) value)[i]);

      g_signal_connect_data (slider, "notify::value",
                             G_CALLBACK (color_prop_value_cb),
                             prop_comp,
                             (GClosureNotify) color_prop_comp_free,
                             0);

      table_y++;
    }
}
Ejemplo n.º 3
0
static void
penge_grid_view_init (PengeGridView *self)
{
  PengeGridViewPrivate *priv = GET_PRIVATE_REAL (self);

  self->priv = priv;



  priv->everything_pane = g_object_new (PENGE_TYPE_EVERYTHING_PANE,
                                        NULL);

  mx_table_add_actor (MX_TABLE (self), priv->everything_pane, 0, 0);

  mx_table_set_row_spacing (MX_TABLE (self), 6);
  mx_table_set_column_spacing (MX_TABLE (self), 6);

  /* 
   * Create a background and parent it to the grid. We paint and allocate this
   * in the overridden vfuncs
   */
  priv->background = g_object_new (PENGE_TYPE_VIEW_BACKGROUND, NULL);
  clutter_actor_set_parent (priv->background, (ClutterActor *)self);
  clutter_actor_show (priv->background);

  priv->background_fade = clutter_texture_new_from_file (FADE_BG,
                                                         NULL);
  clutter_actor_set_parent (priv->background_fade, (ClutterActor *)self);
  clutter_actor_show (priv->background_fade);

  priv->gconf_client = gconf_client_get_default ();

 _update_layout (self);
}
Ejemplo n.º 4
0
static void
ntf_tray_constructed (GObject *object)
{
  NtfTray        *self = (NtfTray*) object;
  ClutterActor   *actor = (ClutterActor*) self;
  NtfTrayPrivate *priv = self->priv;
  ClutterActor   *button;

  if (G_OBJECT_CLASS (ntf_tray_parent_class)->constructed)
    G_OBJECT_CLASS (ntf_tray_parent_class)->constructed (object);

  priv->notifiers = clutter_actor_new ();

  clutter_actor_add_child(actor, priv->notifiers);
  /* 'Overflow' control */
  priv->control = mx_table_new ();

  mx_stylable_set_style_class (MX_STYLABLE (priv->control),
                               "notification-control");
#if 0
  button = mx_button_new ();
  mx_button_set_label (MX_BUTTON (button), _("Dismiss All"));
  mx_table_add_actor (MX_TABLE (priv->control), button, 0, 1);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (ntf_tray_dismiss_all_cb), self);
#endif //DV
  priv->control_text = mx_label_new ();
  mx_table_add_actor (MX_TABLE (priv->control),
                        CLUTTER_ACTOR (priv->control_text), 0, 0);

  clutter_actor_set_width (priv->control, CLUSTER_WIDTH);

  clutter_actor_add_child(actor, priv->control);

  clutter_actor_hide (priv->control);

  clutter_actor_set_reactive (priv->notifiers, TRUE);
  clutter_actor_set_reactive (actor, TRUE);

  mnb_input_manager_push_actor (actor, MNB_INPUT_LAYER_TOP);
}
Ejemplo n.º 5
0
static void
penge_interesting_tile_init (PengeInterestingTile *self)
{
    PengeInterestingTilePrivate *priv = GET_PRIVATE_REAL (self);
    ClutterActor *tmp_text;
    ClutterActor *icon;

    self->priv = priv;

    priv->inner_table = mx_table_new ();
    mx_bin_set_child (MX_BIN (self),
                      priv->inner_table);
    mx_bin_set_fill (MX_BIN (self), TRUE, TRUE);

    priv->primary_text = mx_label_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->primary_text),
                                 "PengeInterestingTilePrimaryLabel");
    tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->primary_text));
    clutter_text_set_line_alignment (CLUTTER_TEXT (tmp_text),
                                     PANGO_ALIGN_LEFT);
    clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text),
                                PANGO_ELLIPSIZE_END);
    g_signal_connect (priv->primary_text,
                      "notify::allocation",
                      (GCallback)_label_notify_allocation_cb,
                      self);

    priv->secondary_text = mx_label_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->secondary_text),
                                 "PengeInterestingTileSecondaryLabel");
    tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->secondary_text));
    clutter_text_set_line_alignment (CLUTTER_TEXT (tmp_text),
                                     PANGO_ALIGN_LEFT);
    clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text),
                                PANGO_ELLIPSIZE_END);
    g_signal_connect (priv->secondary_text,
                      "notify::allocation",
                      (GCallback)_label_notify_allocation_cb,
                      self);

    priv->icon = clutter_texture_new ();
    clutter_actor_set_size (priv->icon, 28, 28);
    clutter_actor_hide (priv->icon);

    /* This gets added to ourself table after our body because of ordering */
    priv->details_overlay = mx_table_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->details_overlay),
                                 "PengeInterestingTileDetails");

    mx_table_add_actor (MX_TABLE (priv->inner_table),
                        priv->details_overlay,
                        1,
                        0);

    clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                                 (ClutterActor *)priv->details_overlay,
                                 "x-expand", TRUE,
                                 "y-expand", FALSE,
                                 "y-fill", FALSE,
                                 "y-align", MX_ALIGN_END,
                                 NULL);

    mx_table_add_actor (MX_TABLE (priv->details_overlay),
                        priv->primary_text,
                        0,
                        1);

    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 (ClutterActor *)priv->primary_text,
                                 "x-expand",
                                 TRUE,
                                 "y-expand",
                                 FALSE,
                                 NULL);

    mx_table_add_actor (MX_TABLE (priv->details_overlay),
                        priv->secondary_text,
                        1,
                        1);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 (ClutterActor *)priv->secondary_text,
                                 "x-expand",
                                 TRUE,
                                 "y-expand",
                                 FALSE,
                                 NULL);

    mx_table_add_actor (MX_TABLE (priv->details_overlay),
                        priv->icon,
                        0,
                        0);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 priv->icon,
                                 "row-span", 2,
                                 "y-expand", FALSE,
                                 "x-expand", FALSE,
                                 "y-fill", FALSE,
                                 "x-fill", FALSE,
                                 NULL);

    priv->remove_button = mx_button_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->remove_button),
                                 "PengeInterestingTileRemoveButton");
    icon = (ClutterActor *)mx_icon_new ();
    mx_stylable_set_style_class (MX_STYLABLE (icon),
                                 "PengeInterestingTileIcon");
    mx_bin_set_child (MX_BIN (priv->remove_button),
                      (ClutterActor *)icon);
    mx_table_add_actor_with_properties (MX_TABLE (priv->details_overlay),
                                        priv->remove_button,
                                        0, 2,
                                        "row-span", 2,
                                        "x-expand", TRUE,
                                        "y-expand", TRUE,
                                        "x-fill", FALSE,
                                        "y-fill", FALSE,
                                        "x-align", MX_ALIGN_END,
                                        "y-align", MX_ALIGN_MIDDLE,
                                        NULL);

    g_signal_connect (priv->remove_button,
                      "clicked",
                      (GCallback)_remove_button_clicked,
                      self);

    mx_table_set_column_spacing (MX_TABLE (priv->details_overlay), 4);

    clutter_actor_set_reactive ((ClutterActor *) self, TRUE);

    clutter_actor_hide (priv->icon);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 priv->primary_text,
                                 "column", 0,
                                 NULL);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 priv->secondary_text,
                                 "column", 0,
                                 NULL);
}
Ejemplo n.º 6
0
int
main (int argc, char **argv)
{
  ClutterActor *stage = stage;
  ClutterActor *side_box;
  ClutterActor *button_box;
  ClutterActor *box;
  ClutterAnimation *anim;
  MashLightSet *light_set;
  MxStyle *style;
  GError *error = NULL;
  Data data;
  int i;

  if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  style = mx_style_get_default ();
  if (!mx_style_load_from_file (style, "lights.css",
                                &error))
    {
      g_warning ("Error setting style: %s", error->message);
      g_clear_error (&error);
    }

  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 800, 600);

  side_box = mx_table_new ();
  clutter_actor_set_name (side_box, "side-box");
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), side_box);
  clutter_actor_set_size (side_box, 300,
                          clutter_actor_get_height (stage));
  clutter_actor_set_x (side_box,
                       clutter_actor_get_width (stage)
                       - clutter_actor_get_width (side_box));

  button_box = mx_table_new ();
  mx_table_add_actor (MX_TABLE (side_box), button_box, 0, 0);

  data.notebook = mx_notebook_new ();

  mx_table_add_actor (MX_TABLE (side_box), data.notebook, 1, 0);

  data.model = mash_model_new_from_file (MASH_DATA_NONE,
                                         argc > 1
                                         ? argv[1]
                                         : "suzanne.ply",
                                         &error);
  if (data.model == NULL)
    {
      g_warning ("Error loading model: %s", error->message);
      g_clear_error (&error);
      return 1;
    }

  light_set = mash_light_set_new ();

  box = clutter_box_new (clutter_fixed_layout_new ());

  clutter_actor_set_size (data.model, 400, 400);
  clutter_actor_set_position (data.model, 50.0, 100.0);
  clutter_container_add_actor (CLUTTER_CONTAINER (box), data.model);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);

  g_signal_connect_swapped (box, "paint",
                            G_CALLBACK (cogl_set_depth_test_enabled),
                            GINT_TO_POINTER (TRUE));
  g_signal_connect_data (box, "paint",
                         G_CALLBACK (cogl_set_depth_test_enabled),
                         GINT_TO_POINTER (FALSE), NULL,
                         G_CONNECT_AFTER | G_CONNECT_SWAPPED);

  data.light_marker_material = cogl_material_new ();
  {
    CoglColor color;
    cogl_color_set_from_4ub (&color, 255, 0, 0, 255);
    /* Use the layer state to ignore the vertex color from the shader so
       that the light marker won't itself be lit */
    cogl_material_set_layer_combine_constant (data.light_marker_material, 0,
                                              &color);
    cogl_material_set_layer_combine (data.light_marker_material, 0,
                                     "RGBA = REPLACE(CONSTANT)",
                                     NULL);
  }

  clutter_actor_set_rotation (data.model, CLUTTER_Y_AXIS,
                              0.0f,
                              clutter_actor_get_width (data.model) / 2.0f,
                              0.0f,
                              0.0f);

  anim = clutter_actor_animate (data.model, CLUTTER_LINEAR, 3000,
                                "rotation-angle-y", 360.0f,
                                NULL);
  clutter_animation_set_loop (anim, TRUE);

  for (i = 0; i < N_LIGHTS; i++)
    {
      ClutterActor *table = mx_table_new ();
      ClutterActor *button;
      static ClutterActor *(* constructors[N_LIGHTS]) (void) =
        { mash_directional_light_new,
          mash_point_light_new,
          mash_spot_light_new };
      static const ClutterColor black = { 0, 0, 0, 255 };

      data.lights[i] = constructors[i] ();

      button = mx_button_new_with_label (G_OBJECT_TYPE_NAME (data.lights[i]));
      mx_table_add_actor (MX_TABLE (button_box), button, i, 0);

      /* Default to disable all of the lights */
      g_object_set (data.lights[i],
                    "ambient", &black,
                    "diffuse", &black,
                    "specular", &black,
                    NULL);

      data.notebook_buttons[i] = button;

      clutter_container_add_actor (CLUTTER_CONTAINER (box), data.lights[i]);
      mash_light_set_add_light (light_set, MASH_LIGHT (data.lights[i]));

      add_color_prop (table, "ambient light",
                      G_OBJECT (data.lights[i]), "ambient");
      add_color_prop (table, "diffuse light",
                      G_OBJECT (data.lights[i]), "diffuse");
      add_color_prop (table, "specular light",
                      G_OBJECT (data.lights[i]), "specular");

      if (MASH_IS_POINT_LIGHT (data.lights[i]))
        {
          add_float_prop (table, "constant attenuation",
                          G_OBJECT (data.lights[i]), "constant-attenuation",
                          0.0f, 10.0f);
          add_float_prop (table, "linear attenuation",
                          G_OBJECT (data.lights[i]), "linear-attenuation",
                          0.0f, 10.0f);
          add_float_prop (table, "quadratic attenuation",
                          G_OBJECT (data.lights[i]), "quadratic-attenuation",
                          0.0f, 10.0f);
        }

      if (MASH_IS_SPOT_LIGHT (data.lights[i]))
        {
          clutter_actor_set_x (data.lights[i], 250);

          add_float_prop (table, "spot cutoff",
                          G_OBJECT (data.lights[i]), "spot-cutoff",
                          0.0f, 90.0f);
          add_float_prop (table, "spot exponent",
                          G_OBJECT (data.lights[i]), "spot-exponent",
                          0.0f, 128.0f);
        }

      clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table);

      data.notebook_pages[i] = table;
    }

  {
    ClutterActor *button;
    ClutterActor *table;
    CoglHandle material;
    float maximum_shininess;

    material = mash_model_get_pipeline (MASH_MODEL (data.model));

    /* Before version 1.3.10 on the 1.3 branch and 1.2.14 on the 1.2
       branch Cogl would remap the shininess property to the range
       [0,1]. After this it is just a value greater or equal to zero
       (but GL imposes a limit of 128.0) */
    if (clutter_check_version (1, 3, 9)
        || (clutter_major_version == 1
            && clutter_minor_version == 2
            && clutter_micro_version >= 13))
      maximum_shininess = 128.0f;
    else
      maximum_shininess = 1.0f;

    cogl_material_set_shininess (material, maximum_shininess);

    button = mx_button_new_with_label ("Material");
    data.notebook_buttons[i] = button;
    mx_table_add_actor (MX_TABLE (button_box), button, i, 0);
    table = mx_table_new ();
    data.notebook_pages[i] = table;
    clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table);

    add_material_color_prop (table, "emission", material,
                             cogl_material_set_emission,
                             cogl_material_get_emission);
    add_material_color_prop (table, "diffuse", material,
                             cogl_material_set_diffuse,
                             cogl_material_get_diffuse);
    add_material_color_prop (table, "ambient", material,
                             cogl_material_set_ambient,
                             cogl_material_get_ambient);
    add_material_color_prop (table, "specular", material,
                             cogl_material_set_specular,
                             cogl_material_get_specular);
    add_material_float_prop (table, "shininess", material,
                             0.0f, maximum_shininess,
                             cogl_material_set_shininess,
                             cogl_material_get_shininess);
  }

  mash_model_set_light_set (MASH_MODEL (data.model), light_set);
  g_object_unref (light_set);

  for (i = 0; i < N_PAGES; i++)
    {
      g_signal_connect (data.notebook_buttons[i], "notify::toggled",
                        G_CALLBACK (notebook_button_cb), &data);
      mx_button_set_is_toggle (MX_BUTTON (data.notebook_buttons[i]), TRUE);
    }

  mx_button_set_toggled (MX_BUTTON (data.notebook_buttons[0]), TRUE);

  g_signal_connect (stage, "motion-event",
                    G_CALLBACK (motion_event_cb),
                    &data);

  clutter_actor_show (stage);

  clutter_main ();

  cogl_handle_unref (data.light_marker_material);

  return 0;
}
Ejemplo n.º 7
0
static void
penge_apps_pane_update (PengeAppsPane *pane)
{
  PengeAppsPanePrivate *priv = GET_PRIVATE (pane);
  GList *bookmarks, *l, *to_remove;
  ClutterActor *actor;
  gint count = 0;
  gchar *path;
  GError *error = NULL;
  const gchar *uri = NULL;

  bookmarks = mpl_app_bookmark_manager_get_bookmarks (priv->manager);

  to_remove = g_hash_table_get_keys (priv->uris_to_actors);

  for (l = bookmarks; l && count < MAX_COUNT; l = l->next)
  {
    uri = (gchar *)l->data;

    actor = g_hash_table_lookup (priv->uris_to_actors,
                                 uri);

    /* Check if this URI is on the system */
    path = g_filename_from_uri (uri, NULL, &error);

    if (error)
    {
      g_warning (G_STRLOC ": Error converting uri to path: %s",
                 error->message);
      g_clear_error (&error);

      if (actor)
      {
        clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                        actor);
      }

      continue;
    }

    if (!g_file_test (path, G_FILE_TEST_EXISTS))
    {
      /* skip those that have a missing .desktop file */
      g_free (path);
      continue;
    }

    g_free (path);

    if (actor)
    {
      if (!priv->vertical)
      {
        clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                     actor,
                                     "row",
                                     count / ROW_SIZE,
                                     "column",
                                     count % ROW_SIZE,
                                     NULL);
      } else {
        clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                     actor,
                                     "row",
                                     count / 1,
                                     "column",
                                     count % 1,
                                     NULL);
      }
    } else {
      actor = g_object_new (PENGE_TYPE_APP_TILE,
                            "bookmark",
                            uri,
                            NULL);
      if (!priv->vertical)
      {
        mx_table_add_actor (MX_TABLE (pane),
                            actor,
                            count / ROW_SIZE,
                            count % ROW_SIZE);
      } else {
        mx_table_add_actor (MX_TABLE (pane),
                            actor,
                            count / 1,
                            count % 1);
      }
      clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                   actor,
                                   "x-expand", TRUE,
                                   "y-expand", TRUE,
                                   "x-fill", FALSE,
                                   "y-fill", FALSE,
                                   NULL);
      g_hash_table_insert (priv->uris_to_actors,
                           g_strdup (uri),
                           actor);
    }

    /* Found, so don't remove */
    /* This craziness is because the allocated string is probably different */
    to_remove = g_list_delete_link (to_remove,
                                    g_list_find_custom (to_remove,
                                                        uri,
                                                        (GCompareFunc)g_strcmp0));
    count++;
  }

  g_list_free (bookmarks);

  for (l = to_remove; l; l = g_list_delete_link (l, l))
  {
    actor = g_hash_table_lookup (priv->uris_to_actors,
                                 (gchar *)(l->data));
    clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                    actor);
    g_hash_table_remove (priv->uris_to_actors, (gchar *)(l->data));
  }
}
Ejemplo n.º 8
0
static void
mex_search_plugin_init (MexSearchPlugin *self)
{
  MexProxy *suggest_proxy;
  ClutterActor *icon, *header, *text, *frame, *box, *hbox;
  MexSearchPluginPrivate *priv = self->priv = SEARCH_PLUGIN_PRIVATE (self);

  /* Load style data */
  mx_style_load_from_file (mx_style_get_default (),
                           PLUGIN_DATA_DIR "/style.css", NULL);

  /* Create the history model and models list */
  priv->history_model = mex_feed_new (_("Search"), _("Search"));

  priv->model_info =
    mex_model_info_new_with_sort_funcs (MEX_MODEL (priv->history_model),
                                        "search", 0);
  g_object_unref (priv->history_model);
  priv->models = g_list_append (NULL, priv->model_info);

  /* Create the actions list */
  memset (&priv->action_info, 0, sizeof (MexActionInfo));
  priv->action_info.action =
    mx_action_new_full ("x-mex/search",
                        _("Search"),
                        G_CALLBACK (mex_search_plugin_history_cb),
                        self);
  priv->action_info.mime_types = (gchar **)search_mimetypes;
  priv->actions = g_list_append (NULL, &priv->action_info);

  /* Create the suggestions model */
  priv->suggest_model =
    mex_feed_new (_("Suggestions"), _("Google Suggestions"));

  /* Create the search page */

  /* Create header */
  icon = mx_icon_new ();
  mx_stylable_set_style_class (MX_STYLABLE (icon), "Search");

  header = mx_box_layout_new ();
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (header), 5);
  clutter_actor_set_name (header, "search-header");

  /* Create search entry */
  frame = mx_table_new ();
  clutter_actor_set_name (frame, "search-entry-frame");
  priv->search_entry = mx_entry_new ();
  priv->spinner = mx_spinner_new ();

  mx_table_add_actor (MX_TABLE (frame), priv->search_entry, 0, 0);
  mx_table_add_actor (MX_TABLE (frame), priv->spinner, 0, 1);
  mx_table_child_set_x_fill (MX_TABLE (frame), priv->spinner, FALSE);
  mx_table_child_set_x_expand (MX_TABLE (frame), priv->spinner, FALSE);
  mx_table_child_set_y_fill (MX_TABLE (frame), priv->spinner, FALSE);

  mx_spinner_set_animating (MX_SPINNER (priv->spinner), FALSE);
  clutter_actor_hide (priv->spinner);

  clutter_container_add (CLUTTER_CONTAINER (header), icon, frame, NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (header), icon,
                               "x-fill", FALSE, "y-fill", FALSE, NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (header), frame,
                               "expand", TRUE, "x-fill", TRUE, NULL);

  text = mx_entry_get_clutter_text (MX_ENTRY (priv->search_entry));
  g_signal_connect_swapped (text, "activate",
                            G_CALLBACK (mex_search_plugin_search_cb), self);
  g_signal_connect (priv->search_entry, "notify::text",
                    G_CALLBACK (mex_search_text_changed_cb), self);
  g_signal_connect (priv->search_entry, "notify::style-pseudo-class",
                    G_CALLBACK (mex_search_text_style_changed), header);

  /* Create the suggestions column */
  priv->suggest_column = mx_box_layout_new ();
  clutter_actor_set_name (priv->suggest_column, "suggest-column");
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->suggest_column),
                                 MX_ORIENTATION_VERTICAL);
  suggest_proxy = mex_generic_proxy_new (MEX_MODEL (priv->suggest_model),
                                        MX_TYPE_BUTTON);
  mex_generic_proxy_bind (MEX_GENERIC_PROXY (suggest_proxy),
                          mex_enum_to_string (MEX_TYPE_CONTENT_METADATA,
                                              MEX_CONTENT_METADATA_TITLE),
                          "label");
  g_signal_connect (suggest_proxy, "object-created",
                    G_CALLBACK (mex_search_proxy_add_cb),
                    priv->suggest_column);
  g_signal_connect (suggest_proxy, "object-removed",
                    G_CALLBACK (mex_search_proxy_remove_cb),
                    priv->suggest_column);
  g_object_weak_ref (G_OBJECT (priv->suggest_column),
                     (GWeakNotify)g_object_unref, suggest_proxy);

  /* Pack the search page */
  priv->search_page = mx_frame_new ();
  clutter_actor_set_name (priv->search_page, "search-page");
  mx_bin_set_fill (MX_BIN (priv->search_page), FALSE, TRUE);
  mx_bin_set_alignment (MX_BIN (priv->search_page), MX_ALIGN_START,
                        MX_ALIGN_START);
  hbox = mex_resizing_hbox_new ();
  mex_resizing_hbox_set_resizing_enabled (MEX_RESIZING_HBOX (hbox), FALSE);
  box = mx_box_layout_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (priv->search_page), hbox);
  clutter_container_add_actor (CLUTTER_CONTAINER (hbox), box);
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box),
                                 MX_ORIENTATION_VERTICAL);
  clutter_container_add (CLUTTER_CONTAINER (box),
                         header, priv->suggest_column, NULL);
  mx_box_layout_child_set_expand (MX_BOX_LAYOUT (box),
                                  priv->suggest_column, TRUE);
  clutter_container_child_set (CLUTTER_CONTAINER (box), header,
                               "x-fill", TRUE,
                               "x-align", MX_ALIGN_START, NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (box),
                               priv->suggest_column,
                               "x-fill", TRUE,
                               "x-align", MX_ALIGN_START, NULL);
  clutter_actor_set_width (box, 426.0);

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

  /* Start the history list and suggestions proxy */
  mex_proxy_start (suggest_proxy);
}
Ejemplo n.º 9
0
static void
penge_event_tile_init (PengeEventTile *self)
{
  PengeEventTilePrivate *priv = GET_PRIVATE_REAL (self);
  ClutterActor *tmp_text;
  ClutterActor *indicator_container, *indicator_overlay;
  GError *error = NULL;

  self->priv = priv;

  priv->inner_table = mx_table_new ();
  mx_bin_set_child (MX_BIN (self), (ClutterActor *)priv->inner_table);
  mx_bin_set_fill (MX_BIN (self), TRUE, TRUE);

  indicator_container = mx_stack_new ();
  clutter_actor_set_size (indicator_container, 20, 20);

  priv->calendar_indicator = clutter_cairo_texture_new (20, 20);
  clutter_actor_set_size (priv->calendar_indicator, 20, 20);

  indicator_overlay = clutter_texture_new_from_file (CALENDAR_INDICATOR_OVERLAY_MASK, &error); 
  if (error != NULL)
    {
      g_critical (G_STRLOC ": Loading calendar colour overlay failed: %s",
                  error->message);
      g_clear_error (&error);
      indicator_overlay = NULL;
    }
  else
    {
      clutter_actor_set_size (indicator_overlay, 20, 20);
    }

  clutter_container_add (CLUTTER_CONTAINER (indicator_container),
      priv->calendar_indicator, indicator_overlay, NULL);

  priv->time_label = mx_label_new ();
  tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->time_label));
  clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_NONE);
  mx_stylable_set_style_class (MX_STYLABLE (priv->time_label),
                               "PengeEventTimeLabel");

  priv->summary_label = mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->summary_label),
                               "PengeEventSummary");
  tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->summary_label));
  clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text), PANGO_ELLIPSIZE_END);
  clutter_text_set_single_line_mode (CLUTTER_TEXT (tmp_text), TRUE);

  /* Populate the table */
  mx_table_add_actor (MX_TABLE (priv->inner_table),
                      indicator_container,
                      0,
                      0);
  mx_table_add_actor (MX_TABLE (priv->inner_table),
                      priv->time_label,
                      0,
                      1);
  mx_table_add_actor (MX_TABLE (priv->inner_table),
                      priv->summary_label,
                      0,
                      2);

  clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                               indicator_container,
                               "x-expand", FALSE,
                               "x-fill", FALSE,
                               "y-expand", FALSE,
                               "y-fill", FALSE,
                               NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                               priv->time_label,
                               "x-expand", FALSE,
                               "x-fill", FALSE,
                               "y-expand", FALSE,
                               "y-fill", FALSE,
                               NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                               priv->summary_label,
                               "x-expand", TRUE,
                               "x-fill", TRUE,
                               "y-expand", FALSE,
                               "y-fill", FALSE,
                               NULL);


  /* Setup spacing and padding */
  mx_table_set_column_spacing (MX_TABLE (priv->inner_table), 6);

  g_signal_connect (self,
                    "clicked",
                    (GCallback)_button_clicked_cb,
                    self);

  clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
}
static void
mnb_people_panel_init (MnbPeoplePanel *self)
{
  MnbPeoplePanelPrivate *priv = GET_PRIVATE (self);
  ClutterActor *label;
  ClutterActor *scroll_view, *bin, *tmp_text;
  AnerleyFeed *active_feed;
  ClutterActor *settings_launcher;

  mx_table_set_column_spacing (MX_TABLE (self), 6);
  mx_table_set_row_spacing (MX_TABLE (self), 6);

  /* Populate top level table */
  priv->header_box = mx_table_new ();
  clutter_actor_set_name (priv->header_box, "people-panel-header-box");
  mx_table_set_column_spacing (MX_TABLE (priv->header_box), 20);
  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      CLUTTER_ACTOR (priv->header_box),
                                      0, 0,
                                      "column-span", 2,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "x-fill", TRUE,
                                      "y-fill", TRUE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_START,
                                      NULL);

  priv->content_table = mx_table_new ();
  clutter_actor_set_name (priv->content_table, "people-panel-content-box");
  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      CLUTTER_ACTOR (priv->content_table),
                                      1, 0,
                                      "x-expand", TRUE,
                                      "y-expand", TRUE,
                                      "x-fill", TRUE,
                                      "y-fill", TRUE,
                                      NULL);

  priv->side_table = mx_table_new ();
  clutter_actor_set_width (priv->side_table, 288);
  clutter_actor_set_name (priv->side_table, "people-panel-side-box");
  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      CLUTTER_ACTOR (priv->side_table),
                                      1, 1,
                                      "x-expand", FALSE,
                                      "y-expand", TRUE,
                                      "x-fill", TRUE,
                                      "y-fill", TRUE,
                                      NULL);


  /* Populate header */
  label = mx_label_new_with_text (_("People"));
  mx_table_add_actor_with_properties (MX_TABLE (priv->header_box),
                                      CLUTTER_ACTOR (label),
                                      0, 0,
                                      "x-expand", FALSE,
                                      "y-expand", FALSE,
                                      "x-fill", FALSE,
                                      "y-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      NULL);
  clutter_actor_set_name (label, "people-panel-header-label");

  /* Main body table */

  bin = mx_frame_new ();
  clutter_actor_set_name (bin, "people-panel-content-header");
  label = mx_label_new_with_text (_("Me and my people"));
  clutter_actor_set_name (label, "people-panel-content-header-label");
  mx_bin_set_child (MX_BIN (bin), label);
  mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE);
  mx_table_add_actor_with_properties (MX_TABLE (priv->content_table),
                                      CLUTTER_ACTOR (bin),
                                      0, 0,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "x-fill", TRUE,
                                      "y-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      NULL);

  /* Me table containing avatar, name and presence chooser */
  priv->me_table = mx_table_new ();

  mx_table_set_column_spacing (MX_TABLE (priv->me_table), 16);
  mx_table_set_row_spacing (MX_TABLE (priv->me_table), 8);

  clutter_actor_set_name (priv->me_table, "people-panel-me-box");

  priv->avatar = anerley_tp_user_avatar_new ();
  bin = mx_frame_new ();
  clutter_actor_set_name (bin, "people-panel-me-avatar-frame");
  mx_bin_set_child (MX_BIN (bin), priv->avatar);
  clutter_actor_set_size (priv->avatar, 48, 48);
  mx_bin_set_fill (MX_BIN (bin), TRUE, TRUE);
  mx_table_add_actor_with_properties (MX_TABLE (priv->me_table),
                                      bin,
                                      0, 0,
                                      "row-span", 2,
                                      "x-expand", FALSE,
                                      "y-expand", TRUE,
                                      "x-fill", FALSE,
                                      "y-fill", FALSE,
                                      NULL);
  label = mx_label_new_with_text (_("Me"));
  clutter_actor_set_name (label, "people-panel-me-label");
  mx_table_add_actor_with_properties (MX_TABLE (priv->me_table),
                                      label,
                                      0, 1,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      NULL);
  priv->presence_chooser = anerley_presence_chooser_new ();
  mx_table_add_actor_with_properties (MX_TABLE (priv->me_table),
                                      priv->presence_chooser,
                                      1, 1,
                                      "x-expand", TRUE,
                                      "x-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      "y-expand", TRUE,
                                      "y-fill", TRUE,
                                      NULL);

  settings_launcher = _make_settings_launcher (self);
  mx_table_add_actor_with_properties (MX_TABLE (priv->me_table),
                                      settings_launcher,
                                      0, 2,
                                      "x-expand", TRUE,
                                      "x-fill", FALSE,
                                      "x-align", MX_ALIGN_END,
                                      "y-expand", TRUE,
                                      "y-fill", FALSE,
                                      "row-span", 2,
                                      NULL);

  mx_table_add_actor_with_properties (MX_TABLE (priv->content_table),
                                      CLUTTER_ACTOR (priv->me_table),
                                      1, 0,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "x-fill", TRUE,
                                      "y-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      NULL);

  priv->tp_feed = anerley_aggregate_tp_feed_new ();

  priv->model = (AnerleyFeedModel *)anerley_feed_model_new (priv->tp_feed);
  priv->tile_view = anerley_tile_view_new (priv->model);

  priv->main_scroll_view = mx_scroll_view_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (priv->main_scroll_view),
                               priv->tile_view);

  mx_table_add_actor (MX_TABLE (priv->content_table),
                      priv->main_scroll_view,
                      2,
                      0);

  /* No people && no accounts enabled */
  priv->no_people_tile = _make_empty_people_tile (self);
  clutter_actor_hide (priv->no_people_tile);

  mx_table_add_actor_with_properties (MX_TABLE (priv->content_table),
                                      priv->no_people_tile,
                                      1, 0,
                                      "x-fill", TRUE,
                                      "x-expand", TRUE,
                                      "y-expand", TRUE,
                                      "y-fill", TRUE,
                                      NULL);

  /* No people && acounts are online */
  priv->everybody_offline_tile = _make_everybody_offline_tile (self);
  clutter_actor_hide (priv->everybody_offline_tile);

  mx_table_add_actor_with_properties (MX_TABLE (priv->content_table),
                                      priv->everybody_offline_tile,
                                      2, 0,
                                      "x-fill", TRUE,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "y-fill", FALSE,
                                      "y-align", MX_ALIGN_START,
                                      "row-span", 1,
                                      NULL);

  priv->offline_banner =
    _make_offline_banner (self,
                          clutter_actor_get_width (priv->main_scroll_view));
  clutter_actor_hide (priv->offline_banner);
  mx_table_add_actor_with_properties (MX_TABLE (priv->content_table),
                                      priv->offline_banner,
                                      2, 0,
                                      "x-fill", TRUE,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "y-fill", FALSE,
                                      "y-align", MX_ALIGN_START,
                                      "row-span", 1,
                                      NULL);

  /* Side table */
  label = mx_label_new_with_text (_("My conversations"));
  clutter_actor_set_name (label, "people-panel-side-box-header-label");
  bin = mx_frame_new ();
  clutter_actor_set_name (bin, "people-panel-side-box-header");
  mx_bin_set_child (MX_BIN (bin), label);
  mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE);
  mx_table_add_actor_with_properties (MX_TABLE (priv->side_table),
                                      CLUTTER_ACTOR (bin),
                                      0, 0,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "x-fill", TRUE,
                                      "y-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      NULL);
  mx_table_add_actor_with_properties (MX_TABLE (priv->side_table),
                                      _make_messenger_launcher_tile (self),
                                      1, 0,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "x-fill", TRUE,
                                      "y-fill", FALSE,
                                      NULL);


  active_feed = anerley_tp_monitor_feed_new ((AnerleyAggregateTpFeed *)priv->tp_feed,
                                             "MeegoPanelPeople");
  priv->active_model = (AnerleyFeedModel *)anerley_feed_model_new (active_feed);


  priv->active_list_view = anerley_compact_tile_view_new (priv->active_model);
  scroll_view = mx_scroll_view_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view),
                               priv->active_list_view);

  /* active conversations */
  priv->active_content_table = mx_table_new ();
  clutter_actor_set_name (priv->active_content_table,
                          "people-panel-active-content-box");

  bin = mx_frame_new ();
  clutter_actor_set_name (bin, "people-panel-active-content-header");
  label = mx_label_new_with_text (_("You are chatting with:"));
  clutter_actor_set_name (label, "people-panel-active-content-header-label");
  tmp_text = mx_label_get_clutter_text (MX_LABEL (label));
  clutter_text_set_ellipsize (CLUTTER_TEXT(tmp_text), PANGO_ELLIPSIZE_NONE);
  mx_bin_set_child (MX_BIN (bin), label);
  mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE);
  mx_bin_set_fill (MX_BIN (bin), TRUE, TRUE);

  mx_table_add_actor_with_properties (MX_TABLE (priv->active_content_table),
                                      bin,
                                      0, 0,
                                      "y-expand", FALSE,
                                      NULL);


  mx_table_add_actor (MX_TABLE (priv->active_content_table),
                      scroll_view,
                      1, 0);

  mx_table_add_actor_with_properties (MX_TABLE (priv->side_table),
                                      priv->active_content_table,
                                      2, 0,
                                      "x-expand", TRUE,
                                      NULL);



  g_signal_connect (priv->tile_view,
                    "item-activated",
                    (GCallback)_tile_view_item_activated_cb,
                    self);

  g_signal_connect (priv->active_list_view,
                    "item-activated",
                    (GCallback)_tile_view_item_activated_cb,
                    self);


  g_signal_connect (priv->model,
                    "bulk-change-end",
                    (GCallback)_model_bulk_changed_end_cb,
                    self);
  g_signal_connect (priv->active_model,
                    "bulk-change-end",
                    (GCallback)_active_model_bulk_change_end_cb,
                    self);
  clutter_actor_hide ((ClutterActor *)priv->main_scroll_view);

  /* Placeholder changes based on onlineness or not */
  _update_placeholder_state (self);

  g_signal_connect (priv->tp_feed,
                    "notify::accounts-online",
                    (GCallback)_tp_feed_online_notify_cb,
                    self);
  g_signal_connect (priv->tp_feed,
                    "notify::accounts-available",
                    (GCallback)_tp_feed_available_notify_cb,
                    self);

  sw_online_add_notify (_online_notify_cb, self);
  _update_online_state (self, sw_is_online ());
}
static void
mnb_people_panel_init (MnbPeoplePanel *self)
{
  MnbPeoplePanelPrivate *priv = GET_PRIVATE (self);
  ClutterActor *label;
  ClutterActor *scroll_view, *scroll_bin, *bin, *tmp_text;
  AnerleyFeed *active_feed;

  mx_table_set_column_spacing (MX_TABLE (self), 4);
  mx_table_set_row_spacing (MX_TABLE (self), 6);
  clutter_actor_set_name (CLUTTER_ACTOR (self), "people-vbox");

  priv->header_box = mx_table_new ();
  clutter_actor_set_name (CLUTTER_ACTOR (priv->header_box), "people-search");
  mx_table_set_column_spacing (MX_TABLE (priv->header_box), 20);
  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      CLUTTER_ACTOR (priv->header_box),
                                      0, 0,
                                      "row-span", 1,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "x-fill", TRUE,
                                      "y-fill", TRUE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_START,
                                      NULL);

  label = mx_label_new_with_text (_("People"));
  clutter_actor_set_name (CLUTTER_ACTOR (label), "people-search-label");
  mx_table_add_actor_with_properties (MX_TABLE (priv->header_box),
                                      CLUTTER_ACTOR (label),
                                      0, 0,
                                      "x-expand", FALSE,
                                      "y-expand", FALSE,
                                      "x-fill", FALSE,
                                      "y-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      NULL);

  priv->entry = (ClutterActor *) mpl_entry_new (_("Search"));
  clutter_actor_set_name (CLUTTER_ACTOR (priv->entry), "people-search-entry");
  clutter_actor_set_width (CLUTTER_ACTOR (priv->entry), 600);
  mx_table_add_actor_with_properties (MX_TABLE (priv->header_box),
                                      CLUTTER_ACTOR (priv->entry),
                                      0, 1,
                                      "x-expand", FALSE,
                                      "y-expand", FALSE,
                                      "x-fill", FALSE,
                                      "y-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      NULL);
  priv->presence_chooser = anerley_presence_chooser_new ();
  mx_table_add_actor_with_properties (MX_TABLE (priv->header_box),
                                      priv->presence_chooser,
                                      0, 2,
                                      "x-expand", TRUE,
                                      "x-fill", FALSE,
                                      "x-align", MX_ALIGN_END,
                                      "y-expand", TRUE,
                                      "y-fill", TRUE,
                                      NULL);
  g_signal_connect (priv->entry,
                    "text-changed",
                    (GCallback)_entry_text_changed_cb,
                    self);

  priv->tp_feed = anerley_aggregate_tp_feed_new ();

  priv->model = (AnerleyFeedModel *)anerley_feed_model_new (priv->tp_feed);
  priv->tile_view = anerley_tile_view_new (priv->model);

  active_feed = anerley_tp_monitor_feed_new ((AnerleyAggregateTpFeed *)priv->tp_feed,
                                             "MeegoPanelPeople");
  priv->active_model = (AnerleyFeedModel *)anerley_feed_model_new (active_feed);

  priv->active_list_view = anerley_compact_tile_view_new (priv->active_model);
  scroll_view = mx_scroll_view_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view),
                               priv->active_list_view);
  priv->content_table = mx_table_new ();
  clutter_actor_set_name (priv->content_table, "content-table");

  /* active conversations */
  priv->active_content_table = mx_table_new ();

  clutter_actor_hide (priv->active_content_table);
  clutter_actor_set_name (priv->active_content_table, "active-content-table");

  bin = mx_frame_new ();
  label = mx_label_new_with_text (_("You are chatting with:"));
  tmp_text = mx_label_get_clutter_text (MX_LABEL (label));
  clutter_text_set_ellipsize (CLUTTER_TEXT(tmp_text), PANGO_ELLIPSIZE_NONE);
  clutter_actor_set_name (label, "active-content-header-label");
  mx_bin_set_child (MX_BIN (bin), label);
  mx_bin_set_alignment (MX_BIN (bin), MX_ALIGN_START, MX_ALIGN_MIDDLE);
  mx_bin_set_fill (MX_BIN (bin), TRUE, TRUE);
  clutter_actor_set_name (bin, "active-content-header");

  mx_table_add_actor_with_properties (MX_TABLE (priv->active_content_table),
                                      bin,
                                      0, 0,
                                      "y-expand", FALSE,
                                      NULL);

  mx_table_add_actor (MX_TABLE (priv->active_content_table),
                      scroll_view,
                      1, 0);

  mx_table_add_actor_with_properties (MX_TABLE (priv->content_table),
                                      priv->active_content_table,
                                      0, 1,
                                      "x-expand", FALSE,
                                      NULL);


  /* main area */
  scroll_view = mx_scroll_view_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll_view),
                               priv->tile_view);

  scroll_bin = mx_table_new ();
  mx_table_add_actor (MX_TABLE (scroll_bin),
                      scroll_view,
                      0,
                      0);
  mx_table_add_actor (MX_TABLE (priv->content_table),
                      scroll_bin,
                      0,
                      0);
  clutter_actor_set_name (scroll_bin, "people-scroll-bin");


  /* No people && no accounts enabled */
  priv->no_people_tile = _make_empty_people_tile (self);

  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      priv->no_people_tile,
                                      1, 0,
                                      "x-fill", TRUE,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "y-fill", FALSE,
                                      "y-align", MX_ALIGN_START,
                                      "row-span", 1,
                                      NULL);

  /* No people && acounts are online */
  priv->everybody_offline_tile = _make_everybody_offline_tile (self);
  clutter_actor_hide (priv->everybody_offline_tile);

  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      priv->everybody_offline_tile,
                                      1, 0,
                                      "x-fill", TRUE,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "y-fill", FALSE,
                                      "y-align", MX_ALIGN_START,
                                      "row-span", 1,
                                      NULL);

  priv->offline_banner =
    _make_offline_banner (self,
                          clutter_actor_get_width (scroll_view));
  clutter_actor_hide (priv->offline_banner);
  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      priv->offline_banner,
                                      1, 0,
                                      "x-fill", TRUE,
                                      "x-expand", TRUE,
                                      "y-expand", FALSE,
                                      "y-fill", FALSE,
                                      "y-align", MX_ALIGN_START,
                                      "row-span", 1,
                                      NULL);

  /* Real content stuff */
  mx_table_add_actor_with_properties (MX_TABLE (self),
                                      priv->content_table,
                                      2, 0,
                                      "x-fill", TRUE,
                                      "x-expand", TRUE,
                                      "y-expand", TRUE,
                                      "y-fill", TRUE,
                                      "row-span", 1,
                                      NULL);

  g_signal_connect (priv->tile_view,
                    "item-activated",
                    (GCallback)_tile_view_item_activated_cb,
                    self);

  g_signal_connect (priv->active_list_view,
                    "item-activated",
                    (GCallback)_tile_view_item_activated_cb,
                    self);

  /* Put into the no people state */
  clutter_actor_hide ((ClutterActor *)priv->content_table);

  g_signal_connect (priv->model,
                    "bulk-change-end",
                    (GCallback)_model_bulk_changed_end_cb,
                    self);
  g_signal_connect (priv->active_model,
                    "bulk-change-end",
                    (GCallback)_active_model_bulk_change_end_cb,
                    self);

  /* Placeholder changes based on onlineness or not */
  _update_placeholder_state (self);

  g_signal_connect (priv->tp_feed,
                    "notify::accounts-online",
                    (GCallback)_tp_feed_online_notify_cb,
                    self);
  g_signal_connect (priv->tp_feed,
                    "notify::accounts-available",
                    (GCallback)_tp_feed_available_notify_cb,
                    self);

  sw_online_add_notify (_online_notify_cb, self);
  _update_online_state (self, sw_is_online ());
}
Ejemplo n.º 12
0
static gboolean
_create_settings_dialog (MexInfoBar *self)
{
  MexInfoBarPrivate *priv = self->priv;

  ClutterActor *dialog, *network_graphic;
  ClutterActor *network_tile, *dialog_layout, *dialog_label;
  ClutterActor *network_button;

  MxAction *close_dialog, *network_settings;

  dialog = mx_dialog_new ();
  mx_stylable_set_style_class (MX_STYLABLE (dialog), "MexInfoBarDialog");

  dialog_label = mx_label_new_with_text (_("Settings"));
  mx_stylable_set_style_class (MX_STYLABLE (dialog_label), "DialogHeader");

  /* Create actions for settings dialog */
  network_settings =
    _action_new_from_desktop_file ("mex-networks.desktop");

  close_dialog = mx_action_new_full ("close", _("Close"),
                                     G_CALLBACK (_close_dialog_cb), self);

  dialog_layout = mx_table_new ();
  mx_table_set_column_spacing (MX_TABLE (dialog_layout), 10);
  mx_table_set_row_spacing (MX_TABLE (dialog_layout), 30);

  mx_table_add_actor (MX_TABLE (dialog_layout),
                      CLUTTER_ACTOR (dialog_label), 0, 0);

  if (network_settings)
    {
      gchar *tmp;
      network_graphic = mx_image_new ();
      mx_stylable_set_style_class (MX_STYLABLE (network_graphic),
                                   "NetworkGraphic");

      tmp = g_build_filename (mex_get_data_dir (), "style",
                              "graphic-network.png", NULL);
      mx_image_set_from_file (MX_IMAGE (network_graphic), tmp, NULL);
      g_free (tmp);

      network_tile = mex_tile_new ();
      mex_tile_set_label (MEX_TILE (network_tile), _("Network"));
      mex_tile_set_important (MEX_TILE (network_tile), TRUE);

      network_button = mx_button_new ();

      mx_button_set_action (MX_BUTTON (network_button), network_settings);

      mx_bin_set_child (MX_BIN (network_tile), network_button);
      mx_bin_set_child (MX_BIN (network_button), network_graphic);

      mx_table_add_actor (MX_TABLE (dialog_layout),
                          CLUTTER_ACTOR (network_tile), 1, 1);
    }

  if (!network_settings)
    {
      ClutterActor *no_settings;
      no_settings = mx_label_new_with_text (_("No settings helpers installed"));

      clutter_actor_destroy (priv->settings_button);

      mx_table_add_actor (MX_TABLE (dialog_layout),
                          CLUTTER_ACTOR (no_settings), 1, 0);
    }


  clutter_container_add_actor (CLUTTER_CONTAINER (dialog), dialog_layout);
  mx_dialog_add_action (MX_DIALOG (dialog), close_dialog);

  priv->settings_dialog = g_object_ref (dialog);

  return TRUE;
}
static void
mnb_home_new_widget_dialog_init (MnbHomeNewWidgetDialog *self)
{
  ClutterActor *table, *itemview;
  MnbHomeNewWidgetDialogItemFactory *factory;
  MnbHomePluginsEngine *engine;
  const GList *l;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
      MNB_TYPE_HOME_NEW_WIDGET_DIALOG, MnbHomeNewWidgetDialogPrivate);

  /* set up model and view */
  self->priv->items = clutter_list_model_new (ITEMS_N_COLUMNS,
      G_TYPE_STRING, "Module", /* ITEMS_MODULE */
      G_TYPE_STRING, "Name", /* ITEMS_NAME */
      G_TYPE_STRING, "Icon" /* ITEMS_ICON */);

  table = mx_table_new ();
  mx_bin_set_child (MX_BIN (self), table);

  factory = g_object_new (MNB_TYPE_HOME_NEW_WIDGET_DIALOG_ITEM_FACTORY, NULL);
  factory->dialog = self;

  itemview = mx_item_view_new ();
  mx_table_add_actor (MX_TABLE (table), itemview, 0, 1);
  mx_item_view_set_model (MX_ITEM_VIEW (itemview), self->priv->items);
  mx_item_view_set_factory (MX_ITEM_VIEW (itemview), MX_ITEM_FACTORY (factory));

  mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "module", ITEMS_MODULE);
  mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "label", ITEMS_NAME);
  mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "icon", ITEMS_ICON);

  clutter_actor_show_all (table);

  /* find plugins */
  /* FIXME: should we monitor for new plugins on the fly? */
  engine = mnb_home_plugins_engine_dup ();

  for (l = peas_engine_get_plugin_list (PEAS_ENGINE (engine));
       l != NULL;
       l = g_list_next (l))
    {
      PeasPluginInfo *info = l->data;
      char *icon;

      if (!peas_plugin_info_is_available (info, NULL))
        continue;

      icon = g_build_filename (
          peas_plugin_info_get_module_dir (info),
          peas_plugin_info_get_icon_name (info),
          NULL);

      clutter_model_append (self->priv->items,
          ITEMS_MODULE, peas_plugin_info_get_module_name (info),
          ITEMS_NAME, peas_plugin_info_get_name (info),
          ITEMS_ICON, icon,
          -1);

      g_free (icon);
    }

  /* add actions */
  mx_dialog_add_action (MX_DIALOG (self),
      mx_action_new_full ("cancel", _("Cancel"),
        G_CALLBACK (home_new_widget_dialog_cancel),
        self));

  g_object_unref (engine);
  g_object_unref (factory);
}