[Glade-users] Building a simple composite widget?

On Tue, 2018-02-20 at 16:03 -0600, Pat Riehecky wrote:
I'm trying to build a set of reusable widgets.  Basically I have a
of places where I need the same dropdown boxes.  Each box may have a 
different selected value (Instance A uses Index 1 while Instance B
Index 2), but the items in the list are the same.

I'm really just looking to build a set of Pre-populated
items - A simplified example is attached.

I'd prefer to store the possible enum values within a widget and
interrogate it rather than a bunch of "GtkListStore" items I need to 
edit over and over.

Is there a way I can convert the attached "ProtocolDropdown" object
a widget?  I'd want it to stay associated with the "Protocols" 

Building a C program to track this feels like massive overkill, but
don't see a way to "Export object as widget".

First of all you have to make your custom GtkComboBox derived class


(In Glade check the composite checkbox next to widget ID to make that
toplevel a composite template)

Then you will need to write a custom catalog for Glade to know about
your new widget


AS the first implementation you do not need to load your library in
Glade you can simply define your new class and add parent="GtkComboBox"

Something like...

<?xml version="1.0" encoding="UTF-8"?>
<glade-catalog name="custom"

    <glade-widget-class name="MyComboBox"
  <glade-widget-group name="custom" title="Custom Widgets">
    <glade-widget-class-ref name="MyComboBox"/>


should do the trick after you save the catalog in a place specified in
Glade->preferences->Extra catalog paths

hope this helps


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