Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 134581
Collapse All | Expand All

(-)xqf-1.0.4.org/src/pref.c (-1 / +81 lines)
Lines 113-118 Link Here
113
int	default_show_only_configured_games;
113
int	default_show_only_configured_games;
114
char*   default_icontheme;
114
char*   default_icontheme;
115
115
116
// ---- Copy+ format string patch
117
char*	default_copyplusformat;
118
// --end-- Copy+ format string patch
119
116
int     maxretries;
120
int     maxretries;
117
int     maxsimultaneous;
121
int     maxsimultaneous;
118
char*   qstat_srcip;
122
char*   qstat_srcip;
Lines 195-200 Link Here
195
static  GtkWidget *show_only_configured_games_check_button;
199
static  GtkWidget *show_only_configured_games_check_button;
196
static  GtkWidget *use_custom_gtkrc_check_button;
200
static  GtkWidget *use_custom_gtkrc_check_button;
197
201
202
// --begin-- Copy+ format string patch 
203
static  GtkWidget *copyplusformat_entry;
204
// --end-- Copy+ format string patch
205
198
static  GtkWidget *pushlatency_mode_radio_buttons[3];
206
static  GtkWidget *pushlatency_mode_radio_buttons[3];
199
static  GtkWidget *pushlatency_value_spinner;
207
static  GtkWidget *pushlatency_value_spinner;
200
208
Lines 379-384 Link Here
379
	NULL
387
	NULL
380
};
388
};
381
389
390
// --begin-- Copy+ format string patch 
391
void appearance_copyplusformat_default_callback();
392
// --end-- Copy+ format string patch
393
382
static void game_file_dialog(enum server_type type);
394
static void game_file_dialog(enum server_type type);
383
static void game_dir_dialog(enum server_type type);
395
static void game_dir_dialog(enum server_type type);
384
static void game_file_activate_callback(enum server_type type);
396
static void game_file_activate_callback(enum server_type type);
Lines 1051-1056 Link Here
1051
  if (i != use_custom_gtkrc)
1063
  if (i != use_custom_gtkrc)
1052
    config_set_bool ("use custom gtkrc", use_custom_gtkrc = i);
1064
    config_set_bool ("use custom gtkrc", use_custom_gtkrc = i);
1053
1065
1066
  // --begin-- Copy+ format string patch 
1067
  default_copyplusformat = strdup_strip (gtk_entry_get_text (GTK_ENTRY (copyplusformat_entry)));
1068
  config_set_string ("copyplusformat", (default_copyplusformat)? default_copyplusformat : "bla");
1069
  // --end-- Copy+ format string patch
1070
1054
  config_pop_prefix ();
1071
  config_pop_prefix ();
1055
1072
1056
  /* General */
1073
  /* General */
Lines 3999-4004 Link Here
3999
  GtkWidget *frame;
4016
  GtkWidget *frame;
4000
  GtkWidget *hbox;
4017
  GtkWidget *hbox;
4001
  GtkWidget *vbox;
4018
  GtkWidget *vbox;
4019
4020
  // --begin-- Copy+ format string patch 
4021
  GtkWidget *button;
4022
  GtkWidget *label;
4023
  // --end-- Copy+ format string patch
4024
4002
  GSList *group = NULL;
4025
  GSList *group = NULL;
4003
  static const char *toolbar_styles[] = { N_("Icons"), N_("Text"), N_("Both") };
4026
  static const char *toolbar_styles[] = { N_("Icons"), N_("Text"), N_("Both") };
4004
  int i;
4027
  int i;
Lines 4189-4194 Link Here
4189
4212
4190
  gtk_widget_show (page_vbox);
4213
  gtk_widget_show (page_vbox);
4191
4214
4215
  // --begin-- Copy+ format string patch
4216
  frame = gtk_frame_new (_("Copy+ format"));
4217
  gtk_box_pack_start (GTK_BOX (page_vbox), frame, FALSE, FALSE, 0);
4218
4219
  vbox = gtk_vbox_new (FALSE, 4);
4220
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
4221
  gtk_container_add (GTK_CONTAINER (frame), vbox);
4222
4223
  hbox = gtk_hbox_new (FALSE, 4);
4224
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
4225
  
4226
  copyplusformat_entry = gtk_entry_new ();
4227
  if(default_copyplusformat) {
4228
    gtk_entry_set_text (GTK_ENTRY (copyplusformat_entry), default_copyplusformat);
4229
  } else {
4230
    // set default format string
4231
    appearance_copyplusformat_default_callback();
4232
  }
4233
4234
  button = gtk_button_new_with_label (_("Default"));
4235
  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
4236
                    GTK_SIGNAL_FUNC (appearance_copyplusformat_default_callback), 0);
4237
4238
  gtk_box_pack_start (GTK_BOX (hbox), copyplusformat_entry, TRUE, TRUE, 0);
4239
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
4240
4241
  label = gtk_label_new(_("Possible tags:"));
4242
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
4243
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
4244
  gtk_widget_show (label);
