[Glade-users] Changing Text Size



This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C34026.349C4FA0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Add the font name to fload gchar. Use fontsel for the same.

Regds,
Ishan

void
apply_font_to_widget (GtkWidget *widget, gchar *fload)
{
    GtkStyle *style = gtk_style_new();
    gdk_font_unref(style->font);
    style->font = gdk_font_load(fload);
    gtk_widget_set_style(GTK_WIDGET(widget), style);
}


----- Original Message ----- 
From: "Henry Granados" <granados73 hotmail com>
To: <glade-users lists ximian com>
Sent: Tuesday, July 08, 2003 11:39 PM
Subject: [Glade-users] Changing Text Size


Currently I am using Glade very extensively to build basic user
applications for our predominantly Linux environment.  I am using Glade
1.1.3.  I have had a lot of success using Glade.  The one thing that I
cannot be able to do so far is change the text size on labels, buttons,
etc.  Is there on option on the Glade panels to change text or font
size?  If not can you direct me to finding the proper code for "C" to be
able to change font or text size?  Thank you for your time.

Henry Granados

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

_______________________________________________
Glade-users maillist  -  Glade-users lists ximian com
http://lists.ximian.com/mailman/listinfo/glade-users


------=_NextPart_000_000B_01C34026.349C4FA0
Content-Type: application/octet-stream;
        name="gabook.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
        filename="gabook.c"

#include <gtk/gtk.h>
#include <stdio.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "myheader.h"

#ifdef WIN32
#       include "windows.h"
#   include <dirent.h>
#endif


#include <glib.h>
#include <direct.h>


#define BUFFER_SIZE 8192


void Color_Widget_bg (int r, int g, int b, GtkWidget *widget)
{
    GdkColor color =3D { 0, r, g, b };
    GtkRcStyle *rc_style =3D gtk_rc_style_new ();

    rc_style->bg[GTK_STATE_NORMAL] =3D color;
    rc_style->color_flags[GTK_STATE_NORMAL] |=3D GTK_RC_BG;
    gtk_widget_modify_style (widget, rc_style);
    gtk_rc_style_unref (rc_style);
}


void Color_Widget_fg (int r, int g, int b, GtkWidget *widget)
{
    GdkColor color =3D { 0, r, g, b };
    GtkRcStyle *rc_style =3D gtk_rc_style_new ();

    rc_style->fg[GTK_STATE_NORMAL] =3D color;
    rc_style->color_flags[GTK_STATE_NORMAL] |=3D GTK_RC_FG;
    gtk_widget_modify_style (widget, rc_style);
    gtk_rc_style_unref (rc_style);

}


void
Font_Widget (GtkWidget *widget, gchar *fload)
{
    GtkStyle *style =3D gtk_style_new();
    gdk_font_unref(style->font);
    style->font =3D gdk_font_load(fload);
    gtk_widget_set_style(GTK_WIDGET(widget), style);
}


void=20
menu_popup (GtkWidget *widget, GdkEvent *event)
{

    GtkMenu *menu;
    GdkEventButton *event_button;

    menu=3DGTK_MENU (widget);

    event_button =3D (GdkEventButton *) event;
    gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event_button->button, =
event_button->time);
    gtk_widget_draw_focus (GTK_WIDGET(menu));

}

