-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
AC_DEFUN([GP_CHECK_PINNER], | ||
[ | ||
GP_ARG_DISABLE([pinner], [auto]) | ||
GP_COMMIT_PLUGIN_STATUS([Pinner]) | ||
AC_CONFIG_FILES([ | ||
pinner/Makefile | ||
]) | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
include $(top_srcdir)/build/vars.build.mk | ||
|
||
plugin = pinner | ||
|
||
geanyplugins_LTLIBRARIES = pinner.la | ||
|
||
pinner_la_SOURCES = \ | ||
pinner.c | ||
|
||
pinner_la_CPPFLAGS = $(AM_CPPFLAGS) \ | ||
-DG_LOG_DOMAIN=\"Pinner\" | ||
|
||
pinner_la_CFLAGS = \ | ||
$(AM_CFLAGS) \ | ||
-fsanitize=address,undefined | ||
|
||
pinner_la_LDFLAGS = \ | ||
$(AM_LDFLAGS) \ | ||
-fsanitize=address,undefined | ||
|
||
pinner_la_LIBADD = \ | ||
$(COMMONLIBS) | ||
|
||
AM_CPPCHECKFLAGS = -DSCE_PAS_DEFAULT=0 | ||
include $(top_srcdir)/build/cppcheck.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* pinner.c | ||
* | ||
* Copyright 2024 Andy Alt <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
* | ||
* | ||
*/ | ||
|
||
#include <geanyplugin.h> | ||
|
||
static GtkWidget *pinned_view_vbox; | ||
static gint page_number = 0; | ||
|
||
struct pindata { | ||
GeanyPlugin *plugin; | ||
GSList *list; | ||
}; | ||
|
||
static struct pindata *init_pindata(GeanyPlugin *plugin) | ||
{ | ||
static struct pindata container = { | ||
NULL, | ||
NULL | ||
}; | ||
return &container; | ||
} | ||
|
||
static void pin_activate_cb(GtkMenuItem *menuitem, gpointer pdata) | ||
{ | ||
struct pindata *container = pdata; | ||
GeanyPlugin *plugin = container->plugin; | ||
GSList *list = container->list; | ||
|
||
GeanyDocument *doc = document_get_current(); | ||
// Let's not add the pointer to the list, otherwise | ||
// it won't be around when the function returns. | ||
// We might find that it's better to store *doc to the list | ||
// in which case we'll need to use malloc() | ||
gchar tmp_file_name[strlen(doc->file_name) + 1]; | ||
strcpy(tmp_file_name, doc->file_name); | ||
|
||
if (doc != NULL) | ||
{ | ||
list = g_slist_append(list, tmp_file_name); | ||
GtkWidget *label = gtk_label_new_with_mnemonic(doc->file_name); | ||
gtk_widget_show(label); | ||
gtk_box_pack_start(GTK_BOX(pinned_view_vbox), label, FALSE, FALSE, 0); | ||
gtk_notebook_set_current_page(GTK_NOTEBOOK(plugin->geany_data->main_widgets->sidebar_notebook), page_number); | ||
} | ||
} | ||
|
||
|
||
static gboolean pin_init(GeanyPlugin *plugin, gpointer pdata) | ||
{ | ||
GtkWidget *main_menu_item; | ||
|
||
struct pindata *container = init_pindata(plugin); | ||
container->plugin = plugin; | ||
|
||
// Create a new menu item and show it | ||
main_menu_item = gtk_menu_item_new_with_mnemonic("Pin Document"); | ||
gtk_widget_show(main_menu_item); | ||
gtk_container_add(GTK_CONTAINER(plugin->geany_data->main_widgets->tools_menu), | ||
main_menu_item); | ||
g_signal_connect(main_menu_item, "activate", | ||
G_CALLBACK(pin_activate_cb), container); | ||
|
||
geany_plugin_set_data(plugin, main_menu_item, NULL); | ||
|
||
pinned_view_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); | ||
gtk_widget_show_all(pinned_view_vbox); | ||
page_number = gtk_notebook_append_page(GTK_NOTEBOOK(plugin->geany_data->main_widgets->sidebar_notebook), | ||
pinned_view_vbox, gtk_label_new(_("Pinned"))); | ||
return TRUE; | ||
} | ||
|
||
|
||
static void pin_cleanup(GeanyPlugin *plugin, gpointer pdata) | ||
{ | ||
GtkWidget *main_menu_item = (GtkWidget *) pdata; | ||
|
||
gtk_widget_destroy(main_menu_item); | ||
} | ||
|
||
|
||
G_MODULE_EXPORT | ||
void geany_load_module(GeanyPlugin *plugin) | ||
{ | ||
plugin->info->name = "Pinner"; | ||
plugin->info->description = "Pin a document"; | ||
plugin->info->version = "0.1.0"; | ||
plugin->info->author = "Andy Alt <[email protected]>"; | ||
|
||
plugin->funcs->init = pin_init; | ||
plugin->funcs->cleanup = pin_cleanup; | ||
|
||
GEANY_PLUGIN_REGISTER(plugin, 225); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,8 @@ | |
# geanyvc | ||
geanyvc/src/commit.glade | ||
|
||
# Pinner | ||
pinner/pinner.c | ||
|
||
# WebHelper | ||
webhelper/src/gwh-enum-types.c |