Skip to content
This repository was archived by the owner on Mar 8, 2018. It is now read-only.

Commit d614181

Browse files
author
andreas99
committed
- UTF-8 support
- libpopt support
1 parent e48fe6e commit d614181

File tree

5 files changed

+97
-43
lines changed

5 files changed

+97
-43
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2003-11-16 AV <[email protected]>
2+
* configure.in: added support for libpopt
3+
4+
* src/gtkcompletionline.cc: added UTF-8 support for input and output
5+
6+
* src/main.cc: added UTF-8 support for input and output and
7+
added an option to place gmrun (-geometry)
8+
19
2002-06-05 EJ <[email protected]>
210

311
* src/history.cc (append): Previously, an item was not placed in

config.h.in

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
/* config.h.in. Generated from configure.in by autoheader. */
1+
/* config.h.in. Generated automatically from configure.in by autoheader. */
2+
3+
/* Define if you have the ANSI C header files. */
4+
#undef STDC_HEADERS
5+
26
#undef ENABLE_NLS
37
#undef HAVE_CATGETS
48
#undef HAVE_GETTEXT
@@ -9,41 +13,21 @@
913
#undef PACKAGE_DATA_DIR
1014
#undef PACKAGE_SOURCE_DIR
1115

12-
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
13-
*/
16+
/* Define if you have the <dirent.h> header file. */
1417
#undef HAVE_DIRENT_H
1518

16-
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
19+
/* Define if you have the <ndir.h> header file. */
1720
#undef HAVE_NDIR_H
1821

19-
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
20-
*/
22+
/* Define if you have the <sys/dir.h> header file. */
2123
#undef HAVE_SYS_DIR_H
2224

23-
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
24-
*/
25+
/* Define if you have the <sys/ndir.h> header file. */
2526
#undef HAVE_SYS_NDIR_H
2627

2728
/* Name of package */
2829
#undef PACKAGE
2930

30-
/* Define to the address where bug reports for this package should be sent. */
31-
#undef PACKAGE_BUGREPORT
32-
33-
/* Define to the full name of this package. */
34-
#undef PACKAGE_NAME
35-
36-
/* Define to the full name and version of this package. */
37-
#undef PACKAGE_STRING
38-
39-
/* Define to the one symbol short name of this package. */
40-
#undef PACKAGE_TARNAME
41-
42-
/* Define to the version of this package. */
43-
#undef PACKAGE_VERSION
44-
45-
/* Define to 1 if you have the ANSI C header files. */
46-
#undef STDC_HEADERS
47-
4831
/* Version number of package */
4932
#undef VERSION
33+

configure.in

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@ AC_HEADER_STDC
3939
AC_PROG_CXX
4040
AC_PATH_STLPORT_LIB
4141
AC_PATH_STLPORT_INC
42-
42+
43+
44+
AC_CHECK_FUNC( poptGetContext,
45+
,
46+
AC_CHECK_LIB(popt,
47+
poptGetContext,
48+
LIBS="${LIBS} -lpopt",
49+
echo "*** You need to get libpopt ***";exit
50+
)
51+
)
52+
4353
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.0.4
4454
gobject-2.0 >= 2.0.4
4555
gthread-2.0 >= 2.0.4)

src/gtkcompletionline.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*****************************************************************************
2-
* $Id: gtkcompletionline.cc,v 1.32 2003/11/16 10:43:32 andreas99 Exp $
2+
* $Id: gtkcompletionline.cc,v 1.33 2003/11/16 10:55:07 andreas99 Exp $
33
* Copyright (C) 2000, Mishoo
44
* Author: Mihai Bazon Email: [email protected]
55
*
@@ -214,7 +214,8 @@ void gtk_completion_line_last_history_item(GtkCompletionLine* object) {
214214
if (last_item) {
215215
object->hist->set_default("");
216216
const char* txt = object->hist->prev();
217-
gtk_entry_set_text(GTK_ENTRY(object), txt);
217+
gtk_entry_set_text(GTK_ENTRY(object),
218+
g_locale_to_utf8 (txt, -1, NULL, NULL, NULL));
218219
gtk_entry_select_region(GTK_ENTRY(object), 0, strlen(txt));
219220
}
220221
}
@@ -320,7 +321,8 @@ set_words(GtkCompletionLine *object, const vector<string>& words, int pos = -1)
320321
gtk_signal_emit_by_name(GTK_OBJECT(object), "ext_handler", NULL);
321322
}
322323

323-
gtk_entry_set_text(GTK_ENTRY(object), ss.str().c_str());
324+
gtk_entry_set_text(GTK_ENTRY(object),
325+
g_locale_to_utf8 (ss.str().c_str(), -1, NULL, NULL, NULL));
324326
gtk_editable_set_position(GTK_EDITABLE(object), where);
325327
return where;
326328
}
@@ -782,14 +784,16 @@ static void
782784
up_history(GtkCompletionLine* cl)
783785
{
784786
cl->hist->set_default(gtk_entry_get_text(GTK_ENTRY(cl)));
785-
gtk_entry_set_text(GTK_ENTRY(cl), cl->hist->prev());
787+
gtk_entry_set_text(GTK_ENTRY(cl),
788+
g_locale_to_utf8 (cl->hist->prev(), -1, NULL, NULL, NULL));
786789
}
787790

788791
static void
789792
down_history(GtkCompletionLine* cl)
790793
{
791794
cl->hist->set_default(gtk_entry_get_text(GTK_ENTRY(cl)));
792-
gtk_entry_set_text(GTK_ENTRY(cl), cl->hist->next());
795+
gtk_entry_set_text(GTK_ENTRY(cl),
796+
g_locale_to_utf8 (cl->hist->next(), -1, NULL, NULL, NULL));
793797
}
794798

795799
static int
@@ -813,7 +817,8 @@ search_back_history(GtkCompletionLine* cl, bool avance, bool begin)
813817
if (i != string::npos && !(begin && i != 0)) {
814818
const char *tmp = gtk_entry_get_text(GTK_ENTRY(cl));
815819
if (!(avance && strcmp(tmp, histext) == 0)) {
816-
gtk_entry_set_text(GTK_ENTRY(cl), histext);
820+
gtk_entry_set_text(GTK_ENTRY(cl),
821+
g_locale_to_utf8 (histext, -1, NULL, NULL, NULL));
817822
gtk_entry_select_region(GTK_ENTRY(cl),
818823
i, i + cl->hist_word->length());
819824
gtk_signal_emit_by_name(GTK_OBJECT(cl), "search_letter");
@@ -855,7 +860,8 @@ search_forward_history(GtkCompletionLine* cl, bool avance, bool begin)
855860
if (i != string::npos && !(begin && i != 0)) {
856861
const char *tmp = gtk_entry_get_text(GTK_ENTRY(cl));
857862
if (!(avance && strcmp(tmp, histext) == 0)) {
858-
gtk_entry_set_text(GTK_ENTRY(cl), histext);
863+
gtk_entry_set_text(GTK_ENTRY(cl),
864+
g_locale_to_utf8 (histext, -1, NULL, NULL, NULL));
859865
gtk_entry_select_region(GTK_ENTRY(cl),
860866
i, i + cl->hist_word->length());
861867
gtk_signal_emit_by_name(GTK_OBJECT(cl), "search_letter");

src/main.cc

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*****************************************************************************
2-
* $Id: main.cc,v 1.25 2003/11/16 10:43:32 andreas99 Exp $
2+
* $Id: main.cc,v 1.26 2003/11/16 10:55:07 andreas99 Exp $
33
* Copyright (C) 2000, Mishoo
44
* Author: Mihai Bazon Email: [email protected]
55
*
@@ -19,6 +19,8 @@
1919
#include <vector>
2020
#include <algorithm>
2121
#include <iterator>
22+
#include <popt.h>
23+
2224
using namespace std;
2325

2426
#ifdef MTRACE
@@ -155,7 +157,7 @@ run_the_command(const std::string& command, struct gigi* g)
155157
{
156158
string prog;
157159
std::vector<char*> argv;
158-
160+
159161
string cmd = command + ' ';
160162
istringstream iss(cmd);
161163
#ifdef DEBUG
@@ -277,7 +279,11 @@ on_ext_handler(GtkCompletionLine *cl, const char* ext, struct gigi* g)
277279
static void
278280
on_compline_runwithterm(GtkCompletionLine *cl, struct gigi* g)
279281
{
280-
string command(gtk_entry_get_text(GTK_ENTRY(cl)));
282+
string command(g_locale_from_utf8 (gtk_entry_get_text(GTK_ENTRY(cl)),
283+
-1,
284+
NULL,
285+
NULL,
286+
NULL));
281287
string tmp;
282288
string term;
283289

@@ -381,7 +387,12 @@ on_search_not_found(GtkCompletionLine *cl, struct gigi *g)
381387
static bool
382388
url_check(GtkCompletionLine *cl, struct gigi *g)
383389
{
384-
string text(gtk_entry_get_text(GTK_ENTRY(cl)));
390+
string text(g_locale_from_utf8 (gtk_entry_get_text(GTK_ENTRY(cl)),
391+
-1,
392+
NULL,
393+
NULL,
394+
NULL));
395+
385396
string::size_type i;
386397
string::size_type sp;
387398

@@ -478,7 +489,12 @@ on_compline_activated(GtkCompletionLine *cl, struct gigi *g)
478489
if (ext_check(cl, g))
479490
return;
480491

481-
string command = gtk_entry_get_text(GTK_ENTRY(cl));
492+
string command = g_locale_from_utf8 (gtk_entry_get_text(GTK_ENTRY(cl)),
493+
-1,
494+
NULL,
495+
NULL,
496+
NULL);
497+
482498
string::size_type i;
483499
i = command.find_first_not_of(" \t");
484500

@@ -512,7 +528,7 @@ int main(int argc, char **argv)
512528
GtkWidget *compline;
513529
GtkWidget *label_search;
514530
struct gigi g;
515-
531+
516532
#ifdef MTRACE
517533
mtrace();
518534
#endif
@@ -604,12 +620,42 @@ int main(int argc, char **argv)
604620
}
605621

606622
gtk_box_pack_start(GTK_BOX(hbox), compline, TRUE, TRUE, 0);
607-
623+
608624
int prefs_top = 80;
609625
int prefs_left = 100;
610626
configuration.get_int("Top", prefs_top);
611-
configuration.get_int("Left", prefs_left);
612-
gtk_widget_set_uposition(win, prefs_left, prefs_top);
627+
configuration.get_int("Left", prefs_left);
628+
629+
// parse commandline options
630+
gboolean geo_parsed;
631+
char geo_option[30] = "";
632+
char *geoptr;
633+
poptContext context;
634+
int option;
635+
636+
geoptr = geo_option;
637+
638+
struct poptOption options[] = {
639+
{ "geometry", 'g', POPT_ARG_STRING | POPT_ARGFLAG_ONEDASH,
640+
&geoptr, 0, "This option specifies the initial "
641+
"size and location of the window.", NULL },
642+
POPT_AUTOHELP
643+
{ NULL, '\0', 0, NULL, 0 }
644+
};
645+
646+
context = poptGetContext("popt1", argc, (const char**) argv, options, 0);
647+
option = poptGetNextOpt (context);
648+
649+
if (strcmp (geoptr, ""))
650+
{
651+
geo_parsed = gtk_window_parse_geometry (GTK_WINDOW (win),
652+
geoptr);
653+
}
654+
else
655+
{
656+
gtk_widget_set_uposition(win, prefs_left, prefs_top);
657+
}
658+
613659
gtk_widget_show(win);
614660

615661
gtk_window_set_focus(GTK_WINDOW(win), compline);

0 commit comments

Comments
 (0)