gchar*
glade_util_make_absolute_path (const gchar *dir, const gchar *file)
{
  gint dir_pos, file_pos, len, root_pos =3D 0;
  gchar *path;

  g_return_val_if_fail (dir !=3D NULL, NULL);

  if (file =3D=3D NULL || file[0] =3D=3D '\0')
    return g_strdup (dir);

  if (g_path_is_absolute (file))
    return g_strdup (file);

  /* For windows if dir has a drive set, e.g. "C:\", we never delete =
that. */
#ifdef NATIVE_WIN32
  if (isalpha (dir[0]) && dir[1] =3D=3D ':' && dir[2] =3D=3D =
G_DIR_SEPARATOR)
    root_pos =3D 2;
#endif

  /* Start at last character in dir. */
  dir_pos =3D strlen (dir) - 1;

  /* First we make sure we skip any '/' at the end of dir. */
  if (dir_pos > root_pos && dir[dir_pos] =3D=3D G_DIR_SEPARATOR)
    dir_pos--;

  /* Now for each '..' in file, we step back one component in dir, and
     forward one component in file. */
  file_pos =3D 0;
  for (;;)
    {
      /* Skip './' */
      if (file[file_pos] =3D=3D '.' && file[file_pos + 1] =3D=3D =
G_DIR_SEPARATOR)
        file_pos +=3D 2;

      else if (file[file_pos] =3D=3D '.' && file[file_pos + 1] =3D=3D =
'.'
               && (file[file_pos + 2] =3D=3D G_DIR_SEPARATOR
                   || file[file_pos + 2] =3D=3D '\0'))
        {
          while (dir_pos > root_pos && dir[dir_pos] !=3D G_DIR_SEPARATOR)
            dir_pos--;
          if (dir_pos > root_pos)
            dir_pos--;

          if (file[file_pos + 2] =3D=3D G_DIR_SEPARATOR)
            file_pos +=3D 3;
          else
            file_pos +=3D 2;
        }

      else
        break;
    }

  /* Now concatenate the parts of dir and file together. */
  if (dir_pos > root_pos)
    dir_pos++;
  len =3D dir_pos + 1 + (strlen (file) - file_pos) + 1;
  path =3D g_malloc (len);=20
  strncpy (path, dir, dir_pos);
  path[dir_pos] =3D G_DIR_SEPARATOR;
  strcpy (path + dir_pos + 1, file + file_pos);
  return path;
}

gchar *Get_Filename()
{
        return "";
}

void
Tree_List_Init (GtkWidget *button, GtkWidget *statusbar, gpointer =
user_data)
{

    GtkWidget *ctree =3D lookup_widget(GTK_WIDGET(button),"ctree1");
    GtkWidget *clist1 =3D lookup_widget(GTK_WIDGET(button),"clist1");
    char *line[1];=20
    GtkCTreeNode *n2, *n3;
    char *xyz1, *xyz=3D"";=20
        gchar *data_to_be_displayed[1];
        gboolean new_entry=3DFALSE;
        FILE *config_file;
        FILE *temp;
        gchar *buffer=3D"",*char_extracted=3D"";
        gint loopvar;
        gint cat_or_file=3D0;
        gint temp_counter=3D0;

#ifndef WIN32
    int fileexists;
    FILE *fp;
#endif

    /*statusbar=3Dlookup_widget(GTK_WIDGET(button), "statusbar1");
    gtk_statusbar_push (GTK_STATUSBAR (statusbar), 1, "Welcome to =
Address Book Program.");
*/
    //gtk_clist_freeze (GTK_CLIST(ctree));

        gtk_clist_clear(GTK_CLIST(ctree));

#ifndef WIN32
    fileexists =3D g_file_exists (g_strdup_printf("%s/%s",  =
g_get_home_dir(), ".gabook/.config"));
        if (fileexists =3D=3D 0)
        {
                system(g_strdup_printf("%s/%s", "mkdir ", g_strdup_printf("%s/%s", =20
                        g_get_home_dir(), ".gabook")) );
            fp =3D fopen (g_strdup_printf("%s/%s",  g_get_home_dir(), =
".gabook/.config"), "w");
            fclose (fp);
        }
#endif
        =09

        config_file =3D fopen ("gabook.config", "r");

        for(;;)
        {
                =09
                temp_counter++;
                data_to_be_displayed[0] =3Dline[0];
                char_extracted =3D fgets(buffer, 2, config_file);
                                =09
                if(temp_counter=3D=3D1)
                        line[0] =3D g_strdup (char_extracted);
                else
                        line[0] =3D g_strdup_printf("%s%s", line[0], char_extracted);
        =09
                        if (feof(config_file))
                        break;
        =09
                if(!strcmp(char_extracted,"\n"))
                {                               =09
                        if(strcmp(line[0],"\n\n"))
                                if(!cat_or_file)
                                {=09
                                        n2 =3D gtk_ctree_insert_node (GTK_CTREE(ctree), NULL,=20
                                                NULL, data_to_be_displayed, 1, NULL, NULL, NULL, NULL, 1, 1);
                                        cat_or_file=3D1;
                                        temp_counter=3D0;
                                }
                                else
                                {
                                        gtk_ctree_node_set_row_data (GTK_CTREE(ctree), n2,=20
                                                data_to_be_displayed[0]);
                                        /* If file doesn't exist, create it */
                                        if (!if_file_exists (data_to_be_displayed[0]))
                                        {
                                                temp=3Dfopen(data_to_be_displayed[0],"w");
                                                fclose(temp);
                                        }

                                        cat_or_file=3D0;                        =09
                                }
                        else
                                temp_counter =3D 0;

                        line[0] =3D "";                 =09
                }
        }=20

        fclose(config_file);


    //gtk_clist_thaw (GTK_CLIST(ctree));
    gtk_widget_show(ctree);

    gtk_clist_set_column_auto_resize (GTK_CLIST(clist1), 1, TRUE);
    gtk_clist_set_column_auto_resize (GTK_CLIST(clist1), 0, TRUE);
    gtk_clist_set_column_auto_resize (GTK_CLIST(clist1), 4, TRUE);


g_free(line);
}

void
GetFile (GtkWidget *button, gboolean CatSelected, gchar *filename, =
/*gint last_pos,*/ gpointer user_data)
{
/* I-LL PERHAPS HAVE TO MERGE THIS FUNCTION WITHIN THE FUNCTION WHICH
 * CALLS IT (PERHAPS THE on_Save_toolbar()). THIS WAY I-LL DO NOT HAVE A =
FUNCTION
 * LIKE THIS AS SUCH.*/

    GtkWidget *text1=3Dlookup_widget (GTK_WIDGET (button), "text1");
    GtkWidget *theclist=3Dlookup_widget(GTK_WIDGET(button),"clist1");
    FILE *fp;
    gchar buffer[BUFFER_SIZE];
    gint bytes_read;

//    if (CatSelected =3D=3D FALSE) return;

    gtk_editable_delete_text (GTK_EDITABLE (text1), 0, -1);
    gtk_clist_clear(GTK_CLIST(theclist));

    fp =3D fopen (filename, "r");
    if (fp =3D=3D NULL)
       {
         gtk_text_thaw (GTK_TEXT (text1));
         return;
       }

    for (;;)
       {
        bytes_read =3D fread (buffer, sizeof (gchar), BUFFER_SIZE, fp);

        if (bytes_read > 0)
            gtk_text_insert (GTK_TEXT (text1), NULL, NULL, NULL, buffer,
                         bytes_read);

        if (bytes_read !=3D BUFFER_SIZE && (feof (fp) || ferror (fp)))
            break;
       }

    if (ferror (fp))
    {
       fclose (fp);
       gtk_editable_delete_text (GTK_EDITABLE (text1), 0, -1);
       gtk_text_thaw (GTK_TEXT (text1));
       return;
    }

    fclose (fp);
    gtk_text_thaw (GTK_TEXT (text1));

    gtk_text_set_point(GTK_TEXT (text1),gtk_text_get_length(GTK_TEXT =
(text1)));
    //last_pos=3Dgtk_text_get_length(GTK_TEXT (text1));
}


void
Save_File (GtkWidget *button, GtkWidget *statusbar, gboolean =
CatSelected, gchar *filename, gpointer user_data)
{
    GtkWidget *text1=3Dlookup_widget (GTK_WIDGET (button), "text1");
    gchar *data=3D gtk_editable_get_chars (GTK_EDITABLE (text1), 0, -1);
    FILE *fp;
    gint bytes_written, len;


    //if (CatSelected =3D=3D FALSE) return;

    fp =3D fopen (filename, "w");
    if (fp =3D=3D NULL)
      {
         g_free (data);
         return;
      }

    len =3D strlen (data);
    bytes_written =3D fwrite (data, sizeof (gchar), len, fp);
    fclose (fp);

    g_free (data);
}


void=20
Open_File (GtkWidget *button, gboolean CatSelected, /*gint last_pos,*/
                   gchar *filename, gpointer user_data)
{
     gchar *variable,*a,*b,*variable2; // *variable3, *c;
     int loopvar,loopvary, loopvarz, counter1=3D0;
     GtkWidget *text1=3Dlookup_widget(GTK_WIDGET(button),"text1");
     guint cur_pos=3Dgtk_text_get_point(GTK_TEXT(text1));
     char *strings[5];
     GtkWidget *theclist=3Dlookup_widget(GTK_WIDGET(button),"clist1");

     if(CatSelected =3D=3D FALSE) return;

     /*GetFile (GTK_WIDGET(button), user_data);*/

GetFile (button, CatSelected, filename, /*last_pos,*/ NULL);

     cur_pos=3D0; gtk_text_set_point(GTK_TEXT(text1),0);

         counter1=3DCount_Entries (text1);


    for(loopvarz=3D1;loopvarz<counter1+1;loopvarz++)
         {
          if (gtk_text_get_length(GTK_TEXT(text1))=3D=3D0) return;

          for (loopvary=3D0;loopvary<5;loopvary++)
             {
             cur_pos=3Dgtk_text_get_point(GTK_TEXT(text1));

             =
for(loopvar=3Dcur_pos;loopvar<gtk_text_get_length(GTK_TEXT(text1));loopva=
r++)
               {
                variable =3D =
gtk_editable_get_chars(GTK_EDITABLE(text1),loopvar,loopvar+1);
                a=3Dstrstr(variable,"\n");

                if (a=3D=3Dvariable)
                  {
                   =
strings[loopvary]=3Dgtk_editable_get_chars(GTK_EDITABLE(text1),cur_pos,lo=
opvar);
                   gtk_text_set_point(GTK_TEXT(text1),loopvar+1);
                   break;
                  }
=20
               }
            }


         gtk_clist_append(GTK_CLIST(theclist), strings);

         =
gtk_text_set_point(GTK_TEXT(text1),gtk_text_get_point(GTK_TEXT(text1))+1)=
;
         if =
(gtk_text_get_point(GTK_TEXT(text1))=3D=3Dgtk_text_get_length(GTK_TEXT(te=
xt1)))
             { gtk_text_set_point(GTK_TEXT(text1),0);  }
        }


    gtk_text_set_point(GTK_TEXT(text1),0);
}

gint Count_Entries (GtkWidget *text1)
{

    gint loopvar;
    gint counter1=3D0;
    gchar *b,*variable2;

            =
for(loopvar=3D2;loopvar<gtk_text_get_length(GTK_TEXT(text1));loopvar++)
        {
         variable2 =3D =
gtk_editable_get_chars(GTK_EDITABLE(text1),loopvar-1,loopvar+1);
         b=3Dstrstr(variable2,"\n\n");

        if (b=3D=3Dvariable2)
           {
                                counter1++;
           }
        }
        return counter1;

}


PrevEntry get_prev_entry (GtkWidget *text1, gint listrow)
{

        PrevEntry xyz;
        gint loopvar, counter1=3D0, pos_of_prev_entry=3D0, =
pos_of_prev_exit=3D0;
        gchar *b, *variable2;

        for(loopvar=3D2;loopvar<gtk_text_get_length(GTK_TEXT(text1));loopvar++)
        {
         variable2 =3D =
gtk_editable_get_chars(GTK_EDITABLE(text1),loopvar-1,loopvar+1);
         b=3Dstrstr(variable2,"\n\n");

        if (b=3D=3Dvariable2)
           {
           counter1++;
           if (counter1=3D=3Dlistrow)
              {
               pos_of_prev_entry=3Dloopvar+1;
              }
           if (counter1=3D=3Dlistrow+1)
              {
               pos_of_prev_exit=3Dloopvar+1;
              }
           }
        }
=09
        xyz.entry_pos =3D pos_of_prev_entry;
        xyz.exit_pos =3D pos_of_prev_exit;

        return xyz;

}


gboolean
if_file_exists (gchar *filename)
{
        FILE *file=3DNULL;

        file=3Dfopen(filename, "r");
=09
        if(file=3D=3DNULL)
                return FALSE;

        fclose(file);
        return TRUE;


}


void
gabook_message_box (const gchar *message)
{
  GtkWidget *dialog, *label, *button;

  dialog =3D gtk_dialog_new ();
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);

  label =3D gtk_label_new (message);
  gtk_misc_set_padding (GTK_MISC (label), 20, 20);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label,
                      TRUE, TRUE, 0);
  gtk_widget_show (label);

  button =3D gtk_button_new_with_label ("OK");
  gtk_widget_set_usize (button, 80, -1);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), =
button,
                      FALSE, FALSE, 14);
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_widget_grab_default (button);
  gtk_widget_grab_focus (button);
  gtk_widget_show (button);

  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                             GTK_SIGNAL_FUNC (gtk_widget_destroy),
                             GTK_OBJECT (dialog));
  gtk_widget_show (dialog);
}

------=_NextPart_000_000B_01C34026.349C4FA0--





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]