Created
December 22, 2012 15:31
-
-
Save moebiuseye/4359418 to your computer and use it in GitHub Desktop.
--- DO NOT USE -- In this example, buffer == NULL
WHY?
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
/* | |
* transformadd.h | |
* | |
* Copyright 2012 moebiuseye <moebiuseye@deadlyweapon> | |
* | |
* 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> | |
#include <assert.h> | |
GeanyPlugin *geany_plugin; | |
GeanyData *geany_data; | |
GeanyFunctions *geany_functions; | |
/* _c_ means current */ | |
static gint _c_tab; | |
void print_hello( GtkWidget *w, gpointer data) { | |
GtkWidget *notebook = geany->main_widgets->notebook; | |
_c_tab = gtk_notebook_get_current_page( GTK_NOTEBOOK(notebook) ); | |
GtkTextView *current_tab = GTK_TEXT_VIEW( | |
gtk_notebook_get_nth_page( GTK_NOTEBOOK(notebook), _c_tab) ); | |
if ( current_tab == NULL ) { | |
dialogs_show_msgbox( GTK_MESSAGE_INFO, "current_tab==NULL" ); return; | |
} | |
GtkTextBuffer *buffer = gtk_text_view_get_buffer( current_tab ); | |
if ( buffer == NULL ) { | |
dialogs_show_msgbox( GTK_MESSAGE_INFO, "buffer==NULL" ); return; | |
} | |
GtkTextIter *start = NULL , *end = NULL; | |
gtk_text_buffer_get_start_iter( buffer, start ); | |
gtk_text_buffer_get_end_iter( buffer, end ); | |
int b = 1; | |
char *text = (char*)gtk_text_buffer_get_text ( buffer, | |
start , end, (gboolean)b ); | |
if ( text == NULL ) { | |
dialogs_show_msgbox( GTK_MESSAGE_INFO, "text==NULL" ); return; | |
} | |
dialogs_show_msgbox( GTK_MESSAGE_INFO, text ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment