Exemple #1
0
static void _darkroom_ui_apply_style_popupmenu(GtkWidget *w, gpointer user_data)
{
  /* show styles popup menu */
  GList *styles = dt_styles_get_list("");
  GtkWidget *menu = NULL;
  if(styles)
  {
    menu= gtk_menu_new();
    do
    {
      dt_style_t *style=(dt_style_t *)styles->data;
      GtkWidget *mi=gtk_menu_item_new_with_label(style->name);

      char* items_string = dt_styles_get_item_list_as_string(style->name);
      gchar* tooltip = NULL;

      if((style->description) && strlen(style->description))
      {
        tooltip = g_strconcat("<b><i>", style->description, "</i></b>\n", items_string, NULL);
      }
      else
      {
        tooltip = g_strdup(items_string);
      }

      gtk_widget_set_tooltip_markup(mi, tooltip);

      gtk_menu_append (GTK_MENU (menu), mi);
      gtk_signal_connect_object (GTK_OBJECT (mi), "activate",
                                 GTK_SIGNAL_FUNC (_darkroom_ui_apply_style_activate_callback),
                                 (gpointer) g_strdup (style->name));
      gtk_widget_show (mi);

      g_free(style->name);
      g_free(style->description);
      g_free(style);
      g_free(items_string);
      g_free(tooltip);
    }
    while ((styles=g_list_next(styles))!=NULL);
  }

  /* if we got any styles, lets popup menu for selection */
  if (menu)
  {
    gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL,
                    0, 0);
  }
  else dt_control_log(_("no styles have been created yet"));
}
Exemple #2
0
static void _gui_styles_update_view( dt_lib_styles_t *d)
{
    /* clear current list */
    GtkTreeIter iter;
    GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(d->list));
    g_object_ref(model);
    gtk_tree_view_set_model(GTK_TREE_VIEW(d->list), NULL);
    gtk_list_store_clear(GTK_LIST_STORE(model));

    GList *result = dt_styles_get_list(gtk_entry_get_text(d->entry));
    if (result)
    {
        do
        {
            dt_style_t *style = (dt_style_t *)result->data;

            char* items_string = dt_styles_get_item_list_as_string (style->name);
            gchar* tooltip = NULL;

            if((style->description) && strlen (style->description))
            {
                tooltip = g_strconcat("<b><i>", style->description, "</i></b>\n", items_string, NULL);
            }
            else
            {
                tooltip = g_strdup(items_string);
            }

            gtk_list_store_append (GTK_LIST_STORE(model), &iter);
            gtk_list_store_set (GTK_LIST_STORE(model), &iter,
                                DT_STYLES_COL_NAME, style->name,
                                DT_STYLES_COL_TOOLTIP, tooltip,
                                -1);

            g_free(style->name);
            g_free(style->description);
            g_free(style);
            g_free(items_string);
            g_free(tooltip);
        }
        while ((result=g_list_next(result))!=NULL);
    }

    gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(d->list), DT_STYLES_COL_TOOLTIP);
    gtk_tree_view_set_model(GTK_TREE_VIEW(d->list), model);
    g_object_unref(model);

}