Re: GTK+, WM, desktops and CSD

2015-03-05 Thread David Nečas
On Thu, Mar 05, 2015 at 10:01:44PM +0100, Olivier Fourdan wrote:
  It's a subtle difference, but it shows our preference: we don't want a hint
  to say that the DE prefers SSD, we want a hint to say that the DE can
  support/not support CSD.
 
 That would work as well, why not.

As long as I can set up my DE to pretend not to support CSD, whatever
the actual state is.  Because this is, at the end, user's preference.

  But ultimately, SSD does not lead to the types of applications and
  the types of experiences we want to create...

This is sad.  Once your mission becomes creating certain types of
experience, instead of enabling them, everything else gets destroyed,
whether the types of experience it enables are also good or not.  And
there does not seem anything capable of stopping the destructive mindset
at this moment...

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: a new combo box

2014-12-27 Thread David Nečas
On Sat, Dec 27, 2014 at 08:02:44AM -0500, Matthias Clasen wrote:
 over Christmas, I had some for a little side project, a  new combo
 box. It is based on these mockups:
 https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/theming/widgets/combobox-replacements.png
 
 ...
 
 I'm off for a few days now - would be great to hear some feedback when
 I come back.

Judging from the mockups, it eats precious vertical screen space and
goes against Fitt's law by making it necessary to move the pointer far
in order to select even an adjacent value (which, if the values are
sanely organised, is a more likely change than selecting a distant
value).

Regards,

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Custom Titlebar

2014-08-11 Thread David Nečas
On Mon, Aug 11, 2014 at 11:28:34PM +0200, Florian Müllner wrote:
 That is not quite true - since GTK 3.10, there's
 
   gtk_window_set_titlebar (GTK_WINDOW (window), titlebar_widget);

Unless you are running someting like Gnome 3(?), this will add a
strangely looking thing to the top of your window, but inside.  It will
not change the title bar which is controlled by the window manager.

I've never seen it actually do what is advertised.  Admittely, I didn't
test it much because I consider it broken by intent (not even getting to
broken by design).

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Segmentation fault in creating basic app using GTK+ (with C)

2014-07-14 Thread David Nečas
On Tue, Jul 01, 2014 at 01:39:03AM -0700, Anoop Neem wrote:
   p-one = textEntry;
   p-two = label;

Here the unititialised textEntry and label pointers are assigned to the
struct fields.

   textEntry = gtk_entry_new();
   calButton = gtk_button_new_with_label(Calculate);

And here, much laters, they are actually initialised.

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How ot remove the minimize and maximize button of GtkWindow

2014-02-21 Thread David Nečas
On Fri, Feb 21, 2014 at 03:29:07PM +0800, Wiky wrote:
  The default GtkWindow has a minimize , a maximize and a close button in the 
 right or left top coner.
 But I want a window which only has a close button. How can I remove the 
 minimize and maximize button?

You can't.  In my window manager the windows may have a completely
different set of buttons.  Or no title bar at all.  Or whatever.  And
the window manager has the last word.

You can override the decoration-button-layout style property, but you
need 3.10+ and it will only work in something like GNOME 3 anyway.

The meaningful thing you can do is setting the window type hint with
gdk_window_get_type_hint() (and possibly other hints) to specify what
the window *is* instead, and let the window manager treat it
appropriately and consistently with other widows with the same role.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to locate the 'Gtk-WARNING' line number

2014-02-17 Thread David Nečas
On Mon, Feb 17, 2014 at 04:44:53PM +0800, Wiky wrote:
  Hi,all. I'm currently writing a program based Gtk+-3.0.
 When it runs, I get '(a.out:10874): Gtk-WARNING **: Failed to ...' in the 
 terminal.
 I know the problem is about GtkLabel, but I really don't know which GtkLabel.
 Is there a way to locate the line numer that give the warning?

Run it with G_DEBUG=fatal-warnings, let it dump core and look at the
stack trace.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Populating A Combo Box With Integers In Hex

2013-12-07 Thread David Nečas
On Sat, Dec 07, 2013 at 05:54:23PM +, Tristian Celestin wrote:
 I have a GtkListStore that contains 4 columns of unsigned integers
 (G_TYPE_UINT). I would like to display the second column of integers
 in a GtkComboBoxText widget, and I would like the integers to be
 displayed in Base 12. 

I would stop here and use normal GtkComboBox with a cell data function
(gtk_cell_layout_set_cell_data_func()) such as

static void
render_base12(GtkTreeViewColumn *column,
  GtkCellRenderer *renderer,
  GtkTreeModel *model,
  GtkTreeIter *iter,
  gpointer data)
{
guint value;
gtk_tree_model_get(model, iter, 1, value, -1);
/* format the value here in base 12 */
g_object_set(renderer, text, formatted_value, NULL);
}

It may be possible to do this with GtkComboBoxText too.  I don't know.
If I want something non-default I just use the real thing instead of
studying what is and what isn't allowed with GtkComboBoxText.

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Valgrind is grinding my gears

2013-11-05 Thread David Nečas
On Tue, Nov 05, 2013 at 09:47:13AM -0800, David Buchan wrote:
 But when I invoke Valgrind at runtime, I get a lot of errors which I
 can't make any sense of.
 
 I have grabbed a small sample of them here:
 
 http://pdbuchan.com/valgrind.txt
 
 I don't like ignoring errors and warnings, but I don't know what to do
 with these.
 
 Has anybody else come across these types of Valgrind notifications?

Yes, everyone.  You must understand that all the GObject type
registration machinery is, under normal circumstances, only ever used to
create structures that will exist during the entire program lifetime.
So although things such as class reference leaks can exists, eveything
inside g_type_class_ref() should be ignorable – and you can clearly see
from the log that these allocations happen once, not a thousand times.
The same for g_thread_init(), gtk_init(), etc.  Create a suppression
file or google one...

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Signal of a button dynamically created

2013-10-28 Thread David Nečas
On Mon, Oct 28, 2013 at 04:22:38PM +0100, Borja Mon Serrano wrote:
 The point here is: how can I know what button was pressed in order to
 remove a row?

(a) by passing something that identifies the button within user_data
when you do g_signal_connect...

(b) using something along the lines of g_object_set_data(button, id, ...)
to give each button an identifier and retrieving it in the signal
handler

(c) by keeping the buttons in some data structure (list, hash table,...)
and identifying them by the object address in the signal handler

There are other methods, but these are probably typical.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: disable mouse click

2013-10-17 Thread David Nečas
On Thu, Oct 17, 2013 at 09:10:30AM +, Andrea Zagli wrote:
 i want to disable mouse click on every widget of a window when i
 change the cursor to GDK_WATCH

gtk_widget_set_sensitive(window, FALSE);

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Delaying redraws?

2013-10-06 Thread David Nečas
On Sat, Oct 05, 2013 at 08:18:58PM -0400, Rena wrote:
 I have a window with a large number of GtkEntry and GtkCheckButton
 displaying stats,

‘Displaying stats’ sounds a bit suspicious because entry and check
button are input widgets.

 Is it possible to speed
 this up, maybe by asking GTK not to redraw the widgets until I'm done
 updating them all?

Anyway, this is what happens normally.  When you change the widget
state/content a redraw is queued.  The redraws are then processed when
the Gtk+ main loops gets to run.

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Developing a widget - help with introspection and feedback

2013-10-02 Thread David Nečas
On Tue, Oct 01, 2013 at 09:08:12PM -0400, Rena wrote:
 Hi all, I'm developing my first GTK widget. I have it working OK, but I
 can't get g-ir-scanner to cooperate.

Since you don't use libtool to build the library (which I strongly
recommend against but it's your fight) pass --no-libtool to
g-ir-scanner.  It seems to work then.

Regards,

Yeti


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Invisible GtkImage

2013-06-23 Thread David Nečas
On Sat, 22 Jun 2013 15:30:34 -0700, Kip Warner wrote:
 Yes, your code is similar to what I had tried before with GtkImage,
 only you're subclassing the DrawingArea instead which is probably a
 better idea, except it still doesn't work properly either.

So how exactly does the behaviour of my simple example differ from what
you want?  The widget fills the allocated space and the image scales,
keeping the aspect ratio.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Invisible GtkImage

2013-06-23 Thread David Nečas
On Sun, Jun 23, 2013 at 11:05:00AM -0700, Kip Warner wrote:
 When the parent window is resized, I'd like the image to scale to fill
 the allocated space as much as possible, maintaining the aspect ratio.
 My code draws the image correctly, but it doesn't resize as the parent
 window is resized:
 
 http://pastebin.com/6LEzFk8A

Well, as it has already been suggested, this is a matter of packing. If
you request that the widget does not expand

page.pack_start(page._bannerAspectFrame, False, False, 0)

then the containing box will not expand the widget when it is enlarged
itself.  You have to pass expand=True, fill=True.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Invisible GtkImage

2013-06-22 Thread David Nečas
On Sat, Jun 22, 2013 at 01:09:17PM -0700, Kip Warner wrote:
 I can't believe resizing a widget in Gtk+ is this difficult.

Frankly, I don't quite understand what you are trying to achieve since
you have never posted anything runnable and your examples have never
included any actual drawing code.  Anyway, it is trivial to create a
scaleable widget (whether it draws an image or anything else):

---
from gi.repository import Gtk, GdkPixbuf, Gdk

class ScalableImage(Gtk.DrawingArea):
def __init__(self, filename):
super(ScalableImage, self).__init__()
self.pb = GdkPixbuf.Pixbuf.new_from_file(filename)

def do_get_preferred_width(self):
pw = self.pb.get_width()
return (pw, pw)

def do_get_preferred_height(self):
ph = self.pb.get_height()
return (ph, ph)

def do_draw(self, cr):
alloc = self.get_allocation()
pw, ph = self.pb.get_width(), self.pb.get_height()
aw, ah = float(alloc.width), float(alloc.height)
r = min(aw/pw, ah/ph)
cr.scale(r, r)
Gdk.cairo_set_source_pixbuf(cr, self.pb, 0.0, 0.0)
cr.paint()
return False

w = Gtk.Window(Gtk.WindowType.TOPLEVEL)
w.connect('destroy', Gtk.main_quit)

b = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
w.add(b)

b.pack_start(Gtk.Label(label='Test'), False, False, 0)
d = ScalableImage('/usr/share/icons/HighContrast/48x48/stock/gtk-ok.png')
b.pack_start(d, True, True, 0)
b.pack_start(Gtk.Label(label='Somewhat longer test'), False, False, 0)

w.show_all()

Gtk.main()
---

This might not be exactly what you need but as I noted I don't get where
the problem is...

If you need your widget to be a GtkImage subclass things will likely
turn hairy because GtkImage is not scaleable, all its methods think it
is not scaleable so you will end up fighting the implementation of the
widget.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Can I install both GTK+2 and GTK+3?

