2014-05-11

Incomplete Documentation and examples

OK, is it lazyness?

Lack of knowledge?

A cruel streak?

I am finding lately that developers and those who
write tutorials, example code and books, do a very
poor job of complete examples.

Why?

For example: I am working on a project in which
I am trying to use GtkIconFactory, not bad in and
of itself, but the sample code I have seen takes
you to the point where you can get the menubar
visible, but no one (and I mean NO ONE) who
writes example code either on the net, or in books,
shows you how to actually take it to the next step
and make those really pretty buttons you just
created actually do something, at least without
segfaulting....

Bah

ではまた

2014-05-02

Wow - 8 Months

8 months since my last post - busy times.
Got a few things planned and up my sleeve.
---

1) Got a small programming project going on
2) Got a complex software installation happening - which I want
    to make a how-to for, as none of the how-to's for this package
    are terribly complete.

Stay tuned. ;)

ではまた
2013-09-19

Programming - part 1: Gtktables

After not having blogged for months (and being embarrassed after
the large number of blogs from last year) I decided to blog again,
And I also decided, after not having done so in a serious (more or less)
manner for several years, to work on a programming project,
and maybe actually get it doing what I wanted to, in other words, finish it.

I am a Linux geek, so I am using the Gnome and Gtk
libraries to create my masterpiece ( :) ).

I program in c mostly, when I am programming
large projects.

One of the problems I ran accross was understanding tables.

Consider this actual c source code:

GtkWidget * table;

table = gtk_table_new(5,3,FALSE);

This is easy enough to understand: in simple terms, make a table called
(strangely enough) table. It is to be 5 rows high and 3 columns wide,
the "FALSE" indicates that it is to be "not homogeneous" (cells won't
have their size set by the size of the largest element contained in the
table).

Easy

BUT

The table documentation and all the tutorials I could find (two tutorials)
were driving me batty. Determining how to place widgets/text/whatever
in specific cells was, confusing, to say the least.

Here is an example attach command:

gtk_table_attach(GTK_TABLE(table),label,1,2,1,2,GTK_FILL,
                                                                    GTK_FILL,0,0);

OK - what did it mean??

First of all, the gtk_table_attach command places an item in a table cell.

Here is how the docs described it:

void                gtk_table_attach      (GtkTable *table,
                                           GtkWidget *child,
                                           guint left_attach,
                                           guint right_attach,
                                           guint top_attach,
                                           guint bottom_attach,
                                           GtkAttachOptions xoptions,
                                           GtkAttachOptions yoptions,
                                           guint xpadding,
                                           guint ypadding);


The docs followed with a simple example:

To make a button occupy the lower right cell of a 2x2 table, use

1 
2 
3 
4 
5 
gtk_table_attach (table, button,
                  1, 2, // left, right attach
                  1, 2, // top, bottom attach
                  xoptions, yoptions,
                  xpadding, ypadding);
 

HUH???

To my tired mind, the instructions were a little hazy.

The actual confusing bits were: 

guint left_attach,
guint right_attach,
guint top_attach,
guint bottom_attach,

For anyone else running into this, here is how I eventually came to
understand it. Consider this table:

3 columns wide.
5 rows high.
Notice, I have placed a
number at the end of each
dividing line, both vertically
and horizontally.


With example placements in each cell. (Tables in gtk are
always numbered starting at zero.)

Notice the repeating number patterns?

So, taking the number in the first cell on the top left as an example,
the first digit (0) represents the first vertical line on the left side of
the cell. The second digit (1) represents the first vertical line on the
right side of the cell.

OK so far?

The third digit (0) represents the line on the top of the cell.
The fourth digit (1) represents the line on the bottom of the cell.

Therefore this:

gtk_table_attach(GTK_TABLE(table),label,1,2,1,2,GTK_FILL,
                                                                    GTK_FILL,0,0);

means place a label into the table cell second from the left and second from
the top. To place an object (widget/text/whatever) in the very first cell
top row, top left the attach command would look like this:

gtk_table_attach(GTK_TABLE(table),label,0,1,0,1,GTK_FILL,
                                                                    GTK_FILL,0,0);

Hope that saves someone a bit of time.

じゃまた

2013-02-22

History

While I am not sure I agree with this quote
(Often attributed to Mark Twain) I certainly
find it interesting, at least:

History does not repeat itself, but it does rhyme.

じゃまた
2013-01-31

Is it Really a Diet?

OK, a friend is doing this weird thing she calls a diet,
which contains things like "Cilantro Lime Chickpea Salad"
or "Quinoa Spinach Breakfast Bars" this sounds more like
a yuppie coffee bar menu than a diet to me, I am sure
there is lots of strange stuff to enjoy, and while margarine
may not be healthy, it's the only realistic alternative
for people like me, who is not only mildly gluten
intolerant but very lactose intolerant, so don't bother
suggesting butter to me, AT ALL! I cannot eat it without
being sick for a couple of hours afterwards.

Here is a portion of a realistic diet menu:

Green salad - skip the croutons and use low-cal dressing.
back off on the spuds - especially in potato salad. 
In fact, cut back on the starch, it turns to sugar which
translates into no weight loss.
Eat your veggies, carrots (raw is good) peas, broccoli, cauliflour.
Protein - white meat or fish is best.
Fruit, no milk, no sugar on top.

Ordinary foods may seem boring, but they can
be spiced up, in a healthy fashion, without being
something off a yuppie menu which looks, sounds and
tastes totally bizarre.

Curry on the meat and rice (brown if you can stand it -
I despise brown rice in all its forms) is a good topper.

Try that.
2012-12-30

Sleep

I am finally beginning to catch up on
sleep lost during my studies this last
semester. I don't know why, but this time
around, I didn't sleep very well.
The post semester is making up for it;
the fact I am on holidays doesn't
hurt matters.

No studies

+

Holidays

=

sleep and rest.

じゃまた
2012-12-24

Christmas 2012

It's Christmas time again, the time
of year when we (well, a good number
of us) celebrate Messiah's birth.

Time to pause and take stock of where
we are, not location wise, but spiritually.

What is really important?
Not just to us, but what is important,
period. It certainly shouldn't be things,
stuff, and more stuff. In a world where
so many have so little, and so many of
us have too much, we need to take
thought at this time of year, for the
reason why Christ came in the first
place: to give... Not stuff, but himself;
for everyone, every man, woman, and
child on this ball of rock.

Think about what that means.

Merry Christmas.

 
じゃまた

2012-12-15

Why does God...

So often you hear the question being
asked:

"Why does God allow such things to happen?"

The question should really be:

"Why do we, His creation, make it happen
in disobedience to Him?"

じゃまた

Blog Archive

Contributors

CatWalker

CatWalker
CatWalker at 29