[Geany-Users] Creating a Plugin for Microcontrollers-STM8dev

Colomban Wendling lists.ban at xxxxx
Fri Nov 1 13:25:59 UTC 2013


Le 01/11/2013 07:19, lmx a écrit :
> hi guys,

Hi,

> [...]
> The problem is...I can't change their name..it inherit the name of the
> IDE(Geany) :S.
> 
> I created it with:
> 
> #include <gtk/gtk.h>
> 
> GtkWidget *window=gtk_window_new (GTK_WINDOW_TOPLEVEL);
> //gtk_window_set_title(window->window,"STM8dev");
> 
> I tried(like you can see in the picture) with gtk directly, but it won't
> work :S
> 
> Any Idea?

You need to read a bit about GTK I think :)  Try to find a tutorial to
get the basic concepts used by GTK so you'll be able to understand the
docs easily.  There probably are a few on the web, but you can start
with the GTK one
https://developer.gnome.org/gtk3/stable/gtk-getting-started.html

But here you just need to call `gtk_window_set_title(GTK_WINDOW(window),
STM8dev")`.  window->window is a GTK internal and represents a low-level
platform primitive you don't wanna deal with (and BTW, since version 3
of GTK, you can't access private members like that anymore).

> I started with gtk, because I don't know if it possible to do it in the
> Geany glade xml...?

Geany uses GTK and don't re-create the wheel, so you're in the right
direction using GTK :)

> Another problem, is like you can see, the button(big button), have a
> listener associated with, but if I click it, in the first time...it does
> nothing...in the second it shutdowns, the GEANY IDE :S ??!!but I don 
> know if it kills that window in memory...
> 
> I done it with:
>  
>     gint delete( GtkWidget *widget,GtkWidget *event,gpointer   data ){
>         gtk_main_quit();    //------>what is the main windows??????Geany
> or STM8dev plugin??????????????????
>         return(FALSE);
>     }
> ...
>     button = gtk_button_new_with_label ("close-One more?None?Don't know");
>     gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
>                                GTK_SIGNAL_FUNC (delete), NULL);
>     gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,1,2);
>     gtk_widget_show(button);

First, your handler signature is wrong for that signal, see
https://developer.gnome.org/gtk3/stable/GtkButton.html#GtkButton-clicked

So your "delete" handler should be like `void delete(GtkWidget*, gpointer)`.

Also, gtk_main_quit() quits the GTK even loop, which basically means
quitting the application.
https://developer.gnome.org/gtk3/stable/gtk3-General.html#gtk-main-quit

What you want to do is using `gtk_widget_destroy()` on your window
widget if you want to destroy the window.

Also, don't use GTK_OBJECT or GTK_SIGNAL_FUNC, those are deprecated
since forever in favor of GObjet's equivalents, G_OBJECT and G_CALLBACK
(https://developer.gnome.org/gobject/stable/).  GObject is the object
system library used by GTK.

Regards,
Colomban


More information about the Users mailing list