2013-05-17 Thread David Nečas
On Fri, May 17, 2013 at 11:40:10AM +0100, Emmanuele Bassi wrote:
 it's maintained only for critical bugs, or for platform support; no
 new feature, and no new API is *ever* going in to the gtk-2-24 branch.

And that's what many 3rd party developers like.  Absolutely no changes
except critical bug and platform support fixes.  All the small bugs and
peculiarities are known, are not replaced with a different set of small
bugs and peculiarities in the next release and we've learned how to work
around them.

Actually, I do target Gtk+3 with a program which has a number of its own
widgets.  And I'm constantly anxious and wondering whether it was a good
decision...

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: parsing bibtex using gscanner

2013-02-18 Thread David Nečas
On Mon, Feb 18, 2013 at 05:15:56PM +, Rudra Banerjee wrote:
 I am trying to parse a bibtex file using gscanner.
 The problem is that, due to many formats accepted by bibtex, it seems
 bit hard to parse it.
 What I mean is as long as the bibtex is of the form key=some value,
 then g_scanner_get_next_token can get the string.
 But it fails if it is in the format key={value}.

And it fails even before escaping literal TeX code using braces within
entries or string macros have come to play...

 I am attaching my code. Some help (outside using btparse/ bison )is
 needed.

Don't do it this way.  GScanner is a lexical scanner, it just tokenizes
the input but it does not help with grammar.

The best approach to parse a grammar is, you know, using a parser.

If you insist on writing one manually realise that you need to formally
keep state, eg. the nesting level of braces at which you are now, etc.
Construct the parser similarly you would if you did if you just wrote
the BNF and let the parser be generared, e.g. write subroutines to parse
balanced braces, string, etc. possibly recusrively calling each other.

Attempting to write code for all the cases that can occur using
sequences of hardcoded ifs will only result in buggy mess.  You have
been warned.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Problems with un-owned objects passed to closures in pygobject (gtk_cell_renderer_text_start_editing)

2013-02-04 Thread David Nečas
On Mon, Feb 04, 2013 at 04:44:02PM +0900, Tristan Van Berkom wrote:
 On Mon, Feb 4, 2013 at 11:39 AM, Simon Feltman s.felt...@gmail.com wrote:
 [...]
  However, it also adds a leak for the most basic (and useless) case:
  for i in range(10):
  Gtk.Button()
 
 This could arguably trigger a compiler warning, or even an error.

This is nonsense.  Since Gtk.Button() is not guaranteed *not* to have
any side effects it is perfectly valid to run it without doing anything
with the return value.

In fact, since we talk about a dynamic language, the interpreter does
not know, in general, what Gtk.Button will mean at the time the code is
actually executed.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: GTK app development for windows.

2013-01-30 Thread David Nečas
On Thu, Jan 31, 2013 at 12:32:48AM +0700, Ardhan Madras wrote:
 One thing you should know that most version of GTK+ in today Linux
 system is using version 3.x.

This is somewhat inaccurate.  All major Linux distributions contain
Gtk+3 packages and the number of Gtk+3 programs grows.  But if you look
outside core Gnome3, at third-party programs, the number of Gtk+2
programs is huge.  Some will be never ported.  After all, even though
they are quite rare nowadays, some Gtk+1 programs still have not been
ported to Gtk+2...

 I recommended you to use also GTK+ 2 in Linux, and you can build it
 with no or less efforts in Windows compared if you use GTK+ 3 in Linux
 but build it with GTK+ 2 in Windows.

For new projects, I would not recommend using Gtk+2 unless you are
quite conservative or it is a small project using only stock widgets
(in such case porting to Gtk+3 will not be a big deal).

For larger projects, it is more likely that Gtk+3 will be fine on MS
Windows and Gtk+2 obsolete everywhere when you get to releasing a stable
version...

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: open an existing file in buffer and write on it

2013-01-25 Thread David Nečas
On Fri, Jan 25, 2013 at 04:25:53PM -0500, Liam R E Quin wrote:
 That it's easier for the programmers to create and read
 application-specific binary files is a problem that would be worth
 fixing.

Probably you mean replacing it with the problem of application-specific
hodge podge XML...

I have implemented the import of ~80 data formats of varying complexity
and style to one program.  I have seen both utterly mad binary formats
and binary formats that were well thought out and pleasure to implement.
But XML was crap quite invariably.  It appears to be used as an excuse
for not thinking about data representation at all.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: edit and use treeview cell

2013-01-24 Thread David Nečas
On Thu, Jan 24, 2013 at 09:41:20AM +, Rudra Banerjee wrote:
 g_object_set(cell, editable, TRUE, NULL);
 
 but I have no idea of how to connect the edited flag to file/buffer. It
 will be very helpful if someone kindly show the way...a very short
 example may be.

Have you read the tutorial?

http://scentric.net/tutorial/sec-editable-cells.html

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Would this leak be inside gtk?

2013-01-23 Thread David Nečas
On Wed, Jan 23, 2013 at 10:41:54AM -0600, Edscott Wilson wrote:
 I conclude this is a gtk memory leak. It occurs when calling
 gtk_combo_box_new_with_entry(), Apparently, when the dialog that contains
 the combo box is destroyed, the GList visible_children in file
 gtkcombobox.c is not being cleansed of the pointer to the child widget,
 entry. The leak does not occur if plain gtk_combo_box_new() is used
 instead. Correct me if I'm wrong.

Whether gtk_combo_box_get_path_for_child() can be called with a visible
child different from those enumerated there (the only way a leak can
occur) I cannot tell.

In any case, any suspected leak that goes through GSlice should be first
reproduced with G_SLICE=always-malloc -- and you find it real, a bug
report is much better than suppression...

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: glib-mkenums in glib 2

2012-12-31 Thread David Nečas
On Mon, Dec 31, 2012 at 05:24:09PM +, John Emmas wrote:
 which should either be in gio/gioenums.h or alternatively,
 gio/gregistrysettingbackend.h.  It's the absence of this enum that's
 causing 'g_registry_backend_get_type()' to not get auto-generated when
 glib-mkenums gets processed.

This all goes to a strange direction.

First, GRegistryBackend is not an enum, it is a subclass of
GSettingsBackend.  glib-mkenums will not generated
g_registry_backend_get_type() for you.

The get-type function g_registry_backend_get_type() is provied by
gio/gregistrysettingsbackend.c.  Which is built only on MS Windows
(using the standard Makefiles, see the if OS_WIN32 condition there).  So
might it be that you do not compile it into gio?

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: glib-mkenums in glib 2

2012-12-29 Thread David Nečas
On Sat, Dec 29, 2012 at 07:13:56AM +, John Emmas wrote:
 2)  Along a similar vein, it looks like I need to process the module
 'gio/gdbus-2.0/codegen/gdbus-codegen.in' but I don't know what program
 / script I need for processing it.

Anything ending with .in is usually processed by configure
(config.status) which you obviously don't have so you must replace
@VARIABLE@s with the corresponding values using whatever you have.  But
the only two variables present there are unused on MS Windows anyway –
MS Windows neither recognise shbangs nor is the fixed datadir code path
useful there.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: one function to go...

2012-12-23 Thread David Nečas
On Sun, Dec 23, 2012 at 02:35:31PM -0800, Gary Kline wrote:
 in this popup dialog I would have a few words that the
 file does not exist and want a button WITH the Enter-key
 icon that gives an iconic clue that all the user need do is
 hit the enter key.  I suppose if the users could, if they wished,
 mouse-click on the button.

I cannot speak for your target audience but according to my experience
(a) if people see a message box with a single button (probably with some
visual clue that it has focus) they will just press Enter or Esc to
make it go away, or
(b) if people see a button they will always use the pointer to click on
the button no matter what other, possibly much simpler, means may be
available to activate it.
This is a strict division with little between.  There is no way to
migrate people from (b) to (a), you can try for years with no effect.
So targetting those between you may find you are targetting a group of
size zero.

Just my 2 eurocents...

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Focus vs Sensitivity

2012-12-22 Thread David Nečas
On Fri, Dec 21, 2012 at 07:16:07PM -0200, Ivan Baldo wrote:
 What happens is that the Tab handler runs before the value-changed
 handler

This is the wrong view what happens.  The adjustment value is not
updated during user's editing of the entry.  If the spin button is not
set to numeric its entry can contain any text during the editing
(whereas setting numeric ensures the entry contents always parses as a
number, making impossible to enter numbers in the scientific format, for
instance).  The value is updated when editing finishes, for which one
possibility is that the entry loses focus.  So *first* the focus leaves
the entry then *in consequence* the adjustment value is updated.

However, this does not seem to be entirely the core of your problem.
The CRITICAL errors are printed becuase in gtk_window_real_set_focus()
this:

if (priv-has_focus)
do_focus_change (priv-focus_widget, TRUE);

g_object_notify (G_OBJECT (priv-focus_widget), is-focus);

assumes that do_focus_change() cannot make priv-focus_widget become
NULL.  IMO there may be sane use cases when this can occur (like yours)
so I would try to report a bug.

How to work around it?  Instead of connecting to value-changed monitor
all changes to the entry text:

g_signal_connect(spin_button, changed, G_CALLBACK(spin_entry_changed), 
spin_button2);

...

static void
spin_entry_changed(GtkEntry *entry, GtkWidget *target)
{
gtk_widget_set_sensitive(target, g_strtod(gtk_entry_get_text(entry), 
NULL) != 0);
}

This will *also* make the second entry insensitive when the content of
the first does not parse as a number at all (which is likely a good
thing though perhaps not).

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkCheckMenuItem needs double click?

2012-12-08 Thread David Nečas
On Sun, Dec 09, 2012 at 12:57:43AM +1300, Perdie Perduta wrote:
 Using glade with GtkBuilder to create my application GUI. I'm
 developing  testing on Windows 7 using Microsoft C++.
 Trying to add a record button to my menu bar. Note: Ideally I would
 have liked a nice red record button that lights up while my
 application is recording, however just to get it working I put in
 GtkCheckMenuItem.
 
 It is all working but inexplicably I have to click my GtkCheckMenuItem
 *twice* to for each toggle. Is this a known common mistake?
 Any advice or reference to previous thread on the subject would be 
 appreciated.

Adding *buttons* to *menubars* is certainly very odd.  It may be that to
activate the button the menu item must get focus first, hence the two
clicks.

My advice is to use a toolbar instead.  It seems to fit what you are
trying to do better and you can have tool items that act like plain
buttons, toggles, radio button, that pop up menus, etc.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Forks, slices and threads: Can you make GSlice deadlock?

2012-12-07 Thread David Nečas
On Fri, Dec 07, 2012 at 05:53:57AM -0500, Matthias Clasen wrote:
 See https://bugzilla.gnome.org/show_bug.cgi?id=679683
 g_test_trap_fork is just a bad idea, doubly so with threads (and every
 glib program is using threads nowadays)a

Thanks, somehow, I missed that bug.

