?

Log in

No account? Create an account
getmenus - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

getmenus [Feb. 12th, 2002|03:39 pm]
LiveJournal Client Discussions

lj_clients

[reflexion]
Without a currently-in-development client of my own to test it on, can anyone give me some information on the getmenus item in the login mode?

Or, specifically, what "menus" are being returned by the menu_menunum_itemnum_text (and _url, et. al.) values?

I apologise if there's already more information than what's available in the login mode documentation; it was all I could find.
linkReply

Comments:
From: evan
2002-02-12 06:56 am (UTC)
menu_0_10_text
Support
menu_0_10_url
http://www.livejournal.com/support/
menu_0_1_text
Recent Entries
menu_0_1_url
http://www.livejournal.com/users/evan/
menu_0_2_text
Calendar View
menu_0_2_url
http://www.livejournal.com/users/evan/calendar
menu_0_3_text
Friends View
menu_0_3_url
http://www.livejournal.com/users/evan/friends
menu_0_4_text
-
menu_0_5_text
Your Profile
menu_0_5_url
http://www.livejournal.com/userinfo.bml?user=evan
menu_0_6_text
Your To-Do List
menu_0_6_url
http://www.livejournal.com/todo/?user=evan
menu_0_7_text
-
menu_0_8_sub
1
menu_0_8_text
Change Settings
menu_0_9_text
-
menu_0_count
10
menu_1_1_text
Personal Info
menu_1_1_url
http://www.livejournal.com/editinfo.bml
menu_1_2_text
Journal Settings
menu_1_2_url
http://www.livejournal.com/modify.bml
menu_1_count
2

But don't depend on that structure.
What about the documentation confuses you? I managed to write my implementation of it (the first one, 'cause I was talking to Brad while he was writing the server end) just from reading the documentation...

Here's some code:
	for (i = 1; i < count+1; i++) {
		sprintf(buf, "menu_%d_%d_text", base, i);
		text = g_hash_table_lookup(hash, buf);
		if (text == NULL) {
			g_warning("menu item has no text?");
			continue;
		}

		sprintf(buf, "menu_%d_%d_url", base, i);
		url = g_hash_table_lookup(hash, buf);
		sprintf(buf, "menu_%d_%d_sub", base, i);
		sub = g_hash_table_lookup(hash, buf);

		if (text[0] == '-' && text[1] == 0) {
			/* separator */
			item = gtk_menu_item_new();
			gtk_menu_append(GTK_MENU(menu), item);
		} else if (url != NULL) {
			/* url menu item */
			GtkWidget *hbox;
			hbox = gtk_hbox_new(FALSE, 0);
			gtk_box_pack_start(GTK_BOX(hbox),
					gtk_label_new(text),
					FALSE, FALSE, 0);
			gtk_box_pack_end(GTK_BOX(hbox),
					gtk_image_new_from_stock(LOGJAM_WEB, GTK_ICON_SIZE_MENU),
					FALSE, FALSE, 0);

			item = gtk_menu_item_new();
			gtk_container_add(GTK_CONTAINER(item), hbox);

			dupstr = g_strdup(url);
			g_signal_connect_swapped(G_OBJECT(item), "activate",
					G_CALLBACK(spawn_url), dupstr);
			/* free the dup'd string after the menu item is destroyed! */
			g_signal_connect_swapped(G_OBJECT(item), "destroy",
					G_CALLBACK(g_free), dupstr);
			/* that GtkObject* cast is GTK hackery */
			gtk_menu_append(GTK_MENU(menu), item);
		} else if (sub != NULL) {
			/* submenu ! */
			GtkWidget *submenu;
			int subbase;

			subbase = atoi(sub);
			item = gtk_menu_item_new_with_mnemonic(text);
			submenu = web_recurse(hash, subbase);
			gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
			gtk_menu_append(GTK_MENU(menu), item);
		} else {
			g_warning("unknown menu item type...");
		}
	}
(Reply) (Thread)
From: evan
2002-02-12 07:05 am (UTC)
(I didn't mean to sound like a jerk about the "what confuses you" bit; rather, I want to know how to improve the documentation. :P)
(Reply) (Parent) (Thread)
[User Picture]From: reflexion
2002-02-14 03:36 am (UTC)

I get it...

Well, I have to admit to assuming you weren't being a jerk; the idea hadn't even occurred to me until you suggested it. :P

It wasn't really the client-side aspect of the menus that was confusing. (I understood the protocol documentation as it applies to client-side handling of the menus, and the structure of how those menus are given. (Obviously, your code helps. :P))

But what I couldn't find was anything specifying what menus will be returned. From your example I see that it's things like links to "your" settings, friends page, userinfo, etc. But since you say "Don't depend on that structure", I'm assuming this is a currently-undocumented aspect of the protocol.

The only reason I ask, is because if I was developing a client (which I'm not; but I'm toying with the idea again :P) I would want to include menu/toolbar-based links to similar things. But if using the menus given to the client by LJ will do that anyway, it seems to me that that would be the "right" way to implement it.

Thanks for your help. :)
(Reply) (Parent) (Thread)
From: evan
2002-02-14 10:56 am (UTC)

Re: I get it...

The idea is for the client not to make any links to within the LiveJournal site. In LogJam, I made an in-client feature which forwards your web browser to the page of the post you're currently viewing, and now that there's the new clustering code that function doesn't work anymore.

Instead, the server provides all of the relevant links to the client. The client can't know anything about the links the server is providing because we want to be able change URLs or functionality at any time without worrying about the consequences on the clients.

(For example, LogJam's comment-linking feature also broke as soon as we released the LJ code, because people were running alternate servers and LogJam was assuming all links would be to livejournal.com. I've since worked around that by using the URL of the server you connected to, but that's not a good solution.)

So yeah, you should treat the menus as a black box, and just create them as they're sent to you from the server.
(Reply) (Parent) (Thread)
[User Picture]From: reflexion
2002-02-15 12:55 am (UTC)

Re: I get it...

Okay, so this is the "right" way to do it. Thanks for that.


(Reply) (Parent) (Thread)