Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagar Chalise committed Jun 12, 2016
2 parents cea797b + f66df03 commit 607cab9
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 162 deletions.
8 changes: 4 additions & 4 deletions codenav/src/codenavigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ PLUGIN_SET_TRANSLATABLE_INFO(
_( "This plugin adds features to facilitate navigation between source files."),
CODE_NAVIGATION_VERSION, "Lionel Fuentes, Federico Reghenzani")

/* Declare "GeanyKeyGroupInfo plugin_key_group_info[1]" and "GeanyKeyGroup *plugin_key_group",
* for Geany to find the keybindings */
PLUGIN_KEY_GROUP(code_navigation, NB_KEY_IDS)


/********************* Data types for the feature *********************/
/* Column for the configuration widget */
Expand All @@ -64,6 +60,8 @@ typedef enum
GeanyPlugin *geany_plugin;
GeanyData *geany_data;

GeanyKeyGroup *plugin_key_group;

static GtkListStore *list_store; /* for settings dialog */


Expand Down Expand Up @@ -100,6 +98,8 @@ void plugin_init(GeanyData *data)
{
log_func();

plugin_key_group = plugin_set_key_group(geany_plugin, "code_navigation", NB_KEY_IDS, NULL);

/* Load configuration */
load_configuration();
/* Initialize the features */
Expand Down
11 changes: 1 addition & 10 deletions codenav/src/codenavigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,17 @@
#define CODENAVIGATION_H

/* First */
#include "geany.h" /* for the GeanyApp data type */
#include <geanyplugin.h>

/* Other includes */
#include "editor.h" /* for the declaration of the GeanyEditor struct, not strictly necessary
as it will be also included by plugindata.h */
#include "document.h" /* for the declaration of the GeanyDocument struct */
#include "ui_utils.h"
#include "Scintilla.h" /* for the SCNotification struct */

#include "keybindings.h"
#include "filetypes.h"
#include <gdk/gdkkeysyms.h>

#include <string.h>

#include "switch_head_impl.h"

/* Last */
#include "plugindata.h" /* this defines the plugin API */

/* Debug flag */
/*#define CODE_NAVIGATION_DEBUG*/

Expand Down
41 changes: 16 additions & 25 deletions geanydoc/src/geanydoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "geanydoc.h"

/* These items are set by Geany before init() is called. */
PluginFields *plugin_fields;
GeanyPlugin *geany_plugin;
GeanyData *geany_data;

static GtkWidget *keyb1;
Expand All @@ -51,18 +51,16 @@ PLUGIN_SET_TRANSLATABLE_INFO(LOCALEDIR, GETTEXT_PACKAGE,
"Yura Siamshka <yurand2@gmail.com>")

/* Keybinding(s) */
enum
{
KB_DOCUMENT_WORD,
KB_DOCUMENT_WORD_ASK,
KB_COUNT
};

PLUGIN_KEY_GROUP(doc_chars, KB_COUNT)
enum
{
KB_DOCUMENT_WORD,
KB_DOCUMENT_WORD_ASK,
KB_COUNT
};

GtkWidget *create_Interactive(void);
GtkWidget *create_Interactive(void);

static gboolean word_check_left(gchar c)
static gboolean word_check_left(gchar c)
{
if (g_ascii_isalnum(c) || c == '_' || c == '.')
return TRUE;
Expand All @@ -80,24 +78,17 @@ word_check_right(gchar c)
static gchar *
current_word(void)
{
gchar *txt;
GeanyDocument *doc;

gint pos;
gint cstart, cend;
gchar c;
gint text_len;

doc = document_get_current();
g_return_val_if_fail(doc != NULL && doc->file_name != NULL, NULL);

text_len = sci_get_selected_text_length(doc->editor->sci);
if (text_len > 1)
{
txt = g_malloc(text_len + 1);
sci_get_selected_text(doc->editor->sci, txt);
return txt;
}
if (sci_has_selection(doc->editor->sci))
return sci_get_selection_contents(doc->editor->sci);

pos = sci_get_current_position(doc->editor->sci);
if (pos > 0)
Expand Down Expand Up @@ -129,10 +120,8 @@ current_word(void)

if (cstart == cend)
return NULL;
txt = g_malloc0(cend - cstart + 1);

sci_get_text_range(doc->editor->sci, cstart, cend, txt);
return txt;
return sci_get_contents_range(doc->editor->sci, cstart, cend);
}

/* name should be in UTF-8, and can have a path. */
Expand Down Expand Up @@ -433,6 +422,7 @@ create_Configure(void)
void
plugin_init(G_GNUC_UNUSED GeanyData * data)
{
GeanyKeyGroup *key_group;
gchar *kb_label1;
gchar *kb_label2;

Expand All @@ -444,9 +434,10 @@ plugin_init(G_GNUC_UNUSED GeanyData * data)
keyb1 = gtk_menu_item_new();
keyb2 = gtk_menu_item_new();

keybindings_set_item(plugin_key_group, KB_DOCUMENT_WORD, kb_doc,
key_group = plugin_set_key_group(geany_plugin, "doc_chars", KB_COUNT, NULL);
keybindings_set_item(key_group, KB_DOCUMENT_WORD, kb_doc,
0, 0, kb_label1, kb_label1, keyb1);
keybindings_set_item(plugin_key_group, KB_DOCUMENT_WORD_ASK, kb_doc_ask,
keybindings_set_item(key_group, KB_DOCUMENT_WORD_ASK, kb_doc_ask,
0, 0, kb_label2, kb_label2, keyb2);
}

Expand Down
12 changes: 6 additions & 6 deletions geanyinsertnum/src/insertnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static void set_entry(GtkWidget *entry, gint maxlen, GtkWidget *label, const gch
gtk_entry_set_max_length(GTK_ENTRY(entry), maxlen);
gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry);
ui_widget_set_tooltip_text(entry, tooltip);
gtk_widget_set_tooltip_text(entry, tooltip);
}

#if !GTK_CHECK_VERSION(3, 0, 0)
Expand Down Expand Up @@ -376,20 +376,20 @@ static void on_insert_numbers_activate(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GN
gtk_table_attach(grid, GTK_WIDGET(combo), 1, 3, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
#endif
label = gtk_label_new(_("Letters:"));
ui_widget_set_tooltip_text(label, case_tip);
gtk_widget_set_tooltip_text(label, case_tip);
gtk_grid_attach(grid, label, 3, 1, 1, 1);
upper = gtk_radio_button_new_with_mnemonic(NULL, _("_Upper"));
ui_widget_set_tooltip_text(upper, case_tip);
gtk_widget_set_tooltip_text(upper, case_tip);
gtk_grid_attach(grid, upper, 4, 1, 1, 1);
d.lower = gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(upper));
ui_widget_set_tooltip_text(label, case_tip);
gtk_widget_set_tooltip_text(label, case_tip);
label = gtk_label_new_with_mnemonic(_("_Lower"));
ui_widget_set_tooltip_text(label, case_tip);
gtk_widget_set_tooltip_text(label, case_tip);
gtk_container_add(GTK_CONTAINER(d.lower), label);
gtk_grid_attach(grid, d.lower, 5, 1, 1, 1);

d.prefix = gtk_check_button_new_with_mnemonic(_("Base _prefix"));
ui_widget_set_tooltip_text(d.prefix,
gtk_widget_set_tooltip_text(d.prefix,
_("0 for octal, 0x for hex, + for positive decimal"));
gtk_grid_attach(grid, d.prefix, 1, 2, 2, 1);
label = gtk_label_new(_("Padding:"));
Expand Down
8 changes: 4 additions & 4 deletions geanylua/glspi_doc.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static gint filename_to_doc_idx(const gchar*fn)
{
if (fn && *fn) {
guint i;
documents_foreach(i)
foreach_document(i)
{
if fncmp(fn,documents[i]->file_name) {return i; }
}
Expand Down Expand Up @@ -173,7 +173,7 @@ static gint glspi_documents(lua_State *L)
static gint glspi_count(lua_State* L)
{
guint i, n=0;
documents_foreach(i)
foreach_document(i)
{
if (documents[i]->is_valid){n++;}
}
Expand Down Expand Up @@ -225,7 +225,7 @@ static gint glspi_open(lua_State* L)
}
}
if (!fn) {
status=document_reload_file(documents[idx],NULL) ? idx : -1;
status=document_reload_force(documents[idx],NULL) ? idx : -1;
} else {
guint len=geany->documents_array->len;
GeanyDocument*doc=document_open_file(fn,FALSE,NULL,NULL);
Expand All @@ -235,7 +235,7 @@ static gint glspi_open(lua_State* L)
/* if len doesn't change, it means we are reloading an already open file */
/* ntrel: actually, len can stay the same when reusing invalid document slots. */
idx=document_get_current()->index;
status=document_reload_file(documents[idx],NULL) ? idx : -1;
status=document_reload_force(documents[idx],NULL) ? idx : -1;
}
}
push_number(L,status+1);
Expand Down
26 changes: 6 additions & 20 deletions geanylua/glspi_sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,9 @@ static gint glspi_text(lua_State* L)

if (!doc) { return 0; }
if (0 == lua_gettop(L)) { /* Called with no args, GET the current text */
gint len = sci_get_length(doc->editor->sci);
gchar *txt = NULL;
if (len>0) {
txt = g_malloc0((guint)len+2);
sci_get_text(doc->editor->sci, len+1, txt);
lua_pushstring(L, (const gchar *) txt);
g_free(txt);
} else {
lua_pushstring(L, "");
}
gchar *txt = sci_get_contents(doc->editor->sci, -1);
lua_pushstring(L, txt ? txt : "");
g_free(txt);
return 1;
} else { /* Called with one arg, SET the current text */
const gchar*txt;
Expand All @@ -48,16 +41,9 @@ static gint glspi_selection(lua_State* L)

DOC_REQUIRED
if (0 == lua_gettop(L)) { /* Called with no args, GET the selection */
gint len = sci_get_selected_text_length(doc->editor->sci);
gchar *txt = NULL;
if (len>0) {
txt = g_malloc0((guint)(len+1));
sci_get_selected_text(doc->editor->sci, txt);
lua_pushstring(L, (const gchar *) txt);
g_free(txt);
} else {
lua_pushstring(L, "");
}
gchar *txt = sci_get_selection_contents(doc->editor->sci);
lua_pushstring(L, txt ? txt : "");
g_free(txt);
return 1;
} else { /* Called with one arg, SET the selection */
const gchar*txt=NULL;
Expand Down
10 changes: 4 additions & 6 deletions geanyminiscript/src/gms.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,10 @@ static gchar *gms_command = NULL ;
*/
static void create_selection_2_input_file( ScintillaObject *sci )
{
gchar *contents = NULL;
gint size_buf = sci_get_selected_text_length(sci);
gchar *contents = sci_get_selection_contents(sci);

contents = GMS_G_MALLOC( gchar, size_buf + 1 ) ;
GMS_PNULL(contents) ;

sci_get_selected_text( sci ,contents );

g_file_set_contents(gms_get_in_filename(gms_hnd), contents, -1 , NULL );
GMS_G_FREE(contents);
}
Expand Down Expand Up @@ -238,9 +234,11 @@ static void item_activate(GtkMenuItem *menuitem, gpointer gdata)
*/
void plugin_init(GeanyData *data)
{
const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);

gms_hnd = gms_new(geany->main_widgets->window,
data->interface_prefs->editor_font ,
data->editor_prefs->indentation->width,
iprefs->width,
geany->app->configdir
) ;

Expand Down
8 changes: 5 additions & 3 deletions geanyprj/src/geanyprj.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ PLUGIN_SET_TRANSLATABLE_INFO(LOCALEDIR, GETTEXT_PACKAGE,
"GeanyPrj", _("Alternative project support."), VERSION,
"Yura Siamashka <yurand2@gmail.com>")

GeanyPlugin *geany_plugin;
GeanyData *geany_data;


Expand All @@ -53,8 +54,6 @@ enum
KB_COUNT
};

PLUGIN_KEY_GROUP(geanyprj, KB_COUNT)


static void reload_project(void)
{
Expand Down Expand Up @@ -210,6 +209,8 @@ static void on_configure_response(G_GNUC_UNUSED GtkDialog *dialog, G_GNUC_UNUSED
/* Called by Geany to initialize the plugin */
void plugin_init(G_GNUC_UNUSED GeanyData *data)
{
GeanyKeyGroup *key_group;

load_settings();
tools_menu_init();

Expand All @@ -218,7 +219,8 @@ void plugin_init(G_GNUC_UNUSED GeanyData *data)
create_sidebar();
reload_project();

keybindings_set_item(plugin_key_group, KB_FIND_IN_PROJECT,
key_group = plugin_set_key_group(geany_plugin, "geanyprj", KB_COUNT, NULL);
keybindings_set_item(key_group, KB_FIND_IN_PROJECT,
kb_find_in_project, 0, 0, "find_in_project",
_("Find a text in geanyprj's project"), NULL);
}
Expand Down
24 changes: 11 additions & 13 deletions geanyprj/src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

#include "geanyprj.h"

PluginFields *plugin_fields;

static struct
{
GtkWidget *tools_item;

GtkWidget *new_project;
GtkWidget *delete_project;

Expand Down Expand Up @@ -156,7 +156,7 @@ static PropertyDialogElements *build_properties_dialog(gboolean properties)
gtk_misc_set_alignment(GTK_MISC(label), 1, 0);

e->base_path = gtk_entry_new();
ui_widget_set_tooltip_text(e->base_path,
gtk_widget_set_tooltip_text(e->base_path,
_("Base directory of all files that make up the project. "
"This can be a new path, or an existing directory tree. "
"You can use paths relative to the project filename."));
Expand All @@ -168,7 +168,7 @@ static PropertyDialogElements *build_properties_dialog(gboolean properties)

label = gtk_label_new("");
e->regenerate = gtk_check_button_new_with_label(_("Generate file list on load"));
ui_widget_set_tooltip_text(e->regenerate,
gtk_widget_set_tooltip_text(e->regenerate,
_("Automatically add files that match project type on project load "
"automatically. You can't manually add/remove files if "
"you checked this option, since your modification will be lost on "
Expand Down Expand Up @@ -362,16 +362,15 @@ void tools_menu_init(void)
{
GtkWidget *item, *image;

GtkWidget *menu_prj = NULL;
GtkWidget *menu_prj_menu = NULL;

menu_prj = gtk_image_menu_item_new_with_mnemonic(_("_Project"));
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_prj);
menu_items.tools_item = gtk_image_menu_item_new_with_mnemonic(_("_Project"));
gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_items.tools_item);

g_signal_connect((gpointer) menu_prj, "activate", G_CALLBACK(update_menu_items), NULL);
g_signal_connect((gpointer) menu_items.tools_item, "activate", G_CALLBACK(update_menu_items), NULL);

menu_prj_menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_prj), menu_prj_menu);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_items.tools_item), menu_prj_menu);

image = gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_MENU);
item = gtk_image_menu_item_new_with_mnemonic(_("New Project"));
Expand Down Expand Up @@ -423,14 +422,13 @@ void tools_menu_init(void)
g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_find_in_project), NULL);
menu_items.find_in_files = item;

gtk_widget_show_all(menu_prj);
gtk_widget_show_all(menu_items.tools_item);

plugin_fields->menu_item = menu_prj;
plugin_fields->flags = PLUGIN_IS_DOCUMENT_SENSITIVE;
ui_add_document_sensitive(menu_items.tools_item);
}


void tools_menu_uninit(void)
{
gtk_widget_destroy(plugin_fields->menu_item);
gtk_widget_destroy(menu_items.tools_item);
}
Loading

0 comments on commit 607cab9

Please sign in to comment.