- merge patch from Jochen Baier to allow filtering for map and server name
- update German translation git-svn-id: http://svn.code.sf.net/p/xqf/code/trunk@429 d2ac09be-c843-0410-8b1f-f8a84130e0ec
This commit is contained in:
parent
d7414bab7a
commit
105dd966a5
@ -1,3 +1,7 @@
|
||||
Feb 03, 2003: Ludwig Nussel <l-n@users.sourceforge.net>
|
||||
- merge patch from Jochen Baier to allow filtering for map and server name
|
||||
- update German translation
|
||||
|
||||
Feb 01, 2003: Ludwig Nussel <l-n@users.sourceforge.net>
|
||||
- fix high cpu load when dialogs are shown during launch phase. It's
|
||||
obviously no good idea to enter the gtk event loop from inside a
|
||||
|
@ -35,3 +35,4 @@ src/xqf-ui.c
|
||||
src/xqf.c
|
||||
#src/xutils.c
|
||||
#src/zipped.c
|
||||
src/splash.c
|
||||
|
640
xqf/po/de.po
640
xqf/po/de.po
File diff suppressed because it is too large
Load Diff
191
xqf/src/filter.c
191
xqf/src/filter.c
@ -107,6 +107,8 @@ static GtkWidget *filter_no_password_check_button;
|
||||
static GtkWidget *game_contains_entry;
|
||||
static GtkWidget *filter_game_type_entry;
|
||||
static GtkWidget *version_contains_entry;
|
||||
static GtkWidget *map_contains_entry;
|
||||
static GtkWidget *server_name_contains_entry;
|
||||
|
||||
static struct server_filter_vars* server_filter_vars_new()
|
||||
{
|
||||
@ -123,7 +125,8 @@ static struct server_filter_vars* server_filter_vars_new()
|
||||
f->game_contains = NULL;
|
||||
f->version_contains = NULL;
|
||||
f->game_type = NULL;
|
||||
|
||||
f->map_contains = NULL;
|
||||
f->server_name_contains=NULL;
|
||||
return f;
|
||||
}
|
||||
|
||||
@ -134,6 +137,8 @@ static void server_filter_vars_free(struct server_filter_vars* v)
|
||||
g_free(v->filter_name);
|
||||
g_free(v->game_contains);
|
||||
g_free(v->version_contains);
|
||||
g_free(v->map_contains);
|
||||
g_free(v->server_name_contains);
|
||||
g_free(v->game_type);
|
||||
}
|
||||
|
||||
@ -147,17 +152,18 @@ static struct server_filter_vars* server_filter_vars_copy(struct server_filter_v
|
||||
f = server_filter_vars_new();
|
||||
if(!f) return NULL;
|
||||
|
||||
f->filter_retries = v->filter_retries;
|
||||
f->filter_ping = v->filter_ping;
|
||||
f->filter_not_full = v->filter_not_full;
|
||||
f->filter_not_empty = v->filter_not_empty;
|
||||
f->filter_no_cheats = v->filter_no_cheats;
|
||||
f->filter_no_password = v->filter_no_password;
|
||||
f->filter_name = g_strdup(v->filter_name);
|
||||
f->game_contains = g_strdup(v->game_contains);
|
||||
f->version_contains = g_strdup(v->version_contains);
|
||||
f->game_type = g_strdup(v->game_type);
|
||||
|
||||
f->filter_retries = v->filter_retries;
|
||||
f->filter_ping = v->filter_ping;
|
||||
f->filter_not_full = v->filter_not_full;
|
||||
f->filter_not_empty = v->filter_not_empty;
|
||||
f->filter_no_cheats = v->filter_no_cheats;
|
||||
f->filter_no_password = v->filter_no_password;
|
||||
f->filter_name = g_strdup(v->filter_name);
|
||||
f->game_contains = g_strdup(v->game_contains);
|
||||
f->version_contains = g_strdup(v->version_contains);
|
||||
f->game_type = g_strdup(v->game_type);
|
||||
f->map_contains = g_strdup(v->map_contains);
|
||||
f->server_name_contains = g_strdup(v->server_name_contains);
|
||||
return f;
|
||||
}
|
||||
|
||||
@ -173,6 +179,8 @@ void server_filter_print(struct server_filter_vars* f)
|
||||
printf(" game: %s\n",f->game_contains);
|
||||
printf(" version: %s\n",f->version_contains);
|
||||
printf(" game type: %s\n",f->game_type);
|
||||
printf(" map: %s\n",f->map_contains);
|
||||
printf(" server name: %s\n",f->server_name_contains);
|
||||
}
|
||||
|
||||
void apply_filters (unsigned mask, struct server *s) {
|
||||
@ -248,7 +256,7 @@ GSList *build_filtered_list (unsigned mask, GSList *server_list) {
|
||||
static int server_pass_filter (struct server *s){
|
||||
char **info_ptr;
|
||||
struct server_filter_vars* filter;
|
||||
|
||||
|
||||
/* Filter Zero is No Filter */
|
||||
if( current_server_filter == 0 ){ return TRUE; }
|
||||
|
||||
@ -293,6 +301,15 @@ static int server_pass_filter (struct server *s){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if( filter->map_contains && *filter->map_contains )
|
||||
{
|
||||
if( !s->map )
|
||||
return FALSE;
|
||||
else if(!lowcasestrstr(s->map, filter->map_contains))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if( filter->version_contains && *filter->version_contains)
|
||||
{
|
||||
const char* version = NULL;
|
||||
@ -308,6 +325,17 @@ static int server_pass_filter (struct server *s){
|
||||
return FALSE;
|
||||
}
|
||||
}/*end version check */
|
||||
|
||||
|
||||
if( filter->server_name_contains && *filter->server_name_contains )
|
||||
{
|
||||
if( !s->name )
|
||||
return FALSE;
|
||||
else if(!lowcasestrstr(s->name, filter->server_name_contains))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -338,17 +366,18 @@ static void server_filter_init (void) {
|
||||
filter = server_filter_vars_new();
|
||||
if(!filter) break;
|
||||
|
||||
filter->filter_name = filtername;
|
||||
filter->filter_retries = config_get_int ("retries=2");
|
||||
filter->filter_ping = config_get_int ("ping=1000");
|
||||
filter->filter_not_full = config_get_bool ("not full=false");
|
||||
filter->filter_not_empty = config_get_bool ("not empty=false");
|
||||
filter->filter_no_cheats = config_get_bool ("no cheats=false");
|
||||
filter->filter_no_password = config_get_bool ("no password=false");
|
||||
filter->game_contains = config_get_string("game_contains");
|
||||
filter->version_contains = config_get_string("version_contains");
|
||||
filter->game_type = config_get_string("game_type");
|
||||
|
||||
filter->filter_name = filtername;
|
||||
filter->filter_retries = config_get_int ("retries=2");
|
||||
filter->filter_ping = config_get_int ("ping=1000");
|
||||
filter->filter_not_full = config_get_bool ("not full=false");
|
||||
filter->filter_not_empty = config_get_bool ("not empty=false");
|
||||
filter->filter_no_cheats = config_get_bool ("no cheats=false");
|
||||
filter->filter_no_password = config_get_bool ("no password=false");
|
||||
filter->game_contains = config_get_string("game_contains");
|
||||
filter->version_contains = config_get_string("version_contains");
|
||||
filter->game_type = config_get_string("game_type");
|
||||
filter->map_contains = config_get_string("map_contains");
|
||||
filter->server_name_contains = config_get_string("server_name_contains");
|
||||
g_array_append_val(server_filters,filter);
|
||||
|
||||
config_pop_prefix ();
|
||||
@ -407,7 +436,8 @@ static struct server_filter_vars* server_filter_new_from_widgets()
|
||||
filter->game_type = gtk_editable_get_chars (GTK_EDITABLE (filter_game_type_entry), 0, -1 );
|
||||
filter->version_contains = gtk_editable_get_chars (GTK_EDITABLE (version_contains_entry), 0, -1 );
|
||||
filter->game_contains = gtk_editable_get_chars (GTK_EDITABLE (game_contains_entry), 0, -1 );
|
||||
|
||||
filter->map_contains = gtk_editable_get_chars (GTK_EDITABLE (map_contains_entry), 0, -1 );
|
||||
filter->server_name_contains = gtk_editable_get_chars (GTK_EDITABLE (server_name_contains_entry), 0, -1 );
|
||||
return filter;
|
||||
}
|
||||
|
||||
@ -587,7 +617,7 @@ static void server_filter_save_settings (int number,
|
||||
if( newfilter->game_type && strlen( newfilter->game_type )){
|
||||
/*
|
||||
First case, the user entered something. See if the value
|
||||
is different
|
||||
is different
|
||||
*/
|
||||
if (oldfilter->game_type){
|
||||
if( strcmp( newfilter->game_type, oldfilter->game_type )) text_changed = 1;
|
||||
@ -608,9 +638,71 @@ static void server_filter_save_settings (int number,
|
||||
filters[FILTER_SERVER].changed = FILTER_CHANGED;
|
||||
}
|
||||
oldfilter->game_type = NULL;
|
||||
}
|
||||
}
|
||||
/* end game_type filter */
|
||||
|
||||
|
||||
/* map string values */
|
||||
text_changed = 0;
|
||||
if( newfilter->map_contains && strlen( newfilter->map_contains )){
|
||||
/*
|
||||
First case, the user entered something. See if the value
|
||||
is different
|
||||
*/
|
||||
if (oldfilter->map_contains){
|
||||
if( strcmp( newfilter->map_contains, oldfilter->map_contains )) text_changed = 1;
|
||||
g_free( oldfilter->map_contains);
|
||||
} else {
|
||||
text_changed = 1;
|
||||
}
|
||||
oldfilter->map_contains = g_strdup( newfilter->map_contains );
|
||||
if (text_changed) {
|
||||
config_set_string ("map_contains", oldfilter->map_contains );
|
||||
filters[FILTER_SERVER].changed = FILTER_CHANGED;
|
||||
}
|
||||
} else {
|
||||
if (oldfilter->map_contains){
|
||||
text_changed = 1; /* From something to nothing */
|
||||
g_free( oldfilter->map_contains );
|
||||
config_set_string ("map_contains", "" );
|
||||
filters[FILTER_SERVER].changed = FILTER_CHANGED;
|
||||
}
|
||||
oldfilter->map_contains= NULL;
|
||||
} /* end of map filter */
|
||||
|
||||
|
||||
|
||||
|
||||
/* servername string values */
|
||||
text_changed = 0;
|
||||
if( newfilter->server_name_contains && strlen( newfilter->server_name_contains )){
|
||||
/*
|
||||
First case, the user entered something. See if the value
|
||||
is different
|
||||
*/
|
||||
if (oldfilter->server_name_contains){
|
||||
if( strcmp( newfilter->server_name_contains, oldfilter->server_name_contains )) text_changed = 1;
|
||||
g_free( oldfilter->server_name_contains);
|
||||
} else {
|
||||
text_changed = 1;
|
||||
}
|
||||
oldfilter->server_name_contains = g_strdup( newfilter->server_name_contains );
|
||||
if (text_changed) {
|
||||
config_set_string ("server_name_contains", oldfilter->server_name_contains );
|
||||
filters[FILTER_SERVER].changed = FILTER_CHANGED;
|
||||
}
|
||||
} else {
|
||||
if (oldfilter->server_name_contains){
|
||||
text_changed = 1; /* From something to nothing */
|
||||
g_free( oldfilter->server_name_contains );
|
||||
config_set_string ("server_name_contains", "" );
|
||||
filters[FILTER_SERVER].changed = FILTER_CHANGED;
|
||||
}
|
||||
oldfilter->server_name_contains = NULL;
|
||||
} /* end of server filter */
|
||||
|
||||
|
||||
|
||||
|
||||
if (oldfilter->filter_not_full != newfilter->filter_not_full) {
|
||||
config_set_bool ("not full", oldfilter->filter_not_full = newfilter->filter_not_full);
|
||||
@ -814,6 +906,8 @@ static void server_filter_set_widgets_sensitive(gboolean sensitive)
|
||||
gtk_widget_set_sensitive(filter_game_type_entry,sensitive);
|
||||
gtk_widget_set_sensitive(version_contains_entry,sensitive);
|
||||
gtk_widget_set_sensitive(game_contains_entry,sensitive);
|
||||
gtk_widget_set_sensitive(map_contains_entry,sensitive);
|
||||
gtk_widget_set_sensitive(server_name_contains_entry,sensitive);
|
||||
gtk_widget_set_sensitive(filter_ping_spinner,sensitive);
|
||||
gtk_widget_set_sensitive(filter_retries_spinner,sensitive);
|
||||
gtk_widget_set_sensitive(filter_not_full_check_button,sensitive);
|
||||
@ -850,6 +944,8 @@ static void server_filter_fill_widgets(guint num)
|
||||
gtk_entry_set_text (GTK_ENTRY (filter_game_type_entry), filter->game_type?filter->game_type:"" );
|
||||
gtk_entry_set_text (GTK_ENTRY (version_contains_entry), filter->version_contains?filter->version_contains:"" );
|
||||
gtk_entry_set_text (GTK_ENTRY (game_contains_entry), filter->game_contains?filter->game_contains:"" );
|
||||
gtk_entry_set_text (GTK_ENTRY (map_contains_entry), filter->map_contains?filter->map_contains:"" );
|
||||
gtk_entry_set_text (GTK_ENTRY (server_name_contains_entry), filter->server_name_contains?filter->server_name_contains:"" );
|
||||
|
||||
gtk_adjustment_set_value(gtk_spin_button_get_adjustment(
|
||||
GTK_SPIN_BUTTON(filter_ping_spinner)),filter->filter_ping);
|
||||
@ -1050,10 +1146,10 @@ static void server_filter_page (GtkWidget *notebook) {
|
||||
|
||||
|
||||
/* Version Filter -- baa */
|
||||
|
||||
|
||||
label = gtk_label_new (_("the version contains the string"));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_table_attach (GTK_TABLE (table), label, 3, 4, row, row+1, GTK_FILL, GTK_FILL,
|
||||
gtk_table_attach (GTK_TABLE (table), label, 3, 4, row, row+1, GTK_FILL, GTK_FILL,
|
||||
0, 0);
|
||||
gtk_widget_show (label);
|
||||
version_contains_entry = gtk_entry_new_with_max_length (32);
|
||||
@ -1064,6 +1160,43 @@ static void server_filter_page (GtkWidget *notebook) {
|
||||
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), version_contains_entry, 4, 5, row, row+1);
|
||||
gtk_widget_show (version_contains_entry);
|
||||
row++;
|
||||
|
||||
|
||||
/* Map filter*/
|
||||
|
||||
label = gtk_label_new (_("the map contains the string"));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_table_attach (GTK_TABLE (table), label, 3, 4, row, row+1, GTK_FILL, GTK_FILL,
|
||||
0, 0);
|
||||
gtk_widget_show (label);
|
||||
map_contains_entry = gtk_entry_new_with_max_length (32);
|
||||
gtk_widget_set_usize (map_contains_entry, 64, -1);
|
||||
gtk_entry_set_editable (GTK_ENTRY (map_contains_entry), TRUE);
|
||||
gtk_signal_connect_object (GTK_OBJECT (map_contains_entry), "changed",
|
||||
GTK_SIGNAL_FUNC (server_filter_set_changed_callback), (gpointer) TRUE);
|
||||
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), map_contains_entry, 4, 5, row, row+1);
|
||||
gtk_widget_show (map_contains_entry);
|
||||
row++;
|
||||
|
||||
|
||||
/* Server name filter*/
|
||||
|
||||
label = gtk_label_new (_("the server name contains the string"));
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
gtk_table_attach (GTK_TABLE (table), label, 3, 4, row, row+1, GTK_FILL, GTK_FILL,
|
||||
0, 0);
|
||||
gtk_widget_show (label);
|
||||
server_name_contains_entry = gtk_entry_new_with_max_length (32);
|
||||
gtk_widget_set_usize (server_name_contains_entry, 64, -1);
|
||||
gtk_entry_set_editable (GTK_ENTRY (server_name_contains_entry), TRUE);
|
||||
gtk_signal_connect_object (GTK_OBJECT (server_name_contains_entry), "changed",
|
||||
GTK_SIGNAL_FUNC (server_filter_set_changed_callback), (gpointer) TRUE);
|
||||
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),server_name_contains_entry , 4, 5, row, row+1);
|
||||
gtk_widget_show (server_name_contains_entry);
|
||||
|
||||
|
||||
|
||||
/* not full */
|
||||
|
@ -53,6 +53,8 @@ struct server_filter_vars {
|
||||
char *game_contains;
|
||||
char *version_contains;
|
||||
char *game_type;
|
||||
char *map_contains;
|
||||
char *server_name_contains;
|
||||
};
|
||||
|
||||
|
||||
|
143
xqf/src/xqf.c
143
xqf/src/xqf.c
@ -171,6 +171,10 @@ static GtkWidget *record_button = NULL;
|
||||
|
||||
static GtkWidget *filter_buttons[FILTERS_TOTAL];
|
||||
|
||||
/*filter widgtet for toolbar*/
|
||||
static GtkWidget *filter_option_menu_toolbar;
|
||||
static GtkWidget *filter_toolbar_label;
|
||||
|
||||
static GtkWidget *player_skin_popup = NULL;
|
||||
static GtkWidget *player_skin_popup_preview = NULL;
|
||||
/*
|
||||
@ -188,6 +192,7 @@ static void launch_close_handler_part2(struct condef *con);
|
||||
/** build server filter menu for menubar
|
||||
*/
|
||||
static GtkWidget* create_filter_menu();
|
||||
static GtkWidget* create_filter_menu_toolbar();
|
||||
//static GtkWidget* filter_menu = NULL; // need to store that for toggling the checkboxes
|
||||
static GSList* filter_menu_radio_buttons = NULL; // for finding the widgets to activate
|
||||
|
||||
@ -561,7 +566,7 @@ static int forced_filters_flag = FALSE;
|
||||
static void set_filters (unsigned char mask) {
|
||||
unsigned n;
|
||||
int i;
|
||||
|
||||
|
||||
forced_filters_flag = TRUE;
|
||||
|
||||
cur_filter = mask;
|
||||
@ -576,6 +581,8 @@ static void set_filters (unsigned char mask) {
|
||||
|
||||
|
||||
static void filter_toggle_callback (GtkWidget *widget, unsigned char mask) {
|
||||
|
||||
|
||||
if (!forced_filters_flag) {
|
||||
cur_filter ^= mask;
|
||||
server_clist_build_filtered (cur_server_list, FALSE); /* in srv-list.c */
|
||||
@ -590,7 +597,7 @@ static void filter_menu_activate_current()
|
||||
unsigned int count = 0;
|
||||
GSList* rbgroup = filter_menu_radio_buttons;
|
||||
GtkWidget* widget = NULL;
|
||||
|
||||
|
||||
while(rbgroup)
|
||||
{
|
||||
if(GTK_IS_CHECK_MENU_ITEM(rbgroup->data))
|
||||
@ -611,6 +618,16 @@ static void filter_menu_activate_current()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*refresh filtermenu on toolbar*/
|
||||
|
||||
void set_filter_option_menu_toolbar (void) {
|
||||
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (filter_option_menu_toolbar), create_filter_menu_toolbar());
|
||||
gtk_option_menu_set_history(GTK_OPTION_MENU(filter_option_menu_toolbar), current_server_filter);
|
||||
}
|
||||
|
||||
|
||||
void set_server_filter_menu_list_text( void ){
|
||||
|
||||
/* baa -- Set the names of the filters if they have been set in
|
||||
@ -690,14 +707,30 @@ void set_server_filter_menu_list_text( void ){
|
||||
|
||||
static void server_filter_select_callback (GtkWidget *widget, int number) {
|
||||
|
||||
if(!GTK_IS_CHECK_MENU_ITEM(widget))
|
||||
{
|
||||
g_warning("no check menu item");
|
||||
return;
|
||||
}
|
||||
|
||||
if(GTK_CHECK_MENU_ITEM(widget)->active == 0)
|
||||
{
|
||||
// signal was triggered for deactivation
|
||||
return;
|
||||
}
|
||||
|
||||
current_server_filter = number;
|
||||
|
||||
filters[FILTER_SERVER].changed = FILTER_CHANGED;
|
||||
filters[FILTER_SERVER].last_changed = ++filter_current_time;
|
||||
|
||||
server_clist_build_filtered (cur_server_list, FALSE); /* in srv-list.c */
|
||||
server_clist_build_filtered (cur_server_list, FALSE); /* in srv-list.c */
|
||||
set_server_filter_menu_list_text ();
|
||||
|
||||
/* refresh optionmenu on toolbar*/
|
||||
|
||||
set_filter_option_menu_toolbar();
|
||||
|
||||
config_push_prefix ( "/" CONFIG_FILE "/Server Filter" );
|
||||
config_set_int ("current_server_filter", current_server_filter);
|
||||
config_pop_prefix ();
|
||||
@ -705,6 +738,19 @@ static void server_filter_select_callback (GtkWidget *widget, int number) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*need new one to refresh filter radio buttons in menu*/
|
||||
|
||||
static void server_filter_select_callback_toolbar (GtkWidget *widget, int number) {
|
||||
|
||||
current_server_filter = number;
|
||||
|
||||
/*apply changes to radio buttons in menu*/
|
||||
|
||||
filter_menu_activate_current();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void start_preferences_dialog (GtkWidget *widget, int page_num) {
|
||||
@ -720,6 +766,13 @@ static void start_filters_cfg_dialog (GtkWidget *widget, int page_num) {
|
||||
rc_save ();
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (server_serverfilter_menu_item), create_filter_menu());
|
||||
filter_menu_activate_current();
|
||||
|
||||
/* refresh optionmenu on toolbar*/
|
||||
set_filter_option_menu_toolbar();
|
||||
|
||||
/* refresh filter status*/
|
||||
set_server_filter_menu_list_text ();
|
||||
|
||||
//happes automagically server_clist_build_filtered (cur_server_list, TRUE);
|
||||
player_clist_redraw ();
|
||||
}
|
||||
@ -2676,7 +2729,7 @@ static void populate_main_toolbar (void) {
|
||||
pixmap = gtk_pixmap_new (observe_pix.pix, observe_pix.mask);
|
||||
gtk_widget_show (pixmap);
|
||||
|
||||
observe_button = gtk_toolbar_append_item (GTK_TOOLBAR (main_toolbar),
|
||||
observe_button = gtk_toolbar_append_item (GTK_TOOLBAR (main_toolbar),
|
||||
_("Observe"), _("Observe"), NULL,
|
||||
pixmap,
|
||||
GTK_SIGNAL_FUNC (launch_callback), (gpointer) LAUNCH_SPECTATE);
|
||||
@ -2728,6 +2781,31 @@ static void populate_main_toolbar (void) {
|
||||
pixmap,
|
||||
GTK_SIGNAL_FUNC (start_filters_cfg_dialog), (gpointer) i);
|
||||
}
|
||||
gtk_toolbar_append_space (GTK_TOOLBAR (main_toolbar));
|
||||
|
||||
|
||||
|
||||
/*filter option menu for toolbar */
|
||||
|
||||
filter_toolbar_label = gtk_label_new ("Filter: ");
|
||||
gtk_toolbar_append_widget( GTK_TOOLBAR (main_toolbar),
|
||||
filter_toolbar_label,
|
||||
"Select a server filter",
|
||||
"Private" );
|
||||
gtk_widget_show(filter_toolbar_label);
|
||||
|
||||
|
||||
filter_option_menu_toolbar = gtk_option_menu_new ();
|
||||
gtk_option_menu_set_menu (GTK_OPTION_MENU (filter_option_menu_toolbar),
|
||||
create_filter_menu_toolbar());
|
||||
|
||||
gtk_toolbar_append_widget( GTK_TOOLBAR (main_toolbar),
|
||||
filter_option_menu_toolbar,
|
||||
"Select a server filter",
|
||||
"Private" );
|
||||
|
||||
|
||||
gtk_widget_show (filter_option_menu_toolbar);
|
||||
|
||||
set_toolbar_appearance (GTK_TOOLBAR (main_toolbar),
|
||||
default_toolbar_style, default_toolbar_tips);
|
||||
@ -2735,6 +2813,53 @@ static void populate_main_toolbar (void) {
|
||||
|
||||
/** build server filter menu for menubar
|
||||
*/
|
||||
|
||||
static GtkWidget* create_filter_menu_toolbar()
|
||||
{
|
||||
unsigned int i;
|
||||
GtkWidget *menu;
|
||||
GtkWidget *menu_item;
|
||||
|
||||
struct server_filter_vars* filter = NULL;
|
||||
|
||||
|
||||
menu = gtk_menu_new();
|
||||
|
||||
|
||||
for (i = 0;i<=server_filters->len;i++)
|
||||
{
|
||||
char* name = NULL;
|
||||
if(i == 0)
|
||||
{
|
||||
filter = NULL;
|
||||
name = _("None");
|
||||
}
|
||||
else
|
||||
{
|
||||
filter = g_array_index (server_filters, struct server_filter_vars*, i-1);
|
||||
name = filter->filter_name;
|
||||
}
|
||||
|
||||
menu_item = gtk_menu_item_new_with_label(name);
|
||||
gtk_menu_append (GTK_MENU (menu), menu_item);
|
||||
gtk_widget_show (menu_item);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
|
||||
GTK_SIGNAL_FUNC (server_filter_select_callback_toolbar), (gpointer)i); // array starts from zero but filters from 1
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
gtk_widget_show (menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** build server filter menu for toolbar
|
||||
*/
|
||||
static GtkWidget* create_filter_menu()
|
||||
{
|
||||
unsigned int i;
|
||||
@ -2774,7 +2899,7 @@ static GtkWidget* create_filter_menu()
|
||||
// rbgroup = gtk_radio_button_group(GTK_RADIO_BUTTON(radiobutton));
|
||||
// gtk_container_add(GTK_CONTAINER(menu_item),radiobutton);
|
||||
// gtk_widget_show(radiobutton);
|
||||
|
||||
|
||||
// menu_item = gtk_check_menu_item_new_with_label(name);
|
||||
// gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), (current_server_filter == i));
|
||||
// that doesn't do what the docu says, right?
|
||||
@ -2804,8 +2929,6 @@ static GtkWidget* create_filter_menu()
|
||||
// filter_menu = menu;
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
||||
void create_main_window (void) {
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
@ -3097,6 +3220,12 @@ void create_main_window (void) {
|
||||
|
||||
/* Make sure the current filter is dispalyed and applied if needed */
|
||||
set_server_filter_menu_list_text ();
|
||||
|
||||
/*refresh optionmenu on toolbar*/
|
||||
|
||||
set_filter_option_menu_toolbar();
|
||||
|
||||
|
||||
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user