Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
G
geany
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
geany
Commits
13ec6ffb
Kaydet (Commit)
13ec6ffb
authored
Haz 09, 2013
tarafından
Matthew Brush
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add new API function plugin_builder_connect_signals()
üst
e949ff88
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
2 deletions
+91
-2
geanyfunctions.h
plugins/geanyfunctions.h
+2
-0
plugindata.h
src/plugindata.h
+2
-1
plugins.c
src/plugins.c
+2
-1
pluginutils.c
src/pluginutils.c
+82
-0
pluginutils.h
src/pluginutils.h
+3
-0
No files found.
plugins/geanyfunctions.h
Dosyayı görüntüle @
13ec6ffb
...
...
@@ -32,6 +32,8 @@
geany_functions->p_plugin->plugin_timeout_add_seconds
#define plugin_idle_add \
geany_functions->p_plugin->plugin_idle_add
#define plugin_builder_connect_signals \
geany_functions->p_plugin->plugin_builder_connect_signals
#define document_new_file \
geany_functions->p_document->document_new_file
#define document_get_current \
...
...
src/plugindata.h
Dosyayı görüntüle @
13ec6ffb
...
...
@@ -55,7 +55,7 @@ G_BEGIN_DECLS
* @warning You should not test for values below 200 as previously
* @c GEANY_API_VERSION was defined as an enum value, not a macro.
*/
#define GEANY_API_VERSION 21
6
#define GEANY_API_VERSION 21
7
/* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins
* with GTK3-linked Geany leads to crash */
...
...
@@ -666,6 +666,7 @@ typedef struct PluginFuncs
guint
(
*
plugin_timeout_add_seconds
)
(
GeanyPlugin
*
plugin
,
guint
interval
,
GSourceFunc
function
,
gpointer
data
);
guint
(
*
plugin_idle_add
)
(
GeanyPlugin
*
plugin
,
GSourceFunc
function
,
gpointer
data
);
void
(
*
plugin_builder_connect_signals
)
(
GeanyPlugin
*
plugin
,
GtkBuilder
*
builder
,
gpointer
user_data
);
}
PluginFuncs
;
...
...
src/plugins.c
Dosyayı görüntüle @
13ec6ffb
...
...
@@ -86,7 +86,8 @@ static PluginFuncs plugin_funcs = {
&
plugin_show_configure
,
&
plugin_timeout_add
,
&
plugin_timeout_add_seconds
,
&
plugin_idle_add
&
plugin_idle_add
,
&
plugin_builder_connect_signals
};
static
DocumentFuncs
doc_funcs
=
{
...
...
src/pluginutils.c
Dosyayı görüntüle @
13ec6ffb
...
...
@@ -395,4 +395,86 @@ void plugin_show_configure(GeanyPlugin *plugin)
}
struct
BuilderConnectData
{
gpointer
user_data
;
GeanyPlugin
*
plugin
;
};
static
void
connect_plugin_signals
(
GtkBuilder
*
builder
,
GObject
*
object
,
const
gchar
*
signal_name
,
const
gchar
*
handler_name
,
GObject
*
connect_object
,
GConnectFlags
flags
,
gpointer
user_data
)
{
gpointer
symbol
=
NULL
;
struct
BuilderConnectData
*
data
=
user_data
;
if
(
!
g_module_symbol
(
data
->
plugin
->
priv
->
module
,
handler_name
,
&
symbol
))
{
g_warning
(
"Failed to locate signal handler for '%s': %s"
,
signal_name
,
g_module_error
());
return
;
}
plugin_signal_connect
(
data
->
plugin
,
object
,
signal_name
,
FALSE
,
G_CALLBACK
(
symbol
)
/*ub?*/
,
data
->
user_data
);
}
/**
* Allows auto-connecting Glade/GtkBuilder signals in plugins.
*
* When a plugin uses GtkBuilder to load some UI from file/string,
* the gtk_builder_connect_signals() function is unable to automatically
* connect to the plugin's signal handlers. A plugin could itself use
* the gtk_builder_connect_signals_full() function to automatically
* connect to the signal handler functions by loading it's GModule
* and retrieving pointers to the handler functions, but rather than
* each plugin having to do that, this function handles it automatically.
*
* @code
* ...
* GeanyPlugin *geany_plugin;
*
* G_MODULE_EXPORT void
* myplugin_button_clicked(GtkButton *button, gpointer user_data)
* {
* g_print("Button pressed\n");
* }
*
* void plugin_init(GeanyData *data)
* {
* GtkBuilder *builder = gtk_builder_new();
* gtk_builder_add_from_file(builder, "gui.glade", NULL);
* plugin_builder_connect_signals(geany_plugin, builder, NULL);
* ...
* }
* @endcode
*
* @note It's important that you prefix your callback handlers with
* a plugin-specific prefix to avoid clashing with other plugins since
* the function symbols will be exported process-wide.
*
* @param plugin Must be @ref geany_plugin.
* @param builder The GtkBuilder to connect signals with.
* @param user_data User data to pass to the connected signal handlers.
*
* @since 1.24, plugin API 217.
*/
void
plugin_builder_connect_signals
(
GeanyPlugin
*
plugin
,
GtkBuilder
*
builder
,
gpointer
user_data
)
{
struct
BuilderConnectData
data
=
{
NULL
};
g_return_if_fail
(
plugin
!=
NULL
&&
plugin
->
priv
!=
NULL
);
g_return_if_fail
(
plugin
->
priv
->
module
!=
NULL
);
g_return_if_fail
(
GTK_IS_BUILDER
(
builder
));
data
.
user_data
=
user_data
;
data
.
plugin
=
plugin
;
gtk_builder_connect_signals_full
(
builder
,
connect_plugin_signals
,
&
data
);
}
#endif
src/pluginutils.h
Dosyayı görüntüle @
13ec6ffb
...
...
@@ -53,5 +53,8 @@ struct GeanyKeyGroup *plugin_set_key_group(struct GeanyPlugin *plugin,
void
plugin_show_configure
(
struct
GeanyPlugin
*
plugin
);
void
plugin_builder_connect_signals
(
struct
GeanyPlugin
*
plugin
,
GtkBuilder
*
builder
,
gpointer
user_data
);
#endif
/* HAVE_PLUGINS */
#endif
/* GEANY_PLUGINUTILS_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment