-1

Excuse me, I am a newbie. I am trying learning reading the very simple text editor for xfce4: mousepad. But in it I can see two broken symbols mousepad_window_get_type and mousepad_application_get_type

/home/utente/Desktop/mousepad-master/mousepad/mousepad-window.h:
   22  G_BEGIN_DECLS
   23  
   24: #define MOUSEPAD_TYPE_WINDOW            (mousepad_window_get_type ())
   25  #define MOUSEPAD_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOUSEPAD_TYPE_WINDOW, MousepadWindow))
   26  #define MOUSEPAD_WINDOW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), MOUSEPAD_TYPE_WINDOW, MousepadWindowClass))
   ..
   44  typedef struct _MousepadWindow      MousepadWindow;
   45  
   46: GType           mousepad_window_get_type         (void) G_GNUC_CONST;
   47  
   48  GtkWidget      *mousepad_window_new              (void);



/home/utente/Desktop/mousepad-master/mousepad/mousepad-application.h:
   25  typedef struct _MousepadApplication      MousepadApplication;
   26  
   27: #define MOUSEPAD_TYPE_APPLICATION            (mousepad_application_get_type ())
   28  #define MOUSEPAD_APPLICATION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOUSEPAD_TYPE_APPLICATION, MousepadApplication))
   29  #define MOUSEPAD_APPLICATION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), MOUSEPAD_TYPE_APPLICATION, MousepadApplicationClass))
   ..
   32  #define MOUSEPAD_APPLICATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), MOUSEPAD_TYPE_APPLICATION, MousepadApplicationClass))
   33  
   34: GType                mousepad_application_get_type               (void) G_GNUC_CONST;
   35  
   36  MousepadApplication *mousepad_application_get                    (void);
Hardplus
  • 1
  • 3
  • What do you mean by "broken symbols"? Can you please elaborate? – Some programmer dude Jul 30 '17 at 15:47
  • Those symbols are unreferred. – Hardplus Jul 30 '17 at 16:22
  • Those symbols are not in source files – Hardplus Jul 30 '17 at 16:22
  • Please edit the question to clarify your problem. As a general rule, don't include line numbers on the LHS of code in a question. It would be reasonable to specify a range of line numbers in the heading. How are you linking your code? Did you build the xfce libraries you're using? How have you shown that the symbols are not present in the relevant libraries? Have you checked which libraries are in use? – Jonathan Leffler Jul 30 '17 at 16:26
  • As I wrote, I am reading sources that I downloaded from official repository – Hardplus Jul 30 '17 at 16:31
  • So some header files declares functions that is not definef *nor called* in any source file for any part of Xfce? That's not an error, or a problem really. – Some programmer dude Jul 30 '17 at 16:35
  • Those symbols are used from other files – Hardplus Jul 30 '17 at 16:38
  • MousepadApplication* mousepad_application_get (void) { static MousepadApplication *application = NULL; if (G_UNLIKELY (application == NULL)) { application = g_object_new (MOUSEPAD_TYPE_APPLICATION, NULL); g_object_add_weak_pointer (G_OBJECT (application), (gpointer) &application); } else { g_object_ref (G_OBJECT (application)); } return application; } – Hardplus Jul 30 '17 at 16:38
  • And you checked *every* part of every library in Xfce and it's not defined in any source file? How about *makefiles*? Or *script* files? Maybe it's auto-generated? If it builds without linker errors, then it must be defines *somewhere*. Or the code where it's called is simply not used? Have you checked the context (surrounding source) for conditional compilation? – Some programmer dude Jul 30 '17 at 16:41
  • If I compile it runs, but i am READING sources. And i need understand in order to learn! – Hardplus Jul 30 '17 at 16:44
  • Then you need to look outside the header and source files. Do a recursive `grep` for it in the root directory. – Some programmer dude Jul 30 '17 at 17:45

2 Answers2

0

Those symbols are probably defined in other header files of the project. Do a $ grep -nr mousepad_window_get_type . in your project directory. This will show you all available usages of the word mousepad_window_get_type. However you will most likely not find these symbols defined anywhere in the project, as I suspect them to be functions which are available in one of the libraries you link against when compiling your project.

SCCC
  • 341
  • 3
  • 13
0

The *_get_type functions are defined by the G_DEFINE_TYPE macro. They could also be declared by G_DECLARE_FINAL_TYPE or G_DECLARE_DERIVABLE_TYPE, but that's not the case for mousepad.

Xfce's projects are written in GTK+, so you need to learn it first otherwise you'll find some code parts confusing. You can find lots of tutorials for GTK+/GObject/GLib and their documentations is (hopefully) comprehensive. The GLib/GTK+ Development Platform is great start for beginners.

AndreLDM
  • 2,117
  • 1
  • 18
  • 27
  • Those symbols are not called from an use of G_DEFINE_TYPE macro. They are alone in two rows of code! – Hardplus Jul 31 '17 at 05:24
  • No, but `mousepad_window_get_type` is "aliased" by the `MOUSEPAD_TYPE_WINDOW` macro and is used as `g_object_new (MOUSEPAD_TYPE_WINDOW, NULL)`. It's just GOjbect idiosyncrasy. – AndreLDM Jul 31 '17 at 14:07