-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncs.c
82 lines (68 loc) · 1.95 KB
/
funcs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "funcs.h"
#include "strings.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
extern global_t global;
void show_in_statusbar( const char* message )
{
gtk_statusbar_pop( global.statusbar, 0 );
gtk_statusbar_push( global.statusbar, 0, message );
}
void show_in_statusbar_ext( const char* format, const char* value )
{
char message[ COMMAND_BUFFER_SIZE ];
snprintf( message, COMMAND_BUFFER_SIZE, format, value );
show_in_statusbar( message );
}
void entry_edited( GtkEntry* entry, char** destination )
{
if( *destination != NULL ) free( *destination );
GtkEntryBuffer* entry_buffer = gtk_entry_get_buffer( entry );
*destination = strdup( gtk_entry_buffer_get_text( entry_buffer ) );
}
void entry_edited_dig( GtkEntry* entry, int* destination )
{
GtkEntryBuffer* entry_buffer = gtk_entry_get_buffer( entry );
*destination = atoi( gtk_entry_buffer_get_text( entry_buffer ) );
}
void combo_changed( GtkComboBoxText* combobox, char** destination )
{
if( *destination != NULL ) free( *destination );
*destination = strdup( gtk_combo_box_text_get_active_text( combobox ) );
if( strcmp( *destination, "-" ) == 0 ) *destination = NULL;
}
void check_button_activate( GtkCheckButton* button, int* destination )
{
*destination = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ) );
}
void remove_children( GtkContainer* container )
{
GList* children = gtk_container_get_children( GTK_CONTAINER( container ) );
if( children != NULL )
{
for( GList* iter = children; iter != NULL; iter = g_list_next( iter ) )
{
gtk_widget_destroy( GTK_WIDGET( iter->data ) );
}
g_list_free( children );
}
}
int isempty( const char* string )
{
if( string[0] == '\0' )
{
return TRUE;
}
else
{
return FALSE;
}
}
void pop_char( char* string )
{
if( strlen(string) != 0 )
{
string[ strlen(string) - 1 ] = '\0';
}
}