Regards,

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Forks, slices and threads: Can you make GSlice deadlock?

2012-12-07 Thread David Nečas
On Fri, Dec 07, 2012 at 08:44:01PM +, Chris Vine wrote:
 ...
 So for your scheme to work, the parent before forking must be single
 threaded.

As I have learnt the hard way, this is not something I can ensure even
the program does not use any multi-threading itself because libraries
may.  Even apparently very innocent programs can exhibit weird
threading-related bugs.  And while it is a sort of gray area, starting
to use threads internally is rarely considered an ABI breakage.  So,
unfortunately, the conditions you listed can be reduced to ‘it will
never work’ in practice.

Anyway, I do not attempt to do this kind of fork  not-exec in real Gtk+
applications.   So I'm looking forward to a better solution for unit
tests which is discussed in the bugzilla bug mentioned by Matthias.

Regards,

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Forks, slices and threads: Can you make GSlice deadlock?

2012-12-06 Thread David Nečas

Hello,

can g_slice_alloc() be made to deadlock simply by some bad sequence of
GLib function calls, considering the calling program does not, of
course, hold any GLib lock explicitly?  (Without a GLib bug, that is.)

I am starting to suspect a problem in GSlice interaction with threads.
But I cannot report anything to bugzilla because I am unable to get to
the core of the problem.

My program (test program for a library) does g_test_trap_fork() and the
child creates worker threads with g_thread_new(), sends them tasks with
GAsyncQueue and cancels the tasks using GCancellables.

Occasionally, a seemingly innocent g_thread_new() call deadlocks in
g_slice_alloc(), see the backtrace below for how and where exactly.  If
it happens, it happens in the child soon after forking.

I canNOT reproduce any deadlock if:
- G_SLICE=always-malloc is set,
- g_test_trap_fork() is not used and the test is run directly in the
  main program,
- under valgrind (also, it reports no errors),
- I print anything to stderr in g_slice_alloc() – infuriating, but so it
  works.


When it deadlocks the main thread looks:
#0  __lll_lock_wait () at 
../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
#1  0x003451009c8c in _L_lock_1024 () from /lib64/libpthread.so.0
#2  0x003451009c35 in __pthread_mutex_lock (mutex=0x25442e0) at 
pthread_mutex_lock.c:105
#3  0x7fe496b01fb6 in g_mutex_lock (mutex=0x7fe496d9f8e0) at 
gthread-posix.c:208
#4  0x7fe496adef29 in magazine_cache_pop_magazine (ix=4, countp=0x2544368) 
at gslice.c:718
#5  0x7fe496adf235 in thread_memory_magazine1_reload (tmem=0x2544310, ix=4) 
at gslice.c:794
#6  0x7fe496adf4df in g_slice_alloc (mem_size=72) at gslice.c:992
#7  0x7fe496adf572 in g_slice_alloc0 (mem_size=72) at gslice.c:1032
#8  0x7fe496b02981 in g_system_thread_new (thread_func=0x7fe496ae8fc9 
g_thread_proxy, stack_size=0, error=0x7fffb1ded5a0) at gthread-posix.c:1101
#9  0x7fe496ae9207 in g_thread_new_internal (name=0x491da9 canceller, 
proxy=0x7fe496ae8fc9 g_thread_proxy, func=0x461790 cancel_cancel, 
data=0x25822f0, stack_size=0, 
error=0x7fffb1ded5a0) at gthread.c:884
#10 0x7fe496ae90d5 in g_thread_new (name=0x491da9 canceller, 
func=0x461790 cancel_cancel, data=0x25822f0) at gthread.c:835
#11 0x00461667 in master_cancel_one (nproc=1) at master.c:232
#12 master_cancel_one (nproc=1) at master.c:208
#13 0x7fe496ae792d in test_case_run (tc=0x2555c90) at gtestutils.c:1679
#14 g_test_run_suite_internal (suite=suite@entry=0x2557c80, path=optimized 
out, path@entry=0x7fe496b5c2be ) at gtestutils.c:1732
#15 0x7fe496ae7aa6 in g_test_run_suite_internal 
(suite=suite@entry=0x2557c60, path=optimized out, path@entry=0x7fe496b5c2be 
) at gtestutils.c:1743
#16 0x7fe496ae7aa6 in g_test_run_suite_internal 
(suite=suite@entry=0x2557c40, path=optimized out, path@entry=0x7fffb1deef4d 
/master) at gtestutils.c:1743
#17 0x7fe496ae7aa6 in g_test_run_suite_internal 
(suite=suite@entry=0x2545c20, path=optimized out, path@entry=0x7fffb1deef43 
testlibgwy/master) at gtestutils.c:1743
#18 0x7fe496ae7e0b in g_test_run_suite (suite=0x2545c20) at 
gtestutils.c:1788
#19 0x7fe496ae7e55 in g_test_run () at gtestutils.c:1308
#20 0x00412e11 in main (argc=1, argv=0x7fffb1dedae8) at testlibgwy.c:88


There is also a worker thread waiting on my own GConf with my own lock
at the moment:
#0  pthread_cond_wait@@GLIBC_2.3.2 () at 
../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:166
#1  0x7fe496b02575 in g_cond_wait (cond=0x258b5a8, mutex=0x258b5a0) at 
gthread-posix.c:746
#2  0x7fe496a9b09b in g_async_queue_pop_intern_unlocked 
(queue=queue@entry=0x258b5a0, wait=wait@entry=1, end_time=end_time@entry=-1) at 
gasyncqueue.c:421
#3  0x7fe496a9b546 in g_async_queue_pop (queue=queue@entry=0x258b5a0) at 
gasyncqueue.c:455
#4  0x7fe4973b60e3 in worker_thread_main (thread_data=optimized out) at 
master.c:190
#5  0x7fe496ae9082 in g_thread_proxy (data=0x258e850) at gthread.c:797
#6  0x003451007d14 in start_thread (arg=0x7fe49534c700) at 
pthread_create.c:309
#7  0x0034508f168d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:115


and several threads are in the following state:
#0  __lll_lock_wait () at 
../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
#1  0x003451009c8c in _L_lock_1024 () from /lib64/libpthread.so.0
#2  0x003451009c35 in __pthread_mutex_lock (mutex=0x25442e0) at 
pthread_mutex_lock.c:105
#3  0x7fe496b01fb6 in g_mutex_lock (mutex=0x7fe496d9f8e0) at 
gthread-posix.c:208
#4  0x7fe496adf163 in private_thread_memory_cleanup (data=0x7fe4740008c0) 
at gslice.c:774
#5  0x003451007b12 in __nptl_deallocate_tsd () at pthread_create.c:157
#6  0x003451007d22 in start_thread (arg=0x7fe495b4d700) at 
pthread_create.c:316
#7  0x0034508f168d in clone () at 
../sysdeps/unix/sysv/linux/x86_64/clone.S:115


That's all the threads.

So, they are all trying to lock allocator-slab_mutex in 

Re: Lack of gtk_application_get_window_by_id function despite of documentation

2012-11-17 Thread David Nečas
On Sun, Nov 18, 2012 at 12:05:51AM +0100, Jakub Kucharski wrote:
 Can you tell me what's wrong?

The documentation for gtk_application_get_window_by_id says ‘Since: 3.6’.

Sid has Gtk+ 3.4.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkTreeIter assignment

2012-10-30 Thread David Nečas
On Tue, Oct 30, 2012 at 05:05:37PM +0400, Vlasov Vitaly wrote:
 Is that normal, to assign one GtkTreeIter to another?
 
 For example:
 void add_new( ... , GtkTreeIter *iter)
 {
 GtkTreeIter *default_iter;
 
 if(iter != NULL)
 {
default_iter = iter; -- is that noraml??

This is pointer assignment: default_iter will denote the same chunk of
memory as iter.  What exactly should be abnormal here?

 }
 gtk_tree_store_append(default_iter);

This is invalid code: wrong number of arguments of wrong type.  And, of
course, default_iter is possibly being used uninitialised.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkTreeIter assignment

2012-10-30 Thread David Nečas
On Tue, Oct 30, 2012 at 06:53:18PM +0400, Vlasov Vitaly wrote:
 GtkTreeIter *default_iter -- GtkTreeIter default_iter;
 
 It's question about:
 default_iter = *iter; -- is that normal?

Yes.  It is explicitly specified that tree iters can be copied by value.
See for instance here

http://developer.gnome.org/gtk/stable/GtkTreeModel.html#gtk-tree-iter-copy

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: understanding GtkRGBA

2012-10-11 Thread David Nečas
On Thu, Oct 11, 2012 at 11:14:00AM +0100, Rudra Banerjee wrote:
 So, I am trying to use:
 
 gtk_widget_override_background_color (Hbutton, GTK_STATE_NORMAL,
 GdkRGBA(0,0,0,1.));
 
 ofcourse, this is not the way to use RGBA.
 What is the correct way of using it?

GdkRGBA is a plain C struct and is used as any other plain C struct,
please see your C reference guide for the syntax and use of structs.

In C89 you need to create it on stack (or on heap) if you want to take
its address.

In C99 you can also use (GwyRGBA){0.0, 0.0, 0.0, 1.0}.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: understanding GtkRGBA

2012-10-11 Thread David Nečas
On Thu, Oct 11, 2012 at 12:56:36PM +0200, David Nečas wrote:
 In C99 you can also use (GwyRGBA){0.0, 0.0, 0.0, 1.0}.

I mean (GdkRGBA){0.0, 0.0, 0.0, 1.0}, was thinking about something
else...

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: link treeview with file

2012-10-11 Thread David Nečas
On Thu, Oct 11, 2012 at 06:58:04PM +0100, Rudra Banerjee wrote:
 As the treeview is loaded from a file, in my program, new entries can
 also be entered. It writes to the Treeview, as well as in a file using:
 
 strAuth = gtk_entry_get_text(GTK_ENTRY(e-entryAuth));
 
 /*Entering the data in Treeview */
   gtk_list_store_append(store, siter);
   gtk_list_store_set(store, siter,
   COL_BIB_KEY, strkey,
   COL_BIB_TYPE, strcombo,
   COL_BIB_NAME, strAuth,
   COL_BIB_YEAR, strYear,
   COL_BIB_PUB, strTitle,
   -1);
 /*Entering the data in file */
 if( strlen(strEditor)!=0)
 g_fprintf( fop, \tEditor=\%s\,\n, strAuth);
 ...etc...
 
 
 Now, my question is, can this two entry be linked such that if I delete
 an entry from treeview, it will also delete the entry from file(fop).

In principle, certainly: by loading the entire file, parsing it, finding
the corresponding line, deleting it and saving the file again.  Or, if
the file ‘cannot’ change on-disk meanwhile, just by re-generating the
file from the treeview and saving it.

For a saner use you need an API for handling of these files, similar to
GKeyFile for .ini files.  Apparently you are trying to process BibTeX
files.  Although there is no shortage of tools working with BibTeX files
and even a few attempts to create a reusable BibTeX file handling
library have been made (btOOl, ...), I cannot really recommend any
parser.  Maybe others know some.

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_tree_model_get end of Line marker

2012-10-07 Thread David Nečas
On Sun, Oct 07, 2012 at 05:43:52PM +0200, Arne Pagel wrote:
 because of my lazy programming style I sometimes forget or overwirte
 the comma before the -1  end of line marker for the gtk_tree_model_get
 or gtk_tree_store_set function.  This error can usually not be
 detected by the c-compilers, so that I had to spend some really
 unnecessary time to fix this typo.
 
 Now I defined a makro for this, and in the case I forget the comma
 again at least I get a compiler error:
 
 #define TREE_MODEL_EOL (int)-1
 
 gtk_tree_model_get(model,iter,STUFF,stuff,TREE_MODEL_EOL);
 
 I think something like this would be integrated officially and also
 the all the examples would be updated, at lot of headache of many
 people could be avoided.

Errors related to the -1 sentinel could be avoided by much more
straightforward means: defining gtk_tree_model_get() with column id and
value pointer reversed, i.e. first comes the value pointer (presumably
non-NULL), then comes the column id.  Then gtk_tree_model_get() could
just carry __attribute__((sentinel)) a.k.a. G_GNUC_NULL_TERMINATED.  But
the Gtk+ devs decided otherwise.

It would be nice (also in other cases) if gcc had an attribute for
arbitrary constant-value sentinels.  Unfortunately, it has not.  The
corresponding bug

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28319

seems to be stale.  I'm not sure about LLVM but it does not seem to
support this either.

While I've never forget the comma before -1 I have forgetten the -1
entirely a few times so something that prevents all sentinels errors
would be quite useful.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Sortable Treeview

2012-10-06 Thread David Nečas
On Sun, Oct 07, 2012 at 12:25:22AM +0100, Rudra Banerjee wrote:
 What I am looking for, is make my header clickable to get the sorting,
 with initial view completely unsorted.

Then look at List Store in gtk-demo.  It demonstrates this clearly.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Handle Enter pressing at GtkEntry

2012-10-04 Thread David Nečas
On Wed, Oct 03, 2012 at 08:19:39PM -0700, Andrew Potter wrote:
 On Wed, Oct 3, 2012 at 7:42 AM, Yury Alyaev muta...@rambler.ru wrote:
  What is the right way to catch Enter pressing at the end of the text input
  to GtkEntry
 
 gtk_entry_set_activates_default() is probably what you want.

If you actually want what it does.  Usually, I do not want that at all.

I want to recalculate and update something once user has finished
editing the value there (but not during the editing).  This means namely
when the entry loses focus, however, it should be also possible to
invoke the update without leaving the entry, by pressing Enter.  So,
instead of gtk_entry_set_activates_default() I use something like
set-activate-on-unfocus and then just handle activate.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Handle Enter pressing at GtkEntry

2012-10-04 Thread David Nečas
On Thu, Oct 04, 2012 at 06:55:08PM +0900, Tristan Van Berkom wrote:
 I'm curious about this, out of my own personal interest... do we
 have a workable solution for this commit-on-focus-out paradigm ?
 
 As I understand, it's not very stable to use focus-out events
 and, I recall reading a detailed blog about this I can't seem to
 find at the moment (but it seems the problem is not at all limited
 to GTK+, just broken by design).
 
 Note in many cases validation/apply/commit user input on
 focus-out does work but... here is a case where I expect it
 to break:

 ...

Validation is a different problem.  For validation, the user should have
an instataneous visual clue whether the input would be considered valid
(but no blocking of non-conforming inputs, of course).  In the second
case you mentioned, loading of new values must not happen when there are
uncommited changes and that should be also easy to achieve – except it
may come a bit too late from the user's perspective if validation needs
also be performed.  However, if the GUI is constructed so that the user
expects immediate commit, as it seems from your description, then it
should be probably really immediate.

Imagine the case I was talking about as function plotting.  You may
attempt to plot the function as the user types the expression but (1)
the ‘plotting’ thing is not something really instanteneous and so doing
it after each keystroke would interfere with typing (2) the user is
essentially never interested in displaying the intermediate rubbish, in
fact, he may be strongly intereseted in seeing the last meaningful, i.e.
commited, output while editing.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Handle Enter pressing at GtkEntry

2012-10-03 Thread David Nečas
On Wed, Oct 03, 2012 at 09:42:24AM -0500, Yury Alyaev wrote:
 What is the right way to catch Enter pressing at the end of the
 text input to GtkEntry. The obvious way is conecting the callback to
 the activate signal, but for some reason documentation says
 Applications should not connect to it.

My Gtk+ documentation says the opposite:

...it is also commonly used by applications to intercept activation
of entries.

and I've been using it for a long time without problems.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: glib branched

2012-10-03 Thread David Nečas
On Wed, Oct 03, 2012 at 12:35:57AM -0400, Matthias Clasen wrote:
 I have now created a glib-2-34 branch, so master is now open for
 ... GTask ...

Is this also intended, at least in the future, for things like
long-running calculations that need some monitoring/reporting of
progress not just the final result?  I mean, some monitoring can be
always implemented on top of GTask but once I get my hands dirty with
explicit asynchronous communication I can implement that directly on top
of GThread as well.  I always look hopefully at the asynchronous
interfaces in GLib with hope, however, the intended use cases do not
seem to match mine...

Thanks,

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: PATHBAR written using GTK 3

2012-10-02 Thread David Nečas
On Tue, Oct 02, 2012 at 03:42:53AM -0300, Mariano Gaudix wrote:
 Excuse me   .  For  my   the question .. someone  have   or  seen a
 PATHBAR   written with gtk 3 .
 You  can  tell me   the page address where you can download the code for
 this widget  .

I suppose typing ‘dowload Gtk+’ to Google is not that difficult so the
question is where in the source code you can find GtkPathBar – and that
is gtk/gtkpathbar.c and .h (if grep is not your friend).

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Synchronization of gtk_tree_store add/remove events

2012-09-19 Thread David Nečas
On Wed, Sep 19, 2012 at 09:44:28PM +0200, Arne Pagel wrote:
 I have an application where I use a tree-view to display some data
 from an external hardware.  Different Objects can be added or removed
 to the treestore, each existing object in the treestore has a specific
 id which is used to get data over some communication interface.
 
 It can easily happen, the the user deselects an object in the
 treestore while this communication is ongoing.  This means that my
 treepath or iter which I rembered befor is not valid anymore after the
 communication has finished (*1).

Did you mean deletes instead of deselects here?  The rest of the
description would make much more sense to me then.

Anyway, I think GtkTreeRowReference is what you need – a thing that
points to a specific row that may not exist anymore and it had a method
to tell whether the row still exists.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: gtk_tree_view/store, best way to select all nodes of a branch

2012-09-12 Thread David Nečas
On Wed, Sep 12, 2012 at 10:40:11AM +0200, Arne Pagel wrote:
 My current simple solution is as follows:
 I use the gtk_tree_model_foreach() function and pass some user data with the 
 current major number of the tree-path.
 Inside the foreach-function I use gtk_tree_path_to_string, where I check if 
 the first number is identical to the user data.
 
 This works, but I have to use a lot of string functions.
 Is there a smarter way to do that with less overhead?

Use gtk_tree_selection_select_range().

You already have the start path, so, how to get the end path?  Use
gtk_tree_model_iter_n_children() and gtk_tree_model_iter_nth_child()
recursively to always move to the last child in the branch.  If your
tree is only two-level (as it seems to be) you do not even need to
recurse.

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: how to get entry from GtkComboBoxEntry?

2012-09-11 Thread David Nečas
On Tue, Sep 11, 2012 at 03:29:10PM +0400, Vlasov Vitaly wrote:
 I wanna use some ComboBox/Entry widget:
 It should contain tree model with language names and hidden ISO 639-1
 codes, for example English(en) German(de) Russian(ru) or
 other. And, in addition, it should allow to user write ISO 639-1
 language code from keyboard.
 
 So, with tree i can get selected value and respectively get lang code
 from tree.
 When in ComboBox is not selected values, it could mean: 1) User set it
 from keyboard 2) Entry is empty.
 
 It is possible to create ComboBox with tree model and separate entry,
 but i don't like that way.
 
 How to check, whether the user has entered a value from the keyboard or
 entry is empty?
 May be i should use other Entry/ComboBox widget? I used before
 GtkEntryCompletion. It work's, but it uncomfortable with two-letter ISO
 codes.
 
 Now i use gtk-2.0, but later will switch to 3.0. As i can see, in
 gtk-3.0 GtkComboBox and GtkComboxEntry is same thing. But i still can't
 get entry widget from gtk-3.0 ComboBox.

I don't quite get the difference between empty entry and user-typed text
(she could type something and then delete it, for instance).  Anyway, I
will try to answer the simple part:

Use gtk_bin_get_child(comboboxentry) to get the GtkComboBoxEntry's
GtkEntry widget.

Regards,

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: how to get entry from GtkComboBoxEntry?

2012-09-11 Thread David Nečas
On Tue, Sep 11, 2012 at 04:14:52PM +0400, Vlasov Vitaly wrote:
 Is gtk_bin_get_child() always return GtkEntry widget?

For a GtkComboBoxEntry?  Yes.  But in general, it returns the only child
of a GtkBin container, whatever it is for that container.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: write to a file using g_print

2012-08-21 Thread David Nečas
On Tue, Aug 21, 2012 at 11:42:53PM +0100, Rudra Banerjee wrote:
 Is it possible to write to a file using g_print? 

g_print() is not an interface to print things to *a specific
destination*.  Quite the opposite.

It sends messages to the print handler.  Depending on the print handler
stup, it do anything with them (print to stdout, save to some file,
display somewhere, discard, ...).

 Any solution?

Don't do that then.  Use g_fprintf().  Or, in most cases, just
fprintf().

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GList strange behavior

2012-08-16 Thread David Nečas
On Thu, Aug 16, 2012 at 06:49:25PM +0400, Vlasov Vitaly wrote:
 I need to save newly created list poiner.

No.

Many operations change the list head (by adding, removing, reordering,
..., elements).  In general, if an operation returns the new list head
you *must* save and use that in subsequent operations.

  So, i need to use g_list_last() to 
 save it? Is there another method to save created list pointer?

*Every* operation that may change the list head returns the new list
head.  That's the pointer to use.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: next steps for touch support in GTK+

2012-08-04 Thread David Nečas
On Sat, Aug 04, 2012 at 03:39:05PM +0100, Emmanuele Bassi wrote:
 one implies a soft action (GtkToggleButton), whereas the other
 implies something similar of a hardware switch (GtkSwitch).

As every user knows, widgets relay wishes to magic pixies.  I wonder if
that is soft or hard action, maybe it depends on how hard you need to
beat the pixies to do what you want.

Do you actually expect different kinds of on/off controls to be mixed
wildly because each was selected based on how soft is the action it
implies?

 they both
 have their use cases which are not interchangeable:
 
 https://live.gnome.org/GnomeOS/UX/Guidelines/SwitchWidget
 
 the page above should become part of the new Human Interface
 guidelines/design patterns. not every application should use switches,
 nor existing applications should be mindlessly migrated to moving from
 toggle and/or check buttons to switches.

All cases listed there as good use cases of GtkSwitch would be – for me
– improved by using a plain toggle button.

It would take less horizontal space, it would be less wordy, it would
not leave me wondering whether it shows ON when it is on or whether I
should move it to ON if I want it ON (yes, I still do not remember it),
it would not look trendy, and it would not have translation issues.  In
fact, even the ‘wrong’ checkbuttons would represent an improvement for
me.

I would also say the widgets are completely interchangeable, but forced
to interpret the statement ‘their use cases are not interchangeable'
somehow I would have to conclude that GtkSwitch has no meaningful use
case at all.  Could the page be improved to include this?  In my opinion
it could lead to a considerable simplification of the guidelines.

 the short takeaway is that the switch should be used in specific
 cases, and that the way its been defined as a widget does not allow
 inheritance from GtkToggleButton or GtkButton (no label, no children,
 styling of trough and handle).

I am sorry but, again, this is just a recapitulation of the status quo.
Stating it a hundered times does not make problems vanish magically even
if you beat the pixies really hard with a switch.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Passing structure with a callback

2012-07-24 Thread David Nečas
On Tue, Jul 24, 2012 at 12:27:41AM -0600, Frank Cox wrote:
 Is my understanding of how this actually works correct?

Yes.  Now please read my reply to your first e-mail...

 If so, what is the
 recommended way to deal with structures like this?

...that already answered this too.

https://mail.gnome.org/archives/gtk-app-devel-list/2012-July/msg00057.html

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Passing structure with a callback

2012-07-24 Thread David Nečas
On Tue, Jul 24, 2012 at 08:43:08AM +0200, David Nečas wrote:
 Now please read my reply to your first e-mail...

I see.  So, in case you read the mailing list archives: It's a bit
pointless to ask questions in a mailing list if your mailserver blocks
all answers.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Passing structure with a callback

2012-07-22 Thread David Nečas
On Sun, Jul 22, 2012 at 11:22:07PM -0600, Frank Cox wrote:
 My widgetshare structure gets passed from main() to MainMenu with no
 apparent problem, but using the same scheme to pass emailshare from
 MainMenu to Clear segfaults.

This is elementary C.  Both structures are created on stack so they
cease to exist upon return from the corresponding functions.  While
main() is never exited while the program is running, MainMenu() is
particularly short-lived.

Use heap-allocated data.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How can I check if a GtkWidget exists?

2012-07-20 Thread David Nečas
On Fri, Jul 20, 2012 at 12:50:45AM -0600, Frank Cox wrote:
 How can I check if a GtkWidget exists?

By keeping track of it (either when you create and destroy the widgets
or using weak references/weak pointers/destroy callbacks/...).

‘Checking the existence of a widget’ is, essentially, a meaningless
phrase.  If the widget has been destroyed you do not have any means to
*refer* to it.  You cannot ask ‘does this widget exist’ because there is
no way to say ‘this widget’.

Using the pointer to the memory the widget used to occupy for anything
is a programming error.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How can I check if a GtkWidget exists?

2012-07-20 Thread David Nečas
On Fri, Jul 20, 2012 at 10:15:54AM +0200, Miroslav Rajcic wrote:
 Not sure, but perhaps GTK_IS_WIDGET(widget) macro would help.

If you have the pointer to a GObject instance and want to know whether
it is an instance of GtkWidget (including subclasses) then
GTK_IS_WIDGET() is the right thing to use.

But if you use this macro with a random pointer (e.g. one pointing to a
memory location where some GObject might be some time ago) do not expect
anything more useful than a CRITICAL error/crash.

To deal with objects that may or may not exist use one of the several
mechanisms (weak pointers/weak refs/destroy callbacks/...) for keeping
track of the object existence.  And, generally, use these mechanisms to
avoid even the possibility of dangling pointers in your code.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Open file from menu

2012-07-09 Thread David Nečas
On Mon, Jul 09, 2012 at 03:40:11PM -0400, Liam R E Quin wrote:
 also check that the free() was OK

I wonder how you do that (apart from not getting any glibc MALLOC_CHECK_
error message or similar).

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: multiple GTKentry inside a GTKnotebook

2012-06-18 Thread David Nečas
On Mon, Jun 18, 2012 at 11:28:48PM +0530, Rudra Banerjee wrote:
 pasted is a minimal layout of my trial to create a bibliography maker.
 The problem is, in Authors tab inside notebook, I want to edit 3 more
 entry, as Editor an example. But its taking only the first entry.
 Please show me where I am making the error.

GtkFrame is a GtkBin which means it can contain a single widget.  If you
want more you need to use packing container (GtkTable, GtkVBox, GtkGrid,
...), put it to the frame and then pack widgets to this contaner.

Yeti


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Help with a multi-threaded application. Spot a crash.

2012-05-31 Thread David Nečas
On Thu, May 31, 2012 at 07:11:10AM +0100, Osmo Antero wrote:
 Now learned that it's a POD, Perl Object.

I meant Plain Old Data, but of course in C.  Nothing in GLib (as opposed
to GObject and GIO) is an GObject.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Help with a multi-threaded application. Spot a crash.

2012-05-30 Thread David Nečas
On Wed, May 30, 2012 at 08:30:40PM +0100, Osmo Antero wrote:
 I have a multi-threaded application that filters data practically
 while user types text in an entry-field. But this applications
 regularly crashes.

GRegex is not a GObject, it's just POD.  So

if (G_IS_OBJECT(search-regex))

will surely attempt to read some bogus memory location and crash.
I cannot see why such code is there at all but anyway set search-regex
to NULL if it does not exist and then just use

if (search-regex)

if necessary.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: wide characters in label

2012-05-30 Thread David Nečas

This is the wrong mailing list, dedicated to development of Gtk+.

Your e-mail does not contain any question.  So I suppose you want to
know why your code is broken.

On Tue, May 29, 2012 at 09:18:38AM -0700, jessCPP wrote:
 setlocale(LC_CTYPE, UTF-8);

A bit strange and not actually influencing anything else in your code.

   wchar_t wide[]=Lthis is wide;

Gtk+ works with UTF-8 encoded strings (i.e. sequences of bytes),
*not* wide characters.

wchar_t is an arbitrary poorly-defined platform-dependent type, making
difficult to write a portable code.  Do not use wide characters unless
you have to.  And if you have to then convert them to UTF-8 for use with
Gtk+, e.g. using iconv with WCHAR_T as the source encoding.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: compile gtk with libcurl

2012-05-24 Thread David Nečas
On Thu, May 24, 2012 at 10:37:01PM +0530, Rudra Banerjee wrote:
 $ gcc curlgtk.c -o cpan  `pkg-config --cflags gtk+-2.0` `pkg-config
 --libs libcurl gtk+-2.0`
 /usr/bin/ld: /tmp/ccZN7P8Q.o: undefined reference to symbol
 'g_thread_init'

If you use gthread you must link with it.  Simple.  Use

pkg-config --cflags --libs gtk+-2.0 gthread-2.0 libcurl

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_filename_to_uri() issue in glib-win32

2012-05-23 Thread David Nečas
On Wed, May 23, 2012 at 06:48:31AM +0100, John Emmas wrote:
 But whatever that (second) character looked like, it's decimal value would 
 always be 246 (because the UTF-8 sequence C3 B6 translates to decimal 246).
 
 The URI translation of decimal 246 is %F6.

This is nonsense.  Percent-encoding consists of % followed by *two*
hexadecimal digits and encodes *bytes*, see

http://tools.ietf.org/html/rfc3986#section-2.1

If things worked as you suggest you would not be able to encode any
codepoint larger than 255 and the entire thing would be pretty useless.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: probable gtk_window_present and pango help

2012-05-18 Thread David Nečas
On Fri, May 18, 2012 at 09:12:45PM +0530, Rudra Banerjee wrote:
 Here is a minimal example of a program, where if i click the button, a
 pop up window appears. I am posting both the call back function and the
 main routine (table.c).
 I am facing 2 problem.

Unfortunately, you are facing much more problems.

For start

gtk_container_add(GTK_CONTAINER(window1), vbox1);

is called with an unitialised variable window1 (i.e. no window1 is ever
created).  This leads to a CRITICAL message to console and/or crash.

And if window1 existed then vbox1 would be packed into two different
containers (window1 and window) which is not possible.  So I'm ignoring
that part altogether.

The callback should look like

void
callback_it(GtkWidget *button, gpointer user_data)
{
   ...
}

where in user_data the callback receives the last argument you passed to
g_signal_connect().  It is rarely useful to pass a constant such as
Call there.

The callback is *not* another main() function; it should *not* call
gtk_init() again, etc.  Please read the signals section in the Gtk+
tutorial

http://developer.gnome.org/gtk-tutorial/2.90/x159.html

There are several other highly suspicious things:
- redeclaration of global variables (such as window) inside a function;
  are you aware this creates a new local variable window that has nothing
  to do with the global one?
- inclusion of .c files instead of separate compilation + linking them
  together
- calling gtk_widget_show() on individual widgets and then again showing
  everything using gtk_widget_show_all()
- not terminating the Gtk+ main loop when the main window is destroyed;
  this is usually the first thing to set up in a Gtk+ program, see

http://developer.gnome.org/gtk-tutorial/2.90/c39.html#SEC-HELLOWORLD

etc.

 1) The problem is evry time I click the button main, a new window
 appears(obviously). What I want to achive is, if the window is already
 present, it should not open again; rather it should focus that window. I
 believe, this can be achived by gtk_window_present(may be I am wrong).
 But I don't know how to use it.

You use it just by calling gtk_window_present() on the window object.
To that meaningfully you need not only to keep the window object around
but also get notified when the window is destroyed.  Either by
connecting to the destroy signal or, if you just want to set a pointer
to NULL once it is gone, by using g_object_add_weak_pointer().

 2) In the callback function, I have C_1 and C_2. What I want to achive
 is Csub1/sub etc via pango(or any other).

For simple things you can sometimes just use UTF-8.  But generally, you
need to use Pango markup.  If the widget does not have function to set
the markup it has a function to obtain the label widget so that you can
use gtk_label_set_markup() on that.

See the attached code with main problems fixed (and merged to one file).
Please go through the Gtk+ tutorial farther that you perhaps have done.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: G_PARAM_SPEC_VALUE_TYPE() question

2012-05-15 Thread David Nečas
On Tue, May 15, 2012 at 08:39:12AM +0200, Marc Balmer wrote:
 I want to set properties of an object using the g_value_set_type()
 functions and to cast my value (which I get from a Lua script, which
 e.g. does not differentiate between integers and floats) I need to know
 the type of the property.
 
 Ideally something like the following:
 
 switch (G_PARAM_SPEC_VALUE_TYPE(prop)) {
 case G_TYPE_INT:
   g_value_set_int(...);
   break;
 case G_TYPE_STRING:
   g_value_set_string(...);
   break;
 }
 
 You get the idea...  This works for basic types, but not for e.g.
 GParamEnum, i.e. when G_PARAM_SPEC_TYPE_NAME() returns GParamEnum,
 above scheme seems not to work.  There is a type G_TYPE_ENUM, but it is
 not returned in case of GParamEnum.

You need to use g_type_is_a(...) on the type obtained from
G_PARAM_SPEC_TYPE_NAME(), not direct comparison to some explicit GTypes.
Then it will work also with subclassable types such as enums.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: pango or any other way to format text

2012-05-14 Thread David Nečas
On Mon, May 14, 2012 at 08:20:26PM +0800, Rudra Banerjee wrote:
 Can anybody please take some time to show me simple way of
 implementing pango formatting to get greek letters, subscripts and
 superscripts in gtk2+?

What do you mean by ‘implementing Pango formatting'?  I suppose you are
not writing a Pango backend, i.e. you are not *implementing* any text
rendering yourself.

If you just want to use Pango to render Greek text, subscripts,
superscripts, Cyrillic, math symbols or whatever, use UTF-8:

GtkWidget *label = gtk_label_new(ἀπὸ τοῦ ἡλίου μετάστηθι);

or

GtkWidget *label = gtk_label_new(a² + b² = c²);

That's it.

Function gtk_label_set_markup() with Pango markup

http://developer.gnome.org/pango/stable/PangoMarkupFormat.html

can be used for more complex indexes and exponents and other stuff in
labels.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GRegex regular expression failing to match

2012-05-14 Thread David Nečas
On Mon, May 14, 2012 at 01:36:02PM -0800, Christopher Howard wrote:
 Is there anything wrong with the regexp,

Sure.  Two things.  It should be

^/[0-9]+$

not

^/d+$

First, it lacks the backslash to make \d a digit atom.  But, second,
since \d matches a digit (possibly whatever Unicode may say is a digit),
not 0-9, you should really use [0-9] to match ASCII digits.

Yeti
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: clarification: GErrors and GQuarks

2012-05-11 Thread David Nečas
On Thu, May 10, 2012 at 04:45:09PM -0800, Christopher Howard wrote:
 Quick glib question here: I've been getting into glib's error reporting
 system and trying to integrate it into some code. (My code is using
 glib, but not GTK+ itself.) Overall it seems rather straightforward, but
 there was one point I was hoping for clarification on:
 
 In the g_set_error() parameters, the domain parameter is a GQuark.
 Does this mean that I am supposed to use something like
 g_quark_from_string (MODULE_ERROR_DOMAIN_NAME) for that parameter each
 time I call g_set_error?
 
 That would make sense, from what I've read in the GQuark part of the
 API. But I'm a little confused because the example given in the API for
 g_set_error() usage does not do this. (In the example, they just pass in
 some mysterious constant of unexplained origin.)

The mysterious constants follow the common usage pattern.  For Bar in
package Foo, header:

#define FOO_BAR_ERROR foo_bar_error_quark()

GQuark foo_bar_error_quark(void) G_GNUC_CONST;

typedef enum {
FOO_BAR_ERROR_BAD_WHATEVER...
} FooBarError;

and code:

GQuark
foo_bar_error_quark(void)
{
return g_quark_from_static_string(foo-bar-error-quark);
}

You then do

g_set_error(error, FOO_BAR_ERROR, FOO_BAR_ERROR_BAD_WHATEVER, ...);

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to generate event explicit (through code) ?

2012-04-23 Thread David Nečas
On Mon, Apr 23, 2012 at 05:16:52PM +0530, Leena Chourey wrote:
 I want the focus to move selection/focus from one icon to another
 automatically on single key press. I have tried to just run key_press event
 code in a loop, but the selection is not moving from one to another, it is
 directly coming to the last item. it requires a h/w interruption
 (key_press) .
 
 As I understood, I need to generate the event key_press explicitly in the
 loop every time. How to generate gtk_event explicitly without any (h/w) key
 press?

I must admit that I do not actually understand what you are trying to
achieve (namely why you try to emulate key events).  Anyway:

Common keyboard control is usually defined by bindings, see
GtkBindingSet for start.  Maybe you just need to define bindings for the
required keys to make them move the selection.

If you want something special that does not correspond to the common
movements then register a key-press-event callback for the widget and
in that callback run gtk_widget_grab_focus() to move the focus where you
want, gtk_icon_view_select_path() to set the icon view selection, etc.
Return TRUE from the callback (most likely).

You might also want to manipulate the selection/focus by invoking action
signals of the wiget, e.g. the move-cursor signal for GtkIconView.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Replace context menu of GTK applications

2012-04-23 Thread David Nečas
On Mon, Apr 23, 2012 at 08:18:05PM +0200, Simon Schneegans wrote:
 I asked this question on another mailing list. There I got the hint
 to ask here, maybe you can help me!
 
 I'm going to write my bachelor thesis on different menu types (e.g.
 Pie Menus). For this reason I'd like to replace the context menu of
 GTK applications (the menu opened by right-clicking). I don't want
 to recompile those applications, some kind of plugin technique would
 be awesome!
 
 I thought of two possible approaches:
 
 1. - I know it's possible to do this with the main application menu
 (like all the different global menus are doing it).
 - So here's my question: Is that possible for context menus as
 well? Is there an API for this purpose? If so, what's the way to go?
 Documentation on this topic is very sparse...
 
 2. - Write a GTK module and try to do it with some GObject
 fancyness. May this work?

GtkMenuFoo classes use a number of internal Gtk+ calls and might not be
reasonably replaceable from outside.  So I suggest to simply change the
implementation of menus in Gtk+ source code, recompile it and let
programs use your modified Gtk+ (by setting LD_LIBRARY_PATH).  This is
trivial compared to your suggestions.  In any case, you may run into
some implicit assertions in the programs about how menus work.

Also, there is no fundamental difference between application, context
and whatever else menus.  They are all GtkMenu widgets and programs may
actually use a single GtkMenu object in different places.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: key press events holding keys down

2012-03-19 Thread David Nečas
On Mon, Mar 19, 2012 at 07:25:22PM +, Chris Vine wrote:
 Are you saying that on your hardware, holding one key down blocks press
 and release events for all other keys?  I am not saying you are
 wrong, but I find that surprising.

IMO Christopher observes this:
1) press A
2) press B while still holding A
3) release B while still holding A
You get no auto-repeat key events for A after 3) even though you still
hold it.

The solution can be either using something more low level(?) or simply
*NOT* getting your key events from Gdk key events and ignoring
autorepeat altogether.  (This is probably what has been – unclearly –
already suggested.)

You only use Gdk key events to get notifications that a key was
pressed or released – and update the set of pressed keys.  Then you use
a timer to regularly observe what keys are in the set of pressed keys.
And base the controls processing on what you find in the timer.  NOT the
Gdk key events themselves.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: noob question: g_signal_connect()

2012-03-06 Thread David Nečas
On Tue, Mar 06, 2012 at 10:07:16AM -0900, Christopher Howard wrote:
 Hi. I've installed the api documentation from the source code for both
 gtk+ and glib, but I can't seem to find an api description of
 g_signal_connect().

http://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-connect

 --
   g_signal_connect (G_OBJECT (button[0]), draw,
 G_CALLBACK (draw_callback), NULL);
 --
 
 Could somebody please explain two things:
 
 1) What is the purpose of the string in the second position in the
 parameter list?

That is the signal name – the same as listed in Signals section in the
description of each object.

 2) What is the purpose of the fourth parameter slot, with the NULL in
 it? Can other options go there?

It is a pointer that the callback function will get as its last
argument.  You can use it to pass additional data to the callback.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: TreeView tooltip use immediate control

2012-02-03 Thread David Nečas
On Fri, Feb 03, 2012 at 11:36:13PM +0100, Stefan Salewski wrote:
 How can I immediately activate or deactivate tooltips for all TreeView
 widgets on user action, i.e. menu operation.

You can enable/disable all tooltips using the gtk-enable-tooltips
GtkSettings property.

But if you want to enable/disable them just for some specific of widgets
you have to handle it yourself.  The easiest method is probably making
the widgets query your enable/disable setting in their query-tooltip
signal handlers – and then return TRUE or FALSE from the handlers.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: no File, Edit, Help strings in upper left

2012-01-29 Thread David Nečas
On Sun, Jan 29, 2012 at 02:36:03PM -0800, Gary Kline wrote:
   i've seen this  and don't like it; i'd rather have every
   Konsole have its own menubar.  same with other GUI apps.

Me too but OS X does this.  Aparrently, it does not matter nowadays
whether something makes sense or not but only whether OS X does it...

Some methods how to disable it are described here:

http://www.webupd8.org/2011/03/disable-appmenu-global-menu-in-ubuntu.html

In short, get rid of it globally:

sudo apt-get remove appmenu-gtk3 appmenu-gtk appmenu-qt

or disable it while running specific program:

UBUNTU_MENUPROXY= program args...

   at least for ubuntu linux, i
   need the `gtk-config --cflags [etc]` 

You definitely do NOT need gtk-config.  It was used in Gtk+ 1.x and has
been replaced with pkg-config.

   it may be hthat ubuntu is moving toward gtk-3.0   and
   dropping the older releases.  {?}

It should not be directly related to these issues although Gtk+ 3.x
indeed will bring new methods to do unexpected things to menus.

For me this all means classical application menubars are dead and I will
not use them in newly written programs at all.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: discoveries! gtk DOES dim... how can i infinite-loop?

2012-01-19 Thread David Nečas
On Thu, Jan 19, 2012 at 12:58:09AM -0800, Gary Kline wrote:
 i've spent the last many days tryoing [on ubuntu] anf tonight on my
 EEE-900A netbook [debian].  both dim when i go into a recursive
 loop.
 
 1.  edit with gvim
 2.  have espeak voice gvim when it is written
 3 goto 1;
 
 tonight i did everything absolutedly write in chercking various
 things, but the app still dimd if i have the function call itselg.
 
 i should have asked this list whether there there is  a gtk call
 that let's things go into  either  an infinite loop, or, would a
 for() loop work for 300-500 loops?
 
 if not, i need to rethink my algorithm.

That is probably what you have to do.

If I understand what your code does (and how) then while gvim is running
your app is *not*.  Your app is blocked and waits until gvim terminates.
The same for espeak.

You need to use a function such as g_spawn_async() to execute it.  Then
it depends how you communicate with the programs.  If you just want to
know when it terminates use waitpid().

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: any easy way of having a YES/NO dialog return a 1 or 0?

2012-01-17 Thread David Nečas
On Tue, Jan 17, 2012 at 04:12:51PM +0900, Tristan Van Berkom wrote:
 Even in english, these boolean YES/NO questions can seem ambiguous,

If you use wordy and convoluted questions such as

   Are you sure you want to quit without saving

then nothing can help the poor users.  Of course, they are also
susceptible to mistranslation.  The fix is brevity and clarity, not
banning Yes and No.  The question

Does 2+2 equal 5?

is not improved by buttons labels ‘It is five’ and ‘It is some other
number’.

Hence

Are you sure you want to quit without saving ?
 
 Should typically have the answers: Save Quit

is nonsense.  This question should not occur in a sensible GUI no matter
what answers are offered.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: how to have a dialog ask user if he want to type AGAIN?

2012-01-15 Thread David Nečas
On Sat, Jan 14, 2012 at 07:50:15PM -0800, Gary Kline wrote:
 ok, one function runs in a recursive loop, endlessly.  i could do this
 differently, say from main.  that is my question:  how do i get the
 value 1 or TRUE back from a dialogue that asks simply: Talk again?

Use the return value of gtk_dialog_run(); it returns
GTK_RESPONSE_something depending on how the user responded.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: any easy way of having a YES/NO dialog return a 1 or 0?

2012-01-15 Thread David Nečas
On Sun, Jan 15, 2012 at 01:26:53PM -0800, Gary Kline wrote:
 is there a way of having a YES/NO dialog [that asks a qauestion]
 return a truth value? i'm looking for something like the macro
 eprint(...) that James Steward sent in late december.

Use gtk_message_dialog_new() with GTK_BUTTONS_YES_NO buttons type.
Your boolean is then equal to

gtk_dialog_run(dialog) == GTK_RESPONSE_YES

(which also runs the dialog but you can, of course, separate the
execution and comparison).

 if i eventually figured out a similar marcro that included:
 
   GTK_STOCK_YES,1,
   GTK_STOCK_NO, 0...

I don't understand what stock item names have to do with this.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Real time removal of toolitem

2012-01-14 Thread David Nečas
On Sat, Jan 14, 2012 at 12:34:10PM +, Neil Munro wrote:
   I was wondering if it is possible to remove a tool item from a
 toolbar instantly,

=
from gi.repository import Gtk

def modify(b, t):
if t.get_n_items() == 1:
b.set_stock_id(Gtk.STOCK_REMOVE)
b2 = Gtk.ToolButton.new_from_stock(Gtk.STOCK_HELP)
b2.show_all()
t.insert(b2, 1)
else:
b.set_stock_id(Gtk.STOCK_ADD)
t.get_nth_item(1).destroy()
print t.get_n_items()

w = Gtk.Window()
w.connect('destroy', Gtk.main_quit)
w.set_default_size(200,40)

t = Gtk.Toolbar()
w.add(t)

b = Gtk.ToolButton.new_from_stock(Gtk.STOCK_ADD)
b.connect('clicked', modify, t)
t.insert(b, 0)

w.show_all()
Gtk.main()
=

 I have tried
 to destroy the widget but it still works, am I missing something

Yes.  Hard to tell what.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: RFC: UI design

2012-01-10 Thread David Nečas
On Tue, Jan 10, 2012 at 08:16:53PM +0100, Stefan Sauer wrote:
 On 01/09/2012 04:29 PM, Benjamin Otte wrote:
Who gets to decide how an application looks?
 
  This question is aimed at theming and the question of graphic
  design[1] and not at intersection design[2]. The way I see it, there
  is two extremes to this:
  A) The application decides on the theme
 
  B) The platform decides on the theme
 C) the user decides on the theme.

D) External constraints define the look.

So you like dark pink background.  Does it mean the PDF viewer should
try to give the viewed documents dark pink background?  Such question
might sound silly in case of PDF viewers but I develop mainly scieng
apps and here the boundary between controls and content is often much
fuzzier.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: troubles porting from ubuntu to debian. [??]

2012-01-02 Thread David Nečas
On Mon, Jan 02, 2012 at 12:15:45PM -0800, Gary Kline wrote:
 main.c:157: warning: implicit declaration of function ‘chdir’
 main.c:362: warning: implicit declaration of function ‘sleep’

Declared in unistd.h.  Forgot to include it?

 main.c: In function ‘inc_button_click_cb’:
 main.c:242: warning: implicit declaration of function
 ‘gtk_widget_is_sensitive’
 ...
 Here is the code that has gtk_widget_is_sensitive().  i gave up on
 this after a couple hours [last night].

gtk_widget_is_sensitive() appeared in Gtk+ 2.18.

Use devhelp or look at the on-line reference documentation to see when a
specific symbol appeared.

Use gtkdoc-depscan to scan your source code for functions that are
available only since a specific Gtk+ version.

Use GTK_WIDGET_IS_SENSITIVE() for compatibility with older Gtk+.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: troubles porting from ubuntu to debian. [??]

2012-01-02 Thread David Nečas
On Mon, Jan 02, 2012 at 02:42:43PM -0800, Gary Kline wrote:
   could you please explain more about this macro and how to
   resolve the complaint?

Use GTK_WIDGET_IS_SENSITIVE() instead of gtk_widget_is_sensitive().

   as you note, things do only now frown using the macro def:
 
   main.c:243: warning: implicit declaration of function
   ‘GTK_WIDGET_SET_SENSITIVE’
   main.c: In function ‘dec_button_click_cb’:
 
   how the heck to i fix that warning that GTK_WIDGET_IS_SENSITIVE() IS 
 *implicit*?

GTK_WIDGET_SET_SENSITIVE is not GTK_WIDGET_IS_SENSITIVE.

GTK_WIDGET_SET_SENSITIVE does not exist, there has always been a
function for this: gtk_widget_set_sensitive().

Also note there are two kinds of functions: the -get-/-set- kind and the
-is- kind, the former for querying/setting whether the widget can be
sensitive and the latter for querying whether it actually is sensitive.
See the documentation.

   this program works on ubuntu 11.10 which is a direct fork of
   debian.  i  was certain it would work on my laptop whivh has the
   latest debian.

Ubuntu contains a newer verison of Gtk+.  You cannot expect a program
developed with a newer version to work with an older version unless you
take care to use only functions that are present in the older version.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GTK app with scrolled window crashing trying to show a widget inside

2011-12-30 Thread David Nečas
On Fri, Dec 30, 2011 at 01:28:32PM +0100, Moritz Renftle wrote:
 i want to make one of those widgets visible from
 another thread

Use glib.idle_add() in that other thread to subsequently execute the
actual Gtk+ code in the thread running the Gtk+ main loop.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: focus line pattern around gtk event box

2011-12-20 Thread David Nečas
On Tue, Dec 20, 2011 at 11:24:44AM +0530, Guruprasad Bhat wrote:
 When I set the focus line pattern in rc file, dotted border comes around
 button widgtes, entry widgets when focus comes on that. But for event box,
 layout, even though i set Can focus flag TRUE  focus in indication is not
 appearing. How I can get the visual indication of focus in for gtk event
 box, gtk layout. Early suggestion appreciated.

Using gtk_paint_focus() in the draw handler to draw it if the widget
has focus.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: focus line pattern around gtk event box

2011-12-20 Thread David Nečas
On Tue, Dec 20, 2011 at 10:43:43PM +1100, Andrew Cowie wrote:
 On Tue, 2011-12-20 at 09:25 +0100, David Nečas wrote:
 
  Using gtk_paint_focus() in the draw handler...
 
 Deprecated now, apparently; refers to
 http://developer.gnome.org/gtk3/3.3/GtkStyleContext.html#gtk-render-focus
 instead.

No, I just mixed up Gtk+ 2 and 3 functions (sorry for that).

gtk_paint_focus() is the correct method to draw focus in Gtk+ 2, but you
do this in expose-event handler.  Use gtk_render_focus() in draw
handler if you use Gtk+ 3.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: How to extend a widget?

2011-12-16 Thread David Nečas
On Fri, Dec 16, 2011 at 04:09:54PM -0700, Michael Torrie wrote:
  1. Copy an entire GTK widget and give it a unique name.
  Example: GtkButton becomes GtkMyButton
 
 You really could Create a GtkMyButton by inheriting from GtkButton and
 adding your own code.  However, just as in C++, the ability to override
 specific methods depends on whether they were made as virtual or static
 methods.  static methods can't be overridden, but you could just shadow
 them with your own methods and use them instead.

I wish it was so.  What invariably happens in practice is this:

(a) You find that the widget implementation either provides some
library-level-private _gtk_button_foo() methods or depends on such
methods.  This is the absolutely worst case because it can easily
prevent even copying the code and creating a similarly behaving widget
if it needs to use these functions.  Unfortunately quite common.

(b) Other code in Gtk+ calls the static methods.  This means that you
cannot substitute your derived widget for the base class if you need
different behaviour (but you can happily use the derived widget in your
own code).  Apparently quite rare, possibly because the devs usually
convert this to (a) by making the static method library-private.

(c) To extend the virtual methods you would need to access parent widget
state which is private.  So you need to copy the implementation.  If you
do not run in to (a) or (b) then consider yourself lucky.

Note I do not talk about trivial extensions such as those you posted.
Could you write GtkToggleButton derived from GtkButton if it did not
exist?  Nope.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Usage of gtk_list_store_set_valuesv()

2011-12-10 Thread David Nečas
On Sat, Dec 10, 2011 at 08:16:39PM +0100, Antonio Weber wrote:
 I'm trying to write a small app which uses a GtkTreeView to display a
 table. For some reason it does not work as expected so I extracted my
 usage in a small tableTest app (which a attach to this mail).

You bind all view columns to model column 0.  So they all display the
data in column 0.  See your gtk_tree_view_column_new_with_attributes().

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Why cani i initialize prefix with a default string?

2011-12-09 Thread David Nečas
On Fri, Dec 09, 2011 at 05:40:09PM -0800, Gary Kline wrote:
   guys, i am appending a piece of gtk test code.  it saves the
   internal filename buffer for espeak -f %s ifbuf to run
   on--to be the user's voice.  if i set 
 
   static char *prefix = talk; 
 
   then back up and enter another string in the box at the
   bottom, strange things happen.  Anybody know where i am
   messing up?

Strange things most likely occur after attempting to free the const
string in entry_changed_cb()

g_free(prefix);

which was fine if prefix was NULL initially.  You can use -Wwrite-strings
to catch that.  Unforutnately, passing constant strings as various
user-data-kind arguments or to g_hash_table_insets() then produces
warnings too.

Also learn to use valgrind; it would show you this problem immediately.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GObjectClass.dispose and bringing objects back to life

2011-12-04 Thread David Nečas
On Sun, Dec 04, 2011 at 01:40:58PM +, Emmanuele Bassi wrote:
 
 this is, of course, not true: GNOME is full of badly written GObject
 code, mostly because it has been written at various stages of the
 learning process of various people. plus, the documentation is not
 entirely clear in a lot of places, thus the learning process can (and
 effectively is) broken.
 ...
 
 objects should obviously not be in a fully functional state after
 dispose - but they should be in a stable state, so that other objects
 referencing them from outside of the boundaries of their code space
 can still hold a valid reference to them, until such time that every
 reference can be released.

So, who thinks this idea is not actually inherently inconsistent please
please specify in the documentation, based on your rationale, how are
objects supposed to behave in the disposed state.  Namely with respect
to (not) keeping impossible invariants, returning nontrivial
no-longer-available values, methods that normally create or acquire
something before returning it and other practical issues.  Or say that
there can be certain things the object owners may not do with disposed
objects.  Or anything.  This

 The object is also expected to be able to answer client method
 invocations (with possibly an error code but no memory violation)
 until finalize is executed.

has as, a practical guide, approximately the same value as ‘people
should live together in peace’.

Thank you in advance,

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: Displaying domain objects with GtkTreeView

2011-12-02 Thread David Nečas
On Fri, Dec 02, 2011 at 03:55:51PM +0100, Rafał Krupiński wrote:
 I rather meant to use my object as a model for a whole, multi-column
 row, somehow binding fields or properties to columns.

It makes no sense (to me anyway) to imagine one object as multiple
*model* columns.

But it is easy to create an arbitrary M:N mapping between model rows and
view rows using the cell data functions, see
gtk_cell_layout_set_cell_data_func() which is probably the binding you
are looking for.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Displaying domain objects with GtkTreeView

2011-12-01 Thread David Nečas
On Thu, Nov 24, 2011 at 04:30:25PM +0100, Rafał Krupiński wrote:
 How do I display list of custom objects in GtkTreeView?
 GtkTreeView takes GtkListStore as a model, but it doesn't allow custom
 objects, only list of gobjects.
 
 On the other hand, when I want to read list's selection all I get is
 the GtkListStore model - list of gobjets and I have to figure out the
 actual domain object the data comes from.
 
 I thought of adding a hidden column with some id, but maybe there is a
 better solution?

What are you talking about?  You can pass any GObject-derived type as
the column type (not that it matters much, the net result is the same as
passing G_TYPE_OBJECT).  You get back the objects that you stored there.

If you store objects of different classes to the same column and want to
know the precise type use RTTI: type macros such as MY_IS_FOO(),
G_TYPE_FROM_INSTANCE(), g_type_is_a(), etc.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkHScale: Jump-to-position by left-click instead of middle-click?

2011-11-19 Thread David Nečas

Was it really necessary to cross-post this question to *four* mailing
lists?

On Sat, Nov 19, 2011 at 07:55:59AM -0500, Phong Cao wrote:
 I use GtkHScale for the progress bar, which is responsible for
 updating the track progress  allow user to move to different time position
 in the track.
 
 Everything works fine until now, except that I can not use left-click
 button to snap (or jump) to random position in the GtkHScale. Instead, I
 have to either drag or right-mouse-click.

The following is a kluge, but I suppose if you want the first button to
invoke the same response as the middle button it should be all right
(written in Python for brevity):

from gi.repository import Gtk

def button1to2(scale, event):
if event.button == 1:
event.button = 2
return False

adj = Gtk.Adjustment.new(0.0, 0.0, 1.0, 0.001, 0.01, 0)
scale = Gtk.Scale.new(Gtk.Orientation.HORIZONTAL, adj)
scale.set_round_digits(3)
scale.connect(button-press-event, button1to2)
scale.connect(button-release-event, button1to2)

window = Gtk.Window()
window.add(scale)
window.set_default_size(400, -1)
window.show_all()
window.connect(destroy, Gtk.main_quit)
Gtk.main()


Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Is this a memory leak?

2011-11-14 Thread David Nečas
On Wed, Nov 09, 2011 at 02:38:44PM +0100, Traktor Toni wrote:
 Hi, I'm using librsvg-2. Just calling rsvg_init() rsvg_term() tells  
 bytes possibly lost in valgrind at line g_type_init_with_debug_flags  
 inside rsvg_init().

Do you use nip2.supp?

 Also, why is it still calling g_type_init_with_debug_flags even though  
 I'm not compiling with any -g flag?

g_type_init() is just an alias for g_type_init_with_debug_flags() with
zero debug flags.  So type initialisation always goes through
g_type_init_with_debug_flags().  And the flags are GObject debugging
flags they have nothing to do with the debugging info put into binaries
by the C compiler.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: gtk and linux

2011-11-03 Thread David Nečas
On Thu, Nov 03, 2011 at 04:07:44AM -0400, Craig wrote:
 Is there a list of linux flavors like Ubuntu, KDE, Red Hat... that
 include or don't include gtk?

Use distrowatch.  It lists the packaged version of Gtk+ for every
version of the distribtion.  E.g. for Fedora:

http://distrowatch.com/table.php?distribution=fedora

and see the row labelled gtk+.  Distros that do not package Gtk+ at all
are very rare (mosty those not including any GUI whatsoever).

 And, let's say that a type of linux
 doesn't include gtk, how difficult is it for an average computer user to
 install gtk (on a scale of 1 to 10)?

8.47654138908745330124567, maybe 8.47654138908745330124568.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Severe treeview performance regression (Gtk2 - gtk3)

2011-10-20 Thread David Nečas
On Thu, Oct 20, 2011 at 09:45:10PM +0100, Lionel Landwerlin wrote:
 GtkList isn't based on treeview AFAIK

Please look at the source code before making such remarks.

Anyway, I was about to note that I observed the Gtk+3 version to be
faster (both version from Fedora 15 packages).  But then I realized that
while Gtk+3 uses the default theme the Gtk+2 theme is Glider.  After
fixing that the subjective performance was pretty much the same.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: _wstat on Windows (actually stat stuff in general)

2011-09-29 Thread David Nečas
On Thu, Sep 29, 2011 at 10:05:57AM +0100, Emmanuele Bassi wrote:
 On 29 September 2011 09:57, Andrew W. Nosenko
 andrew.w.nose...@gmail.com wrote:
  On Thu, Sep 29, 2011 at 11:35, Tor Lillqvist t...@iki.fi wrote:
  I would say, bah. Any actively maintained (or recently written)
  GLib-using code that doesn't use GIO by now is just being maintained
  or written in a misguided fashion.
 
  Tor, did I understand your position right that any program written in
  the speed in minds and uses Glib is written in a misguided fashion?
 
 that's a fairly creative way of misinterpreting that sentence.
 
 if GIO is measurably slower at doing I/O than a stat(), please: file
 bugs along with profiling data.

I wish GLib was the nice utility library it used to be.  A utility
library provides functionality people find useful; there is no agenda
and consequently no need to tell people they are misguided if they just
want to use the functionality they find useful and do not want use
specific complex frameworks because they find them cumbersome.

Yeti

___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: configuration file, with dot or gnome structure

2011-09-13 Thread David Nečas
On Tue, Sep 13, 2011 at 01:43:06PM +0430, Mohsen Pahlevanzadeh wrote:
 You know that if install a package, may be it creates a directory in
 your home directory which begin dot. Such as .purple (pidgin appl)
 Recently i see many of appl such as evolution don't use this method and
 use .local .gnome2 .gnome or so on.
 I don't know different between them and don't know any idea on them, dot
 or gnoem configuration.
 
 I'm starting to write a appl with GTK and confused to decide dot method
 or gnome structure. if gnome structure is better, can you give me clue
 about its APIs?

To follow XDG use g_get_user_config_dir(), g_get_user_data_dir() and
similar functions to obtain the base directory names and use app-named
subdirectories of that.

The XDG scheme works for classic desktop applications.  It makes much
less sense though if your program has for instance files that are
config, data and scripts at the same time and they are expected to be
created and edited manually... (imagine bash for an extreme example).

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How to detect when user scrolls

2011-09-05 Thread David Nečas
On Mon, Sep 05, 2011 at 02:37:32PM +0100, Andrew Wood wrote:
 However in the mainwindow is a GtkScrolledWindow, and although its  
 detecting mouse movement over the display area, if the user is just  
 moving the scrollbarsandnot doing anything else, as they would if  
 reading through some text, it doesnt detect it.

 I've tried the following, on both the GtkScrolledWindow  
 (browserscrolledview) and the mainwindow (GtkWindow) but to no avail:

 
 g_signal_connect(G_OBJECT(browserscrolledview),scroll-event,G_CALLBACK(userActive),NULL);
  
 //will be called when user scrolls in display area

 How do I detect when the scrollbars move?

Connect to value-changed signal of the GtkScrolledWindow's
adjustments.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Using the same model in two treeview and prevent selecting the same item?

2011-08-24 Thread David Nečas
On Wed, Aug 24, 2011 at 03:50:46PM +0200, Michal Suchanek wrote:
 I have a list which I want to display in two treeviews and prevent
 selecting the same item in both.
 
 The idea is that the user selects an item in the first list, then the
 second list is shown, and it should not contain the item selected in
 the first list (or the item should be inactive or whatever).
 
 I tried using a model filter to this end. It has an option to set
 custom filter callback and in this callback I fetch the selection of
 the first list (if any) and return false if the filtered item is the
 same as selected.

I would just render the item as inactive using cell renderer's
sensitive property and prevent it from being selected using
gtk_tree_selection_set_select_function().  You need to remember the
current selection but otherwise it is pretty cheap: if the selected row
changes only two rows have to receive row-changed to update the other
treeview: the previously selected one (becomes selectable) and the newly
selected one (becomes unselectable).  Also, depending on the application
this might be visually preferrable to appearing and disappearing rows.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: HScale don't move

2011-08-09 Thread David Nečas
On Tue, Aug 09, 2011 at 02:24:30PM +0800, Xi Yang wrote:
 I changed both page size and page increment to 0, and the slider moves. 
 However, why I get an initial value of 0, instead of 5?
 

By changing the value property:

 property name=value5/property

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: How can I get argc and argv from Gtk+ API?

2011-08-09 Thread David Nečas
On Tue, Aug 09, 2011 at 03:19:16PM +0800, zxx zxx wrote:
 I have some experience in Qt but not Gtk+. I can get argc and argv from
 Qt API when I develop application with Qt4:
 QCoreApplication::argc();
 QCoreApplication::argv();
 
 But I don't know how to get argc and argv from Gtk+ API when I develop
 application with Gtk+.
 Does anyone know how to get argc and argv from Gtk+ API? please tell
 me.

You get argc and argv as arguments to your main() function as usual.

Or from the GApplicationCommandLine argment passed to your
command-line handler of GtkApplication/GApplication if you use the
GApplication framework.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


  1   2   >