LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2004, 04:06 PM   #1
r_jensen11
Senior Member
 
Registered: Apr 2003
Location: Minnesota, USA
Distribution: Slack 10.0 w/2.4.26
Posts: 1,032

Rep: Reputation: 45
Dialog box scripting....


I was curious, anyone have a nice way of creating a script that opens a dialog box? I'm in favor of the dialog boxes where you're given buttons, but I suppose radio buttons work as well. I'm just curious, because I'd like to know how to make a simple one for poweroff menus, without having to download and install other programs(so I can just keep it in my /home partition if I ever reformat, and it'll be safe.)

Edit: This is also supposed to run in X.

Last edited by r_jensen11; 01-25-2004 at 04:07 PM.
 
Old 01-25-2004, 06:35 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Well, you pretty much have to write a program using one of the gui libraries to pull that off.
 
Old 01-25-2004, 06:40 PM   #3
r_jensen11
Senior Member
 
Registered: Apr 2003
Location: Minnesota, USA
Distribution: Slack 10.0 w/2.4.26
Posts: 1,032

Original Poster
Rep: Reputation: 45
Okay, I'm getting introduced to glade-2, but I'm running into troubles.

I have my gui all laid out how I want the buttons to look, etc. But beyond that, I'm lost. I've searched for some tutorials for basic dialoge boxes, but I can't really follow them, for some reason.

Here's my power-menu.glade file:
Code:
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkDialog" id="dialog1">
  <property name="width_request">300</property>
  <property name="height_request">75</property>
  <property name="visible">True</property>
  <property name="title" translatable="yes">Shut Down</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="has_separator">True</property>

  <child internal-child="vbox">
    <widget class="GtkVBox" id="dialog-vbox1">
      <property name="visible">True</property>
      <property name="homogeneous">False</property>
      <property name="spacing">0</property>

      <child internal-child="action_area">
	<widget class="GtkHButtonBox" id="dialog-action_area1">
	  <property name="height_request">35</property>
	  <property name="visible">True</property>
	  <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>

	  <child>
	    <widget class="GtkButton" id="poweroff">
	      <property name="border_width">3</property>
	      <property name="width_request">90</property>
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="response_id">2</property>

	      <child>
		<widget class="GtkAlignment" id="alignment2">
		  <property name="border_width">3</property>
		  <property name="visible">True</property>
		  <property name="xalign">0.5</property>
		  <property name="yalign">0.5</property>
		  <property name="xscale">0</property>
		  <property name="yscale">0</property>

		  <child>
		    <widget class="GtkHBox" id="hbox2">
		      <property name="visible">True</property>
		      <property name="homogeneous">False</property>
		      <property name="spacing">2</property>

		      <child>
			<widget class="GtkImage" id="image2">
			  <property name="visible">True</property>
			  <property name="stock">gtk-stop</property>
			  <property name="icon_size">4</property>
			  <property name="xalign">0.5</property>
			  <property name="yalign">0.5</property>
			  <property name="xpad">0</property>
			  <property name="ypad">0</property>
			</widget>
			<packing>
			  <property name="padding">0</property>
			  <property name="expand">False</property>
			  <property name="fill">False</property>
			</packing>
		      </child>

		      <child>
			<widget class="GtkLabel" id="label3">
			  <property name="visible">True</property>
			  <property name="label" translatable="yes">Poweroff</property>
			  <property name="use_underline">True</property>
			  <property name="use_markup">False</property>
			  <property name="justify">GTK_JUSTIFY_LEFT</property>
			  <property name="wrap">False</property>
			  <property name="selectable">False</property>
			  <property name="xalign">0.5</property>
			  <property name="yalign">0.5</property>
			  <property name="xpad">0</property>
			  <property name="ypad">0</property>
			</widget>
			<packing>
			  <property name="padding">0</property>
			  <property name="expand">False</property>
			  <property name="fill">False</property>
			</packing>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>
	    </widget>
	  </child>

	  <child>
	    <widget class="GtkButton" id="reboot">
	      <property name="border_width">3</property>
	      <property name="width_request">90</property>
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="response_id">3</property>

	      <child>
		<widget class="GtkAlignment" id="alignment3">
		  <property name="border_width">3</property>
		  <property name="width_request">80</property>
		  <property name="visible">True</property>
		  <property name="xalign">0.5</property>
		  <property name="yalign">0.5</property>
		  <property name="xscale">0</property>
		  <property name="yscale">0</property>

		  <child>
		    <widget class="GtkHBox" id="hbox3">
		      <property name="visible">True</property>
		      <property name="homogeneous">False</property>
		      <property name="spacing">2</property>

		      <child>
			<widget class="GtkImage" id="image3">
			  <property name="visible">True</property>
			  <property name="stock">gtk-refresh</property>
			  <property name="icon_size">4</property>
			  <property name="xalign">0.5</property>
			  <property name="yalign">0.5</property>
			  <property name="xpad">0</property>
			  <property name="ypad">0</property>
			</widget>
			<packing>
			  <property name="padding">0</property>
			  <property name="expand">False</property>
			  <property name="fill">False</property>
			</packing>
		      </child>

		      <child>
			<widget class="GtkLabel" id="label4">
			  <property name="visible">True</property>
			  <property name="label" translatable="yes">Reboot</property>
			  <property name="use_underline">True</property>
			  <property name="use_markup">False</property>
			  <property name="justify">GTK_JUSTIFY_LEFT</property>
			  <property name="wrap">False</property>
			  <property name="selectable">False</property>
			  <property name="xalign">0.5</property>
			  <property name="yalign">0.5</property>
			  <property name="xpad">0</property>
			  <property name="ypad">0</property>
			</widget>
			<packing>
			  <property name="padding">0</property>
			  <property name="expand">False</property>
			  <property name="fill">False</property>
			</packing>
		      </child>
		    </widget>
		  </child>
		</widget>
	      </child>
	    </widget>
	  </child>

	  <child>
	    <widget class="GtkButton" id="cancel">
	      <property name="border_width">3</property>
	      <property name="width_request">90</property>
	      <property name="visible">True</property>
	      <property name="can_default">True</property>
	      <property name="can_focus">True</property>
	      <property name="label">gtk-cancel</property>
	      <property name="use_stock">True</property>
	      <property name="relief">GTK_RELIEF_NORMAL</property>
	      <property name="response_id">-6</property>
	    </widget>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">False</property>
	  <property name="fill">True</property>
	  <property name="pack_type">GTK_PACK_END</property>
	</packing>
      </child>

      <child>
	<widget class="GtkVPaned" id="vpaned1">
	  <property name="width_request">60</property>
	  <property name="height_request">60</property>
	  <property name="sensitive">False</property>
	  <property name="can_focus">True</property>
	  <property name="position">30</property>

	  <child>
	    <widget class="GtkLabel" id="label">
	      <property name="width_request">60</property>
	      <property name="height_request">20</property>
	      <property name="visible">True</property>
	      <property name="sensitive">False</property>
	      <property name="label" translatable="yes">Shut Down</property>
	      <property name="use_underline">False</property>
	      <property name="use_markup">False</property>
	      <property name="justify">GTK_JUSTIFY_CENTER</property>
	      <property name="wrap">False</property>
	      <property name="selectable">False</property>
	      <property name="xalign">0.5</property>
	      <property name="yalign">0.5</property>
	      <property name="xpad">0</property>
	      <property name="ypad">0</property>
	    </widget>
	    <packing>
	      <property name="shrink">False</property>
	      <property name="resize">False</property>
	    </packing>
	  </child>

	  <child>
	    <placeholder/>
	  </child>
	</widget>
	<packing>
	  <property name="padding">0</property>
	  <property name="expand">True</property>
	  <property name="fill">True</property>
	</packing>
      </child>
    </widget>
  </child>
</widget>

</glade-interface>
If anyone could help me out at all by linking each button with a command(Power off goes to halt -n, reboot goes to halt -r, cancel closes the program), it would be greatly appreciated.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dialog box help!!!!!!!! HopelessLinuxNewbie Fedora 1 08-24-2005 11:48 AM
bash scripting: dialog --inputbox chibiace Linux - Newbie 1 11-08-2004 10:22 PM
Garbled Dialog Box on Red Hat 8 boot. eNergiZer Linux - Newbie 3 12-16-2003 09:23 PM
How to get Open-With dialog box back again? AskMe Linux - Newbie 2 10-25-2003 11:13 AM
Creating an x windows dialog box antken Programming 5 09-29-2003 01:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration