Пример #1
0
static void
apply_values (void)
{
	gchar *utf;
	grg_ctx_set_crypt_algo (gctx, tmp_pref_crypto);
	grg_ctx_set_hash_algo (gctx, tmp_pref_hash);
	grg_ctx_set_comp_algo (gctx, tmp_pref_comp);
	grg_ctx_set_comp_ratio (gctx, tmp_pref_ratio);
	g_free (grg_pref_file);
	grg_pref_file =
		g_strdup (gtk_entry_get_text (GTK_ENTRY (file_entry)));
	utf = g_filename_from_utf8 (grg_pref_file, -1, NULL, NULL, NULL);
	if (!g_file_test (utf, G_FILE_TEST_IS_REGULAR))
	{
		g_free (grg_pref_file);
		grg_pref_file = NULL;
		gtk_entry_set_text (GTK_ENTRY (file_entry), "");
	}
	g_free (utf);

	set_pref_font_string (pango_font_description_to_string
			      (pango_context_get_font_description
			       (gtk_widget_get_pango_context
				(gtk_bin_get_child (GTK_BIN (but_font))))));
	set_editor_font (grg_prefs_editor_font);

	update_saveable (GRG_SAVE_ACTIVE);
	grg_save_prefs ();
}
Пример #2
0
Glib::ustring font_factory::ConstructFontSpecification(PangoFontDescription *font)
{
    Glib::ustring pangoString;

    g_assert(font);

    if (font) {
        // Once the format for the font specification is decided, it must be
        // kept.. if it is absolutely necessary to change it, the attribute
        // it is written to needs to have a new version so the legacy files
        // can be read.

        PangoFontDescription *copy = pango_font_description_copy(font);

        pango_font_description_unset_fields (copy, PANGO_FONT_MASK_SIZE);
        char * copyAsString = pango_font_description_to_string(copy);
        pangoString = copyAsString;
        g_free(copyAsString);
        copyAsString = 0;

        pango_font_description_free(copy);

    }

    return pangoString;
}
Пример #3
0
static void
tweet_window_style_set (GtkWidget *widget,
                        GtkStyle  *old_style)
{
  TweetWindowPrivate *priv = TWEET_WINDOW (widget)->priv;
  ClutterColor active_color = { 0, };
  ClutterColor text_color = { 0, };
  ClutterColor bg_color = { 0, };
  gchar *font_name;

  tweet_widget_get_base_color (widget, GTK_STATE_SELECTED, &active_color);
  tweet_widget_get_text_color (widget, GTK_STATE_NORMAL, &text_color);
  tweet_widget_get_bg_color (widget, GTK_STATE_NORMAL, &bg_color);

  font_name = pango_font_description_to_string (widget->style->font_desc);

  tidy_stylable_set (TIDY_STYLABLE (priv->scroll),
                     "active-color", &active_color,
                     "bg-color", &bg_color,
                     NULL);
  tidy_stylable_set (TIDY_STYLABLE (priv->status_view),
                     "active-color", &active_color,
                     "bg-color", &bg_color,
                     "text-color", &text_color,
                     "font-name", font_name,
                     NULL);

  g_free (font_name);
}
Пример #4
0
gchar *
gimp_font_util_pango_font_description_to_string (const PangoFontDescription *desc)
{
  gchar       *name;
  size_t       wordlen;
  const gchar *p;

  g_return_val_if_fail (desc != NULL, NULL);

  name = pango_font_description_to_string (desc);

  p = getword (name, name + strlen (name), &wordlen);

  if (wordlen)
    {
      gchar   *end;
      gdouble  size;

      size = g_ascii_strtod (p, &end);

      if (end - p == wordlen)
        {
          gchar *new_name;

          new_name = g_strconcat (name, ",", NULL);
          g_free (name);

          name = new_name;
        }
    }

  return name;
}
Пример #5
0
static void
gimp_font_list_add_font (GimpFontList         *list,
                         PangoContext         *context,
                         PangoFontDescription *desc)
{
  gchar *name;

  if (! desc)
    return;

  name = pango_font_description_to_string (desc);

  if (g_utf8_validate (name, -1, NULL))
    {
      GimpFont *font;

      font = g_object_new (GIMP_TYPE_FONT,
                           "name",          name,
                           "pango-context", context,
                           NULL);

      gimp_container_add (GIMP_CONTAINER (list), GIMP_OBJECT (font));
      g_object_unref (font);
    }

  g_free (name);
}
Пример #6
0
static void
st_entry_style_changed (StWidget *self)
{
  StEntryPrivate *priv = ST_ENTRY_PRIV (self);
  StThemeNode *theme_node;
  ClutterColor color;
  const PangoFontDescription *font;
  gchar *font_string;
  gdouble size;

  theme_node = st_widget_get_theme_node (self);
 
  st_theme_node_get_foreground_color (theme_node, &color);
  clutter_text_set_color (CLUTTER_TEXT (priv->entry), &color);

  if (st_theme_node_lookup_length (theme_node, "caret-size", TRUE, &size))
    clutter_text_set_cursor_size (CLUTTER_TEXT (priv->entry), (int)(.5 + size));

  if (st_theme_node_lookup_color (theme_node, "caret-color", TRUE, &color))
    clutter_text_set_cursor_color (CLUTTER_TEXT (priv->entry), &color);

  if (st_theme_node_lookup_color (theme_node, "selection-background-color", TRUE, &color))
    clutter_text_set_selection_color (CLUTTER_TEXT (priv->entry), &color);

  if (st_theme_node_lookup_color (theme_node, "selected-color", TRUE, &color))
    clutter_text_set_selected_text_color (CLUTTER_TEXT (priv->entry), &color);

  font = st_theme_node_get_font (theme_node);
  font_string = pango_font_description_to_string (font);
  clutter_text_set_font_name (CLUTTER_TEXT (priv->entry), font_string);
  g_free (font_string);

  ST_WIDGET_CLASS (st_entry_parent_class)->style_changed (self);
}
Пример #7
0
G_MODULE_EXPORT void 
gw_settingswindow_sync_global_document_font_cb (GSettings *settings, gchar *KEY, gpointer data)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GwApplication *application;
    LwPreferences *preferences;
    gchar font[50];
    gchar *font2;
    gchar *text;
    PangoFontDescription *desc;

    //Initializations
    window = GW_SETTINGSWINDOW (data);
    g_return_if_fail (window != NULL);
    priv = window->priv;
    application = gw_window_get_application (GW_WINDOW (window));
    preferences = gw_application_get_preferences (application);
    lw_preferences_get_string_by_schema (preferences, font, LW_SCHEMA_GNOME_INTERFACE, LW_KEY_DOCUMENT_FONT_NAME, 50);
    desc = pango_font_description_from_string (font);
    pango_font_description_set_family (desc, "Serif");
    font2 = pango_font_description_to_string (desc);
    if (font2) text = g_strdup_printf (gettext("_Use the System Document Font (%s)"), font2);
    g_free (font2); font2 = NULL;
    pango_font_description_free (desc); desc = NULL;

    if (text != NULL) 
    {
      gtk_button_set_label (GTK_BUTTON (priv->system_font_checkbutton), text);
      g_free (text);
    }
}
/**
 * static applet config functions
 */
static void
matekbd_indicator_config_load_font (MatekbdIndicatorConfig * ind_config)
{
    ind_config->font_family =
        g_settings_get_string (ind_config->settings,
                               MATEKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY);

    if (ind_config->font_family == NULL ||
            ind_config->font_family[0] == '\0') {
        PangoFontDescription *fd = NULL;
        GtkStyle *style =
            gtk_rc_get_style_by_paths (gtk_settings_get_default (),
                                       GTK_STYLE_PATH,
                                       GTK_STYLE_PATH,
                                       GTK_TYPE_LABEL);
        if (style != NULL)
            fd = style->font_desc;
        if (fd != NULL) {
            ind_config->font_family =
                g_strdup (pango_font_description_to_string(fd));
        }
    }
    xkl_debug (150, "font: [%s]\n", ind_config->font_family);

}
Пример #9
0
gchar *get_font_name_from_widget(GtkWidget *widget) /* MUST BE FREED */
{
	GtkStyle *style;
	
	style = gtk_widget_get_style(widget);
	return pango_font_description_to_string(style->font_desc);
}
Пример #10
0
/* compose_get_font */
static char const * _compose_get_font(Compose * compose)
{
	char const * p;
	char * q;
	GtkSettings * settings;
	PangoFontDescription * desc;

	if((p = config_get(compose->config, NULL, "messages_font")) != NULL)
		return p;
	settings = gtk_settings_get_default();
	g_object_get(G_OBJECT(settings), "gtk-font-name", &q, NULL);
	if(q != NULL)
	{
		desc = pango_font_description_from_string(q);
		g_free(q);
		pango_font_description_set_family(desc, "monospace");
		q = pango_font_description_to_string(desc);
		config_set(compose->config, NULL, "messages_font", q);
		g_free(q);
		pango_font_description_free(desc);
		if((p = config_get(compose->config, NULL, "messages_font"))
				!= NULL)
			return p;
	}
	return MAILER_MESSAGES_FONT;
}
Пример #11
0
static void
run_fontsel_settings_dlg(SettingsWidget *sw) {
    GtkWidget *dlg;
    const gchar *newfont;
    gchar *oldfont;

    dlg = gtk_font_selection_dialog_new(_("Select font"));
    gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(dlg),
                                            gtk_label_get_text(GTK_LABEL(sw->widget)));

    if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK) {
        gtk_label_set_text(GTK_LABEL(sw->widget),
                           gtk_font_selection_dialog_get_font_name(
                               GTK_FONT_SELECTION_DIALOG(dlg)));
    }


    newfont = gtk_label_get_text(GTK_LABEL(sw->widget));
    oldfont = pango_font_description_to_string(
                  pango_context_get_font_description(
                      gtk_widget_get_pango_context(GTK_WIDGET(sw->data))));

    if (newfont && g_ascii_strcasecmp(oldfont, newfont) != 0) {
        string_replace(sw->conf, g_strdup(newfont));
        jam_widget_set_font(sw->widget, newfont);
        jam_widget_set_font(sw->data, newfont);
    }
    g_free(oldfont);

    gtk_widget_destroy(dlg);
}
Пример #12
0
JNIEXPORT jstring JNICALL
Java_org_gnome_pango_PangoFontDescription_pango_1font_1description_1to_1string
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	char* result;
	jstring _result;
	PangoFontDescription* self;

	// convert parameter self
	self = (PangoFontDescription*) _self;

	// call function
	result = pango_font_description_to_string(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jstring) bindings_java_newString(env, result);

	// cleanup return value
	if (result != NULL) {
		g_free(result);
	}

	// and finally
	return _result;
}
Пример #13
0
string PangoFontInfo::DescriptionName() const {
  if (!desc_) return "";
  char* desc_str = pango_font_description_to_string(desc_);
  string desc_name(desc_str);
  g_free(desc_str);
  return desc_name;
}
Пример #14
0
bool PangoFontInfo::ParseFontDescription(const PangoFontDescription *desc) {
  Clear();
  const char* family = pango_font_description_get_family(desc);
  if (!family) {
    char* desc_str = pango_font_description_to_string(desc);
    tprintf("WARNING: Could not parse family name from description: '%s'\n",
            desc_str);
    g_free(desc_str);
    return false;
  }
  family_name_ = string(family);
  desc_ = pango_font_description_copy(desc);
  is_monospace_ = IsMonospaceFontFamily(family);

  // Set font size in points
  font_size_ = pango_font_description_get_size(desc);
  if (!pango_font_description_get_size_is_absolute(desc)) {
    font_size_ /= PANGO_SCALE;
  }

  PangoStyle style = pango_font_description_get_style(desc);
  is_italic_ = (PANGO_STYLE_ITALIC == style ||
                PANGO_STYLE_OBLIQUE == style);
  is_smallcaps_ = (pango_font_description_get_variant(desc)
                   == PANGO_VARIANT_SMALL_CAPS);

  is_bold_ = (pango_font_description_get_weight(desc) >= PANGO_WEIGHT_BOLD);
  // We dont have a way to detect whether a font is of type Fraktur. The fonts
  // we currently use all have "Fraktur" in their family name, so we do a
  // fragile but functional check for that here.
  is_fraktur_ = (strcasestr(family, "Fraktur") != NULL);
  return true;
}
Пример #15
0
/**
 * he_helper_get_logical_font_desc:
 * @name: The logical font name (see he-helper.h for possible values)
 *
 * Returns a newly-allocated string that contains the string representation
 * of the Pango font description for the given logical string. This can be
 * used in the font_desc attribute of span elements in Pango markup.
 *
 * This function should be used to get the font desc for Pango markup in
 * special use cases (e.g. GtkTreeView, mixed-content GtkLabel). If you
 * want to set a logical font directly on a widget, you can use
 * #hildon_helper_set_logical_font (from Hildon 2.2) for this.
 *
 * The return value should be freed with g_free() after use.
 **/
gchar *
he_helper_get_logical_font_desc (const gchar *name)
{
    GtkSettings *settings = gtk_settings_get_default();
    GtkStyle *style = gtk_rc_get_style_by_paths(settings,
            name, NULL, G_TYPE_NONE);

    return pango_font_description_to_string(style->font_desc);
}
Пример #16
0
static void
get_font_details_from_pattern (FontConfigFont * font, FcPattern * pattern)
{
    int index;
    int slant;
    int weight;
    int width;
    int spacing;
    FcChar8 * file;
    FcChar8 * family;
    FcChar8 * style;

    g_assert(FcInit());
    g_assert(FcPatternGetString(pattern, FC_FILE, 0, &file) == FcResultMatch);
    font_config_font_set_filepath(font, (const gchar *) file);
    font_config_font_set_owner(font, get_file_owner((const gchar *) file));
    g_assert(FcPatternGetString(pattern, FC_FAMILY, 0, &family) == FcResultMatch);
    font_config_font_set_family(font, (const gchar *) family);
    if (FcPatternGetInteger(pattern, FC_INDEX, 0, &index) != FcResultMatch)
        index = 0;
    font_config_font_set_index(font, index);
    if (FcPatternGetInteger(pattern, FC_SPACING, 0, &spacing) != FcResultMatch)
        spacing = FC_PROPORTIONAL;
    font_config_font_set_spacing(font, spacing);
    if (FcPatternGetInteger(pattern, FC_SLANT, 0, &slant) != FcResultMatch)
        slant = FC_SLANT_ROMAN;
    font_config_font_set_slant(font, slant);
    if (FcPatternGetInteger(pattern, FC_WEIGHT, 0, &weight) != FcResultMatch)
        weight = FC_WEIGHT_MEDIUM;
    font_config_font_set_weight(font, weight);
    if (FcPatternGetInteger(pattern, FC_WIDTH, 0, &width) != FcResultMatch)
        width = FC_WIDTH_NORMAL;
    font_config_font_set_width(font, width);
    if (FcPatternGetString (pattern, FC_STYLE, 0, &style) != FcResultMatch) {
        /* Use the same style Pango would if none is given */
        if (weight <= FC_WEIGHT_MEDIUM) {
            if (slant == FC_SLANT_ROMAN)
                font_config_font_set_style(font, "Regular");
            else
                font_config_font_set_style(font, "Italic");
        } else {
            if (slant == FC_SLANT_ROMAN)
                font_config_font_set_style(font, "Bold");
            else
                font_config_font_set_style(font, "Bold Italic");
        }
    } else {
        font_config_font_set_style(font, (const gchar *) style);
    }

    PangoFontDescription * descr = pango_fc_font_description_from_pattern(pattern, FALSE);
    gchar * desc_string = pango_font_description_to_string(descr);
    font_config_font_set_description(font, desc_string);
    pango_font_description_free(descr);
    g_free0(desc_string);
    return;
}
Пример #17
0
static char *
font_description_value_to_string (const GValue *value)
{
  const PangoFontDescription *desc = g_value_get_boxed (value);

  if (desc == NULL)
    return g_strdup ("none");

  return pango_font_description_to_string (desc);
}
Пример #18
0
static void
gnm_font_button_update_font_data (GnmFontButton *font_button)
{
  GnmFontButtonPrivate *priv = font_button->priv;
  PangoFontFamily **families;
  PangoFontFace **faces;
  gint n_families, n_faces, i;
  const gchar *family;

  g_assert (priv->font_desc != NULL);

  priv->fontname = pango_font_description_to_string (priv->font_desc);

  family = pango_font_description_get_family (priv->font_desc);
  if (family == NULL)
    return;

  n_families = 0;
  families = NULL;
  pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (font_button)),
                               &families, &n_families);
  n_faces = 0;
  faces = NULL;
  for (i = 0; i < n_families; i++)
    {
      const gchar *name = pango_font_family_get_name (families[i]);

      if (!g_ascii_strcasecmp (name, family))
        {
          priv->font_family = g_object_ref (families[i]);

          pango_font_family_list_faces (families[i], &faces, &n_faces);
          break;
        }
    }
  g_free (families);

  for (i = 0; i < n_faces; i++)
    {
      PangoFontDescription *tmp_desc = pango_font_face_describe (faces[i]);

      if (font_description_style_equal (tmp_desc, priv->font_desc))
        {
          priv->font_face = g_object_ref (faces[i]);

          pango_font_description_free (tmp_desc);
          break;
        }
      else
        pango_font_description_free (tmp_desc);
    }

  g_free (faces);
}
Пример #19
0
void preferences_set_font (const char *key, const PangoFontDescription *font)
{
        if (font != NULL) {
                char *str;

                str = pango_font_description_to_string (font);
                preferences_set_string (key, str);
        } else {
                preferences_set_string (key, NULL);
        }
}
Пример #20
0
static void termomix_increase_font(GtkWidget *widget, void *data) {
    gint new_size;

    /* Increment font size one unit */
    new_size = pango_font_description_get_size(termomix.font) + PANGO_SCALE;

    pango_font_description_set_size(termomix.font, new_size);
    termomix_set_font();
    termomix_set_size(termomix.columns, termomix.rows);
    termomix_set_config_string("font",
            pango_font_description_to_string(termomix.font));
}
Пример #21
0
static void winfont_to_fontspec (char *spec, CHOOSEFONT *cf)
{
    PangoFontDescription *pfd;
    char *fstr;

    pfd = pango_win32_font_description_from_logfont(cf->lpLogFont);
    pango_font_description_set_size(pfd, PANGO_SCALE * cf->iPointSize / 10);
    fstr = pango_font_description_to_string(pfd);
    strcpy(spec, fstr);
    g_free(fstr);
    pango_font_description_free(pfd);
}
Пример #22
0
static gchar *
font_name (PangoFont *font)
{
  PangoFontDescription *desc;
  gchar *name;

  desc = pango_font_describe (font);
  name = pango_font_description_to_string (desc);
  pango_font_description_free (desc);

  return name;
}
Пример #23
0
static char *
mdm_get_font (const char *theme_name)
{
	char *font_name;
	char *theme_dir;
	char *file_name;
	char buf[512];
	GtkStyle *style;
	FILE *fp;

	style = gtk_widget_get_default_style ();
	font_name = pango_font_description_to_string (style->font_desc);

	theme_dir = gtk_rc_get_theme_dir ();
	file_name = g_build_filename (theme_dir, theme_name, INDEX_FILE1, NULL);
	if ( ! g_file_test (file_name, G_FILE_TEST_EXISTS)) {
		g_free (file_name);
		file_name = g_build_filename (theme_dir, theme_name, INDEX_FILE2, NULL);
		if ( ! g_file_test (file_name, G_FILE_TEST_EXISTS)) {
			g_free (theme_dir);
			g_free (file_name);
			return font_name;
		}
	} 
	g_free (theme_dir);

	/*
	 * FIXME: this is evil!
	 */
	fp = fopen (file_name, "r");
	if (fp != NULL) {
		while (fgets (buf, 512, fp) != NULL) {
			if (strncmp ("ApplicationFont", buf, 15) == 0) {
				char *tmp_name;
				tmp_name = strchr (buf, '=');

				if (tmp_name != NULL) {
					g_free (font_name);
					font_name = strdup (tmp_name + 1);
				}

				fclose (fp);
				g_free (file_name);
				return font_name;
			}
		}
		fclose (fp);
	}
	g_free (file_name);
	return font_name;
}
Пример #24
0
static void termomix_decrease_font(GtkWidget *widget, void *data) {
    gint new_size;

    /* Decrement font size one unit */
    new_size=pango_font_description_get_size(termomix.font)-PANGO_SCALE;
    
    /* Set a minimal size */
    if (new_size >= FONT_MINIMAL_SIZE ) {
        pango_font_description_set_size(termomix.font, new_size);
        termomix_set_font();
        termomix_set_size(termomix.columns, termomix.rows);    
        termomix_set_config_string("font", pango_font_description_to_string(termomix.font));
    }
}
Пример #25
0
/**
 * _st_set_text_from_style:
 * @text: Target #ClutterText
 * @theme_node: Source #StThemeNode
 *
 * Set various GObject properties of the @text object using
 * CSS information from @theme_node.
 */
void
_st_set_text_from_style (ClutterText *text,
                         StThemeNode *theme_node)
{

  ClutterColor color;
  StTextDecoration decoration;
  PangoAttrList *attribs;
  const PangoFontDescription *font;
  gchar *font_string;
  StTextAlign align;

  st_theme_node_get_foreground_color (theme_node, &color);
  clutter_text_set_color (text, &color);

  font = st_theme_node_get_font (theme_node);
  font_string = pango_font_description_to_string (font);
  clutter_text_set_font_name (text, font_string);
  g_free (font_string);

  attribs = pango_attr_list_new ();

  decoration = st_theme_node_get_text_decoration (theme_node);
  if (decoration & ST_TEXT_DECORATION_UNDERLINE)
    {
      PangoAttribute *underline = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
      pango_attr_list_insert (attribs, underline);
    }
  if (decoration & ST_TEXT_DECORATION_LINE_THROUGH)
    {
      PangoAttribute *strikethrough = pango_attr_strikethrough_new (TRUE);
      pango_attr_list_insert (attribs, strikethrough);
    }
  /* Pango doesn't have an equivalent attribute for _OVERLINE, and we deliberately
   * skip BLINK (for now...)
   */

  clutter_text_set_attributes (text, attribs);

  pango_attr_list_unref (attribs);

  align = st_theme_node_get_text_align (theme_node);
  if(align == ST_TEXT_ALIGN_JUSTIFY) {
    clutter_text_set_justify (text, TRUE);
    clutter_text_set_line_alignment (text, PANGO_ALIGN_LEFT);
  } else {
    clutter_text_set_justify (text, FALSE);
    clutter_text_set_line_alignment (text, (PangoAlignment) align);
  }
}
Пример #26
0
char* iupdrvGetSystemFont(void)
{
  static char systemfont[200] = "";
  GtkStyle* style;
  GtkWidget* widget = gtk_invisible_new();
  gtk_widget_realize(widget);
  style = gtk_widget_get_style(widget);
  if (!style || !style->font_desc)
    strcpy(systemfont, "Sans, 10");
  else
    strcpy(systemfont, pango_font_description_to_string(style->font_desc));
  gtk_widget_unrealize(widget);
  gtk_widget_destroy(widget);
  return systemfont;
}
Пример #27
0
static void
font_description_value_print (const GValue *value,
                              GString      *string)
{
  const PangoFontDescription *desc = g_value_get_boxed (value);

  if (desc == NULL)
    g_string_append (string, "none");
  else
    {
      char *s = pango_font_description_to_string (desc);
      g_string_append (string, s);
      g_free (s);
    }
}
Пример #28
0
wxString wxNativeFontInfo::ToString() const
{
    wxGtkString str(pango_font_description_to_string( description ));
    wxString desc = wxPANGO_CONV_BACK(str);

    // Augment the string with the attributes not handled by Pango.
    //
    // Notice that we must add them in the same order they are extracted in
    // FromString() above.
    if (m_strikethrough)
        desc.insert(0, wxS("strikethrough "));
    if (m_underlined)
        desc.insert(0, wxS("underlined "));

    return desc;
}
Пример #29
0
void font_factory::UnrefFace(font_instance *who)
{
    if ( who ) {
        FaceMapType& loadedFaces = *static_cast<FaceMapType*>(loadedPtr);

        if ( loadedFaces.find(who->descr) == loadedFaces.end() ) {
            // not found
            char *tc = pango_font_description_to_string(who->descr);
            g_warning("unrefFace %p=%s: failed\n",who,tc);
            g_free(tc);
        } else {
            loadedFaces.erase(loadedFaces.find(who->descr));
            //            printf("unrefFace %p: success\n",who);
        }
    }
}
Пример #30
0
/** awesome global table.
 * \param L The Lua VM state.
 * \return The number of elements pushed on stack.
 * \luastack
 * \lfield font The default font.
 * \lfield font_height The default font height.
 * \lfield conffile The configuration file which has been loaded.
 */
static int
luaA_awesome_index(lua_State *L)
{
    if(luaA_usemetatable(L, 1, 2))
        return 1;

    size_t len;
    const char *buf = luaL_checklstring(L, 2, &len);

    switch(a_tokenize(buf, len))
    {
      case A_TK_FONT:
        {
            char *font = pango_font_description_to_string(globalconf.font->desc);
            lua_pushstring(L, font);
            g_free(font);
        }
        break;
      case A_TK_FONT_HEIGHT:
        lua_pushnumber(L, globalconf.font->height);
        break;
      case A_TK_CONFFILE:
        lua_pushstring(L, globalconf.conffile);
        break;
      case A_TK_FG:
        luaA_pushxcolor(L, globalconf.colors.fg);
        break;
      case A_TK_BG:
        luaA_pushxcolor(L, globalconf.colors.bg);
        break;
      case A_TK_VERSION:
        lua_pushliteral(L, AWESOME_VERSION);
        break;
      case A_TK_RELEASE:
        lua_pushliteral(L, AWESOME_RELEASE);
        break;
      case A_TK_STARTUP_ERRORS:
        if (globalconf.startup_errors.len == 0)
            return 0;
        lua_pushstring(L, globalconf.startup_errors.s);
      default:
        return 0;
    }

    return 1;
}