"Fossies" - the Fresh Open Source Software Archive

Member "jpilot-2_0_1/font.c" (3 Apr 2021, 2494 Bytes) of package /linux/privat/jpilot-2_0_1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "font.c" see the Fossies "Dox" file reference documentation.

    1 /* #define FONT_TEST */
    2 #ifdef FONT_TEST
    3 #endif
    4 
    5 #ifdef FONT_TEST
    6 
    7 static void SetFontRecursively2(GtkWidget *widget, gpointer data)
    8 {
    9    GtkStyle *style;
   10    char *font_desc;
   11 
   12    font_desc = (char *)data;
   13 
   14    style = gtk_widget_get_style(widget);
   15    pango_font_description_free(style->font_desc);
   16    style->font_desc = pango_font_description_from_string(font_desc);
   17    gtk_widget_set_style(widget, style);
   18    if (GTK_IS_CONTAINER(widget)) {
   19       gtk_container_foreach(GTK_CONTAINER(widget), SetFontRecursively2, font_desc);
   20    }
   21 }
   22 static void font_selection_ok(GtkWidget *w, GtkFontSelectionDialog *fs)
   23 {
   24    gchar *s = gtk_font_selection_dialog_get_font_name(fs);
   25 
   26 
   27    SetFontRecursively2(window, s);
   28 
   29    g_free(s);
   30    gtk_widget_destroy(GTK_WIDGET(fs));
   31    cb_app_button(NULL, GINT_TO_POINTER(REDRAW));
   32 }
   33 
   34 static void font_sel_dialog()
   35 {
   36    static GtkWidget *fontsel = NULL;
   37 
   38    if (!fontsel) {
   39       fontsel = gtk_font_selection_dialog_new(_("Font Selection Dialog"));
   40       gtk_window_set_position(GTK_WINDOW(fontsel), GTK_WIN_POS_MOUSE);
   41 
   42       g_signal_connect(G_OBJECT(fontsel), "destroy",
   43                          G_CALLBACK(gtk_widget_destroyed),
   44                          &fontsel);
   45 
   46       gtk_window_set_modal(GTK_WINDOW(fontsel), TRUE);
   47 
   48       g_signal_connect(G_OBJECT(GTK_FONT_SELECTION_DIALOG(fontsel)->ok_button),
   49                          "clicked", G_CALLBACK(font_selection_ok),
   50                          GTK_FONT_SELECTION_DIALOG(fontsel));
   51       gtk_signal_connect_object(G_OBJECT(GTK_FONT_SELECTION_DIALOG(fontsel)->cancel_button),
   52                                 "clicked", G_CALLBACK(gtk_widget_destroy),
   53                                 G_OBJECT(fontsel));
   54      }
   55 
   56    if (!GTK_WIDGET_VISIBLE(fontsel)) {
   57       gtk_widget_show(fontsel);
   58    } else {
   59       gtk_widget_destroy(fontsel);
   60    }
   61 }
   62 
   63 static void cb_font(GtkWidget *widget, gpointer data)
   64 {
   65    font_sel_dialog();
   66 
   67    return;
   68 }
   69 #endif
   70 
   71 #ifdef FONT_TEST
   72 /*   f=gdk_fontset_load("-adobe-utopia-medium-r-normal-*-*-200-*-*-p-*-iso8859-1");
   73    f=gdk_fontset_load("-adobe-utopia-bold-i-normal-*-*-100-*-*-p-*-iso8859-2");
   74    SetFontRecursively(window, f);
   75    SetFontRecursively2(window, "Sans 14");
   76    SetFontRecursively2(menubar, "Sans 16");*/
   77 #endif
   78 
   79 #ifdef FONT_TEST
   80    /* Create "Font" button */
   81    button = gtk_button_new_with_label(_("Font"));
   82    g_signal_connect(G_OBJECT(button), "clicked",
   83                       G_CALLBACK(cb_font), NULL);
   84 
   85    gtk_box_pack_start(GTK_BOX(g_vbox0), button, FALSE, FALSE, 0);
   86 #endif