4245
4246
  label = gtk_label_new("<ping> <ip> <port> <servername> <map> <players> <maxplayers> <game> <gametype>");
4247
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
4248
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
4249
  gtk_widget_show (label);
4250
4251
  
4252
  gtk_widget_show (button);
4253
  gtk_widget_show (label);
4254
  gtk_widget_show (copyplusformat_entry);
4255
  gtk_widget_show (vbox);
4256
  gtk_widget_show (hbox);
4257
  gtk_widget_show (frame);
4258
4259
  gtk_widget_show (page_vbox);
4260
  // --end-- Copy+ format string patch
4261
4262
4192
  return page_vbox;
4263
  return page_vbox;
4193
}
4264
}
4194
4265
Lines 4276-4282 Link Here
4276
	    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
4347
	    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
4277
	    gtk_misc_set_padding(GTK_MISC(GTK_BIN(button)->child),4,0);
4348
	    gtk_misc_set_padding(GTK_MISC(GTK_BIN(button)->child),4,0);
4278
	    gtk_signal_connect (GTK_OBJECT (button), "clicked",
4349
	    gtk_signal_connect (GTK_OBJECT (button), "clicked",
4279
		    GTK_SIGNAL_FUNC (scan_maps_callback), NULL);
4350
			GTK_SIGNAL_FUNC (scan_maps_callback), NULL);
4280
	    gtk_widget_show (button);
4351
	    gtk_widget_show (button);
4281
	}
4352
	}
4282
4353
Lines 5558-5563 Link Here
5558
  default_resolve_on_update = config_get_bool ("resolve on update=false");
5629
  default_resolve_on_update = config_get_bool ("resolve on update=false");
5559
  default_show_only_configured_games =    config_get_bool ("show only configured games=false");
5630
  default_show_only_configured_games =    config_get_bool ("show only configured games=false");
5560
  default_icontheme =         config_get_string ("icontheme");
5631
  default_icontheme =         config_get_string ("icontheme");
5632
  default_copyplusformat =    config_get_string ("copyplusformat");
5561
5633
5562
  set_style();
5634
  set_style();
5563
5635
Lines 5657-5662 Link Here
5657
}
5729
}
5658
*/
5730
*/
5659
5731
5732
// --begin-- Copy+ format string patch
5733
void appearance_copyplusformat_default_callback()
5734
{
5735
	gtk_entry_set_text(GTK_ENTRY(copyplusformat_entry),
5736
	  "<servername> | <ip>:<port> | <map> | <players>/<maxplayers> players");
5737
}
5738
// --end-- Copy+ format string patch
5739
5660
void game_file_dialog_ok_callback (GtkWidget *ok_button, gpointer data)
5740
void game_file_dialog_ok_callback (GtkWidget *ok_button, gpointer data)
5661
{
5741
{
5662
  enum server_type type;
5742
  enum server_type type;
(-)xqf-1.0.4.org/src/pref.h (+4 lines)
Lines 100-105 Link Here
100
extern	int	default_show_only_configured_games;
100
extern	int	default_show_only_configured_games;
101
extern  char*   default_icontheme;
101
extern  char*   default_icontheme;
102
102
103
// --begin-- Copy+ format string patch 
104
extern	char*	default_copyplusformat;
105
// --end-- Copy+ format string patch
106
103
extern	int	maxretries;
107
extern	int	maxretries;
104
extern	int	maxsimultaneous;
108
extern	int	maxsimultaneous;
105
extern  char*   qstat_srcip;
109
extern  char*   qstat_srcip;
(-)xqf-1.0.4.org/src/rc.c (+4 lines)
Lines 83-88 Link Here
83
  { "autofavorites", KEYWORD_BOOL,
83
  { "autofavorites", KEYWORD_BOOL,
84
    "/" CONFIG_FILE "/General/refresh favorites" },
84
    "/" CONFIG_FILE "/General/refresh favorites" },
85
85
86
  // --begin-- Copy+ format string patch 
87
  { "copyplusformat", KEYWORD_STRING, "/" CONFIG_FILE "/Appearance/copyplusformat" },
88
  // --end-- Copy+ format string patch 
89
86
  { "tb_style",	 KEYWORD_INT,	"/" CONFIG_FILE "/Appearance/toolbar style" },
90
  { "tb_style",	 KEYWORD_INT,	"/" CONFIG_FILE "/Appearance/toolbar style" },
87
  { "tb_tips",	 KEYWORD_BOOL,	"/" CONFIG_FILE "/Appearance/toolbar tips" },
91
  { "tb_tips",	 KEYWORD_BOOL,	"/" CONFIG_FILE "/Appearance/toolbar tips" },
88
92
(-)xqf-1.0.4.org/src/utils.c (+25 lines)
Lines 1159-1161 Link Here
1159
1159
1160
  return msg;
1160
  return msg;
1161
}
1161
}
1162
1163
int str_replace(char* result, int maxlen, const char* source, const char* pattern, const char* replacewith)
1164
{
1165
	char* p;
1166
	// we have to use a temporary buffer in case of result and source overlapping
1167
	char* wbuf;
1168
1169
	if( maxlen <= strlen(source)+(strlen(replacewith)-strlen(pattern)) ) {
1170
		return 1;
1171
	}
1172
	if( (p=strstr(source,pattern)) == NULL)
1173
		return 0;
1174
1175
	wbuf = malloc(maxlen);
1176
	wbuf[0]=0;
1177
	strncpy(wbuf, source, (p-source)+1);
1178
	wbuf[p-source]=0;
1179
	strcat(wbuf, replacewith);
1180
	p+=strlen(pattern);
1181
	strcat(wbuf, p);
1182
	strcpy(result, wbuf);
1183
    free(wbuf);
1184
1185
	return 0;
1186
}
(-)xqf-1.0.4.org/src/utils.h (+10 lines)
Lines 165-168 Link Here
165
 */
165
 */
166
const char* copy_file(const char* src, const char* dest);
166
const char* copy_file(const char* src, const char* dest);
167
167
168
/** replace a part of a string (used by for the copy+ format strings)
169
  @param output already allocated buffer for the result
170
  @param maxlen length of result buffer (including trailing zero)
171
  @param source original string
172
  @param pattern search for this pattern
173
  @param replacewith replace with this
174
  @return 0 on success, 1 on failure
175
 */
176
int str_replace(char* result, int maxlen, const char* source, const char* pattern, const char* replacewith);
177
168
#endif /* __UTILS_H__ */
178
#endif /* __UTILS_H__ */
(-)xqf-1.0.4.org/src/xqf.c (-4 / +32 lines)
Lines 1682-1691 Link Here
1682
static void copy_server_callback_plus (GtkWidget *widget, gpointer data) {
1682
static void copy_server_callback_plus (GtkWidget *widget, gpointer data) {
1683
  GList *selection = server_clist->selection;
1683
  GList *selection = server_clist->selection;
1684
  struct server *s;
1684
  struct server *s;
1685
  char buf[256];
1685
1686
  // possible overflow here? increased it a bit but that won't help much ;P
1687
  char buf[4096];
1686
  int pos = 0;
1688
  int pos = 0;
1687
  unsigned players;
1689
  unsigned players;
1688
1690
1691
  char str_ping[16];
1692
  char str_port[16];
1693
  char str_players[16];
1694
  char str_maxplayers[16];
1695
  char* formatstring;
1696
1689
  gtk_editable_delete_text (selection_manager, 0, -1);
1697
  gtk_editable_delete_text (selection_manager, 0, -1);
1690
1698
1691
  switch (g_list_length (selection)) {
1699
  switch (g_list_length (selection)) {
Lines 1700-1709 Link Here
1700
                                         server_clist, GPOINTER_TO_INT(selection->data));
1708
                                         server_clist, GPOINTER_TO_INT(selection->data));
1701
      players = s->curplayers;
1709
      players = s->curplayers;
1702
      if(serverlist_countbots && s->curbots <= players)
1710
      if(serverlist_countbots && s->curbots <= players)
1703
	players-=s->curbots;
1711
      players-=s->curbots;
1712
1713
      // --begin-- Copy+ format string patch 
1714
      formatstring = config_get_string_with_default("/" CONFIG_FILE "/Appearance/copyplusformat", NULL);
1715
      if(!formatstring) {
1716
        xqf_error("no formatstring defined");
1717
      }
1718
      sprintf(str_ping,"%i",s->ping);
1719
      sprintf(str_port,"%d",s->port);
1720
      sprintf(str_players, "%i", players);
1721
      sprintf(str_maxplayers, "%i", s->maxplayers);
1722
1723
      strcpy(buf, formatstring);
1724
      str_replace(buf, 4096, buf, "<ping>", str_ping);
1725
      str_replace(buf, 4096, buf, "<ip>", inet_ntoa(s->host->ip));
1726
      str_replace(buf, 4096, buf, "<port>", str_port);
1727
      str_replace(buf, 4096, buf, "<servername>", s->name);
1728
      str_replace(buf, 4096, buf, "<map>", s->map);
1729
      str_replace(buf, 4096, buf, "<players>", str_players);
1730
      str_replace(buf, 4096, buf, "<maxplayers>", str_maxplayers);
1731
      str_replace(buf, 4096, buf, "<game>", s->game);
1732
      str_replace(buf, 4096, buf, "<gametype>", s->gametype);
1733
      // --end-- Copy+ format string patch 
1704
1734
1705
      g_snprintf (buf, 256, "%i  %s:%d  %s  %s  %i of %i%s", s->ping, inet_ntoa
1706
       (s->host->ip), s->port, s->name, s->map, players, s->maxplayers, selection->next?"\n":"");
1707
      gtk_editable_insert_text (selection_manager, buf, strlen (buf), &pos);
1735
      gtk_editable_insert_text (selection_manager, buf, strlen (buf), &pos);
1708
    }
1736
    }
1709
    gtk_editable_select_region (selection_manager, 0, -1);
1737
    gtk_editable_select_region (selection_manager, 0, -1);

Return to bug 134581